From 111652d23733d04e379c2454c8b39171596a6b50 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期六, 09 十一月 2024 14:28:51 +0800 Subject: [PATCH] 代码提交 --- xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserWalletRecordController.java | 42 ++++++++++++++++++++++++++++++++++++------ 1 files changed, 36 insertions(+), 6 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 65268ac..567e37c 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,6 +12,8 @@ import com.xinquan.common.security.utils.SecurityUtils; import com.xinquan.course.api.domain.Course; import com.xinquan.course.api.feign.RemoteCourseService; +import com.xinquan.meditation.api.domain.Meditation; +import com.xinquan.meditation.api.feign.RemoteMeditationService; import com.xinquan.order.api.domain.Order; import com.xinquan.order.api.feign.RemoteOrderService; import com.xinquan.system.api.domain.AppUser; @@ -63,10 +65,22 @@ private RemoteOrderService remoteOrderService; @Resource private RemoteCourseService remoteCourseService; + @Resource + private RemoteMeditationService remoteMeditationService; // 用户获得分佣收益 新增一条余额明细记录 @PostMapping("/addBalanceRecord") public R addBalanceRecord(@RequestBody AppUserWalletRecord appUserWalletRecord) { appUserWalletRecordService.save(appUserWalletRecord); + if(appUserWalletRecord.getReason().contains("分佣")){ + AppUser byId = appUserService.getById(appUserWalletRecord.getAppUserId()); + byId.setBalance(byId.getBalance().add(appUserWalletRecord.getAmount())); + appUserService.updateById(byId); + } + if (appUserWalletRecord.getChangeType() == 2){ + AppUser byId = appUserService.getById(appUserWalletRecord.getAppUserId()); + byId.setBalance(byId.getBalance().subtract(appUserWalletRecord.getAmount())); + appUserService.updateById(byId); + } return R.ok(); } @@ -86,6 +100,7 @@ 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.eq(StringUtils.hasLength(dto.getUserStatus()),AppUser::getUserStatus,dto.getUserStatus()); appUserWalletRecordLambdaQueryWrapper.orderByDesc(BaseModel::getCreateTime); Page<AppUser> page = appUserService .page(new Page<>(dto.getPageCurr(), dto.getPageSize()),appUserWalletRecordLambdaQueryWrapper); @@ -95,9 +110,11 @@ } for (AppUser record : page.getRecords()) { // 查询该用户带来收益 - List<AppUserWalletRecord> list = appUserWalletRecordService.lambdaQuery().eq(AppUserWalletRecord::getAppUserId, record.getId()) - .eq(AppUserWalletRecord::getChildAppUserId, record.getUserId()).list(); + List<AppUserWalletRecord> list = appUserWalletRecordService.lambdaQuery() + .eq(AppUserWalletRecord::getAppUserId, userId) + .eq(AppUserWalletRecord::getChildAppUserId, record.getId()).list(); BigDecimal bigDecimal = new BigDecimal("0"); + record.setMoney(new BigDecimal("0")); for (AppUserWalletRecord appUserWalletRecord : list) { if (appUserWalletRecord.getAmount()!=null && appUserWalletRecord.getChangeType() == 1){ bigDecimal = bigDecimal.add(appUserWalletRecord.getAmount()); @@ -114,8 +131,8 @@ 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"; + startTime = split[0]+" 00:00:00"; + endTime = split[1]+" 23:59:59"; } String userId = dto.getUid(); LambdaQueryWrapper<AppUserWalletRecord> appUserWalletRecordLambdaQueryWrapper = new LambdaQueryWrapper<>(); @@ -128,6 +145,9 @@ if (CollUtils.isEmpty(page.getRecords())){ PageDTO<OrderListVO> empty = PageDTO.empty(page); return R.ok(empty); + } + for (AppUserWalletRecord record : page.getRecords()) { + record.setId(record.getOrderId()); } return R.ok(PageDTO.of(page, OrderListVO.class)); } @@ -244,7 +264,7 @@ OrderDetailVO orderDetailVO = new OrderDetailVO(); AppUserWalletRecord byId = walletRecordService.getById(id); if (byId.getOrderId()!=null){ - if (byId.getReason().equals("提现")){ + if (byId.getReason().contains("提现")){ AppUserWithdraw byId1 = appUserWithdrawService.getById(byId.getOrderId()); orderDetailVO.setType("提现"); orderDetailVO.setPayOrderNo(byId1.getSerialNo()); @@ -295,10 +315,20 @@ Course data1 = remoteCourseService.getCourseById(data.getBusinessId()).getData(); orderDetailVO.setType("课程购买"); orderDetailVO.setPayOrderNo(data.getPayOrderNo()); - orderDetailVO.setAmount(data.getRealPayAmount()); + orderDetailVO.setAmount(data.getBalance()); orderDetailVO.setChangeType(byId.getChangeType()); orderDetailVO.setPaymentTime(data.getPaymentTime()); } + } else if (byId.getReason().contains("疗愈")) { + Order data = remoteOrderService.getOrderById(byId.getOrderId()).getData(); + if (data!=null){ + Meditation data1 = remoteMeditationService.getMeditationById(data.getBusinessId()).getData(); + orderDetailVO.setType("疗愈购买"); + orderDetailVO.setPayOrderNo(data.getPayOrderNo()); + orderDetailVO.setAmount(data.getBalance()); + orderDetailVO.setChangeType(2); + orderDetailVO.setPaymentTime(data.getPaymentTime()); + } } } return R.ok(orderDetailVO); -- Gitblit v1.7.1