From c11bce150d6e702f41ce247a0c62ea03401318f1 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期一, 26 一月 2026 18:34:08 +0800
Subject: [PATCH] 经销商管理
---
server/dmmall_service/src/main/java/com/doumee/dao/system/vo/CountDataVO.java | 3
server/dmmall_service/src/main/java/com/doumee/service/business/WorkbenchService.java | 3
admin/src/views/index.vue | 219 ++++++++++++++++++++++-----
server/dmmall_admin/src/main/java/com/doumee/api/business/WorkbenchController.java | 17 +
server/dmmall_service/src/main/java/com/doumee/service/business/impl/WorkbenchServiceImpl.java | 144 +++++++++++++-----
server/dmmall_service/src/main/java/com/doumee/core/utils/DateUtil.java | 67 +++++++
admin/src/api/business/workbench.js | 12 +
server/dmmall_service/src/main/java/com/doumee/dao/system/vo/BusinessDataCountVO.java | 10
8 files changed, 380 insertions(+), 95 deletions(-)
diff --git a/admin/src/api/business/workbench.js b/admin/src/api/business/workbench.js
index c3890ff..1b61405 100644
--- a/admin/src/api/business/workbench.js
+++ b/admin/src/api/business/workbench.js
@@ -1,7 +1,17 @@
import request from '../../utils/request'
-export function allList (data) {
+export function businessData (data) {
return request.post('/business/workbench/businessData', data, {
trim: true
})
}
+export function shopRankList10 (data) {
+ return request.post('/business/workbench/shopRankList10', data, {
+ trim: true
+ })
+}
+export function goodsRankList10 (data) {
+ return request.post('/business/workbench/goodsRankList10', data, {
+ trim: true
+ })
+}
diff --git a/admin/src/views/index.vue b/admin/src/views/index.vue
index 44acdb1..34ad636 100644
--- a/admin/src/views/index.vue
+++ b/admin/src/views/index.vue
@@ -11,22 +11,22 @@
<div class="data-summary">
<div class="data-item blue">
<div>{{tabName}}閿�鍞</div>
- <div class="data-num">锟{ (countData.totalPrice ||0).toFixed(2) }}</div>
+ <div class="data-num">锟{ (topData.price ||0).toFixed(2) }}</div>
</div>
<div class="parting"></div>
<div class="data-item yellow">
<div>{{tabName}}鎴愪氦璁㈠崟閲�</div>
- <div class="data-num">{{ countData.totalNum ||0}}</div>
+ <div class="data-num">{{ topData.num||0}}</div>
</div>
<div class="parting"></div>
<div class="data-item green">
<div>{{tabName}}閫�娆鹃噾棰�</div>
- <div class="data-num">锟{( countData.totalRefundPrice ||0).toFixed(2) }}</div>
+ <div class="data-num">锟{( topData.price1 ||0).toFixed(2) }}</div>
</div>
<div class="parting"></div>
<div class="data-item orange">
<div>{{tabName}}閫�娆捐鍗曢噺</div>
- <div class="data-num">{{ countData.totalRefundNum ||0 }}</div>
+ <div class="data-num">{{ topData.num1 ||0 }}</div>
</div>
<div class="parting"></div>
</div>
@@ -35,7 +35,7 @@
<div class="change-style">
<div class="count-left">
<div class="item-title">璁㈠崟閲忎笌閿�鍞瓒嬪娍</div>
- <div ref="orderCount" class="bottom"></div>
+ <div ref="orderCount" class="bottom" ></div>
</div>
<div class="count-right">
<div class="item-title">鍚勫搧绫婚攢鍞鍗犳瘮</div>
@@ -46,9 +46,9 @@
<div class="tab-title" style="display: flex;align-items: center; ">
<span style="">鎺掑悕鍒嗘瀽</span>
<div class="tab-item" style="margin-left: 20px;" >
- <el-date-picker style="width: 110px;height: 22px;margin-right: 10px;" v-model="searchForm.topYear" type="year"
+ <el-date-picker style="width: 110px;height: 22px;margin-right: 10px;" v-model="searchForm.topYear" type="year" @change="changeYearMonth"
clearable value-format="yyyy" format="yyyy'骞�'" placeholder="骞翠唤" ></el-date-picker>
- <el-date-picker style="width: 100px;height: 22px;" v-model="searchForm.topMonth" type="month"
+ <el-date-picker style="width: 100px;height: 22px;" v-model="searchForm.topMonth" type="month" @change="changeYearMonth"
clearable value-format="MM" format="MM'鏈�'" placeholder="鏈堜唤" ></el-date-picker>
</div>
</div>
@@ -69,7 +69,7 @@
<el-table-column prop="name" label="缁忛攢鍟嗗悕绉�" align="center" > </el-table-column>
<el-table-column prop="num" label="璁㈠崟閲�" align="center" > </el-table-column>
<el-table-column prop="price" label="閿�鍞锛堝厓锛�" align="center" ></el-table-column>
- <el-table-column prop="num2" label="浼氬憳鏁�" align="center" ></el-table-column>
+ <el-table-column prop="num1" label="浼氬憳鏁�" align="center" ></el-table-column>
</el-table>
</div>
</div>
@@ -138,27 +138,40 @@
<script>
import TableLayout from '@/layouts/TableLayout'
+import BaseTable from '@/components/base/BaseTable'
import * as echarts from 'echarts'
export default {
+ extends: BaseTable,
components: {
TableLayout
},
data () {
return {
- tabs2: [{ index: 0, name: '鎸夐攢閲�' }, { index: 1, name: '鎸夐攢鍞'}],
+ loading1: false,
+ loading2: false,
+ loading3: false,
+ tabs2: [{ index: 0, name: '鎸夐攢閲�' }, { index: 1, name: '鎸夐攢鍞' }],
tabs1: [{ index: 0, name: '鎸夎鍗曢噺' }, { index: 1, name: '鎸夐攢鍞' }, { index: 2, name: '鎸変細鍛樻暟' }],
tabs: [{ index: 0, name: '浠婃棩' }, { index: 1, name: '杩�7鏃�' }, { index: 2, name: '杩�30鏃�' }, { index: 3, name: '杩�12鏈�' }],
tabName: '浠婃棩',
tabIndex: 0,
tabIndex1: 0,
tabIndex2: 0,
- searchForm:{
- topYear:null,
- topMonth:null,
- topYear2:null,
+ searchForm: {
+ topYear: null,
+ topMonth: null,
+ topYear2: null
},
- topData:{
-
+ topData: {
+ num: 0,
+ num1: 0,
+ price: 0,
+ price1: 0,
+ dateStrList: [],
+ dataList: [],
+ dataList2: [],
+ cateList: [],
+ numList: []
},
countData: {
totalPrice: 1000,
@@ -166,10 +179,8 @@
totalRefundPrice: 10000,
totalRefundNum: 100
},
- dataList1:[],
- dataList2:[],
- orderCorderCount: [10, 10, 20, 10, 40, 10, 30],
- opinionData: ['3.20', '3.21', '3.22', '3.23', '3.24', '3.25', '3.26'],
+ dataList1: [],
+ dataList2: [],
myChart0: null,
myChart1: null
}
@@ -183,10 +194,54 @@
})
},
mounted () {
- this.initCountData()
+ this.initTopData()
+ this.initShopRankData()
+ this.initGoodsRankData()
},
methods: {
- initCountData () {
+ changeYearMonth(){
+ this.initGoodsRankData()
+ this.initShopRankData()
+ },
+ initShopRankData () {
+ this.loading2 = true
+ this.api.shopRankList10({ year: this.searchForm.topYear, month: this.searchForm.topMonth ,type:this.tabIndex1}).then(res => {
+ res = res || []
+ this.dataList1 = res
+ }).finally(() => {
+ this.loading2 = false
+ })
+ },
+ initGoodsRankData () {
+ this.loading3 = true
+ this.api.goodsRankList10({ year: this.searchForm.topYear, month: this.searchForm.topMonth ,type:this.tabIndex2}).then(res => {
+ res = res || []
+ this.dataList2 = res
+ }).finally(() => {
+ this.loading3 = false
+ })
+ },
+ initTopData () {
+ this.loading1 = true
+ this.initTopEcharts()
+ this.api.businessData({ dateType: this.tabIndex }).then(res => {
+ res = res || {}
+ res.num = res.num || 0
+ res.num1 = res.num1 || 0
+ res.price = res.price || 0
+ res.price1 = res.price1 || 0
+ res.dateStrList = res.dateStrList || []
+ res.datalist2 = res.datalist2 || []
+ res.dataList = res.dataList || []
+ res.cateList = res.cateList || []
+ this.topData = res
+ this.renderEchartOption0()
+ this.renderEchartOption2()
+ }).finally(() => {
+ this.loading1 = false
+ })
+ },
+ initTopEcharts () {
this.myChart0 = echarts.init(this.$refs.orderCount)
window.addEventListener('resize', () => {
this.myChart0.resize()
@@ -195,23 +250,46 @@
window.addEventListener('resize', () => {
this.myChart1.resize()
})
- this.renderOrderChange(this.myChart0)
- this.renderOrderChange(this.myChart1)
+ this.renderEchartOption0()
+ this.renderEchartOption2()
},
changeTab (item) {
- this.tabName = item.name
- this.tabIndex = item.index
+ if (this.loading1) {
+ return
+ }
+ if (item.index !== this.tabIndex) {
+ this.tabName = item.name
+ this.tabIndex = item.index
+ this.initTopData()
+ }
},
changeTab1 (item) {
- this.tabIndex1 = item.index
+ if (this.loading2) {
+ return
+ }
+ if (item.index !== this.tabIndex1) {
+ this.tabName = item.name
+ this.tabIndex1 = item.index
+ this.initShopRankData()
+ }
},
changeTab2 (item) {
- this.tabIndex2 = item.index
+ if (this.loading3) {
+ return
+ }
+ if (item.index !== this.tabIndex2) {
+ this.tabName = item.name
+ this.tabIndex2 = item.index
+ this.initGoodsRankData()
+ }
},
- renderOrderChange (chart) {
- chart.setOption({
+ renderEchartOption0 () {
+ this.myChart0.setOption({
tooltip: {
- trigger: 'axis'
+ trigger: 'axis',
+ axisPointer: {
+ type: 'cross'
+ }
},
grid: {
left: '3%',
@@ -221,23 +299,84 @@
},
toolbox: {
feature: {
-
}
+ },
+ legend: {
+ data: ['璁㈠崟閲�', '閿�鍞(鍏�)']
},
xAxis: {
type: 'category',
boundaryGap: false,
- data: this.opinionData
+ data: this.topData.dateStrList || []
},
- yAxis: {
- type: 'value'
+ yAxis: [
+ {
+ type: 'value',
+ name: '璁㈠崟閲�',
+ min: 0
+ },
+ {
+ type: 'value',
+ name: '閿�鍞(鍏�)',
+ min: 0
+ }
+ ],
+ series: [
+ {
+ name: '璁㈠崟閲�',
+ data: this.topData.dataList || [],
+ type: 'bar'
+ },
+ {
+ name: '閿�鍞(鍏�)',
+ yAxisIndex: 1,
+ data: this.topData.dataList2 || [],
+ type: 'line'
+ }
+ ]
+ })
+ },
+ renderEchartOption2 () {
+ const series = []
+ this.topData.cateList.forEach((item, index) => {
+ series.push( {
+ name: item.name,
+ type: 'bar',
+ stack: 'total',
+ barWidth: '60%',
+ label: {
+ // show: true
+ },
+ data: item.data||[]
+ })
+ })
+ this.myChart1.setOption({
+ tooltip: {
+ trigger: 'axis',
+ axisPointer: {
+ type: 'cross'
+ }
},
- series: [{
- name: '璁㈠崟',
- type: 'line',
- stack: '鎬婚噺',
- data: this.orderCorderCount
- }]
+ grid: {
+ left: '3%',
+ right: '4%',
+ bottom: '3%',
+ containLabel: true
+ },
+ toolbox: {
+ feature: {
+ }
+ },
+ legend: {
+ data: this.topData.cateList || []
+ },
+ xAxis: {
+ type: 'category',
+ boundaryGap: false,
+ data: this.topData.dateStrList || []
+ },
+ yAxis: { type: 'value' } ,
+ series
})
}
}
diff --git a/server/dmmall_admin/src/main/java/com/doumee/api/business/WorkbenchController.java b/server/dmmall_admin/src/main/java/com/doumee/api/business/WorkbenchController.java
index 9c8b21f..6b7afac 100644
--- a/server/dmmall_admin/src/main/java/com/doumee/api/business/WorkbenchController.java
+++ b/server/dmmall_admin/src/main/java/com/doumee/api/business/WorkbenchController.java
@@ -15,6 +15,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
+import java.util.List;
+
/**
* @author 姹熻箘韫�
* @date 2023/03/21 15:48
@@ -27,11 +29,20 @@
@Autowired
private WorkbenchService workbenchService;
- @PreventRepeat
- @ApiOperation("鏂板缓")
+ @ApiOperation("缁忚惀鏁版嵁鍒嗘瀽")
@PostMapping("/businessData")
- public ApiResponse<BusinessDataCountVO> create(@RequestBody CountDataDTO param) {
+ public ApiResponse<BusinessDataCountVO> businessData(@RequestBody CountDataDTO param) {
return ApiResponse.success(workbenchService.businessData(param));
}
+ @ApiOperation("缁忛攢鍟員OP10")
+ @PostMapping("/shopRankList10")
+ public ApiResponse<List<BusinessDataCountVO>> shopRankList10(@RequestBody CountDataDTO param) {
+ return ApiResponse.success(workbenchService.shopRankList10(param));
+ }
+ @ApiOperation("鍗曚竴鍟嗗搧TOP10")
+ @PostMapping("/goodsRankList10")
+ public ApiResponse<List<BusinessDataCountVO>> goodsRankList10(@RequestBody CountDataDTO param) {
+ return ApiResponse.success(workbenchService.goodsRankList10(param));
+ }
}
diff --git a/server/dmmall_service/src/main/java/com/doumee/core/utils/DateUtil.java b/server/dmmall_service/src/main/java/com/doumee/core/utils/DateUtil.java
index b1520c5..1b2b8ff 100644
--- a/server/dmmall_service/src/main/java/com/doumee/core/utils/DateUtil.java
+++ b/server/dmmall_service/src/main/java/com/doumee/core/utils/DateUtil.java
@@ -7,13 +7,11 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.*;
+import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
-import java.util.Calendar;
+import java.util.*;
import java.util.Date;
-import java.util.Enumeration;
-import java.util.GregorianCalendar;
-import java.util.Hashtable;
-import java.util.Locale;
+
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
@@ -1240,7 +1238,12 @@
}
return length;
}
+ public static String minusMonthToDate(LocalDate date, int num) {
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
+ String month = date.minusMonths(num).format(formatter);
+ return month;
+}
/**
* 寰楀埌涓や釜鏃ユ湡涔嬮棿鐩稿樊鐨勫ぉ鏁�
*
@@ -1712,7 +1715,56 @@
calo.add(Calendar.DATE, intBetween);
return calo.getTime();
}
+ public static List<Date> getDatePeriodByYearAndMonth(int year , int month) {
+ List<Date> list = new ArrayList<>();
+ list.add(null);
+ list.add(null);
+ try {
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(Calendar.YEAR, year);
+ calendar.set(Calendar.MONTH, month);
+ calendar.set(Calendar.DAY_OF_MONTH, 1);
+ calendar.set(Calendar.HOUR_OF_DAY, 0);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ list.set(0,calendar.getTime());
+ calendar.add(Calendar.MONTH, 1); // 鍔犱竴涓湀
+ calendar.add(Calendar.DAY_OF_MONTH, -1); // 鐒跺悗鍑忎竴澶╁緱鍒拌繖涓湀鏈�鍚庝竴澶�
+ calendar.set(Calendar.HOUR_OF_DAY, 23);
+ calendar.set(Calendar.MINUTE, 59);
+ calendar.set(Calendar.SECOND, 59);
+ list.set(1,calendar.getTime());
+ }catch (Exception e){
+ }
+
+ return list;
+ }
+ public static List<Date> getDatePeriodByYear(int year) {
+ List<Date> list = new ArrayList<>();
+ list.add(null);
+ list.add(null);
+ try {
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(Calendar.YEAR, year);
+ calendar.set(Calendar.MONTH,0);
+ calendar.set(Calendar.DAY_OF_MONTH, 1);
+ calendar.set(Calendar.HOUR_OF_DAY, 0);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ list.set(0,calendar.getTime());
+ calendar.add(Calendar.YEAR, 1); // 鍔犱竴涓湀
+ calendar.add(Calendar.DAY_OF_MONTH, -1); // 鐒跺悗鍑忎竴澶╁緱鍒拌繖涓湀鏈�鍚庝竴澶�
+ calendar.set(Calendar.HOUR_OF_DAY, 23);
+ calendar.set(Calendar.MINUTE, 59);
+ calendar.set(Calendar.SECOND, 59);
+ list.set(1,calendar.getTime());
+ }catch (Exception e){
+
+ }
+
+ return list;
+ }
/**
* 寰楀埌灏哾ate澧炲姞鎸囧畾骞存暟鍚庣殑date
*
@@ -2753,7 +2805,10 @@
public static void main(String[] args) {
try {
- System.out.println(RandomStringUtils.randomNumeric(3));
+ System.out.println(getPlusTime2(getDatePeriodByYearAndMonth(2026,11).get(0)));
+ System.out.println(getPlusTime2(getDatePeriodByYearAndMonth(2026,11).get(1)));
+ System.out.println(getPlusTime2(getDatePeriodByYear(2026).get(0)));
+ System.out.println(getPlusTime2(getDatePeriodByYear(2026).get(1)));
} catch (Exception ex) {
ex.printStackTrace();
}
diff --git a/server/dmmall_service/src/main/java/com/doumee/dao/system/vo/BusinessDataCountVO.java b/server/dmmall_service/src/main/java/com/doumee/dao/system/vo/BusinessDataCountVO.java
index 1b29b5a..c769b0c 100644
--- a/server/dmmall_service/src/main/java/com/doumee/dao/system/vo/BusinessDataCountVO.java
+++ b/server/dmmall_service/src/main/java/com/doumee/dao/system/vo/BusinessDataCountVO.java
@@ -22,11 +22,11 @@
@ApiModelProperty(value = "缁熻缁村害鍚嶇О")
private String name;
@ApiModelProperty(value = "缁熻鍒楄〃鏁版嵁")
- private List<CountDataVO> dataList;
+ private List<Long> dataList;
+ @ApiModelProperty(value = "妯酱")
+ private List<String> dateStrList;
@ApiModelProperty(value = "缁熻鍒楄〃鏁版嵁2")
- private List<CountDataVO> dataList2;
+ private List<BigDecimal> dataList2;
@ApiModelProperty(value = "缁熻鍒楄〃鏁版嵁鍒嗙被2")
- private List<String> cateList;
- @ApiModelProperty(value = "缁熻鍒楄〃鏁版嵁3")
- private List<BigDecimal[]> numList;
+ private List<CountDataVO> cateList;
}
diff --git a/server/dmmall_service/src/main/java/com/doumee/dao/system/vo/CountDataVO.java b/server/dmmall_service/src/main/java/com/doumee/dao/system/vo/CountDataVO.java
index ca7ef89..8c90bde 100644
--- a/server/dmmall_service/src/main/java/com/doumee/dao/system/vo/CountDataVO.java
+++ b/server/dmmall_service/src/main/java/com/doumee/dao/system/vo/CountDataVO.java
@@ -6,6 +6,7 @@
import lombok.Data;
import java.math.BigDecimal;
+import java.util.List;
@Data
@ApiModel("缁忛攢鍟嗚处鎴锋槑缁嗗璞�")
@@ -26,4 +27,6 @@
private String name;
@ApiModelProperty(value = "缁熻缁村害鏃堕棿鍚嶇О")
private String dateStr;
+ @ApiModelProperty(value = "閿�鍞闆嗗悎")
+ private BigDecimal[] data;
}
diff --git a/server/dmmall_service/src/main/java/com/doumee/service/business/WorkbenchService.java b/server/dmmall_service/src/main/java/com/doumee/service/business/WorkbenchService.java
index 6f11655..170ac07 100644
--- a/server/dmmall_service/src/main/java/com/doumee/service/business/WorkbenchService.java
+++ b/server/dmmall_service/src/main/java/com/doumee/service/business/WorkbenchService.java
@@ -17,4 +17,7 @@
public interface WorkbenchService {
BusinessDataCountVO businessData(CountDataDTO param);
+
+ List<BusinessDataCountVO> shopRankList10(CountDataDTO param);
+ List<BusinessDataCountVO> goodsRankList10(CountDataDTO param);
}
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 b619893..0a6262c 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
@@ -45,6 +45,7 @@
import javax.annotation.Resource;
import java.math.BigDecimal;
+import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
@@ -60,12 +61,71 @@
private GoodsorderMapper goodsorderMapper;
@Autowired
private GoodsorderDetailMapper goodsorderDetailMapper;
+ @Override
+ public List<BusinessDataCountVO> shopRankList10(CountDataDTO param) {
+ Date startDate = null,endDate = null;
+ if(param.getYear()!=null && param.getMonth()!=null){
+ List<Date> dList = DateUtil.getDatePeriodByYearAndMonth(param.getYear(),param.getMonth()-1);
+ startDate = dList.get(0);
+ endDate = dList.get(1);
+ }else if(param.getYear()!=null && param.getMonth()==null){
+ List<Date> dList = DateUtil.getDatePeriodByYear(param.getYear());
+ startDate = dList.get(0);
+ endDate = dList.get(1);
+ }
+ //缁熻璁㈠崟閿�閲忓拰閿�鍞闆嗗悎
+ List<BusinessDataCountVO> list1 = goodsorderMapper.selectJoinList(BusinessDataCountVO.class,new MPJLambdaWrapper<Goodsorder>()
+ .selectAs(Shop::getName,BusinessDataCountVO::getName)
+ .select("(select count(distinct(t.member_id)) )",BusinessDataCountVO::getNum1)
+ .select("(select count(t.id) )",BusinessDataCountVO::getNum)
+ .select("(select sum(t.total_price) )",BusinessDataCountVO::getPrice)
+ .leftJoin(Shop.class,Shop::getId,Goodsorder::getDistributionShopId)
+ .ge(startDate!=null,Goodsorder::getCreateDate,startDate)
+ .ne(endDate!=null,Goodsorder::getCreateDate,endDate)
+ .eq(Goodsorder::getIsdeleted,Constants.ZERO)
+ .in(Goodsorder::getStatus,Constants.OrderStatus.DONE.getKey(),Constants.OrderStatus.REFUND.getKey())
+ .groupBy(Goodsorder::getDistributionShopId)
+ .orderByDesc(Constants.equalsInteger(param.getType() ,0),"sum(t.total_price) ")
+ .orderByDesc(Constants.equalsInteger(param.getType() ,1),"count(t.id) ")
+ .orderByDesc(Constants.equalsInteger(param.getType() ,2),"count(distinct(t.member_id))")
+ .last("limit 10")) ;
+ return list1;
+ }
+ @Override
+ public List<BusinessDataCountVO> goodsRankList10(CountDataDTO param) {
+ Date startDate = null,endDate = null;
+ if(param.getYear()!=null && param.getMonth()!=null){
+ List<Date> dList = DateUtil.getDatePeriodByYearAndMonth(param.getYear(),param.getMonth()-1);
+ startDate = dList.get(0);
+ endDate = dList.get(1);
+ }else if(param.getYear()!=null && param.getMonth()==null){
+ List<Date> dList = DateUtil.getDatePeriodByYear(param.getYear());
+ startDate = dList.get(0);
+ endDate = dList.get(1);
+ }
+ //缁熻璁㈠崟閿�閲忓拰閿�鍞闆嗗悎
+ List<BusinessDataCountVO> list1 = goodsorderDetailMapper.selectJoinList(BusinessDataCountVO.class,new MPJLambdaWrapper<GoodsorderDetail>()
+ .selectAs(Goods::getName,BusinessDataCountVO::getName)
+ .select("(select sum(t.goods_num) )",BusinessDataCountVO::getNum)
+ .select("(select sum(ifnull(t.price,0) * ifnull(t.goods_num,0)))",BusinessDataCountVO::getPrice)
+ .leftJoin(Goodsorder.class,Goodsorder::getId,GoodsorderDetail::getOrderId)
+ .leftJoin(Goods.class,Goods::getId,GoodsorderDetail::getGoodsId)
+ .ge(startDate!=null,Goodsorder::getCreateDate,startDate)
+ .ne(endDate!=null,Goodsorder::getCreateDate,endDate)
+ .eq(Goodsorder::getIsdeleted,Constants.ZERO)
+ .in(Goodsorder::getStatus,Constants.OrderStatus.DONE.getKey(),Constants.OrderStatus.REFUND.getKey())
+ .groupBy(GoodsorderDetail::getGoodsId)
+ .orderByDesc(Constants.equalsInteger(param.getType() ,1),"sum(ifnull(t.price,0) * ifnull(t.goods_num,0)) ")
+ .orderByDesc(Constants.equalsInteger(param.getType() ,0),"sum(t.goods_num) ")
+ .last("limit 10")) ;
+ return list1;
+ }
@Override
public BusinessDataCountVO businessData(CountDataDTO param) {
BusinessDataCountVO data = new BusinessDataCountVO();
int dataType = param.getDateType();//0浠婃棩 1杩戜竷鏃� 2杩�30鏃� 3杩�1骞�
- String name = "HOUR(CREATE_DATE)";
+ String name = "HOUR(t.CREATE_DATE)";
List<String> dateList = new ArrayList<>();
Date date = Utils.Date.getEnd(new Date());//浠婃棩 23:59:59
Date startDate = DateUtil.addDaysToDate(date,-1);
@@ -73,22 +133,23 @@
case 1: {
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)));
+ dateList.add(DateUtil.getShortTime(DateUtil.addDaysToDate(date,i-7)));
}
- startDate = DateUtil.addDaysToDate(date,7);
+ startDate = DateUtil.addDaysToDate(date,-7);
break;
} case 2: {
- name = "DATE_FORMAT(GoodsCREATE_DATE, '%Y-%m-%d')";
+ name = "DATE_FORMAT(t.CREATE_DATE, '%Y-%m-%d')";
for(int i=1;i<=30;i++){
- dateList.add(DateUtil.getPlusTime2(DateUtil.addDaysToDate(date,30-i)));
+ dateList.add(DateUtil.getShortTime(DateUtil.addDaysToDate(date,i-30)));
}
- startDate = DateUtil.addDaysToDate(date,30);
+ startDate = DateUtil.addDaysToDate(date,-30);
break;
} case 3: {
- startDate = DateUtil.increaseMonth(date,-12);
- name = "DATE_FORMAT(GoodsCREATE_DATE, '%Y-%m')";
+ LocalDate now = LocalDate.now();
+ startDate = DateUtil.increaseYear(date,-1);
+ name = "DATE_FORMAT(t.CREATE_DATE, '%Y-%m')";
for(int i=1;i<=12;i++){
- dateList.add(DateUtil.getPlusTime2(DateUtil.increaseMonth(date,12-i)));
+ dateList.add(DateUtil.minusMonthToDate(now,12-i));
}
break;
} default:{
@@ -98,10 +159,12 @@
break;
}
}
+
+ data.setDateStrList(dateList);
//璁㈠崟閿�閲�
CountDataVO r = goodsorderMapper.selectJoinOne(CountDataVO.class,new MPJLambdaWrapper<Goodsorder>()
.select("(select count(t.id) )",CountDataVO::getNum)
- .select("(select sum(t.totalPrice) )",CountDataVO::getPrice)
+ .select("(select sum(t.total_Price) )",CountDataVO::getPrice)
.ge(Goodsorder::getCreateDate,startDate)
.eq(Goodsorder::getIsdeleted,Constants.ZERO)
.in(Goodsorder::getStatus,Constants.OrderStatus.DONE.getKey(),Constants.OrderStatus.REFUND.getKey()) );
@@ -112,7 +175,7 @@
//閫�娆剧粺璁�
CountDataVO r1 = goodsorderMapper.selectJoinOne(CountDataVO.class,new MPJLambdaWrapper<Goodsorder>()
.select("(select count(t.id) )",CountDataVO::getNum)
- .select("(select sum(t.reundMoney) )",CountDataVO::getPrice)
+ .select("(select sum(t.refund_money) )",CountDataVO::getPrice)
.ge(Goodsorder::getRefundTime,startDate)
.eq(Goodsorder::getIsdeleted,Constants.ZERO)
.in(Goodsorder::getStatus,Constants.OrderStatus.REFUND.getKey()) );
@@ -127,76 +190,77 @@
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)
+ .select("(select sum(t.total_price) )",CountDataVO::getPrice)
+ .ge(Goodsorder::getCreateDate,startDate)
.eq(Goodsorder::getIsdeleted,Constants.ZERO)
.in(Goodsorder::getStatus,Constants.OrderStatus.DONE.getKey(),Constants.OrderStatus.REFUND.getKey())
.groupBy(name) );
- List<CountDataVO> datalist1 = new ArrayList<>();
+ List<Long> datalist1 = new ArrayList<>();
+ List<BigDecimal> datalistPrice = new ArrayList<>();
for(String str : dateList){
- CountDataVO tmp = new CountDataVO();
- tmp.setDateStr(str);
- tmp.setNum(0l);
- tmp.setPrice(new BigDecimal(0));
+ long tnum =0;
+ BigDecimal tprice = 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()));
+ tnum =(Constants.formatLongNum(p.getNum()));
+ tprice = (Constants.formatBigdecimal(p.getPrice()));
+ break;
}
}
}
- datalist1.add(tmp);
+ datalist1.add( tnum );
+ datalistPrice.add(tprice);
}
data.setDataList(datalist1 );
+ data.setDataList2(datalistPrice );
+ String name1 =name.replace("t.","t3.");
//缁熻鍚勭被鍟嗗搧鏁版嵁闆嗗悎
List<CountDataVO> list2 = goodsorderDetailMapper.selectJoinList(CountDataVO.class,new MPJLambdaWrapper<GoodsorderDetail>()
- .select("(select "+name+")",CountDataVO::getDateStr)
+ .select("(select "+name1+")",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)
+ .select("(select sum(ifnull(t.price,0) * ifnull(t.goods_num,0)) )",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::getCreateDate,startDate)
.eq(Goodsorder::getIsdeleted,Constants.ZERO)
.in(Goodsorder::getStatus,Constants.OrderStatus.DONE.getKey(),Constants.OrderStatus.REFUND.getKey())
- .groupBy(name +",t2.category_id"));
+ .groupBy(name1+",t1.category_id"));
- List<BigDecimal[]> datalist2 = new ArrayList<>();
- List<String> cateList = getCateListFromDataList(list2);
+ List<CountDataVO> 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(CountDataVO 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()));
+ if(StringUtils.equals(model.getDateStr(),dateList.get(i)) && StringUtils.equals(model.getName(),cate.getName())){
+ temp[i] = Constants.formatBigdecimal(model.getPrice());
}
}
}
- datalist2.add(temp);
+ cate.setData(temp);
}
}
data.setCateList(cateList);
- data.setNumList(datalist2 );
return data;
}
- private List<String> getCateListFromDataList(List<CountDataVO> list2) {
- List<String> list = new ArrayList<>();
+ private List<CountDataVO> getCateListFromDataList(List<CountDataVO> list2) {
+ List<CountDataVO> list = new ArrayList<>();
for(CountDataVO model :list2){
boolean isnew = true;
- for(String str :list){
- if(StringUtils.equals(str,model.getName())){
+ for(CountDataVO str :list){
+ if(StringUtils.equals(str.getName(),model.getName())){
isnew = false;
}
}
if(isnew ){
- list.add(model.getName());
+ list.add(model);
}
}
return list;
--
Gitblit v1.9.3