更新
This commit is contained in:
parent
75dede5e20
commit
27bf7c5fad
|
@ -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<ServiceIncomeVO> getServiceIncome(ServiceIncomeQuery query) {
|
||||
|
||||
// 查询服务费
|
||||
BonusQuery bonusQuery = new BonusQuery();
|
||||
bonusQuery.setPayDateStart(query.getStartDate());
|
||||
bonusQuery.setPayDateEnd(query.getEndDate());
|
||||
bonusQuery.setArrivalType(BonusArrivalType.PLATFORM.getType());
|
||||
List<BonusDailyAmountVO> 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<Date> 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,9 @@ import java.math.BigDecimal;
|
|||
@Data
|
||||
public class BonusMonthAmountVO {
|
||||
|
||||
@ApiModelProperty("年份")
|
||||
private Integer year;
|
||||
|
||||
@ApiModelProperty("月份")
|
||||
private Integer month;
|
||||
|
||||
|
|
|
@ -147,7 +147,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="selectMonthAmount" resultMap="BonusMonthAmountVO">
|
||||
select
|
||||
month(sb.pay_time) as month,
|
||||
year(sb.pay_time) as `year`,
|
||||
month(sb.pay_time) as `month`,
|
||||
sum(amount) as amount
|
||||
<include refid="searchTables"/>
|
||||
<where>
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.ruoyi.ss.bonus.domain.vo.BonusMonthAmountVO;
|
|||
import com.ruoyi.ss.bonus.domain.vo.ProvideBonusVO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -141,4 +142,9 @@ public interface BonusService
|
|||
* @return
|
||||
*/
|
||||
int selectCount(BonusQuery query);
|
||||
|
||||
/**
|
||||
* 支付预计分成在指定时间的分成
|
||||
*/
|
||||
int payBonusBeforeTime(LocalDateTime time);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.ruoyi.ss.user.service.UserAssembler;
|
|||
import com.ruoyi.system.domain.enums.config.ConfigKey;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import com.ruoyi.system.service.ISysDeptService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
@ -36,6 +37,8 @@ import java.math.RoundingMode;
|
|||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -45,6 +48,7 @@ import java.util.stream.Collectors;
|
|||
* @date 2024-08-20
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class BonusServiceImpl implements BonusService
|
||||
{
|
||||
@Autowired
|
||||
|
@ -68,6 +72,9 @@ public class BonusServiceImpl implements BonusService
|
|||
@Autowired
|
||||
private UserAssembler userAssembler;
|
||||
|
||||
@Autowired
|
||||
private ScheduledExecutorService scheduledExecutorService;
|
||||
|
||||
/**
|
||||
* 查询分成明细
|
||||
*
|
||||
|
@ -290,6 +297,11 @@ public class BonusServiceImpl implements BonusService
|
|||
return updateAmount;
|
||||
});
|
||||
|
||||
// 立即执行一次分成
|
||||
scheduledExecutorService.schedule(() -> {
|
||||
this.payBonusBeforeTime(LocalDateTime.now());
|
||||
}, 3, TimeUnit.SECONDS);
|
||||
|
||||
return result == null ? 0 : result;
|
||||
}
|
||||
|
||||
|
@ -373,6 +385,31 @@ public class BonusServiceImpl implements BonusService
|
|||
return bonusMapper.selectCount(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int payBonusBeforeTime(LocalDateTime time) {
|
||||
// 查询预计分成时间当前时间之前,且为待分成的分成单
|
||||
BonusQuery query = new BonusQuery();
|
||||
query.setStatus(BonusStatus.WAIT_DIVIDE.getStatus());
|
||||
query.setPrePayTimeEnd(time);
|
||||
List<BonusVO> list = this.selectBonusList(query);
|
||||
|
||||
if (CollectionUtils.isEmptyElement(list)) {
|
||||
log.info("暂无待分成的分成单");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sum = 0;
|
||||
for (BonusVO bonus : list) {
|
||||
try {
|
||||
sum += this.payBonus(bonus);
|
||||
} catch (Exception e) {
|
||||
log.warn("分成打款失败:id={}, e={}", bonus.getId(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
private int batchUpdateAmount(List<BonusVO> list) {
|
||||
if (CollectionUtils.isEmptyElement(list)) {
|
||||
return 0;
|
||||
|
|
|
@ -204,7 +204,7 @@ public class SmBusinessRecordServiceImpl implements ISmBusinessRecordService
|
|||
rechargeDto.setStatus(TransactionBillStatus.SUCCESS.getStatus());
|
||||
List<BillCountVo> billCount = transactionBillService.selectCount(rechargeDto);
|
||||
if (!CollectionUtils.isEmpty(billCount) && billCount.get(0).getRecharge() != null) {
|
||||
brief.setRechargeAmount(billCount.get(0).getRecharge());
|
||||
brief.setRechargeAmount(billCount.get(0).getRechargeAmount());
|
||||
} else {
|
||||
brief.setRechargeAmount(BigDecimal.ZERO);
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ public class SmBusinessRecordServiceImpl implements ISmBusinessRecordService
|
|||
todayRechargeQuery.setCreateDate(now);
|
||||
List<BillCountVo> todayBillCount = transactionBillService.selectCount(todayRechargeQuery);
|
||||
if (!CollectionUtils.isEmpty(todayBillCount) && todayBillCount.get(0).getRecharge() != null) {
|
||||
brief.setTodayRechargeAmount(todayBillCount.get(0).getRecharge());
|
||||
brief.setTodayRechargeAmount(todayBillCount.get(0).getRechargeAmount());
|
||||
} else {
|
||||
brief.setTodayRechargeAmount(BigDecimal.ZERO);
|
||||
}
|
||||
|
|
|
@ -81,4 +81,8 @@ public class BillCountVo {
|
|||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModelProperty("数量")
|
||||
private Integer count;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModelProperty("订单金额")
|
||||
private BigDecimal rechargeAmount;
|
||||
}
|
||||
|
|
|
@ -298,6 +298,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="serviceCharge" column="service_charge" typeHandler="com.ruoyi.system.mapper.typehandler.NonNullDecimalTypeHandler"/>
|
||||
<result property="channelCost" column="channel_cost" typeHandler="com.ruoyi.system.mapper.typehandler.NonNullDecimalTypeHandler"/>
|
||||
<result property="profit" column="profit" typeHandler="com.ruoyi.system.mapper.typehandler.NonNullDecimalTypeHandler"/>
|
||||
<result property="rechargeAmount" column="recharge_amount" typeHandler="com.ruoyi.system.mapper.typehandler.NonNullDecimalTypeHandler"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectCount" resultMap="BillCountVo">
|
||||
|
@ -327,6 +328,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
stb.device_id as device_id,
|
||||
</if>
|
||||
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,
|
||||
|
|
|
@ -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<BonusVO> 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;
|
||||
});
|
||||
|
||||
|
|
|
@ -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
|
||||
</sql>
|
||||
|
||||
|
|
|
@ -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<BonusVO> 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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user