This commit is contained in:
磷叶 2025-01-13 11:36:23 +08:00
parent 1f08cae40a
commit 2be04b77ee
17 changed files with 293 additions and 27 deletions

View File

@ -0,0 +1,25 @@
package com.ruoyi.dashboard.domain.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
/**
* @author wjh
* 2025/1/13
*/
@Data
public class BonusTrendDetailVO {
@ApiModelProperty("日期")
private LocalDate date;
@ApiModelProperty("收入金额")
private BigDecimal incomeAmount;
@ApiModelProperty("订单数量")
private Integer orderCount;
}

View File

@ -0,0 +1,25 @@
package com.ruoyi.dashboard.domain.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* @author wjh
* 2025/1/13
*/
@Data
public class BonusTrendVO {
@ApiModelProperty("明细列表")
private List<BonusTrendDetailVO> detailList;
@ApiModelProperty("总收入")
private BigDecimal totalIncome;
@ApiModelProperty("总订单数")
private Integer totalOrder;
}

View File

@ -0,0 +1,24 @@
package com.ruoyi.dashboard.domain.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* @author wjh
* 2025/1/13
*/
@Data
public class BusinessStatisticsByStoreVO {
@ApiModelProperty("订单总数")
private Integer totalOrder;
@ApiModelProperty("订单总金额")
private BigDecimal totalOrderAmount;
@ApiModelProperty("明细列表")
List<BusinessStatisticsVO> list;
}

View File

@ -0,0 +1,35 @@
package com.ruoyi.dashboard.domain.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author wjh
* 2025/1/13
*/
@Data
public class MchRevenueVO {
@ApiModelProperty("今日收入")
private BigDecimal todayIncome;
@ApiModelProperty("昨日收入")
private BigDecimal yesterdayIncome;
@ApiModelProperty("今日订单")
private Integer todayOrder;
@ApiModelProperty("昨日订单")
private Integer yesterdayOrder;
@ApiModelProperty("设备总数")
private Integer deviceCount;
@ApiModelProperty("空闲设备数")
private Integer freeDeviceCount;
@ApiModelProperty("使用中设备数")
private Integer usingDeviceCount;
}

View File

@ -3,21 +3,22 @@ package com.ruoyi.dashboard.service;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.collection.CollectionUtils;
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.domain.dto.ServiceIncomeQuery;
import com.ruoyi.dashboard.domain.vo.*;
import com.ruoyi.dashboard.mapper.DashboardMapper;
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.BonusVO;
import com.ruoyi.ss.bonus.domain.enums.BonusArrivalType;
import com.ruoyi.ss.bonus.domain.enums.BonusStatus;
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.dashboard.domain.dto.ServiceIncomeQuery;
import com.ruoyi.dashboard.domain.vo.ServiceIncomeVO;
import com.ruoyi.ss.device.domain.DeviceQuery;
import com.ruoyi.ss.device.domain.enums.DeviceStatus;
import com.ruoyi.ss.device.service.DeviceService;
import com.ruoyi.ss.mchApply.domain.MchApplyQuery;
import com.ruoyi.ss.mchApply.domain.enums.MchApplyStatus;
@ -43,9 +44,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author wjh
@ -222,10 +226,20 @@ public class DashboardService {
return result;
}
public List<BusinessStatisticsVO> businessStatisticsByStore(BusinessStatisticsQuery query) {
public BusinessStatisticsByStoreVO businessStatisticsByStore(BusinessStatisticsQuery query) {
BusinessStatisticsByStoreVO vo = new BusinessStatisticsByStoreVO();
// 查询列表
query.setBillType(TransactionBillType.RECHARGE.getType());
query.setBillStatusList(TransactionBillStatus.payedOrder());
return dashboardMapper.selectBusinessStatisticsByStore(query);
List<BusinessStatisticsVO> list = dashboardMapper.selectBusinessStatisticsByStore(query);
vo.setList(list);
// 统计数量金额
vo.setTotalOrder(list.stream().mapToInt(BusinessStatisticsVO::getOrderCount).sum());
vo.setTotalOrderAmount(CollectionUtils.sumDecimal(list, BusinessStatisticsVO::getArrivalAmount));
return vo;
}
@ -234,4 +248,104 @@ public class DashboardService {
query.setBillStatusList(TransactionBillStatus.payedOrder());
return dashboardMapper.selectBusinessStatisticsByDevice(query);
}
/**
* 查询商户中心营收统计
*/
public MchRevenueVO mchRevenue(Long mchId) {
MchRevenueVO vo = new MchRevenueVO();
LocalDate today = LocalDate.now();
LocalDate yesterday = today.plusDays(-1);
// 营业额统计
BonusQuery bonusQuery = new BonusQuery();
bonusQuery.setArrivalId(mchId);
bonusQuery.setArrivalTypes(BonusArrivalType.userList());
bonusQuery.setStatus(BonusStatus.DIVIDEND.getStatus());
// 今日营业额
bonusQuery.setPayDate(today);
BigDecimal todayIncome = bonusService.selectSumOfPayedAmount(bonusQuery);
if (todayIncome == null) {
todayIncome = BigDecimal.ZERO;
}
vo.setTodayIncome(todayIncome);
// 昨日营业额
bonusQuery.setPayDate(yesterday);
BigDecimal yesterdayIncome = bonusService.selectSumOfPayedAmount(bonusQuery);
if (yesterdayIncome == null) {
yesterdayIncome = BigDecimal.ZERO;
}
vo.setYesterdayIncome(yesterdayIncome);
// 订单数统计
TransactionBillQuery billQuery = new TransactionBillQuery();
billQuery.setType(TransactionBillType.RECHARGE.getType());
billQuery.setStatusList(TransactionBillStatus.payedOrder());
billQuery.setMchId(mchId);
// 今日订单数
billQuery.setCreateDate(today);
int todayOrder = transactionBillService.selectSimpleCount(billQuery);
vo.setTodayOrder(todayOrder);
// 昨日订单数
billQuery.setCreateDate(yesterday);
int yesterdayOrder = transactionBillService.selectSimpleCount(billQuery);
vo.setYesterdayOrder(yesterdayOrder);
// 设备统计
DeviceQuery deviceQuery = new DeviceQuery();
deviceQuery.setUserId(mchId);
// 设备总数
int deviceCount = deviceService.selectCount(deviceQuery);
vo.setDeviceCount(deviceCount);
// 空闲设备数量
deviceQuery.setStatus(DeviceStatus.NORMAL.getStatus());
int freeDeviceCount = deviceService.selectCount(deviceQuery);
vo.setFreeDeviceCount(freeDeviceCount);
// 使用中设备数量
deviceQuery.setStatus(DeviceStatus.USING.getStatus());
int usingDeviceCount = deviceService.selectCount(deviceQuery);
vo.setUsingDeviceCount(usingDeviceCount);
return vo;
}
public BonusTrendVO selectBonusTrend(BonusQuery query) {
BonusTrendVO vo = new BonusTrendVO();
// 查询分成列表
List<BonusVO> bonusList = bonusService.selectBonusList(query);
// 若是日期不为空则构建明细列表
List<BonusTrendDetailVO> detailList = new ArrayList<>();
if (query.getPayDateStart() != null && query.getPayDateEnd() != null) {
detailList = CollectionUtils.fillVoids(detailList, BonusTrendDetailVO::getDate, (date) -> {
// 当天的分成列表
List<BonusVO> dateBonusList = bonusList.stream()
.filter(item -> item.getPayTime() != null && item.getPayTime().toLocalDate().isEqual(date))
.collect(Collectors.toList());
// 构造明细数据
BonusTrendDetailVO detail = new BonusTrendDetailVO();
detail.setDate(date);
detail.setIncomeAmount(CollectionUtils.sumDecimal(dateBonusList, BonusVO::getPayedAmount));
detail.setOrderCount(new HashSet<>(CollectionUtils.map(dateBonusList, BonusVO::getBillId)).size());
return detail;
}, query.getPayDateStart(), query.getPayDateEnd());
}
vo.setDetailList(detailList);
// 收入
BigDecimal totalIncome = CollectionUtils.sumDecimal(bonusList, BonusVO::getPayedAmount);
if (totalIncome == null) {
totalIncome = BigDecimal.ZERO;
}
vo.setTotalIncome(totalIncome);
// 订单数
int totalOrder = new HashSet<>(CollectionUtils.map(bonusList, BonusVO::getBillId)).size();
vo.setTotalOrder(totalOrder);
return vo;
}
}

View File

@ -1,10 +1,10 @@
package com.ruoyi.ss.balancePeriod.service;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.dashboard.domain.vo.BillCountVo;
import com.ruoyi.ss.balancePeriod.domain.SmBalancePeriod;
import com.ruoyi.ss.balancePeriod.domain.SmBalancePeriodQuery;
import com.ruoyi.ss.balancePeriod.mapper.SmBalancePeriodMapper;
import com.ruoyi.dashboard.domain.vo.BillCountVo;
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillGroupBy;
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus;
@ -17,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
@ -128,7 +129,7 @@ public class SmBalancePeriodServiceImpl implements ISmBalancePeriodService
// 充值
TransactionBillQuery dto = new TransactionBillQuery();
dto.setCreateDate(now);
dto.setCreateDate(LocalDate.now());
dto.setHour(now.getHours());
dto.setGroupBy(TransactionBillGroupBy.create_hour.name());
dto.setStatusList(TransactionBillStatus.payedOrder());

View File

@ -35,6 +35,9 @@ public class BonusQuery extends BonusVO {
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate payDateEnd;
@ApiModelProperty("支付日期")
private LocalDate payDate;
@ApiModelProperty("实际支付时间(起始)")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime payTimeStart;

View File

@ -51,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.prePayTimeStart != null "> and sb.pre_pay_time >= #{query.prePayTimeStart}</if>
<if test="query.prePayTimeEnd != null "> and sb.pre_pay_time &lt;= #{query.prePayTimeEnd}</if>
<if test="query.toBalance != null "> and sb.to_balance = #{query.toBalance}</if>
<if test="query.payDate != null "> and date(sb.pay_time) = #{query.payDate}</if>
<if test="query.billIds != null and query.billIds.size() > 0 ">
and sb.bill_id in
<foreach collection="query.billIds" item="item" open="(" close=")" separator=",">

View File

@ -153,7 +153,7 @@ public class SmBusinessRecordServiceImpl implements ISmBusinessRecordService
BriefVo brief = redisCache.getCacheObject(CacheConstants.BRIEF);
if (brief == null ) {
brief = new BriefVo();
Date now = DateUtils.getNowDate();
LocalDate now = LocalDate.now();
// 总订单数
TransactionBillQuery rechargeQuery = new TransactionBillQuery();
@ -224,7 +224,7 @@ public class SmBusinessRecordServiceImpl implements ISmBusinessRecordService
brief.setTotalMonthAmount(receiveBillService.selectSumOfAmount(monthQuery));
// 今日月费
monthQuery.setBillDate(LocalDate.now());
monthQuery.setBillDate(now);
BigDecimal todayMonthAmount = receiveBillService.selectSumOfAmount(monthQuery);
brief.setTodayMonthAmount(todayMonthAmount == null ? BigDecimal.ZERO : todayMonthAmount);

View File

@ -1,19 +1,19 @@
package com.ruoyi.ss.customerService.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.constants.DictTypeConstants;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.core.domain.ValidGroup;
import com.ruoyi.common.utils.RegexpUtils;
import com.ruoyi.system.valid.DictValid;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.time.LocalTime;
/**
* 客服对象 ss_customer_service
@ -46,12 +46,21 @@ public class CustomerService extends BaseEntity
@NotBlank(message = "类型不能为空", groups = {ValidGroup.Create.class})
private String type;
@Excel(name = "微信号")
@ApiModelProperty("微信号")
@Size(max = 64, message = "微信号长度不能超过64个字符")
@Excel(name = "微信图片")
@ApiModelProperty("微信图片")
private String wx;
@Excel(name = "排序")
@ApiModelProperty("排序")
private Integer sort;
@DateTimeFormat(pattern = "HH:mm:ss")
@Excel(name = "上班时间(起始)")
@ApiModelProperty("上班时间")
private LocalTime workTimeStart;
@DateTimeFormat(pattern = "HH:mm:ss")
@Excel(name = "上班时间(结束)")
@ApiModelProperty("上班时间")
private LocalTime workTimeEnd;
}

View File

@ -14,7 +14,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
scs.type,
scs.wx,
scs.create_time,
scs.sort
scs.sort,
scs.work_time_start,
scs.work_time_end
from ss_customer_service scs
</sql>
@ -47,6 +49,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="wx != null">wx,</if>
<if test="createTime != null">create_time,</if>
<if test="sort != null">sort,</if>
<if test="workTimeStart != null">work_time_start,</if>
<if test="workTimeEnd != null">work_time_end,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},</if>
@ -55,6 +59,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="wx != null">#{wx},</if>
<if test="createTime != null">#{createTime},</if>
<if test="sort != null">#{sort},</if>
<if test="workTimeStart != null">#{workTimeStart},</if>
<if test="workTimeEnd != null">#{workTimeEnd},</if>
</trim>
</insert>
@ -73,6 +79,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="data.wx != null">wx = #{data.wx},</if>
<if test="data.createTime != null">create_time = #{data.createTime},</if>
<if test="data.sort != null">sort = #{data.sort},</if>
<if test="data.workTimeStart != null">work_time_start = #{data.workTimeStart},</if>
<if test="data.workTimeEnd != null">work_time_end = #{data.workTimeEnd},</if>
</sql>
<delete id="deleteCustomerServiceById" parameterType="Long">

View File

@ -14,7 +14,7 @@ import java.util.Objects;
@Getter
public enum DeviceStatus {
NORMAL("1", "正常"),
NORMAL("1", "正常(空闲)"),
USING("2", "使用中"),
FIXING("3", "维修中");

View File

@ -27,6 +27,9 @@ public class StoreVo extends Store {
@ApiModelProperty("本日收入")
private BigDecimal todayIncome;
@ApiModelProperty("本日订单数量")
private Integer todayOrderCount;
@ApiModelProperty("本月收入")
private BigDecimal monthIncome;

View File

@ -1,6 +1,5 @@
package com.ruoyi.ss.store.service.impl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.dashboard.domain.vo.BillCountVo;
import com.ruoyi.ss.device.domain.DeviceCountVO;
@ -72,7 +71,7 @@ public class StoreAssemblerImpl implements StoreAssembler {
if (CollectionUtils.isEmptyElement(list)) {
return;
}
// 本日收入
// 本日收入本日订单量
this.assembleTodayIncome(list);
// 本月收入
this.assembleMonthIncome(list);
@ -116,7 +115,7 @@ public class StoreAssemblerImpl implements StoreAssembler {
}
/**
* 拼接本日收入
* 拼接本日收入订单量
*
* @param list
*/
@ -131,15 +130,17 @@ public class StoreAssemblerImpl implements StoreAssembler {
query.setStoreIds(list.stream().map(StoreVo::getStoreId).filter(Objects::nonNull).distinct().collect(Collectors.toList()));
query.setStatusList(TransactionBillStatus.payedOrder());
query.setType(TransactionBillType.RECHARGE.getType());
query.setCreateDate(DateUtils.getNowDate());
query.setCreateDate(LocalDate.now());
Map<Long, BillCountVo> map = transactionBillService.selectCountMap(query, BillCountVo::getStoreId);
for (StoreVo store : list) {
BillCountVo count = map.get(store.getStoreId());
if (count != null) {
store.setTodayIncome(count.getRecharge());
store.setTodayOrderCount(count.getCount());
} else {
store.setTodayIncome(BigDecimal.ZERO);
store.setTodayOrderCount(0);
}
}
}

View File

@ -11,7 +11,6 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
/**
@ -41,7 +40,7 @@ public class TransactionBillQuery extends TransactionBill {
@ApiModelProperty("创建日期")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date createDate;
private LocalDate createDate;
@ApiModelProperty("分组字段")
@EnumValid(

View File

@ -569,7 +569,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
TransactionBillQuery query = new TransactionBillQuery();
query.setType(TransactionBillType.WITHDRAW.getType());
query.setStatusList(TransactionBillStatus.countOfLimit());
query.setCreateDate(DateUtils.getNowDate());
query.setCreateDate(LocalDate.now());
query.setUserId(user.getUserId());
// 每日限额

View File

@ -7,7 +7,7 @@ import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.dashboard.service.DashboardService;
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.domain.enums.BonusStatus;
import com.ruoyi.ss.bonus.service.BonusService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
@ -31,6 +31,9 @@ public class AppDashboardController extends BaseController {
@Autowired
private BonusService bonusService;
@Autowired
private DashboardService dashboardService;
@ApiOperation("按日查询本人分成列表")
@GetMapping("/bonusDailyAmount")
public AjaxResult bonusDailyAmount(BonusQuery query) {
@ -56,4 +59,19 @@ public class AppDashboardController extends BaseController {
return ajax;
}
@ApiOperation("查询商户中心营收统计")
@GetMapping("/mchRevenue")
public AjaxResult mchRevenue() {
return success(dashboardService.mchRevenue(getUserId()));
}
@ApiOperation("查询商户中心收入趋势统计")
@GetMapping("/bonusTrend")
public AjaxResult bonusTrend(BonusQuery query) {
query.setArrivalId(getUserId());
query.setArrivalTypes(BonusArrivalType.userList());
query.setStatus(BonusStatus.DIVIDEND.getStatus());
return success(dashboardService.selectBonusTrend(query));
}
}