From fbdbb67c9de7a99398b5776435abb69352a11845 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期一, 26 一月 2026 14:04:01 +0800
Subject: [PATCH] 经销商管理
---
server/dmmall_service/src/main/java/com/doumee/service/business/impl/WorkbenchServiceImpl.java | 134 +++++++++++++++++++++++++++++++++++++++++---
1 files changed, 125 insertions(+), 9 deletions(-)
diff --git a/server/dmmall_service/src/main/java/com/doumee/service/business/impl/WorkbenchServiceImpl.java b/server/dmmall_service/src/main/java/com/doumee/service/business/impl/WorkbenchServiceImpl.java
index 1b84f94..b619893 100644
--- a/server/dmmall_service/src/main/java/com/doumee/service/business/impl/WorkbenchServiceImpl.java
+++ b/server/dmmall_service/src/main/java/com/doumee/service/business/impl/WorkbenchServiceImpl.java
@@ -35,6 +35,7 @@
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
+import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
@@ -57,33 +58,148 @@
public class WorkbenchServiceImpl implements WorkbenchService {
@Autowired
private GoodsorderMapper goodsorderMapper;
+ @Autowired
+ private GoodsorderDetailMapper goodsorderDetailMapper;
@Override
public BusinessDataCountVO businessData(CountDataDTO param) {
BusinessDataCountVO data = new BusinessDataCountVO();
int dataType = param.getDateType();//0浠婃棩 1杩戜竷鏃� 2杩�30鏃� 3杩�1骞�
- int days = 1;
+ String name = "HOUR(CREATE_DATE)";
+ List<String> dateList = new ArrayList<>();
+ Date date = Utils.Date.getEnd(new Date());//浠婃棩 23:59:59
+ Date startDate = DateUtil.addDaysToDate(date,-1);
switch (dataType) {
case 1: {
- days = 7;
+ name = "DATE_FORMAT(t.CREATE_DATE, '%Y-%m-%d')";
+ for(int i=1;i<=7;i++){
+ dateList.add(DateUtil.getPlusTime2(DateUtil.addDaysToDate(date,7-i)));
+ }
+ startDate = DateUtil.addDaysToDate(date,7);
break;
} case 2: {
- days =30;
+ name = "DATE_FORMAT(GoodsCREATE_DATE, '%Y-%m-%d')";
+ for(int i=1;i<=30;i++){
+ dateList.add(DateUtil.getPlusTime2(DateUtil.addDaysToDate(date,30-i)));
+ }
+ startDate = DateUtil.addDaysToDate(date,30);
break;
} case 3: {
- days = 365;
+ startDate = DateUtil.increaseMonth(date,-12);
+ name = "DATE_FORMAT(GoodsCREATE_DATE, '%Y-%m')";
+ for(int i=1;i<=12;i++){
+ dateList.add(DateUtil.getPlusTime2(DateUtil.increaseMonth(date,12-i)));
+ }
break;
} default:{
-
+ for(int i=0;i<=23;i++){
+ dateList.add(i+"");
+ }
+ break;
}
}
- Date startDate = DateUtil.addDaysToDate(Utils.Date.getStart(new Date()),-days);
- CountDataVO r= goodsorderMapper.selectJoinOne(CountDataVO.class,new MPJLambdaWrapper<Goodsorder>()
+ //璁㈠崟閿�閲�
+ CountDataVO r = goodsorderMapper.selectJoinOne(CountDataVO.class,new MPJLambdaWrapper<Goodsorder>()
+ .select("(select count(t.id) )",CountDataVO::getNum)
+ .select("(select sum(t.totalPrice) )",CountDataVO::getPrice)
.ge(Goodsorder::getCreateDate,startDate)
- .in(Goodsorder::getStatus,Constants.OrderStatus.DONE.getKey(),Constants.OrderStatus.DONE.getKey())
- );
+ .eq(Goodsorder::getIsdeleted,Constants.ZERO)
+ .in(Goodsorder::getStatus,Constants.OrderStatus.DONE.getKey(),Constants.OrderStatus.REFUND.getKey()) );
+ if (r != null) {
+ data.setNum(Constants.formatLongNum(r.getNum()));//璁㈠崟閲�
+ data.setPrice(Constants.formatBigdecimal(r.getPrice()));//璁㈠崟閲戦
+ }
+ //閫�娆剧粺璁�
+ CountDataVO r1 = goodsorderMapper.selectJoinOne(CountDataVO.class,new MPJLambdaWrapper<Goodsorder>()
+ .select("(select count(t.id) )",CountDataVO::getNum)
+ .select("(select sum(t.reundMoney) )",CountDataVO::getPrice)
+ .ge(Goodsorder::getRefundTime,startDate)
+ .eq(Goodsorder::getIsdeleted,Constants.ZERO)
+ .in(Goodsorder::getStatus,Constants.OrderStatus.REFUND.getKey()) );
+
+ if (r1 != null) {
+ data.setNum1(Constants.formatLongNum(r1.getNum()));//閫�娆惧崟閲�
+ data.setPrice1(Constants.formatBigdecimal(r1.getPrice()));//閫�娆鹃噾棰�
+ }
+
+ //缁熻璁㈠崟閿�閲忓拰閿�鍞闆嗗悎
+ List<CountDataVO> list1 = goodsorderMapper.selectJoinList(CountDataVO.class,new MPJLambdaWrapper<Goodsorder>()
+ .select("(select "+name+")",CountDataVO::getDateStr)
+ .select("(select count(t.id) )",CountDataVO::getNum)
+ .select("(select sum(t.totalPrice) )",CountDataVO::getPrice)
+ .ge(Goodsorder::getRefundTime,startDate)
+ .eq(Goodsorder::getIsdeleted,Constants.ZERO)
+ .in(Goodsorder::getStatus,Constants.OrderStatus.DONE.getKey(),Constants.OrderStatus.REFUND.getKey())
+ .groupBy(name) );
+
+ List<CountDataVO> datalist1 = new ArrayList<>();
+ for(String str : dateList){
+ CountDataVO tmp = new CountDataVO();
+ tmp.setDateStr(str);
+ tmp.setNum(0l);
+ tmp.setPrice(new BigDecimal(0));
+ if(list1!=null){
+ for(CountDataVO p : list1){
+ if(StringUtils.equals(p.getDateStr(),str)){
+ tmp.setNum(Constants.formatLongNum(p.getNum()));
+ tmp.setPrice(Constants.formatBigdecimal(p.getPrice()));
+ }
+ }
+ }
+ datalist1.add(tmp);
+ }
+ data.setDataList(datalist1 );
+
+ //缁熻鍚勭被鍟嗗搧鏁版嵁闆嗗悎
+ List<CountDataVO> list2 = goodsorderDetailMapper.selectJoinList(CountDataVO.class,new MPJLambdaWrapper<GoodsorderDetail>()
+ .select("(select "+name+")",CountDataVO::getDateStr)
+ .selectAs(Labels::getName,CountDataVO::getName)
+ .select("(select sum(t.totalPrice) )",CountDataVO::getPrice)
+ .leftJoin(Goods.class,Goods::getId,GoodsorderDetail::getGoodsId)
+ .leftJoin(Labels.class,Labels::getId,Goods::getCategoryId)
+ .leftJoin(Goodsorder.class,Goodsorder::getId,GoodsorderDetail::getOrderId)
+ .ge(Goodsorder::getRefundTime,startDate)
+ .eq(Goodsorder::getIsdeleted,Constants.ZERO)
+ .in(Goodsorder::getStatus,Constants.OrderStatus.DONE.getKey(),Constants.OrderStatus.REFUND.getKey())
+ .groupBy(name +",t2.category_id"));
+
+ List<BigDecimal[]> datalist2 = new ArrayList<>();
+ List<String> cateList = getCateListFromDataList(list2);
+ if(list2!=null &&list2.size()>0 && cateList!=null && cateList.size()>0){
+ BigDecimal[] temp = new BigDecimal[dateList.size()];
+ for(String cate : cateList){
+ for(int i=0;i<dateList.size();i++){
+ temp[i] = new BigDecimal(0);
+ for(CountDataVO model : list2){
+ if(StringUtils.equals(model.getDateStr(),dateList.get(i)) && StringUtils.equals(model.getName(),cate)){
+ temp[i] = temp[i].add(Constants.formatBigdecimal(model.getPrice()));
+ }
+ }
+ }
+ datalist2.add(temp);
+ }
+ }
+ data.setCateList(cateList);
+ data.setNumList(datalist2 );
return data;
}
+ private List<String> getCateListFromDataList(List<CountDataVO> list2) {
+ List<String> list = new ArrayList<>();
+ for(CountDataVO model :list2){
+ boolean isnew = true;
+ for(String str :list){
+ if(StringUtils.equals(str,model.getName())){
+ isnew = false;
+ }
+
+ }
+ if(isnew ){
+ list.add(model.getName());
+ }
+ }
+ return list;
+ }
+
}
--
Gitblit v1.9.3