Browse Source

退款优化,工作台昨日数据改正

huangqizheng/feature-20250707173453-7.7bug修改
lijianlin 1 month ago
parent
commit
b792a8f82b
  1. 22
      src/main/java/com/example/demo/domain/vo/WorkbenchMarketCard.java
  2. 2
      src/main/java/com/example/demo/service/WorkbenchService.java
  3. 4
      src/main/java/com/example/demo/serviceImpl/RefundServiceImpl.java
  4. 63
      src/main/java/com/example/demo/serviceImpl/WorkbenchServiceImpl.java

22
src/main/java/com/example/demo/domain/vo/WorkbenchMarketCard.java

@ -31,21 +31,21 @@ public class WorkbenchMarketCard implements Serializable {
private Integer currentFree; // 免费金币余量currentFreeJune + currentFreeDecember
// 卡片二充值相关
private Integer recharge; // 日充值金币数
private Integer money; // 日金额永久金币
private Integer recharge; // 日充值金币数
private Integer money; // 日金额永久金币
private Integer yearlyRecharge; // 全年累计充值金币数
private Integer yearlyMoney; // 全年累计金额
// 卡片三当日消费/退款/消耗相关
private Integer consumePermanent; // 日新增消费永久
private Integer consumeFreeJune; // 日新增消费六月免费
private Integer consumeFreeDecember; // 日新增消费十二月免费
private Integer consumeTask; // 日新增消费任务
private Integer refundPermanent; // 日新增退款永久
private Integer refundFreeJune; // 日新增退款六月免费
private Integer refundFreeDecember; // 日新增退款十二月免费
private Integer refundTask; // 日新增退款任务
private Integer dailyReduce; // 日总消耗 = consumePermanent + consumeFreeJune + consumeFreeDecember + consumeTask - (refundPermanent + refundFreeJune + refundFreeDecember + refundTask)
private Integer consumePermanent; // 日新增消费永久
private Integer consumeFreeJune; // 日新增消费六月免费
private Integer consumeFreeDecember; // 日新增消费十二月免费
private Integer consumeTask; // 日新增消费任务
private Integer refundPermanent; // 日新增退款永久
private Integer refundFreeJune; // 日新增退款六月免费
private Integer refundFreeDecember; // 日新增退款十二月免费
private Integer refundTask; // 日新增退款任务
private Integer dailyReduce; // 日总消耗 = consumePermanent + consumeFreeJune + consumeFreeDecember + consumeTask - (refundPermanent + refundFreeJune + refundFreeDecember + refundTask)
private Integer yearlyConsume; // 全年累计消费
private Integer yearlyRefund; // 全年累计退款金币数
private Integer yearlyReduce; // 全年累计消耗金币数 = yearlyConsume - yearlyRefund

2
src/main/java/com/example/demo/service/WorkbenchService.java

@ -22,7 +22,7 @@ public interface WorkbenchService {
//获取不同地区的工作台统计卡片
WorkbenchCard getCard(String token);
//获取卡片数据
WorkbenchMarketCard createWorkbenchMarketCard(String market, Statistics statistics, Date yearlyStartDate, Date currentDate);
WorkbenchMarketCard createWorkbenchMarketCard(String market, Statistics currentStatistics,Statistics ydayStatistics, Date yearlyStartDate, Date currentDate);
//获取不同地区的工作台柱状图数据根据类型起止时间地区查询
WorkbenchCard getGraph(String token, Date startDate, Date endDate, List<String> markets);
//根据类型获取年初至今的统计数据

4
src/main/java/com/example/demo/serviceImpl/RefundServiceImpl.java

@ -142,8 +142,8 @@ public class RefundServiceImpl implements RefundService {
userGoldRecord.setType((byte) 2);
userGoldRecord.setAuditStatus(0);
userGoldRecord.setCreateTime(new Date());
List<ConsumeUser> list = consumeMapper.selectOrderCodeByJwcode(userGoldRecord.getJwcode().toString(), userGoldRecord.getOrderCode());
if (list != null && list.isEmpty()) {
List<ConsumeUser> list = consumeMapper.selectOrderCodeByJwcode(userGoldRecord.getJwcode().toString(), orderCode);
if (list == null || list.isEmpty()) {
return Result.error("该用户没有该订单号");
}
refundMapper.add(userGoldRecord);

63
src/main/java/com/example/demo/serviceImpl/WorkbenchServiceImpl.java

@ -40,14 +40,20 @@ public class WorkbenchServiceImpl implements WorkbenchService {
private StatisticsMapper statisticsMapper;
@Override
public WorkbenchCard getCard(String token) {
Date date=new Date();
Date date=new Date();//当天
Date yday=generalService.getYesterday();
// 获取开始时间和结束时间当天
LocalDateTime startOfDay = date.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDateTime()
.with(LocalTime.MIN);
LocalDateTime endOfDay = startOfDay.plusDays(1).minusSeconds(1);
// 获取开始时间和结束时间当天
LocalDateTime startOfYday = yday.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDateTime()
.with(LocalTime.MIN);
LocalDateTime endOfYday = startOfYday.plusDays(1).minusSeconds(1);
// 获取当前日期
LocalDate today = LocalDate.now();
// 获取当前年份的第一天
@ -61,13 +67,18 @@ public class WorkbenchServiceImpl implements WorkbenchService {
.filter(market -> market != null && !market.trim().isEmpty())
.map(market -> {
// 根据市场名称和日期范围查询统计信息
Statistics statistics = statisticsMapper.selectByMarketAndDate(
Statistics currentStatistics = statisticsMapper.selectByMarketAndDate(
market,
Date.from(startOfDay.atZone(ZoneId.systemDefault()).toInstant()),
Date.from(endOfDay.atZone(ZoneId.systemDefault()).toInstant())
);
Statistics ydayStatistics = statisticsMapper.selectByMarketAndDate(
market,
Date.from(startOfYday.atZone(ZoneId.systemDefault()).toInstant()),
Date.from(endOfYday.atZone(ZoneId.systemDefault()).toInstant())
);
// 创建并返回市场卡片对象
return createWorkbenchMarketCard(market, statistics, yearlyStartDate, date);
return createWorkbenchMarketCard(market, currentStatistics,ydayStatistics, yearlyStartDate, date);
})
// 收集并行流结果为列表
.collect(Collectors.toList());
@ -137,48 +148,48 @@ public class WorkbenchServiceImpl implements WorkbenchService {
获取卡片数据
*/
@Override
public WorkbenchMarketCard createWorkbenchMarketCard(String market, Statistics statistics, Date yearlyStartDate, Date currentDate) {
public WorkbenchMarketCard createWorkbenchMarketCard(String market,Statistics currentStatistics, Statistics ydayStatistics, Date yearlyStartDate, Date currentDate) {
Date date=new Date();
WorkbenchMarketCard card = new WorkbenchMarketCard();
card.setMarket(market);
if (statistics != null) {
if (currentStatistics != null&& ydayStatistics != null) {
// 一次性获取全年统计数据从年初到今天
Map<String, Integer> yearlyStats = calculateAllSum(market, yearlyStartDate, date);
// 卡片一当前金币相关
card.setCurrentPermanent(statistics.getCurrentPermanent());//余量-永久金币
card.setCurrentFreeJune(statistics.getCurrentFreeJune()); //余量-免费六月金币
card.setCurrentFreeDecember(statistics.getCurrentFreeDecember()); //余量-免费十二月金币
card.setCurrentTask(statistics.getCurrentTask()); //余量-任务金币
card.setCurrentPermanent(currentStatistics.getCurrentPermanent());//余量-永久金币
card.setCurrentFreeJune(currentStatistics.getCurrentFreeJune()); //余量-免费六月金币
card.setCurrentFreeDecember(currentStatistics.getCurrentFreeDecember()); //余量-免费十二月金币
card.setCurrentTask(currentStatistics.getCurrentTask()); //余量-任务金币
card.setCurrentFree(card.getCurrentFreeJune() + card.getCurrentFreeDecember()); //余量-免费金币
card.setCurrentGold(card.getCurrentPermanent() + card.getCurrentFree() + card.getCurrentTask()); //余量-总金币
card.setDailyChange(statistics.getDailyChange()); //较前一日变化
card.setDailyChange(currentStatistics.getDailyChange()); //较前一日变化
// 卡片二充值相关
card.setRecharge(statistics.getRecharge()); //充值-日充值
card.setMoney(statistics.getMoney()); //充值-日金额永久
card.setRecharge(ydayStatistics.getRecharge()); //充值-日充值
card.setMoney(ydayStatistics.getMoney()); //充值-日金额永久
card.setYearlyRecharge(yearlyStats.getOrDefault("recharge", 0)); // 充值-全年累计充值
card.setYearlyMoney(yearlyStats.getOrDefault("money", 0)); // 充值-全年累计金额永久//充值-全年累计金额永久
// 卡片三消费与退款
card.setConsumePermanent(statistics.getConsumePermanent());//消费-永久金币
card.setConsumeFreeJune(statistics.getConsumeFreeJune());//消费-免费六月金币
card.setConsumeFreeDecember(statistics.getConsumeFreeDecember());//消费-免费十二月金币
card.setConsumeTask(statistics.getConsumeTask());//消费-任务金币
card.setRefundPermanent(statistics.getRefundPermanent());//退款-永久金币
card.setRefundFreeJune(statistics.getRefundFreeJune());//退款-免费六月金币
card.setRefundFreeDecember(statistics.getRefundFreeDecember());//退款-免费十二月金币
card.setRefundTask(statistics.getRefundTask());//退款-任务金币
//日总消费
card.setConsumePermanent(ydayStatistics.getConsumePermanent());//昨日消费-永久金币
card.setConsumeFreeJune(ydayStatistics.getConsumeFreeJune());//昨日消费-免费六月金币
card.setConsumeFreeDecember(ydayStatistics.getConsumeFreeDecember());//昨日消费-免费十二月金币
card.setConsumeTask(ydayStatistics.getConsumeTask());//昨日消费-任务金币
card.setRefundPermanent(ydayStatistics.getRefundPermanent());//昨日退款-永久金币
card.setRefundFreeJune(ydayStatistics.getRefundFreeJune());//昨日退款-免费六月金币
card.setRefundFreeDecember(ydayStatistics.getRefundFreeDecember());//昨日退款-免费十二月金币
card.setRefundTask(ydayStatistics.getRefundTask());//昨日退款-任务金币
//日总消费
int totalConsume = card.getConsumePermanent() + card.getConsumeFreeJune() + card.getConsumeFreeDecember() + card.getConsumeTask();
//日总退款
//日总退款
int totalRefund = card.getRefundPermanent() + card.getRefundFreeJune() + card.getRefundFreeDecember() + card.getRefundTask();
card.setDailyReduce(totalConsume - totalRefund);//日总消耗
card.setDailyReduce(totalConsume - totalRefund);//日总消耗
card.setYearlyConsume(yearlyStats.getOrDefault("consume", 0)); // 年累计消费
card.setYearlyRefund(yearlyStats.getOrDefault("refund", 0)); // 年累计退款
card.setYearlyReduce(card.getYearlyConsume() - card.getYearlyRefund());//年累计消耗
// 卡片四人头数相关
card.setRechargeNum(statistics.getRechargeNum());
card.setFirstRecharge(statistics.getFirstRecharge());
card.setRechargeNum(currentStatistics.getRechargeNum());
card.setFirstRecharge(currentStatistics.getFirstRecharge());
card.setYearlyRechargeNum(yearlyStats.getOrDefault("rechargeNum", 0));

Loading…
Cancel
Save