From 6bf0be4ab60da79915b6fce39c711cdd5d048718 Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Sat, 5 Jan 2019 13:50:08 +0800 Subject: [PATCH] =?UTF-8?q?[=E7=A0=8D=E4=BB=B7][=E4=BF=AE=E6=94=B9]:?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E7=A0=8D=E4=BB=B7=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/WxOrderServiceImpl.java | 41 ++++++++++++++----- 1 file changed, 30 insertions(+), 11 deletions(-) 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 426d6938a..2d9952e1f 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java @@ -369,7 +369,6 @@ public class WxOrderServiceImpl implements WxOrderService { bodyStr = /*wxMerchant.getName() + */ "-" + EnumCouponType.getEnum(coupon.getType()); } - WxOrder record = new WxOrder(); record.setId(orderNumber); record.setTenantId(user.getTenantId()); @@ -384,9 +383,23 @@ public class WxOrderServiceImpl implements WxOrderService { record.setCreateDate(curr); record.setUpdateDate(curr); if(isPress) { - record.setPressCurrentNum(1); + // 初始砍价信息 + record.setPressCurrentNum(0); record.setPressEndDate(DateUtils.getHourTimeAfter(coupon.getPressLimitHours(), curr)); + record.setPressCurrentValue(coupon.getPrice() - coupon.getSalePrice()); + } + try { + // 保存订单 + wxOrderMapper.insertSelective(record); + } catch (RuntimeException e) { + // 库存恢复 + stockBack(record); + logger.error("保存订单:" + e.getMessage()); + throw new MallinkException(ErrorCode.ORDER_SAVE_ERR); + } + + if(isPress) { // 添加 wx_order_press int total = coupon.getPrice() - coupon.getSalePrice(); int left_total = total; @@ -406,16 +419,22 @@ public class WxOrderServiceImpl implements WxOrderService { logger.error("保存砍价记录Err:" + e.getMessage()); throw new MallinkException(ErrorCode.ORDER_SAVE_ERR); } - } - try { - // 保存订单 - wxOrderMapper.insertSelective(record); - } catch (RuntimeException e) { - // 库存恢复 - stockBack(record); - logger.error("保存订单:" + e.getMessage()); - throw new MallinkException(ErrorCode.ORDER_SAVE_ERR); + // 更新砍价信息 + WxOrder orderUpdatePress = new WxOrder(); + orderUpdatePress.setId(record.getId()); + orderUpdatePress.setPressCurrentNum(1); + orderUpdatePress.setPressCurrentValue(left_total - orderPress.getPressValue()); + orderUpdatePress.setUpdateDate(new Date()); + try { + // 保存订单 + wxOrderMapper.updateByPrimaryKeySelective(orderUpdatePress); + } catch (RuntimeException e) { + // 库存恢复 + stockBack(record); + logger.error("保存砍价记录Err:" + e.getMessage()); + throw new MallinkException(ErrorCode.ORDER_SAVE_ERR); + } } // couponActionLog