1
This commit is contained in:
@@ -20,7 +20,7 @@ public class RuoYiApplication
|
||||
ConfigurableApplicationContext context = SpringApplication.run(RuoYiApplication.class, args);
|
||||
Environment env =context.getEnvironment();
|
||||
System.out.println("实际加载的端口:" + env.getProperty("server.port"));
|
||||
System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.ruoyi.web.controller.jarvis;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.common.core.page.PageDomain;
|
||||
import com.ruoyi.common.core.page.TableSupport;
|
||||
import com.ruoyi.jarvis.domain.SuperAdmin;
|
||||
import com.ruoyi.jarvis.service.SuperAdminService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
@@ -31,6 +30,9 @@ public class OrderRowsController extends BaseController
|
||||
@Autowired
|
||||
private IOrderRowsService orderRowsService;
|
||||
|
||||
@Autowired
|
||||
private SuperAdminService superAdminService;
|
||||
|
||||
/**
|
||||
* 查询京粉订单列表
|
||||
*/
|
||||
@@ -42,21 +44,36 @@ public class OrderRowsController extends BaseController
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 导出京粉订单列表
|
||||
*/
|
||||
@Log(title = "京粉订单", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, OrderRows orderRows)
|
||||
public void export(HttpServletResponse response, OrderRows orderRows) throws IOException
|
||||
{
|
||||
// 判断是否需要分页
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
if (pageDomain.getPageNum() != null && pageDomain.getPageSize() != null) {
|
||||
startPage();
|
||||
}
|
||||
String fileName = "京粉订单数据";
|
||||
|
||||
List<OrderRows> list = orderRowsService.selectOrderRowsList(orderRows);
|
||||
if (!list.isEmpty()){
|
||||
Long unionId = list.get(0).getUnionId();
|
||||
SuperAdmin superAdmin = superAdminService.selectSuperAdminByUnionId(unionId);
|
||||
if (superAdmin != null && superAdmin.getName() != null) {
|
||||
String name = superAdmin.getName();
|
||||
String unionIdStr = String.valueOf(superAdmin.getUnionId());
|
||||
fileName = name + "-" + unionIdStr + "-订单";
|
||||
}
|
||||
}
|
||||
|
||||
// 设置响应头,指定文件名
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
String encodedFileName = java.net.URLEncoder.encode(fileName + ".xlsx", "UTF-8");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + encodedFileName);
|
||||
// 添加download-filename响应头,以支持前端工具类
|
||||
response.setHeader("download-filename", encodedFileName);
|
||||
|
||||
ExcelUtil<OrderRows> util = new ExcelUtil<OrderRows>(OrderRows.class);
|
||||
util.exportExcel(response, list, "京粉订单数据");
|
||||
util.exportExcel(response, list, fileName);
|
||||
}
|
||||
|
||||
|
||||
@@ -107,4 +124,130 @@ public class OrderRowsController extends BaseController
|
||||
List<Map<String, Object>> options = ValidCodeConverter.getAllValidCodeOptions();
|
||||
return AjaxResult.success(options);
|
||||
}
|
||||
/**
|
||||
* 根据联盟ID或日期范围统计订单数据,按validCode分组
|
||||
*/
|
||||
@GetMapping("/statistics")
|
||||
public AjaxResult getStatistics(OrderRows orderRows, Date beginTime, Date endTime) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
// 获取superAdminList,筛选出isCount = 0的unionId
|
||||
List<Long> excludeUnionIds = new ArrayList<>();
|
||||
List<SuperAdmin> superAdminList = superAdminService.selectSuperAdminList(null);
|
||||
logger.info("superAdminList.size: {}", superAdminList.size());
|
||||
for (SuperAdmin superAdmin : superAdminList) {
|
||||
if (superAdmin.getIsCount() != null && superAdmin.getIsCount() == 0 && superAdmin.getUnionId() != null) {
|
||||
try {
|
||||
excludeUnionIds.add(Long.parseLong(superAdmin.getUnionId()));
|
||||
} catch (NumberFormatException e) {
|
||||
// 忽略无法解析的unionId
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.info("excludeUnionIds: {}", excludeUnionIds.size());
|
||||
|
||||
// 使用新的查询方法,直接在SQL中完成日期过滤和unionId排除
|
||||
List<OrderRows> filteredList = orderRowsService.selectOrderRowsListWithFilter(orderRows, beginTime, endTime, excludeUnionIds);
|
||||
|
||||
// 定义分组
|
||||
Map<String, Object> groups = new HashMap<>();
|
||||
groups.put("cancel", Arrays.asList("3"));
|
||||
groups.put("invalid", Arrays.asList("2","4","5","6","7","8","9","10","11","14","19","20","21","22","23","29","30","31","32","33","34"));
|
||||
groups.put("pending", Arrays.asList("15"));
|
||||
groups.put("paid", Arrays.asList("16"));
|
||||
groups.put("finished", Arrays.asList("17"));
|
||||
groups.put("deposit", Arrays.asList("24"));
|
||||
groups.put("illegal", Arrays.asList("25","26","27","28"));
|
||||
|
||||
// 初始化统计结果
|
||||
Map<String, Map<String, Object>> groupStats = new HashMap<>();
|
||||
groupStats.put("cancel", createGroupStat("取消", "cancel"));
|
||||
groupStats.put("invalid", createGroupStat("无效", "invalid"));
|
||||
groupStats.put("pending", createGroupStat("待付款", "pending"));
|
||||
groupStats.put("paid", createGroupStat("已付款", "paid"));
|
||||
groupStats.put("finished", createGroupStat("已完成", "finished"));
|
||||
groupStats.put("deposit", createGroupStat("已付定金", "deposit"));
|
||||
groupStats.put("illegal", createGroupStat("违规", "illegal"));
|
||||
|
||||
// 总统计数据
|
||||
int totalOrders = 0;
|
||||
double totalCommission = 0;
|
||||
double totalActualFee = 0;
|
||||
long totalSkuNum = 0;
|
||||
|
||||
// 违规订单统计
|
||||
long violationOrders = 0;
|
||||
double violationCommission = 0.0;
|
||||
|
||||
// 按分组统计
|
||||
for (OrderRows row : filteredList) {
|
||||
totalOrders++;
|
||||
if (row.getEstimateFee() != null) {
|
||||
totalCommission += row.getEstimateFee();
|
||||
}
|
||||
if (row.getActualFee() != null) {
|
||||
totalActualFee += row.getActualFee();
|
||||
}
|
||||
if (row.getSkuNum() != null) {
|
||||
totalSkuNum += row.getSkuNum();
|
||||
}
|
||||
|
||||
// 按validCode分组统计
|
||||
if (row.getValidCode() != null) {
|
||||
String validCode = String.valueOf(row.getValidCode());
|
||||
for (Map.Entry<String, Object> group : groups.entrySet()) {
|
||||
List<String> codes = (List<String>) group.getValue();
|
||||
if (codes.contains(validCode)) {
|
||||
Map<String, Object> stat = groupStats.get(group.getKey());
|
||||
stat.put("count", (Integer) stat.get("count") + 1);
|
||||
stat.put("commission", (Double) stat.get("commission") + (row.getEstimateFee() != null ? row.getEstimateFee() : 0));
|
||||
stat.put("actualFee", (Double) stat.get("actualFee") + (row.getActualFee() != null ? row.getActualFee() : 0));
|
||||
if (row.getSkuNum() != null) {
|
||||
stat.put("skuNum", (Long) stat.get("skuNum") + row.getSkuNum());
|
||||
}
|
||||
|
||||
// 统计违规订单
|
||||
if ("illegal".equals(group.getKey())) {
|
||||
violationOrders++;
|
||||
// 违规订单佣金计算方式:实际价格 * 佣金比例
|
||||
if (row.getActualCosPrice() != null && row.getCommissionRate() != null) {
|
||||
violationCommission += row.getActualCosPrice() * row.getCommissionRate() * 0.01;
|
||||
} else if (row.getEstimateFee() != null) {
|
||||
// 如果无法计算,使用预估佣金
|
||||
violationCommission += row.getEstimateFee();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.put("totalOrders", totalOrders);
|
||||
result.put("totalCommission", totalCommission);
|
||||
result.put("totalActualFee", totalActualFee);
|
||||
result.put("totalSkuNum", totalSkuNum);
|
||||
result.put("violationOrders", violationOrders);
|
||||
result.put("violationCommission", violationCommission);
|
||||
result.put("groupStats", groupStats);
|
||||
|
||||
return AjaxResult.success(result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建分组统计对象
|
||||
*/
|
||||
private Map<String, Object> createGroupStat(String label, String value) {
|
||||
Map<String, Object> stat = new HashMap<>();
|
||||
stat.put("label", label);
|
||||
stat.put("value", value);
|
||||
stat.put("count", 0);
|
||||
stat.put("commission", 0.0);
|
||||
stat.put("actualFee", 0.0);
|
||||
stat.put("skuNum", 0L);
|
||||
return stat;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -20,7 +20,7 @@ import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.jarvis.domain.SuperAdmin;
|
||||
import com.ruoyi.jarvis.service.ISuperAdminService;
|
||||
import com.ruoyi.jarvis.service.SuperAdminService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
@@ -34,7 +34,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
||||
public class SuperAdminController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISuperAdminService superAdminService;
|
||||
private SuperAdminService superAdminService;
|
||||
|
||||
/**
|
||||
* 查询超级管理员列表
|
||||
|
||||
Reference in New Issue
Block a user