2024-10-08 16:05:28 +08:00
|
|
|
package com.ruoyi.dashboard.service;
|
2024-08-06 17:43:10 +08:00
|
|
|
|
2024-09-07 16:43:49 +08:00
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
|
import com.ruoyi.common.utils.collection.CollectionUtils;
|
2024-10-08 16:05:28 +08:00
|
|
|
import com.ruoyi.dashboard.domain.dto.BusinessStatisticsQuery;
|
|
|
|
import com.ruoyi.dashboard.domain.vo.BusinessStatisticsVO;
|
|
|
|
import com.ruoyi.dashboard.domain.vo.TodoListVO;
|
|
|
|
import com.ruoyi.dashboard.mapper.DashboardMapper;
|
2024-08-06 17:43:10 +08:00
|
|
|
import com.ruoyi.ss.abnormal.domain.AbnormalQuery;
|
|
|
|
import com.ruoyi.ss.abnormal.domain.enums.AbnormalStatus;
|
|
|
|
import com.ruoyi.ss.abnormal.service.AbnormalService;
|
2024-10-02 15:00:29 +08:00
|
|
|
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;
|
2024-08-06 17:43:10 +08:00
|
|
|
import com.ruoyi.ss.complaint.domain.SmComplaintQuery;
|
|
|
|
import com.ruoyi.ss.complaint.service.ISmComplaintService;
|
2024-10-08 16:05:28 +08:00
|
|
|
import com.ruoyi.dashboard.domain.dto.ServiceIncomeQuery;
|
|
|
|
import com.ruoyi.dashboard.domain.vo.ServiceIncomeVO;
|
2024-08-06 17:43:10 +08:00
|
|
|
import com.ruoyi.ss.device.domain.DeviceQuery;
|
|
|
|
import com.ruoyi.ss.device.service.DeviceService;
|
|
|
|
import com.ruoyi.ss.mchApply.domain.MchApplyQuery;
|
|
|
|
import com.ruoyi.ss.mchApply.domain.enums.MchApplyStatus;
|
|
|
|
import com.ruoyi.ss.mchApply.service.IMchApplyService;
|
2024-09-07 16:43:49 +08:00
|
|
|
import com.ruoyi.ss.receiveBill.domain.ReceiveBillQuery;
|
|
|
|
import com.ruoyi.ss.receiveBill.domain.enums.ReceiveBillGroupBy;
|
2024-09-30 13:37:19 +08:00
|
|
|
import com.ruoyi.ss.receiveBill.domain.enums.ReceiveBillType;
|
2024-09-07 16:43:49 +08:00
|
|
|
import com.ruoyi.ss.receiveBill.domain.vo.ReceiveAmountVO;
|
|
|
|
import com.ruoyi.ss.receiveBill.service.ReceiveBillService;
|
2024-11-27 18:06:07 +08:00
|
|
|
import com.ruoyi.ss.riskInfo.domain.RiskInfoQuery;
|
|
|
|
import com.ruoyi.ss.riskInfo.domain.enums.RiskInfoStatus;
|
|
|
|
import com.ruoyi.ss.riskInfo.service.RiskInfoService;
|
2024-08-06 17:43:10 +08:00
|
|
|
import com.ruoyi.ss.storeApply.domain.StoreApplyQuery;
|
|
|
|
import com.ruoyi.ss.storeApply.domain.enums.StoreApplyStatus;
|
|
|
|
import com.ruoyi.ss.storeApply.service.StoreApplyService;
|
|
|
|
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
|
2024-09-07 16:43:49 +08:00
|
|
|
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillGroupBy;
|
2024-08-06 17:43:10 +08:00
|
|
|
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus;
|
|
|
|
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillType;
|
2024-09-07 16:43:49 +08:00
|
|
|
import com.ruoyi.ss.transactionBill.domain.vo.TransactionAmountVO;
|
2024-08-06 17:43:10 +08:00
|
|
|
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
2024-09-07 16:43:49 +08:00
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
|
2024-08-06 17:43:10 +08:00
|
|
|
/**
|
|
|
|
* @author wjh
|
|
|
|
* 2024/8/6
|
|
|
|
*/
|
|
|
|
@Service
|
|
|
|
public class DashboardService {
|
|
|
|
|
2024-10-08 16:05:28 +08:00
|
|
|
@Autowired
|
|
|
|
private DashboardMapper dashboardMapper;
|
|
|
|
|
2024-08-06 17:43:10 +08:00
|
|
|
@Autowired
|
|
|
|
private TransactionBillService transactionBillService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private IMchApplyService mchApplyService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private AbnormalService abnormalService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private ISmComplaintService complaintService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private DeviceService deviceService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private StoreApplyService storeApplyService;
|
|
|
|
|
2024-09-07 16:43:49 +08:00
|
|
|
@Autowired
|
|
|
|
private ReceiveBillService receiveBillService;
|
|
|
|
|
2024-10-02 15:00:29 +08:00
|
|
|
@Autowired
|
|
|
|
private BonusService bonusService;
|
|
|
|
|
2024-11-27 18:06:07 +08:00
|
|
|
@Autowired
|
|
|
|
private RiskInfoService riskInfoService;
|
|
|
|
|
2024-08-06 17:43:10 +08:00
|
|
|
public TodoListVO getTodoList() {
|
|
|
|
TodoListVO vo = new TodoListVO();
|
|
|
|
|
|
|
|
// 提现申请数量
|
|
|
|
TransactionBillQuery withdrawQuery = new TransactionBillQuery();
|
|
|
|
withdrawQuery.setType(TransactionBillType.WITHDRAW.getType());
|
|
|
|
withdrawQuery.setStatus(TransactionBillStatus.WITHDRAW_APPROVING.getStatus());
|
|
|
|
vo.setWithdrawCount(transactionBillService.selectSimpleCount(withdrawQuery));
|
|
|
|
|
|
|
|
// 商户合作申请
|
|
|
|
MchApplyQuery mchApplyQuery = new MchApplyQuery();
|
|
|
|
mchApplyQuery.setStatus(MchApplyStatus.APPROVING.getStatus());
|
|
|
|
vo.setMchApplyCount(mchApplyService.selectCount(mchApplyQuery));
|
|
|
|
|
|
|
|
// 店铺申请
|
|
|
|
StoreApplyQuery storeApplyQuery = new StoreApplyQuery();
|
|
|
|
storeApplyQuery.setStatus(StoreApplyStatus.WAIT_AUDIT.getStatus());
|
|
|
|
vo.setStoreApplyCount(storeApplyService.selectCount(storeApplyQuery));
|
|
|
|
|
|
|
|
// 设备故障
|
|
|
|
AbnormalQuery abnormalQuery = new AbnormalQuery();
|
|
|
|
abnormalQuery.setStatus(AbnormalStatus.UNREAD.getStatus());
|
|
|
|
vo.setAbnormalCount(abnormalService.selectCount(abnormalQuery));
|
|
|
|
|
|
|
|
// 投诉意见
|
|
|
|
vo.setComplaintCount(complaintService.selectCount(new SmComplaintQuery()));
|
|
|
|
|
|
|
|
// 过期设备
|
|
|
|
DeviceQuery deviceQuery = new DeviceQuery();
|
|
|
|
deviceQuery.setIsArrears(true);
|
|
|
|
vo.setArrearsDeviceCount(deviceService.selectCount(deviceQuery));
|
|
|
|
|
2024-11-27 18:06:07 +08:00
|
|
|
// 风控审核
|
|
|
|
RiskInfoQuery riskInfoQuery = new RiskInfoQuery();
|
|
|
|
riskInfoQuery.setStatus(RiskInfoStatus.WAIT_VERIFY.getStatus());
|
|
|
|
vo.setRiskVerifyCount(riskInfoService.selectCount(riskInfoQuery));
|
|
|
|
|
2024-08-06 17:43:10 +08:00
|
|
|
return vo;
|
|
|
|
}
|
2024-09-07 16:43:49 +08:00
|
|
|
|
|
|
|
public List<ServiceIncomeVO> getServiceIncome(ServiceIncomeQuery query) {
|
|
|
|
|
2024-10-02 15:00:29 +08:00
|
|
|
// 查询服务费
|
|
|
|
BonusQuery bonusQuery = new BonusQuery();
|
|
|
|
bonusQuery.setPayDateStart(query.getStartDate());
|
|
|
|
bonusQuery.setPayDateEnd(query.getEndDate());
|
|
|
|
bonusQuery.setArrivalType(BonusArrivalType.PLATFORM.getType());
|
|
|
|
List<BonusDailyAmountVO> bonusList = bonusService.selectDailyAmount(bonusQuery);
|
|
|
|
|
2024-09-07 16:43:49 +08:00
|
|
|
// 查询订单
|
|
|
|
TransactionBillQuery billQuery = new TransactionBillQuery();
|
|
|
|
billQuery.setStartDate(query.getStartDate());
|
|
|
|
billQuery.setEndDate(query.getEndDate());
|
2024-09-07 17:40:12 +08:00
|
|
|
billQuery.setStatusList(TransactionBillStatus.serviceIncome());
|
2024-09-18 17:51:24 +08:00
|
|
|
billQuery.setType(TransactionBillType.RECHARGE.getType());
|
2024-09-07 16:43:49 +08:00
|
|
|
List<TransactionAmountVO<Date>> amountList = transactionBillService.selectCommonSumOfMoney(billQuery, TransactionBillGroupBy.create_date.name());
|
|
|
|
|
2024-09-18 17:51:24 +08:00
|
|
|
// 查询提现
|
|
|
|
billQuery.setType(TransactionBillType.WITHDRAW.getType());
|
|
|
|
List<TransactionAmountVO<Date>> withdrawList = transactionBillService.selectCommonSumOfMoney(billQuery, TransactionBillGroupBy.create_date.name());
|
|
|
|
|
2024-09-07 16:43:49 +08:00
|
|
|
// 查询月费收入
|
|
|
|
ReceiveBillQuery receiveQuery = new ReceiveBillQuery();
|
|
|
|
receiveQuery.setStartDate(query.getStartDate());
|
|
|
|
receiveQuery.setEndDate(query.getEndDate());
|
2024-10-15 09:29:42 +08:00
|
|
|
receiveQuery.setType(ReceiveBillType.MONTH.getType());
|
2024-09-07 16:43:49 +08:00
|
|
|
List<ReceiveAmountVO<Date>> receiveList = receiveBillService.selectCommonSumOfAmount(receiveQuery, ReceiveBillGroupBy.create_date.name());
|
|
|
|
|
2024-10-15 09:29:42 +08:00
|
|
|
// 查询订单手机号收入
|
|
|
|
receiveQuery.setType(ReceiveBillType.MOBILE.getType());
|
|
|
|
List<ReceiveAmountVO<Date>> mobileList = receiveBillService.selectCommonSumOfAmount(receiveQuery, ReceiveBillGroupBy.create_date.name());
|
|
|
|
|
2024-09-07 16:43:49 +08:00
|
|
|
// 拼接结果集
|
|
|
|
List<ServiceIncomeVO> result = new ArrayList<>();
|
|
|
|
if (query.getStartDate() != null && query.getEndDate() != null) {
|
|
|
|
result = CollectionUtils.fillVoids(result, ServiceIncomeVO::getDate, (date) -> {
|
|
|
|
ServiceIncomeVO vo = new ServiceIncomeVO();
|
|
|
|
vo.setDate(date);
|
|
|
|
|
2024-10-02 15:00:29 +08:00
|
|
|
// 订单服务费
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 渠道成本
|
2024-09-07 16:43:49 +08:00
|
|
|
TransactionAmountVO<Date> transaction = amountList.stream()
|
|
|
|
.filter(item -> item.getKey().compareTo(DateUtils.toDate(date)) == 0)
|
|
|
|
.findFirst().orElse(null);
|
|
|
|
if (transaction != null) {
|
|
|
|
vo.setChannelCost(transaction.getChannelCost());
|
|
|
|
} else {
|
|
|
|
vo.setChannelCost(BigDecimal.ZERO);
|
|
|
|
}
|
|
|
|
|
2024-09-18 17:51:24 +08:00
|
|
|
// 提现服务费收入及成本
|
|
|
|
TransactionAmountVO<Date> withdraw = withdrawList.stream()
|
|
|
|
.filter(item -> item.getKey().compareTo(DateUtils.toDate(date)) == 0)
|
|
|
|
.findFirst().orElse(null);
|
|
|
|
if (withdraw != null) {
|
|
|
|
vo.setWithdrawServiceAmount(withdraw.getServiceAmount());
|
|
|
|
vo.setChannelCost(vo.getChannelCost().add(withdraw.getChannelCost()));
|
|
|
|
} else {
|
|
|
|
vo.setWithdrawServiceAmount(BigDecimal.ZERO);
|
|
|
|
}
|
|
|
|
|
2024-09-07 16:43:49 +08:00
|
|
|
// 月费收入
|
|
|
|
ReceiveAmountVO<Date> receive = receiveList.stream()
|
|
|
|
.filter(item -> item.getKey().compareTo(DateUtils.toDate(date)) == 0)
|
|
|
|
.findFirst()
|
|
|
|
.orElse(null);
|
|
|
|
if (receive != null) {
|
|
|
|
vo.setMonthAmount(receive.getReceivedAmount());
|
|
|
|
} else {
|
|
|
|
vo.setMonthAmount(BigDecimal.ZERO);
|
|
|
|
}
|
|
|
|
|
2024-10-15 09:29:42 +08:00
|
|
|
// 订单手机号收入
|
|
|
|
ReceiveAmountVO<Date> mobile = mobileList.stream()
|
|
|
|
.filter(item -> item.getKey().compareTo(DateUtils.toDate(date)) == 0)
|
|
|
|
.findFirst()
|
|
|
|
.orElse(null);
|
|
|
|
if (mobile != null) {
|
|
|
|
vo.setBillMobileAmount(mobile.getReceivedAmount());
|
|
|
|
} else {
|
|
|
|
vo.setBillMobileAmount(BigDecimal.ZERO);
|
|
|
|
}
|
|
|
|
|
2024-09-07 16:43:49 +08:00
|
|
|
return vo;
|
|
|
|
}, query.getStartDate(), query.getEndDate());
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2024-10-08 16:05:28 +08:00
|
|
|
|
|
|
|
public List<BusinessStatisticsVO> businessStatisticsByStore(BusinessStatisticsQuery query) {
|
|
|
|
query.setBillType(TransactionBillType.RECHARGE.getType());
|
|
|
|
query.setBillStatusList(TransactionBillStatus.payedOrder());
|
|
|
|
return dashboardMapper.selectBusinessStatisticsByStore(query);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<BusinessStatisticsVO> businessStatisticsByDevice(BusinessStatisticsQuery query) {
|
|
|
|
query.setBillType(TransactionBillType.RECHARGE.getType());
|
|
|
|
query.setBillStatusList(TransactionBillStatus.payedOrder());
|
|
|
|
return dashboardMapper.selectBusinessStatisticsByDevice(query);
|
|
|
|
}
|
2024-08-06 17:43:10 +08:00
|
|
|
}
|