From 27bf7c5fad82f549eb4cdc9d3b083ab8ce1efa5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A3=B7=E5=8F=B6?= <14103883+leaf-phos@user.noreply.gitee.com> Date: Wed, 2 Oct 2024 15:00:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/dashboard/DashboardService.java | 28 ++++++++++++-- .../bonus/domain/vo/BonusMonthAmountVO.java | 3 ++ .../com/ruoyi/ss/bonus/mapper/BonusMapper.xml | 3 +- .../ruoyi/ss/bonus/service/BonusService.java | 6 +++ .../bonus/service/impl/BonusServiceImpl.java | 37 +++++++++++++++++++ .../service/SmBusinessRecordServiceImpl.java | 4 +- .../ruoyi/ss/dashboard/vo/BillCountVo.java | 4 ++ .../mapper/TransactionBillMapper.xml | 2 + .../impl/TransactionBillServiceImpl.java | 17 +++++++-- .../com/ruoyi/ss/user/mapper/SmUserMapper.xml | 2 +- .../java/com/ruoyi/task/bonus/BonusTask.java | 25 +------------ .../controller/ss/SmDashboardController.java | 14 +++++++ .../src/main/resources/application-dev.yml | 4 +- 13 files changed, 113 insertions(+), 36 deletions(-) diff --git a/smart-switch-service/src/main/java/com/ruoyi/dashboard/DashboardService.java b/smart-switch-service/src/main/java/com/ruoyi/dashboard/DashboardService.java index 7c37d1f2..0693a5a1 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/dashboard/DashboardService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/dashboard/DashboardService.java @@ -6,6 +6,10 @@ import com.ruoyi.dashboard.vo.TodoListVO; import com.ruoyi.ss.abnormal.domain.AbnormalQuery; import com.ruoyi.ss.abnormal.domain.enums.AbnormalStatus; import com.ruoyi.ss.abnormal.service.AbnormalService; +import com.ruoyi.ss.bonus.domain.BonusQuery; +import com.ruoyi.ss.bonus.domain.enums.BonusArrivalType; +import com.ruoyi.ss.bonus.domain.vo.BonusDailyAmountVO; +import com.ruoyi.ss.bonus.service.BonusService; import com.ruoyi.ss.complaint.domain.SmComplaintQuery; import com.ruoyi.ss.complaint.service.ISmComplaintService; import com.ruoyi.ss.dashboard.ServiceIncomeQuery; @@ -64,6 +68,9 @@ public class DashboardService { @Autowired private ReceiveBillService receiveBillService; + @Autowired + private BonusService bonusService; + public TodoListVO getTodoList() { TodoListVO vo = new TodoListVO(); @@ -101,6 +108,13 @@ public class DashboardService { public List getServiceIncome(ServiceIncomeQuery query) { + // 查询服务费 + BonusQuery bonusQuery = new BonusQuery(); + bonusQuery.setPayDateStart(query.getStartDate()); + bonusQuery.setPayDateEnd(query.getEndDate()); + bonusQuery.setArrivalType(BonusArrivalType.PLATFORM.getType()); + List bonusList = bonusService.selectDailyAmount(bonusQuery); + // 查询订单 TransactionBillQuery billQuery = new TransactionBillQuery(); billQuery.setStartDate(query.getStartDate()); @@ -126,15 +140,23 @@ public class DashboardService { ServiceIncomeVO vo = new ServiceIncomeVO(); vo.setDate(date); - // 订单服务费收入及成本 + // 订单服务费 + BonusDailyAmountVO bonus = bonusList.stream() + .filter(item -> item.getKey().isEqual(date)) + .findFirst().orElse(null); + if (bonus != null) { + vo.setServiceAmount(bonus.getSum()); + } else { + vo.setServiceAmount(BigDecimal.ZERO); + } + + // 渠道成本 TransactionAmountVO transaction = amountList.stream() .filter(item -> item.getKey().compareTo(DateUtils.toDate(date)) == 0) .findFirst().orElse(null); if (transaction != null) { - vo.setServiceAmount(transaction.getServiceAmount()); vo.setChannelCost(transaction.getChannelCost()); } else { - vo.setServiceAmount(BigDecimal.ZERO); vo.setChannelCost(BigDecimal.ZERO); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/domain/vo/BonusMonthAmountVO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/domain/vo/BonusMonthAmountVO.java index c44853a5..eae8306d 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/domain/vo/BonusMonthAmountVO.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/domain/vo/BonusMonthAmountVO.java @@ -12,6 +12,9 @@ import java.math.BigDecimal; @Data public class BonusMonthAmountVO { + @ApiModelProperty("年份") + private Integer year; + @ApiModelProperty("月份") private Integer month; diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/mapper/BonusMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/mapper/BonusMapper.xml index caa0f0be..4a3d1ae1 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/mapper/BonusMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/mapper/BonusMapper.xml @@ -147,7 +147,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -327,6 +328,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" stb.device_id as device_id, SUM(IF( stb.type = '1' and stb.status = '2', stb.arrival_amount, 0 )) AS recharge, + SUM(IF( stb.type = '1' and stb.status = '2', stb.money, 0 )) AS recharge_amount, SUM(IF( stb.type = '2' and stb.status = '14', stb.arrival_amount, 0 )) AS withdraw, SUM(stb.service_charge) AS service_charge, SUM(stb.channel_cost) AS channel_cost, diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java index 1bce4137..8739489b 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java @@ -933,7 +933,15 @@ public class TransactionBillServiceImpl implements TransactionBillService, After ServiceUtil.assertion(bill == null || !TransactionBillType.RECHARGE.getType().equals(bill.getType()), "充值订单不存在"); ServiceUtil.assertion(!TransactionBillStatus.UNPAID.getStatus().equals(bill.getStatus()), "当前订单状态非未支付"); + List bonusList = bill.getBonusList(); + Integer result = transactionTemplate.execute(status -> { + + // 处理分成,将金额分好 + bonusService.partBonus(bonusList, bill.getMoney()); + BonusVO platform = bonusList.stream().filter(bonus -> bonus.getArrivalType().equals(BonusArrivalType.PLATFORM.getType())).findFirst().orElse(null); + BonusVO mch = bonusList.stream().filter(bonus -> bonus.getArrivalType().equals(BonusArrivalType.MCH.getType())).findFirst().orElse(null); + // 修改订单信息 TransactionBill data = new TransactionBill(); data.setStatus(TransactionBillStatus.SUCCESS.getStatus()); @@ -941,6 +949,12 @@ public class TransactionBillServiceImpl implements TransactionBillService, After data.setChannelId(pay.getChannelId()); data.setChannelCost(pay.getChannelCost()); data.setPayId(pay.getPayId()); + if (platform != null) { + data.setServiceCharge(platform.getAmount()); + } + if (mch != null) { + data.setArrivalAmount(mch.getAmount()); + } TransactionBillQuery query = new TransactionBillQuery(); query.setBillId(bill.getBillId()); query.setStatus(TransactionBillStatus.UNPAID.getStatus()); @@ -948,9 +962,6 @@ public class TransactionBillServiceImpl implements TransactionBillService, After int updateCount = this.updateByQuery(data, query); ServiceUtil.assertion(updateCount != 1, "订单状态已发生变化,请刷新后重试"); - // 处理分成,将金额分好 - bonusService.partBonus(bill.getBonusList(), bill.getMoney()); - return updateCount; }); diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/user/mapper/SmUserMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/user/mapper/SmUserMapper.xml index 2bcaa85d..5c5ce367 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/user/mapper/SmUserMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/user/mapper/SmUserMapper.xml @@ -59,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" if(su.is_real, su.real_name, su.user_name) as real_or_user_name, (select sum(stb.money) from sm_transaction_bill stb where stb.user_id = su.user_id and stb.type = '1' and stb.status = '2') as recharge_amount, (select sum(stb.arrival_amount) from sm_transaction_bill stb where stb.user_id = su.user_id and stb.type = '2' and stb.status = '14') as with_drawl_amount, - (select sum(stb.arrival_amount) from sm_transaction_bill stb where stb.mch_id = su.user_id and stb.type = '1' and stb.status = '2') as total_income + (select sum(sb.payed_amount) from ss_bonus sb where sb.arrival_id = su.user_id and sb.arrival_type in ('2', '3')) as total_income from sm_user su diff --git a/smart-switch-service/src/main/java/com/ruoyi/task/bonus/BonusTask.java b/smart-switch-service/src/main/java/com/ruoyi/task/bonus/BonusTask.java index 35901d5f..9d3242e6 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/task/bonus/BonusTask.java +++ b/smart-switch-service/src/main/java/com/ruoyi/task/bonus/BonusTask.java @@ -1,16 +1,11 @@ package com.ruoyi.task.bonus; -import com.ruoyi.common.utils.collection.CollectionUtils; -import com.ruoyi.ss.bonus.domain.BonusQuery; -import com.ruoyi.ss.bonus.domain.BonusVO; -import com.ruoyi.ss.bonus.domain.enums.BonusStatus; import com.ruoyi.ss.bonus.service.BonusService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.time.LocalDateTime; -import java.util.List; /** * @author wjh @@ -27,25 +22,7 @@ public class BonusTask { * 分成打款 */ public void payBonus() { - // 查询预计分成时间当前时间之前,且为待分成的分成单 - BonusQuery query = new BonusQuery(); - query.setStatus(BonusStatus.WAIT_DIVIDE.getStatus()); - query.setPrePayTimeEnd(LocalDateTime.now()); - List list = bonusService.selectBonusList(query); - - if (CollectionUtils.isEmptyElement(list)) { - log.info("暂无待分成的分成单"); - return; - } - - for (BonusVO bonus : list) { - try { - bonusService.payBonus(bonus); - } catch (Exception e) { - log.warn("分成打款失败:id={}, e={}", bonus.getId(), e.getMessage()); - } - } - + bonusService.payBonusBeforeTime(LocalDateTime.now()); } } diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDashboardController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDashboardController.java index d1b55651..40a70fd5 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDashboardController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDashboardController.java @@ -7,6 +7,8 @@ import com.ruoyi.common.utils.DateUtils; import com.ruoyi.dashboard.DashboardService; import com.ruoyi.ss.balancePeriod.domain.SmBalancePeriodQuery; import com.ruoyi.ss.balancePeriod.service.ISmBalancePeriodService; +import com.ruoyi.ss.bonus.domain.BonusQuery; +import com.ruoyi.ss.bonus.service.BonusService; import com.ruoyi.ss.businessRecord.service.ISmBusinessRecordService; import com.ruoyi.ss.dashboard.ServiceIncomeQuery; import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery; @@ -42,9 +44,13 @@ public class SmDashboardController extends BaseController { @Autowired private ISmBusinessRecordService businessRecordService; + @Autowired private DashboardService dashboardService; + @Autowired + private BonusService bonusService; + /** * 舆情分析数据 */ @@ -99,4 +105,12 @@ public class SmDashboardController extends BaseController { return success(dashboardService.getServiceIncome(query)); } + /** + * 按月统计分成 + */ + @GetMapping("/bonusMonthAmount") + public AjaxResult getBonusMonthAmount(BonusQuery query) { + return success(bonusService.selectMonthAmount(query)); + } + } diff --git a/smart-switch-web/src/main/resources/application-dev.yml b/smart-switch-web/src/main/resources/application-dev.yml index 9474375e..1b85f834 100644 --- a/smart-switch-web/src/main/resources/application-dev.yml +++ b/smart-switch-web/src/main/resources/application-dev.yml @@ -26,8 +26,8 @@ wx: # 转账回调地址 transferNotifyUrl: https://kg-dev.chuangtewl.com/dev-api/app/pay/notify/wx/transfer # 密钥所在位置 -# privateKeyPath: H:/project/创特/证书/wxpay-kg/apiclient_key.pem - privateKeyPath: D:/project/证书/wxpay-kg/apiclient_key.pem + privateKeyPath: H:/project/创特/证书/wxpay-kg/apiclient_key.pem +# privateKeyPath: D:/project/证书/wxpay-kg/apiclient_key.pem # 证书序列号 merchantSerialNumber: 6AD69237C0F22A9AE51A64F1927E3A0962AC1FB0