Explorar el Código

add 增加门店统计

xuhaifeng hace 2 meses
padre
commit
97fcd87b16

+ 3 - 3
admin-ui/src/api/settlement/bill.js

@@ -74,7 +74,7 @@ export function submitStoreSettlement(data) {
 // 获取门店经营日报数据
 export function getDailyStatistics(query) {
   return request({
-    url: '/settlement/store/statistics/daily',
+    url: '/mapi/settlement/store/statistics/daily',
     method: 'get',
     params: query
   })
@@ -83,8 +83,8 @@ export function getDailyStatistics(query) {
 // 获取门店经营日报趋势数据
 export function getDailyTrend(query) {
   return request({
-    url: '/settlement/store/statistics/trend',
+    url: '/mapi/settlement/store/statistics/trend',
     method: 'get',
     params: query
   })
-}
+}

+ 1 - 1
admin-ui/src/router/index.js

@@ -73,7 +73,7 @@ export const constantRoutes = [
     children: [
       {
         path: 'index',
-        component: () => import('@/views/index'),
+        component: () => import('@/views/index_store'),
         name: 'Index',
         meta: { title: '首页', icon: 'dashboard', affix: true }
       }

+ 6 - 3
admin-ui/src/views/cloth/hanger/upHanger.vue

@@ -158,7 +158,7 @@
         </el-row>
 
         <!-- 选择上挂位置页面 -->
-        <el-dialog :title="title" :visible.sync="open" size="70%">
+        <el-dialog :title="title" :visible.sync="open" size="70%" append-to-body>
             <div style="margin-left: 5%; margin-top: 1%; margin-right: 5%">
                 <el-row :gutter="20">
                     <el-descriptions title="衣物信息" v-if="clothItemInfoWithIn" :column="2">
@@ -218,14 +218,17 @@
                     <el-col :span="19">
                         <div class="head-upHanger-two" :style="{ border: '1px solid #ddd' }">
                             <el-radio-group v-model="detailId" size="medium">
-                                <el-radio-button v-for="detail in detailList" :key="detail.id" :label="detail.id" border style="margin-top: 10px; margin-left: 10px" :style="{ border: '1px solid #ddd' }">{{ detail.code }}# {{ detail.isHangerCount }} 件 </el-radio-button>
+                              <el-radio-button v-for="detail in detailList" :key="detail.id" :label="detail.id" border
+                                               :class="detail.isHangerCount>0 ? 'hasCloth' : 'nocloth'"
+                                               :style="detail.isHangerCount>0 ?  {'background-color': '#00ff00', 'border': '1px solid #ddd', 'margin-top': '10px', 'margin-left': '10px' } :  { border: '1px solid #ddd', 'margin-top': '10px', 'margin-left': '10px'}">
+                                {{ detail.code }}# {{ detail.isHangerCount }} 件 </el-radio-button>
                             </el-radio-group>
                         </div>
                     </el-col>
                 </el-row>
                 <el-row>
                     <el-col :span="3">
-                        <el-button type="primary" style="width: 50%; height: 40px; margin-top: 30px; text-align: center" size="small" @click="submitForm">提交 </el-button>
+                        <el-button type="primary" style="height: 40px; margin-top: 30px; text-align: center" size="small" @click="submitForm">提交 </el-button>
                     </el-col>
                 </el-row>
             </div>

+ 5 - 5
admin-ui/src/views/components/ChargeTrendChart.vue

@@ -41,7 +41,7 @@ export default {
       if (!this.chart) {
         this.chart = echarts.init(this.$refs.chart)
       }
-      
+
       const option = {
         tooltip: {
           trigger: 'axis',
@@ -64,7 +64,7 @@ export default {
         xAxis: {
           type: 'category',
           boundaryGap: false,
-          data: this.data.map(item => item.statisticsDate)
+          data: this.data.map(item => item.day)
         },
         yAxis: {
           type: 'value',
@@ -84,11 +84,11 @@ export default {
             emphasis: {
               focus: 'series'
             },
-            data: this.data.map(item => item.dailyChargeAmount || 0)
+            data: this.data.map(item => item.rechargePayAmount || 0)
           }
         ]
       }
-      
+
       this.chart.setOption(option)
     },
     resizeChart() {
@@ -98,4 +98,4 @@ export default {
     }
   }
 }
-</script> 
+</script>

+ 49 - 49
admin-ui/src/views/index_store.vue

@@ -11,7 +11,7 @@
               <div class="stat-card stat-card-blue">
                 <div class="stat-card-title">洗衣件数</div>
                 <div class="stat-card-value">
-                  <count-to :start-val="0" :end-val="orderStats.dailyInFactoryCount || 0" :duration="2600" />
+                  <count-to :start-val="0" :end-val="orderStats.clothCount || 0" :duration="2600" />
                 </div>
               </div>
             </el-col>
@@ -19,30 +19,30 @@
               <div class="stat-card stat-card-green">
                 <div class="stat-card-title">洗衣金额</div>
                 <div class="stat-card-value">
-                  <count-to :start-val="0" :end-val="orderStats.dailyInFactoryAmount || 0" :duration="2600" prefix="¥" />
+                  <count-to :start-val="0" :end-val="orderStats.clothCashAmount || 0" :duration="2600" prefix="¥" />
                 </div>
               </div>
             </el-col>
             <el-col :xs="12" :sm="12" :lg="6">
               <div class="stat-card stat-card-red">
-                <div class="stat-card-title">撤单件数</div>
+                <div class="stat-card-title">商品笔数</div>
                 <div class="stat-card-value">
-                  <count-to :start-val="0" :end-val="orderStats.dailyRefundCount || 0" :duration="2600" />
+                  <count-to :start-val="0" :end-val="orderStats.goodsOrderCount || 0" :duration="2600" />
                 </div>
               </div>
             </el-col>
             <el-col :xs="12" :sm="12" :lg="6">
               <div class="stat-card stat-card-orange">
-                <div class="stat-card-title">撤单金额</div>
+                <div class="stat-card-title">商品金额</div>
                 <div class="stat-card-value">
-                  <count-to :start-val="0" :end-val="orderStats.dailyRefundAmount || 0" :duration="2600" prefix="¥" />
+                  <count-to :start-val="0" :end-val="orderStats.goodsOrderAmount || 0" :duration="2600" prefix="¥" />
                 </div>
               </div>
             </el-col>
           </el-row>
         </div>
       </el-col>
-      
+
       <!-- 充值统计卡片 -->
       <el-col :xs="24" :sm="24" :lg="12">
         <div class="stat-section">
@@ -50,9 +50,9 @@
           <el-row :gutter="20">
             <el-col :xs="12" :sm="12" :lg="6">
               <div class="stat-card stat-card-purple">
-                <div class="stat-card-title">充值金额</div>
+                <div class="stat-card-title">付款金额</div>
                 <div class="stat-card-value">
-                  <count-to :start-val="0" :end-val="chargeStats.dailyChargeAmount || 0" :duration="2600" prefix="¥" />
+                  <count-to :start-val="0" :end-val="chargeStats.rechargePayAmount || 0" :duration="2600" prefix="¥" />
                 </div>
               </div>
             </el-col>
@@ -60,23 +60,23 @@
               <div class="stat-card stat-card-cyan">
                 <div class="stat-card-title">充值笔数</div>
                 <div class="stat-card-value">
-                  <count-to :start-val="0" :end-val="chargeStats.dailyChargeCount || 0" :duration="2600" />
+                  <count-to :start-val="0" :end-val="chargeStats.rechargeCount || 0" :duration="2600" />
                 </div>
               </div>
             </el-col>
             <el-col :xs="12" :sm="12" :lg="6">
               <div class="stat-card stat-card-teal">
-                <div class="stat-card-title">平均充值</div>
+                <div class="stat-card-title">退款金额</div>
                 <div class="stat-card-value">
-                  <count-to :start-val="0" :end-val="chargeStats.dailyChargeAmount ? (chargeStats.dailyChargeAmount / chargeStats.dailyChargeCount) : 0" :duration="2600" prefix="¥" />
+                  <count-to :start-val="0" :end-val="chargeStats.chargeRefundAmount || 0" :duration="2600" prefix="¥" />
                 </div>
               </div>
             </el-col>
             <el-col :xs="12" :sm="12" :lg="6">
               <div class="stat-card stat-card-indigo">
-                <div class="stat-card-title">会员充值</div>
+                <div class="stat-card-title">退款笔数</div>
                 <div class="stat-card-value">
-                  <count-to :start-val="0" :end-val="chargeStats.dailyMemberChargeAmount || 0" :duration="2600" prefix="¥" />
+                  <count-to :start-val="0" :end-val="chargeStats.refundCount || 0" :duration="2600" prefix="¥" />
                 </div>
               </div>
             </el-col>
@@ -107,7 +107,7 @@
                   </div>
                   <div class="card-panel-description">
                     <div class="card-panel-text">洗衣件数</div>
-                    <count-to :start-val="0" :end-val="dailyOrderStats.dailyInFactoryCount || 0" :duration="2600" class="card-panel-num" />
+                    <count-to :start-val="0" :end-val="dailyOrderStats.clothOrderCount || 0" :duration="2600" class="card-panel-num" />
                   </div>
                 </div>
               </el-col>
@@ -118,7 +118,7 @@
                   </div>
                   <div class="card-panel-description">
                     <div class="card-panel-text">洗衣金额</div>
-                    <count-to :start-val="0" :end-val="dailyOrderStats.dailyInFactoryAmount || 0" :duration="2600" class="card-panel-num" prefix="¥" />
+                    <count-to :start-val="0" :end-val="dailyOrderStats.clothOrderAmount || 0" :duration="2600" class="card-panel-num" prefix="¥" />
                   </div>
                 </div>
               </el-col>
@@ -129,7 +129,7 @@
                   </div>
                   <div class="card-panel-description">
                     <div class="card-panel-text">充值金额</div>
-                    <count-to :start-val="0" :end-val="dailyChargeStats.dailyChargeAmount || 0" :duration="2600" class="card-panel-num" prefix="¥" />
+                    <count-to :start-val="0" :end-val="dailyChargeStats.rechargePayAmount || 0" :duration="2600" class="card-panel-num" prefix="¥" />
                   </div>
                 </div>
               </el-col>
@@ -140,7 +140,7 @@
                   </div>
                   <div class="card-panel-description">
                     <div class="card-panel-text">充值笔数</div>
-                    <count-to :start-val="0" :end-val="dailyChargeStats.dailyChargeCount || 0" :duration="2600" class="card-panel-num" />
+                    <count-to :start-val="0" :end-val="dailyChargeStats.rechargeCount || 0" :duration="2600" class="card-panel-num" />
                   </div>
                 </div>
               </el-col>
@@ -233,22 +233,22 @@ export default {
         }
       })
     },
-    
+
     /**
      * 处理今日概览时间范围变化
      */
     handleDailyTimeRangeChange() {
       this.getDailyStatistics()
     },
-    
+
     /**
      * 获取今日概览数据
      */
     getDailyStatistics() {
-      const date = this.dailyTimeRange === 'today' 
-        ? this.formatDate(new Date()) 
+      const date = this.dailyTimeRange === 'today'
+        ? this.formatDate(new Date())
         : this.formatDate(this.getYesterday())
-      
+
       getStoreDailyStatistics(date).then(response => {
         if (response.code === 200) {
           this.dailyOrderStats = response.data.orderStats || {}
@@ -256,7 +256,7 @@ export default {
         }
       })
     },
-    
+
     /**
      * 获取趋势数据
      */
@@ -265,19 +265,19 @@ export default {
       const endDate = new Date()
       const startDate = new Date()
       startDate.setDate(endDate.getDate() - 14)
-      
+
       const params = {
         startDate: this.formatDate(startDate),
         endDate: this.formatDate(endDate)
       }
-      
+
       // 获取订单趋势数据
       listStoreStatistics(params).then(response => {
         if (response.code === 200) {
           this.orderTrendData = response.rows || []
         }
       })
-      
+
       // 获取充值趋势数据
       listStoreChargeStatistics(params).then(response => {
         if (response.code === 200) {
@@ -285,7 +285,7 @@ export default {
         }
       })
     },
-    
+
     /**
      * 获取昨天的日期
      */
@@ -294,7 +294,7 @@ export default {
       yesterday.setDate(yesterday.getDate() - 1)
       return yesterday
     },
-    
+
     /**
      * 格式化日期为 yyyy-MM-dd
      */
@@ -312,13 +312,13 @@ export default {
 .home {
   .panel-group {
     margin-top: 18px;
-    
+
     .stat-section {
       background: #fff;
       padding: 20px;
       border-radius: 8px;
       box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
-      
+
       .section-title {
         font-size: 16px;
         font-weight: bold;
@@ -326,7 +326,7 @@ export default {
         margin-bottom: 20px;
       }
     }
-    
+
     .stat-card {
       height: 120px;
       border-radius: 8px;
@@ -337,56 +337,56 @@ export default {
       justify-content: center;
       box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
       transition: all 0.3s;
-      
+
       &:hover {
         transform: translateY(-5px);
         box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
       }
-      
+
       .stat-card-title {
         font-size: 16px;
         margin-bottom: 10px;
         opacity: 0.9;
       }
-      
+
       .stat-card-value {
         font-size: 28px;
         font-weight: bold;
       }
     }
-    
+
     .stat-card-blue {
       background: linear-gradient(135deg, #1890ff, #36cfc9);
     }
-    
+
     .stat-card-green {
       background: linear-gradient(135deg, #52c41a, #73d13d);
     }
-    
+
     .stat-card-red {
       background: linear-gradient(135deg, #f5222d, #ff4d4f);
     }
-    
+
     .stat-card-orange {
       background: linear-gradient(135deg, #fa8c16, #ffa940);
     }
-    
+
     .stat-card-purple {
       background: linear-gradient(135deg, #722ed1, #b37feb);
     }
-    
+
     .stat-card-cyan {
       background: linear-gradient(135deg, #13c2c2, #5cdbd3);
     }
-    
+
     .stat-card-teal {
       background: linear-gradient(135deg, #006d75, #08979c);
     }
-    
+
     .stat-card-indigo {
       background: linear-gradient(135deg, #2f54eb, #597ef7);
     }
-    
+
     .card-panel {
       height: 108px;
       cursor: pointer;
@@ -442,30 +442,30 @@ export default {
       }
     }
   }
-  
+
   .chart-wrapper {
     background: #fff;
     padding: 20px;
     border-radius: 4px;
     box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
-    
+
     .chart-header {
       display: flex;
       justify-content: space-between;
       align-items: center;
       margin-bottom: 20px;
-      
+
       .chart-title {
         font-size: 16px;
         font-weight: bold;
         color: #303133;
       }
     }
-    
+
     .chart-content {
       height: 300px;
     }
-    
+
     .chart-content-1 {
       height: 130px;
     }

+ 0 - 4
yiqi-admin/src/main/java/com/yiqi/admin/controller/order/OrderClothController.java

@@ -1069,10 +1069,6 @@ public class OrderClothController extends BaseController {
         }
         // 设置 出厂件数
         factoryFinancialClothDayCountVO.setCountClothOut(outOrderClothItemList.size());
-        factoryFinancialClothDayCountVO.setTotalStatementPrice(
-                outOrderClothItemList.stream().map(vo -> vo.getTotalPrice().multiply(vo.getFactorySettlementRate()))
-                        .reduce(BigDecimal.ZERO, BigDecimal::add)
-        );
         return R.ok(factoryFinancialClothDayCountVO);
     }
 

+ 17 - 8
yiqi-admin/src/main/java/com/yiqi/admin/controller/settlement/SettlementStoreStatisticsController.java

@@ -14,10 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @RestController
 @RequestMapping(UrlConstants.managerApi + "/settlement/store/statistics")
@@ -113,15 +110,27 @@ public class SettlementStoreStatisticsController extends BaseController {
     @GetMapping("/charge/list")
     public TableDataInfo chargeList(@RequestParam(required = false) String startDate,
                                     @RequestParam(required = false) String endDate,
+                                    @RequestParam(required = false) Integer sort,
                                     @RequestParam(defaultValue = "1") Integer pageNum,
                                     @RequestParam(defaultValue = "15") Integer pageSize) {
-
-        startPage();
         Date start = startDate != null ? DateUtils.parseDate(startDate) : DateUtils.addDays(new Date(), -14);
         Date end = endDate != null ? DateUtils.parseDate(endDate) : new Date();
         Long storeId = getLoginUser().getStoreId();
-        List<StoreChargeStatistics> chargeTrend = settlementStoreStatisticsService.generateChargeStatisticsByDate(storeId, start, end);
-        return getDataTable(chargeTrend);
+        List<StoreChargeStatistics> statisticsList = settlementStoreStatisticsService.generateChargeStatisticsByDate(storeId, start, end);
+        if (sort != null && sort == 1) {
+            statisticsList.sort(Comparator.comparing(StoreChargeStatistics::getDay, Comparator.reverseOrder()));
+        }
+        Long totalCount = (long) statisticsList.size();
+        // 4. 处理分页
+        if (pageNum != null && pageSize != null && pageNum > 0 && pageSize > 0) {
+            int startIndex = (pageNum - 1) * pageSize;
+            int endIndex = Math.min(startIndex + pageSize, statisticsList.size());
+            if (startIndex >= statisticsList.size()) {
+                statisticsList = Collections.emptyList();
+            }
+            statisticsList = statisticsList.subList(startIndex, endIndex);
+        }
+        return getDataTable(statisticsList, totalCount);
     }
 
     /**

+ 12 - 3
yiqi-core/src/main/java/com/yiqi/core/service/impl/SettlementStoreStatisticsServiceImpl.java

@@ -16,6 +16,7 @@ import com.yiqi.common.utils.SecurityUtils;
 import com.yiqi.core.service.ISettlementManageBillService;
 import com.yiqi.order.domain.OrderRecharge;
 import com.yiqi.order.domain.OrderRechargeRefund;
+import com.yiqi.order.domain.dto.SettlementFactoryStatisticsDto;
 import com.yiqi.order.service.IOrderRechargeRefundService;
 import com.yiqi.order.service.IOrderRechargeService;
 import com.yiqi.settlement.domain.dto.OrderStatisticsVO;
@@ -247,7 +248,17 @@ public class SettlementStoreStatisticsServiceImpl extends ServiceImpl<Settlement
             allDays.addAll(dateRechargeMap.keySet());
             allDays.addAll(dateRefundMap.keySet());
 
-            for (Integer day : allDays) {
+            // 1. 获取日期范围内的所有日期
+            List<Date> dateList = new ArrayList<>();
+            Date currentDate = endDate;
+            while (currentDate.after(startDate)) {
+                dateList.add(currentDate);
+                currentDate = DateUtils.addDays(currentDate, -1);
+            }
+            List<SettlementFactoryStatisticsDto> statisticsList = new ArrayList<>();
+            // 3. 为每个日期生成统计数据
+            for (Date date : dateList) {
+                Integer day = Integer.parseInt(DateUtil.format(date, "yyyyMMdd"));
                 List<OrderRecharge> dayRechargeList = dateRechargeMap.getOrDefault(day, new ArrayList<>());
                 List<OrderRechargeRefund> dayRefundList = dateRefundMap.getOrDefault(day, new ArrayList<>());
                 // 4.1 构建统计实体
@@ -257,8 +268,6 @@ public class SettlementStoreStatisticsServiceImpl extends ServiceImpl<Settlement
                 genStoreChargeStatistics(statistics, dayRechargeList, dayRefundList);
                 resultList.add(statistics);
             }
-            // 5. 按日期排序
-            resultList.sort(Comparator.comparing(StoreChargeStatistics::getDay));
         } catch (Exception e) {
             log.error("生成门店[{}]充值统计失败: {}", storeId, e.getMessage());
             throw new RuntimeException("生成门店充值统计失败", e);

+ 0 - 12
yiqi-core/src/main/java/com/yiqi/order/service/impl/OrderClothServiceImpl.java

@@ -1290,11 +1290,6 @@ public class OrderClothServiceImpl extends ServiceImpl<OrderClothMapper, OrderCl
                     .map(OrderClothItem::getTotalPrice)
                     .filter(Objects::nonNull)
                     .reduce(BigDecimal.ZERO, BigDecimal::add));
-            // 设置 总计工厂结算金额
-            orderClothFactoryClothQueryVO.setTotalStatementMoney(
-                    orderClothItemAll.stream().map(vo -> vo.getTotalPrice().multiply(vo.getFactorySettlementRate()))
-                            .reduce(BigDecimal.ZERO, BigDecimal::add)
-            );
             // 设置 总件数
             orderClothFactoryClothQueryVO.setTotalOrderClothCount(orderClothItemAll.size());
             orderClothFactoryClothQueryVO.setTotal(orderClothItemAll.size());
@@ -1308,15 +1303,8 @@ public class OrderClothServiceImpl extends ServiceImpl<OrderClothMapper, OrderCl
         List<OrderClothFactoryClothItemVO> orderClothFactoryClothItemVOList = new ArrayList<>();
         for (OrderClothItem orderClothItem : orderClothItems) {
             // 设置门店的工厂费率
-            BigDecimal rate = orderClothItem.getFactorySettlementRate();
             OrderClothFactoryClothItemVO vo = new OrderClothFactoryClothItemVO();
             BeanUtils.copyProperties(orderClothItem, vo);
-            if (vo.getTotalPrice() == null) {
-                vo.setTotalStatementPrice(BigDecimal.ZERO);
-            } else {
-                vo.setTotalStatementPrice(vo.getTotalPrice().multiply(rate));
-            }
-            vo.setStatementRate(rate);
             orderClothFactoryClothItemVOList.add(vo);
         }
         orderClothFactoryClothQueryVO.setOrderClothFactoryClothItemVOList(orderClothFactoryClothItemVOList);