From b60e601d62c0e2d5c4fd1df9f12fa09f2bf99987 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期一, 14 十月 2024 17:56:48 +0800
Subject: [PATCH] 调试支付

---
 xinquan-api/xinquan-api-user/src/main/java/com/xinquan/user/api/domain/dto/UserChildDTO.java                           |   26 ++++
 xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserWalletRecordController.java |  149 +++++++++++++++++-------
 xinquan-api/xinquan-api-system/src/main/java/com/xinquan/system/api/domain/vo/OrderDetailVO.java                       |    8 
 xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserController.java             |   38 ++----
 xinquan-api/xinquan-api-system/src/main/java/com/xinquan/system/api/domain/AppUser.java                                |    3 
 xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/controller/client/ClientOrderController.java             |   15 ++
 xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/utils/JuHeFuUtil.java                                    |   77 ++++++++++--
 7 files changed, 229 insertions(+), 87 deletions(-)

diff --git a/xinquan-api/xinquan-api-system/src/main/java/com/xinquan/system/api/domain/AppUser.java b/xinquan-api/xinquan-api-system/src/main/java/com/xinquan/system/api/domain/AppUser.java
index 4dcfdae..cd25093 100644
--- a/xinquan-api/xinquan-api-system/src/main/java/com/xinquan/system/api/domain/AppUser.java
+++ b/xinquan-api/xinquan-api-system/src/main/java/com/xinquan/system/api/domain/AppUser.java
@@ -136,6 +136,9 @@
     @ApiModelProperty(value = "邀请人id")
     @TableField("invite_user_id")
     private Long inviteUserId;
+    @ApiModelProperty(value = "绑定邀请人时间")
+    @TableField("invite_user_time")
+    private LocalDateTime inviteUserTime;
 
     @ApiModelProperty(value = "余额")
     @TableField("balance")
diff --git a/xinquan-api/xinquan-api-system/src/main/java/com/xinquan/system/api/domain/vo/OrderDetailVO.java b/xinquan-api/xinquan-api-system/src/main/java/com/xinquan/system/api/domain/vo/OrderDetailVO.java
index 1c4d8e3..9052cb8 100644
--- a/xinquan-api/xinquan-api-system/src/main/java/com/xinquan/system/api/domain/vo/OrderDetailVO.java
+++ b/xinquan-api/xinquan-api-system/src/main/java/com/xinquan/system/api/domain/vo/OrderDetailVO.java
@@ -33,9 +33,11 @@
     private LocalDateTime paymentTime;
     @ApiModelProperty(value = "流水单号")
     private String payOrderNo;
-    @ApiModelProperty(value = "提现方式")
-    private String withdraw;
-    @ApiModelProperty(value = "备注")
+    @ApiModelProperty(value = "提现方式 提现方式 1=银行卡提现  2=微信提现 3=支付宝提现")
+    private Integer withdrawType;
+    @ApiModelProperty(value = "充值方式 提现方式 1=微信  2=支付宝 3=余额 4=苹果内购")
+    private Integer payType;
+    @ApiModelProperty(value = "来源备注")
     private String remark;
     @ApiModelProperty(value = "下级用户名称 当类型为佣金的时候展示")
     private String userName;
diff --git a/xinquan-api/xinquan-api-user/src/main/java/com/xinquan/user/api/domain/dto/UserChildDTO.java b/xinquan-api/xinquan-api-user/src/main/java/com/xinquan/user/api/domain/dto/UserChildDTO.java
new file mode 100644
index 0000000..dd13d64
--- /dev/null
+++ b/xinquan-api/xinquan-api-user/src/main/java/com/xinquan/user/api/domain/dto/UserChildDTO.java
@@ -0,0 +1,26 @@
+package com.xinquan.user.api.domain.dto;
+
+import com.xinquan.common.core.web.page.BasePage;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author mitao
+ * @date 2024/9/7
+ */
+@Data
+@ApiModel(value = "管理后台下级用户DTO")
+public class UserChildDTO extends BasePage {
+    @ApiModelProperty(value = "用户昵称")
+    private String nickName;
+    @ApiModelProperty(value = "用户手机号")
+    private String cellPhone;
+    @ApiModelProperty(value = "用户状态 1=正常 2=冻结 3=注销")
+    private String userStatus;
+    @ApiModelProperty(value = "操作时间 2020-11-11 - 2021-11-11")
+    private String time;
+    @ApiModelProperty(value = "用户uid")
+    private String uid;
+
+}
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 449f193..c75f4d5 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
@@ -1,6 +1,7 @@
 package com.xinquan.order.controller.client;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.xinquan.common.core.domain.R;
 import com.xinquan.common.core.utils.page.BeanUtils;
@@ -25,8 +26,14 @@
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -145,6 +152,12 @@
             throw new RuntimeException(e);
         }
     }
+    @ResponseBody
+    @PostMapping("/testCallback")
+    public void wechatPaymentGameCallback(HttpServletRequest request, HttpServletResponse response) throws Exception {
+        System.err.println("进入回调");
+
+    }
     /**
      * 远程调用 根据用户id 查询充值金额
      */
@@ -185,6 +198,7 @@
                     case 3:
                         one.setRemark("苹果内购");
                 }
+                one.setPayOrderNo(two.getPayOrderNo());
             }
             if (one.getCommissionId()!=null){
                 switch (one.getOrderFrom()){
@@ -200,6 +214,7 @@
                         one.setRemark("充值");
                 }
             }
+
             return R.ok(one);
         }
         return R.ok();
diff --git a/xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/utils/JuHeFuUtil.java b/xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/utils/JuHeFuUtil.java
index 7761b0b..7132651 100644
--- a/xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/utils/JuHeFuUtil.java
+++ b/xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/utils/JuHeFuUtil.java
@@ -10,14 +10,19 @@
 import com.xinquan.common.core.utils.StringUtils;
 import java.security.KeyFactory;
 import java.security.PrivateKey;
+import java.security.PublicKey;
 import java.security.Signature;
 import java.security.spec.PKCS8EncodedKeySpec;
+import java.security.spec.X509EncodedKeySpec;
 import java.util.Base64;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.TreeMap;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.SecretKeySpec;
 
 /**
  * 桔禾付支付工具类
@@ -29,15 +34,15 @@
 
     private static Logger logger = LoggerFactory.getLogger(JuHeFuUtil.class);
     // 商户RSA私钥 TODO
-    private static final String MERCHANT_PRIVATE_KEY = "";
+    private static final String MERCHANT_PRIVATE_KEY = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAMQPsMj4OYgjHFWS8wDIQOoMeAx9Ad1wKfIks7Oz5Kw8EVnmZ9o1ZY14goMMr1vJo/XxLLYXDvwj+EhV4MqT6ji2QDVqlhA4f6WFFmKOsvxgNnu0zAysfDpVpYihWC5uOf4ece9fWVci8DYFeXcawYGNB6GrJuo186sqMYwkE90/AgMBAAECgYAnMvfmhnKCPHraxSGeo2sPIGUUIh4wVs+cIShoomvy36OcdMuIvipKqbB2YR/iWyNT9d85nMybLtniJIFoH0CxshmLH/yg31vYhyLfVyih1RVFBRYuDMnIjvmNTBgXM/9vaAwkzonIQnoFoLVjxK2+JIFY+86Iak1Cv/vEi1vaSQJBAPRwebK51NBfrnO+2HY9nuDvbZbSx9I8uR+Yw/ebDUmbow/Dacibl0Hha+fw6cy5I3Rlm2kk5fKXIDIkwyLVq80CQQDNVXuQ8kXrDR0WjPcYPnwKNPEd0EHOKFiT7OqwoMFUUROyajO2nWs80eiZYZ+6M6+LEvYT6KcSiyiIwREnh1k7AkBV3BwjNzsVZkZ0yZhnEAX6pJ8t1yPxKPstqg9Lrd7g+BYyt0U0/dIHhhLNCcZV7sIRZI9OQ3Ox3nukoV0Zo0wRAkBT1eEbry+I5tPHj0qb5Xczm6YOrCcSCzsPOp4f+6Kz0F6ga+gtWVyden7jkQ5sMgosWFOMkWMVmSe1nk5ou0RdAkEAzfJJavQgu+BGQwqS1EojlXKe0GmpbQu+HwuDKcHmju0P2qGQ2yPfvURg1dMp7tmBM8AlVJhgzkNuyUAN1J841w==";
     // 平台RSA公钥 TODO
-    private static final String PLAT_PUBLIC_KEY = "";
+    private static final String PLAT_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDOKBBFXirWIJth+SNJCY4mhbATbL60sKV66bRixHMVz8vpBqONio9X6A+Pm9LNutBe+hLpI1BMmFJk3Mb1/QEcklWptRGgHqIrBxR4b19qc/2/pSxyqlpaifYJFZhOg2+OcQ/fqpAmhNXN5uc1pcYvbvWTam0j+6+nBNQeAAku5QIDAQAB";
     // 应用的app_id TODO
-    private static final String APP_ID = "";
+    private static final String APP_ID = "app_10024101201";
     // 商户id TODO
-    private static final String MER_ID = "";
+    private static final String MER_ID = "1120241012072667";
     // AES密钥 TODO
-    private static final String AES_KEY = "";
+    private static final String AES_KEY = "cb0a181ac97395c6942be19315fc0727";
     // 创建用户接口
     private static final String CREATE_USER_INTERFACE = "/api/member/create_user_a";
     // 创建支付订单
@@ -46,7 +51,7 @@
     private static final String PAYMENT_REFUND_INTERFACE = "/api/payment/payment_refund";
     private static final String MERCHANT_PAY_INTERFACE = "/api/account/merchant_pay";
     // 接口地址 TODO
-    private static final String BASE_URL = "";
+    private static final String BASE_URL = "http://paytest.juhefu.com/";
     // 支付宝支付渠道
     private static final String PAY_CHANNEL_ALIPAY = "alipay_qr";
     // 微信支付渠道
@@ -92,6 +97,11 @@
         return false;
     }
 
+    public static void main(String[] args) throws Exception {
+        createPayment("MX123aaa9999911",1, "0.01",
+                "测试商品", "测试商品描述",
+                "221.182.45.100", "oG50n6Vf0JNid5DOg0brcAnZ0T4s", "https://v7ro848ar5jx.ngrok.xiaomiqiu123.top/order/client/order/order/testCallback");
+    }
     /**
      * 创建支付订单
      *
@@ -113,7 +123,6 @@
         JSONObject expand = new JSONObject();
         data.put("order_no", orderNo);
         data.put("app_id", APP_ID);
-        data.put("mer_id", MER_ID);
         if (payChannel == 1) {
             data.put("pay_channel", PAY_CHANNEL_ALIPAY);
         } else {
@@ -134,16 +143,22 @@
         body.put("sign", sign(JSONObject.toJSONString(data)));
         body.put("reqCipher",
                 EncryptUtils.aes256ECBPkcs7PaddingEncrypt(JSONObject.toJSONString(data), AES_KEY));
-        body.put("reqTime", DateUtils.dateTimeNow("yyyyMMddHHmmssfff"));
+        body.put("reqTime", DateUtils.dateTimeNow("yyyyMMddHHmmsssss"));
         String result = sendPost(BASE_URL + CREATE_PAYMENT_INTERFACE, body);
         JSONObject resJsonObject = JSONObject.parseObject(result);
-        if (resJsonObject.getString("status").equals("failed")) {
-            throw new ServiceException(resJsonObject.getString("error_msg"));
-        }
-        if (resJsonObject.getString("status").equals("succeeded")) {
-            return resJsonObject.getJSONObject("expand");
-        }
-        return null;
+        System.err.println(resJsonObject);
+        String string = resJsonObject.getString("resCipher");
+        String decrypt = decrypt(string);
+        System.err.println(decrypt);
+        JSONObject jsonObject = JSONObject.parseObject(decrypt);
+
+//        if (resJsonObject.getString("status").equals("failed")) {
+//            throw new ServiceException(resJsonObject.getString("error_msg"));
+//        }
+//        if (resJsonObject.getString("status").equals("succeeded")) {
+//            return resJsonObject.getJSONObject("expand");
+//        }
+        return jsonObject.getJSONObject("expand");
     }
 
     /**
@@ -198,7 +213,7 @@
         body.put("sign", sign(JSONObject.toJSONString(data)));
         body.put("reqCipher",
                 EncryptUtils.aes256ECBPkcs7PaddingEncrypt(JSONObject.toJSONString(data), AES_KEY));
-        body.put("reqTime", DateUtils.dateTimeNow("yyyyMMddHHmmssfff"));
+        body.put("reqTime", DateUtils.dateTimeNow("yyyyMMddHHmmss"));
         String result = sendPost(BASE_URL + MERCHANT_PAY_INTERFACE, body);
         JSONObject resJsonObject = JSONObject.parseObject(result);
         if (resJsonObject.getString("status").equals("succeeded")) {
@@ -233,6 +248,7 @@
     }
 
 
+
     /**
      * RSA私钥签名:签名方式SHA256WithRSA
      *
@@ -243,7 +259,6 @@
     public static String sign(String data) {
         // 先对该json对象数据按照参数字典顺序(参数名ASCII码从小到大排序,参数名区分大小写)排序生成字符串,再进行加签和验签。
         data = JSON.toJSONString(JSONObject.parseObject(data, TreeMap.class));
-
         // Base64 --> Key
         try {
             byte[] bytes = Base64.getDecoder().decode(MERCHANT_PRIVATE_KEY);
@@ -261,5 +276,33 @@
             return null;
         }
     }
+    public static String decrypt(String strToDecrypt) {
+        try {
+        SecretKeySpec secretKey = new SecretKeySpec(AES_KEY.getBytes(), "AES");
+        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
+        cipher.init(Cipher.DECRYPT_MODE, secretKey);
+        return new String(cipher.doFinal(Base64.getDecoder().decode(strToDecrypt)));
+    } catch (Exception e) {
+            System.out.println("Error while decrypting: " + e.toString());
+    }
+        return null;}
+//    public static boolean verify(String data, String publicKeyStr) {
+//        try {
+//            // 解码公钥
+//            byte[] publicKeyBytes = Base64.getDecoder().decode(publicKeyStr);
+//            X509EncodedKeySpec keySpec = new X509EncodedKeySpec(publicKeyBytes);
+//            KeyFactory keyFactory = KeyFactory.getInstance("RSA");
+//            PublicKey publicKey = keyFactory.generatePublic(keySpec);
+//            // 验证签名
+//            Signature signature = Signature.getInstance("SHA256WithRSA");
+//            signature.initVerify(publicKey);
+//            signature.update(data.getBytes("UTF-8"));
+//
+//            return true;
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//            return false;
+//        }
+//    }
 
 }
diff --git a/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserController.java b/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserController.java
index 70d639d..5842e00 100644
--- a/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserController.java
+++ b/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserController.java
@@ -95,21 +95,12 @@
     @Resource
     private RemoteUserService remoteUserService;
     public static void main(String[] args) {
-//        LocalDateTime dateTime = LocalDateTime.now();
-//        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
-//        String formattedDateTime = dateTime.format(formatter);
-//        System.err.println(formattedDateTime);
         // 收件人电子邮箱,TODO 换成自己的收件箱
         String to = "443237572@qq.com";
-
         // 发件人电子邮箱,TODO 换成自己的发件箱
         String from = "13281306557@163.com";
-
         // 指定发送邮件的主机为
         String host = "smtp.163.com";
-
-        // 获取系统属性
-        //Properties properties = System.getProperties();
         Properties properties = new Properties();
         // 设置邮件服务器
         properties.setProperty("mail.smtp.host", host);
@@ -142,37 +133,30 @@
             InternetAddress toMail2 = new InternetAddress("443237572@qq.com");
             //发一个邮箱
 //            message.setRecipient(Message.RecipientType.TO, toMail);
-
             //发多个邮箱
             Address[] allRecipients = {toMail, toMail2};
             message.setRecipients(Message.RecipientType.TO, allRecipients);
-
             // Set Subject: 邮件主体
             message.setSubject("明星电力");
-
             // 设置消息体
             message.setSentDate(new Date());
-
             // 指定为混合关系
             MimeMultipart msgMultipart = new MimeMultipart("mixed");
             message.setContent(msgMultipart);
-
             // 邮件信息组装
             //组装的顺序非常重要,一定要先组装文本域,再组装文件
             MimeBodyPart htmlPart = new MimeBodyPart();
             // 组装内容
             htmlPart.setContent("This is message content", "text/html;charset=UTF-8");
             msgMultipart.addBodyPart(htmlPart);
-
             // 组装附件
             MimeBodyPart filePart = new MimeBodyPart();
-            String imageUrl = "http://221.182.45.100:8090/2024-10-10/04-18-09-0466d831fc6365571080.pdf";
+            String imageUrl = "https://xqgwzh.obs.cn-south-1.myhuaweicloud.com/xinquan/b176cf9af35d4773a276e55b7afe3b63.mp4";
             try {
                 // 下载数据
                 URL url = new URL(imageUrl);
                 InputStream inputStream = url.openStream();
                 byte[] imageBytes = IOUtils.toByteArray(inputStream);
-
                 // 创建临时文件
                 // 截取imageUrl后缀名
                 String fileExtension = imageUrl.substring(imageUrl.lastIndexOf("."));
@@ -180,7 +164,6 @@
                 try (FileOutputStream fos = new FileOutputStream(tempFile)) {
                     fos.write(imageBytes);
                 }
-
                 // 创建 FileDataSource
                 FileDataSource fileDataSource = new FileDataSource(tempFile);
                 System.out.println("FileDataSource created: " + fileDataSource.getName());
@@ -650,19 +633,26 @@
         // 查询登录用户邀请了哪些人
         List<Long> collect = page.getRecords().stream().map(AppUser::getId).collect(Collectors.toList());
         if (collect.isEmpty())return R.ok(PageDTO.empty(page));
-        StringBuilder stringBuilder = new StringBuilder();
-        collect.forEach(id -> stringBuilder.append(id).append(","));
-        // 去除最后一位
-        StringBuilder stringBuilder1 = stringBuilder.deleteCharAt(stringBuilder.length() - 1);
-        String[] split = stringBuilder1.toString().split(",");
         for (int i = 0; i < page.getRecords().size(); i++) {
             AppUser appUser = page.getRecords().get(i);
-            appUser.setMoney(new BigDecimal(split[i]));
+            // 查询该给用户带来收益
+            List<AppUserWalletRecord> list = appUserWalletRecordService.lambdaQuery().eq(AppUserWalletRecord::getAppUserId, userId)
+                    .eq(AppUserWalletRecord::getChildAppUserId,appUser.getUserId()).list();
+            BigDecimal bigDecimal = new BigDecimal("0");
+            for (AppUserWalletRecord appUserWalletRecord : list) {
+                if (appUserWalletRecord.getAmount()!=null && appUserWalletRecord.getChangeType() == 1){
+                    bigDecimal = bigDecimal.add(appUserWalletRecord.getAmount());
+                }
+            }
+            appUser.setMoney(bigDecimal);
+
         }
         // 根据佣金金额 从大到小排序
         page.getRecords().sort((o1, o2) -> o2.getMoney().compareTo(o1.getMoney()));
         return R.ok(PageDTO.of(page, InviteRankListVO.class));
     }
+    @Resource
+    private AppUserWalletRecordService appUserWalletRecordService;
     /**
      * 爱心助力榜单-分页
      *
diff --git a/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserWalletRecordController.java b/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserWalletRecordController.java
index 12a7eed..5c3be95 100644
--- a/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserWalletRecordController.java
+++ b/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserWalletRecordController.java
@@ -12,15 +12,19 @@
 import com.xinquan.order.api.feign.RemoteOrderService;
 import com.xinquan.system.api.domain.AppUser;
 import com.xinquan.system.api.domain.AppUserWalletRecord;
+import com.xinquan.system.api.domain.AppUserWithdraw;
 import com.xinquan.system.api.domain.vo.InviteRankListVO;
 import com.xinquan.system.api.domain.vo.OrderDetailVO;
 import com.xinquan.system.api.domain.vo.OrderListVO;
 import com.xinquan.user.api.domain.dto.UserBalanceDetailDTO;
+import com.xinquan.user.api.domain.dto.UserChildDTO;
 import com.xinquan.user.service.AppUserService;
 import com.xinquan.user.service.AppUserWalletRecordService;
+import com.xinquan.user.service.AppUserWithdrawService;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.expression.spel.ast.OpNE;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
@@ -45,7 +49,48 @@
     @Resource
     private AppUserWalletRecordService walletRecordService;
     @Resource
+    private AppUserWithdrawService appUserWithdrawService;
+    @Resource
+    private AppUserWalletRecordService appUserWalletRecordService;
+    @Resource
     private RemoteOrderService remoteOrderService;
+    @PostMapping("/childUserList")
+    @ApiOperation(value = "用户详情-下级用户列表",tags = "管理后台-用户管理")
+    public R<PageDTO<AppUser>> childUserList(@RequestBody UserChildDTO dto) {
+        String startTime = null;
+        String endTime = null;
+        if (org.springframework.util.StringUtils.hasLength(dto.getTime())){
+            String[] split = dto.getTime().split(" - ");
+            startTime = split[0]+"00:00:00";
+            endTime = split[1]+"23:59:59";
+        }
+        String userId = dto.getUid();
+        LambdaQueryWrapper<AppUser> appUserWalletRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        appUserWalletRecordLambdaQueryWrapper.between(startTime!=null,BaseModel::getCreateTime,startTime,endTime);
+        appUserWalletRecordLambdaQueryWrapper.eq(AppUser::getInviteUserId, userId);
+        appUserWalletRecordLambdaQueryWrapper.like(StringUtils.hasLength(dto.getCellPhone()),AppUser::getCellPhone,dto.getCellPhone());
+        appUserWalletRecordLambdaQueryWrapper.like(StringUtils.hasLength(dto.getNickName()),AppUser::getNickname,dto.getNickName());
+        appUserWalletRecordLambdaQueryWrapper.orderByDesc(BaseModel::getCreateTime);
+        Page<AppUser> page = appUserService
+                .page(new Page<>(dto.getPageCurr(), dto.getPageSize()),appUserWalletRecordLambdaQueryWrapper);
+        if (CollUtils.isEmpty(page.getRecords())){
+            PageDTO<AppUser> empty = PageDTO.empty(page);
+            return R.ok(empty);
+        }
+        for (AppUser record : page.getRecords()) {
+            // 查询该用户带来收益
+            List<AppUserWalletRecord> list = appUserWalletRecordService.lambdaQuery().eq(AppUserWalletRecord::getAppUserId, record.getId())
+                    .eq(AppUserWalletRecord::getChildAppUserId, record.getUserId()).list();
+            BigDecimal bigDecimal = new BigDecimal("0");
+            for (AppUserWalletRecord appUserWalletRecord : list) {
+                if (appUserWalletRecord.getAmount()!=null && appUserWalletRecord.getChangeType() == 1){
+                    bigDecimal = bigDecimal.add(appUserWalletRecord.getAmount());
+                }
+                record.setMoney(bigDecimal);
+            }
+        }
+        return R.ok(PageDTO.of(page, AppUser.class));
+    }
     @PostMapping("/userBalanceList")
     @ApiOperation(value = "用户详情-余额明细",tags = "管理后台-用户管理")
     public R<PageDTO<OrderListVO>> userBalanceList(@RequestBody UserBalanceDetailDTO dto) {
@@ -114,33 +159,34 @@
         AppUserWalletRecord byId = walletRecordService.getById(uid);
         if (byId.getOrderId()!=null){
             if (byId.getReason().equals("提现")){
-                // 远程查询提现记录
+                AppUserWithdraw byId1 = appUserWithdrawService.getById(byId.getOrderId());
                 orderDetailVO.setType("提现");
+                orderDetailVO.setPayOrderNo(byId1.getSerialNo());
+                orderDetailVO.setWithdrawType(byId1.getWithdrawType());
+                orderDetailVO.setAmount(byId1.getAmount());
+                orderDetailVO.setChangeType(byId.getChangeType());
+                orderDetailVO.setPaymentTime(byId1.getUpdateTime());
             }else if (byId.getReason().equals("充值")){
                 Order one = remoteOrderService.getOrderById(byId.getOrderId()).getData();
                 if (byId.getChildAppUserId() == null && one!=null){
-                    if (one.getOrderFrom()!=null){
-                        switch (one.getOrderFrom()){
-                            case 1:
-                                orderDetailVO.setType("购买疗愈");
-                                break;
-                            case 2:
-                                orderDetailVO.setType("购买课程");
-                                break;
-                            case 3:
-                                orderDetailVO.setType("购买会员");
-                                break;
-                            case 4:
-                                orderDetailVO.setType("充值");
-                                break;
-                        }
-                    }
+                    orderDetailVO.setType("充值");
+                    orderDetailVO.setPayType(one.getPayType());
+                    orderDetailVO.setPayOrderNo(one.getPayOrderNo());
                     orderDetailVO.setRemark(one.getRemark());
+                    orderDetailVO.setChangeType(byId.getChangeType());
+                    orderDetailVO.setAmount(byId.getAmount());
                     orderDetailVO.setPaymentTime(one.getPaymentTime());
                     return R.ok(orderDetailVO);
-                }else if (byId.getChildAppUserId()!=null && one!=null){
+                }
+            }else if (byId.getReason().equals("分佣收益")){
+                Order one = remoteOrderService.getOrderById(byId.getOrderId()).getData();
+                if (byId.getChildAppUserId()!=null && one!=null){
                     orderDetailVO.setType("分佣");
                     orderDetailVO.setPayOrderNo(one.getPayOrderNo());
+                    orderDetailVO.setPaymentTime(byId.getCreateTime());
+                    orderDetailVO.setChangeType(byId.getChangeType());
+                    orderDetailVO.setAmount(byId.getAmount());
+                    orderDetailVO.setRemark(one.getRemark());
                     if (one.getCommissionId()!=null){
                         AppUser appUserById = appUserService.getById(one.getCommissionId());
                         orderDetailVO.setUserName(appUserById.getNickname());
@@ -148,12 +194,19 @@
                     }
                     return R.ok(new OrderDetailVO());
                 }
-            }else if (byId.getReason().equals("分佣收益")){
-
             }else if (byId.getReason().equals("提现回退")){
+                AppUserWithdraw byId1 = appUserWithdrawService.getById(byId.getOrderId());
+                orderDetailVO.setType("提现回退");
+                orderDetailVO.setPayOrderNo(byId1.getSerialNo());
+                orderDetailVO.setWithdrawType(byId1.getWithdrawType());
+                orderDetailVO.setAmount(byId1.getAmount());
+                orderDetailVO.setChangeType(byId.getChangeType());
+                orderDetailVO.setPaymentTime(byId1.getUpdateTime());
+                return R.ok(new OrderDetailVO());
+
+            }
         }
-        }
-        return R.ok();
+        return R.ok(orderDetailVO);
     }
 
     @PostMapping("/balanceDetail")
@@ -168,34 +221,34 @@
         AppUserWalletRecord byId = walletRecordService.getById(id);
         if (byId.getOrderId()!=null){
             if (byId.getReason().equals("提现")){
-                // 远程查询提现记录
+                AppUserWithdraw byId1 = appUserWithdrawService.getById(byId.getOrderId());
                 orderDetailVO.setType("提现");
-            }else{
+                orderDetailVO.setPayOrderNo(byId1.getSerialNo());
+                orderDetailVO.setWithdrawType(byId1.getWithdrawType());
+                orderDetailVO.setAmount(byId1.getAmount());
+                orderDetailVO.setChangeType(byId.getChangeType());
+                orderDetailVO.setPaymentTime(byId1.getUpdateTime());
+            }else if (byId.getReason().equals("充值")){
                 Order one = remoteOrderService.getOrderById(byId.getOrderId()).getData();
                 if (byId.getChildAppUserId() == null && one!=null){
-                    orderDetailVO.setId(id);
-                    if (one.getOrderFrom()!=null){
-                        switch (one.getOrderFrom()){
-                            case 1:
-                                orderDetailVO.setType("购买疗愈");
-                                break;
-                            case 2:
-                                orderDetailVO.setType("购买课程");
-                                break;
-                            case 3:
-                                orderDetailVO.setType("购买会员");
-                                break;
-                            case 4:
-                                orderDetailVO.setType("充值");
-                                break;
-                        }
-                    }
+                    orderDetailVO.setType("充值");
+                    orderDetailVO.setPayType(one.getPayType());
+                    orderDetailVO.setPayOrderNo(one.getPayOrderNo());
                     orderDetailVO.setRemark(one.getRemark());
+                    orderDetailVO.setChangeType(byId.getChangeType());
+                    orderDetailVO.setAmount(byId.getAmount());
                     orderDetailVO.setPaymentTime(one.getPaymentTime());
                     return R.ok(orderDetailVO);
-                }else if (byId.getChildAppUserId()!=null && one!=null){
+                }
+            }else if (byId.getReason().equals("分佣收益")){
+                Order one = remoteOrderService.getOrderById(byId.getOrderId()).getData();
+                if (byId.getChildAppUserId()!=null && one!=null){
                     orderDetailVO.setType("分佣");
                     orderDetailVO.setPayOrderNo(one.getPayOrderNo());
+                    orderDetailVO.setPaymentTime(byId.getCreateTime());
+                    orderDetailVO.setChangeType(byId.getChangeType());
+                    orderDetailVO.setAmount(byId.getAmount());
+                    orderDetailVO.setRemark(one.getRemark());
                     if (one.getCommissionId()!=null){
                         AppUser appUserById = appUserService.getById(one.getCommissionId());
                         orderDetailVO.setUserName(appUserById.getNickname());
@@ -203,9 +256,19 @@
                     }
                     return R.ok(new OrderDetailVO());
                 }
+            }else if (byId.getReason().equals("提现回退")){
+                AppUserWithdraw byId1 = appUserWithdrawService.getById(byId.getOrderId());
+                orderDetailVO.setType("提现回退");
+                orderDetailVO.setPayOrderNo(byId1.getSerialNo());
+                orderDetailVO.setWithdrawType(byId1.getWithdrawType());
+                orderDetailVO.setAmount(byId1.getAmount());
+                orderDetailVO.setChangeType(byId.getChangeType());
+                orderDetailVO.setPaymentTime(byId1.getUpdateTime());
+                return R.ok(new OrderDetailVO());
+
             }
         }
-        return R.ok();
+        return R.ok(orderDetailVO);
     }
 }
 

--
Gitblit v1.7.1