diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/MemberService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/MemberService.java index 00241c6..27cc23a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/MemberService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/MemberService.java @@ -748,8 +748,6 @@ public class MemberService { baObj.put("time", flow.get().getCreateTime()); producer.balance(baObj.toString()); - - return Result.success(CodeEnum.SUCCESS); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/MpCashierCartService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/MpCashierCartService.java index 225268c..6d80520 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/MpCashierCartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/MpCashierCartService.java @@ -22,5 +22,12 @@ public interface MpCashierCartService extends IService { * @return 是否成功 */ boolean updateStateByIds(Integer shopId, List cartIds, TableConstant.Status status); + + /** + * 根据订单id更改购物车状态 + * @param status 状态 + * @param orderId 订单id + */ + boolean updateStateByOrderId(TableConstant.OrderInfo.Status status, Integer orderId); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java index 74198d5..f7a405d 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java @@ -584,8 +584,11 @@ public class OrderService { if (StrUtil.isNotBlank(cashierCart.getMasterId())) { masterId = cashierCart.getMasterId(); } - totalAmount = totalAmount.add(cashierCart.getTotalAmount()); - if (cashierCart.getIsPack().equals("true")) { + boolean isReturn = TableConstant.CashierCart.Status.RETURN.equalsVals(cashierCart.getStatus()); + if (!isReturn) { + totalAmount = totalAmount.add(cashierCart.getTotalAmount()); + } + if (cashierCart.getIsPack().equals("true") && !isReturn) { packAmount = packAmount.add(cashierCart.getPackFee()); } TbProductSkuWithBLOBs skuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId())); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java index e46b837..8dffbe3 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -11,11 +11,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.chaozhanggui.system.cashierservice.bean.OrderUseTypeEnum; import com.chaozhanggui.system.cashierservice.bean.TableStateEnum; +import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant; import com.chaozhanggui.system.cashierservice.dao.*; import com.chaozhanggui.system.cashierservice.entity.*; import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto; import com.chaozhanggui.system.cashierservice.entity.po.OrderDetailPo; import com.chaozhanggui.system.cashierservice.exception.MsgException; +import com.chaozhanggui.system.cashierservice.exception.NotPrintException; import com.chaozhanggui.system.cashierservice.model.ReturnOrderReq; import com.chaozhanggui.system.cashierservice.model.ScanPayReq; import com.chaozhanggui.system.cashierservice.model.TradeQueryReq; @@ -134,10 +136,13 @@ public class PayService { @Autowired private PlatformTransactionManager transactionManager; + private final MpCashierCartService mpCashierCartService; + private final Utils utils; - public PayService(RedisTemplate redisTemplate, Utils utils) { + public PayService(RedisTemplate redisTemplate, MpCashierCartService mpCashierCartService, Utils utils) { this.redisTemplate = redisTemplate; + this.mpCashierCartService = mpCashierCartService; this.utils = utils; } @@ -398,7 +403,10 @@ public class PayService { reqbody = body.toString(); } - PublicResp publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), reqbody, reqbody, payment.getAmount().setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), payType.equals("wechatPay") ? thirdApply.getSmallAppid() : null, authCode, DateUtils.getSsdfTimes(), thirdApply.getStoreId(), callBack, thirdApply.getAppToken()); + PublicResp publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), reqbody, reqbody, + payment.getAmount().setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), + payType.equals("wechatPay") ? thirdApply.getSmallAppid() : null, authCode, + DateUtils.getSsdfTimes(), thirdApply.getStoreId(), callBack, thirdApply.getAppToken()); if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) { if ("000000".equals(publicResp.getCode())) { MainScanResp mainScanResp = publicResp.getObjData(); @@ -664,14 +672,13 @@ public class PayService { orderInfo.setPayOrderNo("deposit".concat(SnowFlakeUtil.generateOrderNo())); tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo); //更新购物车状态 - int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final"); + mpCashierCartService.updateStateByOrderId(TableConstant.OrderInfo.Status.CLOSED, orderInfo.getId()); if (ObjectUtil.isNotNull(orderInfo.getDiscountRatio()) && ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())) { tbOrderDetailMapper.updateStatusByOrderId(Integer.parseInt(orderId), "closed", orderInfo.getDiscountRatio()); } else { tbOrderDetailMapper.updateStatusByOrderId(Integer.parseInt(orderId), "closed", null); } - log.info("更新购物车:{}", cartCount); return null; }); @@ -917,7 +924,7 @@ public class PayService { orderInfo.setMemberId(vipUserId.toString()); tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo); //更新购物车状态 - int cartCount = tbCashierCartMapper.updateByOrderId(String.valueOf(orderId), "final"); + mpCashierCartService.updateStateByOrderId(TableConstant.OrderInfo.Status.CLOSED, orderInfo.getId()); if (ObjectUtil.isNotNull(orderInfo.getDiscountRatio()) && ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())) { @@ -925,8 +932,6 @@ public class PayService { } else { tbOrderDetailMapper.updateStatusByOrderId(orderId, "closed", null); } - - log.info("更新购物车:{}", cartCount); return null; }); @@ -961,6 +966,7 @@ public class PayService { return Result.success(CodeEnum.SUCCESS); } + public Result cashPay(String orderId, String token, BigDecimal payAmount, BigDecimal discountAmount) { if (ObjectUtil.isEmpty(orderId)) { return Result.fail(CodeEnum.PARAM); @@ -1013,15 +1019,13 @@ public class PayService { tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo); //更新购物车状态 - int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final"); - + mpCashierCartService.updateStateByOrderId(TableConstant.OrderInfo.Status.CLOSED, Integer.valueOf(orderId)); if (ObjectUtil.isNotNull(orderInfo.getDiscountRatio()) && ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())) { tbOrderDetailMapper.updateStatusByOrderId(Integer.parseInt(orderId), "closed", orderInfo.getDiscountRatio()); } else { tbOrderDetailMapper.updateStatusByOrderId(Integer.parseInt(orderId), "closed", null); } - log.info("更新购物车:{}", cartCount); return orderInfo; }); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/MpCashierCartServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/MpCashierCartServiceImpl.java index 25686d8..fddde18 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/MpCashierCartServiceImpl.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/MpCashierCartServiceImpl.java @@ -29,5 +29,12 @@ public class MpCashierCartServiceImpl extends ServiceImpl() + .eq(TbCashierCart::getOrderId, orderId) + .set(TbCashierCart::getStatus, status.getValue())); + } }