报表相关 增加退款后,报表中需要体现

This commit is contained in:
wyn
2026-06-18 17:37:43 +08:00
parent 156862a0c5
commit 7dc1241064
23 changed files with 1162 additions and 155 deletions

View File

@@ -71,7 +71,7 @@ public class StatisticsBusinessVipController {
reBuyRules.put("国学", Arrays.asList(7));
reBuyRules.put("心理学", Arrays.asList(8));
reBuyRules.put("中西汇通学", Arrays.asList(9));
reBuyRules.put("妇幼生殖", Arrays.asList(10));
reBuyRules.put("妇幼生殖", Arrays.asList(10));
// 判断是否复购
List<Integer> required = reBuyRules.get(vipType);
if (required != null && state1UserVips.containsAll(required)) {
@@ -142,8 +142,8 @@ public class StatisticsBusinessVipController {
row5.createCell(0).setCellValue("肿瘤学");row5.createCell(1).setCellValue(state1Counts.getOrDefault("肿瘤学", 0).toString());
row5.createCell(2).setCellValue("肿瘤学");row5.createCell(3).setCellValue(state0Counts.getOrDefault("肿瘤学", 0).toString());
Row row6 = sheet.createRow(rowNum++);
row6.createCell(0).setCellValue("妇幼生殖");row6.createCell(1).setCellValue(state1Counts.getOrDefault("妇幼生殖",0).toString());
row6.createCell(2).setCellValue("妇幼生殖");row6.createCell(3).setCellValue(state0Counts.getOrDefault("妇幼生殖", 0).toString());
row6.createCell(0).setCellValue("妇幼生殖");row6.createCell(1).setCellValue(state1Counts.getOrDefault("妇幼生殖",0).toString());
row6.createCell(2).setCellValue("妇幼生殖");row6.createCell(3).setCellValue(state0Counts.getOrDefault("妇幼生殖", 0).toString());
Row row7 = sheet.createRow(rowNum++);
row7.createCell(0).setCellValue("国学");row7.createCell(1).setCellValue(state1Counts.getOrDefault("国学",0).toString());
row7.createCell(2).setCellValue("国学");row7.createCell(3).setCellValue(state0Counts.getOrDefault("国学", 0).toString());
@@ -296,8 +296,8 @@ public class StatisticsBusinessVipController {
Row row1 = sheet.createRow(rowNum++);
Map<String,Integer> state1Counts = (Map<String,Integer>) r.get("banTypeTotalCounts");
Map<String,Integer> state0Counts = (Map<String,Integer>) r.get("yanTypeTotalCounts");
row1.createCell(0).setCellValue("医学超级");row1.createCell(1).setCellValue(state1Counts.get("医学超级").toString());
row1.createCell(2).setCellValue("医学超级");row1.createCell(3).setCellValue(state0Counts.get("医学超级").toString());
row1.createCell(0).setCellValue("医学超级");row1.createCell(1).setCellValue(state1Counts.containsKey("医学超级")?state1Counts.get("医学超级").toString():"");
row1.createCell(2).setCellValue("医学超级");row1.createCell(3).setCellValue(state0Counts.containsKey("医学超级")?state0Counts.get("医学超级").toString():"");
row1.createCell(4).setCellValue("总延期金额");row1.createCell(5).setCellValue(r.get("yanTotalPrice").toString());
BigDecimal b = new BigDecimal(r.get("yanTotalCount").toString()).subtract(new BigDecimal(r2.get("yanTotalCount").toString())).divide(new BigDecimal(r.get("yanTotalCount").toString()), 4, RoundingMode.HALF_UP);
row1.createCell(6).setCellValue("延期总人数同比增长率:");row1.createCell(7).setCellValue(df.format(b));
@@ -320,8 +320,8 @@ public class StatisticsBusinessVipController {
row5.createCell(0).setCellValue("肿瘤学");row5.createCell(1).setCellValue(state1Counts.getOrDefault("肿瘤学", 0).toString());
row5.createCell(2).setCellValue("肿瘤学");row5.createCell(3).setCellValue(state0Counts.getOrDefault("肿瘤学", 0).toString());
Row row6 = sheet.createRow(rowNum++);
row6.createCell(0).setCellValue("妇幼生殖");row6.createCell(1).setCellValue(state1Counts.getOrDefault("妇幼生殖",0).toString());
row6.createCell(2).setCellValue("妇幼生殖");row6.createCell(3).setCellValue(state0Counts.getOrDefault("妇幼生殖", 0).toString());
row6.createCell(0).setCellValue("妇幼生殖");row6.createCell(1).setCellValue(state1Counts.getOrDefault("妇幼生殖",0).toString());
row6.createCell(2).setCellValue("妇幼生殖");row6.createCell(3).setCellValue(state0Counts.getOrDefault("妇幼生殖", 0).toString());
Row row7 = sheet.createRow(rowNum++);
row7.createCell(0).setCellValue("国学");row7.createCell(1).setCellValue(state1Counts.getOrDefault("国学",0).toString());
row7.createCell(2).setCellValue("国学");row7.createCell(3).setCellValue(state0Counts.getOrDefault("国学", 0).toString());
@@ -346,7 +346,7 @@ public class StatisticsBusinessVipController {
fillRow(sheet.createRow(rowNum++), 0, "中医学", banCounts, yanCounts);
fillRow(sheet.createRow(rowNum++), 0, "针灸学", banCounts, yanCounts);
fillRow(sheet.createRow(rowNum++), 0, "肿瘤学", banCounts, yanCounts);
fillRow(sheet.createRow(rowNum++), 0, "妇幼生殖", banCounts, yanCounts);
fillRow(sheet.createRow(rowNum++), 0, "妇幼生殖", banCounts, yanCounts);
fillRow(sheet.createRow(rowNum++), 0, "国学", banCounts, yanCounts);
fillRow(sheet.createRow(rowNum++), 0, "心理学", banCounts, yanCounts);
fillRow(sheet.createRow(rowNum++), 0, "中西汇通学", banCounts, yanCounts);
@@ -360,7 +360,7 @@ public class StatisticsBusinessVipController {
sheet.createRow(rowNum++).createCell(0).setCellValue("中医学");sheet.getRow(rowNum-1).createCell(1).setCellValue(banTypeRatios.getOrDefault("中医学",0).toString());
sheet.createRow(rowNum++).createCell(0).setCellValue("针灸学");sheet.getRow(rowNum-1).createCell(1).setCellValue(banTypeRatios.getOrDefault("针灸学",0).toString());
sheet.createRow(rowNum++).createCell(0).setCellValue("肿瘤学");sheet.getRow(rowNum-1).createCell(1).setCellValue(banTypeRatios.getOrDefault("肿瘤学",0).toString());
sheet.createRow(rowNum++).createCell(0).setCellValue("妇幼生殖");sheet.getRow(rowNum-1).createCell(1).setCellValue(banTypeRatios.getOrDefault("妇幼生殖",0).toString());
sheet.createRow(rowNum++).createCell(0).setCellValue("妇幼生殖");sheet.getRow(rowNum-1).createCell(1).setCellValue(banTypeRatios.getOrDefault("妇幼生殖",0).toString());
sheet.createRow(rowNum++).createCell(0).setCellValue("国学");sheet.getRow(rowNum-1).createCell(1).setCellValue(banTypeRatios.getOrDefault("国学",0).toString());
sheet.createRow(rowNum++).createCell(0).setCellValue("心理学");sheet.getRow(rowNum-1).createCell(1).setCellValue(banTypeRatios.getOrDefault("心理学",0).toString());
sheet.createRow(rowNum++).createCell(0).setCellValue("中西汇通学");sheet.getRow(rowNum-1).createCell(1).setCellValue(banTypeRatios.getOrDefault("中西汇通学",0).toString());
@@ -443,14 +443,17 @@ public class StatisticsBusinessVipController {
row5.createCell(1).setCellValue("肿瘤学");row5.createCell(2).setCellValue(state1Counts.get("zlCount").toString());
row5.createCell(4).setCellValue("肿瘤学");row5.createCell(5).setCellValue(state0Counts.get("zlCount").toString());
Row row6 = sheet.createRow(rowNum++);
row6.createCell(1).setCellValue("");row6.createCell(2).setCellValue(state1Counts.get("gxCount").toString());
row6.createCell(4).setCellValue("");row6.createCell(5).setCellValue(state0Counts.get("gxCount").toString());
row6.createCell(1).setCellValue("妇幼生殖");row6.createCell(2).setCellValue(state1Counts.get("fyszCount").toString());
row6.createCell(4).setCellValue("妇幼生殖");row6.createCell(5).setCellValue(state0Counts.get("fyszCount").toString());
Row row7 = sheet.createRow(rowNum++);
row7.createCell(1).setCellValue("心理");row7.createCell(2).setCellValue(state1Counts.get("xlCount").toString());
row7.createCell(4).setCellValue("心理");row7.createCell(5).setCellValue(state0Counts.get("xlCount").toString());
row7.createCell(1).setCellValue("");row7.createCell(2).setCellValue(state1Counts.get("gxCount").toString());
row7.createCell(4).setCellValue("");row7.createCell(5).setCellValue(state0Counts.get("gxCount").toString());
Row row8 = sheet.createRow(rowNum++);
row8.createCell(1).setCellValue("中西汇通");row8.createCell(2).setCellValue(state1Counts.get("zxhtCount").toString());
row8.createCell(4).setCellValue("中西汇通");row8.createCell(5).setCellValue(state0Counts.get("zxhtCount").toString());
row8.createCell(1).setCellValue("心理");row8.createCell(2).setCellValue(state1Counts.get("xlCount").toString());
row8.createCell(4).setCellValue("心理");row8.createCell(5).setCellValue(state0Counts.get("xlCount").toString());
Row row9 = sheet.createRow(rowNum++);
row9.createCell(1).setCellValue("中西汇通学");row9.createCell(2).setCellValue(state1Counts.get("zxhtCount").toString());
row9.createCell(4).setCellValue("中西汇通学");row9.createCell(5).setCellValue(state0Counts.get("zxhtCount").toString());
export(wb,sheet,fileName,++rowNum,response,headers,cellValues, (List<Map<String, Object>>) r.get("resultList"));
}
@@ -489,7 +492,8 @@ public class StatisticsBusinessVipController {
"6","肿瘤学",
"7","国学",
"8","心理学",
"9","中西汇通学"
"9","中西汇通学",
"10","妇幼生殖学"
);
// 封装统计结果
@@ -510,6 +514,7 @@ public class StatisticsBusinessVipController {
result.counts.put("gxCount",0);
result.counts.put("xlCount",0);
result.counts.put("zxhtCount",0);
result.counts.put("fyszCount",0);
for (Map<String,Object> map : userVips) {
String[] types = map.get("type").toString().split(",");
@@ -517,7 +522,7 @@ public class StatisticsBusinessVipController {
int yxFlag = 0;
int gxFlag = 0;
// 超级类型
if (typeSet.containsAll(Arrays.asList("4","5","6","9"))) {
if (typeSet.containsAll(Arrays.asList("4","5","6","9","10"))) {
yxFlag = 1;
Map<String,Object> copy = new HashMap<>(map);
copy.put("vipType","医学超级");
@@ -545,7 +550,7 @@ public class StatisticsBusinessVipController {
else if ("7".equals(type) && gxFlag==0) { copy.put("vipType","国学"); result.counts.computeIfPresent("gxCount",(k,v)->v+1); }
else if ("8".equals(type) && gxFlag==0) { copy.put("vipType","心理学"); result.counts.computeIfPresent("xlCount",(k,v)->v+1); }
else if ("9".equals(type) && yxFlag==0) { copy.put("vipType","中西汇通学"); result.counts.computeIfPresent("zxhtCount",(k,v)->v+1); }
else if ("10".equals(type) && yxFlag==0) { copy.put("vipType","妇幼生殖学"); result.counts.computeIfPresent("fyszCount",(k,v)->v+1); }
if (copy.get("vipType") != null) {
result.resultList.add(copy);
result.total.add(map.get("tel").toString());

View File

@@ -367,9 +367,13 @@ public class StatisticsController {
@RequestMapping("/getUserCourseBuyInfoTotal")
public R getUserCourseBuyInfoTotal(@RequestBody Map<String, Object> params) {
List<Map<String,Object>> tanxiaoTotal = userCourseBuyService.getUserCourseBuyInfoTotal(params.get("date").toString());
List<Map<String,Object>> income = userCourseBuyService.getIncome(params.get("date").toString());
return R.ok().put("tanxiaoTotal", tanxiaoTotal).put("income", income);
String date = params.get("date").toString();
List<Map<String,Object>> tanxiaoTotal = userCourseBuyService.getUserCourseBuyInfoTotal(date);
List<Map<String,Object>> monthRefund = userCourseBuyService.getSameMonthRefund(date);
List<Map<String,Object>> income = mergeIncomeWithMonthRefund(
userCourseBuyService.getIncome(date), monthRefund);
List<Map<String,Object>> refund = userCourseBuyService.getRefund(date);
return R.ok().put("tanxiaoTotal", tanxiaoTotal).put("income", income).put("monthRefund", monthRefund).put("refund", refund);
}
//课程明细
@@ -390,42 +394,46 @@ public class StatisticsController {
titleRow.createCell(8).setCellValue("支付类型");
titleRow.createCell(9).setCellValue("支付时间");
titleRow.createCell(10).setCellValue("订单编号");
titleRow.createCell(11).setCellValue("支付宝号");
titleRow.createCell(12).setCellValue("天数");
titleRow.createCell(13).setCellValue("金额");
titleRow.createCell(14).setCellValue("备注");
titleRow.createCell(15).setCellValue("开始摊销时间");
titleRow.createCell(16).setCellValue("每日摊销");
titleRow.createCell(17).setCellValue("已摊销天数");
titleRow.createCell(18).setCellValue("本期天数");
titleRow.createCell(19).setCellValue("已摊销金额");
titleRow.createCell(20).setCellValue("本期摊销金额");
titleRow.createCell(21).setCellValue("剩余金额");
titleRow.createCell(11).setCellValue("订单类型");
titleRow.createCell(12).setCellValue("支付宝号");
titleRow.createCell(13).setCellValue("天数");
titleRow.createCell(14).setCellValue("金额");
titleRow.createCell(15).setCellValue("备注");
titleRow.createCell(16).setCellValue("开始摊销时间");
titleRow.createCell(17).setCellValue("每日摊销");
titleRow.createCell(18).setCellValue("已摊销天数");
titleRow.createCell(19).setCellValue("本期天数");
titleRow.createCell(20).setCellValue("摊销金额");
titleRow.createCell(21).setCellValue("本期摊销金额");
titleRow.createCell(22).setCellValue("剩余金额");
titleRow.createCell(23).setCellValue("退款单号");
int cell = 1;
for (Map<String,Object> map : maps) {
Row row = sheet.createRow(cell);
row.createCell(0).setCellValue(map.get("name").toString());
row.createCell(1).setCellValue(map.get("tel").toString());
row.createCell(2).setCellValue(map.get("ctitle").toString());
row.createCell(3).setCellValue(map.get("cctitle").toString());
row.createCell(4).setCellValue(map.get("startTime").toString());
row.createCell(5).setCellValue(map.get("endTime").toString());
row.createCell(6).setCellValue(map.get("totalDays").toString());
row.createCell(7).setCellValue(map.get("type").toString());
row.createCell(8).setCellValue(map.get("payType").toString());
row.createCell(9).setCellValue(map.get("payTime").toString());
row.createCell(10).setCellValue(map.get("orderSn").toString());
row.createCell(11).setCellValue(map.get("zfbOrder")==null?"":map.get("zfbOrder").toString());
row.createCell(12).setCellValue(map.get("days").toString());
row.createCell(13).setCellValue(map.get("fee").toString());
row.createCell(14).setCellValue(map.get("remark").toString());
row.createCell(15).setCellValue(map.get("startTanxiaoTime")==null?"":map.get("startTanxiaoTime").toString());
row.createCell(16).setCellValue(map.get("dayAmount").toString());
row.createCell(17).setCellValue(map.get("alreadyDay").toString());
row.createCell(18).setCellValue(map.get("currentDay").toString());
row.createCell(19).setCellValue(map.get("alreadyTanxiao").toString());
row.createCell(20).setCellValue(map.get("currentTanxiao").toString());
row.createCell(21).setCellValue(map.get("surplusTanxiao").toString());
row.createCell(0).setCellValue(cellStr(map.get("name")));
row.createCell(1).setCellValue(cellStr(map.get("tel")));
row.createCell(2).setCellValue(cellStr(map.get("ctitle")));
row.createCell(3).setCellValue(cellStr(map.get("cctitle")));
row.createCell(4).setCellValue(cellStr(map.get("startTime")));
row.createCell(5).setCellValue(cellStr(map.get("endTime")));
row.createCell(6).setCellValue(cellStr(map.get("totalDays")));
row.createCell(7).setCellValue(cellStr(map.get("type")));
row.createCell(8).setCellValue(cellStr(map.get("payType")));
row.createCell(9).setCellValue(cellStr(map.get("payTime")));
row.createCell(10).setCellValue(cellStr(map.get("orderSn")));
row.createCell(11).setCellValue(cellStr(map.get("orderStatus")));
row.createCell(12).setCellValue(cellStr(map.get("zfbOrder")));
row.createCell(13).setCellValue(cellStr(map.get("days")));
row.createCell(14).setCellValue(cellStr(map.get("fee")));
row.createCell(15).setCellValue(cellStr(map.get("remark")));
row.createCell(16).setCellValue(cellStr(map.get("startTanxiaoTime")));
row.createCell(17).setCellValue(cellStr(map.get("dayAmount")));
row.createCell(18).setCellValue(cellStr(map.get("alreadyDay")));
row.createCell(19).setCellValue(cellStr(map.get("currentDay")));
row.createCell(20).setCellValue(cellStr(map.get("alreadyTanxiao")));
row.createCell(21).setCellValue(cellStr(map.get("currentTanxiao")));
row.createCell(22).setCellValue(cellStr(map.get("surplusTanxiao")));
row.createCell(22).setCellValue(cellStr(map.get("refund_no")));
//序号自增
cell++;
}
@@ -456,7 +464,8 @@ public class StatisticsController {
public R getTransactionDetailsTotal(@RequestBody Map<String, Object> params) {
Map<String,Object> map = transactionDetailsService.getUserSurplusPeanutCoin(params.get("date").toString()+" 23:59:59");
List<Map<String,Object>> list = transactionDetailsService.getTransactionDetailsTotal(params.get("date").toString()+" 23:59:59");
return R.ok().put("total", list).put("surplus", map);
List<Map<String,Object>> refundList = transactionDetailsService.getRefundTransactionDetails(params.get("date").toString()+" 23:59:59");
return R.ok().put("total", list).put("surplus", map).put("refundInfo", refundList);
}
//导出实物订单明细
@@ -523,7 +532,8 @@ public class StatisticsController {
@RequestMapping("/getPhysicalBuyOrderInfoTotal")
public R getPhysicalBuyOrderInfoTotal(@RequestBody Map<String, Object> params) {
List<Map<String,Object>> list = buyOrderService.getPhysicalBuyOrderTotal(params.get("date").toString(),params.get("orderType").toString());
List<Map<String,Object>> list = buyOrderService.getPhysicalBuyOrderTotal(
params.get("date").toString(), params.get("orderType").toString());
return R.ok().put("total", list);
}
@@ -548,6 +558,7 @@ public class StatisticsController {
titleRow.createCell(9).setCellValue("商品名称");
titleRow.createCell(10).setCellValue("数量");
titleRow.createCell(11).setCellValue("备注");
titleRow.createCell(12).setCellValue("退款单号");
//序号默认为1
int cell = 1;
//遍历
@@ -560,11 +571,12 @@ public class StatisticsController {
row.createCell(4).setCellValue(map.get("zfbOrder")==null?"":map.get("zfbOrder").toString());
row.createCell(5).setCellValue(map.get("orderStatus").toString());
row.createCell(6).setCellValue(map.get("payType").toString());
row.createCell(7).setCellValue(map.get("orderPrice").toString());
row.createCell(8).setCellValue(map.get("price").toString());
row.createCell(7).setCellValue(toAmount(map.get("orderPrice")).doubleValue());
row.createCell(8).setCellValue(toAmount(map.get("price")).doubleValue());
row.createCell(9).setCellValue(map.get("productName").toString());
row.createCell(10).setCellValue(map.get("quantity").toString());
row.createCell(11).setCellValue(map.get("remark").toString());
row.createCell(12).setCellValue(map.get("refund_no")!=null?map.get("refund_no").toString():"");
//序号自增
cell++;
}
@@ -593,7 +605,40 @@ public class StatisticsController {
@RequestMapping("/getUserVipLogInfoTotal")
public R getUserVipLogInfoTotal(@RequestBody Map<String, Object> params) {
Map<String,Object> map = userVipLogService.getUserVipLogInfoTotal(params.get("date").toString());
String date = params.get("date").toString();
//有效订单
Map<String,Object> map = userVipLogService.getUserVipLogInfoTotal(date);
//本月退款金额
BigDecimal refundFee = userVipLogService.getUserVipRefundFeeTotal(date);
//本月退款的订单
List<Map<String,Object>> monthRefundMap = userVipLogService.getMonthRefund(date);
String exportMonth = date.length() >= 7 ? date.substring(0, 7) : date;
BigDecimal refundFeeToSR = BigDecimal.ZERO;
BigDecimal refundMonthTX = BigDecimal.ZERO;
BigDecimal refundYetTX = BigDecimal.ZERO;
if(date.equals("2026-04-30"))log.info("currentTanxiao======="+map.get("currentTanxiao").toString());
for (Map<String,Object> one : monthRefundMap) {
String payMonth = userVipLogService.getPayMonth(one);
if (exportMonth.equals(payMonth)) {
refundFeeToSR = refundFeeToSR.add(new BigDecimal(one.get("fee").toString()));
}else if (!payMonth.isEmpty() && !exportMonth.equals(payMonth)) {
refundMonthTX = refundMonthTX.subtract(new BigDecimal(one.get("alreadyTanxiao").toString()));
//refundYetTX = refundYetTX.subtract(new BigDecimal(one.get("currentTanxiao").toString())).subtract(new BigDecimal(one.get("notyetTanxiao").toString()));
}
}
//当月未退款,下月之后退款的订单
List<Map<String,Object>> monthNextNRefundMap = userVipLogService.getNextNMonthRefund(date);
for (Map<String,Object> two : monthNextNRefundMap) {
System.out.println(two);
refundFeeToSR = refundFeeToSR.add(new BigDecimal(two.get("fee").toString()));
refundMonthTX = refundMonthTX.add(new BigDecimal(two.get("currentTanxiao").toString()));
if(date.equals("2026-04-30"))log.info("refundMonthTX======="+two.get("currentTanxiao").toString()+"/"+refundMonthTX);
refundYetTX = refundYetTX.add(new BigDecimal(two.get("notyetTanxiao").toString()));
}
map.put("fee", toAmount(map.get("fee")).add(refundFeeToSR));
map.put("currentTanxiao", toAmount(map.get("currentTanxiao")).add(refundMonthTX));
map.put("notyetTanxiao", toAmount(map.get("notyetTanxiao")).add(refundYetTX));
map.put("refundFee", refundFee);
return R.ok().put("total", map);
}
@@ -613,19 +658,21 @@ public class StatisticsController {
titleRow.createCell(4).setCellValue("结束时间");
titleRow.createCell(5).setCellValue("支付时间");
titleRow.createCell(6).setCellValue("订单号");
titleRow.createCell(7).setCellValue("支付宝号");
titleRow.createCell(8).setCellValue("支付方式");
titleRow.createCell(9).setCellValue("备注");
titleRow.createCell(10).setCellValue("缴费金额");
titleRow.createCell(11).setCellValue("摊销计算金额");
titleRow.createCell(12).setCellValue("总天数");
titleRow.createCell(13).setCellValue("每日摊销");
titleRow.createCell(14).setCellValue("已摊销天数");
titleRow.createCell(15).setCellValue("当月摊销天数");
titleRow.createCell(16).setCellValue("摊销天数");
titleRow.createCell(17).setCellValue("摊销金额");
titleRow.createCell(18).setCellValue("当月摊销金额");
titleRow.createCell(19).setCellValue("剩余摊销金额");
titleRow.createCell(7).setCellValue("订单类型");
titleRow.createCell(8).setCellValue("支付宝号");
titleRow.createCell(9).setCellValue("支付方式");
titleRow.createCell(10).setCellValue("备注");
titleRow.createCell(11).setCellValue("缴费金额");
titleRow.createCell(12).setCellValue("摊销计算金额");
titleRow.createCell(13).setCellValue("总天数");
titleRow.createCell(14).setCellValue("每日摊销");
titleRow.createCell(15).setCellValue("摊销天数");
titleRow.createCell(16).setCellValue("当月摊销天数");
titleRow.createCell(17).setCellValue("摊销天数");
titleRow.createCell(18).setCellValue("摊销金额");
titleRow.createCell(19).setCellValue("当月摊销金额");
titleRow.createCell(20).setCellValue("剩余摊销金额");
titleRow.createCell(21).setCellValue("退款单号");
//序号默认为1
int cell = 1;
//遍历
@@ -638,19 +685,21 @@ public class StatisticsController {
row.createCell(4).setCellValue(map.get("endTime").toString());
row.createCell(5).setCellValue(map.get("payTime").toString());
row.createCell(6).setCellValue(map.get("orderSn").toString());
row.createCell(7).setCellValue(map.get("zfbOrder")==null?"":map.get("zfbOrder").toString());
row.createCell(8).setCellValue(map.get("payType").toString());
row.createCell(9).setCellValue(map.get("remark").toString());
row.createCell(10).setCellValue(map.get("price").toString());
row.createCell(11).setCellValue(map.get("fee").toString());
row.createCell(12).setCellValue(map.get("totalDays").toString());
row.createCell(13).setCellValue(map.get("dayAmount").toString());
row.createCell(14).setCellValue(map.get("alreadyDays").toString());
row.createCell(15).setCellValue(map.get("currentDays").toString());
row.createCell(16).setCellValue(map.get("notyetDays").toString());
row.createCell(17).setCellValue(map.get("alreadyTanxiao").toString());
row.createCell(18).setCellValue(map.get("currentTanxiao").toString());
row.createCell(19).setCellValue(map.get("notyetTanxiao").toString());
row.createCell(7).setCellValue(map.get("orderStatus").toString());
row.createCell(8).setCellValue(map.get("zfbOrder")==null?"":map.get("zfbOrder").toString());
row.createCell(9).setCellValue(map.get("payType").toString());
row.createCell(10).setCellValue(map.get("remark").toString());
row.createCell(11).setCellValue(map.get("price").toString());
row.createCell(12).setCellValue(map.get("fee").toString());
row.createCell(13).setCellValue(map.get("totalDays").toString());
row.createCell(14).setCellValue(map.get("dayAmount").toString());
row.createCell(15).setCellValue(map.get("alreadyDays").toString());
row.createCell(16).setCellValue(map.get("currentDays").toString());
row.createCell(17).setCellValue(map.get("notyetDays").toString());
row.createCell(18).setCellValue(map.get("alreadyTanxiao").toString());
row.createCell(19).setCellValue(map.get("currentTanxiao").toString());
row.createCell(20).setCellValue(map.get("notyetTanxiao").toString());
row.createCell(21).setCellValue(map.get("refund_no")!=null?map.get("refund_no").toString():"");
//序号自增
cell++;
}
@@ -677,6 +726,50 @@ public class StatisticsController {
}
}
private BigDecimal toAmount(Object value) {
if (value == null) {
return BigDecimal.ZERO;
}
if (value instanceof BigDecimal) {
return (BigDecimal) value;
}
return new BigDecimal(value.toString());
}
private List<Map<String, Object>> mergeIncomeWithMonthRefund(List<Map<String, Object>> income,
List<Map<String, Object>> monthRefund) {
Map<String, BigDecimal> feeMap = new LinkedHashMap<>();
for (Map<String, Object> row : income) {
String payType = normalizeCoursePayType(row.get("pay_type"));
feeMap.merge(payType, toAmount(row.get("fee")), BigDecimal::add);
}
for (Map<String, Object> row : monthRefund) {
String payType = normalizeCoursePayType(row.get("pay_type"));
feeMap.merge(payType, toAmount(row.get("fee")), BigDecimal::add);
}
List<Map<String, Object>> result = new ArrayList<>();
for (Map.Entry<String, BigDecimal> entry : feeMap.entrySet()) {
Map<String, Object> map = new HashMap<>();
map.put("pay_type", entry.getKey());
map.put("fee", entry.getValue());
result.add(map);
}
return result;
}
private String normalizeCoursePayType(Object payType) {
if (payType == null) {
return "";
}
String type = payType.toString();
if (type.startsWith("App")) {
return type.substring(3);
}
return type;
}
private static String cellStr(Object value) {
return value == null ? "" : value.toString();
}
}

View File

@@ -288,7 +288,11 @@ public class UserCertificateController {
ClassEntity classEntity = classEntityService.getById(params.get("classId").toString());
String type = params.get("type").toString();
List<String> certificateNoList = new ArrayList<>();
Map<String,Object> classCourseInfo = classEntityService.getClassCourseInfoByClassId(classEntity.getId(),0);
int courseId = 0;
if(params.containsKey("courseId")){
courseId = Integer.parseInt(params.get("courseId").toString());
}
Map<String,Object> classCourseInfo = classEntityService.getClassCourseInfoByClassId(classEntity.getId(),courseId);
String pinyin = classCourseInfo.get("titleAbbr").toString();
String tels = params.get("tels").toString();
@@ -309,26 +313,26 @@ public class UserCertificateController {
userCertificate.setCertificateNo(certificateNo);
userCertificate.setCourseId((Integer) classCourseInfo.get("courseId"));
if (StringUtils.isNotEmpty(user.getPhoto())&&StringUtils.isNotEmpty(user.getName())){
String startYear = DateUtil.year(classEntity.getStartTime())+"";
String startMonth = DateUtil.month(classEntity.getStartTime())+1+"";
String startDay = DateUtil.dayOfMonth(classEntity.getStartTime())+"";
String endYear = DateUtil.year(classEntity.getEndTime())+"";
String endMonth = DateUtil.month(classEntity.getEndTime())+1+"";
String endDay = DateUtil.dayOfMonth(classEntity.getEndTime())+"";
double keshiTotal = (double)classCourseInfo.get("keshi");
String keshi = (keshiTotal+"").replace(".0","");
String courseTitle = classCourseInfo.get("courseTitle").toString();
if (courseTitle.contains("")){
courseTitle = courseTitle.substring(0,courseTitle.indexOf(""));
}
String[] des = {startYear,startMonth,startDay,endYear,endMonth,endDay,
classEntity.getTitle(),courseTitle,keshi};
String[] edes = {classCourseInfo.get("courseETitle").toString(),keshi};
String url = userCertificateService.generateCertificate(type,certificateNo,user.getPhoto(),user.getName(),
des, edes, endYear,endMonth,endDay);
userCertificate.setCertificateUrl(url);
}
// if (StringUtils.isNotEmpty(user.getPhoto())&&StringUtils.isNotEmpty(user.getName())){
// String startYear = DateUtil.year(classEntity.getStartTime())+"";
// String startMonth = DateUtil.month(classEntity.getStartTime())+1+"";
// String startDay = DateUtil.dayOfMonth(classEntity.getStartTime())+"";
// String endYear = DateUtil.year(classEntity.getEndTime())+"";
// String endMonth = DateUtil.month(classEntity.getEndTime())+1+"";
// String endDay = DateUtil.dayOfMonth(classEntity.getEndTime())+"";
// double keshiTotal = (double)classCourseInfo.get("keshi");
// String keshi = (keshiTotal+"").replace(".0","");
// String courseTitle = classCourseInfo.get("courseTitle").toString();
// if (courseTitle.contains("【")){
// courseTitle = courseTitle.substring(0,courseTitle.indexOf("【"));
// }
// String[] des = {startYear,startMonth,startDay,endYear,endMonth,endDay,
// classEntity.getTitle(),courseTitle,keshi};
// String[] edes = {classCourseInfo.get("courseETitle").toString(),keshi};
// String url = userCertificateService.generateCertificate(type,certificateNo,user.getPhoto(),user.getName(),
// des, edes, endYear,endMonth,endDay);
// userCertificate.setCertificateUrl(url);
// }
userCertificateService.save(userCertificate);
certificateNoList.add(user.getTel());
}

View File

@@ -221,7 +221,8 @@ public class UserVipController {
"5".equals(params.get("type").toString())?"延期针灸学VIP":
"6".equals(params.get("type").toString())?"延期肿瘤学VIP":
"7".equals(params.get("type").toString())?"延期国学VIP":
"8".equals(params.get("type").toString())?"延期心理学VIP":"延期中西汇通VIP";
"8".equals(params.get("type").toString())?"延期心理学VIP":
"10".equals(params.get("type").toString())?"妇幼生殖学VIP":"延期中西汇通VIP";
if(fee.compareTo(BigDecimal.ZERO)>0){
user.setPeanutCoin(user.getPeanutCoin().subtract(fee));
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
@@ -249,8 +250,8 @@ public class UserVipController {
List<Integer> typeList = new ArrayList<>();
int count = 1;
if ("11".equals(params.get("type").toString())) {//超v
count = 6;
for (int i=4;i<10;i++){
count = 7;
for (int i=4;i<=10;i++){
typeList.add(i);
}
}else if ("12".equals(params.get("type").toString())) {//简易超v
@@ -262,11 +263,12 @@ public class UserVipController {
typeList.add(i);
}
}else if ("1".equals(params.get("type").toString())) {//医学超级
count = 4;
for (int i=4;i<8;i++){
count = 5;
for (int i=4;i<=10;i++){
if (i==7){
i = 9;
}
log.info("=========000000===="+i);
typeList.add(i);
}
}else if ("2".equals(params.get("type").toString())) {//国心超级

View File

@@ -24,6 +24,12 @@ public interface UserCourseBuyService extends IService<UserCourseBuyEntity> {
List<Map<String,Object>> getIncome(String date);
List<Map<String,Object>> getRefund(String date);
List<Map<String,Object>> getSameMonthRefund(String date);
List<Map<String,Object>> getRefundInfo(String date);
List<Map<String,Object>> getUserCourseBuyInfoTotal(String date);
List<Map<String,Object>> getUserCourseBuyInfo(String date);

View File

@@ -20,8 +20,11 @@ import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.net.URL;
import java.net.URLConnection;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.*;
@Slf4j
@@ -186,6 +189,21 @@ public class UserCourseBuyServiceImpl extends ServiceImpl<UserCourseBuyDao, User
return this.baseMapper.getIncome(date);
}
@Override
public List<Map<String, Object>> getRefund(String date) {
return this.baseMapper.getRefund(date);
}
@Override
public List<Map<String, Object>> getSameMonthRefund(String date) {
return this.baseMapper.getSameMonthRefund(date);
}
@Override
public List<Map<String, Object>> getRefundInfo(String date) {
return this.baseMapper.getRefundInfo(date);
}
@Override
public List<Map<String, Object>> getUserCourseBuyInfoTotal(String date) {
return this.baseMapper.getUserCourseBuyInfoTotal(date);
@@ -193,7 +211,165 @@ public class UserCourseBuyServiceImpl extends ServiceImpl<UserCourseBuyDao, User
@Override
public List<Map<String, Object>> getUserCourseBuyInfo(String date) {
return this.baseMapper.getUserCourseBuyInfo(date);
List<Map<String, Object>> list = this.baseMapper.getUserCourseBuyInfo(date);
Map<String, Map<String, Object>> refundMap = new HashMap<>();
for (Map<String, Object> refund : this.baseMapper.getRefundInfo(date)) {
refundMap.put(refundKey(refund), refund);
}
List<Map<String, Object>> result = new ArrayList<>();
Set<String> matchedKeys = new HashSet<>();
String exportMonth = date.length() >= 7 ? date.substring(0, 7) : date;
for (Map<String, Object> row : list) {
row.put("orderStatus", "已付款");
Map<String, Object> refund = refundMap.get(refundKey(row));
if (refund != null) {
if (exportMonth.equals(getPayMonth(row))) {
row.put("currentDay", 0);
row.put("currentTanxiao", BigDecimal.ZERO);
row.put("surplusTanxiao", BigDecimal.ZERO);
result.add(row);
}
matchedKeys.add(refundKey(row));
result.add(buildRefundRow(row, refund, date));
} else {
result.add(row);
}
}
for (Map<String, Object> refund : refundMap.values()) {
String key = refundKey(refund);
if (matchedKeys.contains(key)) {
continue;
}
String payMonth = getPayMonth(refund);
if (exportMonth.equals(payMonth)) {
Map<String, Object> paidRow = buildPaidRowFromRefund(refund);
result.add(paidRow);
result.add(buildRefundRow(paidRow, refund, date));
} else if (!payMonth.isEmpty() && payMonth.compareTo(exportMonth) < 0) {
result.add(buildRefundRow(buildBaseRowFromRefund(refund), refund, date));
}
}
return result;
}
private String refundKey(Map<String, Object> row) {
return String.valueOf(row.get("orderSn")) + "|" + String.valueOf(row.get("ctitle")) + "|" + String.valueOf(row.get("cctitle"));
}
private Map<String, Object> buildPaidRowFromRefund(Map<String, Object> refund) {
Map<String, Object> row = new HashMap<>(refund);
row.remove("refundTime");
row.remove("orderStatus");
fillAmortizationFields(row);
row.put("alreadyDay", 0);
row.put("currentDay", 0);
row.put("alreadyTanxiao", BigDecimal.ZERO);
row.put("currentTanxiao", BigDecimal.ZERO);
row.put("surplusTanxiao", BigDecimal.ZERO);
row.put("orderStatus", "已付款");
return row;
}
private Map<String, Object> buildBaseRowFromRefund(Map<String, Object> refund) {
Map<String, Object> row = new HashMap<>(refund);
row.remove("refundTime");
row.remove("orderStatus");
fillAmortizationFields(row);
return row;
}
private void fillAmortizationFields(Map<String, Object> row) {
BigDecimal fee = toBigDecimal(row.get("fee"));
int days = toInt(row.get("days"));
Object startTime = row.get("startTime");
boolean hasStartTime = startTime != null && !startTime.toString().isEmpty();
row.put("dayAmount", hasStartTime && days > 0
? fee.divide(new BigDecimal(days), 2, RoundingMode.HALF_UP)
: BigDecimal.ZERO);
row.put("startTanxiaoTime", hasStartTime ? startTime.toString() : "");
}
private Map<String, Object> buildRefundRow(Map<String, Object> row, Map<String, Object> refund, String date) {
Map<String, Object> refundRow = new HashMap<>(row);
refundRow.put("orderStatus", "已退款");
refundRow.put("payTime", refund.get("refundTime"));
String exportMonth = date.length() >= 7 ? date.substring(0, 7) : date;
String payMonth = getPayMonth(row);
BigDecimal dayAmount = toBigDecimal(row.get("dayAmount"));
if (exportMonth.equals(payMonth)) {
refundRow.put("fee", toBigDecimal(row.get("fee")).negate());
refundRow.put("alreadyDay", 0);
refundRow.put("currentDay", 0);
refundRow.put("alreadyTanxiao", BigDecimal.ZERO);
refundRow.put("currentTanxiao", BigDecimal.ZERO);
refundRow.put("surplusTanxiao", BigDecimal.ZERO);
} else if (payMonth.compareTo(exportMonth) < 0) {
int alreadyDay = calcAlreadyDaysToPrevMonthEnd(row, date);
BigDecimal alreadyTanxiao = dayAmount.multiply(new BigDecimal(alreadyDay)).setScale(2, RoundingMode.HALF_UP);
refundRow.put("fee", toBigDecimal(row.get("fee")).negate());
refundRow.put("alreadyDay", alreadyDay);
refundRow.put("currentDay", 0);
refundRow.put("alreadyTanxiao", BigDecimal.ZERO);
refundRow.put("currentTanxiao", alreadyTanxiao.negate());
refundRow.put("surplusTanxiao", BigDecimal.ZERO);
} else {
refundRow.put("fee", toBigDecimal(row.get("fee")).negate());
refundRow.put("currentDay", 0);
refundRow.put("currentTanxiao", toBigDecimal(row.get("alreadyTanxiao")).negate());
refundRow.put("surplusTanxiao", BigDecimal.ZERO);
}
return refundRow;
}
private String getPayMonth(Map<String, Object> row) {
Object payTime = row.get("payTime");
if (payTime != null && !payTime.toString().isEmpty()) {
return payTime.toString().substring(0, 7);
}
Object startTime = row.get("startTime");
if (startTime != null && !startTime.toString().isEmpty()) {
return startTime.toString().substring(0, 7);
}
return "";
}
private int calcAlreadyDaysToPrevMonthEnd(Map<String, Object> row, String date) {
Object payTime = row.get("payTime");
String payDateStr = payTime != null && !payTime.toString().isEmpty()
? payTime.toString()
: (row.get("startTime") != null ? row.get("startTime").toString() : "");
if (payDateStr.length() < 10) {
return 0;
}
LocalDate payDate = LocalDate.parse(payDateStr.substring(0, 10));
String exportMonth = date.length() >= 7 ? date.substring(0, 7) : date;
LocalDate prevMonthEnd = LocalDate.parse(exportMonth + "-01").minusDays(1);
if (payDate.isAfter(prevMonthEnd)) {
return 0;
}
return (int) ChronoUnit.DAYS.between(payDate, prevMonthEnd) + 1;
}
private BigDecimal toBigDecimal(Object value) {
if (value == null) {
return BigDecimal.ZERO;
}
if (value instanceof BigDecimal) {
return (BigDecimal) value;
}
return new BigDecimal(value.toString());
}
private int toInt(Object value) {
if (value == null) {
return 0;
}
if (value instanceof Number) {
return ((Number) value).intValue();
}
return Integer.parseInt(value.toString());
}
@Override