店铺报表修改

This commit is contained in:
磷叶 2025-02-01 20:54:00 +08:00
parent 657b195725
commit c3289e693e
6 changed files with 149 additions and 81 deletions

View File

@ -11,10 +11,10 @@ import lombok.Data;
/** /**
* @author wjh * @author wjh
* 2024/7/24 * 2024/7/24
*/ */
@Data @Data
public class PayBillQuery extends PayBill{ public class PayBillQuery extends PayBill {
@ApiModelProperty("状态列表") @ApiModelProperty("状态列表")
private List<String> statusList; private List<String> statusList;
@ -45,4 +45,13 @@ public class PayBillQuery extends PayBill{
@ApiModelProperty("支付日期") @ApiModelProperty("支付日期")
@DateTimeFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate payDate; private LocalDate payDate;
@ApiModelProperty("店铺ID列表")
private List<Long> storeIds;
@ApiModelProperty("支付月份")
private Integer payMonth;
@ApiModelProperty("支付年份")
private Integer payYear;
} }

View File

@ -6,6 +6,7 @@ import java.util.List;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import com.ruoyi.common.domain.vo.LocalDateDecimalVO; import com.ruoyi.common.domain.vo.LocalDateDecimalVO;
import com.ruoyi.common.domain.vo.LongDecimalVO;
import com.ruoyi.ss.payBill.domain.PayBill; import com.ruoyi.ss.payBill.domain.PayBill;
import com.ruoyi.ss.payBill.domain.PayBillQuery; import com.ruoyi.ss.payBill.domain.PayBillQuery;
import com.ruoyi.ss.payBill.domain.PayBillVO; import com.ruoyi.ss.payBill.domain.PayBillVO;
@ -16,8 +17,7 @@ import com.ruoyi.ss.payBill.domain.PayBillVO;
* @author ruoyi * @author ruoyi
* @date 2024-07-24 * @date 2024-07-24
*/ */
public interface PayBillMapper public interface PayBillMapper {
{
/** /**
* 查询支付订单 * 查询支付订单
* *
@ -32,7 +32,7 @@ public interface PayBillMapper
* @param payBill 支付订单 * @param payBill 支付订单
* @return 支付订单集合 * @return 支付订单集合
*/ */
public List<PayBillVO> selectPayBillList(@Param("query")PayBillQuery payBill); public List<PayBillVO> selectPayBillList(@Param("query") PayBillQuery payBill);
/** /**
* 新增支付订单 * 新增支付订单
@ -106,11 +106,16 @@ public interface PayBillMapper
/** /**
* 按条件查询渠道成本 * 按条件查询渠道成本
*/ */
BigDecimal selectSumOfChannelCost(@Param("query") PayBillQuery query); BigDecimal selectSumOfChannelCost(@Param("query") PayBillQuery query);
/** /**
* 按日查询渠道成本 * 按日查询渠道成本
*/ */
List<LocalDateDecimalVO> selectDailyChannelCost(@Param("query") PayBillQuery query); List<LocalDateDecimalVO> selectDailyChannelCost(@Param("query") PayBillQuery query);
/**
* 按条件查询店铺金额
*/
List<LongDecimalVO> selectSumOfAmountGroupByStoreId(@Param("query") PayBillQuery query);
} }

View File

@ -49,6 +49,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.appId != null "> and spb.app_id = #{query.appId}</if> <if test="query.appId != null "> and spb.app_id = #{query.appId}</if>
<if test="query.payDate != null">and date(spb.pay_time) = date(#{query.payDate})</if> <if test="query.payDate != null">and date(spb.pay_time) = date(#{query.payDate})</if>
<if test="query.storeId != null "> and spb.store_id = #{query.storeId}</if> <if test="query.storeId != null "> and spb.store_id = #{query.storeId}</if>
<if test="query.payMonth != null">and month(spb.pay_time) = #{query.payMonth}</if>
<if test="query.payYear != null">and year(spb.pay_time) = #{query.payYear}</if>
<if test="query.storeIds != null and query.storeIds.size() > 0">
and spb.store_id in
<foreach item="item" index="index" collection="query.storeIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="query.statusList != null and query.statusList.size() > 0"> <if test="query.statusList != null and query.statusList.size() > 0">
and spb.status in and spb.status in
<foreach item="item" index="index" collection="query.statusList" open="(" separator="," close=")"> <foreach item="item" index="index" collection="query.statusList" open="(" separator="," close=")">
@ -238,5 +246,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
</select> </select>
<!-- selectSumOfAmountGroupByStoreId -->
<resultMap id="LongDecimalVO" type="LongDecimalVO" autoMapping="true">
<result property="value" column="value" typeHandler="com.ruoyi.system.mapper.typehandler.NonNullDecimalTypeHandler"/>
</resultMap>
<select id="selectSumOfAmountGroupByStoreId" resultMap="LongDecimalVO">
select
spb.store_id as `key`,
sum(spb.amount) as `value`
from ss_pay_bill spb
<where>
<include refid="searchCondition"/>
</where>
group by `key`
</select>
</mapper> </mapper>

View File

@ -6,6 +6,7 @@ import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import com.ruoyi.common.domain.vo.LocalDateDecimalVO; import com.ruoyi.common.domain.vo.LocalDateDecimalVO;
import com.ruoyi.common.domain.vo.LongDecimalVO;
import com.ruoyi.ss.payBill.domain.PayBill; import com.ruoyi.ss.payBill.domain.PayBill;
import com.ruoyi.ss.payBill.domain.PayBillQuery; import com.ruoyi.ss.payBill.domain.PayBillQuery;
import com.ruoyi.ss.payBill.domain.PayBillVO; import com.ruoyi.ss.payBill.domain.PayBillVO;
@ -21,8 +22,7 @@ import com.ruoyi.ss.refund.domain.RefundVO;
* @author ruoyi * @author ruoyi
* @date 2024-07-24 * @date 2024-07-24
*/ */
public interface PayBillService public interface PayBillService {
{
/** /**
* 查询支付订单 * 查询支付订单
* *
@ -101,7 +101,8 @@ public interface PayBillService
/** /**
* 处理支付成功时间 * 处理支付成功时间
* @param payNo 支付订单编号 *
* @param payNo 支付订单编号
* @param payTime 支付成功的时间 * @param payTime 支付成功的时间
*/ */
void handleSuccess(String payNo, LocalDateTime payTime); void handleSuccess(String payNo, LocalDateTime payTime);
@ -128,13 +129,13 @@ public interface PayBillService
*/ */
int handleRefundSuccess(RefundVO refund); int handleRefundSuccess(RefundVO refund);
/** /**
* 延迟刷新支付结果直到成功或者超过最大次数 * 延迟刷新支付结果直到成功或者超过最大次数
* @param pay 支付单 *
* @param delay 延迟时间 * @param pay 支付单
* @param delay 延迟时间
* @param timeUnit 延迟时间单位 * @param timeUnit 延迟时间单位
* @param count 最大次数 * @param count 最大次数
*/ */
void refreshPayResultMaxCount(PayBillVO pay, long delay, TimeUnit timeUnit, int count); void refreshPayResultMaxCount(PayBillVO pay, long delay, TimeUnit timeUnit, int count);
@ -167,4 +168,9 @@ public interface PayBillService
* 按条件查询渠道成本 * 按条件查询渠道成本
*/ */
List<LocalDateDecimalVO> selectDailyChannelCost(PayBillQuery query); List<LocalDateDecimalVO> selectDailyChannelCost(PayBillQuery query);
/**
* 按条件查询店铺金额
*/
List<LongDecimalVO> selectSumOfAmountGroupByStoreId(PayBillQuery query);
} }

View File

@ -14,6 +14,7 @@ import org.springframework.transaction.support.TransactionTemplate;
import com.ruoyi.common.core.redis.RedisLock; import com.ruoyi.common.core.redis.RedisLock;
import com.ruoyi.common.core.redis.enums.RedisLockKey; import com.ruoyi.common.core.redis.enums.RedisLockKey;
import com.ruoyi.common.domain.vo.LocalDateDecimalVO; import com.ruoyi.common.domain.vo.LocalDateDecimalVO;
import com.ruoyi.common.domain.vo.LongDecimalVO;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.pay.PayApi; import com.ruoyi.common.pay.PayApi;
import com.ruoyi.common.pay.wx.service.WxPayService; import com.ruoyi.common.pay.wx.service.WxPayService;
@ -57,8 +58,7 @@ import lombok.extern.slf4j.Slf4j;
*/ */
@Service @Service
@Slf4j @Slf4j
public class PayBillServiceImpl implements PayBillService public class PayBillServiceImpl implements PayBillService {
{
@Autowired @Autowired
private PayBillMapper payBillMapper; private PayBillMapper payBillMapper;
@ -96,8 +96,7 @@ public class PayBillServiceImpl implements PayBillService
* @return 支付订单 * @return 支付订单
*/ */
@Override @Override
public PayBillVO selectPayBillByPayId(Long payId) public PayBillVO selectPayBillByPayId(Long payId) {
{
return payBillMapper.selectPayBillByPayId(payId); return payBillMapper.selectPayBillByPayId(payId);
} }
@ -108,8 +107,7 @@ public class PayBillServiceImpl implements PayBillService
* @return 支付订单 * @return 支付订单
*/ */
@Override @Override
public List<PayBillVO> selectPayBillList(PayBillQuery payBill) public List<PayBillVO> selectPayBillList(PayBillQuery payBill) {
{
return payBillMapper.selectPayBillList(payBill); return payBillMapper.selectPayBillList(payBill);
} }
@ -120,8 +118,7 @@ public class PayBillServiceImpl implements PayBillService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int insertPayBill(PayBill payBill) public int insertPayBill(PayBill payBill) {
{
payBill.setPayNo(String.valueOf(SnowFlakeUtil.newId())); payBill.setPayNo(String.valueOf(SnowFlakeUtil.newId()));
payBill.setCreateTime(DateUtils.getNowDate()); payBill.setCreateTime(DateUtils.getNowDate());
return payBillMapper.insertPayBill(payBill); return payBillMapper.insertPayBill(payBill);
@ -134,8 +131,7 @@ public class PayBillServiceImpl implements PayBillService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int updatePayBill(PayBill payBill) public int updatePayBill(PayBill payBill) {
{
return payBillMapper.updatePayBill(payBill); return payBillMapper.updatePayBill(payBill);
} }
@ -146,8 +142,7 @@ public class PayBillServiceImpl implements PayBillService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int deletePayBillByPayIds(Long[] payIds) public int deletePayBillByPayIds(Long[] payIds) {
{
return payBillMapper.deletePayBillByPayIds(payIds); return payBillMapper.deletePayBillByPayIds(payIds);
} }
@ -158,8 +153,7 @@ public class PayBillServiceImpl implements PayBillService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int deletePayBillByPayId(Long payId) public int deletePayBillByPayId(Long payId) {
{
return payBillMapper.deletePayBillByPayId(payId); return payBillMapper.deletePayBillByPayId(payId);
} }
@ -171,7 +165,8 @@ public class PayBillServiceImpl implements PayBillService
String lockKey = bill.getBstType() + bill.getBstId(); String lockKey = bill.getBstType() + bill.getBstId();
if (!redisLock.lock(RedisLockKey.PAY_BILL, lockKey)) { if (!redisLock.lock(RedisLockKey.PAY_BILL, lockKey)) {
return null; return null;
}; }
;
try { try {
// 尝试关闭旧的支付订单 // 尝试关闭旧的支付订单
boolean close = this.closeByBstId(bill.getBstId(), bill.getBstType()); boolean close = this.closeByBstId(bill.getBstId(), bill.getBstType());
@ -195,7 +190,7 @@ public class PayBillServiceImpl implements PayBillService
@Override @Override
public boolean closeByBstId(Long bstId, String bstType) { public boolean closeByBstId(Long bstId, String bstType) {
if (bstId == null || bstType == null ) { if (bstId == null || bstType == null) {
return false; return false;
} }
// 查询未支付支付中的订单 // 查询未支付支付中的订单
@ -254,7 +249,8 @@ public class PayBillServiceImpl implements PayBillService
payApi.closeByOutTradeNo(bill.getPayNo(), channelConverter.toConfig(channel, app)); payApi.closeByOutTradeNo(bill.getPayNo(), channelConverter.toConfig(channel, app));
} catch (Exception e) { } catch (Exception e) {
// 关闭失败尝试查询订单信息判断是否已经支付成功 // 关闭失败尝试查询订单信息判断是否已经支付成功
if (payApi.isPaySuccessByOutTradeNo(bill.getPayNo(), DateUtils.toLocalDate(bill.getCreateTime()) , channelConverter.toConfig(channel, app))) { if (payApi.isPaySuccessByOutTradeNo(bill.getPayNo(),
DateUtils.toLocalDate(bill.getCreateTime()), channelConverter.toConfig(channel, app))) {
throw new ServiceException("当前交易已成功,无法关闭"); throw new ServiceException("当前交易已成功,无法关闭");
} else { } else {
log.error("关闭支付订单失败: payNo = {} 原因:{}", bill.getPayNo(), e.getMessage()); log.error("关闭支付订单失败: payNo = {} 原因:{}", bill.getPayNo(), e.getMessage());
@ -301,11 +297,13 @@ public class PayBillServiceImpl implements PayBillService
ServiceUtil.assertion(payBill == null, "支付订单不存在"); ServiceUtil.assertion(payBill == null, "支付订单不存在");
Long lockKey = payBill.getPayId(); Long lockKey = payBill.getPayId();
// ServiceUtil.assertion(redisLock.lock(RedisLockKey.PAY_BILL_SUCCESS, lockKey), "支付订单正在处理中:payId=" + payBill.getPayId()); // ServiceUtil.assertion(redisLock.lock(RedisLockKey.PAY_BILL_SUCCESS, lockKey),
// "支付订单正在处理中:payId=" + payBill.getPayId());
try { try {
// 若不是支付成功的状态则修改为支付成功 // 若不是支付成功的状态则修改为支付成功
if (!PayBillStatus.payedList().contains(payBill.getStatus())) { if (!PayBillStatus.payedList().contains(payBill.getStatus())) {
ServiceUtil.assertion(!PayBillStatus.PAYING.getStatus().equals(payBill.getStatus()), "该支付订单不是正在支付的支付订单"); ServiceUtil.assertion(!PayBillStatus.PAYING.getStatus().equals(payBill.getStatus()),
"该支付订单不是正在支付的支付订单");
Integer result = transactionTemplate.execute(status -> { Integer result = transactionTemplate.execute(status -> {
// 修改支付订单状态 // 修改支付订单状态
@ -332,10 +330,11 @@ public class PayBillServiceImpl implements PayBillService
AfterPay afterPay = SpringUtils.getBean(bstType.getAfterPay()); AfterPay afterPay = SpringUtils.getBean(bstType.getAfterPay());
int bstResult = afterPay.onPaySuccess(newPayBill); int bstResult = afterPay.onPaySuccess(newPayBill);
ServiceUtil.assertion(bstResult == 0, "业务处理失败"); ServiceUtil.assertion(bstResult == 0, "业务处理失败");
}; }
;
} }
} finally { } finally {
// redisLock.unlock(RedisLockKey.PAY_BILL_SUCCESS, lockKey); // redisLock.unlock(RedisLockKey.PAY_BILL_SUCCESS, lockKey);
} }
} }
@ -355,7 +354,8 @@ public class PayBillServiceImpl implements PayBillService
// 获取渠道信息 // 获取渠道信息
ChannelVO channel = channelService.selectSmChannelByChannelId(bill.getChannelId()); ChannelVO channel = channelService.selectSmChannelByChannelId(bill.getChannelId());
ServiceUtil.assertion(channel == null, "ID为%s的支付渠道不存在", bill.getChannelId()); ServiceUtil.assertion(channel == null, "ID为%s的支付渠道不存在", bill.getChannelId());
ServiceUtil.assertion(channel.getEnabled() == null || !channel.getEnabled(), "支付渠道【%s】不可用", channel.getName()); ServiceUtil.assertion(channel.getEnabled() == null || !channel.getEnabled(), "支付渠道【%s】不可用",
channel.getName());
// 获取API // 获取API
PayApi payApi = ChannelApiType.getPayApi(channel.getApiType()); PayApi payApi = ChannelApiType.getPayApi(channel.getApiType());
@ -421,6 +421,11 @@ public class PayBillServiceImpl implements PayBillService
return payBillMapper.selectDailyChannelCost(query); return payBillMapper.selectDailyChannelCost(query);
} }
@Override
public List<LongDecimalVO> selectSumOfAmountGroupByStoreId(PayBillQuery query) {
return payBillMapper.selectSumOfAmountGroupByStoreId(query);
}
@Override @Override
public int refund(PayBillRefundDTO dto) { public int refund(PayBillRefundDTO dto) {
// 校验订单 // 校验订单
@ -472,13 +477,13 @@ public class PayBillServiceImpl implements PayBillService
Integer result = transactionTemplate.execute(status -> { Integer result = transactionTemplate.execute(status -> {
// 修改支付订单状态 // 修改支付订单状态
// PayBill data = new PayBillVO(); // PayBill data = new PayBillVO();
// data.setStatus(PayBillStatus.REFUNDED.getStatus()); // data.setStatus(PayBillStatus.REFUNDED.getStatus());
// PayBillQuery query = new PayBillQuery(); // PayBillQuery query = new PayBillQuery();
// query.setPayId(refund.getBillId()); // query.setPayId(refund.getBillId());
// query.setStatus(PayBillStatus.REFUNDING.getStatus()); // query.setStatus(PayBillStatus.REFUNDING.getStatus());
// int update = this.updateByQuery(data, query); // int update = this.updateByQuery(data, query);
// ServiceUtil.assertion(update != 1, "支付订单状态已发生变化,请刷新后重试"); // ServiceUtil.assertion(update != 1, "支付订单状态已发生变化,请刷新后重试");
// 记录已退款金额并修改状态 // 记录已退款金额并修改状态
int recordAmount = payBillMapper.recordRefundAmount(refund.getBillId(), refund.getAmount()); int recordAmount = payBillMapper.recordRefundAmount(refund.getBillId(), refund.getAmount());
@ -527,7 +532,7 @@ public class PayBillServiceImpl implements PayBillService
if (PayBillStatus.PAYING.getStatus().equals(newPay.getStatus())) { if (PayBillStatus.PAYING.getStatus().equals(newPay.getStatus())) {
log.info("{}未支付成功,继续延迟刷新, 剩余次数:{}", newPay.getPayNo(), count - 1); log.info("{}未支付成功,继续延迟刷新, 剩余次数:{}", newPay.getPayNo(), count - 1);
scheduledExecutorService.schedule(() -> { scheduledExecutorService.schedule(() -> {
this.refreshPayResultMaxCount(newPay, delay , timeUnit, count - 1); this.refreshPayResultMaxCount(newPay, delay, timeUnit, count - 1);
}, delay, timeUnit); }, delay, timeUnit);
} }
} }
@ -585,7 +590,8 @@ public class PayBillServiceImpl implements PayBillService
} }
// 获取支付结果 // 获取支付结果
Object result = payApi.queryByOutTradeNo(bill.getPayNo(), DateUtils.toLocalDate(bill.getCreateTime()), channelConverter.toConfig(channel, app)); Object result = payApi.queryByOutTradeNo(bill.getPayNo(), DateUtils.toLocalDate(bill.getCreateTime()),
channelConverter.toConfig(channel, app));
if (payApi.isPaySuccess(result)) { if (payApi.isPaySuccess(result)) {
return PayResultVO.success(payApi.getPayTime(result), result); return PayResultVO.success(payApi.getPayTime(result), result);
} else { } else {

View File

@ -21,7 +21,10 @@ import com.ruoyi.ss.device.domain.enums.DeviceGroupBy;
import com.ruoyi.ss.device.domain.enums.DeviceOnlineStatus; import com.ruoyi.ss.device.domain.enums.DeviceOnlineStatus;
import com.ruoyi.ss.device.domain.enums.DeviceStatus; import com.ruoyi.ss.device.domain.enums.DeviceStatus;
import com.ruoyi.ss.device.service.DeviceService; import com.ruoyi.ss.device.service.DeviceService;
import com.ruoyi.ss.payBill.domain.PayBillQuery;
import com.ruoyi.ss.payBill.domain.enums.PayBillBstType; import com.ruoyi.ss.payBill.domain.enums.PayBillBstType;
import com.ruoyi.ss.payBill.domain.enums.PayBillStatus;
import com.ruoyi.ss.payBill.service.PayBillService;
import com.ruoyi.ss.refund.domain.RefundQuery; import com.ruoyi.ss.refund.domain.RefundQuery;
import com.ruoyi.ss.refund.domain.enums.RefundStatus; import com.ruoyi.ss.refund.domain.enums.RefundStatus;
import com.ruoyi.ss.refund.service.RefundService; import com.ruoyi.ss.refund.service.RefundService;
@ -61,6 +64,9 @@ public class StoreAssemblerImpl implements StoreAssembler {
@Autowired @Autowired
private RefundService refundService; private RefundService refundService;
@Autowired
private PayBillService payBillService;
/** /**
* 拼接设备数量 * 拼接设备数量
* *
@ -90,8 +96,10 @@ public class StoreAssemblerImpl implements StoreAssembler {
if (CollectionUtils.isEmptyElement(list)) { if (CollectionUtils.isEmptyElement(list)) {
return; return;
} }
// 本日收入本日订单量 // 本日收入
this.assembleTodayIncome(list); this.assembleTodayIncome(list);
// 本日充值订单量
this.assembleTodayOrderCount(list);
// 本月收入 // 本月收入
this.assembleMonthIncome(list); this.assembleMonthIncome(list);
// 上月收入 // 上月收入
@ -102,6 +110,32 @@ public class StoreAssemblerImpl implements StoreAssembler {
this.assembleOfflineCount(list); this.assembleOfflineCount(list);
} }
/**
* 拼接本日订单量
*
* @param list
*/
public void assembleTodayOrderCount(List<StoreVo> list) {
if (CollectionUtils.isEmptyElement(list)) {
return;
}
LocalDate now = LocalDate.now();
// 查询订单量
TransactionBillQuery rechargeQuery = new TransactionBillQuery();
rechargeQuery.setStoreIds(CollectionUtils.map(list, StoreVo::getStoreId));
rechargeQuery.setStatusList(TransactionBillStatus.payedOrder());
rechargeQuery.setType(TransactionBillType.RECHARGE.getType());
rechargeQuery.setCreateDate(now);
Map<Long, Integer> countMap = transactionBillService.selectCountGroupByStoreId(rechargeQuery)
.stream().collect(Collectors.toMap(LongIntegerVO::getKey, LongIntegerVO::getValue));
for (StoreVo store : list) {
Integer count = countMap.get(store.getStoreId());
store.setTodayOrderCount(count == null ? 0 : count);
}
}
/** /**
* 拼接本月收入 * 拼接本月收入
* *
@ -113,15 +147,14 @@ public class StoreAssemblerImpl implements StoreAssembler {
return; return;
} }
// 查询订单信息 // 查询支付信息
TransactionBillQuery query = new TransactionBillQuery(); PayBillQuery query = new PayBillQuery();
LocalDate now = LocalDate.now(); LocalDate now = LocalDate.now();
query.setStoreIds(CollectionUtils.map(list, StoreVo::getStoreId)); query.setStoreIds(CollectionUtils.map(list, StoreVo::getStoreId));
query.setStatusList(TransactionBillStatus.payedOrder()); query.setStatusList(PayBillStatus.payedList());
query.setType(TransactionBillType.RECHARGE.getType()); query.setPayMonth(now.getMonthValue());
query.setMonth(now.getMonthValue()); query.setPayYear(now.getYear());
query.setYear(now.getYear()); Map<Long, BigDecimal> billMap = payBillService.selectSumOfAmountGroupByStoreId(query)
Map<Long, BigDecimal> billMap = transactionBillService.selectSumOfMoneyGroupByStoreId(query)
.stream().collect(Collectors.toMap(LongDecimalVO::getKey, LongDecimalVO::getValue)); .stream().collect(Collectors.toMap(LongDecimalVO::getKey, LongDecimalVO::getValue));
// 查询退款信息 // 查询退款信息
@ -148,7 +181,7 @@ public class StoreAssemblerImpl implements StoreAssembler {
} }
/** /**
* 拼接本日收入订单量 * 拼接本日收入
* *
* @param list * @param list
*/ */
@ -159,20 +192,14 @@ public class StoreAssemblerImpl implements StoreAssembler {
} }
LocalDate now = LocalDate.now(); LocalDate now = LocalDate.now();
// 查询订单信息 // 查询支付信息
TransactionBillQuery query = new TransactionBillQuery(); PayBillQuery query = new PayBillQuery();
query.setStoreIds(list.stream().map(StoreVo::getStoreId).filter(Objects::nonNull).distinct() query.setStoreIds(CollectionUtils.map(list, StoreVo::getStoreId));
.collect(Collectors.toList())); query.setStatusList(PayBillStatus.payedList());
query.setStatusList(TransactionBillStatus.payedOrder()); query.setPayDate(now);
query.setType(TransactionBillType.RECHARGE.getType()); Map<Long, BigDecimal> billMap = payBillService.selectSumOfAmountGroupByStoreId(query)
query.setCreateDate(now);
Map<Long, BigDecimal> billMap = transactionBillService.selectSumOfMoneyGroupByStoreId(query)
.stream().collect(Collectors.toMap(LongDecimalVO::getKey, LongDecimalVO::getValue)); .stream().collect(Collectors.toMap(LongDecimalVO::getKey, LongDecimalVO::getValue));
// 查询订单量
Map<Long, Integer> countMap = transactionBillService.selectCountGroupByStoreId(query)
.stream().collect(Collectors.toMap(LongIntegerVO::getKey, LongIntegerVO::getValue));
// 查询退款信息 // 查询退款信息
RefundQuery refundQuery = new RefundQuery(); RefundQuery refundQuery = new RefundQuery();
refundQuery.setStoreIds(CollectionUtils.map(list, StoreVo::getStoreId)); refundQuery.setStoreIds(CollectionUtils.map(list, StoreVo::getStoreId));
@ -185,13 +212,6 @@ public class StoreAssemblerImpl implements StoreAssembler {
for (StoreVo store : list) { for (StoreVo store : list) {
BigDecimal todayIncome = billMap.get(store.getStoreId()); BigDecimal todayIncome = billMap.get(store.getStoreId());
BigDecimal refundAmount = refundMap.get(store.getStoreId()); BigDecimal refundAmount = refundMap.get(store.getStoreId());
Integer count = countMap.get(store.getStoreId());
// 订单量
if (count != null) {
store.setTodayOrderCount(count);
} else {
store.setTodayOrderCount(0);
}
// 订单金额 // 订单金额
if (todayIncome == null) { if (todayIncome == null) {
todayIncome = BigDecimal.ZERO; todayIncome = BigDecimal.ZERO;
@ -217,15 +237,13 @@ public class StoreAssemblerImpl implements StoreAssembler {
// 上月 // 上月
LocalDate lastMonth = LocalDate.now().plusMonths(-1); LocalDate lastMonth = LocalDate.now().plusMonths(-1);
// 查询订单信息 // 查询支付信息
TransactionBillQuery query = new TransactionBillQuery(); PayBillQuery query = new PayBillQuery();
query.setStoreIds(list.stream().map(StoreVo::getStoreId).filter(Objects::nonNull).distinct() query.setStoreIds(CollectionUtils.map(list, StoreVo::getStoreId));
.collect(Collectors.toList())); query.setStatusList(PayBillStatus.payedList());
query.setStatusList(TransactionBillStatus.payedOrder()); query.setPayMonth(lastMonth.getMonthValue());
query.setType(TransactionBillType.RECHARGE.getType()); query.setPayYear(lastMonth.getYear());
query.setMonth(lastMonth.getMonthValue()); Map<Long, BigDecimal> billMap = payBillService.selectSumOfAmountGroupByStoreId(query)
query.setYear(lastMonth.getYear());
Map<Long, BigDecimal> billMap = transactionBillService.selectSumOfMoneyGroupByStoreId(query)
.stream().collect(Collectors.toMap(LongDecimalVO::getKey, LongDecimalVO::getValue)); .stream().collect(Collectors.toMap(LongDecimalVO::getKey, LongDecimalVO::getValue));
// 查询退款信息 // 查询退款信息