From 039a33d1bfa6ef041161666bbd120c34086fe7c1 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期一, 14 十月 2024 14:09:25 +0800
Subject: [PATCH] 课程代码

---
 xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserWalletRecordController.java |  194 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 192 insertions(+), 2 deletions(-)

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 7864c84..12a7eed 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
@@ -1,9 +1,33 @@
 package com.xinquan.user.controller.client;
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.xinquan.common.core.domain.R;
+import com.xinquan.common.core.utils.page.CollUtils;
+import com.xinquan.common.core.utils.page.PageDTO;
+import com.xinquan.common.core.web.domain.BaseModel;
+import com.xinquan.common.security.utils.SecurityUtils;
+import com.xinquan.order.api.domain.Order;
+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.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.service.AppUserService;
+import com.xinquan.user.service.AppUserWalletRecordService;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
 
-import org.springframework.web.bind.annotation.RestController;
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -16,6 +40,172 @@
 @RestController
 @RequestMapping("/client/app-user-wallet-record")
 public class ClientAppUserWalletRecordController {
+    @Resource
+    private AppUserService appUserService;
+    @Resource
+    private AppUserWalletRecordService walletRecordService;
+    @Resource
+    private RemoteOrderService remoteOrderService;
+    @PostMapping("/userBalanceList")
+    @ApiOperation(value = "用户详情-余额明细",tags = "管理后台-用户管理")
+    public R<PageDTO<OrderListVO>> userBalanceList(@RequestBody UserBalanceDetailDTO 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<AppUserWalletRecord> appUserWalletRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        appUserWalletRecordLambdaQueryWrapper.between(startTime!=null,BaseModel::getCreateTime,startTime,endTime);
+        appUserWalletRecordLambdaQueryWrapper.eq(AppUserWalletRecord::getAppUserId, userId);
+        appUserWalletRecordLambdaQueryWrapper.like(StringUtils.hasLength(dto.getReason()),AppUserWalletRecord::getReason,dto.getReason());
+        appUserWalletRecordLambdaQueryWrapper.orderByDesc(BaseModel::getCreateTime);
+        Page<AppUserWalletRecord> page = walletRecordService
+                .page(new Page<>(dto.getPageCurr(), dto.getPageSize()),appUserWalletRecordLambdaQueryWrapper);
+        if (CollUtils.isEmpty(page.getRecords())){
+            PageDTO<OrderListVO> empty = PageDTO.empty(page);
+            return R.ok(empty);
+        }
+        return R.ok(PageDTO.of(page, OrderListVO.class));
+    }
+    /**
+     * 爱心助力榜单-分页
+     *
+     * @param pageCurr    分页参数,当前页码
+     * @param pageSize    分页参数,每页数量
+     * @return 课程分页列表
+     */
+    @PostMapping("/balanceList")
+    @ApiOperation(value = "余额明细列表",tags = "钱包")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "state", value = "1全部 2收入 3支出", dataType = "Integer", required = true),
+            @ApiImplicitParam(value = "分页参数,当前页码", name = "pageCurr", required = true, dataType = "Integer"),
+            @ApiImplicitParam(value = "分页参数,每页数量", name = "pageSize", required = true, dataType = "Integer")
+    })
+    public R<PageDTO<OrderListVO>> balanceList(Integer state,Integer pageCurr, Integer pageSize) {
+        Long userId = SecurityUtils.getUserId();
+        if (userId==0)return R.tokenError("登录失效");
+        LambdaQueryWrapper<AppUserWalletRecord> appUserWalletRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        if (state!=1){
+            appUserWalletRecordLambdaQueryWrapper.eq(AppUserWalletRecord::getChangeType, state);
+        }
+        appUserWalletRecordLambdaQueryWrapper.eq(AppUserWalletRecord::getAppUserId, userId);
+        appUserWalletRecordLambdaQueryWrapper.orderByDesc(BaseModel::getCreateTime);
+        Page<AppUserWalletRecord> page = walletRecordService
+                .page(new Page<>(pageCurr, pageSize),appUserWalletRecordLambdaQueryWrapper);
+        if (CollUtils.isEmpty(page.getRecords())){
+            PageDTO<OrderListVO> empty = PageDTO.empty(page);
+            return R.ok(empty);
+        }
+        for (AppUserWalletRecord record : page.getRecords()) {
+            record.setUid(record.getId()+"");
+        }
+        return R.ok(PageDTO.of(page, OrderListVO.class));
+    }
+    @PostMapping("/userBalanceDetail")
+    @ApiOperation(value = "用户详情-余额明细-详情",tags = "管理后台-用户管理")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "uid", value = "uid", dataType = "Long", required = true),
+    })
+    public R<OrderDetailVO> userBalanceDetail(String uid) {
+        OrderDetailVO orderDetailVO = new OrderDetailVO();
+        AppUserWalletRecord byId = walletRecordService.getById(uid);
+        if (byId.getOrderId()!=null){
+            if (byId.getReason().equals("提现")){
+                // 远程查询提现记录
+                orderDetailVO.setType("提现");
+            }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.setRemark(one.getRemark());
+                    orderDetailVO.setPaymentTime(one.getPaymentTime());
+                    return R.ok(orderDetailVO);
+                }else if (byId.getChildAppUserId()!=null && one!=null){
+                    orderDetailVO.setType("分佣");
+                    orderDetailVO.setPayOrderNo(one.getPayOrderNo());
+                    if (one.getCommissionId()!=null){
+                        AppUser appUserById = appUserService.getById(one.getCommissionId());
+                        orderDetailVO.setUserName(appUserById.getNickname());
+                        orderDetailVO.setAvatar(appUserById.getAvatar());
+                    }
+                    return R.ok(new OrderDetailVO());
+                }
+            }else if (byId.getReason().equals("分佣收益")){
 
+            }else if (byId.getReason().equals("提现回退")){
+        }
+        }
+        return R.ok();
+    }
+
+    @PostMapping("/balanceDetail")
+    @ApiOperation(value = "余额明细列表-查看详情",tags = "钱包")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", dataType = "Long", required = true),
+    })
+    public R<OrderDetailVO> balanceDetail(Long id) {
+        Long userId = SecurityUtils.getUserId();
+        if (userId==0)return R.tokenError("登录失效");
+        OrderDetailVO orderDetailVO = new OrderDetailVO();
+        AppUserWalletRecord byId = walletRecordService.getById(id);
+        if (byId.getOrderId()!=null){
+            if (byId.getReason().equals("提现")){
+                // 远程查询提现记录
+                orderDetailVO.setType("提现");
+            }else{
+                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.setRemark(one.getRemark());
+                    orderDetailVO.setPaymentTime(one.getPaymentTime());
+                    return R.ok(orderDetailVO);
+                }else if (byId.getChildAppUserId()!=null && one!=null){
+                    orderDetailVO.setType("分佣");
+                    orderDetailVO.setPayOrderNo(one.getPayOrderNo());
+                    if (one.getCommissionId()!=null){
+                        AppUser appUserById = appUserService.getById(one.getCommissionId());
+                        orderDetailVO.setUserName(appUserById.getNickname());
+                        orderDetailVO.setAvatar(appUserById.getAvatar());
+                    }
+                    return R.ok(new OrderDetailVO());
+                }
+            }
+        }
+        return R.ok();
+    }
 }
 

--
Gitblit v1.7.1