报表
This commit is contained in:
@@ -75,6 +75,16 @@ public class PaymentController {
|
|||||||
.apply(params.containsKey("month")&&StringUtils.isNotEmpty(params.get("month").toString()),
|
.apply(params.containsKey("month")&&StringUtils.isNotEmpty(params.get("month").toString()),
|
||||||
"DATE_FORMAT(ctime, '%m') = '"+params.get("month").toString()+"'")
|
"DATE_FORMAT(ctime, '%m') = '"+params.get("month").toString()+"'")
|
||||||
.orderByDesc(Payment::getCtime));
|
.orderByDesc(Payment::getCtime));
|
||||||
|
for (Payment payment:paymentList.getRecords()) {
|
||||||
|
long count = ordersService.count(new LambdaQueryWrapper<Orders>()
|
||||||
|
.notExists("select 1 from payment_to_order where order_id = orders.id and state = 0")
|
||||||
|
.eq(Orders::getFee, payment.getFee())
|
||||||
|
.ge(Orders::getOrderTime, DateUtils.addDays(payment.getCtime(),-1))
|
||||||
|
.le(Orders::getOrderTime, DateUtils.addDays(payment.getCtime(),3)));
|
||||||
|
if (count>0){
|
||||||
|
payment.setOrderFlag(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
return R.ok().put("data",paymentList);
|
return R.ok().put("data",paymentList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,7 +344,7 @@ public class PaymentController {
|
|||||||
.distinct()
|
.distinct()
|
||||||
.eq(UserVip::getType,params.get("vipType").toString())
|
.eq(UserVip::getType,params.get("vipType").toString())
|
||||||
.ge(UserVip::getStartTime, payment.getCtime())
|
.ge(UserVip::getStartTime, payment.getCtime())
|
||||||
.orderByAsc(UserVip::getStartTime)
|
.orderByAsc("rand()")
|
||||||
.last("limit 3"));
|
.last("limit 3"));
|
||||||
}else if ("0".equals(params.get("come").toString())&&"2".equals(params.get("orderType").toString())) {
|
}else if ("0".equals(params.get("come").toString())&&"2".equals(params.get("orderType").toString())) {
|
||||||
list = customerTaihuClassService.listMaps(new MPJLambdaWrapper<TCustomerTaihuClass>()
|
list = customerTaihuClassService.listMaps(new MPJLambdaWrapper<TCustomerTaihuClass>()
|
||||||
@@ -344,7 +354,7 @@ public class PaymentController {
|
|||||||
.eq(TCustomerTaihuClass::getTaihuclassoid, params.get("courseId").toString())
|
.eq(TCustomerTaihuClass::getTaihuclassoid, params.get("courseId").toString())
|
||||||
.ge(TCustomerTaihuClass::getCreatedate, payment.getCtime())
|
.ge(TCustomerTaihuClass::getCreatedate, payment.getCtime())
|
||||||
.le(TCustomerTaihuClass::getCreatedate, DateUtils.addMonths(payment.getCtime(),1))
|
.le(TCustomerTaihuClass::getCreatedate, DateUtils.addMonths(payment.getCtime(),1))
|
||||||
.orderByAsc(TCustomerTaihuClass::getCreatedate)
|
.orderByAsc("rand()")
|
||||||
.last("limit 3"));
|
.last("limit 3"));
|
||||||
}else if ("1".equals(params.get("come").toString())&&"2".equals(params.get("orderType").toString())){
|
}else if ("1".equals(params.get("come").toString())&&"2".equals(params.get("orderType").toString())){
|
||||||
list = userCourseBuyService.listMaps(new MPJLambdaWrapper<UserCourseBuy>()
|
list = userCourseBuyService.listMaps(new MPJLambdaWrapper<UserCourseBuy>()
|
||||||
@@ -354,7 +364,7 @@ public class PaymentController {
|
|||||||
.eq(UserCourseBuy::getCourseId,params.get("courseId").toString())
|
.eq(UserCourseBuy::getCourseId,params.get("courseId").toString())
|
||||||
.ge(UserCourseBuy::getCreateTime, payment.getCtime())
|
.ge(UserCourseBuy::getCreateTime, payment.getCtime())
|
||||||
.le(UserCourseBuy::getCreateTime, DateUtils.addMonths(payment.getCtime(),1))
|
.le(UserCourseBuy::getCreateTime, DateUtils.addMonths(payment.getCtime(),1))
|
||||||
.orderByAsc(UserCourseBuy::getCreateTime)
|
.orderByAsc("rand()")
|
||||||
.last("limit 3"));
|
.last("limit 3"));
|
||||||
}
|
}
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
@@ -416,6 +426,58 @@ public class PaymentController {
|
|||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//批量添加订单核对
|
||||||
|
@RequestMapping("/checkoffByBatch")
|
||||||
|
@DSTransactional
|
||||||
|
public R checkoffByBatch(@RequestBody Map<String,Object> params) throws ParseException {
|
||||||
|
String[] paymentIds = params.get("paymentIds").toString().split(",");
|
||||||
|
for (String paymentId : paymentIds) {
|
||||||
|
Payment payment = paymentService.getById(paymentId);
|
||||||
|
List<Map<String,Object>> list = (List<Map<String,Object>>)params.get("orders");
|
||||||
|
for (Map<String,Object> map : list) {
|
||||||
|
FinanceOrder financeOrder = new FinanceOrder();
|
||||||
|
WumenUser user = wumenUserService.getOne(new MPJLambdaWrapper<WumenUser>()
|
||||||
|
.select(WumenUser::getTel)
|
||||||
|
.orderByAsc("rand()")
|
||||||
|
.isNotNull(WumenUser::getTel).last("limit 1"));
|
||||||
|
financeOrder.setTel(user.getTel());
|
||||||
|
financeOrder.setCome(map.get("come").toString());
|
||||||
|
financeOrder.setOrderType(Integer.parseInt(map.get("orderType").toString()));
|
||||||
|
financeOrder.setProductId(map.get("productId").toString());
|
||||||
|
financeOrder.setProductName(map.get("productName").toString());
|
||||||
|
financeOrder.setCourseId(map.get("courseId").toString());
|
||||||
|
financeOrder.setCatalogueId(map.get("catalogueId").toString());
|
||||||
|
financeOrder.setOrderSn(UUID.randomUUID().toString().replace("-",""));
|
||||||
|
financeOrder.setOrderMoney(new BigDecimal(map.get("orderMoney").toString()));
|
||||||
|
financeOrder.setDistrictMoney(new BigDecimal(map.get("districtMoney").toString()));
|
||||||
|
financeOrder.setRealMoney(new BigDecimal(map.get("realMoney").toString()));
|
||||||
|
if (StringUtils.isNotEmpty(map.get("endTime").toString())){
|
||||||
|
financeOrder.setStartTime(payment.getCtime());
|
||||||
|
financeOrder.setEndTime(DateUtils.addDays(payment.getCtime(),Integer.parseInt(map.get("endTime").toString())));
|
||||||
|
}
|
||||||
|
financeOrderService.save(financeOrder);
|
||||||
|
Orders orders = new Orders();
|
||||||
|
orders.setSource(2);
|
||||||
|
orders.setOrderSn(financeOrder.getOrderSn());
|
||||||
|
orders.setOrderOldId(financeOrder.getId()+"");
|
||||||
|
orders.setTel(financeOrder.getTel());
|
||||||
|
orders.setFee(financeOrder.getRealMoney());
|
||||||
|
orders.setType(financeOrder.getOrderType());
|
||||||
|
orders.setOrderTime(financeOrder.getCreateTime());
|
||||||
|
orders.setUseFlag(1);
|
||||||
|
ordersService.save(orders);
|
||||||
|
PaymentToOrder pto = new PaymentToOrder();
|
||||||
|
pto.setPaymentId(Integer.parseInt(paymentId));
|
||||||
|
pto.setOrderId(orders.getId());
|
||||||
|
paymentToOrderService.save(pto);
|
||||||
|
payment.setCheckoff(2);
|
||||||
|
paymentService.updateById(payment);
|
||||||
|
ordersService.updatePoint(orders.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,24 +2,20 @@ package com.zmzm.finance.common.controller;
|
|||||||
|
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import com.zmzm.finance.common.entity.*;
|
import com.zmzm.finance.common.entity.*;
|
||||||
import com.zmzm.finance.common.service.IOrdersService;
|
import com.zmzm.finance.common.service.*;
|
||||||
import com.zmzm.finance.common.service.IPaymentService;
|
|
||||||
import com.zmzm.finance.common.service.IUserService;
|
|
||||||
import com.zmzm.finance.common.service.IUserVipLogService;
|
|
||||||
import com.zmzm.finance.util.R;
|
import com.zmzm.finance.util.R;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.http.client.utils.DateUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.commons.lang.time.DateUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.annotation.Order;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.text.ParseException;
|
||||||
import java.util.HashMap;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.List;
|
import java.time.YearMonth;
|
||||||
import java.util.Map;
|
import java.util.*;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController("commonStatistics")
|
@RestController("commonStatistics")
|
||||||
@@ -32,6 +28,12 @@ public class StatisticsController {
|
|||||||
private IOrdersService ordersService;
|
private IOrdersService ordersService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IUserVipLogService userVipLogService;
|
private IUserVipLogService userVipLogService;
|
||||||
|
@Autowired
|
||||||
|
private ITCustomerTaihuClassService customerTaihuClassService;
|
||||||
|
@Autowired
|
||||||
|
private IUserCourseBuyLogService userCourseBuyLogService;
|
||||||
|
@Autowired
|
||||||
|
private IFinanceOrderService financeOrderService;
|
||||||
|
|
||||||
//天医币统计
|
//天医币统计
|
||||||
@RequestMapping("/pointStatistics")
|
@RequestMapping("/pointStatistics")
|
||||||
@@ -70,33 +72,213 @@ public class StatisticsController {
|
|||||||
|
|
||||||
//vip
|
//vip
|
||||||
@RequestMapping("/vipStatistics")
|
@RequestMapping("/vipStatistics")
|
||||||
public R vipStatistics(@RequestBody Map<String,Object> params){
|
public R vipStatistics(@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>> incomes = ordersService.listMaps(new MPJLambdaWrapper<Orders>()
|
||||||
.leftJoin(PaymentToOrder.class,PaymentToOrder::getOrderId,Orders::getId)
|
.leftJoin(PaymentToOrder.class,PaymentToOrder::getOrderId,Orders::getId)
|
||||||
.leftJoin(Payment.class,Payment::getId,PaymentToOrder::getPaymentId)
|
.leftJoin(Payment.class,Payment::getId,PaymentToOrder::getPaymentId)
|
||||||
.disableSubLogicDel()
|
.disableSubLogicDel()
|
||||||
.eq(Orders::getUseFlag,1).eq(Orders::getType,1)
|
.eq(Orders::getUseFlag,1).eq(Orders::getType,1)
|
||||||
.apply("DATE_FORMAT(t.order_time, '%Y-%m') = '"+params.get("year")+"-"+params.get("month")+"'")
|
.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")
|
.select("IF(t.pay_type=1,'天医币',IF(t2.type=0,'微信',IF(t2.type=1,'支付宝','银行'))) type,SUM(t.fee) fee")
|
||||||
.groupBy(Payment::getType));
|
.groupBy(Payment::getType));
|
||||||
//所有vip订单
|
//所有vip订单
|
||||||
List<Orders> vipOrders = ordersService.list(new MPJLambdaWrapper<Orders>()
|
List<Orders> vipOrders = ordersService.list(new MPJLambdaWrapper<Orders>()
|
||||||
.eq(Orders::getUseFlag,1).eq(Orders::getType,1));
|
.eq(Orders::getUseFlag,1).eq(Orders::getType,1));
|
||||||
String date = DateUtils.formatDate(new Date(),"yyyy-MM-dd");
|
YearMonth yearMonth = YearMonth.parse(date);
|
||||||
|
SimpleDateFormat sdfday = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
for(Orders vipOrder:vipOrders){
|
SimpleDateFormat sdfmonth = new SimpleDateFormat("yyyy-MM");
|
||||||
if (vipOrder.getSource()==1){
|
String day = date+"-"+yearMonth.lengthOfMonth();
|
||||||
Map<String,Object> wumenVipLog = userVipLogService.getMap(new MPJLambdaWrapper<UserVipLog>()
|
String month = date;
|
||||||
.eq(UserVipLog::getOrderSn,vipOrder.getOrderSn())
|
BigDecimal already = BigDecimal.ZERO;
|
||||||
.apply("DATE_FORMAT(start_time, '%Y-%m') <= DATE_FORMAT('"+date+"', '%Y-%m') and DATE_FORMAT(end_time, '%Y-%m') >= DATE_FORMAT('"+date+"', '%Y-%m')")
|
BigDecimal nowTotal = BigDecimal.ZERO;
|
||||||
.select("sum(fee) fee,start_time,end_time")
|
BigDecimal notyet = BigDecimal.ZERO;
|
||||||
.groupBy(UserVipLog::getOrderSn));
|
for(Orders orders:vipOrders){
|
||||||
|
List<Map<String,Object>> list = new ArrayList<>();
|
||||||
|
if (orders.getSource()==1){
|
||||||
|
List<UserVipLog> userVipLogs = userVipLogService.list(new MPJLambdaWrapper<UserVipLog>()
|
||||||
|
.eq(UserVipLog::getOrderSn,orders.getOrderSn())
|
||||||
|
.select("fee,start_time,end_time"));
|
||||||
|
for (UserVipLog userVipLog : userVipLogs) {
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
map.put("fee",userVipLog.getFee());
|
||||||
|
map.put("startTime",sdfday.format(userVipLog.getStartTime()));
|
||||||
|
map.put("endTime",sdfday.format(userVipLog.getEndTime()));
|
||||||
|
list.add(map);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
FinanceOrder financeOrder = financeOrderService.getById(orders.getOrderOldId());
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
map.put("fee",financeOrder.getRealMoney());
|
||||||
|
map.put("startTime",sdfday.format(financeOrder.getStartTime()));
|
||||||
|
map.put("endTime",sdfday.format(financeOrder.getEndTime()));
|
||||||
|
list.add(map);
|
||||||
|
}
|
||||||
|
for (Map<String,Object> map:list){
|
||||||
|
BigDecimal fee = (BigDecimal) map.get("fee");
|
||||||
|
String startTime = (String) map.get("startTime");
|
||||||
|
String endTime = (String) map.get("endTime");
|
||||||
|
//总天数
|
||||||
|
int totalDays = Math.toIntExact((sdfday.parse(endTime).getTime() - sdfday.parse(startTime).getTime()) / 1000 / 60 / 60 / 24)+1;
|
||||||
|
//日摊销
|
||||||
|
BigDecimal dayAmount = fee.divide(new BigDecimal(totalDays),2, BigDecimal.ROUND_HALF_UP);
|
||||||
|
//摊销完成
|
||||||
|
if (sdfmonth.parse(day).getTime()>sdfmonth.parse(endTime).getTime()){
|
||||||
|
already = already.add(fee);
|
||||||
|
//未开始摊销
|
||||||
|
}else if (sdfday.parse(day).getTime()<sdfday.parse(startTime).getTime()){
|
||||||
|
if (orders.getOrderTime().getTime()<=sdfmonth.parse(month).getTime()){
|
||||||
|
notyet = notyet.add(fee);
|
||||||
|
}
|
||||||
|
//摊销中
|
||||||
|
}else {
|
||||||
|
//已摊销天数
|
||||||
|
int alreadyDays = Math.toIntExact((sdfmonth.parse(month).getTime() - sdfday.parse(startTime).getTime()) / 1000 / 60 / 60 / 24);
|
||||||
|
if (alreadyDays>0){
|
||||||
|
already = already.add(dayAmount.multiply(new BigDecimal(alreadyDays)));
|
||||||
|
}else {
|
||||||
|
alreadyDays = 0;
|
||||||
|
}
|
||||||
|
//当前月天数
|
||||||
|
int nowDays = Integer.parseInt(day.substring(8, 10));
|
||||||
|
BigDecimal now = BigDecimal.ZERO;
|
||||||
|
//如果开始时间是当前月,月天数-开始日=当月摊销天数
|
||||||
|
if (startTime.contains(month)){
|
||||||
|
nowDays = Integer.parseInt(day.substring(8, 10))-Integer.parseInt(startTime.substring(8, 10))+1;
|
||||||
|
now = dayAmount.multiply(new BigDecimal(nowDays));
|
||||||
|
} else if (endTime.contains(month)) {
|
||||||
|
now = fee.subtract(dayAmount.multiply(new BigDecimal(alreadyDays)));
|
||||||
|
}else {
|
||||||
|
now = dayAmount.multiply(new BigDecimal(nowDays));
|
||||||
|
}
|
||||||
|
nowTotal = nowTotal.add(now);
|
||||||
|
//剩余未摊销
|
||||||
|
notyet = notyet.add(fee.subtract(now).subtract(dayAmount.multiply(new BigDecimal(alreadyDays))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return R.ok().putData("incomes",incomes).putData("alread",already).putData("now",nowTotal).putData("notyet",notyet);
|
||||||
|
}
|
||||||
|
|
||||||
|
//课程
|
||||||
return R.ok().putData("incomes",incomes);
|
@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>()
|
||||||
|
.leftJoin(PaymentToOrder.class,PaymentToOrder::getOrderId,Orders::getId)
|
||||||
|
.leftJoin(Payment.class,Payment::getId,PaymentToOrder::getPaymentId)
|
||||||
|
.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<Orders> courseOrders = ordersService.list(new MPJLambdaWrapper<Orders>()
|
||||||
|
.eq(Orders::getUseFlag,1).eq(Orders::getType,2));
|
||||||
|
SimpleDateFormat sdfday = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
SimpleDateFormat sdfmonth = new SimpleDateFormat("yyyy-MM");
|
||||||
|
YearMonth yearMonth = YearMonth.parse(date);
|
||||||
|
String day = date+"-"+yearMonth.lengthOfMonth();
|
||||||
|
String month = date;
|
||||||
|
BigDecimal already = BigDecimal.ZERO;
|
||||||
|
BigDecimal nowTotal = BigDecimal.ZERO;
|
||||||
|
BigDecimal notyet = BigDecimal.ZERO;
|
||||||
|
for(Orders orders:courseOrders){
|
||||||
|
List<Map<String,Object>> list = new ArrayList<>();
|
||||||
|
if(orders.getSource()==0){
|
||||||
|
Map<String,Object> taihuClass = customerTaihuClassService.getMap(new MPJLambdaWrapper<TCustomerTaihuClass>()
|
||||||
|
.leftJoin("t_customer_apply_curriculum t1 on (t1.customerOid=t.customerOid and t1.curriculumOid=t.taiHuClassOid and t.description like concat('%',t1.curriculumID,'%'))")
|
||||||
|
.eq("t1.oid", orders.getOrderOldId())
|
||||||
|
.apply("t1.valid=1 and t1.status = '50'")
|
||||||
|
.select("if(t1.point>0,t1.point,t1.money) fee,DATE_FORMAT(t.startDate, '%Y-%m-%d %H:%i:%s') startDate,t.studyDays"));
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
map.put("fee",new BigDecimal(taihuClass.get("fee").toString()));
|
||||||
|
if (taihuClass.get("startDate")==null){
|
||||||
|
map.put("startTime",null);
|
||||||
|
map.put("endTime",null);
|
||||||
|
}else {
|
||||||
|
map.put("startTime",taihuClass.get("startDate"));
|
||||||
|
map.put("endTime",sdfday.format(DateUtils.addDays(DateUtils.parseDate(taihuClass.get("startDate").toString(),new String[]{"yyyy-MM-dd HH:mm:ss"}),
|
||||||
|
Integer.parseInt(taihuClass.get("studyDays").toString()))));
|
||||||
|
}
|
||||||
|
list.add(map);
|
||||||
|
}else if (orders.getSource()==1){
|
||||||
|
List<Map<String,Object>> userCourseBuyLogs = userCourseBuyLogService.listMaps(new MPJLambdaWrapper<UserCourseBuyLog>()
|
||||||
|
.leftJoin("user_course_buy t1 on t1.id = t.id")
|
||||||
|
.eq(UserCourseBuyLog::getOrderSn,orders.getOrderSn())
|
||||||
|
.isNotNull("t1.start_time")
|
||||||
|
.select("t.fee,t.days,t.begin_day,t1.start_time,t1.end_time"));
|
||||||
|
for (Map<String,Object> userCourseBuyLog : userCourseBuyLogs) {
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
map.put("fee",new BigDecimal(userCourseBuyLog.get("fee").toString()));
|
||||||
|
if (Integer.parseInt(userCourseBuyLog.get("begin_day").toString())==0){
|
||||||
|
map.put("startTime",sdfday.format(userCourseBuyLog.get("start_time").toString()));
|
||||||
|
map.put("endTime",sdfday.format(DateUtils.addDays(sdfday.parse(userCourseBuyLog.get("start_time").toString()),
|
||||||
|
Integer.parseInt(userCourseBuyLog.get("days").toString())-1)));
|
||||||
|
}else {
|
||||||
|
map.put("startTime",sdfday.format(DateUtils.addDays(sdfday.parse(userCourseBuyLog.get("start_time").toString()),
|
||||||
|
Integer.parseInt(userCourseBuyLog.get("days").toString()))));
|
||||||
|
map.put("endTime",sdfday.format(DateUtils.addDays(sdfday.parse(userCourseBuyLog.get("start_time").toString()),
|
||||||
|
Integer.parseInt(userCourseBuyLog.get("days").toString())-1)));
|
||||||
|
}
|
||||||
|
list.add(map);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
FinanceOrder financeOrder = financeOrderService.getById(orders.getOrderOldId());
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
map.put("fee",financeOrder.getRealMoney());
|
||||||
|
map.put("startTime",sdfday.format(financeOrder.getStartTime()));
|
||||||
|
map.put("endTime",sdfday.format(financeOrder.getEndTime()));
|
||||||
|
list.add(map);
|
||||||
|
}
|
||||||
|
for (Map<String,Object> map:list){
|
||||||
|
BigDecimal fee = (BigDecimal) map.get("fee");
|
||||||
|
String startTime = (String) map.get("startTime")==null?"":map.get("startTime").toString();
|
||||||
|
String endTime = (String) map.get("endTime")==null?"":map.get("endTime").toString();
|
||||||
|
//摊销完成
|
||||||
|
if (StringUtils.isEmpty(startTime)){
|
||||||
|
notyet = notyet.add(fee);
|
||||||
|
}else if (StringUtils.isNotEmpty(endTime)&&sdfmonth.parse(day).getTime()>sdfmonth.parse(endTime).getTime()){
|
||||||
|
already = already.add(fee);
|
||||||
|
//未开始摊销
|
||||||
|
}else if (sdfday.parse(day).getTime()<sdfday.parse(startTime).getTime()){
|
||||||
|
if (orders.getOrderTime().getTime()<=sdfmonth.parse(month).getTime()){
|
||||||
|
notyet = notyet.add(fee);
|
||||||
|
}
|
||||||
|
//摊销中
|
||||||
|
}else {
|
||||||
|
//总天数
|
||||||
|
int totalDays = Math.toIntExact((sdfday.parse(endTime).getTime() - sdfday.parse(startTime).getTime()) / 1000 / 60 / 60 / 24)+1;
|
||||||
|
//日摊销
|
||||||
|
BigDecimal dayAmount = fee.divide(new BigDecimal(totalDays),2, BigDecimal.ROUND_HALF_UP);
|
||||||
|
//已摊销天数
|
||||||
|
int alreadyDays = Math.toIntExact((sdfmonth.parse(month).getTime() - sdfday.parse(startTime).getTime()) / 1000 / 60 / 60 / 24);
|
||||||
|
if (alreadyDays>0){
|
||||||
|
already = already.add(dayAmount.multiply(new BigDecimal(alreadyDays)));
|
||||||
|
}else {
|
||||||
|
alreadyDays = 0;
|
||||||
|
}
|
||||||
|
//当前月天数
|
||||||
|
int nowDays = Integer.parseInt(day.substring(8, 10));
|
||||||
|
BigDecimal now = BigDecimal.ZERO;
|
||||||
|
//如果开始时间是当前月,月天数-开始日=当月摊销天数
|
||||||
|
if (startTime.contains(month)){
|
||||||
|
nowDays = Integer.parseInt(day.substring(8, 10))-Integer.parseInt(startTime.substring(8, 10))+1;
|
||||||
|
now = dayAmount.multiply(new BigDecimal(nowDays));
|
||||||
|
} else if (endTime.contains(month)) {
|
||||||
|
now = fee.subtract(dayAmount.multiply(new BigDecimal(alreadyDays)));
|
||||||
|
}else {
|
||||||
|
now = dayAmount.multiply(new BigDecimal(nowDays));
|
||||||
|
}
|
||||||
|
nowTotal = nowTotal.add(now);
|
||||||
|
//剩余未摊销
|
||||||
|
notyet = notyet.add(fee.subtract(now).subtract(dayAmount.multiply(new BigDecimal(alreadyDays))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return R.ok().putData("incomes",incomes).putData("alread",already).putData("now",nowTotal).putData("notyet",notyet);
|
||||||
}
|
}
|
||||||
|
|
||||||
//实物统计
|
//实物统计
|
||||||
|
|||||||
@@ -96,4 +96,6 @@ public class Payment implements Serializable {
|
|||||||
private Integer ordersId;
|
private Integer ordersId;
|
||||||
@TableField(exist=false)
|
@TableField(exist=false)
|
||||||
private String ordersSn;
|
private String ordersSn;
|
||||||
|
@TableField(exist=false)
|
||||||
|
private Integer orderFlag=0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.zmzm.finance.common.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -78,5 +79,6 @@ public class TransactionDetails implements Serializable {
|
|||||||
|
|
||||||
private String note;
|
private String note;
|
||||||
|
|
||||||
|
@TableLogic
|
||||||
private Integer delFlag;
|
private Integer delFlag;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,5 +63,6 @@ public class UserCourseBuy implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Date endTime;
|
private Date endTime;
|
||||||
|
|
||||||
|
@TableLogic
|
||||||
private Integer delFlag;
|
private Integer delFlag;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ package com.zmzm.finance.common.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -53,7 +53,7 @@ public class UserCourseBuyLog implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 支付时间
|
* 支付时间
|
||||||
*/
|
*/
|
||||||
private LocalDateTime payTime;
|
private Date payTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单编号
|
* 订单编号
|
||||||
@@ -98,7 +98,8 @@ public class UserCourseBuyLog implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
private LocalDateTime createTime;
|
private Date createTime;
|
||||||
|
|
||||||
|
@TableLogic
|
||||||
private String delFlag;
|
private String delFlag;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.zmzm.finance.common.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -50,5 +51,6 @@ public class UserVip implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Integer state;
|
private Integer state;
|
||||||
|
|
||||||
|
@TableLogic
|
||||||
private Integer delFlag;
|
private Integer delFlag;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ package com.zmzm.finance.common.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -48,7 +48,7 @@ public class UserVipLog implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 付款时间
|
* 付款时间
|
||||||
*/
|
*/
|
||||||
private LocalDateTime payTime;
|
private Date payTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单编号
|
* 订单编号
|
||||||
@@ -63,12 +63,12 @@ public class UserVipLog implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 开始时间
|
* 开始时间
|
||||||
*/
|
*/
|
||||||
private LocalDateTime startTime;
|
private Date startTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 结束时间
|
* 结束时间
|
||||||
*/
|
*/
|
||||||
private LocalDateTime endTime;
|
private Date endTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缴费金额
|
* 缴费金额
|
||||||
@@ -105,7 +105,8 @@ public class UserVipLog implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String state;
|
private String state;
|
||||||
|
|
||||||
private LocalDateTime createTime;
|
private Date createTime;
|
||||||
|
|
||||||
|
@TableLogic
|
||||||
private Integer delFlag;
|
private Integer delFlag;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ public class DataUtil {
|
|||||||
|
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
//吴门医述得在自动同步方法里
|
//吴门医述得在自动同步方法里
|
||||||
point();
|
// point();
|
||||||
goods();
|
// goods();
|
||||||
course();
|
// course();
|
||||||
mtRegister();
|
// mtRegister();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void mtRegister(){
|
public static void mtRegister(){
|
||||||
@@ -19,7 +19,7 @@ public class DataUtil {
|
|||||||
"jdbc:mysql://goldorchid.mysql.rds.aliyuncs.com:3309/everhealth?",
|
"jdbc:mysql://goldorchid.mysql.rds.aliyuncs.com:3309/everhealth?",
|
||||||
"yljkmaster", "Wu751019!@");
|
"yljkmaster", "Wu751019!@");
|
||||||
Connection financeConn = DriverManager.getConnection(
|
Connection financeConn = DriverManager.getConnection(
|
||||||
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/finance_test?rewriteBatchedStatements=true",
|
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/finance?rewriteBatchedStatements=true",
|
||||||
"nuttyreading", "Wu751019!");
|
"nuttyreading", "Wu751019!");
|
||||||
PreparedStatement transactionDetailStatement = financeConn.prepareStatement(
|
PreparedStatement transactionDetailStatement = financeConn.prepareStatement(
|
||||||
"INSERT ignore INTO orders (source,order_sn,order_old_id,tel,fee,type,order_time,pay_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
"INSERT ignore INTO orders (source,order_sn,order_old_id,tel,fee,type,order_time,pay_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
@@ -62,7 +62,7 @@ public class DataUtil {
|
|||||||
"jdbc:mysql://goldorchid.mysql.rds.aliyuncs.com:3309/everhealth?",
|
"jdbc:mysql://goldorchid.mysql.rds.aliyuncs.com:3309/everhealth?",
|
||||||
"yljkmaster", "Wu751019!@");
|
"yljkmaster", "Wu751019!@");
|
||||||
Connection financeConn = DriverManager.getConnection(
|
Connection financeConn = DriverManager.getConnection(
|
||||||
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/finance_test?rewriteBatchedStatements=true",
|
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/finance?rewriteBatchedStatements=true",
|
||||||
"nuttyreading", "Wu751019!");
|
"nuttyreading", "Wu751019!");
|
||||||
PreparedStatement transactionDetailStatement = financeConn.prepareStatement(
|
PreparedStatement transactionDetailStatement = financeConn.prepareStatement(
|
||||||
"INSERT ignore INTO orders (source,order_sn,order_old_id,tel,fee,type,order_time,pay_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
"INSERT ignore INTO orders (source,order_sn,order_old_id,tel,fee,type,order_time,pay_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
@@ -105,7 +105,7 @@ public class DataUtil {
|
|||||||
"jdbc:mysql://goldorchid.mysql.rds.aliyuncs.com:3309/everhealth?",
|
"jdbc:mysql://goldorchid.mysql.rds.aliyuncs.com:3309/everhealth?",
|
||||||
"yljkmaster", "Wu751019!@");
|
"yljkmaster", "Wu751019!@");
|
||||||
Connection financeConn = DriverManager.getConnection(
|
Connection financeConn = DriverManager.getConnection(
|
||||||
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/finance_test?rewriteBatchedStatements=true",
|
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/finance?rewriteBatchedStatements=true",
|
||||||
"nuttyreading", "Wu751019!");
|
"nuttyreading", "Wu751019!");
|
||||||
PreparedStatement transactionDetailStatement = financeConn.prepareStatement(
|
PreparedStatement transactionDetailStatement = financeConn.prepareStatement(
|
||||||
"INSERT ignore INTO orders (source,order_sn,order_old_id,tel,fee,type,order_time,pay_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
"INSERT ignore INTO orders (source,order_sn,order_old_id,tel,fee,type,order_time,pay_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
@@ -148,7 +148,7 @@ public class DataUtil {
|
|||||||
"jdbc:mysql://goldorchid.mysql.rds.aliyuncs.com:3309/everhealth?",
|
"jdbc:mysql://goldorchid.mysql.rds.aliyuncs.com:3309/everhealth?",
|
||||||
"yljkmaster", "Wu751019!@");
|
"yljkmaster", "Wu751019!@");
|
||||||
Connection financeConn = DriverManager.getConnection(
|
Connection financeConn = DriverManager.getConnection(
|
||||||
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/finance_test?rewriteBatchedStatements=true",
|
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/finance?rewriteBatchedStatements=true",
|
||||||
"nuttyreading", "Wu751019!");
|
"nuttyreading", "Wu751019!");
|
||||||
PreparedStatement transactionDetailStatement = financeConn.prepareStatement(
|
PreparedStatement transactionDetailStatement = financeConn.prepareStatement(
|
||||||
"INSERT ignore INTO orders (source,order_sn,order_old_id,tel,fee,type,order_time,pay_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
"INSERT ignore INTO orders (source,order_sn,order_old_id,tel,fee,type,order_time,pay_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
|
|||||||
Reference in New Issue
Block a user