课程报表去除课书一起买的订单,书的金额
This commit is contained in:
@@ -595,20 +595,14 @@ public class StatisticsController {
|
||||
@RequestMapping("/courseStatistics")
|
||||
public R courseStatistics(@RequestBody Map<String,Object> params) throws ParseException {
|
||||
String date = params.get("year")+"-"+params.get("month");
|
||||
//收入
|
||||
List<Map<String,Object>> incomes = ordersService.listMaps(new MPJLambdaWrapper<Orders>()
|
||||
//所有课程订单
|
||||
List<Map<String,Object>> courseOrders = ordersService.listMaps(new MPJLambdaWrapper<Orders>()
|
||||
.leftJoin(PaymentToOrder.class,t->t.eq(PaymentToOrder::getOrderId,Orders::getId).eq(PaymentToOrder::getState,0))
|
||||
.leftJoin(Payment.class,t->t.eq(Payment::getId,PaymentToOrder::getPaymentId).eq(Payment::getState,0))
|
||||
.disableSubLogicDel()
|
||||
.eq(Orders::getUseFlag,1).eq(Orders::getType,2)
|
||||
.apply("DATE_FORMAT(t.order_time, '%Y-%m') = '"+date+"'")
|
||||
.select("IF(t.pay_type=1,'天医币',IF(t2.type=0,'微信',IF(t2.type=1,'支付宝','银行'))) type,SUM(t.fee) fee")
|
||||
.groupBy(Payment::getType));
|
||||
//所有课程订单
|
||||
List<Map<String,Object>> courseOrders = ordersService.listMaps(new MPJLambdaWrapper<Orders>()
|
||||
.eq(Orders::getUseFlag,1).eq(Orders::getType,2)
|
||||
.select("DATE_FORMAT(order_time, '%Y-%m-%d %H:%i:%s') orderTime,if(source=0,'一路健康',if(source=1,'吴门医述','管理员')) source,order_old_id orderOldId," +
|
||||
"tel,order_sn,t.tel,t.fee realMoney")
|
||||
"IF(t.pay_type=1,'天医币',IF(t2.type=0,'微信',IF(t2.type=1,'支付宝','银行'))) type,tel,order_sn,t.tel,t.fee realMoney")
|
||||
.orderByAsc(Orders::getOrderTime));
|
||||
//一路健康订单课程
|
||||
List<String> taihuOrderIds = courseOrders.stream().filter(o -> o.get("source").equals("一路健康"))
|
||||
@@ -726,8 +720,26 @@ public class StatisticsController {
|
||||
result.add(courseOrder);
|
||||
}
|
||||
}
|
||||
//收入
|
||||
List<Map<String,Object>> incomes = new ArrayList<>();
|
||||
BigDecimal wxIncomes = BigDecimal.ZERO;
|
||||
BigDecimal zfbIncomes = BigDecimal.ZERO;
|
||||
BigDecimal bankIncomes = BigDecimal.ZERO;
|
||||
BigDecimal pointIncomes = BigDecimal.ZERO;
|
||||
for (Map<String,Object> map:result) {
|
||||
BigDecimal fee = (BigDecimal) map.get("fee");
|
||||
//去除课书一起买的订单,书的金额
|
||||
if (map.get("orderTime").toString().contains(date)){
|
||||
if ("微信".equals(map.get("type").toString())){
|
||||
wxIncomes = wxIncomes.add(fee);
|
||||
}else if ("支付宝".equals(map.get("type").toString())){
|
||||
zfbIncomes = zfbIncomes.add(fee);
|
||||
}else if ("银行".equals(map.get("type").toString())){
|
||||
bankIncomes = bankIncomes.add(fee);
|
||||
}else if ("天医币".equals(map.get("type").toString())){
|
||||
pointIncomes = pointIncomes.add(fee);
|
||||
}
|
||||
}
|
||||
String startTime = (String) map.get("startTime");
|
||||
String endTime = (String) map.get("endTime");
|
||||
if (startTime==null){
|
||||
@@ -777,6 +789,23 @@ public class StatisticsController {
|
||||
notyet = notyet.add(fee.subtract(now).subtract(dayAmount.multiply(new BigDecimal(alreadyDays))));
|
||||
}
|
||||
}
|
||||
//去除课书一起买的订单,书的金额
|
||||
Map<String,Object> wxMap = new HashMap<>();
|
||||
wxMap.put("type","微信");
|
||||
wxMap.put("fee",wxIncomes);
|
||||
incomes.add(wxMap);
|
||||
Map<String,Object> zfbMap = new HashMap<>();
|
||||
zfbMap.put("type","支付宝");
|
||||
zfbMap.put("fee",zfbIncomes);
|
||||
incomes.add(zfbMap);
|
||||
Map<String,Object> bankMap = new HashMap<>();
|
||||
bankMap.put("type","银行");
|
||||
bankMap.put("fee",bankIncomes);
|
||||
incomes.add(bankMap);
|
||||
Map<String,Object> pointMap = new HashMap<>();
|
||||
pointMap.put("type","天医币");
|
||||
pointMap.put("fee",pointIncomes);
|
||||
incomes.add(pointMap);
|
||||
return R.ok().putData("incomes",incomes).putData("already",already).putData("now",nowTotal).putData("notyet",notyet);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user