From ef8adf7666cebed7dc153090fcbd31680dac02dc Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Mon, 14 Jan 2019 11:07:36 +0800 Subject: [PATCH] =?UTF-8?q?[=E7=A0=8D=E4=BB=B7][=E6=96=B0=E5=A2=9E]:?= =?UTF-8?q?=E7=A0=8D=E4=BB=B7=E5=88=B8=E6=94=AF=E6=8C=81=E4=B8=A4=E7=A7=8D?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E6=96=B9=E5=BC=8F=EF=BC=8C=E4=B8=80=E7=A7=8D?= =?UTF-8?q?=E6=98=AF=E5=85=A8=E4=BB=B7=E7=AB=8B=E5=8D=B3=E6=94=AF=E4=BB=98?= =?UTF-8?q?=EF=BC=8C=E4=B8=80=E7=A7=8D=E6=98=AF=E7=A0=8D=E4=BB=B7=E5=90=8E?= =?UTF-8?q?=E4=BD=8E=E4=BB=B7=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/iformall/controller/WxOrderController.java | 14 ++++++++++++-- .../java/com/iformall/service/WxOrderService.java | 2 +- .../iformall/service/impl/WxOrderServiceImpl.java | 14 +++++--------- 3 files changed, 18 insertions(+), 12 deletions(-) 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;