From 2e6c812f367e1c51ec116a2eb1920872b46bfbea Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期一, 07 四月 2025 11:35:51 +0800 Subject: [PATCH] 修改订单支付金额重复添加问题 --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java | 67 +++++++++++++++++++++------------ 1 files changed, 43 insertions(+), 24 deletions(-) diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java index 52e263b..e0c937f 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java @@ -456,19 +456,6 @@ if (200 == r.getCode()) { this.updateById(order); } - - R r1 = balanceChangeRecordClient.deleteBalanceChangeRecordCopy(orderId, Arrays.asList(4)); - if (200 != r1.getCode()) { // 项目没有分布式事务,此处报错可能会导致数据不一致 - throw new RuntimeException("订单取消失败"); - } - R r2 = userPointClient.deleteUserPointCopy(orderId, Arrays.asList(2,8,9,10,14)); - if (200 != r2.getCode()) { // 项目没有分布式事务,此处报错可能会导致数据不一致 - throw new RuntimeException("订单取消失败"); - } - R<Boolean> r3 = shopBalanceStatementClient.deleteShopBalanceStatementCopy(orderId, Arrays.asList(1,2,3)); - if (200 != r3.getCode()) { // 项目没有分布式事务,此处报错可能会导致数据不一致 - throw new RuntimeException("订单取消失败"); - } return r; } @@ -587,11 +574,6 @@ userPointClient.saveUserPoint(userPoint); } appUserClient.editAppUserById(appUser); - - //降级检测 - if (1 < appUser.getVipId() && appUser.getVipId() < 4) { - appUserClient.vipDemotion(appUser.getId()); - } //回退优惠券状态 if (null != order.getUserCouponId()) { UserCoupon userCoupon = userCouponClient.getUserCoupon(order.getUserCouponId()).getData(); @@ -699,6 +681,11 @@ //删除用户和门店添加的汇总数据(冻结数据) appUserGiveawayTemporaryClient.delAppUserGiveawayTemporary(order.getId()); shopGiveawayTemporaryClient.delShopGiveawayTemporary(order.getId()); + + //降级检测 + if (1 < appUser.getVipId() && appUser.getVipId() < 4) { + appUserClient.vipDemotion(appUser.getId()); + } return R.ok(); } @@ -754,16 +741,49 @@ } appUserClient.editAppUserById(appUser); - //降级检测 - if (1 < appUser.getVipId() && appUser.getVipId() < 4) { - appUserClient.vipDemotion(appUser.getId()); - } - //回退优惠券状态 if (null != order.getUserCouponId()) { UserCoupon userCoupon = userCouponClient.getUserCoupon(order.getUserCouponId()).getData(); userCoupon.setUseTime(null); userCouponClient.editReturnUse(userCoupon); + } + + //生成反向冻结流水数据 + List<UserPointCopy> data2 = userPointClient.getUserPointCopy(order.getId(), Arrays.asList(2, 8, 9, 10, 14)).getData(); + for (UserPointCopy userPointCopy : data2) { + userPointCopy.setId(null); + userPointCopy.setCreateTime(LocalDateTime.now()); + userPointCopy.setChangeDirection(-1); + userPointClient.saveUserPointCopy(userPointCopy); + } + List<BalanceChangeRecordCopy> data3 = balanceChangeRecordClient.getBalanceChangeRecordCopy(order.getId(), Arrays.asList(4)).getData(); + for (BalanceChangeRecordCopy balanceChangeRecordCopy : data3) { + balanceChangeRecordCopy.setId(null); + balanceChangeRecordCopy.setCreateTime(LocalDateTime.now()); + balanceChangeRecordCopy.setChangeDirection(-1); + balanceChangeRecordClient.saveBalanceChangeRecordCopy(balanceChangeRecordCopy); + } + List<ShopPointCopy> data = shopPointClient.getShopPointCopy(order.getId(), Arrays.asList(1, 2, 3)).getData(); + for (ShopPointCopy datum : data) { + datum.setId(null); + datum.setCreateTime(LocalDateTime.now()); + datum.setChangeDirection(-1); + shopPointClient.saveShopPointCopy(datum); + } + List<ShopBalanceStatementCopy> data1 = shopBalanceStatementClient.getShopBalanceStatementCopy(order.getId(), Arrays.asList(1, 2, 3)).getData(); + for (ShopBalanceStatementCopy shopBalanceStatementCopy : data1) { + shopBalanceStatementCopy.setId(null); + shopBalanceStatementCopy.setCreateTime(LocalDateTime.now()); + shopBalanceStatementCopy.setChangeDirection(-1); + shopBalanceStatementClient.saveShopBalanceStatementCopy(shopBalanceStatementCopy); + } + //删除用户和门店添加的汇总数据(冻结数据) + appUserGiveawayTemporaryClient.delAppUserGiveawayTemporary(order.getId()); + shopGiveawayTemporaryClient.delShopGiveawayTemporary(order.getId()); + + //降级检测 + if (1 < appUser.getVipId() && appUser.getVipId() < 4) { + appUserClient.vipDemotion(appUser.getId()); } return R.ok(); } @@ -843,7 +863,6 @@ Long days = jsonObject.getLong("days"); order.setAfterSaleTime(LocalDateTime.now().plusDays(days)); this.updateById(order); - commissionService.calculationCommissionShop(order.getId()); return R.ok(); } -- Gitblit v1.7.1