From fd88d7b527e99bbf7272d28bf0826b05e3c175d8 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期一, 16 十二月 2024 17:10:53 +0800
Subject: [PATCH] 代码提交

---
 xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/controller/client/ClientOrderController.java |   41 +++++++++++++++++++++++------------------
 1 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/controller/client/ClientOrderController.java b/xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/controller/client/ClientOrderController.java
index 7557675..fe4be9c 100644
--- a/xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/controller/client/ClientOrderController.java
+++ b/xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/controller/client/ClientOrderController.java
@@ -371,8 +371,6 @@
                                     order.setRealPayAmount(data1.getIosPrice());
                                     break;
                             }
-
-
                             break;
                         case 2:
                             Course data = remoteCourseService.getCourseById(targetId).getData();
@@ -409,6 +407,12 @@
                             break;
                     }
 
+                    // 删除原有非余额支付详细记录
+                    OrderPaymentRecord two = orderPaymentRecordService.lambdaQuery().eq(OrderPaymentRecord::getOrderId, order.getId())
+                            .ne(OrderPaymentRecord::getPaymentType, 4).one();
+                    if (two!=null){
+                        orderPaymentRecordService.removeById(two.getId());
+                    }
                     OrderPaymentRecord one = orderPaymentRecordService.lambdaQuery().eq(OrderPaymentRecord::getOrderId, order.getId())
                             .eq(OrderPaymentRecord::getPaymentType, 4).one();
                     if (one!=null){
@@ -434,6 +438,9 @@
                     ClientPlaceOrderVO clientPlaceOrderVO = new ClientPlaceOrderVO();
                     clientPlaceOrderVO.setId(order.getId());
                     clientPlaceOrderVO.setOrderNo(order.getBizOrderNo());
+                    order.setRealPayAmount(new BigDecimal("0"));
+                    order.setPayType(4);
+                    orderService.updateById(order);
                     return R.ok(clientPlaceOrderVO);
             }
 
@@ -690,11 +697,9 @@
                 AppUser data = remoteAppUserService.getAppUserById(one.getAppUserId() + "").getData();
                 if (one.getGiveUserId()!=null){
                     remoteAppUserService.addNotice(one.getGiveUserId() + "", one.getBusinessId() + "",
-                            one.getAppUserId() + "", one.getTotalAmount() + "");
+                            one.getAppUserId() + "", realPayAmount + "");
                 }
-
                 if (data.getInviteUserId()!=null) {
-
                     if (one.getOrderFrom() == 1 || one.getOrderFrom() == 2 || one.getOrderFrom() == 3) {
                         // 查询实际支付价格 不包含余额抵扣价格
                         OrderPaymentRecord one1 = orderPaymentRecordService.lambdaQuery().eq(OrderPaymentRecord::getOrderId, one.getId())
@@ -703,8 +708,7 @@
                     CommissionRule data1 = sysUserClient.getCommission().getData();
                     if (data1 != null) {
                         if (data1.getProportion() != null) {
-
-                            BigDecimal bigDecimal = one1.getPayAmount().multiply(data1.getProportion()).divide(new BigDecimal("100"))
+                            BigDecimal bigDecimal = one1.getPayAmount().add(one.getChangePrice()!=null?one.getChangePrice():new BigDecimal("0")).multiply(data1.getProportion()).divide(new BigDecimal("100"))
                                     .setScale(2, BigDecimal.ROUND_DOWN);
                             // 上级获取的分佣金额
                             AppUser appUserById = remoteAppUserService.getAppUserById(data.getInviteUserId() + "").getData();
@@ -714,16 +718,18 @@
 //                                                    appUserById.getBalance().add(bigDecimal))
 //                                            .build(), SecurityConstants.INNER);
                             // 新增分佣流水明细
-                            AppUserWalletRecord appUserWalletRecord = new AppUserWalletRecord();
-                            appUserWalletRecord.setAppUserId(data.getInviteUserId());
-                            appUserWalletRecord.setChangeType(1);
-                            appUserWalletRecord.setReason("分佣收益");
-                            appUserWalletRecord.setAmount(bigDecimal);
-                            appUserWalletRecord.setChildAppUserId(one.getAppUserId());
-                            appUserWalletRecord.setOrderId(one.getId());
-                            remoteAppUserService.addBalanceRecord(appUserWalletRecord);
-                            one.setCommissionAmount(bigDecimal);
-                            one.setCommissionId(data.getInviteUserId());
+                            if (bigDecimal.compareTo(new BigDecimal("0"))>0){
+                                AppUserWalletRecord appUserWalletRecord = new AppUserWalletRecord();
+                                appUserWalletRecord.setAppUserId(data.getInviteUserId());
+                                appUserWalletRecord.setChangeType(1);
+                                appUserWalletRecord.setReason("分佣收益");
+                                appUserWalletRecord.setAmount(bigDecimal);
+                                appUserWalletRecord.setChildAppUserId(one.getAppUserId());
+                                appUserWalletRecord.setOrderId(one.getId());
+                                remoteAppUserService.addBalanceRecord(appUserWalletRecord);
+                                one.setCommissionAmount(bigDecimal);
+                                one.setCommissionId(data.getInviteUserId());
+                            }
                             orderService.updateById(one);
                         }
                     }
@@ -741,7 +747,6 @@
                             Meditation data1 = remoteMeditationService.getMeditationById(one.getBusinessId()).getData();
                             appUserWalletRecord.setChangeType(2);
                             reason = "购买疗愈【"+data1.getMeditationTitle()+"】";
-
                             break;
                         case 2:
                             Course data2 = remoteCourseService.getCourseById(one.getBusinessId()).getData();

--
Gitblit v1.7.1