提交代码

dev-discount
胡锐 3 years ago
parent 13a9cff968
commit 84c860b06d
  1. 21
      hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java
  2. 1
      hai-cweb/src/main/java/com/cweb/config/AuthConfig.java
  3. 30
      hai-cweb/src/main/java/com/cweb/controller/HighCouponAgentController.java
  4. 7
      hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java
  5. 4
      hai-service/src/main/java/com/hai/service/HighCouponAgentService.java
  6. 39
      hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java

@ -80,6 +80,27 @@ public class HighCouponAgentController {
}
}
@RequestMapping(value = "/getAgentConvertCodeCount", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "代理商兑换码统计")
public ResponseData getAgentConvertCodeCount(HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (userInfoModel.getHighAgent() == null) {
log.error("HighCouponAgentController -> assignCouponAgent() error!","该主角色没有权限");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, "");
}
return ResponseMsgUtil.success(highCouponAgentService.getConvertCodeCountByAgent(userInfoModel.getHighAgent().getId()));
} catch (Exception e) {
log.error("HighCouponAgentController --> getCodeById() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getAgentSalesCodeList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询代理商已销售的卡券")

@ -94,6 +94,7 @@ public class AuthConfig implements WebMvcConfigurer {
.excludePathPatterns("/coupon/getCouponList")
.excludePathPatterns("/wechatpay/*")
.excludePathPatterns("/couponAgent/useConvertCode")
.excludePathPatterns("/couponAgent/convertCodeDetail")
.excludePathPatterns("/coupon/getCouponById")
.excludePathPatterns("/discount/getDiscountByQrCode")
.excludePathPatterns("/discount/getDiscountById")

@ -44,6 +44,12 @@ public class HighCouponAgentController {
@Resource
private HighCouponAgentService highCouponAgentService;
@Resource
private HighCouponService highCouponService;
@Resource
private HighCouponCodeService highCouponCodeService;
@RequestMapping(value = "/useConvertCode", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "兑换码使用")
@ -80,5 +86,29 @@ public class HighCouponAgentController {
}
}
@RequestMapping(value = "/convertCodeDetail", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "兑换码详情")
public ResponseData convertCodeDetail(@RequestParam(name = "code", required = true) String code) {
try {
// 查询兑换码
HighCouponAgentCode couponAgentCode = highCouponAgentService.getConvertCode(code);
if (couponAgentCode == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到销售码");
}
Map<String, Object> map = new HashMap<>();
map.put("couponInfo", highCouponService.getCouponById(couponAgentCode.getCouponId()));
map.put("couponCode", highCouponCodeService.getCouponCodeById(couponAgentCode.getCouponCodeId()));
map.put("couponAgentCode", couponAgentCode);
return ResponseMsgUtil.success(map);
} catch (Exception e) {
log.error("HighCouponAgentController --> getConvertCodeDetail() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -25,7 +25,7 @@ public interface HighCouponAgentRelMapperExt {
AgentSalesModel getAgentSales(@Param("agentId") Long agentId, @Param("consumeTimeS")String consumeTimeS, @Param("consumeTimeE")String consumeTimeE);
@Select(" select a.* from high_coupon_agent_code a,high_coupon_code b,high_coupon_agent_rel c " +
" where c.id = a.coupon_agent_id and c.agent_id = #{agentId} and a.status = 3 and a.coupon_code_id = b.id " +
" where c.id = a.coupon_agent_id and c.agent_id = #{agentId} and b.`status` = 3 and a.coupon_code_id = b.id " +
" and b.consume_time >= #{consumeTimeS} and b.consume_time <= #{consumeTimeE} ORDER BY b.consume_time desc")
@Results({
@Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true),
@ -49,4 +49,9 @@ public interface HighCouponAgentRelMapperExt {
@Select(" select count(1) from high_coupon_agent_code a where a.agent_id = #{agentId} and a.`status` in (${status}) and a.type = #{type} ")
Integer getAgentCodeCount(@Param("agentId") Long agentId,@Param("status") String status,@Param("type") Integer type);
@Select(" select sum(b.sales_price) from high_coupon_agent_code a " +
" LEFT JOIN high_coupon_agent_rel b on b.id = a.coupon_agent_id " +
" where a.agent_id = #{agentId} and a.`status` in (${status}) and a.type = #{type} ")
Integer getAgentCodePrice(@Param("agentId") Long agentId,@Param("status") String status,@Param("type") Integer type);
}

@ -80,6 +80,8 @@ public interface HighCouponAgentService {
**/
Map<String, Object> getSalesCountByAgent(Long agentId, Integer type) throws Exception;
Map<String, Object> getConvertCodeCountByAgent(Long agentId);
/**
*
* @param map
@ -123,6 +125,6 @@ public interface HighCouponAgentService {
* @param code
* @return
*/
String useConvertCode(String code);
Map<String, Object> useConvertCode(String code);
}

@ -311,6 +311,34 @@ 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);
List<HighCouponAgentRel> list = getCouponAgentList(listMap).stream().sorted(Comparator.comparing(HighCouponAgentRel::getSalesPrice)).collect(Collectors.toList());
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 +401,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) {
@ -395,9 +423,14 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
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;
}
}

Loading…
Cancel
Save