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

---
 xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/controller/client/ClientOrderController.java |   49 ++++++++++++++++++++++++++++---------------------
 1 files changed, 28 insertions(+), 21 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 24dbb73..aaa65d7 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
@@ -62,7 +62,7 @@
 import java.security.interfaces.ECPublicKey;
 import java.time.LocalDateTime;
 import java.util.*;
-
+import java.util.stream.Collectors;
 
 
 /**
@@ -118,6 +118,13 @@
         if (byId==null){
             return R.fail("订单失效");
         }
+        if (byId.getGiveUserId()!=null){
+            AppUser data1 = remoteAppUserService.getAppUserById(byId.getGiveUserId() + "").getData();
+            payOrderVO.setPhone(data1.getCellPhone());
+        }
+
+        AppUser data1 = remoteAppUserService.getAppUserById(byId.getAppUserId() + "").getData();
+        payOrderVO.setBalance(data1.getBalance());
         payOrderVO.setOrderId(id);
         if (byId.getOrderFrom()==1){
             Meditation data = remoteMeditationService.getMeditationById(byId.getBusinessId()).getData();
@@ -232,7 +239,15 @@
                     break;
             }
         }
-        List<OrderCourseVO> testing = testing(res1.size(), pageCurr, pageSize, res1);
+        List<OrderCourseVO> orderCourseVOS = new ArrayList<>();
+        List<Long> longs1 = new ArrayList<>();
+        for (OrderCourseVO orderCourseVO : res1) {
+            if (!longs1.contains(orderCourseVO.getBusinessId())){
+                longs1.add(orderCourseVO.getBusinessId());
+                orderCourseVOS.add(orderCourseVO);
+            }
+        }
+        List<OrderCourseVO> testing = testing(orderCourseVOS.size(), pageCurr, pageSize, orderCourseVOS);
         return R.ok(testing);
     }
     public static List<OrderCourseVO> testing(long total, long current, long size, List<OrderCourseVO> str){
@@ -291,6 +306,7 @@
     @ApiOperation(value = "创建支付订单", notes = "微信|支付宝")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "targetId", value = "目标id 订单类型为会员和充值时不传", dataType = "Long", required = false),
+            @ApiImplicitParam(name = "orderId", value = "订单id 待支付时传", dataType = "Long", required = false),
             @ApiImplicitParam(name = "orderFrom", value = "订单来源 1=冥想音频 2=课程 3=购买会员 4充值", dataType = "Integer", required = true),
             @ApiImplicitParam(name = "receiverId", value = "被赠送课程APP用户id", dataType = "Long", required = false),
             @ApiImplicitParam(name = "balanceFlag", value = "是否使用余额抵扣 1=是 2=否", dataType = "Integer", required = false),
@@ -300,6 +316,7 @@
     })
     public R<ClientPlaceOrderVO> placeOrder(
             @RequestParam(value = "targetId", required = false) Long targetId,
+            @RequestParam(value = "orderId", required = false) Long orderId,
             @RequestParam(value = "orderFrom") Integer orderFrom,
             @RequestParam(value = "receiverId", required = false) Long receiverId,
             @RequestParam(value = "balanceFlag", required = false) Integer balanceFlag,
@@ -310,7 +327,7 @@
         try {
 
             return R.ok(
-                    orderService.placeOrder(targetId, orderFrom, receiverId,
+                    orderService.placeOrder(targetId, orderFrom, receiverId,orderId,
                             balanceFlag, payType,amount,vipType));
         } catch (Exception e) {
             throw new RuntimeException(e);
@@ -437,6 +454,7 @@
             case 2:
                 if (receiverId!=null){
                     remoteAppUserService.addAppUserCourse(order.getBusinessId(),order.getGiveUserId(),order.getId(),1);
+                    remoteAppUserService.addNotice(receiverId+"",order.getBusinessId()+"",order.getAppUserId()+"",order.getTotalAmount()+"");
                 }else{
                     // 自己购买
                     remoteAppUserService.addAppUserCourse(order.getBusinessId(),order.getAppUserId(),order.getId(),2);
@@ -458,20 +476,6 @@
         appUserWalletRecord1.setChildAppUserId(order.getAppUserId());
         appUserWalletRecord1.setOrderId(order.getId());
         remoteAppUserService.addBalanceRecord(appUserWalletRecord1);
-        switch (orderFrom){
-            case 1:
-
-                break;
-            case 2:
-
-                if (receiverId!=null){
-                    remoteAppUserService.addAppUserCourse(order.getBusinessId(),order.getGiveUserId(),order.getId(),1);
-                }else{
-                    remoteAppUserService.addAppUserCourse(order.getBusinessId(),userId,order.getId(),1);
-                }
-                break;
-        }
-
         // 判断订单所属用户是否有上级 是否需要做分佣处理
         AppUser data = remoteAppUserService.getAppUserById(order.getAppUserId() + "").getData();
         BigDecimal realPayAmount = order.getRealPayAmount();
@@ -556,6 +560,8 @@
                         .ne(OrderPaymentRecord::getPaymentType, 4).one();
                 if (one2!=null){
                     one2.setPaymentStatus(2);
+                    // 扣除用户余额
+                    Object data = remoteAppUserService.deleteBalance(one.getAppUserId() + "", one2.getPayAmount() + "").getData();
                     orderPaymentRecordService.updateById(one2);
                 }
                 // 实际支付金额
@@ -608,7 +614,7 @@
                     OrderPaymentRecord one1 = orderPaymentRecordService.lambdaQuery().eq(OrderPaymentRecord::getOrderId, one.getId())
                             .eq(OrderPaymentRecord::getPaymentType, 4).one();
                     AppUserWalletRecord appUserWalletRecord = new AppUserWalletRecord();
-                    appUserWalletRecord.setAppUserId(data.getInviteUserId());
+                    appUserWalletRecord.setAppUserId(one.getAppUserId());
                     String reason=null;
                     switch (one.getOrderFrom()){
                         case 1:
@@ -642,7 +648,6 @@
                     }
                     appUserWalletRecord.setReason(reason);
                     appUserWalletRecord.setAmount(one1.getPayAmount());
-                    appUserWalletRecord.setChildAppUserId(one.getAppUserId());
                     appUserWalletRecord.setOrderId(one.getId());
                     remoteAppUserService.addBalanceRecord(appUserWalletRecord);
                 }else{
@@ -749,6 +754,7 @@
                 }
                 one.setPaymentStatus(2);
                 one.setPaymentTime(LocalDateTime.now());
+                orderService.updateById(one);
                 OrderPaymentRecord one2 = orderPaymentRecordService.lambdaQuery().eq(OrderPaymentRecord::getOrderId, one.getId())
                         .ne(OrderPaymentRecord::getPaymentType, 4).one();
                 if (one2!=null){
@@ -866,12 +872,13 @@
                             }
                             break;
                         case 4:
-                            remoteAppUserService.addBalance(one.getAppUserId(),one.getRealPayAmount());
+                            System.err.println("进入充值");
+                            remoteAppUserService.addBalance(one.getAppUserId(),one.getTotalAmount());
                             AppUserWalletRecord appUserWalletRecord = new AppUserWalletRecord();
                             appUserWalletRecord.setAppUserId(one.getAppUserId());
                             appUserWalletRecord.setChangeType(1);
                             appUserWalletRecord.setReason("充值");
-                            appUserWalletRecord.setAmount(one.getRealPayAmount());
+                            appUserWalletRecord.setAmount(one.getTotalAmount());
                             appUserWalletRecord.setChildAppUserId(one.getAppUserId());
                             appUserWalletRecord.setOrderId(one.getId());
                             remoteAppUserService.addBalanceRecord(appUserWalletRecord);

--
Gitblit v1.7.1