|
|
|
@ -311,6 +311,43 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { |
|
|
|
|
return returnMap; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Map<String, Object> getConvertCodeCountByAgent(Long agentId) { |
|
|
|
|
Map<String,Object> listMap = new HashMap<>(); |
|
|
|
|
listMap.put("agentId", agentId); |
|
|
|
|
listMap.put("type", 2); |
|
|
|
|
List<HighCouponAgentRel> list = getCouponAgentList(listMap).stream().sorted(Comparator.comparing(HighCouponAgentRel::getSalesPrice)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
for (HighCouponAgentRel couponAgentRel : list) { |
|
|
|
|
Map<String, Object> map = highCouponAgentRelMapper.getUseNum(couponAgentRel.getId()); |
|
|
|
|
couponAgentRel.setUsedNum(MapUtils.getInteger(map, "usedNum")); |
|
|
|
|
couponAgentRel.setUsedPrice(new BigDecimal(MapUtils.getString(map, "usedPrice"))); |
|
|
|
|
couponAgentRel.setNoUsedNum(MapUtils.getInteger(map, "noUsedNum")); |
|
|
|
|
couponAgentRel.setNoUsedPrice(new BigDecimal(MapUtils.getString(map, "noUsedPrice"))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Map<String, Object> returnMap = new HashMap<>(); |
|
|
|
|
returnMap.put("list", list); |
|
|
|
|
|
|
|
|
|
// 待销售
|
|
|
|
|
returnMap.put("noSalesNum", highCouponAgentRelMapper.getAgentCodeCount(agentId, "1", 2)); |
|
|
|
|
returnMap.put("noSalesPrice", highCouponAgentRelMapper.getAgentCodePrice(agentId, "1", 2)); |
|
|
|
|
|
|
|
|
|
// 已销售
|
|
|
|
|
returnMap.put("salesNum", highCouponAgentRelMapper.getAgentCodeCount(agentId, "2", 2)); |
|
|
|
|
returnMap.put("salesPrice", highCouponAgentRelMapper.getAgentCodePrice(agentId, "2", 2)); |
|
|
|
|
|
|
|
|
|
// 待使用
|
|
|
|
|
returnMap.put("noUsedNum", highCouponAgentRelMapper.getAgentCodeCount(agentId, "2", 2)); |
|
|
|
|
returnMap.put("noUsedPrice", highCouponAgentRelMapper.getAgentCodePrice(agentId, "2", 2)); |
|
|
|
|
|
|
|
|
|
// 已使用
|
|
|
|
|
returnMap.put("usedNum", highCouponAgentRelMapper.getAgentCodeCount(agentId, "3", 2)); |
|
|
|
|
returnMap.put("usedPrice", highCouponAgentRelMapper.getAgentCodePrice(agentId, "3", 2)); |
|
|
|
|
|
|
|
|
|
return returnMap; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<HighCouponAgentRecord> getRecordList(Map<String, Object> map) { |
|
|
|
|
HighCouponAgentRecordExample example = new HighCouponAgentRecordExample(); |
|
|
|
@ -373,7 +410,7 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(propagation= Propagation.REQUIRES_NEW,isolation= Isolation.SERIALIZABLE) |
|
|
|
|
public String useConvertCode(String code) { |
|
|
|
|
public Map<String, Object> useConvertCode(String code) { |
|
|
|
|
// 查询兑换码
|
|
|
|
|
HighCouponAgentCode convertCode = getConvertCode(code); |
|
|
|
|
if (convertCode == null) { |
|
|
|
@ -382,19 +419,32 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { |
|
|
|
|
if (convertCode.getStatus() == 3) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "兑换码已被使用"); |
|
|
|
|
} |
|
|
|
|
if (convertCode.getCouponCodeId() != null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "兑换码已被使用"); |
|
|
|
|
} |
|
|
|
|
// 查询未销售的卡券
|
|
|
|
|
List<HighCouponCode> codeList = highCouponCodeService.getNoSaleCode(convertCode.getCouponId()); |
|
|
|
|
if (codeList.size() == 0) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法使用兑换码"); |
|
|
|
|
} |
|
|
|
|
HighCouponCode couponCode = codeList.get(0); |
|
|
|
|
couponCode.setIsAssignAgent(true); |
|
|
|
|
couponCode.setAgentId(couponCode.getAgentId()); |
|
|
|
|
couponCode.setReceiveTime(new Date()); |
|
|
|
|
couponCode.setStatus(2); |
|
|
|
|
highCouponCodeService.updateCouponCode(couponCode); |
|
|
|
|
|
|
|
|
|
convertCode.setCouponCodeId(couponCode.getId()); |
|
|
|
|
convertCode.setCouponCode(couponCode.getSalesCode()); |
|
|
|
|
convertCode.setQrCode(couponCode.getExt1()); |
|
|
|
|
convertCode.setStatus(2); |
|
|
|
|
convertCode.setStatus(3); |
|
|
|
|
highCouponAgentCodeMapper.updateByPrimaryKey(convertCode); |
|
|
|
|
|
|
|
|
|
return "/couponCode/"+couponCode.getExt1(); |
|
|
|
|
// 查询卡券销售码
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("couponInfo", highCouponService.getCouponById(convertCode.getCouponId())); |
|
|
|
|
map.put("couponCode", highCouponCodeService.getCouponCodeById(convertCode.getCouponCodeId())); |
|
|
|
|
map.put("couponAgentCode", convertCode); |
|
|
|
|
return map; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|