Compare commits
9 Commits
156862a0c5
...
wyn
| Author | SHA1 | Date | |
|---|---|---|---|
| e1ff7d4b9e | |||
| a8507deb2e | |||
| 76f96ae804 | |||
| dbcf3151bd | |||
| 7bddd3d012 | |||
| eef9e7ff69 | |||
| 60e507b750 | |||
| 54069c6810 | |||
| 7dc1241064 |
@@ -1222,6 +1222,26 @@ public class BuyOrderController {
|
|||||||
return buyOrderService.delivery(expressCompanyCode, buyOrderProductId);
|
return buyOrderService.delivery(expressCompanyCode, buyOrderProductId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量订单发货(仅支持单商品且数量为1的订单,快递公司固定顺丰 SF)
|
||||||
|
* 异步执行,立即返回 taskId,通过 getBatchDeliveryProgress 查询进度
|
||||||
|
*
|
||||||
|
* @param orderIds 订单 ID 列表
|
||||||
|
* @return R,包含 taskId;存在不符合条件的订单时 msg 为逗号拼接的订单号
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/batchDelivery", method = RequestMethod.POST)
|
||||||
|
public R batchDelivery(@RequestBody List<Integer> orderIds) throws Exception {
|
||||||
|
return buyOrderService.batchDelivery("SF", orderIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询批量发货任务进度
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/getBatchDeliveryProgress", method = RequestMethod.GET)
|
||||||
|
public R getBatchDeliveryProgress(@RequestParam("taskId") Integer taskId) {
|
||||||
|
return buyOrderService.getBatchDeliveryProgress(taskId);
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping("/mytest")
|
@RequestMapping("/mytest")
|
||||||
public R mytest() throws IOException {
|
public R mytest() throws IOException {
|
||||||
String mytest = buyOrderService.mytest();
|
String mytest = buyOrderService.mytest();
|
||||||
|
|||||||
@@ -55,6 +55,19 @@ public interface BuyOrderService extends IService<BuyOrder> {
|
|||||||
*/
|
*/
|
||||||
R delivery(String expressCompanyCode, List<Integer> buyOrderDetailId);
|
R delivery(String expressCompanyCode, List<Integer> buyOrderDetailId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量订单发货(仅支持单商品且数量为1的订单)
|
||||||
|
*
|
||||||
|
* @param expressCompanyCode 快递公司代码
|
||||||
|
* @param orderIds 订单 ID 列表
|
||||||
|
*/
|
||||||
|
R batchDelivery(String expressCompanyCode, List<Integer> orderIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询批量发货任务进度
|
||||||
|
*/
|
||||||
|
R getBatchDeliveryProgress(Integer taskId);
|
||||||
|
|
||||||
Page<BuyOrder> orderList(BuyOrderListRequestVo requestVo, Boolean isHT);
|
Page<BuyOrder> orderList(BuyOrderListRequestVo requestVo, Boolean isHT);
|
||||||
|
|
||||||
Page<BuyOrder> getUserOrderList(UserOrderDto userOrderDto);
|
Page<BuyOrder> getUserOrderList(UserOrderDto userOrderDto);
|
||||||
@@ -69,6 +82,8 @@ public interface BuyOrderService extends IService<BuyOrder> {
|
|||||||
|
|
||||||
List<ShopProductCourseEntity> getOrderCourse(String orderSn);
|
List<ShopProductCourseEntity> getOrderCourse(String orderSn);
|
||||||
|
|
||||||
|
void removeCourseToUser(BuyOrder orderEntity);
|
||||||
|
|
||||||
void addCourseToUser(String payType, BuyOrder orderEntity);
|
void addCourseToUser(String payType, BuyOrder orderEntity);
|
||||||
|
|
||||||
boolean checkWlOrder(String orderSn);
|
boolean checkWlOrder(String orderSn);
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
package com.peanut.modules.book.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.peanut.common.utils.R;
|
||||||
|
import com.peanut.modules.book.service.BuyOrderBatchDeliveryAsyncService;
|
||||||
|
import com.peanut.modules.book.service.BuyOrderService;
|
||||||
|
import com.peanut.modules.common.dao.BuyOrderBatchDeliveryItemDao;
|
||||||
|
import com.peanut.modules.common.dao.BuyOrderBatchDeliveryTaskDao;
|
||||||
|
import com.peanut.modules.common.entity.BuyOrderBatchDeliveryItem;
|
||||||
|
import com.peanut.modules.common.entity.BuyOrderBatchDeliveryTask;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class BuyOrderBatchDeliveryAsyncServiceImpl implements BuyOrderBatchDeliveryAsyncService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BuyOrderBatchDeliveryTaskDao batchDeliveryTaskDao;
|
||||||
|
@Autowired
|
||||||
|
private BuyOrderBatchDeliveryItemDao batchDeliveryItemDao;
|
||||||
|
@Lazy
|
||||||
|
@Autowired
|
||||||
|
private BuyOrderService buyOrderService;
|
||||||
|
|
||||||
|
@Async
|
||||||
|
@Override
|
||||||
|
public void executeBatchDelivery(Integer taskId) {
|
||||||
|
BuyOrderBatchDeliveryTask task = batchDeliveryTaskDao.selectById(taskId);
|
||||||
|
if (task == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Date now = new Date();
|
||||||
|
task.setStatus(BuyOrderBatchDeliveryTask.STATUS_RUNNING);
|
||||||
|
task.setUpdateTime(now);
|
||||||
|
batchDeliveryTaskDao.updateById(task);
|
||||||
|
|
||||||
|
List<BuyOrderBatchDeliveryItem> items = batchDeliveryItemDao.selectList(
|
||||||
|
new LambdaQueryWrapper<BuyOrderBatchDeliveryItem>()
|
||||||
|
.eq(BuyOrderBatchDeliveryItem::getTaskId, taskId)
|
||||||
|
.orderByAsc(BuyOrderBatchDeliveryItem::getId));
|
||||||
|
|
||||||
|
int successCount = 0;
|
||||||
|
int failCount = 0;
|
||||||
|
try {
|
||||||
|
for (BuyOrderBatchDeliveryItem item : items) {
|
||||||
|
if (item.getStatus() != BuyOrderBatchDeliveryItem.STATUS_PENDING) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
R result = buyOrderService.delivery(
|
||||||
|
task.getExpressCompanyCode(),
|
||||||
|
Collections.singletonList(item.getBuyOrderProductId()));
|
||||||
|
Date itemTime = new Date();
|
||||||
|
if (Integer.valueOf(0).equals(result.get("code"))) {
|
||||||
|
item.setStatus(BuyOrderBatchDeliveryItem.STATUS_SUCCESS);
|
||||||
|
successCount++;
|
||||||
|
} else {
|
||||||
|
item.setStatus(BuyOrderBatchDeliveryItem.STATUS_FAILED);
|
||||||
|
item.setFailMessage(String.valueOf(result.get("msg")));
|
||||||
|
failCount++;
|
||||||
|
}
|
||||||
|
item.setUpdateTime(itemTime);
|
||||||
|
batchDeliveryItemDao.updateById(item);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("批量发货单条失败 taskId={} orderId={}", taskId, item.getOrderId(), e);
|
||||||
|
item.setStatus(BuyOrderBatchDeliveryItem.STATUS_FAILED);
|
||||||
|
item.setFailMessage(e.getMessage());
|
||||||
|
item.setUpdateTime(new Date());
|
||||||
|
batchDeliveryItemDao.updateById(item);
|
||||||
|
failCount++;
|
||||||
|
}
|
||||||
|
updateTaskProgress(taskId, successCount, failCount);
|
||||||
|
}
|
||||||
|
finishTask(taskId, successCount, failCount, null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("批量发货任务异常 taskId={}", taskId, e);
|
||||||
|
finishTask(taskId, successCount, failCount, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTaskProgress(Integer taskId, int successCount, int failCount) {
|
||||||
|
BuyOrderBatchDeliveryTask task = batchDeliveryTaskDao.selectById(taskId);
|
||||||
|
if (task == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
task.setSuccessCount(successCount);
|
||||||
|
task.setFailCount(failCount);
|
||||||
|
task.setUpdateTime(new Date());
|
||||||
|
batchDeliveryTaskDao.updateById(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void finishTask(Integer taskId, int successCount, int failCount, String failMessage) {
|
||||||
|
BuyOrderBatchDeliveryTask task = batchDeliveryTaskDao.selectById(taskId);
|
||||||
|
if (task == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Date now = new Date();
|
||||||
|
task.setSuccessCount(successCount);
|
||||||
|
task.setFailCount(failCount);
|
||||||
|
task.setUpdateTime(now);
|
||||||
|
task.setFinishTime(now);
|
||||||
|
if (failMessage != null) {
|
||||||
|
task.setStatus(BuyOrderBatchDeliveryTask.STATUS_FAILED);
|
||||||
|
task.setFailMessage(failMessage);
|
||||||
|
} else {
|
||||||
|
task.setStatus(BuyOrderBatchDeliveryTask.STATUS_COMPLETED);
|
||||||
|
}
|
||||||
|
batchDeliveryTaskDao.updateById(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import com.peanut.common.utils.*;
|
import com.peanut.common.utils.*;
|
||||||
import com.peanut.config.Constants;
|
import com.peanut.config.Constants;
|
||||||
|
import com.peanut.modules.book.service.BuyOrderBatchDeliveryAsyncService;
|
||||||
import com.peanut.modules.book.service.BuyOrderService;
|
import com.peanut.modules.book.service.BuyOrderService;
|
||||||
import com.peanut.modules.book.service.CityService;
|
import com.peanut.modules.book.service.CityService;
|
||||||
import com.peanut.modules.book.service.CountyService;
|
import com.peanut.modules.book.service.CountyService;
|
||||||
@@ -118,8 +119,14 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
|||||||
private UserVipDao userVipDao;
|
private UserVipDao userVipDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
private VipBuyConfigDao vipBuyConfigDao;
|
private VipBuyConfigDao vipBuyConfigDao;
|
||||||
|
@Autowired
|
||||||
|
private BuyOrderBatchDeliveryTaskDao batchDeliveryTaskDao;
|
||||||
|
@Autowired
|
||||||
|
private BuyOrderBatchDeliveryItemDao batchDeliveryItemDao;
|
||||||
|
@Autowired
|
||||||
|
private BuyOrderBatchDeliveryAsyncService batchDeliveryAsyncService;
|
||||||
|
|
||||||
// TODO 新版本上线后删除
|
//private static final int BATCH_DELIVERY_MAX_SIZE = 100;
|
||||||
@Override
|
@Override
|
||||||
public PageUtils list(Map<String, Object> params) throws Exception {
|
public PageUtils list(Map<String, Object> params) throws Exception {
|
||||||
|
|
||||||
@@ -437,6 +444,22 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
|||||||
List<Integer> collect = buyOrderProductDao.selectJoinList(BuyOrderProduct.class, buyOrderProductMPJLambdaWrapper).stream().map(BuyOrderProduct::getOrderId).collect(Collectors.toList());
|
List<Integer> collect = buyOrderProductDao.selectJoinList(BuyOrderProduct.class, buyOrderProductMPJLambdaWrapper).stream().map(BuyOrderProduct::getOrderId).collect(Collectors.toList());
|
||||||
wrapper.in(BuyOrder::getOrderId,collect);
|
wrapper.in(BuyOrder::getOrderId,collect);
|
||||||
}
|
}
|
||||||
|
if(requestVo.getShowOne()!=null && requestVo.getShowOne()==1){
|
||||||
|
List<Map<String, Object>> list = buyOrderProductService.listMaps(
|
||||||
|
new QueryWrapper<BuyOrderProduct>()
|
||||||
|
.select("order_id orderId")
|
||||||
|
.groupBy("order_id")
|
||||||
|
.having("COUNT(*) = 1 AND SUM(quantity) = 1")
|
||||||
|
);
|
||||||
|
List<Integer> collect = list.stream()
|
||||||
|
.map(map -> ((Number) map.get("orderId")).intValue())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (collect.size() > 0) {
|
||||||
|
wrapper.in(BuyOrder::getOrderId, collect);
|
||||||
|
} else {
|
||||||
|
wrapper.eq(BuyOrder::getOrderId, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
Page<BuyOrder> buyOrderPage = getBaseMapper().selectPage(new Page<BuyOrder>(requestVo.getPageIndex(), requestVo.getPageSize()), wrapper);
|
Page<BuyOrder> buyOrderPage = getBaseMapper().selectPage(new Page<BuyOrder>(requestVo.getPageIndex(), requestVo.getPageSize()), wrapper);
|
||||||
//丰富订单内容
|
//丰富订单内容
|
||||||
for (BuyOrder b : buyOrderPage.getRecords()){
|
for (BuyOrder b : buyOrderPage.getRecords()){
|
||||||
@@ -487,6 +510,8 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
|||||||
refundableStatus = true;
|
refundableStatus = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}else if("relearn".equals(b.getOrderType()) && paymentDateTime > timestamp-7*24*60*60*1000){
|
||||||
|
refundableStatus = true;
|
||||||
}
|
}
|
||||||
if(b.getOrderStatus().equals(Constants.ORDER_STATUS_REFUND)){
|
if(b.getOrderStatus().equals(Constants.ORDER_STATUS_REFUND)){
|
||||||
BuyOrderRefund refundInfo = buyOrderRefundService.getRefundInfoByOrderId(b.getOrderId());
|
BuyOrderRefund refundInfo = buyOrderRefundService.getRefundInfoByOrderId(b.getOrderId());
|
||||||
@@ -718,6 +743,107 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R batchDelivery(String expressCompanyCode, List<Integer> orderIds) {
|
||||||
|
if (orderIds == null || orderIds.isEmpty()) {
|
||||||
|
return R.error("订单列表不能为空");
|
||||||
|
}
|
||||||
|
// if (orderIds.size() > BATCH_DELIVERY_MAX_SIZE) {
|
||||||
|
// return R.error("单次批量发货最多" + BATCH_DELIVERY_MAX_SIZE + "单");
|
||||||
|
// }
|
||||||
|
List<Integer> distinctOrderIds = orderIds.stream().distinct().collect(Collectors.toList());
|
||||||
|
List<BatchDeliveryOrderItem> validOrders = new ArrayList<>();
|
||||||
|
List<String> invalidOrderSns = new ArrayList<>();
|
||||||
|
for (Integer orderId : distinctOrderIds) {
|
||||||
|
BuyOrder buyOrder = getById(orderId);
|
||||||
|
if (buyOrder == null) {
|
||||||
|
invalidOrderSns.add(String.valueOf(orderId));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<BuyOrderProduct> products = buyOrderProductService.list(
|
||||||
|
new LambdaQueryWrapper<BuyOrderProduct>().eq(BuyOrderProduct::getOrderId, orderId));
|
||||||
|
if (products.size() != 1 || products.get(0).getQuantity() != 1) {
|
||||||
|
invalidOrderSns.add(buyOrder.getOrderSn());
|
||||||
|
} else {
|
||||||
|
BatchDeliveryOrderItem item = new BatchDeliveryOrderItem();
|
||||||
|
item.orderId = orderId;
|
||||||
|
item.orderSn = buyOrder.getOrderSn();
|
||||||
|
item.buyOrderProductId = products.get(0).getId();
|
||||||
|
validOrders.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!invalidOrderSns.isEmpty()) {
|
||||||
|
return R.error(String.join(",", invalidOrderSns));
|
||||||
|
}
|
||||||
|
List<Integer> busyOrderIds = batchDeliveryTaskDao.findBusyOrderIds(distinctOrderIds);
|
||||||
|
if (!busyOrderIds.isEmpty()) {
|
||||||
|
return R.error("以下订单正在批量发货处理中,请勿重复提交:" + busyOrderIds.stream()
|
||||||
|
.map(String::valueOf).collect(Collectors.joining(",")));
|
||||||
|
}
|
||||||
|
|
||||||
|
Date now = new Date();
|
||||||
|
BuyOrderBatchDeliveryTask task = new BuyOrderBatchDeliveryTask();
|
||||||
|
task.setExpressCompanyCode(expressCompanyCode);
|
||||||
|
task.setTotalCount(validOrders.size());
|
||||||
|
task.setSuccessCount(0);
|
||||||
|
task.setFailCount(0);
|
||||||
|
task.setStatus(BuyOrderBatchDeliveryTask.STATUS_PENDING);
|
||||||
|
task.setCreateTime(now);
|
||||||
|
task.setUpdateTime(now);
|
||||||
|
batchDeliveryTaskDao.insert(task);
|
||||||
|
|
||||||
|
for (BatchDeliveryOrderItem orderItem : validOrders) {
|
||||||
|
BuyOrderBatchDeliveryItem item = new BuyOrderBatchDeliveryItem();
|
||||||
|
item.setTaskId(task.getId());
|
||||||
|
item.setOrderId(orderItem.orderId);
|
||||||
|
item.setOrderSn(orderItem.orderSn);
|
||||||
|
item.setBuyOrderProductId(orderItem.buyOrderProductId);
|
||||||
|
item.setStatus(BuyOrderBatchDeliveryItem.STATUS_PENDING);
|
||||||
|
item.setCreateTime(now);
|
||||||
|
item.setUpdateTime(now);
|
||||||
|
batchDeliveryItemDao.insert(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
batchDeliveryAsyncService.executeBatchDelivery(task.getId());
|
||||||
|
return R.ok()
|
||||||
|
.put("taskId", task.getId())
|
||||||
|
.put("totalCount", task.getTotalCount())
|
||||||
|
.put("message", "批量发货任务已提交,请轮询进度");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R getBatchDeliveryProgress(Integer taskId) {
|
||||||
|
if (taskId == null) {
|
||||||
|
return R.error("任务ID不能为空");
|
||||||
|
}
|
||||||
|
BuyOrderBatchDeliveryTask task = batchDeliveryTaskDao.selectById(taskId);
|
||||||
|
if (task == null) {
|
||||||
|
return R.error("任务不存在");
|
||||||
|
}
|
||||||
|
List<BuyOrderBatchDeliveryItem> failedItems = batchDeliveryItemDao.selectList(
|
||||||
|
new LambdaQueryWrapper<BuyOrderBatchDeliveryItem>()
|
||||||
|
.eq(BuyOrderBatchDeliveryItem::getTaskId, taskId)
|
||||||
|
.eq(BuyOrderBatchDeliveryItem::getStatus, BuyOrderBatchDeliveryItem.STATUS_FAILED));
|
||||||
|
int processedCount = task.getSuccessCount() + task.getFailCount();
|
||||||
|
boolean finished = task.getStatus() >= BuyOrderBatchDeliveryTask.STATUS_COMPLETED;
|
||||||
|
return R.ok()
|
||||||
|
.put("taskId", task.getId())
|
||||||
|
.put("status", task.getStatus())
|
||||||
|
.put("totalCount", task.getTotalCount())
|
||||||
|
.put("successCount", task.getSuccessCount())
|
||||||
|
.put("failCount", task.getFailCount())
|
||||||
|
.put("processedCount", processedCount)
|
||||||
|
.put("finished", finished)
|
||||||
|
.put("failMessage", task.getFailMessage())
|
||||||
|
.put("failedItems", failedItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class BatchDeliveryOrderItem {
|
||||||
|
private Integer orderId;
|
||||||
|
private String orderSn;
|
||||||
|
private Integer buyOrderProductId;
|
||||||
|
}
|
||||||
|
|
||||||
public String mytest() throws IOException {
|
public String mytest() throws IOException {
|
||||||
String html = "";
|
String html = "";
|
||||||
File file = new File("D:/1.html");
|
File file = new File("D:/1.html");
|
||||||
@@ -743,15 +869,12 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
|||||||
List<ShopProductCourseEntity> shopProductCourseEntities = this.getBaseMapper().selectJoinList(ShopProductCourseEntity.class, wrapper);
|
List<ShopProductCourseEntity> shopProductCourseEntities = this.getBaseMapper().selectJoinList(ShopProductCourseEntity.class, wrapper);
|
||||||
return shopProductCourseEntities;
|
return shopProductCourseEntities;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void removeCourseToUser(BuyOrder orderEntity){
|
public void removeCourseToUser(BuyOrder orderEntity){
|
||||||
QueryWrapper<UserCourseBuyLog> buyLogQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<UserCourseBuyLog> buyLogQueryWrapper = new QueryWrapper<>();
|
||||||
buyLogQueryWrapper.eq("order_sn",orderEntity.getOrderSn());
|
buyLogQueryWrapper.eq("order_sn",orderEntity.getOrderSn());
|
||||||
log.info("order+sn===="+orderEntity.getOrderSn());
|
|
||||||
List<UserCourseBuyLog> userCourseBuyLogList = userCourseBuyLogDao.selectList(buyLogQueryWrapper);
|
List<UserCourseBuyLog> userCourseBuyLogList = userCourseBuyLogDao.selectList(buyLogQueryWrapper);
|
||||||
log.info("size===="+userCourseBuyLogList.size());
|
|
||||||
for (UserCourseBuyLog userCourseBuyLog:userCourseBuyLogList){
|
for (UserCourseBuyLog userCourseBuyLog:userCourseBuyLogList){
|
||||||
log.info("===delete====="+userCourseBuyLog.getUserCourseBuyId());
|
|
||||||
log.info("===delete2====="+userCourseBuyLog.getId());
|
|
||||||
userCourseBuyDao.realDeleteById(userCourseBuyLog.getUserCourseBuyId());
|
userCourseBuyDao.realDeleteById(userCourseBuyLog.getUserCourseBuyId());
|
||||||
userCourseBuyLogDao.realDeleteById(userCourseBuyLog.getId());
|
userCourseBuyLogDao.realDeleteById(userCourseBuyLog.getId());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,4 +55,9 @@ public class BuyOrderListRequestVo {
|
|||||||
* 数据起始位置
|
* 数据起始位置
|
||||||
*/
|
*/
|
||||||
private Integer index;
|
private Integer index;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过滤预售
|
||||||
|
*/
|
||||||
|
private Integer showOne;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ public class CourseRelearnController {
|
|||||||
String timeId = IdWorker.getTimeId().substring(0, 32);
|
String timeId = IdWorker.getTimeId().substring(0, 32);
|
||||||
buyOrder.setOrderSn(timeId);
|
buyOrder.setOrderSn(timeId);
|
||||||
buyOrder.setUserId(uid);
|
buyOrder.setUserId(uid);
|
||||||
|
buyOrder.setPaymentDate(new Date());
|
||||||
buyOrderService.save(buyOrder);
|
buyOrderService.save(buyOrder);
|
||||||
BigDecimal totalPrice = buyOrder.getRealMoney();
|
BigDecimal totalPrice = buyOrder.getRealMoney();
|
||||||
//虚拟币支付
|
//虚拟币支付
|
||||||
|
|||||||
@@ -56,8 +56,8 @@ public class JfTransactionDetailsController {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public R activityDonateJF(){
|
public R activityDonateJF(){
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
String startTime = "2025-11-08 00:00:00";
|
String startTime = "2026-06-18 00:00:00";
|
||||||
String endTime = "2025-11-13 09:22:00";
|
String endTime = "2026-06-22 10:06:59";
|
||||||
//查询时间段内所有充值的人
|
//查询时间段内所有充值的人
|
||||||
List<TransactionDetailsEntity> list = transactionDetailsService.list(new LambdaQueryWrapper<TransactionDetailsEntity>()
|
List<TransactionDetailsEntity> list = transactionDetailsService.list(new LambdaQueryWrapper<TransactionDetailsEntity>()
|
||||||
.between(TransactionDetailsEntity::getCreateTime,startTime,endTime)
|
.between(TransactionDetailsEntity::getCreateTime,startTime,endTime)
|
||||||
@@ -76,7 +76,7 @@ public class JfTransactionDetailsController {
|
|||||||
//时间段内获得的积分
|
//时间段内获得的积分
|
||||||
Map<String,Object> jftd = jfService.getMap(new MPJLambdaWrapper<JfTransactionDetails>()
|
Map<String,Object> jftd = jfService.getMap(new MPJLambdaWrapper<JfTransactionDetails>()
|
||||||
.eq(JfTransactionDetails::getUserId,transactionDetail.getUserId())
|
.eq(JfTransactionDetails::getUserId,transactionDetail.getUserId())
|
||||||
.like(JfTransactionDetails::getRemark,"双11")
|
.like(JfTransactionDetails::getRemark,"618活动充值")
|
||||||
.between(JfTransactionDetails::getCreateTime,startTime,endTime)
|
.between(JfTransactionDetails::getCreateTime,startTime,endTime)
|
||||||
.gt(TransactionDetailsEntity::getChangeAmount,0)
|
.gt(TransactionDetailsEntity::getChangeAmount,0)
|
||||||
.selectSum(TransactionDetailsEntity::getChangeAmount));
|
.selectSum(TransactionDetailsEntity::getChangeAmount));
|
||||||
@@ -114,19 +114,19 @@ public class JfTransactionDetailsController {
|
|||||||
new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(1000))>=0||
|
new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(1000))>=0||
|
||||||
new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(500))>=0){
|
new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(500))>=0){
|
||||||
if (new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(5000))>=0){
|
if (new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(5000))>=0){
|
||||||
shouldJf = shouldJf.add(new BigDecimal(2500));
|
shouldJf = shouldJf.add(new BigDecimal(2000));
|
||||||
changeAmount = changeAmount.subtract(new BigDecimal(5000));
|
changeAmount = changeAmount.subtract(new BigDecimal(5000));
|
||||||
}else if (new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(3000))>=0){
|
}else if (new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(3000))>=0){
|
||||||
shouldJf = shouldJf.add(new BigDecimal(1300));
|
shouldJf = shouldJf.add(new BigDecimal(1000));
|
||||||
changeAmount = changeAmount.subtract(new BigDecimal(3000));
|
changeAmount = changeAmount.subtract(new BigDecimal(3000));
|
||||||
}else if (new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(2000))>=0){
|
}else if (new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(2000))>=0){
|
||||||
shouldJf = shouldJf.add(new BigDecimal(800));
|
shouldJf = shouldJf.add(new BigDecimal(600));
|
||||||
changeAmount = changeAmount.subtract(new BigDecimal(2000));
|
changeAmount = changeAmount.subtract(new BigDecimal(2000));
|
||||||
}else if (new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(1000))>=0){
|
}else if (new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(1000))>=0){
|
||||||
shouldJf = shouldJf.add(new BigDecimal(300));
|
shouldJf = shouldJf.add(new BigDecimal(240));
|
||||||
changeAmount = changeAmount.subtract(new BigDecimal(1000));
|
changeAmount = changeAmount.subtract(new BigDecimal(1000));
|
||||||
}else if (new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(500))>=0){
|
}else if (new BigDecimal(changeAmount.toString()).compareTo(new BigDecimal(500))>=0){
|
||||||
shouldJf = shouldJf.add(new BigDecimal(120));
|
shouldJf = shouldJf.add(new BigDecimal(100));
|
||||||
changeAmount = changeAmount.subtract(new BigDecimal(500));
|
changeAmount = changeAmount.subtract(new BigDecimal(500));
|
||||||
}
|
}
|
||||||
return chgf(changeJf,shouldJf,changeAmount,jf);
|
return chgf(changeJf,shouldJf,changeAmount,jf);
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.peanut.modules.common.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.peanut.modules.common.entity.BuyOrderBatchDeliveryItem;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface BuyOrderBatchDeliveryItemDao extends BaseMapper<BuyOrderBatchDeliveryItem> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.peanut.modules.common.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.peanut.modules.common.entity.BuyOrderBatchDeliveryTask;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface BuyOrderBatchDeliveryTaskDao extends BaseMapper<BuyOrderBatchDeliveryTask> {
|
||||||
|
|
||||||
|
@Select("<script>" +
|
||||||
|
"SELECT i.order_id FROM buy_order_batch_delivery_item i " +
|
||||||
|
"INNER JOIN buy_order_batch_delivery_task t ON t.id = i.task_id " +
|
||||||
|
"WHERE t.status IN (0, 1) AND i.status IN (0, 1) AND i.order_id IN " +
|
||||||
|
"<foreach collection='orderIds' item='id' open='(' separator=',' close=')'>" +
|
||||||
|
"#{id}" +
|
||||||
|
"</foreach>" +
|
||||||
|
"</script>")
|
||||||
|
List<Integer> findBusyOrderIds(@Param("orderIds") List<Integer> orderIds);
|
||||||
|
}
|
||||||
@@ -22,8 +22,12 @@ public interface BuyOrderDao extends MPJBaseMapper<BuyOrder> {
|
|||||||
|
|
||||||
List<Map<String,Object>> getPhysicalBuyOrderTotal(@Param("date") String date,@Param("orderType") String orderType);
|
List<Map<String,Object>> getPhysicalBuyOrderTotal(@Param("date") String date,@Param("orderType") String orderType);
|
||||||
|
|
||||||
|
List<Map<String,Object>> getRefund(@Param("date") String date,@Param("orderType") String orderType);
|
||||||
|
|
||||||
List<Map<String,Object>> exportPhysicalBuyOrderInfo(@Param("date") String date,@Param("orderType") String orderType);
|
List<Map<String,Object>> exportPhysicalBuyOrderInfo(@Param("date") String date,@Param("orderType") String orderType);
|
||||||
|
|
||||||
|
List<Map<String,Object>> exportPhysicalBuyOrderRefundInfo(@Param("date") String date,@Param("orderType") String orderType);
|
||||||
|
|
||||||
List<BuyOrder> orderList(BuyOrderListRequestVo requestVo);
|
List<BuyOrder> orderList(BuyOrderListRequestVo requestVo);
|
||||||
int orderListCount(BuyOrderListRequestVo requestVo);
|
int orderListCount(BuyOrderListRequestVo requestVo);
|
||||||
|
|
||||||
|
|||||||
@@ -23,4 +23,6 @@ public interface TransactionDetailsDao extends BaseMapper<TransactionDetailsEnti
|
|||||||
List<Map<String,Object>> getTransactionDetailsTotal(@Param("date") String date);
|
List<Map<String,Object>> getTransactionDetailsTotal(@Param("date") String date);
|
||||||
|
|
||||||
List<Map<String,Object>> getTransactionDetailsInfo(@Param("date") String date);
|
List<Map<String,Object>> getTransactionDetailsInfo(@Param("date") String date);
|
||||||
|
|
||||||
|
List<Map<String,Object>> getRefundTransactionDetails(@Param("date") String date);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,14 @@ public interface UserCourseBuyDao extends MPJBaseMapper<UserCourseBuyEntity> {
|
|||||||
|
|
||||||
List<Map<String,Object>> getIncome(@Param("date") String date);
|
List<Map<String,Object>> getIncome(@Param("date") String date);
|
||||||
|
|
||||||
|
List<Map<String,Object>> getRefund(@Param("date") String date);
|
||||||
|
|
||||||
|
List<Map<String,Object>> getSameMonthRefund(@Param("date") String date);
|
||||||
|
|
||||||
List<Map<String,Object>> getCoursePurchaseDetails(int courseId,int catalogueId,Integer limit,Integer offset);
|
List<Map<String,Object>> getCoursePurchaseDetails(int courseId,int catalogueId,Integer limit,Integer offset);
|
||||||
|
|
||||||
@Delete("DELETE FROM user_course_buy WHERE id = #{userCourseBuyId}")
|
@Delete("DELETE FROM user_course_buy WHERE id = #{userCourseBuyId}")
|
||||||
int realDeleteById(int userCourseBuyId);
|
int realDeleteById(int userCourseBuyId);
|
||||||
|
|
||||||
|
List<Map<String,Object>> getRefundInfo(@Param("date") String date);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.peanut.modules.common.entity.UserVipLog;
|
|||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -15,5 +16,24 @@ public interface UserVipLogDao extends MPJBaseMapper<UserVipLog> {
|
|||||||
|
|
||||||
Map<String,Object> getUserVipLogInfoTotal(@Param("date") String date);
|
Map<String,Object> getUserVipLogInfoTotal(@Param("date") String date);
|
||||||
|
|
||||||
|
BigDecimal getUserVipRefundFeeTotal(@Param("date") String date);
|
||||||
|
|
||||||
|
BigDecimal getUserVipSameMonthRefundFeeTotal(@Param("date") String date);
|
||||||
|
|
||||||
|
List<Map<String,Object>> getUserVipRefundLogInfo(@Param("date") String date);
|
||||||
|
|
||||||
|
List<Map<String,Object>> getAllUserVipLogInfo(@Param("date") String date);
|
||||||
|
|
||||||
List<Map<String,Object>> getUserVipRefundInfo(@Param("date") String last_l_date,@Param("date") String last_date);
|
List<Map<String,Object>> getUserVipRefundInfo(@Param("date") String last_l_date,@Param("date") String last_date);
|
||||||
|
|
||||||
|
List<Map<String,Object>> getLastMonthRefund(@Param("date") String date);
|
||||||
|
|
||||||
|
BigDecimal getLastMonthRefundFee(@Param("date") String date);
|
||||||
|
|
||||||
|
List<Map<String,Object>> getMonthRefund(@Param("date") String date);
|
||||||
|
|
||||||
|
List<Map<String,Object>> getCurrMonthOtherRefund(@Param("date") String date);
|
||||||
|
|
||||||
|
List<Map<String,Object>> getNextNMonthRefund(@Param("date") String date);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ public class CouponEntity {
|
|||||||
//使用门槛
|
//使用门槛
|
||||||
private Integer useLevel;
|
private Integer useLevel;
|
||||||
|
|
||||||
|
//限定VIP类型,逗号分隔,如1,11,5,51;用户开通其中任意VIP可现金券直接换积分
|
||||||
|
private String userVipIds;
|
||||||
|
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
@TableLogic
|
@TableLogic
|
||||||
|
|||||||
@@ -26,5 +26,7 @@ public interface BuyOrderService extends IService<BuyOrder> {
|
|||||||
|
|
||||||
List<Map<String,Object>> getPhysicalBuyOrderTotal(String date, String orderType);
|
List<Map<String,Object>> getPhysicalBuyOrderTotal(String date, String orderType);
|
||||||
|
|
||||||
|
List<Map<String,Object>> getRefund(String date, String orderType);
|
||||||
|
|
||||||
List<Map<String,Object>> exportPhysicalBuyOrderInfo(String date, String orderType);
|
List<Map<String,Object>> exportPhysicalBuyOrderInfo(String date, String orderType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,7 @@ public interface TransactionDetailsService extends IService<TransactionDetailsEn
|
|||||||
|
|
||||||
List<Map<String,Object>> getTransactionDetailsTotal(String date);
|
List<Map<String,Object>> getTransactionDetailsTotal(String date);
|
||||||
|
|
||||||
|
List<Map<String,Object>> getRefundTransactionDetails(String date);
|
||||||
|
|
||||||
List<Map<String,Object>> getTransactionDetailsInfo(String date);
|
List<Map<String,Object>> getTransactionDetailsInfo(String date);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,26 @@ public interface UserVipLogService extends IService<UserVipLog> {
|
|||||||
|
|
||||||
BigDecimal countDayAmount(UserVipLog userVipLog);
|
BigDecimal countDayAmount(UserVipLog userVipLog);
|
||||||
|
|
||||||
|
BigDecimal getLastMonthRefundFee(String date);
|
||||||
|
|
||||||
|
List<Map<String, Object>> getCurrMonthOtherRefund(String date);
|
||||||
|
|
||||||
|
List<Map<String, Object>> getNextNMonthRefund(String date);
|
||||||
|
|
||||||
|
List<Map<String, Object>> getMonthRefund(String date);
|
||||||
|
|
||||||
List<Map<String,Object>> getUserVipLogInfo(String date);
|
List<Map<String,Object>> getUserVipLogInfo(String date);
|
||||||
|
|
||||||
|
String getPayMonth(Map<String, Object> row);
|
||||||
|
|
||||||
List<Map<String, Object>> getUserVipRefundInfo(String last_l_date, String last_date);
|
List<Map<String, Object>> getUserVipRefundInfo(String last_l_date, String last_date);
|
||||||
|
|
||||||
Map<String, Object> getUserVipLogInfoTotal(String date);
|
Map<String, Object> getUserVipLogInfoTotal(String date);
|
||||||
|
|
||||||
|
BigDecimal getUserVipRefundFeeTotal(String date);
|
||||||
|
|
||||||
|
BigDecimal getUserVipSameMonthRefundFeeTotal(String date);
|
||||||
|
|
||||||
|
List<Map<String, Object>> getLastMonthRefund(String date);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import org.apache.commons.lang.StringUtils;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -147,6 +148,8 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
|||||||
List<ExpressOrder> expressOrders = expressOrderDao.selectList(new LambdaQueryWrapper<ExpressOrder>().in(ExpressOrder::getId, collect));
|
List<ExpressOrder> expressOrders = expressOrderDao.selectList(new LambdaQueryWrapper<ExpressOrder>().in(ExpressOrder::getId, collect));
|
||||||
b.setExpressList(expressOrders);
|
b.setExpressList(expressOrders);
|
||||||
}
|
}
|
||||||
|
}else if("relearn".equals(b.getOrderType()) && paymentDateTime > timestamp-7*24*60*60*1000){
|
||||||
|
refundableStatus = true;
|
||||||
}
|
}
|
||||||
b.setRefundableStatus(b.getOrderStatus().equals("6") || b.getOrderStatus().equals("7")?false:refundableStatus);
|
b.setRefundableStatus(b.getOrderStatus().equals("6") || b.getOrderStatus().equals("7")?false:refundableStatus);
|
||||||
}
|
}
|
||||||
@@ -252,29 +255,82 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, Object>> getPhysicalBuyOrderTotal(String date,String orderType) {
|
public List<Map<String, Object>> getPhysicalBuyOrderTotal(String date,String orderType) {
|
||||||
return this.baseMapper.getPhysicalBuyOrderTotal(date, orderType);
|
List<Map<String, Object>> incomeList = this.baseMapper.getPhysicalBuyOrderTotal(date, orderType);
|
||||||
|
List<Map<String, Object>> refundList = this.baseMapper.getRefund(date, orderType);
|
||||||
|
Map<String, Map<String, Object>> merged = new LinkedHashMap<>();
|
||||||
|
for (Map<String, Object> income : incomeList) {
|
||||||
|
String payType = income.get("payType").toString();
|
||||||
|
Map<String, Object> row = new HashMap<>();
|
||||||
|
row.put("payType", payType);
|
||||||
|
row.put("count", income.get("count"));
|
||||||
|
row.put("totalPrice", income.get("totalPrice"));
|
||||||
|
row.put("refundCount", 0);
|
||||||
|
row.put("refundTotalPrice", 0);
|
||||||
|
merged.put(payType, row);
|
||||||
|
}
|
||||||
|
for (Map<String, Object> refund : refundList) {
|
||||||
|
String payType = refund.get("payType").toString();
|
||||||
|
Map<String, Object> row = merged.computeIfAbsent(payType, k -> {
|
||||||
|
Map<String, Object> r = new HashMap<>();
|
||||||
|
r.put("payType", payType);
|
||||||
|
r.put("count", 0);
|
||||||
|
r.put("totalPrice", 0);
|
||||||
|
return r;
|
||||||
|
});
|
||||||
|
row.put("refundCount", refund.get("count"));
|
||||||
|
row.put("refundTotalPrice", refund.get("totalPrice"));
|
||||||
|
}
|
||||||
|
for (Map<String, Object> row : merged.values()) {
|
||||||
|
if (!row.containsKey("refundCount")) {
|
||||||
|
row.put("refundCount", 0);
|
||||||
|
row.put("refundTotalPrice", 0);
|
||||||
|
}
|
||||||
|
BigDecimal totalPrice = toBigDecimal(row.get("totalPrice"));
|
||||||
|
BigDecimal refundTotalPrice = toBigDecimal(row.get("refundTotalPrice"));
|
||||||
|
row.put("netTotalPrice", totalPrice.subtract(refundTotalPrice));
|
||||||
|
}
|
||||||
|
return new ArrayList<>(merged.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
private BigDecimal toBigDecimal(Object value) {
|
||||||
|
if (value == null) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
if (value instanceof BigDecimal) {
|
||||||
|
return (BigDecimal) value;
|
||||||
|
}
|
||||||
|
return new BigDecimal(value.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> getRefund(String date, String orderType) {
|
||||||
|
return this.baseMapper.getRefund(date, orderType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, Object>> exportPhysicalBuyOrderInfo(String date,String orderType) {
|
public List<Map<String, Object>> exportPhysicalBuyOrderInfo(String date,String orderType) {
|
||||||
List<Map<String, Object>> list = this.baseMapper.exportPhysicalBuyOrderInfo(date, orderType);
|
List<Map<String, Object>> purchaseList = this.baseMapper.exportPhysicalBuyOrderInfo(date, orderType);
|
||||||
List<Map<String, Object>> newList = new ArrayList<>();
|
List<Map<String, Object>> refundList = this.baseMapper.exportPhysicalBuyOrderRefundInfo(date, orderType);
|
||||||
for (Map<String, Object> map:list){
|
|
||||||
|
|
||||||
if(map.get("orderStatus").toString().equals("已退款")){
|
List<Map<String, Object>> result = new ArrayList<>();
|
||||||
Map<String, Object> newMap = new HashMap<>(map);
|
for (Map<String, Object> map : purchaseList) {
|
||||||
map.put("orderStatus","已付款");
|
//本月下单即为本月收入,已退款订单的购买行也展示(退款行按退款月份在对应报表中体现)
|
||||||
newList.add(map);
|
if ("已退款".equals(map.get("orderStatus").toString())) {
|
||||||
|
Map<String, Object> purchaseRow = new HashMap<>(map);
|
||||||
newMap.put("orderPrice","-"+map.get("orderPrice").toString());
|
purchaseRow.put("orderStatus", "已付款");
|
||||||
newMap.put("price","-"+map.get("price").toString());
|
result.add(purchaseRow);
|
||||||
newList.add(newMap);
|
|
||||||
} else {
|
} else {
|
||||||
newList.add(map);
|
result.add(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return newList;
|
for (Map<String, Object> refund : refundList) {
|
||||||
|
Map<String, Object> refundRow = new HashMap<>(refund);
|
||||||
|
refundRow.put("orderPrice", toBigDecimal(refund.get("orderPrice")).abs().negate());
|
||||||
|
refundRow.put("price", toBigDecimal(refund.get("price")).abs().negate());
|
||||||
|
result.add(refundRow);
|
||||||
|
}
|
||||||
|
result.sort(Comparator.comparing(m -> m.get("createTime").toString()));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -271,6 +271,15 @@ public class CouponServiceImpl extends ServiceImpl<CouponDao, CouponEntity> impl
|
|||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean matchUserVipIds(String userVipIds, List<UserVip> userVipList) {
|
||||||
|
Set<Integer> allowedVipTypes = Arrays.stream(userVipIds.split(","))
|
||||||
|
.map(String::trim)
|
||||||
|
.filter(StringUtils::isNotEmpty)
|
||||||
|
.map(Integer::parseInt)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
return userVipList.stream().anyMatch(userVip -> allowedVipTypes.contains(userVip.getType()));
|
||||||
|
}
|
||||||
|
|
||||||
public void getCourseMedicalIds(int courseMedicalId,List<Integer> list){
|
public void getCourseMedicalIds(int courseMedicalId,List<Integer> list){
|
||||||
CourseMedicine courseMedicine = courseMedicineDao.selectById(courseMedicalId);
|
CourseMedicine courseMedicine = courseMedicineDao.selectById(courseMedicalId);
|
||||||
if (courseMedicine.getIsLast()==1){
|
if (courseMedicine.getIsLast()==1){
|
||||||
@@ -380,7 +389,7 @@ public class CouponServiceImpl extends ServiceImpl<CouponDao, CouponEntity> impl
|
|||||||
List<Map<String,Object>> buyOrderProducts = couponToProductDao.selectJoinMaps(wrapper);
|
List<Map<String,Object>> buyOrderProducts = couponToProductDao.selectJoinMaps(wrapper);
|
||||||
for (Map<String,Object> map : buyOrderProducts) {
|
for (Map<String,Object> map : buyOrderProducts) {
|
||||||
ShopProduct shopProduct = shopProductDao.selectById(map.get("product_id").toString());
|
ShopProduct shopProduct = shopProductDao.selectById(map.get("product_id").toString());
|
||||||
//预售书+赠送现金券:VIP用户将券额转为积分;仅产品id=2023时需为妇幼生殖vip(type=10)
|
//预售书+赠送现金券:VIP用户将券额转为积分;配置user_vip_ids时匹配VIP且现金券换积分,不匹配只送券
|
||||||
if ("03".equals(shopProduct.getGoodsType())){
|
if ("03".equals(shopProduct.getGoodsType())){
|
||||||
MyUserEntity userEntity = userDao.selectById(order.getUserId());
|
MyUserEntity userEntity = userDao.selectById(order.getUserId());
|
||||||
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
|
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
|
||||||
@@ -389,8 +398,15 @@ public class CouponServiceImpl extends ServiceImpl<CouponDao, CouponEntity> impl
|
|||||||
int productId = Integer.parseInt(map.get("product_id").toString());
|
int productId = Integer.parseInt(map.get("product_id").toString());
|
||||||
int couponId = Integer.parseInt(map.get("coupon_id").toString());
|
int couponId = Integer.parseInt(map.get("coupon_id").toString());
|
||||||
CouponEntity couponEntity = couponDao.selectById(couponId);
|
CouponEntity couponEntity = couponDao.selectById(couponId);
|
||||||
|
boolean couponToJf = false;
|
||||||
|
if (StringUtils.isNotEmpty(couponEntity.getUserVipIds())) {
|
||||||
|
if (matchUserVipIds(couponEntity.getUserVipIds(), userVipList)) {
|
||||||
|
couponToJf = couponEntity.getCouponType() == 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
boolean isFyszVip = userVipList.stream().anyMatch(userVip -> Integer.valueOf(10).equals(userVip.getType()));
|
boolean isFyszVip = userVipList.stream().anyMatch(userVip -> Integer.valueOf(10).equals(userVip.getType()));
|
||||||
boolean couponToJf = couponEntity.getCouponType() == 0 && (productId == 2023 ? isFyszVip : userVipList.size() > 0);
|
couponToJf = couponEntity.getCouponType() == 0 && (productId == 2023 ? isFyszVip : userVipList.size() > 0);
|
||||||
|
}
|
||||||
if (couponToJf){
|
if (couponToJf){
|
||||||
BigDecimal jf = BigDecimal.ZERO;
|
BigDecimal jf = BigDecimal.ZERO;
|
||||||
for (int i=0;i<Integer.parseInt(map.get("quantity").toString());i++){
|
for (int i=0;i<Integer.parseInt(map.get("quantity").toString());i++){
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ public class TransactionDetailsServiceImpl extends ServiceImpl<TransactionDetail
|
|||||||
return this.baseMapper.getTransactionDetailsTotal(date);
|
return this.baseMapper.getTransactionDetailsTotal(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> getRefundTransactionDetails(String date) {
|
||||||
|
return this.baseMapper.getRefundTransactionDetails(date);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, Object>> getTransactionDetailsInfo(String date) {
|
public List<Map<String, Object>> getTransactionDetailsInfo(String date) {
|
||||||
return this.baseMapper.getTransactionDetailsInfo(date);
|
return this.baseMapper.getTransactionDetailsInfo(date);
|
||||||
|
|||||||
@@ -11,9 +11,16 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service("commonUserVipLogService")
|
@Service("commonUserVipLogService")
|
||||||
@@ -87,10 +94,172 @@ public class UserVipLogServiceImpl extends ServiceImpl<UserVipLogDao, UserVipLog
|
|||||||
return userVipLog.getFee().divide(days, 2, BigDecimal.ROUND_HALF_UP);
|
return userVipLog.getFee().divide(days, 2, BigDecimal.ROUND_HALF_UP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public BigDecimal getLastMonthRefundFee(String date){
|
||||||
|
return this.baseMapper.getLastMonthRefundFee(date);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> getLastMonthRefund(String date){
|
||||||
|
return this.baseMapper.getLastMonthRefund(date);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> getCurrMonthOtherRefund(String date){
|
||||||
|
return this.baseMapper.getCurrMonthOtherRefund(date);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> getNextNMonthRefund(String date){
|
||||||
|
return this.baseMapper.getNextNMonthRefund(date);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> getMonthRefund(String date){
|
||||||
|
return this.baseMapper.getMonthRefund(date);
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, Object>> getUserVipLogInfo(String date) {
|
public List<Map<String, Object>> getUserVipLogInfo(String date) {
|
||||||
return this.baseMapper.getUserVipLogInfo(date);
|
// date:报表截止日期,如 2026-06-30;从 DAO 查出未删除 + 已退款(del_flag=-1)的 VIP 明细及摊销
|
||||||
|
List<Map<String, Object>> list = this.baseMapper.getUserVipLogInfo(date);
|
||||||
|
// 以 uvlId 为 key,缓存「本月发生退款」的订单,供后续匹配主列表并生成退款行
|
||||||
|
Map<String, Map<String, Object>> refundMap = new HashMap<>();
|
||||||
|
for (Map<String, Object> refund : this.baseMapper.getMonthRefund(date)) {
|
||||||
|
Object uvlId = refund.get("uvlId");
|
||||||
|
if (uvlId != null) {
|
||||||
|
refundMap.put(uvlId.toString(), refund);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 最终返回给导出的明细列表(可能比 SQL 原始行数多,因退款会拆成「已付款行 + 已退款行」)
|
||||||
|
List<Map<String, Object>> result = new ArrayList<>();
|
||||||
|
// 记录已在主列表中处理过的退款 uvlId,避免第二步重复追加
|
||||||
|
Set<String> matchedUvlIds = new HashSet<>();
|
||||||
|
for (Map<String, Object> row : list) {
|
||||||
|
// 主列表默认标记为已付款
|
||||||
|
row.put("orderStatus", "已付款");
|
||||||
|
|
||||||
|
Object uvlId = row.get("uvlId");
|
||||||
|
// 若该 VIP 记录在本月有退款,则 refund 非空
|
||||||
|
Map<String, Object> refund = uvlId == null ? null : refundMap.get(uvlId.toString());
|
||||||
|
if (refund != null) {
|
||||||
|
// 本月退款的订单:原「已付款」行当月/剩余摊销清零(退款单独成行体现)
|
||||||
|
row.put("currentTanxiao",BigDecimal.ZERO);
|
||||||
|
row.put("notyetTanxiao",BigDecimal.ZERO);
|
||||||
|
String exportMonth = date.length() >= 7 ? date.substring(0, 7) : date;
|
||||||
|
String payMonth = getPayMonth(row);
|
||||||
|
// 本月付本月退:保留原已付款行(金额为正),再追加一条负金额退款行
|
||||||
|
if (exportMonth.equals(payMonth)){
|
||||||
|
result.add(row);
|
||||||
|
}
|
||||||
|
matchedUvlIds.add(uvlId.toString());
|
||||||
|
// 追加「已退款」行,金额/摊销按 buildRefundRow 规则处理
|
||||||
|
result.add(buildRefundRow(row, refund, date));
|
||||||
|
|
||||||
|
}else{
|
||||||
|
// 无本月退款:原样加入结果
|
||||||
|
result.add(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// 其他月份下单、指定月份退款:主列表里没有对应行(user_vip_log已删除),单独追加到列表最下面
|
||||||
|
String exportMonth = date.length() >= 7 ? date.substring(0, 7) : date;
|
||||||
|
for (Map<String, Object> refund : refundMap.values()) {
|
||||||
|
Object uvlId = refund.get("uvlId");
|
||||||
|
// 已在主列表匹配过的跳过
|
||||||
|
if (uvlId != null && matchedUvlIds.contains(uvlId.toString())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String payMonth = getPayMonth(refund);
|
||||||
|
// 早月付款、本月退款且主列表无行:仅用 refund 数据构造一条退款行
|
||||||
|
if (!payMonth.isEmpty() && !exportMonth.equals(payMonth)) {
|
||||||
|
result.add(buildRefundRow(refund, refund, date));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public 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"));
|
||||||
|
refundRow.put("refund_no", refund.get("refund_no"));
|
||||||
|
String exportMonth = date.length() >= 7 ? date.substring(0, 7) : date;
|
||||||
|
String payMonth = getPayMonth(row);
|
||||||
|
BigDecimal dayAmount = toBigDecimal(row.get("dayAmount"));
|
||||||
|
if (exportMonth.equals(payMonth)) {
|
||||||
|
|
||||||
|
// 当月订单当月退款:金额为负,当月/剩余摊销为0
|
||||||
|
refundRow.put("price", toBigDecimal(row.get("price")).negate());
|
||||||
|
refundRow.put("fee", toBigDecimal(row.get("fee")).negate());
|
||||||
|
refundRow.put("alreadyDays", 0);
|
||||||
|
refundRow.put("currentDays", 0);
|
||||||
|
refundRow.put("notyetDays", 0);
|
||||||
|
refundRow.put("alreadyTanxiao", BigDecimal.ZERO);
|
||||||
|
refundRow.put("currentTanxiao", BigDecimal.ZERO);
|
||||||
|
refundRow.put("notyetTanxiao", BigDecimal.ZERO);
|
||||||
|
} else if (!payMonth.isEmpty() && !exportMonth.equals(payMonth)) {
|
||||||
|
// 其他月份下单、指定月份退款:冲回截至上月末的已摊销,当月摊销为负的已摊销额
|
||||||
|
int alreadyDays = calcAlreadyDaysToPrevMonthEnd(row, date);
|
||||||
|
BigDecimal alreadyTanxiao = dayAmount.multiply(new BigDecimal(alreadyDays)).setScale(2, RoundingMode.HALF_UP);
|
||||||
|
refundRow.put("price", toBigDecimal(row.get("price")).negate());
|
||||||
|
refundRow.put("fee", toBigDecimal(row.get("price")).negate());
|
||||||
|
refundRow.put("alreadyDays", alreadyDays);
|
||||||
|
refundRow.put("currentDays", 0);
|
||||||
|
refundRow.put("notyetDays", 0);
|
||||||
|
refundRow.put("alreadyTanxiao", 0);
|
||||||
|
// 当月摊销 = 负的「付款月至上月末」累计摊销
|
||||||
|
refundRow.put("currentTanxiao", alreadyTanxiao.negate());
|
||||||
|
refundRow.put("notyetTanxiao", 0);
|
||||||
|
refundRow.put("startTime", refund.get("refundTime"));
|
||||||
|
} else {
|
||||||
|
// 兜底:按原行已摊销冲回
|
||||||
|
refundRow.put("price", toBigDecimal(row.get("price")).negate());
|
||||||
|
refundRow.put("fee", toBigDecimal(row.get("fee")).negate());
|
||||||
|
refundRow.put("alreadyDays", row.get("alreadyDays"));
|
||||||
|
refundRow.put("currentDays", 0);
|
||||||
|
refundRow.put("notyetDays", 0);
|
||||||
|
refundRow.put("alreadyTanxiao", toBigDecimal(row.get("alreadyTanxiao")));
|
||||||
|
refundRow.put("currentTanxiao", toBigDecimal(row.get("alreadyTanxiao")).negate());
|
||||||
|
refundRow.put("notyetTanxiao", BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
return refundRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public 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());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -102,4 +271,14 @@ public class UserVipLogServiceImpl extends ServiceImpl<UserVipLogDao, UserVipLog
|
|||||||
public Map<String, Object> getUserVipLogInfoTotal(String date) {
|
public Map<String, Object> getUserVipLogInfoTotal(String date) {
|
||||||
return this.baseMapper.getUserVipLogInfoTotal(date);
|
return this.baseMapper.getUserVipLogInfoTotal(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal getUserVipRefundFeeTotal(String date) {
|
||||||
|
return this.baseMapper.getUserVipRefundFeeTotal(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal getUserVipSameMonthRefundFeeTotal(String date) {
|
||||||
|
return this.baseMapper.getUserVipSameMonthRefundFeeTotal(date);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -266,7 +266,6 @@ public class UserVipServiceImpl extends ServiceImpl<UserVipDao, UserVip> impleme
|
|||||||
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
|
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
|
||||||
.eq(UserVip::getUserId,buyOrder.getUserId()).eq(UserVip::getState,0).in(UserVip::getType,4,9,5,6,10));
|
.eq(UserVip::getUserId,buyOrder.getUserId()).eq(UserVip::getState,0).in(UserVip::getType,4,9,5,6,10));
|
||||||
for (int i=4;i<=10;i++){
|
for (int i=4;i<=10;i++){
|
||||||
log.info("openVipForUser====i:"+i);
|
|
||||||
if (i==7){
|
if (i==7){
|
||||||
i=9;
|
i=9;
|
||||||
}
|
}
|
||||||
@@ -302,8 +301,8 @@ public class UserVipServiceImpl extends ServiceImpl<UserVipDao, UserVip> impleme
|
|||||||
}
|
}
|
||||||
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
|
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
|
||||||
.eq(UserVip::getUserId,buyOrder.getUserId()).eq(UserVip::getType,i).orderByDesc(UserVip::getEndTime));
|
.eq(UserVip::getUserId,buyOrder.getUserId()).eq(UserVip::getType,i).orderByDesc(UserVip::getEndTime));
|
||||||
UserVip userVip = userVipList.get(0);
|
UserVip userVip = userVipList.isEmpty() ? null : userVipList.get(0);
|
||||||
if (userVip.getState()==0) {
|
if (userVipList.size()>0 && userVip != null && (userVip.getState() == null || userVip.getState() == 0)) {
|
||||||
Date startTime = userVip.getEndTime();
|
Date startTime = userVip.getEndTime();
|
||||||
Date endTime = DateUtils.addYears(userVip.getEndTime(),vipBuyConfigEntity.getYear());
|
Date endTime = DateUtils.addYears(userVip.getEndTime(),vipBuyConfigEntity.getYear());
|
||||||
userVip.setEndTime(endTime);
|
userVip.setEndTime(endTime);
|
||||||
@@ -354,8 +353,8 @@ public class UserVipServiceImpl extends ServiceImpl<UserVipDao, UserVip> impleme
|
|||||||
for (int i=7;i<9;i++){
|
for (int i=7;i<9;i++){
|
||||||
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
|
List<UserVip> userVipList = userVipDao.selectList(new LambdaQueryWrapper<UserVip>()
|
||||||
.eq(UserVip::getUserId,buyOrder.getUserId()).eq(UserVip::getType,i).orderByDesc(UserVip::getEndTime));
|
.eq(UserVip::getUserId,buyOrder.getUserId()).eq(UserVip::getType,i).orderByDesc(UserVip::getEndTime));
|
||||||
UserVip userVip = userVipList.get(0);
|
UserVip userVip = userVipList.isEmpty() ? null : userVipList.get(0);
|
||||||
if (userVip.getState()==0) {
|
if (userVip != null && (userVip.getState() == null || userVip.getState() == 0)) {
|
||||||
Date startTime = userVip.getEndTime();
|
Date startTime = userVip.getEndTime();
|
||||||
Date endTime = DateUtils.addYears(userVip.getEndTime(),vipBuyConfigEntity.getYear());
|
Date endTime = DateUtils.addYears(userVip.getEndTime(),vipBuyConfigEntity.getYear());
|
||||||
userVip.setEndTime(endTime);
|
userVip.setEndTime(endTime);
|
||||||
@@ -388,8 +387,8 @@ public class UserVipServiceImpl extends ServiceImpl<UserVipDao, UserVip> impleme
|
|||||||
.eq(UserVip::getUserId,buyOrder.getUserId())
|
.eq(UserVip::getUserId,buyOrder.getUserId())
|
||||||
.eq(UserVip::getType,vipBuyConfigEntity.getType().toString().substring(0,vipBuyConfigEntity.getType()==101?2:1))
|
.eq(UserVip::getType,vipBuyConfigEntity.getType().toString().substring(0,vipBuyConfigEntity.getType()==101?2:1))
|
||||||
.orderByDesc(UserVip::getEndTime));
|
.orderByDesc(UserVip::getEndTime));
|
||||||
UserVip userVip = userVipList.get(0);
|
UserVip userVip = userVipList.isEmpty() ? null : userVipList.get(0);
|
||||||
if (userVip.getState()==0) {
|
if (userVip != null && (userVip.getState() == null || userVip.getState() == 0)) {
|
||||||
Date startTime = userVip.getEndTime();
|
Date startTime = userVip.getEndTime();
|
||||||
Date endTime = DateUtils.addYears(userVip.getEndTime(),vipBuyConfigEntity.getYear());
|
Date endTime = DateUtils.addYears(userVip.getEndTime(),vipBuyConfigEntity.getYear());
|
||||||
userVip.setEndTime(endTime);
|
userVip.setEndTime(endTime);
|
||||||
|
|||||||
@@ -35,13 +35,16 @@ public class StatisticsBusinessVipController {
|
|||||||
|
|
||||||
@RequestMapping("/getUserVipByMonth")
|
@RequestMapping("/getUserVipByMonth")
|
||||||
public R getUserVipByMonth(@RequestBody Map<String,Object> params) {
|
public R getUserVipByMonth(@RequestBody Map<String,Object> params) {
|
||||||
CountResult result = countInfo(userVipService.getUserVipByMonth(params.get("date").toString()));
|
CountResult result = countInfo(userVipService.getUserVipByMonth(params.get("date").toString()), params.get("date").toString());
|
||||||
|
|
||||||
List<Map<String,Object>> allResultList = result.resultList;
|
List<Map<String,Object>> allResultList = result.resultList;
|
||||||
|
|
||||||
Map<String, Integer> banCounts = new HashMap<>();
|
Map<String, Integer> banCounts = new HashMap<>();
|
||||||
Map<String, Integer> yanCounts = new HashMap<>();
|
Map<String, Integer> yanCounts = new HashMap<>();
|
||||||
BigDecimal banTotalPrice = BigDecimal.ZERO;
|
BigDecimal banTotalPrice = BigDecimal.ZERO;
|
||||||
BigDecimal yanTotalPrice = BigDecimal.ZERO;
|
BigDecimal yanTotalPrice = BigDecimal.ZERO;
|
||||||
|
String date = params.get("date").toString();
|
||||||
|
Map<String, List<Integer>> reBuyRules = buildReBuyRules(date);
|
||||||
for (Map<String,Object> map : allResultList) {
|
for (Map<String,Object> map : allResultList) {
|
||||||
String vipType = map.get("vipType").toString();
|
String vipType = map.get("vipType").toString();
|
||||||
boolean isBan = map.get("startTime").equals(map.get("uvlStartTime"));
|
boolean isBan = map.get("startTime").equals(map.get("uvlStartTime"));
|
||||||
@@ -61,17 +64,6 @@ public class StatisticsBusinessVipController {
|
|||||||
.eq(UserVip::getUserId, map.get("userId").toString())
|
.eq(UserVip::getUserId, map.get("userId").toString())
|
||||||
.eq(UserVip::getState,1).lt(UserVip::getStartTime,map.get("startTime").toString()))
|
.eq(UserVip::getState,1).lt(UserVip::getStartTime,map.get("startTime").toString()))
|
||||||
.stream().map(UserVip::getType).collect(Collectors.toList());
|
.stream().map(UserVip::getType).collect(Collectors.toList());
|
||||||
// 定义复购规则
|
|
||||||
Map<String, List<Integer>> reBuyRules = new HashMap<>();
|
|
||||||
reBuyRules.put("医学超级", Arrays.asList(4, 5, 6, 9, 10));
|
|
||||||
reBuyRules.put("国学心理学超级", Arrays.asList(7, 8));
|
|
||||||
reBuyRules.put("中医学", Arrays.asList(4));
|
|
||||||
reBuyRules.put("针灸学", Arrays.asList(5));
|
|
||||||
reBuyRules.put("肿瘤学", Arrays.asList(6));
|
|
||||||
reBuyRules.put("国学", Arrays.asList(7));
|
|
||||||
reBuyRules.put("心理学", Arrays.asList(8));
|
|
||||||
reBuyRules.put("中西汇通学", Arrays.asList(9));
|
|
||||||
reBuyRules.put("妇幼生殖", Arrays.asList(10));
|
|
||||||
// 判断是否复购
|
// 判断是否复购
|
||||||
List<Integer> required = reBuyRules.get(vipType);
|
List<Integer> required = reBuyRules.get(vipType);
|
||||||
if (required != null && state1UserVips.containsAll(required)) {
|
if (required != null && state1UserVips.containsAll(required)) {
|
||||||
@@ -112,7 +104,7 @@ public class StatisticsBusinessVipController {
|
|||||||
row0.createCell(0).setCellValue("办理总人数");row0.createCell(1).setCellValue(r.get("banTotalCount").toString());
|
row0.createCell(0).setCellValue("办理总人数");row0.createCell(1).setCellValue(r.get("banTotalCount").toString());
|
||||||
row0.createCell(2).setCellValue("延期总人数");row0.createCell(3).setCellValue(r.get("yanTotalCount").toString());
|
row0.createCell(2).setCellValue("延期总人数");row0.createCell(3).setCellValue(r.get("yanTotalCount").toString());
|
||||||
row0.createCell(4).setCellValue("总办理金额");row0.createCell(5).setCellValue(r.get("banTotalPrice").toString());
|
row0.createCell(4).setCellValue("总办理金额");row0.createCell(5).setCellValue(r.get("banTotalPrice").toString());
|
||||||
BigDecimal a = new BigDecimal(r.get("banTotalCount").toString()).subtract(new BigDecimal(r2.get("banTotalCount").toString())).divide(new BigDecimal(r.get("banTotalCount").toString()), 4, RoundingMode.HALF_UP);
|
BigDecimal a = calcGrowthRate(r.get("banTotalCount"), r2.get("banTotalCount"));
|
||||||
DecimalFormat df = new DecimalFormat("0.00%");
|
DecimalFormat df = new DecimalFormat("0.00%");
|
||||||
row0.createCell(6).setCellValue("办理总人数环比增长率:");row0.createCell(7).setCellValue(df.format(a));
|
row0.createCell(6).setCellValue("办理总人数环比增长率:");row0.createCell(7).setCellValue(df.format(a));
|
||||||
Row row1 = sheet.createRow(rowNum++);
|
Row row1 = sheet.createRow(rowNum++);
|
||||||
@@ -121,19 +113,19 @@ public class StatisticsBusinessVipController {
|
|||||||
row1.createCell(0).setCellValue("医学超级");row1.createCell(1).setCellValue(state1Counts.getOrDefault("医学超级",0).toString());
|
row1.createCell(0).setCellValue("医学超级");row1.createCell(1).setCellValue(state1Counts.getOrDefault("医学超级",0).toString());
|
||||||
row1.createCell(2).setCellValue("医学超级");row1.createCell(3).setCellValue(state0Counts.getOrDefault("医学超级",0).toString());
|
row1.createCell(2).setCellValue("医学超级");row1.createCell(3).setCellValue(state0Counts.getOrDefault("医学超级",0).toString());
|
||||||
row1.createCell(4).setCellValue("总延期金额");row1.createCell(5).setCellValue(r.get("yanTotalPrice").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);
|
BigDecimal b = calcGrowthRate(r.get("yanTotalCount"), r2.get("yanTotalCount"));
|
||||||
row1.createCell(6).setCellValue("延期总人数环比增长率:");row1.createCell(7).setCellValue(df.format(b));
|
row1.createCell(6).setCellValue("延期总人数环比增长率:");row1.createCell(7).setCellValue(df.format(b));
|
||||||
Row row2 = sheet.createRow(rowNum++);
|
Row row2 = sheet.createRow(rowNum++);
|
||||||
row2.createCell(0).setCellValue("国学心理学超级");row2.createCell(1).setCellValue(state1Counts.getOrDefault("国学心理学超级",0).toString());
|
row2.createCell(0).setCellValue("国学心理学超级");row2.createCell(1).setCellValue(state1Counts.getOrDefault("国学心理学超级",0).toString());
|
||||||
row2.createCell(2).setCellValue("国学心理学超级");row2.createCell(3).setCellValue(state0Counts.getOrDefault("国学心理学超级",0).toString());
|
row2.createCell(2).setCellValue("国学心理学超级");row2.createCell(3).setCellValue(state0Counts.getOrDefault("国学心理学超级",0).toString());
|
||||||
row2.createCell(4).setCellValue("总金额");row2.createCell(5).setCellValue(
|
row2.createCell(4).setCellValue("总金额");row2.createCell(5).setCellValue(
|
||||||
new BigDecimal(r.get("banTotalPrice").toString()).add(new BigDecimal(r.get("yanTotalPrice").toString())).toString());
|
new BigDecimal(r.get("banTotalPrice").toString()).add(new BigDecimal(r.get("yanTotalPrice").toString())).toString());
|
||||||
BigDecimal c = new BigDecimal(r.get("banTotalPrice").toString()).subtract(new BigDecimal(r2.get("banTotalPrice").toString())).divide(new BigDecimal(r.get("banTotalPrice").toString()), 4, RoundingMode.HALF_UP);
|
BigDecimal c = calcGrowthRate(r.get("banTotalPrice"), r2.get("banTotalPrice"));
|
||||||
row2.createCell(6).setCellValue("办理金额环比增长率:");row2.createCell(7).setCellValue(df.format(c));
|
row2.createCell(6).setCellValue("办理金额环比增长率:");row2.createCell(7).setCellValue(df.format(c));
|
||||||
Row row3 = sheet.createRow(rowNum++);
|
Row row3 = sheet.createRow(rowNum++);
|
||||||
row3.createCell(0).setCellValue("中医学");row3.createCell(1).setCellValue(state1Counts.getOrDefault("中医学", 0).toString());
|
row3.createCell(0).setCellValue("中医学");row3.createCell(1).setCellValue(state1Counts.getOrDefault("中医学", 0).toString());
|
||||||
row3.createCell(2).setCellValue("中医学");row3.createCell(3).setCellValue(state0Counts.getOrDefault("中医学", 0).toString());
|
row3.createCell(2).setCellValue("中医学");row3.createCell(3).setCellValue(state0Counts.getOrDefault("中医学", 0).toString());
|
||||||
BigDecimal d = new BigDecimal(r.get("yanTotalPrice").toString()).subtract(new BigDecimal(r2.get("yanTotalPrice").toString())).divide(new BigDecimal(r.get("yanTotalPrice").toString()), 4, RoundingMode.HALF_UP);
|
BigDecimal d = calcGrowthRate(r.get("yanTotalPrice"), r2.get("yanTotalPrice"));
|
||||||
row3.createCell(6).setCellValue("延期金额环比增长率:");row3.createCell(7).setCellValue(df.format(d));
|
row3.createCell(6).setCellValue("延期金额环比增长率:");row3.createCell(7).setCellValue(df.format(d));
|
||||||
Row row4 = sheet.createRow(rowNum++);
|
Row row4 = sheet.createRow(rowNum++);
|
||||||
row4.createCell(0).setCellValue("针灸学");row4.createCell(1).setCellValue(state1Counts.getOrDefault("针灸学", 0).toString());
|
row4.createCell(0).setCellValue("针灸学");row4.createCell(1).setCellValue(state1Counts.getOrDefault("针灸学", 0).toString());
|
||||||
@@ -142,8 +134,8 @@ public class StatisticsBusinessVipController {
|
|||||||
row5.createCell(0).setCellValue("肿瘤学");row5.createCell(1).setCellValue(state1Counts.getOrDefault("肿瘤学", 0).toString());
|
row5.createCell(0).setCellValue("肿瘤学");row5.createCell(1).setCellValue(state1Counts.getOrDefault("肿瘤学", 0).toString());
|
||||||
row5.createCell(2).setCellValue("肿瘤学");row5.createCell(3).setCellValue(state0Counts.getOrDefault("肿瘤学", 0).toString());
|
row5.createCell(2).setCellValue("肿瘤学");row5.createCell(3).setCellValue(state0Counts.getOrDefault("肿瘤学", 0).toString());
|
||||||
Row row6 = sheet.createRow(rowNum++);
|
Row row6 = sheet.createRow(rowNum++);
|
||||||
row6.createCell(0).setCellValue("妇幼生殖");row6.createCell(1).setCellValue(state1Counts.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());
|
row6.createCell(2).setCellValue("妇幼生殖学");row6.createCell(3).setCellValue(state0Counts.getOrDefault("妇幼生殖学", 0).toString());
|
||||||
Row row7 = sheet.createRow(rowNum++);
|
Row row7 = sheet.createRow(rowNum++);
|
||||||
row7.createCell(0).setCellValue("国学");row7.createCell(1).setCellValue(state1Counts.getOrDefault("国学",0).toString());
|
row7.createCell(0).setCellValue("国学");row7.createCell(1).setCellValue(state1Counts.getOrDefault("国学",0).toString());
|
||||||
row7.createCell(2).setCellValue("国学");row7.createCell(3).setCellValue(state0Counts.getOrDefault("国学", 0).toString());
|
row7.createCell(2).setCellValue("国学");row7.createCell(3).setCellValue(state0Counts.getOrDefault("国学", 0).toString());
|
||||||
@@ -290,28 +282,28 @@ public class StatisticsBusinessVipController {
|
|||||||
row0.createCell(0).setCellValue("办理总人数");row0.createCell(1).setCellValue(r.get("banTotalCount").toString());
|
row0.createCell(0).setCellValue("办理总人数");row0.createCell(1).setCellValue(r.get("banTotalCount").toString());
|
||||||
row0.createCell(2).setCellValue("延期总人数");row0.createCell(3).setCellValue(r.get("yanTotalCount").toString());
|
row0.createCell(2).setCellValue("延期总人数");row0.createCell(3).setCellValue(r.get("yanTotalCount").toString());
|
||||||
row0.createCell(4).setCellValue("总办理金额");row0.createCell(5).setCellValue(r.get("banTotalPrice").toString());
|
row0.createCell(4).setCellValue("总办理金额");row0.createCell(5).setCellValue(r.get("banTotalPrice").toString());
|
||||||
BigDecimal a = new BigDecimal(r.get("banTotalCount").toString()).subtract(new BigDecimal(r2.get("banTotalCount").toString())).divide(new BigDecimal(r.get("banTotalCount").toString()), 4, RoundingMode.HALF_UP);
|
BigDecimal a = calcGrowthRate(r.get("banTotalCount"), r2.get("banTotalCount"));
|
||||||
DecimalFormat df = new DecimalFormat("0.00%");
|
DecimalFormat df = new DecimalFormat("0.00%");
|
||||||
row0.createCell(6).setCellValue("办理总人数同比增长率:");row0.createCell(7).setCellValue(df.format(a));
|
row0.createCell(6).setCellValue("办理总人数同比增长率:");row0.createCell(7).setCellValue(df.format(a));
|
||||||
Row row1 = sheet.createRow(rowNum++);
|
Row row1 = sheet.createRow(rowNum++);
|
||||||
Map<String,Integer> state1Counts = (Map<String,Integer>) r.get("banTypeTotalCounts");
|
Map<String,Integer> state1Counts = (Map<String,Integer>) r.get("banTypeTotalCounts");
|
||||||
Map<String,Integer> state0Counts = (Map<String,Integer>) r.get("yanTypeTotalCounts");
|
Map<String,Integer> state0Counts = (Map<String,Integer>) r.get("yanTypeTotalCounts");
|
||||||
row1.createCell(0).setCellValue("医学超级");row1.createCell(1).setCellValue(state1Counts.get("医学超级").toString());
|
row1.createCell(0).setCellValue("医学超级");row1.createCell(1).setCellValue(state1Counts.containsKey("医学超级")?state1Counts.get("医学超级").toString():"");
|
||||||
row1.createCell(2).setCellValue("医学超级");row1.createCell(3).setCellValue(state0Counts.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());
|
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);
|
BigDecimal b = calcGrowthRate(r.get("yanTotalCount"), r2.get("yanTotalCount"));
|
||||||
row1.createCell(6).setCellValue("延期总人数同比增长率:");row1.createCell(7).setCellValue(df.format(b));
|
row1.createCell(6).setCellValue("延期总人数同比增长率:");row1.createCell(7).setCellValue(df.format(b));
|
||||||
Row row2 = sheet.createRow(rowNum++);
|
Row row2 = sheet.createRow(rowNum++);
|
||||||
row2.createCell(0).setCellValue("国学心理学超级");row2.createCell(1).setCellValue(state1Counts.get("国学心理学超级").toString());
|
row2.createCell(0).setCellValue("国学心理学超级");row2.createCell(1).setCellValue(state1Counts.get("国学心理学超级").toString());
|
||||||
row2.createCell(2).setCellValue("国学心理学超级");row2.createCell(3).setCellValue(state0Counts.get("国学心理学超级").toString());
|
row2.createCell(2).setCellValue("国学心理学超级");row2.createCell(3).setCellValue(state0Counts.get("国学心理学超级").toString());
|
||||||
row2.createCell(4).setCellValue("总金额");row2.createCell(5).setCellValue(
|
row2.createCell(4).setCellValue("总金额");row2.createCell(5).setCellValue(
|
||||||
new BigDecimal(r.get("banTotalPrice").toString()).add(new BigDecimal(r.get("yanTotalPrice").toString())).toString());
|
new BigDecimal(r.get("banTotalPrice").toString()).add(new BigDecimal(r.get("yanTotalPrice").toString())).toString());
|
||||||
BigDecimal c = new BigDecimal(r.get("banTotalPrice").toString()).subtract(new BigDecimal(r2.get("banTotalPrice").toString())).divide(new BigDecimal(r.get("banTotalPrice").toString()), 4, RoundingMode.HALF_UP);
|
BigDecimal c = calcGrowthRate(r.get("banTotalPrice"), r2.get("banTotalPrice"));
|
||||||
row2.createCell(6).setCellValue("办理金额同比增长率:");row2.createCell(7).setCellValue(df.format(c));
|
row2.createCell(6).setCellValue("办理金额同比增长率:");row2.createCell(7).setCellValue(df.format(c));
|
||||||
Row row3 = sheet.createRow(rowNum++);
|
Row row3 = sheet.createRow(rowNum++);
|
||||||
row3.createCell(0).setCellValue("中医学");row3.createCell(1).setCellValue(state1Counts.getOrDefault("中医学", 0).toString());
|
row3.createCell(0).setCellValue("中医学");row3.createCell(1).setCellValue(state1Counts.getOrDefault("中医学", 0).toString());
|
||||||
row3.createCell(2).setCellValue("中医学");row3.createCell(3).setCellValue(state0Counts.getOrDefault("中医学", 0).toString());
|
row3.createCell(2).setCellValue("中医学");row3.createCell(3).setCellValue(state0Counts.getOrDefault("中医学", 0).toString());
|
||||||
BigDecimal d = new BigDecimal(r.get("yanTotalPrice").toString()).subtract(new BigDecimal(r2.get("yanTotalPrice").toString())).divide(new BigDecimal(r.get("yanTotalPrice").toString()), 4, RoundingMode.HALF_UP);
|
BigDecimal d = calcGrowthRate(r.get("yanTotalPrice"), r2.get("yanTotalPrice"));
|
||||||
row3.createCell(6).setCellValue("延期金额同比增长率:");row3.createCell(7).setCellValue(df.format(d));
|
row3.createCell(6).setCellValue("延期金额同比增长率:");row3.createCell(7).setCellValue(df.format(d));
|
||||||
Row row4 = sheet.createRow(rowNum++);
|
Row row4 = sheet.createRow(rowNum++);
|
||||||
row4.createCell(0).setCellValue("针灸学");row4.createCell(1).setCellValue(state1Counts.getOrDefault("针灸学", 0).toString());
|
row4.createCell(0).setCellValue("针灸学");row4.createCell(1).setCellValue(state1Counts.getOrDefault("针灸学", 0).toString());
|
||||||
@@ -320,8 +312,8 @@ public class StatisticsBusinessVipController {
|
|||||||
row5.createCell(0).setCellValue("肿瘤学");row5.createCell(1).setCellValue(state1Counts.getOrDefault("肿瘤学", 0).toString());
|
row5.createCell(0).setCellValue("肿瘤学");row5.createCell(1).setCellValue(state1Counts.getOrDefault("肿瘤学", 0).toString());
|
||||||
row5.createCell(2).setCellValue("肿瘤学");row5.createCell(3).setCellValue(state0Counts.getOrDefault("肿瘤学", 0).toString());
|
row5.createCell(2).setCellValue("肿瘤学");row5.createCell(3).setCellValue(state0Counts.getOrDefault("肿瘤学", 0).toString());
|
||||||
Row row6 = sheet.createRow(rowNum++);
|
Row row6 = sheet.createRow(rowNum++);
|
||||||
row6.createCell(0).setCellValue("妇幼生殖");row6.createCell(1).setCellValue(state1Counts.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());
|
row6.createCell(2).setCellValue("妇幼生殖学");row6.createCell(3).setCellValue(state0Counts.getOrDefault("妇幼生殖学", 0).toString());
|
||||||
Row row7 = sheet.createRow(rowNum++);
|
Row row7 = sheet.createRow(rowNum++);
|
||||||
row7.createCell(0).setCellValue("国学");row7.createCell(1).setCellValue(state1Counts.getOrDefault("国学",0).toString());
|
row7.createCell(0).setCellValue("国学");row7.createCell(1).setCellValue(state1Counts.getOrDefault("国学",0).toString());
|
||||||
row7.createCell(2).setCellValue("国学");row7.createCell(3).setCellValue(state0Counts.getOrDefault("国学", 0).toString());
|
row7.createCell(2).setCellValue("国学");row7.createCell(3).setCellValue(state0Counts.getOrDefault("国学", 0).toString());
|
||||||
@@ -346,7 +338,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);
|
||||||
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 +352,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());
|
||||||
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 +435,17 @@ public class StatisticsBusinessVipController {
|
|||||||
row5.createCell(1).setCellValue("肿瘤学");row5.createCell(2).setCellValue(state1Counts.get("zlCount").toString());
|
row5.createCell(1).setCellValue("肿瘤学");row5.createCell(2).setCellValue(state1Counts.get("zlCount").toString());
|
||||||
row5.createCell(4).setCellValue("肿瘤学");row5.createCell(5).setCellValue(state0Counts.get("zlCount").toString());
|
row5.createCell(4).setCellValue("肿瘤学");row5.createCell(5).setCellValue(state0Counts.get("zlCount").toString());
|
||||||
Row row6 = sheet.createRow(rowNum++);
|
Row row6 = sheet.createRow(rowNum++);
|
||||||
row6.createCell(1).setCellValue("国学");row6.createCell(2).setCellValue(state1Counts.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("gxCount").toString());
|
row6.createCell(4).setCellValue("妇幼生殖学");row6.createCell(5).setCellValue(state0Counts.get("fyszCount").toString());
|
||||||
Row row7 = sheet.createRow(rowNum++);
|
Row row7 = sheet.createRow(rowNum++);
|
||||||
row7.createCell(1).setCellValue("心理学");row7.createCell(2).setCellValue(state1Counts.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("xlCount").toString());
|
row7.createCell(4).setCellValue("国学");row7.createCell(5).setCellValue(state0Counts.get("gxCount").toString());
|
||||||
Row row8 = sheet.createRow(rowNum++);
|
Row row8 = sheet.createRow(rowNum++);
|
||||||
row8.createCell(1).setCellValue("中西汇通学");row8.createCell(2).setCellValue(state1Counts.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("zxhtCount").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"));
|
export(wb,sheet,fileName,++rowNum,response,headers,cellValues, (List<Map<String, Object>>) r.get("resultList"));
|
||||||
}
|
}
|
||||||
@@ -489,7 +484,8 @@ public class StatisticsBusinessVipController {
|
|||||||
"6","肿瘤学",
|
"6","肿瘤学",
|
||||||
"7","国学",
|
"7","国学",
|
||||||
"8","心理学",
|
"8","心理学",
|
||||||
"9","中西汇通学"
|
"9","中西汇通学",
|
||||||
|
"10","妇幼生殖学"
|
||||||
);
|
);
|
||||||
|
|
||||||
// 封装统计结果
|
// 封装统计结果
|
||||||
@@ -499,7 +495,13 @@ public class StatisticsBusinessVipController {
|
|||||||
Map<String,Integer> counts = new HashMap<>();
|
Map<String,Integer> counts = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String MEDICAL_SUPER_CUTOFF = "2026-05";
|
||||||
|
|
||||||
private CountResult countInfo(List<Map<String,Object>> userVips) {
|
private CountResult countInfo(List<Map<String,Object>> userVips) {
|
||||||
|
return countInfo(userVips, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CountResult countInfo(List<Map<String,Object>> userVips, String date) {
|
||||||
CountResult result = new CountResult();
|
CountResult result = new CountResult();
|
||||||
// 初始化计数器
|
// 初始化计数器
|
||||||
result.counts.put("yxSuperCount",0);
|
result.counts.put("yxSuperCount",0);
|
||||||
@@ -510,18 +512,21 @@ public class StatisticsBusinessVipController {
|
|||||||
result.counts.put("gxCount",0);
|
result.counts.put("gxCount",0);
|
||||||
result.counts.put("xlCount",0);
|
result.counts.put("xlCount",0);
|
||||||
result.counts.put("zxhtCount",0);
|
result.counts.put("zxhtCount",0);
|
||||||
|
result.counts.put("fyszCount",0);
|
||||||
|
|
||||||
for (Map<String,Object> map : userVips) {
|
for (Map<String,Object> map : userVips) {
|
||||||
|
String recordMonth = resolveRecordMonth(map, date);
|
||||||
|
List<String> medicalSuperTypes = getMedicalSuperTypes(recordMonth);
|
||||||
String[] types = map.get("type").toString().split(",");
|
String[] types = map.get("type").toString().split(",");
|
||||||
Set<String> typeSet = new HashSet<>(Arrays.asList(types));
|
Set<String> typeSet = new HashSet<>(Arrays.asList(types));
|
||||||
int yxFlag = 0;
|
int yxFlag = 0;
|
||||||
int gxFlag = 0;
|
int gxFlag = 0;
|
||||||
// 超级类型
|
// 超级类型
|
||||||
if (typeSet.containsAll(Arrays.asList("4","5","6","9"))) {
|
if (typeSet.containsAll(medicalSuperTypes)) {
|
||||||
yxFlag = 1;
|
yxFlag = 1;
|
||||||
Map<String,Object> copy = new HashMap<>(map);
|
Map<String,Object> copy = new HashMap<>(map);
|
||||||
copy.put("vipType","医学超级");
|
copy.put("vipType","医学超级");
|
||||||
copy.put("price",Math.round(Double.parseDouble(map.get("price").toString())*4));
|
copy.put("price",Math.round(Double.parseDouble(map.get("price").toString())*medicalSuperTypes.size()));
|
||||||
result.resultList.add(copy);
|
result.resultList.add(copy);
|
||||||
result.counts.computeIfPresent("yxSuperCount",(k,v)->v+1);
|
result.counts.computeIfPresent("yxSuperCount",(k,v)->v+1);
|
||||||
result.total.add(map.get("tel").toString());
|
result.total.add(map.get("tel").toString());
|
||||||
@@ -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 ("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 ("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 ("9".equals(type) && yxFlag==0) { copy.put("vipType","中西汇通学"); result.counts.computeIfPresent("zxhtCount",(k,v)->v+1); }
|
||||||
|
else if ("10".equals(type) && yxFlag==0 && isFyszEnabled(recordMonth)) { copy.put("vipType","妇幼生殖学"); result.counts.computeIfPresent("fyszCount",(k,v)->v+1); }
|
||||||
if (copy.get("vipType") != null) {
|
if (copy.get("vipType") != null) {
|
||||||
result.resultList.add(copy);
|
result.resultList.add(copy);
|
||||||
result.total.add(map.get("tel").toString());
|
result.total.add(map.get("tel").toString());
|
||||||
@@ -555,6 +560,56 @@ public class StatisticsBusinessVipController {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String resolveRecordMonth(Map<String, Object> map, String date) {
|
||||||
|
if (date != null) {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
Object payTime = map.get("payTime");
|
||||||
|
if (payTime != null) {
|
||||||
|
String payTimeStr = payTime.toString();
|
||||||
|
return payTimeStr.length() >= 7 ? payTimeStr.substring(0, 7) : payTimeStr;
|
||||||
|
}
|
||||||
|
return MEDICAL_SUPER_CUTOFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> getMedicalSuperTypes(String recordMonth) {
|
||||||
|
if (recordMonth.compareTo(MEDICAL_SUPER_CUTOFF) < 0) {
|
||||||
|
return Arrays.asList("4", "5", "6", "9");
|
||||||
|
}
|
||||||
|
return Arrays.asList("4", "5", "6", "9", "10");
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isFyszEnabled(String recordMonth) {
|
||||||
|
return recordMonth.compareTo(MEDICAL_SUPER_CUTOFF) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, List<Integer>> buildReBuyRules(String date) {
|
||||||
|
Map<String, List<Integer>> reBuyRules = new HashMap<>();
|
||||||
|
if (date.compareTo(MEDICAL_SUPER_CUTOFF) < 0) {
|
||||||
|
reBuyRules.put("医学超级", Arrays.asList(4, 5, 6, 9));
|
||||||
|
} else {
|
||||||
|
reBuyRules.put("医学超级", Arrays.asList(4, 5, 6, 9, 10));
|
||||||
|
reBuyRules.put("妇幼生殖学", Arrays.asList(10));
|
||||||
|
}
|
||||||
|
reBuyRules.put("国学心理学超级", Arrays.asList(7, 8));
|
||||||
|
reBuyRules.put("中医学", Arrays.asList(4));
|
||||||
|
reBuyRules.put("针灸学", Arrays.asList(5));
|
||||||
|
reBuyRules.put("肿瘤学", Arrays.asList(6));
|
||||||
|
reBuyRules.put("国学", Arrays.asList(7));
|
||||||
|
reBuyRules.put("心理学", Arrays.asList(8));
|
||||||
|
reBuyRules.put("中西汇通学", Arrays.asList(9));
|
||||||
|
return reBuyRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BigDecimal calcGrowthRate(Object current, Object previous) {
|
||||||
|
BigDecimal currentVal = new BigDecimal(current.toString());
|
||||||
|
if (currentVal.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
BigDecimal previousVal = new BigDecimal(previous.toString());
|
||||||
|
return currentVal.subtract(previousVal).divide(currentVal, 4, RoundingMode.HALF_UP);
|
||||||
|
}
|
||||||
|
|
||||||
private void export(XSSFWorkbook wb,Sheet sheet,String fileName,int rowNum,HttpServletResponse response, String[] headers, String[] cellValues, List<Map<String,Object>> list){
|
private void export(XSSFWorkbook wb,Sheet sheet,String fileName,int rowNum,HttpServletResponse response, String[] headers, String[] cellValues, List<Map<String,Object>> list){
|
||||||
if (sheet!=null){
|
if (sheet!=null){
|
||||||
// 表头
|
// 表头
|
||||||
|
|||||||
@@ -367,9 +367,13 @@ public class StatisticsController {
|
|||||||
|
|
||||||
@RequestMapping("/getUserCourseBuyInfoTotal")
|
@RequestMapping("/getUserCourseBuyInfoTotal")
|
||||||
public R getUserCourseBuyInfoTotal(@RequestBody Map<String, Object> params) {
|
public R getUserCourseBuyInfoTotal(@RequestBody Map<String, Object> params) {
|
||||||
List<Map<String,Object>> tanxiaoTotal = userCourseBuyService.getUserCourseBuyInfoTotal(params.get("date").toString());
|
String date = params.get("date").toString();
|
||||||
List<Map<String,Object>> income = userCourseBuyService.getIncome(params.get("date").toString());
|
List<Map<String,Object>> tanxiaoTotal = userCourseBuyService.getUserCourseBuyInfoTotal(date);
|
||||||
return R.ok().put("tanxiaoTotal", tanxiaoTotal).put("income", income);
|
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(8).setCellValue("支付类型");
|
||||||
titleRow.createCell(9).setCellValue("支付时间");
|
titleRow.createCell(9).setCellValue("支付时间");
|
||||||
titleRow.createCell(10).setCellValue("订单编号");
|
titleRow.createCell(10).setCellValue("订单编号");
|
||||||
titleRow.createCell(11).setCellValue("支付宝号");
|
titleRow.createCell(11).setCellValue("订单类型");
|
||||||
titleRow.createCell(12).setCellValue("天数");
|
titleRow.createCell(12).setCellValue("支付宝号");
|
||||||
titleRow.createCell(13).setCellValue("金额");
|
titleRow.createCell(13).setCellValue("天数");
|
||||||
titleRow.createCell(14).setCellValue("备注");
|
titleRow.createCell(14).setCellValue("金额");
|
||||||
titleRow.createCell(15).setCellValue("开始摊销时间");
|
titleRow.createCell(15).setCellValue("备注");
|
||||||
titleRow.createCell(16).setCellValue("每日摊销");
|
titleRow.createCell(16).setCellValue("开始摊销时间");
|
||||||
titleRow.createCell(17).setCellValue("已摊销天数");
|
titleRow.createCell(17).setCellValue("每日摊销");
|
||||||
titleRow.createCell(18).setCellValue("本期天数");
|
titleRow.createCell(18).setCellValue("已摊销天数");
|
||||||
titleRow.createCell(19).setCellValue("已摊销金额");
|
titleRow.createCell(19).setCellValue("本期天数");
|
||||||
titleRow.createCell(20).setCellValue("本期摊销金额");
|
titleRow.createCell(20).setCellValue("已摊销金额");
|
||||||
titleRow.createCell(21).setCellValue("剩余金额");
|
titleRow.createCell(21).setCellValue("本期摊销金额");
|
||||||
|
titleRow.createCell(22).setCellValue("剩余金额");
|
||||||
|
titleRow.createCell(23).setCellValue("退款单号");
|
||||||
int cell = 1;
|
int cell = 1;
|
||||||
for (Map<String,Object> map : maps) {
|
for (Map<String,Object> map : maps) {
|
||||||
Row row = sheet.createRow(cell);
|
Row row = sheet.createRow(cell);
|
||||||
row.createCell(0).setCellValue(map.get("name").toString());
|
row.createCell(0).setCellValue(cellStr(map.get("name")));
|
||||||
row.createCell(1).setCellValue(map.get("tel").toString());
|
row.createCell(1).setCellValue(cellStr(map.get("tel")));
|
||||||
row.createCell(2).setCellValue(map.get("ctitle").toString());
|
row.createCell(2).setCellValue(cellStr(map.get("ctitle")));
|
||||||
row.createCell(3).setCellValue(map.get("cctitle").toString());
|
row.createCell(3).setCellValue(cellStr(map.get("cctitle")));
|
||||||
row.createCell(4).setCellValue(map.get("startTime").toString());
|
row.createCell(4).setCellValue(cellStr(map.get("startTime")));
|
||||||
row.createCell(5).setCellValue(map.get("endTime").toString());
|
row.createCell(5).setCellValue(cellStr(map.get("endTime")));
|
||||||
row.createCell(6).setCellValue(map.get("totalDays").toString());
|
row.createCell(6).setCellValue(cellStr(map.get("totalDays")));
|
||||||
row.createCell(7).setCellValue(map.get("type").toString());
|
row.createCell(7).setCellValue(cellStr(map.get("type")));
|
||||||
row.createCell(8).setCellValue(map.get("payType").toString());
|
row.createCell(8).setCellValue(cellStr(map.get("payType")));
|
||||||
row.createCell(9).setCellValue(map.get("payTime").toString());
|
row.createCell(9).setCellValue(cellStr(map.get("payTime")));
|
||||||
row.createCell(10).setCellValue(map.get("orderSn").toString());
|
row.createCell(10).setCellValue(cellStr(map.get("orderSn")));
|
||||||
row.createCell(11).setCellValue(map.get("zfbOrder")==null?"":map.get("zfbOrder").toString());
|
row.createCell(11).setCellValue(cellStr(map.get("orderStatus")));
|
||||||
row.createCell(12).setCellValue(map.get("days").toString());
|
row.createCell(12).setCellValue(cellStr(map.get("zfbOrder")));
|
||||||
row.createCell(13).setCellValue(map.get("fee").toString());
|
row.createCell(13).setCellValue(cellStr(map.get("days")));
|
||||||
row.createCell(14).setCellValue(map.get("remark").toString());
|
row.createCell(14).setCellValue(cellStr(map.get("fee")));
|
||||||
row.createCell(15).setCellValue(map.get("startTanxiaoTime")==null?"":map.get("startTanxiaoTime").toString());
|
row.createCell(15).setCellValue(cellStr(map.get("remark")));
|
||||||
row.createCell(16).setCellValue(map.get("dayAmount").toString());
|
row.createCell(16).setCellValue(cellStr(map.get("startTanxiaoTime")));
|
||||||
row.createCell(17).setCellValue(map.get("alreadyDay").toString());
|
row.createCell(17).setCellValue(cellStr(map.get("dayAmount")));
|
||||||
row.createCell(18).setCellValue(map.get("currentDay").toString());
|
row.createCell(18).setCellValue(cellStr(map.get("alreadyDay")));
|
||||||
row.createCell(19).setCellValue(map.get("alreadyTanxiao").toString());
|
row.createCell(19).setCellValue(cellStr(map.get("currentDay")));
|
||||||
row.createCell(20).setCellValue(map.get("currentTanxiao").toString());
|
row.createCell(20).setCellValue(cellStr(map.get("alreadyTanxiao")));
|
||||||
row.createCell(21).setCellValue(map.get("surplusTanxiao").toString());
|
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++;
|
cell++;
|
||||||
}
|
}
|
||||||
@@ -456,7 +464,8 @@ public class StatisticsController {
|
|||||||
public R getTransactionDetailsTotal(@RequestBody Map<String, Object> params) {
|
public R getTransactionDetailsTotal(@RequestBody Map<String, Object> params) {
|
||||||
Map<String,Object> map = transactionDetailsService.getUserSurplusPeanutCoin(params.get("date").toString()+" 23:59:59");
|
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");
|
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")
|
@RequestMapping("/getPhysicalBuyOrderInfoTotal")
|
||||||
public R getPhysicalBuyOrderInfoTotal(@RequestBody Map<String, Object> params) {
|
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);
|
return R.ok().put("total", list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -548,6 +558,7 @@ public class StatisticsController {
|
|||||||
titleRow.createCell(9).setCellValue("商品名称");
|
titleRow.createCell(9).setCellValue("商品名称");
|
||||||
titleRow.createCell(10).setCellValue("数量");
|
titleRow.createCell(10).setCellValue("数量");
|
||||||
titleRow.createCell(11).setCellValue("备注");
|
titleRow.createCell(11).setCellValue("备注");
|
||||||
|
titleRow.createCell(12).setCellValue("退款单号");
|
||||||
//序号,默认为1
|
//序号,默认为1
|
||||||
int cell = 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(4).setCellValue(map.get("zfbOrder")==null?"":map.get("zfbOrder").toString());
|
||||||
row.createCell(5).setCellValue(map.get("orderStatus").toString());
|
row.createCell(5).setCellValue(map.get("orderStatus").toString());
|
||||||
row.createCell(6).setCellValue(map.get("payType").toString());
|
row.createCell(6).setCellValue(map.get("payType").toString());
|
||||||
row.createCell(7).setCellValue(map.get("orderPrice").toString());
|
row.createCell(7).setCellValue(toAmount(map.get("orderPrice")).doubleValue());
|
||||||
row.createCell(8).setCellValue(map.get("price").toString());
|
row.createCell(8).setCellValue(toAmount(map.get("price")).doubleValue());
|
||||||
row.createCell(9).setCellValue(map.get("productName").toString());
|
row.createCell(9).setCellValue(map.get("productName").toString());
|
||||||
row.createCell(10).setCellValue(map.get("quantity").toString());
|
row.createCell(10).setCellValue(map.get("quantity").toString());
|
||||||
row.createCell(11).setCellValue(map.get("remark").toString());
|
row.createCell(11).setCellValue(map.get("remark").toString());
|
||||||
|
row.createCell(12).setCellValue(map.get("refund_no")!=null?map.get("refund_no").toString():"");
|
||||||
//序号自增
|
//序号自增
|
||||||
cell++;
|
cell++;
|
||||||
}
|
}
|
||||||
@@ -593,7 +605,39 @@ public class StatisticsController {
|
|||||||
|
|
||||||
@RequestMapping("/getUserVipLogInfoTotal")
|
@RequestMapping("/getUserVipLogInfoTotal")
|
||||||
public R getUserVipLogInfoTotal(@RequestBody Map<String, Object> params) {
|
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;
|
||||||
|
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);
|
return R.ok().put("total", map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -613,19 +657,21 @@ public class StatisticsController {
|
|||||||
titleRow.createCell(4).setCellValue("结束时间");
|
titleRow.createCell(4).setCellValue("结束时间");
|
||||||
titleRow.createCell(5).setCellValue("支付时间");
|
titleRow.createCell(5).setCellValue("支付时间");
|
||||||
titleRow.createCell(6).setCellValue("订单号");
|
titleRow.createCell(6).setCellValue("订单号");
|
||||||
titleRow.createCell(7).setCellValue("支付宝号");
|
titleRow.createCell(7).setCellValue("订单类型");
|
||||||
titleRow.createCell(8).setCellValue("支付方式");
|
titleRow.createCell(8).setCellValue("支付宝号");
|
||||||
titleRow.createCell(9).setCellValue("备注");
|
titleRow.createCell(9).setCellValue("支付方式");
|
||||||
titleRow.createCell(10).setCellValue("缴费金额");
|
titleRow.createCell(10).setCellValue("备注");
|
||||||
titleRow.createCell(11).setCellValue("摊销计算金额");
|
titleRow.createCell(11).setCellValue("缴费金额");
|
||||||
titleRow.createCell(12).setCellValue("总天数");
|
titleRow.createCell(12).setCellValue("摊销计算金额");
|
||||||
titleRow.createCell(13).setCellValue("每日摊销");
|
titleRow.createCell(13).setCellValue("总天数");
|
||||||
titleRow.createCell(14).setCellValue("已摊销天数");
|
titleRow.createCell(14).setCellValue("每日摊销");
|
||||||
titleRow.createCell(15).setCellValue("当月摊销天数");
|
titleRow.createCell(15).setCellValue("已摊销天数");
|
||||||
titleRow.createCell(16).setCellValue("未摊销天数");
|
titleRow.createCell(16).setCellValue("当月摊销天数");
|
||||||
titleRow.createCell(17).setCellValue("已摊销金额");
|
titleRow.createCell(17).setCellValue("未摊销天数");
|
||||||
titleRow.createCell(18).setCellValue("当月摊销金额");
|
titleRow.createCell(18).setCellValue("已摊销金额");
|
||||||
titleRow.createCell(19).setCellValue("剩余摊销金额");
|
titleRow.createCell(19).setCellValue("当月摊销金额");
|
||||||
|
titleRow.createCell(20).setCellValue("剩余摊销金额");
|
||||||
|
titleRow.createCell(21).setCellValue("退款单号");
|
||||||
//序号,默认为1
|
//序号,默认为1
|
||||||
int cell = 1;
|
int cell = 1;
|
||||||
//遍历
|
//遍历
|
||||||
@@ -638,19 +684,21 @@ public class StatisticsController {
|
|||||||
row.createCell(4).setCellValue(map.get("endTime").toString());
|
row.createCell(4).setCellValue(map.get("endTime").toString());
|
||||||
row.createCell(5).setCellValue(map.get("payTime").toString());
|
row.createCell(5).setCellValue(map.get("payTime").toString());
|
||||||
row.createCell(6).setCellValue(map.get("orderSn").toString());
|
row.createCell(6).setCellValue(map.get("orderSn").toString());
|
||||||
row.createCell(7).setCellValue(map.get("zfbOrder")==null?"":map.get("zfbOrder").toString());
|
row.createCell(7).setCellValue(map.get("orderStatus").toString());
|
||||||
row.createCell(8).setCellValue(map.get("payType").toString());
|
row.createCell(8).setCellValue(map.get("zfbOrder")==null?"":map.get("zfbOrder").toString());
|
||||||
row.createCell(9).setCellValue(map.get("remark").toString());
|
row.createCell(9).setCellValue(map.get("payType").toString());
|
||||||
row.createCell(10).setCellValue(map.get("price").toString());
|
row.createCell(10).setCellValue(map.get("remark").toString());
|
||||||
row.createCell(11).setCellValue(map.get("fee").toString());
|
row.createCell(11).setCellValue(map.get("price").toString());
|
||||||
row.createCell(12).setCellValue(map.get("totalDays").toString());
|
row.createCell(12).setCellValue(map.get("fee").toString());
|
||||||
row.createCell(13).setCellValue(map.get("dayAmount").toString());
|
row.createCell(13).setCellValue(map.get("totalDays").toString());
|
||||||
row.createCell(14).setCellValue(map.get("alreadyDays").toString());
|
row.createCell(14).setCellValue(map.get("dayAmount").toString());
|
||||||
row.createCell(15).setCellValue(map.get("currentDays").toString());
|
row.createCell(15).setCellValue(map.get("alreadyDays").toString());
|
||||||
row.createCell(16).setCellValue(map.get("notyetDays").toString());
|
row.createCell(16).setCellValue(map.get("currentDays").toString());
|
||||||
row.createCell(17).setCellValue(map.get("alreadyTanxiao").toString());
|
row.createCell(17).setCellValue(map.get("notyetDays").toString());
|
||||||
row.createCell(18).setCellValue(map.get("currentTanxiao").toString());
|
row.createCell(18).setCellValue(map.get("alreadyTanxiao").toString());
|
||||||
row.createCell(19).setCellValue(map.get("notyetTanxiao").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++;
|
cell++;
|
||||||
}
|
}
|
||||||
@@ -677,6 +725,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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -288,7 +288,11 @@ public class UserCertificateController {
|
|||||||
ClassEntity classEntity = classEntityService.getById(params.get("classId").toString());
|
ClassEntity classEntity = classEntityService.getById(params.get("classId").toString());
|
||||||
String type = params.get("type").toString();
|
String type = params.get("type").toString();
|
||||||
List<String> certificateNoList = new ArrayList<>();
|
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 pinyin = classCourseInfo.get("titleAbbr").toString();
|
||||||
|
|
||||||
String tels = params.get("tels").toString();
|
String tels = params.get("tels").toString();
|
||||||
@@ -309,26 +313,26 @@ public class UserCertificateController {
|
|||||||
userCertificate.setCertificateNo(certificateNo);
|
userCertificate.setCertificateNo(certificateNo);
|
||||||
userCertificate.setCourseId((Integer) classCourseInfo.get("courseId"));
|
userCertificate.setCourseId((Integer) classCourseInfo.get("courseId"));
|
||||||
|
|
||||||
if (StringUtils.isNotEmpty(user.getPhoto())&&StringUtils.isNotEmpty(user.getName())){
|
// if (StringUtils.isNotEmpty(user.getPhoto())&&StringUtils.isNotEmpty(user.getName())){
|
||||||
String startYear = DateUtil.year(classEntity.getStartTime())+"";
|
// String startYear = DateUtil.year(classEntity.getStartTime())+"";
|
||||||
String startMonth = DateUtil.month(classEntity.getStartTime())+1+"";
|
// String startMonth = DateUtil.month(classEntity.getStartTime())+1+"";
|
||||||
String startDay = DateUtil.dayOfMonth(classEntity.getStartTime())+"";
|
// String startDay = DateUtil.dayOfMonth(classEntity.getStartTime())+"";
|
||||||
String endYear = DateUtil.year(classEntity.getEndTime())+"";
|
// String endYear = DateUtil.year(classEntity.getEndTime())+"";
|
||||||
String endMonth = DateUtil.month(classEntity.getEndTime())+1+"";
|
// String endMonth = DateUtil.month(classEntity.getEndTime())+1+"";
|
||||||
String endDay = DateUtil.dayOfMonth(classEntity.getEndTime())+"";
|
// String endDay = DateUtil.dayOfMonth(classEntity.getEndTime())+"";
|
||||||
double keshiTotal = (double)classCourseInfo.get("keshi");
|
// double keshiTotal = (double)classCourseInfo.get("keshi");
|
||||||
String keshi = (keshiTotal+"").replace(".0","");
|
// String keshi = (keshiTotal+"").replace(".0","");
|
||||||
String courseTitle = classCourseInfo.get("courseTitle").toString();
|
// String courseTitle = classCourseInfo.get("courseTitle").toString();
|
||||||
if (courseTitle.contains("【")){
|
// if (courseTitle.contains("【")){
|
||||||
courseTitle = courseTitle.substring(0,courseTitle.indexOf("【"));
|
// courseTitle = courseTitle.substring(0,courseTitle.indexOf("【"));
|
||||||
}
|
// }
|
||||||
String[] des = {startYear,startMonth,startDay,endYear,endMonth,endDay,
|
// String[] des = {startYear,startMonth,startDay,endYear,endMonth,endDay,
|
||||||
classEntity.getTitle(),courseTitle,keshi};
|
// classEntity.getTitle(),courseTitle,keshi};
|
||||||
String[] edes = {classCourseInfo.get("courseETitle").toString(),keshi};
|
// String[] edes = {classCourseInfo.get("courseETitle").toString(),keshi};
|
||||||
String url = userCertificateService.generateCertificate(type,certificateNo,user.getPhoto(),user.getName(),
|
// String url = userCertificateService.generateCertificate(type,certificateNo,user.getPhoto(),user.getName(),
|
||||||
des, edes, endYear,endMonth,endDay);
|
// des, edes, endYear,endMonth,endDay);
|
||||||
userCertificate.setCertificateUrl(url);
|
// userCertificate.setCertificateUrl(url);
|
||||||
}
|
// }
|
||||||
userCertificateService.save(userCertificate);
|
userCertificateService.save(userCertificate);
|
||||||
certificateNoList.add(user.getTel());
|
certificateNoList.add(user.getTel());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ public class UserVipController {
|
|||||||
"5".equals(params.get("type").toString())?"开通针灸学VIP":
|
"5".equals(params.get("type").toString())?"开通针灸学VIP":
|
||||||
"6".equals(params.get("type").toString())?"开通肿瘤学VIP":
|
"6".equals(params.get("type").toString())?"开通肿瘤学VIP":
|
||||||
"7".equals(params.get("type").toString())?"开通国学VIP":
|
"7".equals(params.get("type").toString())?"开通国学VIP":
|
||||||
|
"10".equals(params.get("type").toString())?"妇幼生殖学VIP":
|
||||||
"8".equals(params.get("type").toString())?"开通心理学VIP":"开通中西汇通VIP";
|
"8".equals(params.get("type").toString())?"开通心理学VIP":"开通中西汇通VIP";
|
||||||
if(fee.compareTo(BigDecimal.ZERO)>0){
|
if(fee.compareTo(BigDecimal.ZERO)>0){
|
||||||
user.setPeanutCoin(user.getPeanutCoin().subtract(fee));
|
user.setPeanutCoin(user.getPeanutCoin().subtract(fee));
|
||||||
@@ -155,8 +156,8 @@ public class UserVipController {
|
|||||||
typeList.add(i);
|
typeList.add(i);
|
||||||
}
|
}
|
||||||
}else if ("1".equals(params.get("type").toString())) {//医学超级
|
}else if ("1".equals(params.get("type").toString())) {//医学超级
|
||||||
count = 4;
|
count = 5;
|
||||||
for (int i=4;i<8;i++){
|
for (int i=4;i<=10;i++){
|
||||||
if (i==7){
|
if (i==7){
|
||||||
i = 9;
|
i = 9;
|
||||||
}
|
}
|
||||||
@@ -221,7 +222,8 @@ public class UserVipController {
|
|||||||
"5".equals(params.get("type").toString())?"延期针灸学VIP":
|
"5".equals(params.get("type").toString())?"延期针灸学VIP":
|
||||||
"6".equals(params.get("type").toString())?"延期肿瘤学VIP":
|
"6".equals(params.get("type").toString())?"延期肿瘤学VIP":
|
||||||
"7".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){
|
if(fee.compareTo(BigDecimal.ZERO)>0){
|
||||||
user.setPeanutCoin(user.getPeanutCoin().subtract(fee));
|
user.setPeanutCoin(user.getPeanutCoin().subtract(fee));
|
||||||
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
|
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
|
||||||
@@ -249,8 +251,8 @@ public class UserVipController {
|
|||||||
List<Integer> typeList = new ArrayList<>();
|
List<Integer> typeList = new ArrayList<>();
|
||||||
int count = 1;
|
int count = 1;
|
||||||
if ("11".equals(params.get("type").toString())) {//超v
|
if ("11".equals(params.get("type").toString())) {//超v
|
||||||
count = 6;
|
count = 7;
|
||||||
for (int i=4;i<10;i++){
|
for (int i=4;i<=10;i++){
|
||||||
typeList.add(i);
|
typeList.add(i);
|
||||||
}
|
}
|
||||||
}else if ("12".equals(params.get("type").toString())) {//简易超v
|
}else if ("12".equals(params.get("type").toString())) {//简易超v
|
||||||
@@ -262,11 +264,12 @@ public class UserVipController {
|
|||||||
typeList.add(i);
|
typeList.add(i);
|
||||||
}
|
}
|
||||||
}else if ("1".equals(params.get("type").toString())) {//医学超级
|
}else if ("1".equals(params.get("type").toString())) {//医学超级
|
||||||
count = 4;
|
count = 5;
|
||||||
for (int i=4;i<8;i++){
|
for (int i=4;i<=10;i++){
|
||||||
if (i==7){
|
if (i==7){
|
||||||
i = 9;
|
i = 9;
|
||||||
}
|
}
|
||||||
|
log.info("=========000000===="+i);
|
||||||
typeList.add(i);
|
typeList.add(i);
|
||||||
}
|
}
|
||||||
}else if ("2".equals(params.get("type").toString())) {//国心超级
|
}else if ("2".equals(params.get("type").toString())) {//国心超级
|
||||||
|
|||||||
@@ -24,6 +24,12 @@ public interface UserCourseBuyService extends IService<UserCourseBuyEntity> {
|
|||||||
|
|
||||||
List<Map<String,Object>> getIncome(String date);
|
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>> getUserCourseBuyInfoTotal(String date);
|
||||||
|
|
||||||
List<Map<String,Object>> getUserCourseBuyInfo(String date);
|
List<Map<String,Object>> getUserCourseBuyInfo(String date);
|
||||||
|
|||||||
@@ -20,8 +20,11 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -186,6 +189,21 @@ public class UserCourseBuyServiceImpl extends ServiceImpl<UserCourseBuyDao, User
|
|||||||
return this.baseMapper.getIncome(date);
|
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
|
@Override
|
||||||
public List<Map<String, Object>> getUserCourseBuyInfoTotal(String date) {
|
public List<Map<String, Object>> getUserCourseBuyInfoTotal(String date) {
|
||||||
return this.baseMapper.getUserCourseBuyInfoTotal(date);
|
return this.baseMapper.getUserCourseBuyInfoTotal(date);
|
||||||
@@ -193,7 +211,178 @@ public class UserCourseBuyServiceImpl extends ServiceImpl<UserCourseBuyDao, User
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, Object>> getUserCourseBuyInfo(String date) {
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Map<String, Integer> refundChapterCountMap = new HashMap<>();
|
||||||
|
for (Map<String, Object> refund : refundMap.values()) {
|
||||||
|
String orderCourseKey = String.valueOf(refund.get("orderSn")) + "|" + String.valueOf(refund.get("ctitle"));
|
||||||
|
refundChapterCountMap.merge(orderCourseKey, 1, Integer::sum);
|
||||||
|
}
|
||||||
|
for (Map<String, Object> refund : refundMap.values()) {
|
||||||
|
String key = refundKey(refund);
|
||||||
|
if (matchedKeys.contains(key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Map<String, Object> adjustedRefund = new HashMap<>(refund);
|
||||||
|
String orderCourseKey = String.valueOf(refund.get("orderSn")) + "|" + String.valueOf(refund.get("ctitle"));
|
||||||
|
int chapterCount = refundChapterCountMap.getOrDefault(orderCourseKey, 1);
|
||||||
|
if (chapterCount > 1) {
|
||||||
|
BigDecimal dividedFee = toBigDecimal(refund.get("fee"))
|
||||||
|
.divide(BigDecimal.valueOf(chapterCount), 2, RoundingMode.HALF_UP);
|
||||||
|
adjustedRefund.put("fee", dividedFee);
|
||||||
|
}
|
||||||
|
String payMonth = getPayMonth(refund);
|
||||||
|
if (exportMonth.equals(payMonth)) {
|
||||||
|
Map<String, Object> paidRow = buildPaidRowFromRefund(adjustedRefund);
|
||||||
|
result.add(paidRow);
|
||||||
|
result.add(buildRefundRow(paidRow, adjustedRefund, date));
|
||||||
|
} else if (!payMonth.isEmpty() && payMonth.compareTo(exportMonth) < 0) {
|
||||||
|
result.add(buildRefundRow(buildBaseRowFromRefund(adjustedRefund), adjustedRefund, 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
|
@Override
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class MedicalLabelAndMarketController {
|
|||||||
if (params.containsKey("medicineMarketId")&&!"".equals(params.get("medicineMarketId").toString())){
|
if (params.containsKey("medicineMarketId")&&!"".equals(params.get("medicineMarketId").toString())){
|
||||||
wrapper.eq(ShopProductToMedicineMarket::getMedicineMarketId,params.get("medicineMarketId").toString());
|
wrapper.eq(ShopProductToMedicineMarket::getMedicineMarketId,params.get("medicineMarketId").toString());
|
||||||
}
|
}
|
||||||
wrapper.orderByAsc(ShopProductToMedicineMarket::getSort);
|
wrapper.orderByDesc(ShopProductToMedicineMarket::getSort);
|
||||||
Page<ShopProduct> page = productService.page(new Page<>(
|
Page<ShopProduct> page = productService.page(new Page<>(
|
||||||
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
|
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
|
||||||
for (ShopProduct shopProduct:page.getRecords()){
|
for (ShopProduct shopProduct:page.getRecords()){
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
|
|||||||
payWechatOrderService.updateById(payWechatOrderEntity);
|
payWechatOrderService.updateById(payWechatOrderEntity);
|
||||||
// 根据订单号,做幂等处理,并且在对业务数据进行状态检查和处理之前,要采用数据锁进行并发控制,以避免函数重入造成的数据混乱
|
// 根据订单号,做幂等处理,并且在对业务数据进行状态检查和处理之前,要采用数据锁进行并发控制,以避免函数重入造成的数据混乱
|
||||||
BuyOrder order = this.buyOrderService.getOne(new QueryWrapper<BuyOrder>().eq("order_sn", orderNo));
|
BuyOrder order = this.buyOrderService.getOne(new QueryWrapper<BuyOrder>().eq("order_sn", orderNo));
|
||||||
if ("3".equals(order.getOrderStatus())){
|
if ("3".equals(order.getOrderStatus())||"6".equals(order.getOrderStatus())||"7".equals(order.getOrderStatus())){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//使用优惠券
|
//使用优惠券
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
left join shop_product sp on sp.product_id = bop.product_id
|
left join shop_product sp on sp.product_id = bop.product_id
|
||||||
where
|
where
|
||||||
( u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1) and (bo.payment_method='1' or bo.payment_method='2') and bo.create_time>='2026-05-06 00:00:00') )
|
( u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1) and (bo.payment_method='1' or bo.payment_method='2') and bo.create_time>='2026-05-06 00:00:00') )
|
||||||
and bo.order_status in (1,2,3,4) and sp.goods_type != '05' and bo.real_money > 0
|
and bo.order_status in (1,2,3,4,6) and sp.goods_type != '05' and bo.real_money > 0
|
||||||
<if test="orderType != null and orderType!= ''">
|
<if test="orderType != null and orderType!= ''">
|
||||||
<if test="orderType == 'lsorder' ">
|
<if test="orderType == 'lsorder' ">
|
||||||
and (bo.payment_method = '1' or (bo.payment_method = '2' and bo.order_id >= 37867))
|
and (bo.payment_method = '1' or (bo.payment_method = '2' and bo.order_id >= 37867))
|
||||||
@@ -90,7 +90,47 @@
|
|||||||
) s
|
) s
|
||||||
group by payType
|
group by payType
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getRefund" resultType="map">
|
||||||
|
select payType,count(1) count,SUM(price) totalPrice from (
|
||||||
|
select q.*,pzo.trade_no zfbOrder
|
||||||
|
from (
|
||||||
|
select t.createTime,t.name,t.tel,t.orderSn,t.orderStatus,t.payType,t.refundFee,
|
||||||
|
t.refundFee-(select IF(SUM(if(sp2.activity_price<sp2.price,sp2.activity_price,sp2.price)) is NULL,0,SUM(if(sp2.activity_price<sp2.price,sp2.activity_price,sp2.price))) from shop_product sp2 where sp2.goods_type = '05' and sp2.product_id in (GROUP_CONCAT(sp.product_id SEPARATOR ','))) price,
|
||||||
|
GROUP_CONCAT(sp.product_name SEPARATOR ', ') productName,t.remark
|
||||||
|
from (
|
||||||
|
select bo.order_id,DATE_FORMAT(bor.create_time,'%Y-%m-%d %H:%i:%s') createTime,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,bo.order_sn orderSn,
|
||||||
|
IF(bo.payment_method=1,'微信',IF(bo.payment_method=2,'支付宝',IF(bo.payment_method=4,'天医币','0'))) payType,
|
||||||
|
'已退款' orderStatus,bor.fee refundFee,if(bo.remark like '%退%',bo.remark,'') remark
|
||||||
|
from buy_order_refund bor
|
||||||
|
inner join buy_order bo on bo.order_id = bor.order_id and bo.del_flag = 0
|
||||||
|
left join user u on u.id = bo.user_id
|
||||||
|
left join buy_order_product bop on bop.order_id = bo.order_id
|
||||||
|
left join shop_product sp on sp.product_id = bop.product_id
|
||||||
|
where
|
||||||
|
( u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1) and (bo.payment_method='1' or bo.payment_method='2') and bo.create_time>='2026-05-06 00:00:00') )
|
||||||
|
and bo.order_status = '6' and sp.goods_type != '05' and bo.real_money > 0
|
||||||
|
<if test="orderType != null and orderType!= ''">
|
||||||
|
<if test="orderType == 'lsorder' ">
|
||||||
|
and (bo.payment_method = '1' or (bo.payment_method = '2' and bo.order_id >= 37867))
|
||||||
|
and bo.order_type = 'lsorder'
|
||||||
|
</if>
|
||||||
|
<if test="orderType == 'order' ">
|
||||||
|
and (bo.order_type = 'order'
|
||||||
|
or (bo.order_type = 'lsorder' and bo.payment_method = '4')
|
||||||
|
or (bo.order_type = 'lsorder' and bo.payment_method = '2' and bo.order_id < 37867))
|
||||||
|
</if>
|
||||||
|
</if>
|
||||||
|
and DATE_FORMAT(bor.create_time,'%Y-%m') = SUBSTR(#{date},1,7)
|
||||||
|
group by bo.order_sn
|
||||||
|
) t
|
||||||
|
left join buy_order_product bop on bop.order_id = t.order_id
|
||||||
|
left join shop_product sp on sp.product_id = bop.product_id
|
||||||
|
group by t.orderSn
|
||||||
|
) q
|
||||||
|
left join pay_zfb_order pzo on pzo.relevanceOid = q.orderSn and pzo.trade_no is not null
|
||||||
|
) s
|
||||||
|
group by payType
|
||||||
|
</select>
|
||||||
<select id="exportPhysicalBuyOrderInfo" resultType="map">
|
<select id="exportPhysicalBuyOrderInfo" resultType="map">
|
||||||
select q.*,pzo.trade_no zfbOrder
|
select q.*,pzo.trade_no zfbOrder
|
||||||
from (
|
from (
|
||||||
@@ -110,7 +150,7 @@
|
|||||||
and bo.order_status in (1,2,3,4,6) and sp.goods_type != '05' and bo.real_money > 0
|
and bo.order_status in (1,2,3,4,6) and sp.goods_type != '05' and bo.real_money > 0
|
||||||
<if test="orderType != null and orderType!= ''">
|
<if test="orderType != null and orderType!= ''">
|
||||||
<if test="orderType == 'lsorder' ">
|
<if test="orderType == 'lsorder' ">
|
||||||
and (bo.payment_method = '1' or (bo.payment_method = '2' and bo.order_id >37867))
|
and (bo.payment_method = '1' or (bo.payment_method = '2' and bo.order_id >= 37867))
|
||||||
and bo.order_type = 'lsorder'
|
and bo.order_type = 'lsorder'
|
||||||
</if>
|
</if>
|
||||||
<if test="orderType == 'order' ">
|
<if test="orderType == 'order' ">
|
||||||
@@ -128,6 +168,44 @@
|
|||||||
) q
|
) q
|
||||||
left join pay_zfb_order pzo on pzo.relevanceOid = q.orderSn and pzo.trade_no is not null
|
left join pay_zfb_order pzo on pzo.relevanceOid = q.orderSn and pzo.trade_no is not null
|
||||||
</select>
|
</select>
|
||||||
|
<select id="exportPhysicalBuyOrderRefundInfo" resultType="map">
|
||||||
|
select q.*,pzo.trade_no zfbOrder
|
||||||
|
from (
|
||||||
|
select t.createTime,t.name,t.tel,t.orderSn,t.orderStatus,t.payType,t.orderPrice,
|
||||||
|
t.orderPrice-(select IF(SUM(if(sp2.activity_price<sp2.price,sp2.activity_price,sp2.price)) is NULL,0,SUM(if(sp2.activity_price<sp2.price,sp2.activity_price,sp2.price))) from shop_product sp2 where sp2.goods_type = '05' and sp2.product_id in (GROUP_CONCAT(sp.product_id SEPARATOR ','))) price,
|
||||||
|
GROUP_CONCAT(sp.product_name SEPARATOR ', ') productName,IF(count(1)=1,bop.quantity,'') quantity,t.remark,t.refund_no
|
||||||
|
from (
|
||||||
|
select bo.order_id,DATE_FORMAT(bor.create_time,'%Y-%m-%d %H:%i:%s') createTime,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,bo.order_sn orderSn,
|
||||||
|
IF(bo.payment_method=1,'微信',IF(bo.payment_method=2,'支付宝',IF(bo.payment_method=4,'天医币','0'))) payType,
|
||||||
|
'已退款' orderStatus,bor.fee orderPrice,if(bo.remark like '%退%',bo.remark,'') remark,IFNULL(bor.wx_refund_no,bor.refund_no) as refund_no
|
||||||
|
from buy_order_refund bor
|
||||||
|
inner join buy_order bo on bo.order_id = bor.order_id and bo.del_flag = 0
|
||||||
|
left join user u on u.id = bo.user_id
|
||||||
|
left join buy_order_product bop on bop.order_id = bo.order_id
|
||||||
|
left join shop_product sp on sp.product_id = bop.product_id
|
||||||
|
where
|
||||||
|
( u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1) and (bo.payment_method='1' or bo.payment_method='2') and bo.create_time>='2026-05-06 00:00:00') )
|
||||||
|
and bo.order_status = '6' and sp.goods_type != '05' and bo.real_money > 0
|
||||||
|
<if test="orderType != null and orderType!= ''">
|
||||||
|
<if test="orderType == 'lsorder' ">
|
||||||
|
and (bo.payment_method = '1' or (bo.payment_method = '2' and bo.order_id >= 37867))
|
||||||
|
and bo.order_type = 'lsorder'
|
||||||
|
</if>
|
||||||
|
<if test="orderType == 'order' ">
|
||||||
|
and (bo.order_type = 'order'
|
||||||
|
or (bo.order_type = 'lsorder' and bo.payment_method = '4')
|
||||||
|
or (bo.order_type = 'lsorder' and bo.payment_method = '2' and bo.order_id < 37867))
|
||||||
|
</if>
|
||||||
|
</if>
|
||||||
|
and DATE_FORMAT(bor.create_time,'%Y-%m') = SUBSTR(#{date},1,7)
|
||||||
|
group by bo.order_sn
|
||||||
|
) t
|
||||||
|
left join buy_order_product bop on bop.order_id = t.order_id
|
||||||
|
left join shop_product sp on sp.product_id = bop.product_id
|
||||||
|
group by t.orderSn
|
||||||
|
) q
|
||||||
|
left join pay_zfb_order pzo on pzo.relevanceOid = q.orderSn and pzo.trade_no is not null
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<select id="queryListByOrderIds" resultType="com.peanut.modules.common.entity.BuyOrder">
|
<select id="queryListByOrderIds" resultType="com.peanut.modules.common.entity.BuyOrder">
|
||||||
|
|||||||
@@ -39,7 +39,43 @@
|
|||||||
from transaction_details td
|
from transaction_details td
|
||||||
left join user u on u.id = td.user_id
|
left join user u on u.id = td.user_id
|
||||||
where DATE_FORMAT(td.create_time,'%Y-%m') = SUBSTR(#{date},1,7)
|
where DATE_FORMAT(td.create_time,'%Y-%m') = SUBSTR(#{date},1,7)
|
||||||
and td.user_id not in (select id from user where tester_flag = 1)
|
and td.user_id not in (select id from user where tester_flag = 1) and u.del_flag=0
|
||||||
|
) t
|
||||||
|
left join buy_order bo on bo.order_sn = t.payNo
|
||||||
|
left join buy_order_product bop on bop.order_id = bo.order_id
|
||||||
|
left join shop_product sp on sp.product_id = bop.product_id
|
||||||
|
left join vip_buy_config vbc on vbc.id = bo.vip_buy_config_id
|
||||||
|
group by t.id
|
||||||
|
order by t.createTime
|
||||||
|
) q
|
||||||
|
left join pay_zfb_order pzo on pzo.relevanceOid = q.payNo and pzo.trade_no is not null
|
||||||
|
) s
|
||||||
|
group by type,payMethod,goodsType
|
||||||
|
</select>
|
||||||
|
<select id="getRefundTransactionDetails" resultType="map">
|
||||||
|
select type,payMethod,goodsType,SUM(changeAmount) amount
|
||||||
|
from (
|
||||||
|
select q.*,pzo.trade_no zfbOrder
|
||||||
|
from (
|
||||||
|
select t.*,
|
||||||
|
IF(bo.order_type='relearn','课程',
|
||||||
|
IF(bo.order_type='trainingClass','培训班',
|
||||||
|
IF(bo.order_type='vip','VIP',
|
||||||
|
IF((GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '%,05%') or (GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '05,%') or (GROUP_CONCAT(sp.goods_type SEPARATOR ',')='05'),
|
||||||
|
IF((GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '%,05%') or (GROUP_CONCAT(sp.goods_type SEPARATOR ',') like '05,%'),'实物、课程','课程'),
|
||||||
|
'实物')))) goodsType,
|
||||||
|
IF(IF(GROUP_CONCAT(sp.product_name SEPARATOR ',') is NULL,IF(bo.order_type='vip',vbc.title,bo.remark),GROUP_CONCAT(sp.product_name SEPARATOR ',')) is NULL,'',IF(GROUP_CONCAT(sp.product_name SEPARATOR ',') is NULL,IF(bo.order_type='vip',vbc.title,bo.remark),GROUP_CONCAT(sp.product_name SEPARATOR ','))) productName
|
||||||
|
from (
|
||||||
|
select bor.id,DATE_FORMAT(bor.create_time,'%Y-%m-%d %H:%i:%s') createTime,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel
|
||||||
|
,'订单退款' type,'天医币' payMethod,bo.order_sn payNo
|
||||||
|
,bor.fee changeAmount,IF(bor.remark is NULL,'',bor.remark) note
|
||||||
|
from buy_order_refund bor
|
||||||
|
inner join buy_order bo on bo.order_id = bor.order_id and bo.del_flag = 0
|
||||||
|
left join user u on u.id = bor.user_id
|
||||||
|
where DATE_FORMAT(bor.create_time,'%Y-%m') = SUBSTR(#{date},1,7)
|
||||||
|
and bo.order_status = '6'
|
||||||
|
and bo.payment_method = '4'
|
||||||
|
and bor.user_id not in (select id from user where tester_flag = 1)
|
||||||
) t
|
) t
|
||||||
left join buy_order bo on bo.order_sn = t.payNo
|
left join buy_order bo on bo.order_sn = t.payNo
|
||||||
left join buy_order_product bop on bop.order_id = bo.order_id
|
left join buy_order_product bop on bop.order_id = bo.order_id
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
select r.*
|
select r.*
|
||||||
,ROUND(fee-alreadyTanxiao-currentTanxiao,2) surplusTanxiao
|
,ROUND(fee-alreadyTanxiao-currentTanxiao,2) surplusTanxiao
|
||||||
from (select e.*
|
from (select e.*
|
||||||
,ROUND(if(alreadyDay+currentDay>=days,fee-alreadyTanxiao,if(alreadyTanxiao+currentDay*dayAmount>fee,fee-alreadyTanxiao,currentDay*dayAmount)),2) currentTanxiao
|
,ROUND(if(CHAR_LENGTH(IFNULL(endTime,'')) < 10, if(alreadyDay+currentDay>=days,fee-alreadyTanxiao,if(alreadyTanxiao+currentDay*dayAmount>fee,fee-alreadyTanxiao,currentDay*dayAmount)), if(DATEDIFF(#{date}, LEFT(endTime,10)) >= 0, 0, if(alreadyDay+currentDay>=days,fee-alreadyTanxiao,if(alreadyTanxiao+currentDay*dayAmount>fee,fee-alreadyTanxiao,currentDay*dayAmount)))),2) currentTanxiao
|
||||||
from (select w.name,w.tel,w.ctitle,w.cctitle,if(w.startTime is null,'',w.startTime) startTime,if(w.endTime is null,'',w.endTime) endTime,w.totalDays
|
from (select w.name,w.tel,w.ctitle,w.cctitle,if(w.startTime is null,'',w.startTime) startTime,if(w.endTime is null,'',w.endTime) endTime,w.totalDays
|
||||||
,w.type,w.payType,w.payTime,w.orderSn,w.zfbOrder,w.days,w.fee,w.remark,w.dayAmount,w.alreadyDay,w.currentDay
|
,w.type,w.payType,w.payTime,w.orderSn,w.zfbOrder,w.days,w.fee,w.remark,w.dayAmount,w.alreadyDay,w.currentDay
|
||||||
,IF(beginDay=0,startTime,IF(startTime is NULL,startTime,DATE_ADD(startTime,INTERVAL beginDay-1 day))) startTanxiaoTime
|
,IF(beginDay=0,startTime,IF(startTime is NULL,startTime,DATE_ADD(startTime,INTERVAL beginDay-1 day))) startTanxiaoTime
|
||||||
,ROUND(if(alreadyDay=days,fee,if(alreadyDayAmount>fee,fee,alreadyDayAmount)),2) alreadyTanxiao
|
,ROUND(if(CHAR_LENGTH(IFNULL(endTime,'')) < 10, if(alreadyDay=days,fee,if(alreadyDayAmount>fee,fee,alreadyDayAmount)), if(DATEDIFF(#{date}, LEFT(endTime,10)) >= 0, fee, if(alreadyDay=days,fee,if(alreadyDayAmount>fee,fee,alreadyDayAmount)))),2) alreadyTanxiao
|
||||||
from (
|
from (
|
||||||
select q.*,alreadyDay*dayAmount alreadyDayAmount
|
select q.*,alreadyDay*dayAmount alreadyDayAmount
|
||||||
,IF(days-alreadyDay=0,0,IF(beginDay=0,IF(startTime is NULL,0,IF(days-alreadyDay>=monthDays,if(DATE_FORMAT(startTime,'%Y-%m')=SUBSTR(#{date},1,7),DATEDIFF(#{date},startTime)+1,if(DATE_FORMAT(startTime,'%Y-%m')>SUBSTR(#{date},1,7),0,monthDays)),if(DATE_FORMAT(startTime, '%Y-%m')=SUBSTR(#{date},1,7),if(DATEDIFF(#{date},startTime)+1>days,days,DATEDIFF(#{date},startTime)+1),if(DATE_FORMAT(startTime, '%Y-%m') < SUBSTR(#{date},1,7),days-alreadyDay,0)))), if(alreadyTotalDay+monthDays>beginDay,if(alreadyDay>0,if(days-alreadyDay>monthDays,monthDays,monthDays-(days-alreadyDay)),monthDays-(totalDays-days-alreadyTotalDay)),0) )) currentDay
|
,IF(days-alreadyDay=0,0,IF(beginDay=0,IF(startTime is NULL,0,IF(days-alreadyDay>=monthDays,if(DATE_FORMAT(startTime,'%Y-%m')=SUBSTR(#{date},1,7),DATEDIFF(#{date},startTime)+1,if(DATE_FORMAT(startTime,'%Y-%m')>SUBSTR(#{date},1,7),0,monthDays)),if(DATE_FORMAT(startTime, '%Y-%m')=SUBSTR(#{date},1,7),if(DATEDIFF(#{date},startTime)+1>days,days,DATEDIFF(#{date},startTime)+1),if(DATE_FORMAT(startTime, '%Y-%m') < SUBSTR(#{date},1,7),days-alreadyDay,0)))), if(alreadyTotalDay+monthDays>beginDay,if(alreadyDay>0,if(days-alreadyDay>monthDays,monthDays,monthDays-(days-alreadyDay)),monthDays-(totalDays-days-alreadyTotalDay)),0) )) currentDay
|
||||||
@@ -42,12 +42,130 @@
|
|||||||
|
|
||||||
<select id="getIncome" resultType="map">
|
<select id="getIncome" resultType="map">
|
||||||
select pay_type, SUM(fee) fee
|
select pay_type, SUM(fee) fee
|
||||||
from user_course_buy_log
|
from (
|
||||||
where DATE_FORMAT(pay_time,'%Y-%m') = SUBSTR(#{date},1,7) and del_flag = 0
|
select ucbl.pay_type, ucbl.fee
|
||||||
and user_id not in (select id from user where tester_flag = 1)
|
from user_course_buy_log ucbl
|
||||||
|
left join buy_order bo on bo.order_sn = ucbl.order_sn
|
||||||
|
where DATE_FORMAT(ucbl.pay_time,'%Y-%m') = SUBSTR(#{date},1,7) and ucbl.del_flag = 0
|
||||||
|
and (ucbl.user_id not in (select id from user where tester_flag = 1) or ( ucbl.user_id in (select id from user where tester_flag = 1) and ucbl.pay_type in ('微信','支付宝') and ucbl.create_time>='2026-05-06 00:00:00'))
|
||||||
|
union all
|
||||||
|
select IF(bo.payment_method='1','微信',IF(bo.payment_method='2','支付宝',IF(bo.payment_method='4','天医币','其他'))) pay_type,
|
||||||
|
bo.real_money fee
|
||||||
|
from buy_order bo
|
||||||
|
where bo.order_type = 'relearn' and bo.del_flag = 0
|
||||||
|
and bo.order_status not in ('5','6')
|
||||||
|
and DATE_FORMAT(IF(bo.success_time is null,bo.create_time,bo.success_time),'%Y-%m') = SUBSTR(#{date},1,7)
|
||||||
|
and not exists (
|
||||||
|
select 1 from user_course_buy_log ucbl
|
||||||
|
where ucbl.order_sn = bo.order_sn and ucbl.del_flag = 0
|
||||||
|
)
|
||||||
|
and (bo.user_id not in (select id from user where tester_flag = 1)
|
||||||
|
or (bo.user_id in (select id from user where tester_flag = 1) and bo.payment_method in ('1','2') and bo.create_time>='2026-05-06 00:00:00'))
|
||||||
|
) t
|
||||||
GROUP BY pay_type
|
GROUP BY pay_type
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getRefund" resultType="map">
|
||||||
|
select pay_type,SUM(fee) fee
|
||||||
|
from (
|
||||||
|
select IF(bo.payment_method='1','App微信',IF(bo.payment_method='2','App支付宝',IF(bo.payment_method='4','App天医币','其他'))) pay_type,
|
||||||
|
bor.fee
|
||||||
|
from buy_order_refund bor
|
||||||
|
inner join buy_order bo on bo.order_id = bor.order_id and bo.del_flag = 0
|
||||||
|
where bo.order_status = '6'
|
||||||
|
and DATE_FORMAT(bor.create_time,'%Y-%m') = SUBSTR(#{date},1,7)
|
||||||
|
and (bo.user_id not in (select id from user where tester_flag = 1)
|
||||||
|
or (bo.user_id in (select id from user where tester_flag = 1) and bo.payment_method in ('1','2') and bo.create_time>='2026-05-06 00:00:00'))
|
||||||
|
and (bo.order_type = 'relearn' or exists (
|
||||||
|
select 1 from buy_order_product bop
|
||||||
|
inner join shop_product sp on sp.product_id = bop.product_id
|
||||||
|
where bop.order_id = bo.order_id and sp.goods_type = '05'
|
||||||
|
))
|
||||||
|
) t
|
||||||
|
GROUP BY pay_type
|
||||||
|
</select>
|
||||||
|
<select id="getSameMonthRefund" resultType="map">
|
||||||
|
select pay_type,SUM(fee) fee
|
||||||
|
from (
|
||||||
|
select IF(bo.payment_method='1','微信',IF(bo.payment_method='2','支付宝',IF(bo.payment_method='4','天医币','其他'))) pay_type,
|
||||||
|
bor.fee
|
||||||
|
from buy_order_refund bor
|
||||||
|
inner join buy_order bo on bo.order_id = bor.order_id and bo.del_flag = 0
|
||||||
|
where bo.order_status = '6'
|
||||||
|
and DATE_FORMAT(bor.create_time,'%Y-%m') = SUBSTR(#{date},1,7)
|
||||||
|
and DATE_FORMAT(IF(bo.success_time is null,bo.create_time,bo.success_time),'%Y-%m') = SUBSTR(#{date},1,7)
|
||||||
|
and (bo.user_id not in (select id from user where tester_flag = 1)
|
||||||
|
or (bo.user_id in (select id from user where tester_flag = 1) and bo.payment_method in ('1','2') and bo.create_time>='2026-05-06 00:00:00'))
|
||||||
|
and (bo.order_type = 'relearn' or exists (
|
||||||
|
select 1 from buy_order_product bop
|
||||||
|
inner join shop_product sp on sp.product_id = bop.product_id
|
||||||
|
where bop.order_id = bo.order_id and sp.goods_type = '05'
|
||||||
|
))
|
||||||
|
) t
|
||||||
|
GROUP BY pay_type
|
||||||
|
</select>
|
||||||
|
<select id="getRefundInfo" resultType="map">
|
||||||
|
select IFNULL(bor.wx_refund_no,bor.refund_no) as refund_no,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,
|
||||||
|
IFNULL(c.title,IFNULL(sp.product_name,'')) ctitle,IFNULL(cc.title,'') cctitle,
|
||||||
|
IFNULL(spc.days,0) totalDays,'' startTime,'' endTime,
|
||||||
|
IF(bo.order_type='relearn','复读','order') type,
|
||||||
|
IF(bo.payment_method='1','微信',IF(bo.payment_method='2','支付宝',IF(bo.payment_method='4','天医币','其他'))) payType,
|
||||||
|
DATE_FORMAT(IF(bo.success_time is null,bo.create_time,bo.success_time),'%Y-%m-%d %H:%i:%s') payTime,
|
||||||
|
bo.order_sn orderSn,pzo.trade_no zfbOrder,
|
||||||
|
0 beginDay,IFNULL(spc.days,0) days,
|
||||||
|
ROUND(
|
||||||
|
bor.fee / (
|
||||||
|
case
|
||||||
|
when bo.order_type='relearn' then
|
||||||
|
IFNULL((
|
||||||
|
select count(1)
|
||||||
|
from shop_product_course spc2
|
||||||
|
where spc2.product_id = (
|
||||||
|
case
|
||||||
|
when bo.remark is null or bo.remark = '' then null
|
||||||
|
else cast(SUBSTRING_INDEX(bo.remark, ',', 1) as unsigned)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
and spc2.del_flag = 0
|
||||||
|
),1)
|
||||||
|
else
|
||||||
|
IFNULL((
|
||||||
|
select count(1)
|
||||||
|
from buy_order_product bop2
|
||||||
|
inner join shop_product sp2 on sp2.product_id = bop2.product_id
|
||||||
|
where bop2.order_id = bo.order_id and sp2.goods_type = '05'
|
||||||
|
),1)
|
||||||
|
end
|
||||||
|
),2
|
||||||
|
) fee,
|
||||||
|
if(bo.remark like '%退%',bo.remark,if(bor.remark is null,'',bor.remark)) remark,
|
||||||
|
DATE_FORMAT(bor.create_time,'%Y-%m-%d %H:%i:%s') refundTime,
|
||||||
|
'已退款' orderStatus
|
||||||
|
from buy_order_refund bor
|
||||||
|
inner join buy_order bo on bo.order_id = bor.order_id and bo.del_flag = 0
|
||||||
|
left join buy_order_product bop on bop.order_id = bo.order_id and bo.order_type <> 'relearn'
|
||||||
|
left join shop_product sp
|
||||||
|
on sp.product_id = (
|
||||||
|
case
|
||||||
|
when bo.order_type='relearn' then
|
||||||
|
case
|
||||||
|
when bo.remark is null or bo.remark = '' then null
|
||||||
|
else cast(SUBSTRING_INDEX(bo.remark, ',', 1) as unsigned)
|
||||||
|
end
|
||||||
|
else bop.product_id
|
||||||
|
end
|
||||||
|
)
|
||||||
|
and sp.goods_type = '05'
|
||||||
|
left join shop_product_course spc on spc.product_id = sp.product_id and spc.del_flag = 0
|
||||||
|
left join course c on c.id = spc.course_id
|
||||||
|
left join course_catalogue cc on cc.id = spc.catalogue_id
|
||||||
|
left join user u on u.id = bo.user_id
|
||||||
|
left join pay_zfb_order pzo on pzo.relevanceOid = bo.order_sn and pzo.trade_no is not null
|
||||||
|
where bo.order_status = '6'
|
||||||
|
and DATE_FORMAT(bor.create_time,'%Y-%m') = SUBSTR(#{date},1,7)
|
||||||
|
and (bo.user_id not in (select id from user where tester_flag = 1)
|
||||||
|
or (bo.user_id in (select id from user where tester_flag = 1) and bo.payment_method in ('1','2') and bo.create_time>='2026-05-06 00:00:00'))
|
||||||
|
order by bor.create_time asc
|
||||||
|
</select>
|
||||||
<select id="getUserCourseBuyInfoTotal" resultType="map">
|
<select id="getUserCourseBuyInfoTotal" resultType="map">
|
||||||
select if(ROUND(SUM(fee),2) is null,0,ROUND(SUM(fee),2)) fee,
|
select if(ROUND(SUM(fee),2) is null,0,ROUND(SUM(fee),2)) fee,
|
||||||
if(ROUND(SUM(alreadyTanxiao),2) is null,0,ROUND(SUM(alreadyTanxiao),2)) alreadyTanxiao,
|
if(ROUND(SUM(alreadyTanxiao),2) is null,0,ROUND(SUM(alreadyTanxiao),2)) alreadyTanxiao,
|
||||||
@@ -57,11 +175,11 @@
|
|||||||
select r.*
|
select r.*
|
||||||
,ROUND(fee-alreadyTanxiao-currentTanxiao,2) surplusTanxiao
|
,ROUND(fee-alreadyTanxiao-currentTanxiao,2) surplusTanxiao
|
||||||
from (select e.*
|
from (select e.*
|
||||||
,ROUND(if(alreadyDay+currentDay>=days,fee-alreadyTanxiao,if(alreadyTanxiao+currentDay*dayAmount>fee,fee-alreadyTanxiao,currentDay*dayAmount)),2) currentTanxiao
|
,ROUND(if(CHAR_LENGTH(IFNULL(endTime,'')) < 10, if(alreadyDay+currentDay>=days,fee-alreadyTanxiao,if(alreadyTanxiao+currentDay*dayAmount>fee,fee-alreadyTanxiao,currentDay*dayAmount)), if(DATEDIFF(#{date}, LEFT(endTime,10)) >= 0, 0, if(alreadyDay+currentDay>=days,fee-alreadyTanxiao,if(alreadyTanxiao+currentDay*dayAmount>fee,fee-alreadyTanxiao,currentDay*dayAmount)))),2) currentTanxiao
|
||||||
from (select w.name,w.tel,w.ctitle,w.cctitle,if(w.startTime is null,'',w.startTime) startTime,if(w.endTime is null,'',w.endTime) endTime,w.totalDays
|
from (select w.name,w.tel,w.ctitle,w.cctitle,if(w.startTime is null,'',w.startTime) startTime,if(w.endTime is null,'',w.endTime) endTime,w.totalDays
|
||||||
,w.type,w.payType,w.payTime,w.orderSn,w.zfbOrder,w.days,w.fee,w.remark,w.dayAmount,w.alreadyDay,w.currentDay
|
,w.type,w.payType,w.payTime,w.orderSn,w.zfbOrder,w.days,w.fee,w.remark,w.dayAmount,w.alreadyDay,w.currentDay
|
||||||
,IF(beginDay=0,startTime,IF(startTime is NULL,startTime,DATE_ADD(startTime,INTERVAL beginDay-1 day))) startTanxiaoTime
|
,IF(beginDay=0,startTime,IF(startTime is NULL,startTime,DATE_ADD(startTime,INTERVAL beginDay-1 day))) startTanxiaoTime
|
||||||
,ROUND(if(alreadyDay=days,fee,if(alreadyDayAmount>fee,fee,alreadyDayAmount)),2) alreadyTanxiao
|
,ROUND(if(CHAR_LENGTH(IFNULL(endTime,'')) < 10, if(alreadyDay=days,fee,if(alreadyDayAmount>fee,fee,alreadyDayAmount)), if(DATEDIFF(#{date}, LEFT(endTime,10)) >= 0, fee, if(alreadyDay=days,fee,if(alreadyDayAmount>fee,fee,alreadyDayAmount)))),2) alreadyTanxiao
|
||||||
from (
|
from (
|
||||||
select q.*,alreadyDay*dayAmount alreadyDayAmount
|
select q.*,alreadyDay*dayAmount alreadyDayAmount
|
||||||
,IF(days-alreadyDay=0,0,IF(beginDay=0,IF(startTime is NULL,0,IF(days-alreadyDay>=monthDays,if(DATE_FORMAT(startTime,'%Y-%m')=SUBSTR(#{date},1,7),DATEDIFF(#{date},startTime)+1,if(DATE_FORMAT(startTime,'%Y-%m')>SUBSTR(#{date},1,7),0,monthDays)),if(DATE_FORMAT(startTime, '%Y-%m')=SUBSTR(#{date},1,7),if(DATEDIFF(#{date},startTime)+1>days,days,DATEDIFF(#{date},startTime)+1),if(DATE_FORMAT(startTime, '%Y-%m') < SUBSTR(#{date},1,7),days-alreadyDay,0)))), if(alreadyTotalDay+monthDays>beginDay,if(alreadyDay>0,if(days-alreadyDay>monthDays,monthDays,monthDays-(days-alreadyDay)),monthDays-(totalDays-days-alreadyTotalDay)),0) )) currentDay
|
,IF(days-alreadyDay=0,0,IF(beginDay=0,IF(startTime is NULL,0,IF(days-alreadyDay>=monthDays,if(DATE_FORMAT(startTime,'%Y-%m')=SUBSTR(#{date},1,7),DATEDIFF(#{date},startTime)+1,if(DATE_FORMAT(startTime,'%Y-%m')>SUBSTR(#{date},1,7),0,monthDays)),if(DATE_FORMAT(startTime, '%Y-%m')=SUBSTR(#{date},1,7),if(DATEDIFF(#{date},startTime)+1>days,days,DATEDIFF(#{date},startTime)+1),if(DATE_FORMAT(startTime, '%Y-%m') < SUBSTR(#{date},1,7),days-alreadyDay,0)))), if(alreadyTotalDay+monthDays>beginDay,if(alreadyDay>0,if(days-alreadyDay>monthDays,monthDays,monthDays-(days-alreadyDay)),monthDays-(totalDays-days-alreadyTotalDay)),0) )) currentDay
|
||||||
|
|||||||
@@ -9,19 +9,241 @@
|
|||||||
dayAmount*currentDays currentTanxiao,
|
dayAmount*currentDays currentTanxiao,
|
||||||
fee-IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays)-(dayAmount*currentDays) notyetTanxiao
|
fee-IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays)-(dayAmount*currentDays) notyetTanxiao
|
||||||
from (
|
from (
|
||||||
select u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,IF(uv.type=4,'中医学',IF(uv.type=5,'针灸学',IF(uv.type=6,'肿瘤学',IF(uv.type=7,'国学',IF(uv.type=8,'心理学','中西汇通学'))))) type,
|
select uvl.id uvlId,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,IF(uv.type=4,'中医学',IF(uv.type=5,'针灸学',IF(uv.type=6,'肿瘤学',IF(uv.type=7,'国学',IF(uv.type=8,'心理学',IF(uv.type=10,'妇幼生殖学','中西汇通学')))))) type,
|
||||||
uvl.start_time startTime,uvl.end_time endTime,if(uvl.pay_time is null,'',uvl.pay_time) payTime,uvl.order_sn orderSn,pzo.trade_no zfbOrder,uvl.pay_type payType,uvl.remark,uvl.price,uvl.fee,DATEDIFF(uvl.end_time,uvl.start_time)+1 totalDays,ROUND(uvl.fee/(DATEDIFF(uvl.end_time,uvl.start_time)+1),2) dayAmount,
|
uvl.start_time startTime,uvl.end_time endTime,if(uvl.pay_time is null,'',uvl.pay_time) payTime,uvl.order_sn orderSn,pzo.trade_no zfbOrder,uvl.pay_type payType,uvl.remark,uvl.price,uvl.fee,DATEDIFF(uvl.end_time,uvl.start_time)+1 totalDays,ROUND(uvl.fee/(DATEDIFF(uvl.end_time,uvl.start_time)+1),2) dayAmount,
|
||||||
IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(concat(SUBSTR(#{date},1,7),'-01'),uvl.start_time),0))) alreadyDays,
|
IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(concat(SUBSTR(#{date},1,7),'-01'),uvl.start_time),0))) alreadyDays,
|
||||||
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') > SUBSTR(#{date},1,7),if(DATE_FORMAT(uvl.start_time, '%Y-%m') = SUBSTR(#{date},1,7),DATEDIFF(#{date},uvl.start_time)+1,DAY(#{date})),DATEDIFF(uvl.end_time,concat(SUBSTR(#{date},1,7),'-01'))+1))) currentDays,
|
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') > SUBSTR(#{date},1,7),if(DATE_FORMAT(uvl.start_time, '%Y-%m') = SUBSTR(#{date},1,7),DATEDIFF(#{date},uvl.start_time)+1,DAY(#{date})),DATEDIFF(uvl.end_time,concat(SUBSTR(#{date},1,7),'-01'))+1))) currentDays,
|
||||||
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,(IF(DATE_FORMAT(uvl.end_time, '%Y-%m') <= SUBSTR(#{date},1,7),0,DATEDIFF(uvl.end_time,#{date})))) notyetDays
|
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,(IF(DATE_FORMAT(uvl.end_time, '%Y-%m') <= SUBSTR(#{date},1,7),0,DATEDIFF(uvl.end_time,#{date})))) notyetDays
|
||||||
from user_vip_log uvl
|
from user_vip_log uvl LEFT JOIN buy_order a ON a.order_sn=uvl.order_sn
|
||||||
|
LEFT JOIN buy_order_refund b ON a.order_id=b.order_id
|
||||||
left join user_vip uv on uv.id = uvl.user_vip_id
|
left join user_vip uv on uv.id = uvl.user_vip_id
|
||||||
left join user u on u.id = uvl.user_id
|
left join user u on u.id = uvl.user_id
|
||||||
left join pay_zfb_order pzo on pzo.relevanceOid = uvl.order_sn and pzo.trade_no is not null
|
left join pay_zfb_order pzo on pzo.relevanceOid = uvl.order_sn and pzo.trade_no is not null
|
||||||
where u.del_flag = 0 and uvl.del_flag = 0 and uv.del_flag = 0
|
where u.del_flag = 0 and (uvl.del_flag = 0 or (uvl.del_flag = -1 and a.order_status=6))
|
||||||
|
and (DATE_FORMAT(b.create_time, '%Y-%m')>=SUBSTR(#{date},1,7) || ISNULL(b.create_time))
|
||||||
|
AND (uv.del_flag = 0 OR (uv.del_flag = -1 AND a.order_status=6))
|
||||||
and DATE_FORMAT(IF(uvl.pay_time is NULL,uvl.start_time,uvl.pay_time), '%Y-%m') <= SUBSTR(#{date},1,7)
|
and DATE_FORMAT(IF(uvl.pay_time is NULL,uvl.start_time,uvl.pay_time), '%Y-%m') <= SUBSTR(#{date},1,7)
|
||||||
and
|
and
|
||||||
(u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1 and (uvl.pay_type in('微信','支付宝') and uvl.create_time>='2026-05-06 00:00:00'))))
|
(u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1) and (uvl.pay_type in('微信','支付宝') and uvl.create_time>='2026-05-06 00:00:00')))
|
||||||
|
order by uvl.end_time asc
|
||||||
|
) t order by currentDays desc
|
||||||
|
</select>
|
||||||
|
<select id="getLastMonthRefundFee" resultType="java.math.BigDecimal">
|
||||||
|
select IFNULL(SUM(t.refundFee),0) fee
|
||||||
|
from (
|
||||||
|
select a.order_id,MAX(bor.fee) refundFee
|
||||||
|
from buy_order a
|
||||||
|
inner join buy_order_refund bor on bor.order_id = a.order_id
|
||||||
|
inner join user_vip_log uvl on a.order_sn = uvl.order_sn
|
||||||
|
left join user_vip uv on uv.id = uvl.user_vip_id
|
||||||
|
left join user u on u.id = uvl.user_id
|
||||||
|
where a.order_status = '6'
|
||||||
|
and a.order_type = 'vip'
|
||||||
|
and a.del_flag = 0
|
||||||
|
and u.del_flag = 0
|
||||||
|
and DATE_FORMAT(bor.create_time, '%Y-%m') = SUBSTR(#{date},1,7)
|
||||||
|
and DATE_FORMAT(IF(uvl.pay_time is NULL,uvl.start_time,uvl.pay_time), '%Y-%m') < SUBSTR(#{date},1,7)
|
||||||
|
and (u.id not in (select id from user where tester_flag = 1)
|
||||||
|
or (u.id in (select id from user where tester_flag = 1)
|
||||||
|
and (uvl.pay_type in('微信','支付宝') and uvl.create_time>='2026-05-06 00:00:00')))
|
||||||
|
group by a.order_id
|
||||||
|
) t
|
||||||
|
</select>
|
||||||
|
<select id="getNextNMonthRefund" resultType="map">
|
||||||
|
select t.*,
|
||||||
|
IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays) alreadyTanxiao,
|
||||||
|
dayAmount*currentDays currentTanxiao,
|
||||||
|
fee-IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays)-(dayAmount*currentDays) notyetTanxiao
|
||||||
|
from (
|
||||||
|
select IFNULL(bor.wx_refund_no ,bor.refund_no) as refund_no,uvl.id uvlId,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,IF(uv.type=4,'中医学',IF(uv.type=5,'针灸学',IF(uv.type=6,'肿瘤学',IF(uv.type=7,'国学',IF(uv.type=8,'心理学',IF(uv.type=10,'妇幼生殖学','中西汇通学')))))) type,
|
||||||
|
uvl.start_time startTime,uvl.end_time endTime,if(uvl.pay_time is null,'',uvl.pay_time) payTime,a.order_sn orderSn,pzo.trade_no zfbOrder,uvl.pay_type payType,uvl.remark,uvl.price,uvl.fee,DATEDIFF(uvl.end_time,uvl.start_time)+1 totalDays,ROUND(uvl.fee/(DATEDIFF(uvl.end_time,uvl.start_time)+1),2) dayAmount,
|
||||||
|
bor.fee refundFee,DATE_FORMAT(bor.create_time,'%Y-%m-%d %H:%i:%s') refundTime,
|
||||||
|
IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(concat(SUBSTR(#{date},1,7),'-01'),uvl.start_time),0))) alreadyDays,
|
||||||
|
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') > SUBSTR(#{date},1,7),if(DATE_FORMAT(uvl.start_time, '%Y-%m') = SUBSTR(#{date},1,7),DATEDIFF(#{date},uvl.start_time)+1,DAY(#{date})),DATEDIFF(uvl.end_time,concat(SUBSTR(#{date},1,7),'-01'))+1))) currentDays,
|
||||||
|
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,(IF(DATE_FORMAT(uvl.end_time, '%Y-%m') <= SUBSTR(#{date},1,7),0,DATEDIFF(uvl.end_time,#{date})))) notyetDays
|
||||||
|
from buy_order a
|
||||||
|
inner join buy_order_refund bor on bor.order_id = a.order_id
|
||||||
|
inner join user_vip_log uvl on a.order_sn = uvl.order_sn
|
||||||
|
left join user_vip uv on uv.id = uvl.user_vip_id
|
||||||
|
left join user u on u.id = uvl.user_id
|
||||||
|
left join pay_zfb_order pzo on pzo.relevanceOid = a.order_sn and pzo.trade_no is not null
|
||||||
|
where a.order_status = '6'
|
||||||
|
and a.order_type = 'vip'
|
||||||
|
and a.del_flag = 0
|
||||||
|
and u.del_flag = 0
|
||||||
|
and DATE_FORMAT(IF(uvl.pay_time is NULL,uvl.start_time,uvl.pay_time), '%Y-%m') = SUBSTR(#{date},1,7)
|
||||||
|
and DATE_FORMAT(bor.create_time, '%Y-%m') > SUBSTR(#{date},1,7)
|
||||||
|
and
|
||||||
|
(u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1) and (uvl.pay_type in('微信','支付宝') and uvl.create_time>='2026-05-06 00:00:00')))
|
||||||
|
order by uvl.end_time asc
|
||||||
|
) t order by currentDays desc
|
||||||
|
</select>
|
||||||
|
<select id="getCurrMonthOtherRefund" resultType="map">
|
||||||
|
select t.*,
|
||||||
|
IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays) alreadyTanxiao,
|
||||||
|
dayAmount*currentDays currentTanxiao,
|
||||||
|
fee-IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays)-(dayAmount*currentDays) notyetTanxiao
|
||||||
|
from (
|
||||||
|
select IFNULL(bor.wx_refund_no ,bor.refund_no) as refund_no,uvl.id uvlId,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,IF(uv.type=4,'中医学',IF(uv.type=5,'针灸学',IF(uv.type=6,'肿瘤学',IF(uv.type=7,'国学',IF(uv.type=8,'心理学',IF(uv.type=10,'妇幼生殖学','中西汇通学')))))) type,
|
||||||
|
uvl.start_time startTime,uvl.end_time endTime,if(uvl.pay_time is null,'',uvl.pay_time) payTime,a.order_sn orderSn,pzo.trade_no zfbOrder,uvl.pay_type payType,uvl.remark,uvl.price,uvl.fee,DATEDIFF(uvl.end_time,uvl.start_time)+1 totalDays,ROUND(uvl.fee/(DATEDIFF(uvl.end_time,uvl.start_time)+1),2) dayAmount,
|
||||||
|
bor.fee refundFee,DATE_FORMAT(bor.create_time,'%Y-%m-%d %H:%i:%s') refundTime,
|
||||||
|
IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(concat(SUBSTR(#{date},1,7),'-01'),uvl.start_time),0))) alreadyDays,
|
||||||
|
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') > SUBSTR(#{date},1,7),if(DATE_FORMAT(uvl.start_time, '%Y-%m') = SUBSTR(#{date},1,7),DATEDIFF(#{date},uvl.start_time)+1,DAY(#{date})),DATEDIFF(uvl.end_time,concat(SUBSTR(#{date},1,7),'-01'))+1))) currentDays,
|
||||||
|
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,(IF(DATE_FORMAT(uvl.end_time, '%Y-%m') <= SUBSTR(#{date},1,7),0,DATEDIFF(uvl.end_time,#{date})))) notyetDays
|
||||||
|
from buy_order a
|
||||||
|
inner join buy_order_refund bor on bor.order_id = a.order_id
|
||||||
|
inner join user_vip_log uvl on a.order_sn = uvl.order_sn
|
||||||
|
left join user_vip uv on uv.id = uvl.user_vip_id
|
||||||
|
left join user u on u.id = uvl.user_id
|
||||||
|
left join pay_zfb_order pzo on pzo.relevanceOid = a.order_sn and pzo.trade_no is not null
|
||||||
|
where a.order_status = '6'
|
||||||
|
and a.order_type = 'vip'
|
||||||
|
and a.del_flag = 0
|
||||||
|
and u.del_flag = 0
|
||||||
|
and DATE_FORMAT(IF(uvl.pay_time is NULL,uvl.start_time,uvl.pay_time), '%Y-%m') = SUBSTR(#{date},1,7)
|
||||||
|
and DATE_FORMAT(bor.create_time, '%Y-%m') != SUBSTR(#{date},1,7)
|
||||||
|
and
|
||||||
|
(u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1) and (uvl.pay_type in('微信','支付宝') and uvl.create_time>='2026-05-06 00:00:00')))
|
||||||
|
order by uvl.end_time asc
|
||||||
|
) t order by currentDays desc
|
||||||
|
</select>
|
||||||
|
<select id="getLastMonthRefund" resultType="map">
|
||||||
|
select t.*,
|
||||||
|
IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays) alreadyTanxiao,
|
||||||
|
dayAmount*currentDays currentTanxiao,
|
||||||
|
fee-IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays)-(dayAmount*currentDays) notyetTanxiao
|
||||||
|
from (
|
||||||
|
select IFNULL(bor.wx_refund_no ,bor.refund_no) as refund_no,uvl.id uvlId,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,IF(uv.type=4,'中医学',IF(uv.type=5,'针灸学',IF(uv.type=6,'肿瘤学',IF(uv.type=7,'国学',IF(uv.type=8,'心理学',IF(uv.type=10,'妇幼生殖学','中西汇通学')))))) type,
|
||||||
|
uvl.start_time startTime,uvl.end_time endTime,if(uvl.pay_time is null,'',uvl.pay_time) payTime,a.order_sn orderSn,pzo.trade_no zfbOrder,uvl.pay_type payType,uvl.remark,uvl.price,uvl.fee,DATEDIFF(uvl.end_time,uvl.start_time)+1 totalDays,ROUND(uvl.fee/(DATEDIFF(uvl.end_time,uvl.start_time)+1),2) dayAmount,
|
||||||
|
bor.fee refundFee,DATE_FORMAT(bor.create_time,'%Y-%m-%d %H:%i:%s') refundTime,
|
||||||
|
IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(concat(SUBSTR(#{date},1,7),'-01'),uvl.start_time),0))) alreadyDays,
|
||||||
|
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') > SUBSTR(#{date},1,7),if(DATE_FORMAT(uvl.start_time, '%Y-%m') = SUBSTR(#{date},1,7),DATEDIFF(#{date},uvl.start_time)+1,DAY(#{date})),DATEDIFF(uvl.end_time,concat(SUBSTR(#{date},1,7),'-01'))+1))) currentDays,
|
||||||
|
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,(IF(DATE_FORMAT(uvl.end_time, '%Y-%m') <= SUBSTR(#{date},1,7),0,DATEDIFF(uvl.end_time,#{date})))) notyetDays
|
||||||
|
from buy_order a
|
||||||
|
inner join buy_order_refund bor on bor.order_id = a.order_id
|
||||||
|
inner join user_vip_log uvl on a.order_sn = uvl.order_sn
|
||||||
|
left join user_vip uv on uv.id = uvl.user_vip_id
|
||||||
|
left join user u on u.id = uvl.user_id
|
||||||
|
left join pay_zfb_order pzo on pzo.relevanceOid = a.order_sn and pzo.trade_no is not null
|
||||||
|
where a.order_status = '6'
|
||||||
|
and a.order_type = 'vip'
|
||||||
|
and a.del_flag = 0
|
||||||
|
and u.del_flag = 0
|
||||||
|
and DATE_FORMAT(bor.create_time, '%Y-%m') = SUBSTR(#{date},1,7)
|
||||||
|
and DATE_FORMAT(IF(uvl.pay_time is NULL,uvl.start_time,uvl.pay_time), '%Y-%m') =
|
||||||
|
DATE_FORMAT(DATE_SUB(CONCAT(SUBSTR(#{date},1,7),'-01'), INTERVAL 1 MONTH), '%Y-%m')
|
||||||
|
and
|
||||||
|
(u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1) and (uvl.pay_type in('微信','支付宝') and uvl.create_time>='2026-05-06 00:00:00')))
|
||||||
|
order by uvl.end_time asc
|
||||||
|
) t order by currentDays desc
|
||||||
|
</select>
|
||||||
|
<select id="getCurrMonthOtherRefund" resultType="map">
|
||||||
|
select t.*,
|
||||||
|
IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays) alreadyTanxiao,
|
||||||
|
dayAmount*currentDays currentTanxiao,
|
||||||
|
fee-IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays)-(dayAmount*currentDays) notyetTanxiao
|
||||||
|
from (
|
||||||
|
select IFNULL(bor.wx_refund_no ,bor.refund_no) as refund_no,uvl.id uvlId,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,IF(uv.type=4,'中医学',IF(uv.type=5,'针灸学',IF(uv.type=6,'肿瘤学',IF(uv.type=7,'国学',IF(uv.type=8,'心理学',IF(uv.type=10,'妇幼生殖学','中西汇通学')))))) type,
|
||||||
|
uvl.start_time startTime,uvl.end_time endTime,if(uvl.pay_time is null,'',uvl.pay_time) payTime,a.order_sn orderSn,pzo.trade_no zfbOrder,uvl.pay_type payType,uvl.remark,uvl.price,uvl.fee,DATEDIFF(uvl.end_time,uvl.start_time)+1 totalDays,ROUND(uvl.fee/(DATEDIFF(uvl.end_time,uvl.start_time)+1),2) dayAmount,
|
||||||
|
bor.fee refundFee,DATE_FORMAT(bor.create_time,'%Y-%m-%d %H:%i:%s') refundTime,
|
||||||
|
IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(concat(SUBSTR(#{date},1,7),'-01'),uvl.start_time),0))) alreadyDays,
|
||||||
|
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') > SUBSTR(#{date},1,7),if(DATE_FORMAT(uvl.start_time, '%Y-%m') = SUBSTR(#{date},1,7),DATEDIFF(#{date},uvl.start_time)+1,DAY(#{date})),DATEDIFF(uvl.end_time,concat(SUBSTR(#{date},1,7),'-01'))+1))) currentDays,
|
||||||
|
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,(IF(DATE_FORMAT(uvl.end_time, '%Y-%m') <= SUBSTR(#{date},1,7),0,DATEDIFF(uvl.end_time,#{date})))) notyetDays
|
||||||
|
from buy_order a
|
||||||
|
inner join buy_order_refund bor on bor.order_id = a.order_id
|
||||||
|
inner join user_vip_log uvl on a.order_sn = uvl.order_sn
|
||||||
|
left join user_vip uv on uv.id = uvl.user_vip_id
|
||||||
|
left join user u on u.id = uvl.user_id
|
||||||
|
left join pay_zfb_order pzo on pzo.relevanceOid = a.order_sn and pzo.trade_no is not null
|
||||||
|
where a.order_status = '6'
|
||||||
|
and a.order_type = 'vip'
|
||||||
|
and a.del_flag = 0
|
||||||
|
and u.del_flag = 0
|
||||||
|
and DATE_FORMAT(IF(uvl.pay_time is NULL,uvl.start_time,uvl.pay_time), '%Y-%m') = SUBSTR(#{date},1,7)
|
||||||
|
and DATE_FORMAT(bor.create_time, '%Y-%m') != SUBSTR(#{date},1,7)
|
||||||
|
and
|
||||||
|
(u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1) and (uvl.pay_type in('微信','支付宝') and uvl.create_time>='2026-05-06 00:00:00')))
|
||||||
|
order by uvl.end_time asc
|
||||||
|
) t order by currentDays desc
|
||||||
|
</select>
|
||||||
|
<select id="getLastLMonthRefund" resultType="map">
|
||||||
|
select t.*,
|
||||||
|
IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays) alreadyTanxiao,
|
||||||
|
dayAmount*currentDays currentTanxiao,
|
||||||
|
fee-IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays)-(dayAmount*currentDays) notyetTanxiao
|
||||||
|
from (
|
||||||
|
select IFNULL(bor.wx_refund_no ,bor.refund_no) as refund_no,uvl.id uvlId,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,IF(uv.type=4,'中医学',IF(uv.type=5,'针灸学',IF(uv.type=6,'肿瘤学',IF(uv.type=7,'国学',IF(uv.type=8,'心理学',IF(uv.type=10,'妇幼生殖学','中西汇通学')))))) type,
|
||||||
|
uvl.start_time startTime,uvl.end_time endTime,if(uvl.pay_time is null,'',uvl.pay_time) payTime,a.order_sn orderSn,pzo.trade_no zfbOrder,uvl.pay_type payType,uvl.remark,uvl.price,uvl.fee,DATEDIFF(uvl.end_time,uvl.start_time)+1 totalDays,ROUND(uvl.fee/(DATEDIFF(uvl.end_time,uvl.start_time)+1),2) dayAmount,
|
||||||
|
bor.fee refundFee,DATE_FORMAT(bor.create_time,'%Y-%m-%d %H:%i:%s') refundTime,
|
||||||
|
IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(concat(SUBSTR(#{date},1,7),'-01'),uvl.start_time),0))) alreadyDays,
|
||||||
|
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') > SUBSTR(#{date},1,7),if(DATE_FORMAT(uvl.start_time, '%Y-%m') = SUBSTR(#{date},1,7),DATEDIFF(#{date},uvl.start_time)+1,DAY(#{date})),DATEDIFF(uvl.end_time,concat(SUBSTR(#{date},1,7),'-01'))+1))) currentDays,
|
||||||
|
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,(IF(DATE_FORMAT(uvl.end_time, '%Y-%m') <= SUBSTR(#{date},1,7),0,DATEDIFF(uvl.end_time,#{date})))) notyetDays
|
||||||
|
from buy_order a
|
||||||
|
inner join buy_order_refund bor on bor.order_id = a.order_id
|
||||||
|
inner join user_vip_log uvl on a.order_sn = uvl.order_sn
|
||||||
|
left join user_vip uv on uv.id = uvl.user_vip_id
|
||||||
|
left join user u on u.id = uvl.user_id
|
||||||
|
left join pay_zfb_order pzo on pzo.relevanceOid = a.order_sn and pzo.trade_no is not null
|
||||||
|
where a.order_status = '6'
|
||||||
|
and a.order_type = 'vip'
|
||||||
|
and a.del_flag = 0
|
||||||
|
and u.del_flag = 0
|
||||||
|
and DATE_FORMAT(bor.create_time, '%Y-%m') = SUBSTR(#{date},1,7)
|
||||||
|
and DATE_FORMAT(IF(uvl.pay_time is NULL,uvl.start_time,uvl.pay_time), '%Y-%m') != SUBSTR(#{date},1,7)
|
||||||
|
and
|
||||||
|
(u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1) and (uvl.pay_type in('微信','支付宝') and uvl.create_time>='2026-05-06 00:00:00')))
|
||||||
|
order by uvl.end_time asc
|
||||||
|
) t order by currentDays desc
|
||||||
|
</select>
|
||||||
|
<select id="getMonthRefund" resultType="map">
|
||||||
|
select t.*,
|
||||||
|
IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays) alreadyTanxiao,
|
||||||
|
dayAmount*currentDays currentTanxiao,
|
||||||
|
fee-IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays)-(dayAmount*currentDays) notyetTanxiao
|
||||||
|
from (
|
||||||
|
select IFNULL(bor.wx_refund_no ,bor.refund_no) as refund_no,uvl.id uvlId,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,IF(uv.type=4,'中医学',IF(uv.type=5,'针灸学',IF(uv.type=6,'肿瘤学',IF(uv.type=7,'国学',IF(uv.type=8,'心理学',IF(uv.type=10,'妇幼生殖学','中西汇通学')))))) type,
|
||||||
|
uvl.start_time startTime,uvl.end_time endTime,if(uvl.pay_time is null,'',uvl.pay_time) payTime,a.order_sn orderSn,pzo.trade_no zfbOrder,uvl.pay_type payType,uvl.remark,uvl.price,uvl.fee,DATEDIFF(uvl.end_time,uvl.start_time)+1 totalDays,ROUND(uvl.fee/(DATEDIFF(uvl.end_time,uvl.start_time)+1),2) dayAmount,
|
||||||
|
bor.fee refundFee,DATE_FORMAT(bor.create_time,'%Y-%m-%d %H:%i:%s') refundTime,
|
||||||
|
IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(concat(SUBSTR(#{date},1,7),'-01'),uvl.start_time),0))) alreadyDays,
|
||||||
|
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') > SUBSTR(#{date},1,7),if(DATE_FORMAT(uvl.start_time, '%Y-%m') = SUBSTR(#{date},1,7),DATEDIFF(#{date},uvl.start_time)+1,DAY(#{date})),DATEDIFF(uvl.end_time,concat(SUBSTR(#{date},1,7),'-01'))+1))) currentDays,
|
||||||
|
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,(IF(DATE_FORMAT(uvl.end_time, '%Y-%m') <= SUBSTR(#{date},1,7),0,DATEDIFF(uvl.end_time,#{date})))) notyetDays
|
||||||
|
from buy_order a
|
||||||
|
inner join buy_order_refund bor on bor.order_id = a.order_id
|
||||||
|
inner join user_vip_log uvl on a.order_sn = uvl.order_sn
|
||||||
|
left join user_vip uv on uv.id = uvl.user_vip_id
|
||||||
|
left join user u on u.id = uvl.user_id
|
||||||
|
left join pay_zfb_order pzo on pzo.relevanceOid = a.order_sn and pzo.trade_no is not null
|
||||||
|
where a.order_status = '6'
|
||||||
|
and a.order_type = 'vip'
|
||||||
|
and a.del_flag = 0
|
||||||
|
and u.del_flag = 0
|
||||||
|
and DATE_FORMAT(bor.create_time, '%Y-%m') = SUBSTR(#{date},1,7)
|
||||||
|
and
|
||||||
|
(u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1) and (uvl.pay_type in('微信','支付宝') and uvl.create_time>='2026-05-06 00:00:00')))
|
||||||
|
order by uvl.end_time asc
|
||||||
|
) t order by currentDays desc
|
||||||
|
</select>
|
||||||
|
<select id="getAllUserVipLogInfo" resultType="map">
|
||||||
|
select t.*,
|
||||||
|
IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays) alreadyTanxiao,
|
||||||
|
dayAmount*currentDays currentTanxiao,
|
||||||
|
fee-IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays)-(dayAmount*currentDays) notyetTanxiao
|
||||||
|
from (
|
||||||
|
select uvl.id uvlId,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,IF(uv.type=4,'中医学',IF(uv.type=5,'针灸学',IF(uv.type=6,'肿瘤学',IF(uv.type=7,'国学',IF(uv.type=8,'心理学',IF(uv.type=10,'妇幼生殖学','中西汇通学')))))) type,
|
||||||
|
uvl.start_time startTime,uvl.end_time endTime,if(uvl.pay_time is null,'',uvl.pay_time) payTime,a.order_sn orderSn,pzo.trade_no zfbOrder,uvl.pay_type payType,uvl.remark,uvl.price,uvl.fee,DATEDIFF(uvl.end_time,uvl.start_time)+1 totalDays,ROUND(uvl.fee/(DATEDIFF(uvl.end_time,uvl.start_time)+1),2) dayAmount,
|
||||||
|
IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(concat(SUBSTR(#{date},1,7),'-01'),uvl.start_time),0))) alreadyDays,
|
||||||
|
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') > SUBSTR(#{date},1,7),if(DATE_FORMAT(uvl.start_time, '%Y-%m') = SUBSTR(#{date},1,7),DATEDIFF(#{date},uvl.start_time)+1,DAY(#{date})),DATEDIFF(uvl.end_time,concat(SUBSTR(#{date},1,7),'-01'))+1))) currentDays,
|
||||||
|
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,(IF(DATE_FORMAT(uvl.end_time, '%Y-%m') <= SUBSTR(#{date},1,7),0,DATEDIFF(uvl.end_time,#{date})))) notyetDays
|
||||||
|
from buy_order a
|
||||||
|
inner join user_vip_log uvl on a.order_sn = uvl.order_sn and (uvl.del_flag = 0 or a.order_status = '6')
|
||||||
|
left join user_vip uv on uv.id = uvl.user_vip_id and (uv.del_flag = 0 or a.order_status = '6')
|
||||||
|
left join user u on u.id = uvl.user_id and u.del_flag = 0
|
||||||
|
left join pay_zfb_order pzo on pzo.relevanceOid = a.order_sn and pzo.trade_no is not null
|
||||||
|
where a.order_type = 'vip' and a.order_status in (1,2,3,4,6)
|
||||||
|
and a.del_flag = 0
|
||||||
|
and DATE_FORMAT(IF(uvl.pay_time is NULL,uvl.start_time,uvl.pay_time), '%Y-%m') <= SUBSTR(#{date},1,7)
|
||||||
|
and
|
||||||
|
(u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1) and (uvl.pay_type in('微信','支付宝') and uvl.create_time>='2026-05-06 00:00:00')))
|
||||||
order by uvl.end_time asc
|
order by uvl.end_time asc
|
||||||
) t order by currentDays desc
|
) t order by currentDays desc
|
||||||
</select>
|
</select>
|
||||||
@@ -35,7 +257,7 @@
|
|||||||
dayAmount*currentDays currentTanxiao,
|
dayAmount*currentDays currentTanxiao,
|
||||||
fee-IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays)-(dayAmount*currentDays) notyetTanxiao
|
fee-IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays)-(dayAmount*currentDays) notyetTanxiao
|
||||||
from (
|
from (
|
||||||
select u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,IF(uv.type=4,'中医学',IF(uv.type=5,'针灸学',IF(uv.type=6,'肿瘤学',IF(uv.type=7,'国学',IF(uv.type=8,'心理学','中西汇通学'))))) type,
|
select u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel,IF(uv.type=4,'中医学',IF(uv.type=5,'针灸学',IF(uv.type=6,'肿瘤学',IF(uv.type=7,'国学',IF(uv.type=8,'心理学',IF(uv.type=10,'妇幼生殖学','中西汇通学')))))) type,
|
||||||
uvl.start_time startTime,uvl.end_time endTime,if(uvl.pay_time is null,'',uvl.pay_time) payTime,uvl.order_sn orderSn,pzo.trade_no zfbOrder,uvl.pay_type payType,uvl.remark,uvl.price,uvl.fee,DATEDIFF(uvl.end_time,uvl.start_time)+1 totalDays,ROUND(uvl.fee/(DATEDIFF(uvl.end_time,uvl.start_time)+1),2) dayAmount,
|
uvl.start_time startTime,uvl.end_time endTime,if(uvl.pay_time is null,'',uvl.pay_time) payTime,uvl.order_sn orderSn,pzo.trade_no zfbOrder,uvl.pay_type payType,uvl.remark,uvl.price,uvl.fee,DATEDIFF(uvl.end_time,uvl.start_time)+1 totalDays,ROUND(uvl.fee/(DATEDIFF(uvl.end_time,uvl.start_time)+1),2) dayAmount,
|
||||||
IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(concat(SUBSTR(#{date},1,7),'-01'),uvl.start_time),0))) alreadyDays,
|
IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(concat(SUBSTR(#{date},1,7),'-01'),uvl.start_time),0))) alreadyDays,
|
||||||
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') > SUBSTR(#{date},1,7),if(DATE_FORMAT(uvl.start_time, '%Y-%m') = SUBSTR(#{date},1,7),DATEDIFF(#{date},uvl.start_time)+1,DAY(#{date})),DATEDIFF(uvl.end_time,concat(SUBSTR(#{date},1,7),'-01'))+1))) currentDays,
|
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') > SUBSTR(#{date},1,7),if(DATE_FORMAT(uvl.start_time, '%Y-%m') = SUBSTR(#{date},1,7),DATEDIFF(#{date},uvl.start_time)+1,DAY(#{date})),DATEDIFF(uvl.end_time,concat(SUBSTR(#{date},1,7),'-01'))+1))) currentDays,
|
||||||
@@ -44,18 +266,63 @@
|
|||||||
left join user_vip uv on uv.id = uvl.user_vip_id
|
left join user_vip uv on uv.id = uvl.user_vip_id
|
||||||
left join user u on u.id = uvl.user_id
|
left join user u on u.id = uvl.user_id
|
||||||
left join pay_zfb_order pzo on pzo.relevanceOid = uvl.order_sn and pzo.trade_no is not null
|
left join pay_zfb_order pzo on pzo.relevanceOid = uvl.order_sn and pzo.trade_no is not null
|
||||||
where u.del_flag = 0 and uvl.del_flag = 0 and uv.del_flag = 0 and DATE_FORMAT(IF(uvl.pay_time is NULL,uvl.start_time,uvl.pay_time), '%Y-%m') <= SUBSTR(#{date},1,7) and u.id not in (select id from user where tester_flag = 1)
|
where u.del_flag = 0 and uvl.del_flag = 0 and uv.del_flag = 0 and DATE_FORMAT(IF(uvl.pay_time is NULL,uvl.start_time,uvl.pay_time), '%Y-%m') <= SUBSTR(#{date},1,7)
|
||||||
|
and (u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1) and (uvl.pay_type in('微信','支付宝') and uvl.create_time>='2026-05-06 00:00:00')))
|
||||||
order by uvl.end_time asc
|
order by uvl.end_time asc
|
||||||
) t order by currentDays desc
|
) t order by currentDays desc
|
||||||
) s
|
) s
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getUserVipRefundLogInfo" resultType="map">
|
||||||
|
select uvl.id uvlId, a.order_sn orderSn, bor.fee refundFee, DATE_FORMAT(bor.create_time,'%Y-%m-%d %H:%i:%s') refundTime
|
||||||
|
from buy_order a
|
||||||
|
inner join buy_order_refund bor on bor.order_id = a.order_id
|
||||||
|
inner join user_vip_log uvl on a.order_sn = uvl.order_sn
|
||||||
|
left join user_vip uv on uv.id = uvl.user_vip_id
|
||||||
|
left join user u on u.id = uvl.user_id
|
||||||
|
where a.order_status = '6'
|
||||||
|
and a.order_type = 'vip'
|
||||||
|
and a.del_flag = 0
|
||||||
|
and DATE_FORMAT(bor.create_time, '%Y-%m') = SUBSTR(#{date},1,7)
|
||||||
|
and (u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1) and (uvl.pay_type in('微信','支付宝') and uvl.create_time>='2026-05-06 00:00:00')))
|
||||||
|
</select>
|
||||||
|
<select id="getUserVipSameMonthRefundFeeTotal" resultType="java.math.BigDecimal">
|
||||||
|
select IFNULL(SUM(uvl.fee),0)
|
||||||
|
from user_vip_log uvl
|
||||||
|
left join user_vip uv on uv.id = uvl.user_vip_id
|
||||||
|
left join user u on u.id = uvl.user_id
|
||||||
|
left join buy_order a on a.order_sn = uvl.order_sn
|
||||||
|
left join buy_order_refund c on c.order_id = a.order_id
|
||||||
|
where u.del_flag = 0
|
||||||
|
and a.del_flag = 0
|
||||||
|
and a.order_status = '6'
|
||||||
|
and a.order_type = 'vip'
|
||||||
|
and DATE_FORMAT(IF(uvl.pay_time is NULL,uvl.start_time,uvl.pay_time), '%Y-%m') = SUBSTR(#{date},1,7)
|
||||||
|
and (u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1) and (uvl.pay_type in('微信','支付宝') and uvl.create_time>='2026-05-06 00:00:00')))
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getUserVipRefundFeeTotal" resultType="java.math.BigDecimal">
|
||||||
|
select IFNULL(SUM(uvl.price),0)
|
||||||
|
from user_vip_log uvl
|
||||||
|
left join user_vip uv on uv.id = uvl.user_vip_id
|
||||||
|
left join user u on u.id = uvl.user_id
|
||||||
|
left join buy_order a on a.order_sn = uvl.order_sn
|
||||||
|
left join buy_order_refund c on c.order_id = a.order_id
|
||||||
|
where u.del_flag = 0
|
||||||
|
and a.del_flag = 0
|
||||||
|
and a.order_status = '6'
|
||||||
|
and a.order_type = 'vip'
|
||||||
|
and DATE_FORMAT(IF(uvl.pay_time is NULL,uvl.start_time,uvl.pay_time), '%Y-%m') <= SUBSTR(#{date},1,7)
|
||||||
|
and DATE_FORMAT(c.create_time, '%Y-%m') = SUBSTR(#{date},1,7)
|
||||||
|
and (u.id not in (select id from user where tester_flag = 1) or (u.id in (select id from user where tester_flag = 1) and (uvl.pay_type in('微信','支付宝') and uvl.create_time>='2026-05-06 00:00:00')))
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="getUserVipRefundInfo" resultType="map">
|
<select id="getUserVipRefundInfo" resultType="map">
|
||||||
select t.*,
|
select t.*,
|
||||||
IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays) alreadyTanxiao,
|
IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays) alreadyTanxiao,
|
||||||
dayAmount*currentDays currentTanxiao,
|
dayAmount*currentDays currentTanxiao,
|
||||||
fee-IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays)-(dayAmount*currentDays) notyetTanxiao
|
fee-IF(totalDays=alreadyDays,fee,dayAmount*alreadyDays)-(dayAmount*currentDays) notyetTanxiao
|
||||||
from (select uvl.*,c.create_time refund_time,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel, IF(uv.type=4,'中医学',IF(uv.type=5,'针灸学',IF(uv.type=6,'肿瘤学',IF(uv.type=7,'国学',IF(uv.type=8,'心理学','中西汇通学'))))) type,
|
from (select uvl.*,c.create_time refund_time,u.name,if(u.tel is null,if(u.email is null,'',u.email),u.tel) tel, IF(uv.type=4,'中医学',IF(uv.type=5,'针灸学',IF(uv.type=6,'肿瘤学',IF(uv.type=7,'国学',IF(uv.type=8,'心理学',IF(uv.type=10,'妇幼生殖学','中西汇通学')))))) type,
|
||||||
uvl.start_time startTime,uvl.end_time endTime,if(uvl.pay_time is null,'',uvl.pay_time) payTime,uvl.order_sn orderSn,pzo.trade_no zfbOrder,uvl.pay_type payType,uvl.remark,uvl.price,uvl.fee,DATEDIFF(uvl.end_time,uvl.start_time)+1 totalDays,ROUND(uvl.fee/(DATEDIFF(uvl.end_time,uvl.start_time)+1),2) dayAmount,
|
uvl.start_time startTime,uvl.end_time endTime,if(uvl.pay_time is null,'',uvl.pay_time) payTime,uvl.order_sn orderSn,pzo.trade_no zfbOrder,uvl.pay_type payType,uvl.remark,uvl.price,uvl.fee,DATEDIFF(uvl.end_time,uvl.start_time)+1 totalDays,ROUND(uvl.fee/(DATEDIFF(uvl.end_time,uvl.start_time)+1),2) dayAmount,
|
||||||
IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(concat(SUBSTR(#{date},1,7),'-01'),uvl.start_time),0))) alreadyDays,
|
IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(uvl.end_time,uvl.start_time)+1,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.start_time, '%Y-%m') < SUBSTR(#{date},1,7),DATEDIFF(concat(SUBSTR(#{date},1,7),'-01'),uvl.start_time),0))) alreadyDays,
|
||||||
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') > SUBSTR(#{date},1,7),if(DATE_FORMAT(uvl.start_time, '%Y-%m') = SUBSTR(#{date},1,7),DATEDIFF(#{date},uvl.start_time)+1,DAY(#{date})),DATEDIFF(uvl.end_time,concat(SUBSTR(#{date},1,7),'-01'))+1))) currentDays,
|
IF(DATE_FORMAT(uvl.start_time, '%Y-%m') > SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') < SUBSTR(#{date},1,7),0,IF(DATE_FORMAT(uvl.end_time, '%Y-%m') > SUBSTR(#{date},1,7),if(DATE_FORMAT(uvl.start_time, '%Y-%m') = SUBSTR(#{date},1,7),DATEDIFF(#{date},uvl.start_time)+1,DAY(#{date})),DATEDIFF(uvl.end_time,concat(SUBSTR(#{date},1,7),'-01'))+1))) currentDays,
|
||||||
|
|||||||
Reference in New Issue
Block a user