dev-discount
胡锐 4 years ago
commit 4ae4ee33f6
  1. 4
      hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java
  2. 4
      hai-bweb/src/main/java/com/bweb/controller/HighDiscountController.java
  3. 6
      hai-bweb/src/main/java/com/bweb/controller/HighDiscountCouponRelController.java
  4. 17
      hai-bweb/src/main/java/com/bweb/controller/LoginController.java
  5. 18
      hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java
  6. 2
      hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java
  7. 2
      hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java
  8. 2
      hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java
  9. 2
      hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java
  10. 3
      hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java
  11. 2
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java

@ -97,7 +97,7 @@ public class HighDiscountAgentRelController {
// 是否已分配
if (highDiscountAgentRelService.getRelByDiscountAgent(highDiscountAgentRel.getDiscountId(), highDiscountAgentRel.getAgentId()) != null) {
log.error("HighDiscountAgentRelController -> insertDiscountAgent() error!", discount.getDiscountName() + "重复分配给" + agent.getAgentName());
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, discount.getDiscountName() + "重复分配给" + agent.getAgentName());
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, discount.getDiscountName() + "重复分配给" + agent.getAgentName());
}
highDiscountAgentRel.setCreateTime(new Date());
highDiscountAgentRel.setStatus(1);
@ -110,7 +110,7 @@ public class HighDiscountAgentRelController {
//参数
Map<String, Object> map = new HashMap<>();
map.put("type", QrCodeType.AGENT_QR_CODE);
map.put("code", AESEncodeUtil.aesEncrypt(Base64Util.encode(highDiscountAgentRel.getId().toString())));
map.put("code", Base64Util.encode(AESEncodeUtil.aesEncrypt(highDiscountAgentRel.getId().toString())));
QRCodeGenerator.generateQRCodeImage(JSON.toJSONString(map), 350, 350, qrCodeUrl);
highDiscountAgentRel.setQrCode(qrCodeImg);
highDiscountAgentRelService.updateDiscountAgentRel(highDiscountAgentRel);

@ -112,7 +112,6 @@ public class HighDiscountController {
if (highDiscount.getId() == null
|| StringUtils.isBlank(highDiscount.getDiscountName())
|| StringUtils.isBlank(highDiscount.getDiscountImg())
|| StringUtils.isBlank(highDiscount.getDiscountCarouselImg())
|| highDiscount.getEffectiveDay() == null
|| highDiscount.getSalesEndTime() == null) {
log.error("HighDiscountController -> updateDiscount() error!","参数错误");
@ -148,7 +147,7 @@ public class HighDiscountController {
}
@RequestMapping(value="/updateDiscountStatus",method = RequestMethod.POST)
@RequestMapping(value="/updateDiscountStatus",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "修改优惠券状态")
public ResponseData updateDiscountStatus(@RequestParam(name = "discountId", required = true) Long discountId,
@ -187,6 +186,7 @@ public class HighDiscountController {
@RequestMapping(value="/getDiscountList",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询优惠券列表")
public ResponseData getDiscountList(@RequestParam(name = "discountKey", required = false) String discountKey,
@RequestParam(name = "discountName", required = false) String discountName,

@ -49,7 +49,7 @@ public class HighDiscountCouponRelController {
try {
JSONObject jsonObject = JSONObject.parseObject(reqBody);
Long discountId = jsonObject.getLong("discountId");
String couponIdStr = jsonObject.getString("couponId");
String couponIdStr = jsonObject.getString("couponIdStr");
if (discountId == null || StringUtils.isBlank(couponIdStr)) {
log.error("HighDiscountCouponRelController -> insertDiscountCoupon() error!","参数错误");
@ -110,9 +110,9 @@ public class HighDiscountCouponRelController {
}
}
@RequestMapping(value="/insertDiscount",method = RequestMethod.GET)
@RequestMapping(value="/getRelByDiscount",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据卡卷 查询关联卡券")
@ApiOperation(value = "根据优惠券 查询关联卡券")
public ResponseData getRelByDiscount(@RequestParam(name = "discountId", required = true) Long discountId) {
try {

@ -60,6 +60,9 @@ public class LoginController {
@Resource
private SecPermissionService secPermissionService;
@Resource
private HighAgentService highAgentService;
@RequestMapping(value="/userLogin",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "机构用户登录({'loginName':'','password':''})")
@ -156,6 +159,20 @@ public class LoginController {
}
userInfoModel.setMerchantStore(merchantStore);
} else if (secUser.getObjectType() == 4) {
// 查询门店
HighAgent highAgent = highAgentService.findByAgentMsgId(secUser.getObjectId());
if(highAgent == null){
log.error("login error!","未找到代理商");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_AGENT, "");
}
if(highAgent.getStatus() != 1) {
log.error("login error!","未找到代理商");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_AGENT, "");
}
userInfoModel.setHighAgent(highAgent);
} else {
log.error("login error!","用户信息错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, "");

@ -98,8 +98,12 @@ public class HighOrderController {
log.error("HighOrderController --> addOrder() error!", "未找到卡卷信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, "");
}
// 校验优惠券是否可用
// 是否达到限购数量
if (highCouponService.userBuyLimitNumber(userInfoModel.getHighUser().getId(), coupon.getId()) == true) {
log.error("HighOrderController --> addOrder() error!", "已达到限购数量");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + ",已达到限购数量");
}
// 校验优惠券是否可用 如果使用优惠券就只能使用卡券的原价
if (highOrder.getMemDiscountId() != null) {
List<HighDiscountCouponRel> discountCouponRelList = highDiscountCouponRelService.getRelByCoupon(coupon.getId());
if (discountCouponRelList.size() > 0) {
@ -109,14 +113,11 @@ public class HighOrderController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法使用优惠券");
}
}
childOrder.setGoodsPrice(coupon.getSalesPrice());
} else {
childOrder.setGoodsPrice(coupon.getDiscountPrice());
}
// 是否到底限购数量
if (highCouponService.userBuyLimitNumber(userInfoModel.getHighUser().getId(), coupon.getId()) == true) {
log.error("HighOrderController --> addOrder() error!", "已达到限购数量");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + ",已达到限购数量");
}
if (highCouponCodeService.getStockCountByCoupon(coupon.getId()) <= 0) {
log.error("HighOrderController --> addOrder() error!", "卡卷库存数量不足");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COUPON_STOCK_INSUFFICIENT, "");
@ -124,7 +125,6 @@ public class HighOrderController {
childOrder.setGoodsName(coupon.getCouponName());
childOrder.setGoodsImg(coupon.getCouponImg());
childOrder.setGoodsSpecName("默认");
childOrder.setGoodsPrice(coupon.getDiscountPrice());
}
if (childOrder.getGoodsType() == 2) {

@ -30,7 +30,7 @@ public class HighCouponSchedule {
* @Date 2021/4/4 22:44
**/
// @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
//@Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行
@Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行
public void expiredCoupon() {
// 查询过期的卡券
List<HighUserCoupon> userCoupons = highUserCouponService.getOverdueCoupon();

@ -29,7 +29,7 @@ public class HighDiscountSchedule {
* @Description 处理过期的优惠券
* @Date 2021/4/4 22:44
**/
//@Scheduled(cron = "0 0 0 * * ?") //每1分钟执行一次
@Scheduled(cron = "0 0 0 * * ?") //每1分钟执行一次
public void expiredDiscount() {
List<HighDiscountUserRel> expiredDiscount = highDiscountUserRelService.getExpiredDiscount();
for (HighDiscountUserRel rel : expiredDiscount) {

@ -33,7 +33,7 @@ public class HighOrderSchedule {
* @Description 取消订单 15分钟
* @Date 2021/4/4 22:45
**/
//@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
public void cancelOrder() {
List<HighOrder> orderList = highOrderService.getCloseOrder();
if (orderList != null && orderList.size() > 0) {

@ -29,7 +29,7 @@ public class SynchronizeCNPC {
private static final String[] HEX_DIGITS = {"0" ,"1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"};
@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
//@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
public void certification() {
Map<String, Object> tokenMap = new HashMap<>();
tokenMap.put("appId", "jsVpwDoHZfR2rrpjhA");

@ -52,6 +52,9 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic
if (rel == null || rel.getHighDiscount() == null || rel.getAgentId() == null){
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_DISCOUNT, "");
}
rel.setStockCount(rel.getStockCount() - 1);
highDiscountAgentRelService.updateDiscountAgentRel(rel);
// 校验卡卷状态
if (rel.getHighDiscount().getStatus() != 2) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "卡券已下架");

@ -367,7 +367,7 @@ public class HighOrderServiceImpl implements HighOrderService {
HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId());
if (rel != null) {
rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
rel.setUseTime(new Date());
rel.setUseTime(null);
highDiscountUserRelService.updateDiscountUserRel(rel);
}
}

Loading…
Cancel
Save