diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxOrderController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxOrderController.java index 5f3d4be46..cfdc32b6d 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxOrderController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxOrderController.java @@ -84,7 +84,7 @@ public class WxOrderController extends BaseController { } } - @ApiOperation(value = "下订单", notes = "{\"couponChannelId\":\"String\",\"couponId\":\"String\"}") + @ApiOperation(value = "下订单", notes = "{\"couponChannelId\":\"String\",\"couponId\":\"String\",\"press\":\"String\"}") @PostMapping("save") public ResultData saveOrder(@RequestBody Map paramMap) { logger.info("OrderSave: " + paramMap.toString()); @@ -92,11 +92,13 @@ public class WxOrderController extends BaseController { //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); String couponChannelIdStr = paramMap.get("couponChannelId"); String couponIdStr = paramMap.get("couponId"); + String pressStr = paramMap.get("press"); if (StringUtils.isBlank(couponChannelIdStr)) { return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId不能为空"); } Long couponChannelId = 0L, couponId = 0L; + boolean isPress = false; if (StringUtils.isNotBlank(couponChannelIdStr)) { try { @@ -132,10 +134,18 @@ public class WxOrderController extends BaseController { return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId或者couponId不能为空"); } + if(pressStr != null) { + try{ + isPress = Boolean.valueOf(pressStr); + } catch (Exception e) { + logger.error("press转换失败"); + } + } + WxCUser user = getUser(); try { - WxOrder order = wxOrderService.saveCouponOrder(user, couponChannelId, couponId); + WxOrder order = wxOrderService.saveCouponOrder(user, couponChannelId, couponId, isPress); return new ResultData(order); } catch (MallinkException e) { logger.error(e.getMessage()); diff --git a/mallinkService/src/main/java/com/iformall/service/WxOrderService.java b/mallinkService/src/main/java/com/iformall/service/WxOrderService.java index 7fc566d2a..5e455cf45 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxOrderService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxOrderService.java @@ -39,7 +39,7 @@ public interface WxOrderService { * @param couponId * @return 订单id */ - WxOrder saveCouponOrder(WxCUser user, Long couponChannelId, Long couponId); + WxOrder saveCouponOrder(WxCUser user, Long couponChannelId, Long couponId, boolean isPress); /** * 付款码支付 diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java index ee6dbdc83..b18fbea1c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java @@ -312,7 +312,7 @@ public class WxOrderServiceImpl implements WxOrderService { @Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) - public WxOrder saveCouponOrder(WxCUser user, Long couponChannelId, Long couponId) { + public WxOrder saveCouponOrder(WxCUser user, Long couponChannelId, Long couponId, boolean isPress) { // 检查用户 if (user == null) { logger.error("用户不存在"); @@ -339,16 +339,11 @@ public class WxOrderServiceImpl implements WxOrderService { // 减库存操作 stockReduce(user, coupon, couponIdStr); - boolean isPress = false; - if (coupon.getType().equals(EnumCouponType.COUPON_PRESS.getCode())) { - isPress = true; - } - Date curr = new Date(); int payment = coupon.getSalePrice(); if (isPress) { - // 砍价券 + // 砍价券 初始是全价即面额 payment = coupon.getPrice(); } @@ -379,7 +374,7 @@ public class WxOrderServiceImpl implements WxOrderService { record.setDetail(bodyStr); record.setCreateDate(curr); record.setUpdateDate(curr); - if(isPress) { + if (isPress) { // 初始砍价信息 record.setPressCurrentNum(0); record.setPressEndDate(DateUtils.getHourTimeAfter(coupon.getPressLimitHours(), curr)); @@ -396,7 +391,8 @@ public class WxOrderServiceImpl implements WxOrderService { throw new MallinkException(ErrorCode.ORDER_SAVE_ERR); } - if(isPress) { + if (isPress) { + // 初始砍价 // 添加 wx_order_press int total = coupon.getPrice() - coupon.getSalePrice(); int left_total = total;