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