From cf5d8d46f71d0eed77d82702d30b339d418afd98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=85=81=E6=9E=9E?= <3422692813@qq.com> Date: Wed, 16 Oct 2024 15:09:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B010.16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fuintAdmin/src/views/shopowner.vue | 164 ++++++++++++------ .../business/member/mapper/LJStaffMapper.java | 2 +- .../member/mapper/xml/LJStaffMapper.xml | 6 +- .../order/controller/OilOrderController.java | 4 +- .../order/service/OilOrderService.java | 2 +- .../service/impl/OilOrderServiceImpl.java | 4 +- 6 files changed, 121 insertions(+), 61 deletions(-) diff --git a/fuintAdmin/src/views/shopowner.vue b/fuintAdmin/src/views/shopowner.vue index 69d59cf92..654bffe7c 100644 --- a/fuintAdmin/src/views/shopowner.vue +++ b/fuintAdmin/src/views/shopowner.vue @@ -266,9 +266,9 @@ export default { data() { return { amountList:[ - "今日" , - "昨日" , - "本周" , + // "今日" , + // "昨日" , + "近一周" , "本月" , "本季度" , "本年" @@ -348,7 +348,7 @@ export default { start.setMinutes(0) start.setSeconds(0) start.setMilliseconds(0) - this.value2 = [start, new Date()]; + this.value2 = [parseTime(oneWeekAgo), parseTime(nowDate)] this.getStoreList() this.getHardwareList() this.getNoticeList() @@ -379,25 +379,19 @@ export default { let nowDate = new Date(); let oneWeekAgo = new Date(nowDate.getTime() - 1 * 24 * 60 * 60 * 1000) this.value1 = [parseTime(oneWeekAgo),parseTime(oneWeekAgo)] - } else if (command=='本周'){ + } else if (command=='近一周'){ let nowDate = new Date(); let oneWeekAgo = new Date(nowDate.getTime() - 6 * 24 * 60 * 60 * 1000) this.value1 = [parseTime(oneWeekAgo),parseTime(nowDate)] } else if (command=='本月'){ - let nowDate = new Date(); - let oneWeekAgo = new Date(nowDate.getTime() - 30 * 24 * 60 * 60 * 1000) - this.value1 = [parseTime(oneWeekAgo),parseTime(nowDate)] + const [startTime, endTime] = this.getMonthStartAndToday(); + this.value1 = [parseTime(startTime),parseTime(endTime)] }else if (command=='本季度'){ - let nowDate = new Date(); - let quarterStartMonth = Math.floor((nowDate.getMonth() + 1) / 3) * 3 - 2; - let quarterEndMonth = quarterStartMonth + 2; - let startDate = new Date(nowDate.getFullYear(), quarterStartMonth, 1); - let endDate = new Date(nowDate.getFullYear(), quarterEndMonth + 1, 0); - this.value1 = [parseTime(startDate), parseTime(endDate)]; + const [startTime, endTime] = this.getQuarterStartAndEnd(); + this.value1 = [parseTime(startTime), parseTime(endTime)]; } else if (command=='本年'){ - let nowDate = new Date(); - let oneWeekAgo = new Date(nowDate.getFullYear() - 1, nowDate.getMonth(), nowDate.getDate()) - this.value1 = [parseTime(oneWeekAgo),parseTime(nowDate)] + const [startTime, endTime] = this.getYearStartAndEnd(); + this.value1 = [parseTime(startTime),parseTime(endTime)] }else if (command=='自定义'){ this.disabled = false } @@ -422,25 +416,21 @@ export default { let nowDate = new Date(); let oneWeekAgo = new Date(nowDate.getTime() - 1 * 24 * 60 * 60 * 1000) this.showValue = [parseTime(oneWeekAgo),parseTime(oneWeekAgo)] - } else if (command=='本周'){ + } else if (command=='近一周'){ let nowDate = new Date(); let oneWeekAgo = new Date(nowDate.getTime() - 6 * 24 * 60 * 60 * 1000) this.showValue = [parseTime(oneWeekAgo),parseTime(nowDate)] } else if (command=='本月'){ let nowDate = new Date(); let oneWeekAgo = new Date(nowDate.getTime() - 30 * 24 * 60 * 60 * 1000) - this.showValue = [parseTime(oneWeekAgo),parseTime(nowDate)] + const [startTime, endTime] = this.getMonthStartAndToday(); + this.showValue = [parseTime(startTime),parseTime(endTime)] }else if (command=='本季度'){ - let nowDate = new Date(); - let quarterStartMonth = Math.floor((nowDate.getMonth() + 1) / 3) * 3 - 2; - let quarterEndMonth = quarterStartMonth + 2; - let startDate = new Date(nowDate.getFullYear(), quarterStartMonth, 1); - let endDate = new Date(nowDate.getFullYear(), quarterEndMonth + 1, 0); - this.showValue = [parseTime(startDate), parseTime(endDate)]; + const [startTime, endTime] = this.getQuarterStartAndEnd(); + this.showValue = [parseTime(startTime), parseTime(endTime)]; } else if (command=='本年'){ - let nowDate = new Date(); - let oneWeekAgo = new Date(nowDate.getFullYear() - 1, nowDate.getMonth(), nowDate.getDate()) - this.showValue = [parseTime(oneWeekAgo),parseTime(nowDate)] + const [startTime, endTime] = this.getYearStartAndEnd(); + this.showValue = [parseTime(startTime),parseTime(endTime)] }else if (command=='自定义'){ this.disabled = false } @@ -463,25 +453,21 @@ export default { let nowDate = new Date(); let oneWeekAgo = new Date(nowDate.getTime() - 1 * 24 * 60 * 60 * 1000) this.countValue = [parseTime(oneWeekAgo),parseTime(oneWeekAgo)] - } else if (command=='本周'){ + } else if (command=='近一周'){ let nowDate = new Date(); let oneWeekAgo = new Date(nowDate.getTime() - 6 * 24 * 60 * 60 * 1000) this.countValue = [parseTime(oneWeekAgo),parseTime(nowDate)] } else if (command=='本月'){ let nowDate = new Date(); let oneWeekAgo = new Date(nowDate.getTime() - 30 * 24 * 60 * 60 * 1000) - this.countValue = [parseTime(oneWeekAgo),parseTime(nowDate)] + const [startTime, endTime] = this.getMonthStartAndToday(); + this.countValue = [parseTime(startTime),parseTime(endTime)] }else if (command=='本季度'){ - let nowDate = new Date(); - let quarterStartMonth = Math.floor((nowDate.getMonth() + 1) / 3) * 3 - 2; - let quarterEndMonth = quarterStartMonth + 2; - let startDate = new Date(nowDate.getFullYear(), quarterStartMonth, 1); - let endDate = new Date(nowDate.getFullYear(), quarterEndMonth + 1, 0); - this.countValue = [parseTime(startDate), parseTime(endDate)]; + const [startTime, endTime] = this.getQuarterStartAndEnd(); + this.countValue = [parseTime(startTime), parseTime(endTime)]; } else if (command=='本年'){ - let nowDate = new Date(); - let oneWeekAgo = new Date(nowDate.getFullYear() - 1, nowDate.getMonth(), nowDate.getDate()) - this.countValue = [parseTime(oneWeekAgo),parseTime(nowDate)] + const [startTime, endTime] = this.getYearStartAndEnd(); + this.countValue = [parseTime(startTime),parseTime(endTime)] }else if (command=='自定义'){ this.disabled = false } @@ -497,34 +483,108 @@ export default { start.setSeconds(0) start.setMilliseconds(0) this.value2 = [start,new Date()] - } else if (command=='本周'){ + } else if (command=='近一周'){ let nowDate = new Date(); let oneWeekAgo = new Date(nowDate.getTime() - 6 * 24 * 60 * 60 * 1000) this.value2 = [parseTime(oneWeekAgo),parseTime(nowDate)] } else if (command=='本月'){ let nowDate = new Date(); let oneWeekAgo = new Date(nowDate.getTime() - 30 * 24 * 60 * 60 * 1000) - this.value2 = [parseTime(oneWeekAgo),parseTime(nowDate)] + const [startTime, endTime] = this.getMonthStartAndToday(); + this.value2 = [parseTime(startTime),parseTime(endTime)] }else if (command=='本季度'){ - let nowDate = new Date(); - let quarterStartMonth = Math.floor((nowDate.getMonth() + 1) / 3) * 3 - 2; - let quarterEndMonth = quarterStartMonth + 2; - let startDate = new Date(nowDate.getFullYear(), quarterStartMonth, 1); - let endDate = new Date(nowDate.getFullYear(), quarterEndMonth + 1, 0); - this.value2 = [parseTime(startDate), parseTime(endDate)]; + const [startTime, endTime] = this.getQuarterStartAndEnd(); + this.value2 = [parseTime(startTime), parseTime(endTime)]; } else if (command=='本年'){ - let nowDate = new Date(); - let oneWeekAgo = new Date(nowDate.getFullYear() - 1, nowDate.getMonth(), nowDate.getDate()) - this.value2 = [parseTime(oneWeekAgo),parseTime(nowDate)] + const [startTime, endTime] = this.getYearStartAndEnd(); + this.value2 = [parseTime(startTime),parseTime(endTime)] }else if (command=='自定义'){ this.disabled = false } - this.getStoreList() + this.getEmployeList() + }, + getMonthStartAndToday() { + const now = new Date(); + const year = now.getFullYear(); + const month = now.getMonth(); + + // 获取当前月的第一天 + const monthStart = new Date(year, month, 1); + + // 获取当前月的最后一天 + const monthEnd = new Date(year, month + 1, 0); + + // 格式化输出 + const format = (date) => { + const year = date.getFullYear(); + const month = ('0' + (date.getMonth() + 1)).slice(-2); + const day = ('0' + date.getDate()).slice(-2); + return `${year}-${month}-${day}`; + }; + + const startTime = format(monthStart); + const endTime = format(monthEnd); + + return [startTime, endTime]; + }, + getQuarterStartAndEnd() { + const now = new Date(); + const year = now.getFullYear(); + const month = now.getMonth(); + + // 计算当前季度的起始月份 + const quarterStartMonth = Math.floor(month / 3) * 3; + + // 获取当前季度的第一天 + const quarterStart = new Date(year, quarterStartMonth, 1); + + // 获取当前季度的最后一天 + const quarterEnd = new Date(year, quarterStartMonth + 3, 0); + + // 格式化输出 + const format = (date) => { + const year = date.getFullYear(); + const month = ('0' + (date.getMonth() + 1)).slice(-2); + const day = ('0' + date.getDate()).slice(-2); + return `${year}-${month}-${day}`; + }; + + const startTime = format(quarterStart); + const endTime = format(quarterEnd); + + return [startTime, endTime]; + }, + getYearStartAndEnd() { + const now = new Date(); + const year = now.getFullYear(); + + // 获取当前年的第一天 + const yearStart = new Date(year, 0, 1); + + // 获取当前年的最后一天 + const yearEnd = new Date(year, 11, 31); + + // 格式化输出 + const format = (date) => { + const year = date.getFullYear(); + const month = ('0' + (date.getMonth() + 1)).slice(-2); + const day = ('0' + date.getDate()).slice(-2); + return `${year}-${month}-${day}`; + }; + + const startTime = format(yearStart); + const endTime = format(yearEnd); + + return [startTime, endTime]; }, // 获取员工排行信息 getEmployeList() { this.employeLoading = true - employeeSalesApi().then(res => { + let data = { + startTime: this.value2[0], + endTime: this.value2[1] + } + employeeSalesApi(data).then(res => { if (res.code == 200) { if (res.data.length >= 10) { this.employeList = res.data.slice(0, 10); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/mapper/LJStaffMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/mapper/LJStaffMapper.java index 272d0187c..7e4529a14 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/mapper/LJStaffMapper.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/mapper/LJStaffMapper.java @@ -38,7 +38,7 @@ public interface LJStaffMapper extends BaseMapper { */ int auditPrem(@Param("id")Integer id,@Param("auditPrem") String auditPrem); - List> employeeSales(@Param("storeId") Integer storeId); + List> employeeSales(@Param("storeId") Integer storeId,@Param("startTime") String startTime, @Param("endTime") String endTime); List> employeeSalesMongth(@Param("storeId") Integer storeId); LJStaff selectStaffById(@Param("id") Integer id); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/mapper/xml/LJStaffMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/mapper/xml/LJStaffMapper.xml index 10a34a033..b76600dbc 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/mapper/xml/LJStaffMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/member/mapper/xml/LJStaffMapper.xml @@ -61,7 +61,7 @@ LEFT JOIN ( SELECT staff_id, COALESCE(SUM(pay_amount), 0) AS pay_amount FROM oil_order - WHERE order_status = 'paid' + WHERE order_status = 'paid' and create_time between #{startTime} and #{endTime} GROUP BY staff_id ) oo ON ms.id = oo.staff_id LEFT JOIN ( @@ -69,13 +69,13 @@ COALESCE(SUM(CASE WHEN payment_type = 'CASH' THEN amount ELSE 0 END), 0) as recharge_balance FROM card_value_record - WHERE pay_status = 'paid' + WHERE pay_status = 'paid' and create_time between #{startTime} and #{endTime} GROUP BY mt_staff_id ) cvr ON ms.id = cvr.mt_staff_id LEFT JOIN ( SELECT mt_staff_id, COALESCE(SUM(recharge_balance), 0) as recharge_balance FROM card_fuel_record - WHERE pay_status = 'paid' + WHERE pay_status = 'paid' and create_time between #{startTime} and #{endTime} GROUP BY mt_staff_id ) cfr ON ms.id = cfr.mt_staff_id WHERE diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/controller/OilOrderController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/controller/OilOrderController.java index 7fa332dc5..9181ca561 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/controller/OilOrderController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/controller/OilOrderController.java @@ -253,8 +253,8 @@ public class OilOrderController extends BaseController { } // 员工销售 @GetMapping("employeeSales") - public ResponseObject employeeSales() { - return getSuccessResult(orderService.employeeSales()); + public ResponseObject employeeSales(String startTime, String endTime) { + return getSuccessResult(orderService.employeeSales(startTime, endTime)); } // 储值卡销售额 diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/OilOrderService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/OilOrderService.java index 26415afb0..37b234d25 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/OilOrderService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/OilOrderService.java @@ -158,7 +158,7 @@ public interface OilOrderService extends IService { // 流水统计 Map turnoverStatistics(); - List> employeeSales(); + List> employeeSales(String startTime, String endTime); List> prepaidCardSales(); List> tunFuelCardSales(); List> merchandiseSales(); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java index f7c93fc68..90a7196d5 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java @@ -1931,11 +1931,11 @@ public class OilOrderServiceImpl extends ServiceImpl i // 员工统计 @Override - public List> employeeSales() { + public List> employeeSales(String startTime, String endTime) { AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); Integer storeId = nowAccountInfo.getStoreId(); // 员工统计油品 - List> maps = ljStaffMapper.employeeSales(storeId); + List> maps = ljStaffMapper.employeeSales(storeId, startTime, endTime); return maps; }