浏览代码

Merge branch 'master' of http://101.37.21.97:3000/wash/wash_server_v2

DESKTOP-T5C0CIA\lhch 2 月之前
父节点
当前提交
02765b9dc0
共有 27 个文件被更改,包括 806 次插入410 次删除
  1. 4 4
      admin-ui/.env.development
  2. 34 0
      admin-ui/src/api/settlement/statistics.js
  3. 8 9
      admin-ui/src/views/cloth/clothItem/index.vue
  4. 4 4
      admin-ui/src/views/components/OrderTrendChart.vue
  5. 154 104
      admin-ui/src/views/index.vue
  6. 1 1
      admin-ui/src/views/index_store.vue
  7. 44 89
      yiqi-admin/src/main/java/com/yiqi/admin/controller/settlement/PlatformStatisticsController.java
  8. 1 1
      yiqi-admin/src/main/java/com/yiqi/admin/controller/settlement/SettlementStoreStatisticsController.java
  9. 0 41
      yiqi-common/src/main/java/com/yiqi/core/domain/SettlementManageStore.java
  10. 42 0
      yiqi-common/src/main/java/com/yiqi/core/domain/SettlementStoreStatistics.java
  11. 8 0
      yiqi-common/src/main/java/com/yiqi/core/service/ISettlementManageBillService.java
  12. 26 8
      yiqi-common/src/main/java/com/yiqi/core/service/ISettlementStoreStatisticsService.java
  13. 2 2
      yiqi-common/src/main/java/com/yiqi/order/domain/OrderClothItem.java
  14. 7 0
      yiqi-common/src/main/java/com/yiqi/order/domain/OrderGoods.java
  15. 10 3
      yiqi-common/src/main/java/com/yiqi/order/domain/dto/RechargeCardPayDTO.java
  16. 9 2
      yiqi-common/src/main/java/com/yiqi/recharge/domain/dto/BillMstrOrderDTO.java
  17. 5 0
      yiqi-common/src/main/java/com/yiqi/settlement/domain/dto/OrderStatisticsVO.java
  18. 4 6
      yiqi-core/src/main/java/com/yiqi/app/service/impl/AppUserBillMstrServiceImpl.java
  19. 23 3
      yiqi-core/src/main/java/com/yiqi/core/mapper/SettlementStoreStatisticsMapper.java
  20. 178 57
      yiqi-core/src/main/java/com/yiqi/core/service/impl/SettlementManageBillServiceImpl.java
  21. 88 15
      yiqi-core/src/main/java/com/yiqi/core/service/impl/SettlementStoreStatisticsServiceImpl.java
  22. 1 1
      yiqi-core/src/main/java/com/yiqi/order/service/impl/OrderClothServiceImpl.java
  23. 1 1
      yiqi-core/src/main/java/com/yiqi/order/service/impl/OrderGoodsServiceImpl.java
  24. 6 3
      yiqi-core/src/main/java/com/yiqi/order/service/impl/OrderRechargeServiceImpl.java
  25. 4 5
      yiqi-core/src/main/java/com/yiqi/recharge/service/impl/RechargePasswordCardServiceImpl.java
  26. 140 45
      yiqi-core/src/main/resources/mapper/core/SettlementStoreStatisticsMapper.xml
  27. 2 6
      yiqi-core/src/main/resources/mapper/order/OrderClothItemMapper.xml

+ 4 - 4
admin-ui/.env.development

@@ -5,10 +5,10 @@ VUE_APP_TITLE = 一七管理系统
 ENV = 'development'
 
 
-# VUE_APP_BASE_API_HOST = 'http://127.0.0.1:9801'
-# VUE_APP_BASE_API = 'http://127.0.0.1:9801'
-VUE_APP_BASE_API_HOST = 'http://139.224.65.227:8091/prod-api'
-VUE_APP_BASE_API = 'http://139.224.65.227:8091/prod-api'
+VUE_APP_BASE_API_HOST = 'http://192.168.5.247:9801'
+VUE_APP_BASE_API = 'http://192.168.5.247:9801'
+#VUE_APP_BASE_API_HOST = 'http://139.224.65.227:8091/prod-api'
+#VUE_APP_BASE_API = 'http://139.224.65.227:8091/prod-api'
 # VUE_APP_BASE_API_HOST = 'http://192.168.98.9:9801'
 # VUE_APP_BASE_API = 'http://192.168.98.9:9801/'
 

+ 34 - 0
admin-ui/src/api/settlement/statistics.js

@@ -120,3 +120,37 @@ export function factoryDashborad() {
     method: 'get'
   })
 }
+
+//工厂端首页dashboard
+export function platformDashborad() {
+  return request({
+    url: '/mapi/platform/statistics/dashborad',
+    method: 'get'
+  })
+}
+
+// 获取工厂总统计数据
+export function getplatformDayTrend(query) {
+  return request({
+    url: '/mapi/platform/statistics/trend',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询工厂按日期统计列表
+export function listplatformStatisticsByDate(query) {
+  return request({
+    url: '/mapi/platform/statistics/order/list',
+    method: 'get',
+    params: query
+  })
+}
+
+export function listplatformStatisticsByStore(query) {
+  return request({
+    url: '/mapi/platform/statistics/order/bystore',
+    method: 'get',
+    params: query
+  })
+}

+ 8 - 9
admin-ui/src/views/cloth/clothItem/index.vue

@@ -39,9 +39,9 @@
                 <el-table-column label="衣服信息" align="left" min-width="200">
                     <template slot-scope="scope">
                         <div class="goods-info">
-                            <el-image 
+                            <el-image
                                 class="goods-image"
-                                :src="scope.row.imgUrl" 
+                                :src="scope.row.imgUrl"
                                 :preview-src-list="[scope.row.imgUrl]"
                                 fit="cover">
                                 <div slot="error" class="image-slot">
@@ -152,7 +152,7 @@
                             </el-col>
                         </el-row>
                     </el-tab-pane>
-                    
+
                     <el-tab-pane label="图片与描述" name="media">
                         <el-form-item label="商品图片" prop="imgUrl">
                             <div class="image-upload-container">
@@ -235,7 +235,6 @@ export default {
                 isCalArea: [{ required: true, message: '是否按面积计算不能为空', trigger: 'blur' }],
                 isSpecial: [{ required: true, message: '是否特殊产品不能为空', trigger: 'blur' }],
                 imgUrl: [{ required: true, message: '衣服图片不能为空', trigger: 'blur' }],
-                content: [{ required: true, message: '描述不能为空', trigger: 'blur' }],
                 sort: [{ required: true, message: '显示顺序不能为空', trigger: 'blur' }]
             },
             clothTypeList: [],
@@ -508,20 +507,20 @@ export default {
     .el-dialog__body {
         padding: 20px 30px;
     }
-    
+
     .el-tabs__nav {
         padding-left: 20px;
     }
-    
+
     .image-upload-container {
         display: flex;
         align-items: flex-start;
-        
+
         .image-tips {
             margin-left: 20px;
             color: #909399;
             font-size: 12px;
-            
+
             p {
                 margin: 0;
                 line-height: 1.8;
@@ -539,7 +538,7 @@ export default {
     display: flex;
     flex-direction: column;
     align-items: center;
-    
+
     .el-tag + .el-tag {
         margin-top: 5px;
     }

+ 4 - 4
admin-ui/src/views/components/OrderTrendChart.vue

@@ -53,7 +53,7 @@ export default {
           }
         },
         legend: {
-          data: ['洗衣金额', '撤单金额']
+          data: ['洗衣金额','实付金额']
         },
         grid: {
           left: '3%',
@@ -84,10 +84,10 @@ export default {
             emphasis: {
               focus: 'series'
             },
-            data: this.data.map(item => item.dailyInFactoryAmount || 0)
+            data: this.data.map(item => item.clothOrderAmount || 0)
           },
           {
-            name: '撤单金额',
+            name: '实付金额',
             type: 'line',
             stack: 'Total',
             areaStyle: {
@@ -96,7 +96,7 @@ export default {
             emphasis: {
               focus: 'series'
             },
-            data: this.data.map(item => item.dailyRefundAmount || 0)
+            data: this.data.map(item => item.clothReceiveAmount || 0)
           }
         ]
       }

+ 154 - 104
admin-ui/src/views/index.vue

@@ -2,35 +2,51 @@
   <div class="app-container home">
     <!-- 累积统计卡片行 -->
     <el-row :gutter="20" class="panel-group">
-      <el-col :xs="12" :sm="12" :lg="6">
+      <el-col :xs="12" :sm="12" :lg="4">
         <div class="stat-card stat-card-blue">
-          <div class="stat-card-title">累积洗衣件数</div>
+          <div class="stat-card-title">洗衣件数</div>
           <div class="stat-card-value">
-            <count-to :start-val="0" :end-val="statistics.dailyInFactoryCount" :duration="2600" />
+            <count-to :start-val="0" :end-val="statistics.clothCount" :duration="2600" />
           </div>
         </div>
       </el-col>
-      <el-col :xs="12" :sm="12" :lg="6">
+      <el-col :xs="12" :sm="12" :lg="4">
         <div class="stat-card stat-card-green">
-          <div class="stat-card-title">累积洗衣金额</div>
+          <div class="stat-card-title">洗衣金额</div>
           <div class="stat-card-value">
-            <count-to :start-val="0" :end-val="statistics.dailyInFactoryAmount" :duration="2600" prefix="¥" />
+            <count-to :start-val="0" :end-val="statistics.clothReceiveAmount" :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>
+      <el-col :xs="12" :sm="12" :lg="4">
+        <div class="stat-card stat-card-purple">
+          <div class="stat-card-title">零售订单数</div>
           <div class="stat-card-value">
-            <count-to :start-val="0" :end-val="statistics.dailyRefundCount" :duration="2600" />
+            <count-to :start-val="0" :end-val="statistics.goodsOrderCount" :duration="2600" />
           </div>
         </div>
       </el-col>
-      <el-col :xs="12" :sm="12" :lg="6">
+      <el-col :xs="12" :sm="12" :lg="4">
         <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="statistics.dailyRefundAmount" :duration="2600" prefix="¥" />
+            <count-to :start-val="0" :end-val="statistics.goodsReceiveAmount" :duration="2600" prefix="¥" />
+          </div>
+        </div>
+      </el-col>
+      <el-col :xs="12" :sm="12" :lg="4">
+        <div class="stat-card stat-card-red">
+          <div class="stat-card-title">充值笔数</div>
+          <div class="stat-card-value">
+            <count-to :start-val="0" :end-val="statistics.chargeCount" :duration="2600" />
+          </div>
+        </div>
+      </el-col>
+      <el-col :xs="12" :sm="12" :lg="4">
+        <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="statistics.chargeAmount" :duration="2600" prefix="¥" />
           </div>
         </div>
       </el-col>
@@ -53,47 +69,69 @@
           </div>
           <div class="chart-content-1">
             <el-row :gutter="20" class="panel-group">
-              <el-col :xs="12" :sm="12" :lg="6">
+              <el-col :xs="12" :sm="12" :lg="4">
                 <div class="card-panel">
                   <div class="card-panel-icon-wrapper icon-orders">
                     <svg-icon icon-class="form" class-name="card-panel-icon" />
                   </div>
                   <div class="card-panel-description">
                     <div class="card-panel-text">洗衣件数</div>
-                    <count-to :start-val="0" :end-val="factoryStatistics.dailyInFactoryCount" :duration="2600" class="card-panel-num" />
+                    <count-to :start-val="0" :end-val="dayStatistics.clothCount" :duration="2600" class="card-panel-num" />
                   </div>
                 </div>
               </el-col>
-              <el-col :xs="12" :sm="12" :lg="6">
+              <el-col :xs="12" :sm="12" :lg="4">
                 <div class="card-panel">
                   <div class="card-panel-icon-wrapper icon-revenue">
                     <svg-icon icon-class="money" class-name="card-panel-icon" />
                   </div>
                   <div class="card-panel-description">
                     <div class="card-panel-text">洗衣金额</div>
-                    <count-to :start-val="0" :end-val="factoryStatistics.dailyInFactoryAmount" :duration="2600" class="card-panel-num" prefix="¥" />
+                    <count-to :start-val="0" :end-val="dayStatistics.clothReceiveAmount" :duration="2600" class="card-panel-num" prefix="¥" />
+                  </div>
+                </div>
+              </el-col>
+              <el-col :xs="12" :sm="12" :lg="4">
+                <div class="card-panel">
+                  <div class="card-panel-icon-wrapper icon-goods">
+                    <svg-icon icon-class="shopping" class-name="card-panel-icon" />
+                  </div>
+                  <div class="card-panel-description">
+                    <div class="card-panel-text">零售订单数</div>
+                    <count-to :start-val="0" :end-val="dayStatistics.goodsOrderCount" :duration="2600" class="card-panel-num" />
                   </div>
                 </div>
               </el-col>
-              <el-col :xs="12" :sm="12" :lg="6">
+              <el-col :xs="12" :sm="12" :lg="4">
                 <div class="card-panel">
-                  <div class="card-panel-icon-wrapper icon-cancel">
+                  <div class="card-panel-icon-wrapper icon-goods-amount">
+                    <svg-icon icon-class="money" class-name="card-panel-icon" />
+                  </div>
+                  <div class="card-panel-description">
+                    <div class="card-panel-text">零售金额</div>
+                    <count-to :start-val="0" :end-val="dayStatistics.goodsReceiveAmount" :duration="2600" class="card-panel-num" prefix="¥" />
+                  </div>
+                </div>
+              </el-col>
+              <el-col :xs="12" :sm="12" :lg="4">
+                <div class="card-panel">
+                  <div class="card-panel-icon-wrapper icon-charge">
                     <svg-icon icon-class="form" class-name="card-panel-icon" />
                   </div>
                   <div class="card-panel-description">
-                    <div class="card-panel-text">撤单件数</div>
-                    <count-to :start-val="0" :end-val="factoryStatistics.dailyRefundCount" :duration="2600" class="card-panel-num" />
+                    <div class="card-panel-text">充值笔数</div>
+                    <count-to :start-val="0" :end-val="dayStatistics.chargeCount" :duration="2600" class="card-panel-num" />
                   </div>
                 </div>
               </el-col>
-              <el-col :xs="12" :sm="12" :lg="6">
+              <el-col :xs="12" :sm="12" :lg="4">
                 <div class="card-panel">
-                  <div class="card-panel-icon-wrapper icon-cancel-amount">
+                  <div class="card-panel-icon-wrapper icon-charge-amount">
                     <svg-icon icon-class="money" class-name="card-panel-icon" />
                   </div>
                   <div class="card-panel-description">
-                    <div class="card-panel-text">撤单金额</div>
-                    <count-to :start-val="0" :end-val="factoryStatistics.dailyRefundAmount" :duration="2600" class="card-panel-num" prefix="¥" />
+                    <div class="card-panel-text">充值金额</div>
+                    <count-to :start-val="0" :end-val="dayStatistics.chargeAmount" :duration="2600" class="card-panel-num" prefix="¥" />
                   </div>
                 </div>
               </el-col>
@@ -105,19 +143,27 @@
 
     <!-- 交易图表展示 -->
     <el-row :gutter="32" style="margin-top: 32px">
-      <el-col :xs="24" :sm="24" :lg="12">
+      <el-col :xs="24" :sm="24" :lg="8">
+        <div class="chart-wrapper">
+          <div class="chart-title">洗衣交易趋势</div>
+          <div class="chart-content">
+            <amount-trend-chart :data="clothTrendData" />
+          </div>
+        </div>
+      </el-col>
+      <el-col :xs="24" :sm="24" :lg="8">
         <div class="chart-wrapper">
-          <div class="chart-title">交易金额趋势</div>
+          <div class="chart-title">零售交易趋势</div>
           <div class="chart-content">
-            <amount-trend-chart :data="amountTrendData" />
+            <amount-trend-chart :data="goodsTrendData" />
           </div>
         </div>
       </el-col>
-      <el-col :xs="24" :sm="24" :lg="12">
+      <el-col :xs="24" :sm="24" :lg="8">
         <div class="chart-wrapper">
-          <div class="chart-title">交易件数趋势</div>
+          <div class="chart-title">充值交易趋势</div>
           <div class="chart-content">
-            <count-trend-chart :data="countTrendData" />
+            <amount-trend-chart :data="chargeTrendData" />
           </div>
         </div>
       </el-col>
@@ -128,7 +174,7 @@
       <el-col :xs="24" :sm="24" :lg="24">
         <div class="chart-wrapper">
           <div class="chart-header">
-            <div class="chart-title">门店洗衣排行</div>
+            <div class="chart-title">门店营收排行</div>
             <div class="chart-actions">
               <el-radio-group v-model="rankingTimeRange" size="small" @change="handleRankingTimeRangeChange">
                 <el-radio-button label="week">近一周</el-radio-button>
@@ -141,19 +187,24 @@
             <el-table :data="storeRankings" style="width: 100%" :show-header="true">
               <el-table-column prop="index" type="index" label="排名" width="80" />
               <el-table-column label="门店名称" align="center" prop="storeName" />
-              <el-table-column label="入厂金额" align="center" prop="dailyInFactoryAmount">
+              <el-table-column label="洗衣件数" align="center" prop="clothCount" />
+              <el-table-column label="洗衣金额" align="center" prop="clothReceiveAmount">
                 <template slot-scope="scope">
-                  ¥{{ scope.row.dailyInFactoryAmount }}
+                  ¥{{ scope.row.clothReceiveAmount }}
                 </template>
               </el-table-column>
-              <el-table-column label="退单金额" align="center" prop="dailyRefundAmount">
+              <el-table-column label="零售单数" align="center" prop="goodsOrderCount" />
+              <el-table-column label="零售金额" align="center" prop="goodsReceiveAmount">
                 <template slot-scope="scope">
-                  ¥{{ scope.row.dailyRefundAmount }}
+                  ¥{{ scope.row.goodsReceiveAmount }}
+                </template>
+              </el-table-column>
+              <el-table-column label="充值笔数" align="center" prop="chargeCount" />
+              <el-table-column label="充值金额" align="center" prop="chargeAmount">
+                <template slot-scope="scope">
+                  ¥{{ scope.row.dailyChargeAmount }}
                 </template>
               </el-table-column>
-              <el-table-column label="入厂衣服数" align="center" prop="dailyInFactoryCount" />
-              <el-table-column label="检查衣服数" align="center" prop="dailyCheckedCount" />
-              <el-table-column label="出厂衣服数" align="center" prop="dailyOutFactoryCount" />
             </el-table>
           </div>
         </div>
@@ -164,76 +215,55 @@
 
 <script>
 import CountTo from 'vue-count-to'
-import { getTotalStatistics, listStatisticsByDate, listFactoryStatisticsByStore, factoryDashborad } from '@/api/settlement/statistics'
-import { getTimeoutClothing } from '@/api/statistics/reception'
+import {
+  platformDashborad, getplatformDayTrend, listplatformStatisticsByDate, listplatformStatisticsByStore
+} from '@/api/settlement/statistics'
 import AmountTrendChart from './components/AmountTrendChart'
-import CountTrendChart from './components/CountTrendChart'
 
 export default {
   name: 'Index',
-  dicts: ['sys_source_type'],
   components: {
     CountTo,
-    AmountTrendChart,
-    CountTrendChart
+    AmountTrendChart
   },
   data() {
     return {
       version: "3.8.4",
-      timeoutClothing: {},
-      roleType: false,
       statistics: {
-        totalClothCount: 0,
-        totalClothAmount: 0,
-        totalCancelCount: 0,
-        totalCancelAmount: 0
+        clothCount: 0,
+        clothReceiveAmount: 0,
+        goodsReceiveAmount: 0,
+        goodsOrderCount: 0,
+        chargeCount: 0,
+        chargeAmount: 0
       },
-      factoryStatistics: {
-        dailyInFactoryCount: 0,
-        dailyInFactoryAmount: 0,
-        dailyRefundCount: 0,
-        dailyRefundAmount: 0,
-        dailyActualSettlementAmount: 0
+      dayStatistics: {
+        clothCount: 0,
+        clothReceiveAmount: 0,
+        goodsReceiveAmount: 0,
+        goodsOrderCount: 0,
+        chargeCount: 0,
+        chargeAmount: 0
       },
       revenueTimeRange: 'today',
       rankingTimeRange: 'week',
-      amountTrendData: [],
-      countTrendData: [],
+      clothTrendData: [],
+      goodsTrendData: [],
+      chargeTrendData: [],
       storeRankings: []
     }
   },
   created() {
-    // this.getroletype()
-    // this.getTimeout()
     this.getStatistics()
     this.getFactoryStatisticsData()
     this.getStoreRankings()
     this.getTrendData()
   },
   methods: {
-    getroletype() {
-      let name = ''
-      this.dict.type.sys_source_type.map(item => {
-        if (item.value === this.$store.getters.user.userType) {
-          name = item.label
-        }
-      })
-    },
-    goTarget(href) {
-      window.open(href, "_blank");
-    },
-    getTimeout() {
-      getTimeoutClothing(this.queryParams).then(response => {
-        this.timeoutClothing = response.data;
-      });
-    },
-    btn_goto(type) {
-      this.$router.push({ path: '/query/overtimeOrders' })
-    },
     getStatistics() {
       // 获取累积统计数据
-      factoryDashborad({}).then(response => {
-        this.statistics = response.data
+      platformDashborad({}).then(response => {
+        this.statistics = response.data.orderStats
       })
     },
     handleRevenueTimeRangeChange() {
@@ -248,8 +278,10 @@ export default {
         startDate: this.getStartDateByTimeRange(),
         endDate: this.formatDate(new Date())
       }
-      getTotalStatistics(params).then(response => {
-        this.factoryStatistics = response.data
+      getplatformDayTrend(params).then(response => {
+        if(response.data.orderTrend) {
+          this.dayStatistics = response.data.orderTrend
+        }
       })
     },
     getStartDateByTimeRange() {
@@ -292,7 +324,7 @@ export default {
       }
 
       // 使用 listFactoryStatisticsByStore 方法获取门店排行数据
-      listFactoryStatisticsByStore(params).then(response => {
+      listplatformStatisticsByStore(params).then(response => {
         this.storeRankings = response.rows || []
       })
     },
@@ -308,22 +340,26 @@ export default {
       }
 
       // 获取趋势数据
-      listStatisticsByDate(params).then(response => {
-        const data = response.rows || []
+      listplatformStatisticsByDate(params).then(response => {
+        const data = response.data || []
 
-        // 处理金额趋势数据
-        this.amountTrendData = data.map(item => ({
-          date: item.statisticsDate,
-          value: item.dailyInFactoryAmount || 0
+        // 处理洗衣交易趋势数据
+        this.clothTrendData = data.map(item => ({
+          date: item.day,
+          value: item.clothOrderAmount || 0
         }))
 
-        // 处理件数趋势数据 - 确保格式正确
-        this.countTrendData = {
-          dates: data.map(item => item.statisticsDate || ''),
-          inFactory: data.map(item => item.dailyInFactoryCount || 0),
-          checked: data.map(item => item.dailyCheckedCount || 0),
-          outFactory: data.map(item => item.dailyOutFactoryCount || 0)
-        }
+        // 处理零售交易趋势数据
+        this.goodsTrendData = data.map(item => ({
+          date: item.day,
+          value: item.goodsReceiveAmount || 0
+        }))
+
+        // 处理充值交易趋势数据
+        this.chargeTrendData = data.map(item => ({
+          date: item.day,
+          value: item.chargeAmount || 0
+        }))
       })
     }
   }
@@ -371,14 +407,22 @@ export default {
       background: linear-gradient(135deg, #52c41a, #73d13d);
     }
 
-    .stat-card-red {
-      background: linear-gradient(135deg, #f5222d, #ff4d4f);
+    .stat-card-purple {
+      background: linear-gradient(135deg, #722ed1, #9254de);
     }
 
     .stat-card-orange {
       background: linear-gradient(135deg, #fa8c16, #ffa940);
     }
 
+    .stat-card-red {
+      background: linear-gradient(135deg, #f5222d, #ff4d4f);
+    }
+
+    .stat-card-cyan {
+      background: linear-gradient(135deg, #13c2c2, #36cfc9);
+    }
+
     .card-panel {
       height: 108px;
       cursor: pointer;
@@ -399,11 +443,17 @@ export default {
         .icon-revenue {
           background: #34bfa3;
         }
-        .icon-cancel {
-          background: #f4516c;
+        .icon-goods {
+          background: #722ed1;
+        }
+        .icon-goods-amount {
+          background: #fa8c16;
+        }
+        .icon-charge {
+          background: #f5222d;
         }
-        .icon-cancel-amount {
-          background: #ff9800;
+        .icon-charge-amount {
+          background: #13c2c2;
         }
       }
       .card-panel-icon-wrapper {

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

@@ -19,7 +19,7 @@
               <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.clothCashAmount || 0" :duration="2600" prefix="¥" />
+                  <count-to :start-val="0" :end-val="orderStats.clothOrderAmount || 0" :duration="2600" prefix="¥" />
                 </div>
               </div>
             </el-col>

+ 44 - 89
yiqi-admin/src/main/java/com/yiqi/admin/controller/settlement/PlatformStatisticsController.java

@@ -6,16 +6,17 @@ import com.yiqi.common.core.domain.AjaxResult;
 import com.yiqi.common.core.page.TableDataInfo;
 import com.yiqi.common.utils.DateUtils;
 import com.yiqi.common.utils.poi.ExcelUtil;
+import com.yiqi.core.domain.SettlementStoreStatistics;
 import com.yiqi.core.service.ISettlementFactoryStatisticsService;
 import com.yiqi.core.service.ISettlementStoreClothStatisticsService;
+import com.yiqi.core.service.ISettlementStoreStatisticsService;
 import com.yiqi.order.domain.dto.SettlementFactoryStatisticsDto;
+import com.yiqi.settlement.domain.dto.StoreChargeStatistics;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 /**
  * 平台统计报表
@@ -30,112 +31,66 @@ public class PlatformStatisticsController extends BaseController {
     @Autowired
     private ISettlementStoreClothStatisticsService settlementStoreClothStatisticsService;
 
+    @Autowired
+    private ISettlementStoreStatisticsService settlementStoreStatisticsService;
+
     /**
      * 获取工厂端首页总收益数据
      */
     @GetMapping("/dashborad")
     public AjaxResult dashboard() {
-        SettlementFactoryStatisticsDto settlementFactoryStatisticsDto = settlementStoreClothStatisticsService.totalByCondition(getFactoryId(), null, null, null);
-        return AjaxResult.success(settlementFactoryStatisticsDto);
+        // 获取订单统计数据
+        SettlementStoreStatistics orderStats = settlementStoreStatisticsService.orderStatistics(null, null, null);
+        Map<String, Object> result = new HashMap<>();
+        result.put("orderStats", orderStats);
+        return AjaxResult.success(result);
     }
 
     /**
-     * 获取门店每日交易统计列表
+     * 获取门店经营日报趋势数据
      */
-    @GetMapping("/list/bydate")
-    public TableDataInfo generateFactoryStatisticsByDate(@RequestParam(required = false) String startDate,
-                                                         @RequestParam(required = false) String endDate,
-                                                         @RequestParam(required = false) Long storeId,
-                                                         @RequestParam(defaultValue = "1") Integer pageNum,
-                                                         @RequestParam(defaultValue = "10") Integer pageSize) {
-
-        Date start = startDate != null ? DateUtils.parseDate(startDate) : DateUtils.addDays(new Date(), -14);
-        Date end = endDate != null ? DateUtils.parseDate(endDate) : new Date();
-        List<SettlementFactoryStatisticsDto> statisticsList = settlementFactoryStatisticsService
-                .generateFactoryStatisticsByDate(getLoginUser().getOrgId(), storeId, start, end, pageNum, pageSize);
-        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);
+    @GetMapping("/trend")
+    public AjaxResult getDailyTrend(@RequestParam("startDate") String startDate,
+                                    @RequestParam("endDate") String endDate) {
+        Date start = DateUtils.parseDate(startDate);
+        Date end = DateUtils.parseDate(endDate);
+        // 获取订单统计趋势
+        SettlementStoreStatistics orderStats = settlementStoreStatisticsService.orderStatistics(null, DateUtils.parseDate(startDate), DateUtils.parseDate(endDate));
+        Map<String, Object> result = new HashMap<>();
+        result.put("orderTrend", orderStats);
+        return AjaxResult.success(result);
     }
 
-
     /**
-     * 获取门店每日充值统计列表
+     * 获取每日交易统计列表
      */
-    @GetMapping("/list/bystore")
-    public TableDataInfo generateFactoryStatisticsByStore(@RequestParam(required = false) String startDate,
-                                                          @RequestParam(required = false) String endDate,
-                                                          @RequestParam(required = false) Long storeId,
-                                                          @RequestParam(defaultValue = "1") Integer pageNum,
-                                                          @RequestParam(defaultValue = "15") Integer pageSize) {
-        Date start = startDate != null ? DateUtils.parseDate(startDate) : DateUtils.addDays(new Date(), -14);
-        Date end = endDate != null ? DateUtils.parseDate(endDate) : new Date();
-        List<SettlementFactoryStatisticsDto> statisticsList = settlementFactoryStatisticsService
-                .generateFactoryStatisticsByStoreId(getLoginUser().getOrgId(), storeId, start, end);
-        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);
-    }
+    @GetMapping("/order/list")
+    public AjaxResult list(@RequestParam(required = false) String startDate,
+                           @RequestParam(required = false) String endDate,
+                           @RequestParam(defaultValue = "1") Integer pageNum,
+                           @RequestParam(defaultValue = "15") Integer pageSize) {
 
-    /**
-     * 获取门店每日充值统计列表
-     */
-    @GetMapping("/total")
-    public AjaxResult generateFactoryStatistics(@RequestParam(required = false) String startDate,
-                                                @RequestParam(required = false) String endDate,
-                                                @RequestParam(required = false) Long storeId,
-                                                @RequestParam(defaultValue = "1") Integer pageNum,
-                                                @RequestParam(defaultValue = "15") Integer pageSize) {
-        Date start = startDate != null ? DateUtils.parseDate(startDate) : DateUtils.addDays(new Date(), -14);
-        Date end = endDate != null ? DateUtils.parseDate(endDate) : new Date();
-        SettlementFactoryStatisticsDto settlementFactoryStatisticsDto = settlementFactoryStatisticsService
-                .generateTotalFactoryStatistics(getLoginUser().getOrgId(), storeId, start, end);
-        return AjaxResult.success(settlementFactoryStatisticsDto);
+        Date start = DateUtils.parseDate(startDate);
+        Date end = DateUtils.parseDate(endDate);
+        // 获取订单统计趋势
+        List<SettlementStoreStatistics> orderTrend = settlementStoreStatisticsService.generatePlatformStatisticsByDate(start, end);
+        return AjaxResult.success(orderTrend);
     }
 
     /**
-     *
+     * 获取门店每日订单统计列表
      */
-    @PostMapping("/export/bystore")
-    public void chargeExport(HttpServletResponse response, @RequestParam(required = false) String startDate,
-                             @RequestParam(required = false) String endDate,
-                             @RequestParam(required = false) Long storeId) {
+    @GetMapping("/order/bystore")
+    public TableDataInfo generateStatisticsByStore(@RequestParam(required = false) String startDate,
+                                                   @RequestParam(required = false) String endDate,
+                                                   @RequestParam(required = false) Long storeId,
+                                                   @RequestParam(defaultValue = "1") Integer pageNum,
+                                                   @RequestParam(defaultValue = "15") Integer pageSize) {
         Date start = startDate != null ? DateUtils.parseDate(startDate) : DateUtils.addDays(new Date(), -14);
         Date end = endDate != null ? DateUtils.parseDate(endDate) : new Date();
-        List<SettlementFactoryStatisticsDto> list = settlementFactoryStatisticsService
-                .generateFactoryStatisticsByStoreId(getLoginUser().getOrgId(), storeId, start, end);
-        ExcelUtil<SettlementFactoryStatisticsDto> util = new ExcelUtil<>(SettlementFactoryStatisticsDto.class);
-        util.exportExcel(response, list, "工厂门店报表统计");
+        startPage();
+        List<SettlementStoreStatistics> settlementStoreStatistics = settlementStoreStatisticsService.generatePlatformStatisticsByStore(start, end);
+        return getDataTable(settlementStoreStatistics);
     }
 
-    /**
-     * 导出门店每日交易统计
-     */
-    @PostMapping("/export/bydate")
-    public void export(HttpServletResponse response, @RequestParam(required = false) String startDate,
-                       @RequestParam(required = false) String endDate,
-                       @RequestParam(required = false) Long storeId) {
-        Date start = startDate != null ? DateUtils.parseDate(startDate) : DateUtils.addDays(new Date(), -14);
-        Date end = endDate != null ? DateUtils.parseDate(endDate) : new Date();
-        List<SettlementFactoryStatisticsDto> list = settlementFactoryStatisticsService
-                .generateFactoryStatisticsByDate(getLoginUser().getOrgId(), storeId, start, end, 1, 1000);
-        ExcelUtil<SettlementFactoryStatisticsDto> util = new ExcelUtil<>(SettlementFactoryStatisticsDto.class);
-        util.exportExcel(response, list, "工厂每日报表统计");
-    }
 }

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

@@ -29,7 +29,7 @@ public class SettlementStoreStatisticsController extends BaseController {
     @GetMapping("/dashboard")
     public AjaxResult dashboard() {
         // 获取订单统计数据
-        SettlementStoreStatistics orderStats = settlementStoreStatisticsService.orderTotal(getStoreId(), null);
+        SettlementStoreStatistics orderStats = settlementStoreStatisticsService.orderStatistics(getStoreId(), null, null);
 
         // 获取充值统计数据
         StoreChargeStatistics chargeStats = settlementStoreStatisticsService.chargeTotal(getStoreId());

+ 0 - 41
yiqi-common/src/main/java/com/yiqi/core/domain/SettlementManageStore.java

@@ -305,7 +305,6 @@ public class SettlementManageStore
     /** 福利结算表id */
     @Excel(name = "福利结算表id")
     @ApiModelProperty("福利结算表id")
-
     private Long welfareSettleId;
 
     /** 卡密金额 */
@@ -333,46 +332,6 @@ public class SettlementManageStore
     @ApiModelProperty("已付卡密押金")
     private BigDecimal paidCardPasswordDeposit;
 
-    /** 工厂结算费率(门店洗衣费率)/云洗费率 */
-    @Excel(name = "工厂结算费率", readConverterExp = "门=店洗衣费率")
-    @ApiModelProperty("工厂结算费率(门店洗衣费率)/云洗费率")
-    private BigDecimal factoryRate;
-
-    /** 材料费率 */
-    @Excel(name = "材料费率")
-    @ApiModelProperty("材料费率")
-    private BigDecimal materialRate;
-
-    /** 管理费率 */
-    @Excel(name = "管理费率")
-    @ApiModelProperty("管理费率")
-    private BigDecimal manageRate;
-
-    /** 押金费率 */
-    @Excel(name = "押金费率")
-    @ApiModelProperty("押金费率")
-    private BigDecimal depositRate;
-
-    /** 异店消费费率 */
-    @Excel(name = "异店消费费率")
-    @ApiModelProperty("异店消费费率")
-    private BigDecimal otherStoreRate;
-
-    /** 支付宝费率 */
-    @Excel(name = "支付宝费率")
-    @ApiModelProperty("支付宝费率")
-    private BigDecimal aliPayRate;
-
-    /** 微信费率 */
-    @Excel(name = "微信费率")
-    @ApiModelProperty("微信费率")
-    private BigDecimal wxPayRate;
-
-    /** 支付宝微信费率 */
-    @Excel(name = "支付宝微信费率")
-    @ApiModelProperty("支付宝微信费率")
-    private BigDecimal aliWxPayRate;
-
 
     private String remark;
 }

+ 42 - 0
yiqi-common/src/main/java/com/yiqi/core/domain/SettlementStoreStatistics.java

@@ -278,4 +278,46 @@ public class SettlementStoreStatistics extends BaseEntity {
     @ApiModelProperty("福利支付金额")
     private BigDecimal goodsMemberRefundAmount;
 
+    /**
+     * 充值订单数
+     */
+    @Excel(name = "充值订单数")
+    @ApiModelProperty("充值订单数")
+    private Integer chargeCount;
+
+    /**
+     * 充值金额
+     */
+    @Excel(name = "充值金额")
+    @ApiModelProperty("充值金额")
+    private BigDecimal chargeAmount;
+
+    /**
+     * 充值到账金额
+     */
+    @Excel(name = "充值到账金额")
+    @ApiModelProperty("充值到账金额")
+    private BigDecimal chargeArriveAmount;
+
+    /**
+     * 充值订单数
+     */
+    @Excel(name = "充值退款数")
+    @ApiModelProperty("充值退款数")
+    private Integer chargeRefundCount;
+
+    /**
+     * 充值金额
+     */
+    @Excel(name = "充值金额")
+    @ApiModelProperty("充值金额")
+    private BigDecimal chargeRefundAmount;
+
+
+    /**
+     * 充值退款到账金额
+     */
+    @Excel(name = "充值退款到账金额")
+    @ApiModelProperty("充值退款到账金额")
+    private BigDecimal chargeRefundArriveAmount;
 }

+ 8 - 0
yiqi-common/src/main/java/com/yiqi/core/service/ISettlementManageBillService.java

@@ -27,6 +27,14 @@ public interface ISettlementManageBillService extends IService<SettlementManageB
     StoreBillStatistics storeBillSettlement(Long storeId, Date startTime, Date endTime);
 
 
+    /**
+     * @param startTime
+     * @param endTime
+     * @desc 平台订单结算统计
+     */
+    StoreBillStatistics platformBillSettlement(Date startTime, Date endTime);
+
+
     /**
      * @param storeId
      * @param startTime

+ 26 - 8
yiqi-common/src/main/java/com/yiqi/core/service/ISettlementStoreStatisticsService.java

@@ -27,27 +27,45 @@ public interface ISettlementStoreStatisticsService extends IService<SettlementSt
     /**
      * 查询门店每日统计列表
      *
-     * @param settlementStoreStatistics 门店每日统计
      * @return 门店每日统计集合
      */
     List<SettlementStoreStatistics> generateStoreStatisticsByDate(Long storeId, Date start, Date end);
 
+
     /**
-     * 生成每日统计数据*
+     * 平台每日统计列表
      *
-     * @param date
-     * @return
+     * @return 门店每日统计集合
      */
-    void generateDayStatistics(Date date);
+    List<SettlementStoreStatistics> generatePlatformStatisticsByDate(Date start, Date end);
+
 
     /**
-     * 获取门店的累计交易统计
+     * 平台每日统计列表
+     *
+     * @return 门店每日统计集合
+     */
+    SettlementStoreStatistics orderStatistics(Long storeId, Date start, Date end);
+
+
+
+    StoreChargeStatistics generateChargeStatistics(Long storeId, Date start, Date end);
+
+
+    /**
+     * 平台每日统计列表 (按门店)
+     *
+     * @return 门店每日统计集合
+     */
+    List<SettlementStoreStatistics> generatePlatformStatisticsByStore(Date start, Date end);
+
+    /**
+     * 生成每日统计数据*
      *
-     * @param storeId
      * @param date
      * @return
      */
-    SettlementStoreStatistics orderTotal(Long storeId, Date date);
+    void generateDayStatistics(Date date);
 
     /**
      * 获取门店的累计充值交易统计

+ 2 - 2
yiqi-common/src/main/java/com/yiqi/order/domain/OrderClothItem.java

@@ -189,8 +189,8 @@ public class OrderClothItem extends BaseEntity
      *     refund("102","撤单"),
      *
      *     */
-    @Excel(name = "洗衣状态", readConverterExp = "0=待入厂,1=已入厂,2=已检查,3=已出厂,4=已上挂,5=已取衣,6=已到店、待送衣,7=送衣中,8=已送达、待评价,9=已完成,100=重洗,101=删除入厂,102=撤单")
-    @ApiModelProperty("洗衣状态(0=待入厂,1=已入厂,2=已检查,3=已出厂,4=已上挂,5=已取衣,6=已到店、待送衣,7=送衣中,8=已送达、待评价,9=已完成,100=重洗,101=删除入厂,102=撤单)")
+    @Excel(name = "洗衣状态", readConverterExp = "0=待入厂,1=已入厂,2=已检查,3=已出厂,4=已上挂,5=已取衣,6=已到店、待送衣,7=送衣中,8=已送达、待评价,9=已完成,100=重洗,11=删除入厂,-1=撤单")
+    @ApiModelProperty("洗衣状态(0=待入厂,1=已入厂,2=已检查,3=已出厂,4=已上挂,5=已取衣,6=已到店、待送衣,7=送衣中,8=已送达、待评价,9=已完成,100=重洗,11=删除入厂,-1=撤单)")
     private String flowStatus;
 
 

+ 7 - 0
yiqi-common/src/main/java/com/yiqi/order/domain/OrderGoods.java

@@ -76,6 +76,13 @@ public class OrderGoods extends BaseEntity {
     @ApiModelProperty("商品类别")
     private String goodsType;
 
+    /**
+     * 商品数量
+     */
+    @Excel(name = "商品数量")
+    @ApiModelProperty("商品数量")
+    private Integer goodsCount;
+
     /**
      * 商品订单类型
      */

+ 10 - 3
yiqi-common/src/main/java/com/yiqi/order/domain/dto/RechargeCardPayDTO.java

@@ -1,5 +1,6 @@
 package com.yiqi.order.domain.dto;
 
+import com.yiqi.common.annotation.Excel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -16,8 +17,13 @@ public class RechargeCardPayDTO {
     @ApiModelProperty("客户ID")
     private Long appUserId;
 
+    /** 来源类型 */
+    @Excel(name = "来源类型")
+    @ApiModelProperty("来源类型")
+    private String sourceType;
+
     @ApiModelProperty("扣款门店ID")
-    private Long storeId;
+    private Long orgId;
 
     @ApiModelProperty("订单编号,预约单时需要")
     @NotNull(message = "订单编号必传")
@@ -39,8 +45,9 @@ public class RechargeCardPayDTO {
     @NotEmpty(message = "购买商品类型 1:洗衣 2:普通商品 3:生活服务 4:汽车美容")
     private String buyGoodsType;
 
-    public RechargeCardPayDTO(Long appUserId, Long storeId, String orderNo, BigDecimal payAmount, String buyGoodsType) {
-        this.storeId = storeId;
+    public RechargeCardPayDTO(Long appUserId, String sourceType, Long orgId, String orderNo, BigDecimal payAmount, String buyGoodsType) {
+        this.sourceType = sourceType;
+        this.orgId = orgId;
         this.appUserId = appUserId;
         this.orderNo = orderNo;
         this.payAmount = payAmount;

+ 9 - 2
yiqi-common/src/main/java/com/yiqi/recharge/domain/dto/BillMstrOrderDTO.java

@@ -76,9 +76,16 @@ public class BillMstrOrderDTO {
     private Long appUserId;
 
     /**
-     * 扣款门店
+     * 消费来源
      */
-    private Long storeId;
+    @Excel(name = "来源类型")
+    @ApiModelProperty("来源类型")
+    private String sourceType;
+
+    /**
+     * 消费来源门店
+     */
+    private Long orgId;
 
     /**
      * 会员卡绑定门店

+ 5 - 0
yiqi-common/src/main/java/com/yiqi/settlement/domain/dto/OrderStatisticsVO.java

@@ -13,6 +13,11 @@ public class OrderStatisticsVO {
      * 订单数量
      */
     private Integer orderCount;
+
+    /**
+     * 商品数量 或者 衣服件数
+     */
+    private Integer goodsCount;
     
     /**
      * 交易笔数

+ 4 - 6
yiqi-core/src/main/java/com/yiqi/app/service/impl/AppUserBillMstrServiceImpl.java

@@ -8,8 +8,6 @@ import com.yiqi.common.core.domain.R;
 import com.yiqi.common.enums.*;
 import com.yiqi.common.utils.DateUtils;
 import com.yiqi.common.utils.EnumUtils;
-import com.yiqi.order.domain.dto.PayRefundDTO;
-import com.yiqi.order.domain.dto.RefundBaseDTO;
 import com.yiqi.order.service.IPayService;
 import com.yiqi.recharge.domain.dto.BillMstrOrderDTO;
 import com.yiqi.recharge.domain.dto.ConsumeOrderDTO;
@@ -62,9 +60,9 @@ public class AppUserBillMstrServiceImpl extends ServiceImpl<AppUserBillMstrMappe
         appUserBillMstr.setIsRefund(SysBoolType.NO.getCode());
         appUserBillMstr.setOrderNo(billMstrOrderDTO.getOrderNo());
         appUserBillMstr.setOrderType(billMstrOrderDTO.getOrderType());
-        appUserBillMstr.setOrgId(billMstrOrderDTO.getStoreId());
+        appUserBillMstr.setSourceType(billMstrOrderDTO.getSourceType());
+        appUserBillMstr.setOrgId(billMstrOrderDTO.getOrgId());
         appUserBillMstr.setCardStoreId(billMstrOrderDTO.getUseBindStoreId());
-        appUserBillMstr.setSourceType(SourceType.STORE.getCode());
         appUserBillMstr.setContent(billMstrOrderDTO.getRemark());
         appUserBillMstr.setRechargeCardNo(billMstrOrderDTO.getRechargeCardNo());
         switch (EnumUtils.getEnumByType(billMstrOrderDTO.getOrderType(), OrderType.class)) {
@@ -112,9 +110,9 @@ public class AppUserBillMstrServiceImpl extends ServiceImpl<AppUserBillMstrMappe
         appUserBillMstr.setIsRefund(SysBoolType.YES.getCode());
         appUserBillMstr.setOrderNo(billMstrOrderDTO.getOrderNo());
         appUserBillMstr.setOrderType(billMstrOrderDTO.getOrderType());
-        appUserBillMstr.setOrgId(billMstrOrderDTO.getStoreId());
+        appUserBillMstr.setOrgId(billMstrOrderDTO.getOrgId());
         appUserBillMstr.setCardStoreId(billMstrOrderDTO.getUseBindStoreId());
-        appUserBillMstr.setSourceType(SourceType.STORE.getCode());
+        appUserBillMstr.setSourceType(billMstrOrderDTO.getSourceType());
         appUserBillMstr.setContent(billMstrOrderDTO.getRemark());
         switch (EnumUtils.getEnumByType(billMstrOrderDTO.getOrderType(), OrderType.class)) {
             case cloth: {

+ 23 - 3
yiqi-core/src/main/java/com/yiqi/core/mapper/SettlementStoreStatisticsMapper.java

@@ -40,20 +40,40 @@ public interface SettlementStoreStatisticsMapper extends BaseMapper<SettlementSt
      */
     public int deleteSettlementStoreStatisticsByIds(Long[] ids);
 
+
     /**
      * 查询订单统计
      *
      * @param storeId 门店id
-     * @param day     日期
      * @return 结果
      */
-    SettlementStoreStatistics orderTotal(@Param("storeId") Long storeId, @Param("day") Integer day);
+    StoreChargeStatistics chargeTotal(@Param("storeId") Long storeId);
+
+    /**
+     * 查询订单统计
+     *
+     * @param startDay 开始日期
+     * @param endDay   结束日期
+     * @return 结果
+     */
+    List<SettlementStoreStatistics> totalByDate(@Param("startDay") Integer startDay, @Param("endDay") Integer endDay);
+
+    /**
+     * 查询订单统计
+     *
+     * @param startDay 开始日期
+     * @param endDay   结束日期
+     * @return 结果
+     */
+    List<SettlementStoreStatistics> totalByStore(@Param("startDay") Integer startDay, @Param("endDay") Integer endDay);
 
     /**
      * 查询订单统计
      *
      * @param storeId 门店id
+     * @param startDay 开始日期
+     * @param endDay   结束日期
      * @return 结果
      */
-    StoreChargeStatistics chargeTotal(@Param("storeId") Long storeId);
+    SettlementStoreStatistics orderStatistics(@Param("storeId") Long storeId, @Param("startDay") Integer startDay, @Param("endDay") Integer endDay);
 }

+ 178 - 57
yiqi-core/src/main/java/com/yiqi/core/service/impl/SettlementManageBillServiceImpl.java

@@ -11,6 +11,7 @@ import com.wechat.pay.java.service.billdownload.model.BillType;
 import com.yiqi.app.domain.AppUserBillMstr;
 import com.yiqi.app.service.IAppUserBillMstrService;
 import com.yiqi.common.enums.*;
+import com.yiqi.common.exception.ServiceException;
 import com.yiqi.common.utils.CurrencyUtil;
 import com.yiqi.common.utils.DateUtils;
 import com.yiqi.core.domain.SettlementManageFactory;
@@ -111,7 +112,7 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         settlementManageBill.setEndTime(endTime);
         settlementManageBill.setTitle(settlementBillAddDTO.getTitle());
         settlementManageBill.buildCreateData();
-        settlementManageBill.setStatus(SettlementBillStatusType.COUNT.getCode());
+        settlementManageBill.setStatus(SettlementBillStatusType.WAITING.getCode());
         settlementManageBill.setDelFlag(StatusType.OK.getCode());
         this.save(settlementManageBill);
         return settlementManageBill;
@@ -132,14 +133,7 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         }
 
         for (ManageFactory factory : factoryList) {
-            //查询衣服订单,入场时间在上个月的,切没有撤销的衣服
-            List<OrderClothItem> orderClothItemList = orderClothItemService.list(new QueryWrapper<OrderClothItem>().lambda()
-                    .ne(OrderClothItem::getFlowStatus, ClothOrderFlowStatus.refund.getCode())
-                    .eq(OrderClothItem::getFactoryId, factory.getId())
-                    .ge(OrderClothItem::getCreateTime, settlementManageBill.getBeginTime())
-                    .ge(OrderClothItem::getInFactoryTime, settlementManageBill.getBeginTime())
-                    .lt(OrderClothItem::getInFactoryTime, DateUtils.addDays(settlementManageBill.getEndTime(), 1)));
-            this.buildFactorySettlement(settlementManageBill, factory, orderClothItemList);
+            this.buildFactorySettlement(settlementManageBill, factory);
         }
     }
 
@@ -195,6 +189,42 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         return saveStatisticsResult(storeId, startTime, endTime, clothStats, goodsStats, paymentStats);
     }
 
+    @Override
+    public StoreBillStatistics platformBillSettlement(Date startTime, Date endTime) {
+        // 1. 查询洗衣订单
+        List<OrderCloth> orderClothList = new ArrayList<>();
+
+        // 2. 查询商品订单
+        List<OrderGoods> orderGoodsList = orderGoodsService.list(new QueryWrapper<OrderGoods>().lambda()
+                .ne(OrderGoods::getOrderStatus, OrderGoodsStatusType.CANCEL_ORDER.getCode())
+                .eq(OrderGoods::getSourceType, SourceType.MANAGER.getCode())
+                .isNull(OrderGoods::getOrgId)
+                .between(OrderGoods::getCreateTime, startTime, endTime));
+
+        // 3. 查询衣服退款记录
+        List<OrderClothRefund> clothRefundList = new ArrayList<>();
+
+        // 4. 查询商品退款记录
+        List<OrderGoodsRefund> goodsRefundList = orderGoodsRefundService.list(new QueryWrapper<OrderGoodsRefund>().lambda()
+                .isNull(OrderGoodsRefund::getOrgId)
+                .eq(OrderGoodsRefund::getSourceType, SourceType.MANAGER.getCode())
+                .eq(OrderGoodsRefund::getRefundStatus, OrderRefundStatus.REFUND_SUCCESS.getCode())
+                .between(OrderGoodsRefund::getRefundTime, startTime, endTime));
+
+        // 5. 统计洗衣订单数据
+        OrderStatisticsVO clothStats = calculateClothOrderStats(orderClothList, clothRefundList);
+
+        // 6. 统计商品订单数据
+        OrderStatisticsVO goodsStats = calculateGoodsOrderStats(orderGoodsList, goodsRefundList);
+
+        // 7. 汇总支付方式统计
+        PaymentStatisticsVO paymentStats = calculatePaymentStats(clothStats, goodsStats);
+
+        // 8. 保存统计结果
+        return saveStatisticsResult(0L, startTime, endTime, clothStats, goodsStats, paymentStats);
+    }
+
+
     /**
      * 计算洗衣订单统计数据
      */
@@ -204,6 +234,12 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         stats.setTransactionRefundAmount(BigDecimal.ZERO);
         // 1. 订单数量统计
         stats.setOrderCount(orderList.size());
+        stats.setGoodsCount(
+                orderList.stream()
+                        .map(OrderCloth::getOrderClothCount)
+                        .filter(Objects::nonNull)
+                        .reduce(0, Integer::sum)
+        );
         // 2. 交易订单数量统计
         stats.setTransactionCount(orderList.stream()
                 .filter(order -> PayStatus.HAS_PAY.getCode().equals(order.getOrderStatus()))
@@ -261,6 +297,12 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         stats.setTransactionCount(orderList.stream()
                 .filter(order -> PayStatus.HAS_PAY.getCode().equals(order.getPayStatus()))
                 .count());
+//        stats.setGoodsCount(
+//                orderList.stream()
+//                        .map(OrderGoods::get)
+//                        .filter(Objects::nonNull)
+//                        .reduce(0, Integer::sum)
+//        );
 
         // 2. 订单金额统计
         BigDecimal totalAmount = orderList.stream()
@@ -511,6 +553,9 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         // 5. 计算运营相关金额
         calculateOperationalAmounts(settlement, data);
 
+        //计算跨店结算金
+        calculateCrossStoreAmount(settlement, data);
+
         // 6. 计算最终结算金额
         calculateFinalSettlement(settlement);
 
@@ -620,17 +665,18 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
                 .map(OrderClothItem::getPayPrice)
                 .reduce(BigDecimal.ZERO, BigDecimal::add);
         settlement.setWashClothAmount(washAmount);
-
-
-//        calculateCrossStoreAmount(data);
-
-
-//        BigDecimal crossStoreAmount = calculateCrossStoreAmount(data);
-//        settlement.setCrossStoreSettlementAmount(crossStoreAmount);
     }
 
     /**
      * 计算跨店结算金额
+     * *
+     * 1. 洗衣:线下门店,会员用余额支付的洗衣订单
+     * 2. 零售:线下门店,会员用余额支付的零售商品订单
+     * 3. app:线上app,会员用余额支付的零售商品订单(app洗衣订单不存在跨店结算)
+     * 4. 第三方:线下门店,会员用微信/支付宝等第三方支付渠道支付的所有订单(含洗衣和零售,实际情况下比较少)
+     * 5. 运费:暂时为0(目前平台和门店自有运费账户走预充值模式,字段保留)
+     * 根据会员余额所消费的门店费率计算分成,分成规则为:
+     * *      * 本店卡洗衣所得为本店卡在异店消费分给消费门店的费用,异店卡洗衣为异店卡在本店消费分给本店的费用**
      */
     private void calculateCrossStoreAmount(SettlementManageStore settlement, StoreSettlementData data) {
         // 4. 计算跨店结算金额(会员卡)
@@ -638,33 +684,109 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         // (本店卡:零售*费率-异店卡:零售*费率)+(本店卡:app*费率-异店卡:app*费率)+
         // (本店卡:第三方*费率-异店卡:第三方*费率)+(本店卡:运费*费率-异店卡:运费*费率)
         //消费的订单金额  洗衣 零售 app 第三方 运费
-        Map<String, BigDecimal> consoumeMaps = data.getCrossStoreBills().stream()
-                .filter(order -> OrderBillType.pay.getCode().equals(order.getBillType()))
-                .collect(Collectors.groupingBy(
-                        AppUserBillMstr::getOrderType,
-                        Collectors.reducing(
-                                BigDecimal.ZERO,
-                                AppUserBillMstr::getPayTotalAmount,
-                                BigDecimal::add
-                        )));
-        //退款的订单金额
-        Map<String, BigDecimal> refundMaps = data.getCrossStoreBills().stream()
-                .filter(order -> OrderBillType.recharge.getCode().equals(order.getBillType()))
-                .collect(Collectors.groupingBy(
-                        AppUserBillMstr::getOrderType,
-                        Collectors.reducing(
-                                BigDecimal.ZERO,
-                                AppUserBillMstr::getPayTotalAmount,
-                                BigDecimal::add
-                        )));
-
-
+        BigDecimal washAmount = BigDecimal.ZERO;
+        BigDecimal washOtherAmount = BigDecimal.ZERO; //洗衣异店
+        BigDecimal goodsAmount = BigDecimal.ZERO;
+        BigDecimal goodsOtherAmount = BigDecimal.ZERO;
+        BigDecimal appAmount = BigDecimal.ZERO;
+        BigDecimal appOtherAmount = BigDecimal.ZERO;
+        BigDecimal thirdAmount = BigDecimal.ZERO;
+        BigDecimal thirdOtherAmount = BigDecimal.ZERO;
+        BigDecimal freightAmount = BigDecimal.ZERO;
+
+        Long currentStoreId = settlement.getOrgId();
+
+        for (AppUserBillMstr appUserBillMstr : data.getCrossStoreBills()) {
+            if (appUserBillMstr.getIsRefund().equals(SysBoolType.NO.getCode())) {
+
+                if (appUserBillMstr.getSourceType().equals(SourceType.MANAGER.getCode())) {
+                    //线上三方使用门店卡支付的金额
+                    if (OrderType.goods.getCode().equals(appUserBillMstr.getOrderType()) || OrderType.life.getCode().equals(appUserBillMstr.getOrderType()) || OrderType.car.getCode().equals(appUserBillMstr.getOrderType())) {
+                        if (currentStoreId.equals(appUserBillMstr.getCardStoreId())) {
+                            appAmount = CurrencyUtil.add(appAmount, appUserBillMstr.getPayTotalAmount());
+                        }
+                    }
+                    continue;
+                }
+
+
+                if (OrderType.cloth.getCode().equals(appUserBillMstr.getOrderType())) {
+                    //本店的卡在其他店的消费
+                    if (currentStoreId.equals(appUserBillMstr.getCardStoreId()) && !currentStoreId.equals(appUserBillMstr.getOrgId())) {
+                        washAmount = CurrencyUtil.add(washAmount, appUserBillMstr.getPayTotalAmount());
+                    }
+                    //异店的卡在本店的消费
+                    if (!currentStoreId.equals(appUserBillMstr.getCardStoreId()) && currentStoreId.equals(appUserBillMstr.getOrgId())) {
+                        washOtherAmount = CurrencyUtil.add(washOtherAmount, appUserBillMstr.getPayTotalAmount());
+                    }
+                } else if (OrderType.goods.getCode().equals(appUserBillMstr.getOrderType()) || OrderType.life.getCode().equals(appUserBillMstr.getOrderType()) || OrderType.car.getCode().equals(appUserBillMstr.getOrderType())) {
+                    if (currentStoreId.equals(appUserBillMstr.getCardStoreId()) && !currentStoreId.equals(appUserBillMstr.getOrgId())) {
+                        goodsAmount = CurrencyUtil.add(goodsAmount, appUserBillMstr.getPayTotalAmount());
+                    }
+                    if (!currentStoreId.equals(appUserBillMstr.getCardStoreId()) && currentStoreId.equals(appUserBillMstr.getOrgId())) {
+                        goodsOtherAmount = CurrencyUtil.add(goodsOtherAmount, appUserBillMstr.getPayTotalAmount());
+                    }
+                }
+
+            } else {
+                //退款
+                if (appUserBillMstr.getSourceType().equals(SourceType.MANAGER.getCode())) {
+                    //线上三方使用门店卡支付的金额
+                    if (OrderType.goods.getCode().equals(appUserBillMstr.getOrderType()) || OrderType.life.getCode().equals(appUserBillMstr.getOrderType()) || OrderType.car.getCode().equals(appUserBillMstr.getOrderType())) {
+                        if (currentStoreId.equals(appUserBillMstr.getCardStoreId())) {
+                            appAmount = CurrencyUtil.sub(appAmount, appUserBillMstr.getPayTotalAmount());
+                        }
+                    }
+                    continue;
+                }
+
+
+                if (OrderType.cloth.getCode().equals(appUserBillMstr.getOrderType())) {
+                    //本店的卡在其他店的消费
+                    if (currentStoreId.equals(appUserBillMstr.getCardStoreId()) && !currentStoreId.equals(appUserBillMstr.getOrgId())) {
+                        washAmount = CurrencyUtil.sub(washAmount, appUserBillMstr.getPayTotalAmount());
+                    }
+                    //异店的卡在本店的消费
+                    if (!currentStoreId.equals(appUserBillMstr.getCardStoreId()) && currentStoreId.equals(appUserBillMstr.getOrgId())) {
+                        washOtherAmount = CurrencyUtil.sub(washOtherAmount, appUserBillMstr.getPayTotalAmount());
+                    }
+                } else if (OrderType.goods.getCode().equals(appUserBillMstr.getOrderType()) || OrderType.life.getCode().equals(appUserBillMstr.getOrderType()) || OrderType.car.getCode().equals(appUserBillMstr.getOrderType())) {
+                    if (currentStoreId.equals(appUserBillMstr.getCardStoreId()) && !currentStoreId.equals(appUserBillMstr.getOrgId())) {
+                        goodsAmount = CurrencyUtil.sub(goodsAmount, appUserBillMstr.getPayTotalAmount());
+                    }
+                    if (!currentStoreId.equals(appUserBillMstr.getCardStoreId()) && currentStoreId.equals(appUserBillMstr.getOrgId())) {
+                        goodsOtherAmount = CurrencyUtil.sub(goodsOtherAmount, appUserBillMstr.getPayTotalAmount());
+                    }
+                }
+
+            }
+        }
+        SettlementStoreRate settlementRate = data.getSettlementRate();
+        BigDecimal allPayAmount = CurrencyUtil.add(washAmount, goodsAmount, appAmount, thirdAmount, freightAmount);
+        BigDecimal otherPayAmount = CurrencyUtil.add(washOtherAmount, goodsOtherAmount, appOtherAmount, thirdOtherAmount);
+        BigDecimal crossStoreAmount = CurrencyUtil.mul(CurrencyUtil.sub(allPayAmount, otherPayAmount), settlementRate.getOtherConsumeRate());
+        settlement.setOtherStoreAmount(allPayAmount);
+        settlement.setOtherCardAmount(otherPayAmount);
+        settlement.setRetailOtherStoreAmount(goodsAmount);
+        settlement.setRetailOtherCardAmount(goodsOtherAmount);
+        settlement.setAppOtherStoreAmount(appAmount);
+        settlement.setAppOtherCardAmount(appOtherAmount);
+        settlement.setThirdOtherStoreAmount(thirdAmount);
+        settlement.setThirdOtherCardAmount(thirdOtherAmount);
+
+
+        settlement.setCrossStoreSettlementAmount(crossStoreAmount);
     }
 
     /**
      * 计算最终结算金额
      */
     private void calculateFinalSettlement(SettlementManageStore settlement) {
+
+        /**
+         * 门店结算金额=(支付宝+微信实收金额)-(应付押金-已付押金)-(应付福利押金+卡密押金-已付福利押金-已付卡密押金)
+         *  -原材料备用金-系统维护费-洗衣费-跨店结算金*
+         */
         BigDecimal finalAmount = settlement.getAlipayAmount()
                 .add(settlement.getWechatAmount())
                 .subtract(settlement.getPayableDeposit().subtract(settlement.getPaidDeposit()))
@@ -737,24 +859,33 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
      * @param settlementManageBill
      * @return
      */
-    private void buildFactorySettlement(SettlementManageBill settlementManageBill, ManageFactory factory, List<OrderClothItem> orderClothItemList) {
+    private void buildFactorySettlement(SettlementManageBill settlementManageBill, ManageFactory factory) {
+        if (settlementManageBill.getStatus().equals(SettlementBillStatusType.FINISH.getCode())) {
+            throw new ServiceException("该账单已结算完成,请勿重复操作");
+        }
+        //删除工厂结算数据,重新结算
+        settlementManageFactoryService.remove(new QueryWrapper<SettlementManageFactory>().lambda().eq(SettlementManageFactory::getOrgId, factory.getId()).eq(SettlementManageFactory::getBillId, settlementManageBill.getId()));
         SettlementFactoryRate settlementFactoryRate = settlementFactoryRateService.getByFactoryId(factory.getId(), settlementManageBill.getBeginTime());
+        SettlementManageFactory settlementManageFactory = new SettlementManageFactory();
+        this.buildFactorySettlementInfo(settlementManageFactory, settlementManageBill, factory);
         if (settlementFactoryRate == null) {
-            SettlementManageFactory settlementManageFactory = new SettlementManageFactory();
-            this.buildFactorySettlementInfo(settlementManageFactory, settlementManageBill, factory);
             this.build0ClothFactory(settlementManageFactory);
+            settlementManageFactory.setRemark("工厂暂无可用费率");
             settlementManageFactoryService.save(settlementManageFactory);
         }
+        //查询衣服订单,入场时间在上个月的,切没有撤销或者推单的衣服
+        List<OrderClothItem> orderClothItemList = orderClothItemService.list(new QueryWrapper<OrderClothItem>().lambda()
+                .isNull(OrderClothItem::getRefundId)
+                .eq(OrderClothItem::getFactoryId, factory.getId())
+                .ge(OrderClothItem::getCreateTime, settlementManageBill.getBeginTime())
+                .ge(OrderClothItem::getInFactoryTime, settlementManageBill.getBeginTime())
+                .lt(OrderClothItem::getInFactoryTime, DateUtils.addDays(settlementManageBill.getEndTime(), 1)));
         if (CollUtil.isEmpty(orderClothItemList)) {
-            SettlementManageFactory settlementManageFactory = new SettlementManageFactory();
-            this.buildFactorySettlementInfo(settlementManageFactory, settlementManageBill, factory);
             this.build0ClothFactory(settlementManageFactory);
+            settlementManageFactory.setRemark("无入厂洗衣订单");
             settlementManageFactoryService.save(settlementManageFactory);
             return;
         }
-        SettlementManageFactory settlementManageFactory = new SettlementManageFactory();
-        this.buildFactorySettlementInfo(settlementManageFactory, settlementManageBill, factory);
-
         settlementManageFactory.setTotalTransactionNum(orderClothItemList.size());
         //计算衣服总价格
         BigDecimal orderClothItemTotalPrice = orderClothItemList.stream().map(OrderClothItem::getTotalPrice).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
@@ -766,21 +897,13 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         //管理费
         BigDecimal managetAmount = CurrencyUtil.mul(settlementFactoryRate.getManagementRate(), orderClothItemTotalPrice);
         settlementManageFactory.setManageAmount(managetAmount);
-        //工厂结算金额总和
-//        BigDecimal factorySettlementAmount = orderClothItemList.stream().map(OrderClothItem::getFactorySettlementAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
-//        settlementManageFactory.setFactorySettlementAmount(factorySettlementAmount);
         // 工厂消费 = 材料费+ 管理费
         BigDecimal payMoney = settlementManageFactory.getManageAmount().add(settlementManageFactory.getMaterialAmount());
         // 工厂实际收入 = 工厂结算金额总和 - 工厂消费
         settlementManageFactory.setRealIncomeAmount(settlementManageFactory.getFactorySettlementAmount().subtract(payMoney));
         settlementManageFactoryService.save(settlementManageFactory);
-
-        // 设置账单洗衣费
-//        settlementManageBill.setWashClothAmount(
-//                orderClothItemList.stream().map(OrderClothItem::getFactorySettlementAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add)
-//        );
-        settlementManageBill.setStatus(SettlementBillStatusType.WAITING.getCode());
-        this.updateById(settlementManageBill);
+//        settlementManageBill.setStatus(SettlementBillStatusType.WAITING.getCode());
+//        this.updateById(settlementManageBill);
     }
 
     /**
@@ -819,8 +942,6 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         settlementManageFactory.setTotalTransactionNum(0);
         // 工厂实际收入
         settlementManageFactory.setRealIncomeAmount(BigDecimal.ZERO);
-        //
-        settlementManageFactory.setRemark("无入厂洗衣订单");
     }
 
     /**

+ 88 - 15
yiqi-core/src/main/java/com/yiqi/core/service/impl/SettlementStoreStatisticsServiceImpl.java

@@ -11,6 +11,7 @@ import com.yiqi.common.enums.PayStatus;
 import com.yiqi.common.enums.PayType;
 import com.yiqi.common.enums.RechargeRefundStatusType;
 import com.yiqi.common.enums.StatusType;
+import com.yiqi.common.utils.CurrencyUtil;
 import com.yiqi.common.utils.DateUtils;
 import com.yiqi.common.utils.SecurityUtils;
 import com.yiqi.core.service.ISettlementManageBillService;
@@ -77,6 +78,38 @@ public class SettlementStoreStatisticsServiceImpl extends ServiceImpl<Settlement
         return result;
     }
 
+    @Override
+    public SettlementStoreStatistics orderStatistics(Long storeId, Date start, Date end) {
+        Integer startDay = start != null ? Integer.parseInt(DateUtil.format(start, "yyyyMMdd")) : null;
+        Integer endDay = end != null ? Integer.parseInt(DateUtil.format(end, "yyyyMMdd")) : null;
+        return baseMapper.orderStatistics(storeId, startDay, endDay);
+    }
+
+    @Override
+    public StoreChargeStatistics generateChargeStatistics(Long storeId, Date start, Date end) {
+        return null;
+    }
+
+    @Override
+    public List<SettlementStoreStatistics> generatePlatformStatisticsByDate(Date start, Date end) {
+        Integer startDay = Integer.parseInt(DateUtil.format(start, "yyyyMMdd"));
+        Integer endDay = Integer.parseInt(DateUtil.format(end, "yyyyMMdd"));
+        List<SettlementStoreStatistics> result = baseMapper.totalByDate(startDay, endDay);
+        return result;
+    }
+
+    @Override
+    public List<SettlementStoreStatistics> generatePlatformStatisticsByStore(Date start, Date end) {
+        Integer startDay = Integer.parseInt(DateUtil.format(start, "yyyyMMdd"));
+        Integer endDay = Integer.parseInt(DateUtil.format(end, "yyyyMMdd"));
+        List<SettlementStoreStatistics> result = baseMapper.totalByStore(startDay, endDay);
+        for (SettlementStoreStatistics settlementStoreStatistics : result) {
+            settlementStoreStatistics.setStoreName(storeService.getById(settlementStoreStatistics.getStoreId()).getName());
+        }
+        return result;
+    }
+
+
     @Override
     public List<SettlementStoreStatistics> generateStoreStatisticsByStore(Date start) {
         Integer startDay = Integer.parseInt(DateUtil.format(start, "yyyyMMdd"));
@@ -101,6 +134,15 @@ public class SettlementStoreStatisticsServiceImpl extends ServiceImpl<Settlement
         // 2. 遍历门店生成统计数据
         for (SysStore store : storeList) {
             SettlementStoreStatistics settlementStoreStatistics = generateStoreStatistics(date, store.getId());
+            //充值统计
+            StoreChargeStatistics storeChargeStatistics = generateChargeStatistics(date, store.getId());
+            settlementStoreStatistics.setChargeAmount(storeChargeStatistics.getRechargePayAmount());
+            settlementStoreStatistics.setChargeCount(storeChargeStatistics.getRechargeCount());
+            settlementStoreStatistics.setChargeRefundCount(storeChargeStatistics.getRefundCount());
+            settlementStoreStatistics.setChargeRefundAmount(storeChargeStatistics.getRefundAmount());
+            settlementStoreStatistics.setChargeArriveAmount(CurrencyUtil.add(storeChargeStatistics.getArriveCashAmount(), storeChargeStatistics.getArriveGiveAmount(), storeChargeStatistics.getArriveWelfareAmount()));
+            settlementStoreStatistics.setChargeRefundArriveAmount(CurrencyUtil.add(storeChargeStatistics.getArriveCashRefundAmount(), storeChargeStatistics.getArriveGiveRefundAmount(), storeChargeStatistics.getArriveWelfareRefundAmount()));
+
             // 2.6 检查是否已存在当日统计数据
             QueryWrapper<SettlementStoreStatistics> queryWrapper = new QueryWrapper<>();
             queryWrapper.lambda()
@@ -117,12 +159,31 @@ public class SettlementStoreStatisticsServiceImpl extends ServiceImpl<Settlement
                 baseMapper.insert(settlementStoreStatistics);
             }
         }
-    }
-
-    @Override
-    public SettlementStoreStatistics orderTotal(Long storeId, Date date) {
-        Integer day = date != null ? Integer.valueOf(DateUtil.format(date, "yyyyMMdd")) : null;
-        return baseMapper.orderTotal(storeId, day);
+        //生成平台商品统计
+        SettlementStoreStatistics settlementStoreStatistics = generateStoreStatistics(date, 0L);
+//        StoreChargeStatistics storeChargeStatistics = generateChargeStatistics(date, null);
+//        settlementStoreStatistics.setChargeAmount(storeChargeStatistics.getRechargePayAmount());
+//        settlementStoreStatistics.setChargeCount(storeChargeStatistics.getRechargeCount());
+//        settlementStoreStatistics.setChargeRefundCount(storeChargeStatistics.getRefundCount());
+//        settlementStoreStatistics.setChargeRefundAmount(storeChargeStatistics.getRefundAmount());
+//        settlementStoreStatistics.setChargeArriveAmount(CurrencyUtil.add(storeChargeStatistics.getArriveCashAmount(), storeChargeStatistics.getArriveGiveAmount(), storeChargeStatistics.getArriveWelfareAmount()));
+//        settlementStoreStatistics.setChargeRefundArriveAmount(CurrencyUtil.add(storeChargeStatistics.getArriveCashRefundAmount(), storeChargeStatistics.getArriveGiveRefundAmount(), storeChargeStatistics.getArriveWelfareRefundAmount()));
+
+        // 2.6 检查是否已存在当日统计数据
+        QueryWrapper<SettlementStoreStatistics> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda()
+                .eq(SettlementStoreStatistics::getStoreId, 0L)
+                .eq(SettlementStoreStatistics::getDay, settlementStoreStatistics.getDay());
+
+        SettlementStoreStatistics existStatistics = baseMapper.selectOne(queryWrapper);
+        if (existStatistics != null) {
+            // 更新已存在的统计数据
+            settlementStoreStatistics.setId(existStatistics.getId());
+            baseMapper.updateById(settlementStoreStatistics);
+        } else {
+            // 插入新的统计数据
+            baseMapper.insert(settlementStoreStatistics);
+        }
     }
 
     @Override
@@ -133,11 +194,20 @@ public class SettlementStoreStatisticsServiceImpl extends ServiceImpl<Settlement
     @Override
     public SettlementStoreStatistics generateStoreStatistics(Date date, Long storeId) {
         // 2.1 获取门店当日统计数据
-        StoreBillStatistics statistics = settlementManageBillService.storeBillSettlement(
-                storeId,
-                DateUtils.getStartTime(date),
-                DateUtils.getEndTime(date)
-        );
+        StoreBillStatistics statistics = null;
+        if (storeId == 0L) {
+            //获取平台统计
+            statistics = settlementManageBillService.platformBillSettlement(
+                    DateUtils.getStartTime(date),
+                    DateUtils.getEndTime(date)
+            );
+        } else {
+            statistics = settlementManageBillService.storeBillSettlement(
+                    storeId,
+                    DateUtils.getStartTime(date),
+                    DateUtils.getEndTime(date)
+            );
+        }
 
         // 2.2 构建门店统计实体
         SettlementStoreStatistics storeStatistics = new SettlementStoreStatistics();
@@ -149,6 +219,7 @@ public class SettlementStoreStatisticsServiceImpl extends ServiceImpl<Settlement
         OrderStatisticsVO clothStats = statistics.getClothOrderStats();
         if (clothStats != null) {
             storeStatistics.setClothOrderCount(clothStats.getOrderCount());
+            storeStatistics.setClothCount(clothStats.getGoodsCount());
             storeStatistics.setClothOrderAmount(clothStats.getTotalAmount());
             storeStatistics.setClothReceiveAmount(clothStats.getTransactionAmount());
             storeStatistics.setClothWechatAmount(clothStats.getWechatAmount());
@@ -167,6 +238,7 @@ public class SettlementStoreStatisticsServiceImpl extends ServiceImpl<Settlement
         OrderStatisticsVO goodsStats = statistics.getGoodsOrderStats();
         if (goodsStats != null) {
             storeStatistics.setGoodsOrderCount(goodsStats.getOrderCount());
+            storeStatistics.setGoodsCount(goodsStats.getGoodsCount());
             storeStatistics.setGoodsOrderAmount(goodsStats.getTotalAmount());
             storeStatistics.setGoodsWechatAmount(goodsStats.getWechatAmount());
             storeStatistics.setGoodsAlipayAmount(goodsStats.getAlipayAmount());
@@ -179,6 +251,7 @@ public class SettlementStoreStatisticsServiceImpl extends ServiceImpl<Settlement
             storeStatistics.setGoodsCashRefundAmount(goodsStats.getCashRefundAmount());
             storeStatistics.setGoodsUnionRefundAmount(goodsStats.getUnionRefundAmount());
             storeStatistics.setGoodsMemberRefundAmount(goodsStats.getMemberRefundAmount());
+            storeStatistics.setGoodsReceiveAmount(goodsStats.getTransactionAmount());
         }
         return storeStatistics;
     }
@@ -188,14 +261,14 @@ public class SettlementStoreStatisticsServiceImpl extends ServiceImpl<Settlement
         try {
             // 1. 查询门店当日充值记录
             List<OrderRecharge> rechargeList = orderRechargeService.list(new QueryWrapper<OrderRecharge>().lambda()
-                    .eq(OrderRecharge::getStoreId, storeId)
+                    .eq(storeId != null, OrderRecharge::getStoreId, storeId)
                     .eq(OrderRecharge::getPayStatus, PayStatus.HAS_PAY.getCode())
                     .eq(OrderRecharge::getDelFlag, StatusType.OK.getCode())
                     .between(OrderRecharge::getPayTime, DateUtils.getStartTime(date), DateUtils.getEndTime(date)));
 
             // 2. 查询门店当日充值退款记录
             List<OrderRechargeRefund> refundList = orderRechargeRefundService.list(new QueryWrapper<OrderRechargeRefund>().lambda()
-                    .eq(OrderRechargeRefund::getStoreId, storeId)
+                    .eq(storeId != null, OrderRechargeRefund::getStoreId, storeId)
                     .eq(OrderRechargeRefund::getRefundStatus, RechargeRefundStatusType.REFUND_AGREE.getCode())
                     .eq(OrderRechargeRefund::getDelFlag, StatusType.OK.getCode())
                     .between(OrderRechargeRefund::getRefundTime, DateUtils.getStartTime(date), DateUtils.getEndTime(date)));
@@ -218,14 +291,14 @@ public class SettlementStoreStatisticsServiceImpl extends ServiceImpl<Settlement
         try {
             // 1. 查询门店当日充值记录
             List<OrderRecharge> rechargeList = orderRechargeService.list(new QueryWrapper<OrderRecharge>().lambda()
-                    .eq(OrderRecharge::getStoreId, storeId)
+                    .eq(storeId != 0L, OrderRecharge::getStoreId, storeId)
                     .eq(OrderRecharge::getPayStatus, PayStatus.HAS_PAY.getCode())
                     .eq(OrderRecharge::getDelFlag, StatusType.OK.getCode())
                     .between(OrderRecharge::getPayTime, startDate, endDate));
 
             // 2. 查询门店当日充值退款记录
             List<OrderRechargeRefund> refundList = orderRechargeRefundService.list(new QueryWrapper<OrderRechargeRefund>().lambda()
-                    .eq(OrderRechargeRefund::getStoreId, storeId)
+                    .eq(storeId != 0L, OrderRechargeRefund::getStoreId, storeId)
                     .eq(OrderRechargeRefund::getRefundStatus, RechargeRefundStatusType.REFUND_AGREE.getCode())
                     .eq(OrderRechargeRefund::getDelFlag, StatusType.OK.getCode())
                     .between(OrderRechargeRefund::getRefundTime, startDate, endDate));

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

@@ -626,7 +626,7 @@ public class OrderClothServiceImpl extends ServiceImpl<OrderClothMapper, OrderCl
         //会员余额支付
         if (orderClothPayDTO.getPayType().equals(PayType.BALANCE.getCode())) {
             orderCloth.setPayType(PayType.BALANCE.getCode());
-            RechargeCardPayDTO rechargeCardPayDTO = new RechargeCardPayDTO(orderCloth.getAppUserId(), orderCloth.getOrgId(), orderCloth.getOrderNo(), orderCloth.getPayAmount(), OrderType.cloth.getCode());
+            RechargeCardPayDTO rechargeCardPayDTO = new RechargeCardPayDTO(orderCloth.getAppUserId(), orderCloth.getSourceType(), orderCloth.getOrgId(), orderCloth.getOrderNo(), orderCloth.getPayAmount(), OrderType.cloth.getCode());
             rechargePasswordCardService.orderPayByBalance(rechargeCardPayDTO);
             paySuccess(orderCloth);
             return OrderPayResultVO.paySuccess(orderCloth.getOrderNo());

+ 1 - 1
yiqi-core/src/main/java/com/yiqi/order/service/impl/OrderGoodsServiceImpl.java

@@ -302,7 +302,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
         }
         //会员余额支付
         if (orderGoods.getPayType().equals(PayType.BALANCE.getCode())) {
-            RechargeCardPayDTO rechargeCardPayDTO = new RechargeCardPayDTO(orderGoods.getAppUserId(), orderGoods.getOrgId(), orderGoods.getOrderNo(), orderGoods.getPayAmount(), OrderType.goods.getCode());
+            RechargeCardPayDTO rechargeCardPayDTO = new RechargeCardPayDTO(orderGoods.getAppUserId(), orderGoods.getSourceType(), orderGoods.getOrgId(), orderGoods.getOrderNo(), orderGoods.getPayAmount(), OrderType.goods.getCode());
             rechargePasswordCardService.orderPayByBalance(rechargeCardPayDTO);
             this.handlePaySuccessUpdateOrderStatus(orderGoods.getOrderNo(), null);
             orderPayResultVO = OrderPayResultVO.paySuccess(orderGoods.getOrderNo());

+ 6 - 3
yiqi-core/src/main/java/com/yiqi/order/service/impl/OrderRechargeServiceImpl.java

@@ -705,7 +705,8 @@ public class OrderRechargeServiceImpl extends ServiceImpl<OrderRechargeMapper, O
 
         // 设置账单基本信息
         billDTO.setAppUserId(order.getAppUserId());
-        billDTO.setStoreId(order.getStoreId());
+        billDTO.setOrgId(order.getStoreId());
+        billDTO.setSourceType(order.getOrderSource());
         billDTO.setOrderNo(order.getOrderNo());
         billDTO.setOrderType(OrderType.recharge.getCode());
         billDTO.setUseBindStoreId(card.getUseBindStoreId());
@@ -779,7 +780,8 @@ public class OrderRechargeServiceImpl extends ServiceImpl<OrderRechargeMapper, O
     private void saveBillMstrOrder(OrderRecharge orderRecharge, RechargePasswordCard rechargePasswordCard, Date date) {
         BillMstrOrderDTO billMstrOrderDTO = new BillMstrOrderDTO();
         billMstrOrderDTO.setAppUserId(orderRecharge.getAppUserId());
-        billMstrOrderDTO.setStoreId(orderRecharge.getStoreId());
+        billMstrOrderDTO.setSourceType(orderRecharge.getSourceType());
+        billMstrOrderDTO.setOrgId(orderRecharge.getStoreId());
         billMstrOrderDTO.setOrderNo(orderRecharge.getOrderNo());
         billMstrOrderDTO.setOrderType(OrderType.recharge.getCode());
         billMstrOrderDTO.setRechargePayAmount(orderRecharge.getRechargeAmount());
@@ -1278,7 +1280,8 @@ public class OrderRechargeServiceImpl extends ServiceImpl<OrderRechargeMapper, O
 
         BillMstrOrderDTO billMstrOrderDTO = new BillMstrOrderDTO();
         billMstrOrderDTO.setAppUserId(orderRecharge.getAppUserId());
-        billMstrOrderDTO.setStoreId(orderRecharge.getStoreId());
+        billMstrOrderDTO.setOrgId(orderRecharge.getStoreId());
+        billMstrOrderDTO.setSourceType(orderRecharge.getSourceType());
         billMstrOrderDTO.setOrderNo(orderRecharge.getOrderNo());
         billMstrOrderDTO.setOrderType(OrderType.recharge.getCode());
         billMstrOrderDTO.setRechargePayAmount(orderRecharge.getRechargeAmount());

+ 4 - 5
yiqi-core/src/main/java/com/yiqi/recharge/service/impl/RechargePasswordCardServiceImpl.java

@@ -1,12 +1,9 @@
 package com.yiqi.recharge.service.impl;
 
-import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.yiqi.common.exception.ServiceException;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.yiqi.app.domain.AppUser;
@@ -631,7 +628,8 @@ public class RechargePasswordCardServiceImpl extends ServiceImpl<RechargePasswor
             //保存日志
             BillMstrOrderDTO billMstrOrderDTO = new BillMstrOrderDTO();
             billMstrOrderDTO.setAppUserId(rechargeCardPayDTO.getAppUserId());
-            billMstrOrderDTO.setStoreId(rechargeCardPayDTO.getStoreId());
+            billMstrOrderDTO.setOrgId(rechargeCardPayDTO.getOrgId());
+            billMstrOrderDTO.setSourceType(rechargeCardPayDTO.getSourceType());
             billMstrOrderDTO.setUseBindStoreId(rechargePasswordCard.getUseBindStoreId());
             billMstrOrderDTO.setOrderNo(rechargeCardPayDTO.getOrderNo());
             billMstrOrderDTO.setOrderType(rechargeCardPayDTO.getBuyGoodsType());
@@ -704,7 +702,8 @@ public class RechargePasswordCardServiceImpl extends ServiceImpl<RechargePasswor
 
             BillMstrOrderDTO billMstrOrderDTO = new BillMstrOrderDTO();
             BeanUtils.copyProperties(consumeBillMstr, billMstrOrderDTO);
-            billMstrOrderDTO.setStoreId(consumeBillMstr.getOrgId());
+            billMstrOrderDTO.setOrgId(consumeBillMstr.getOrgId());
+            billMstrOrderDTO.setSourceType(consumeBillMstr.getSourceType());
             billMstrOrderDTO.setUseBindStoreId(rechargePasswordCard.getUseBindStoreId());
             billMstrOrderDTO.setRechargeCardNo(rechargePasswordCard.getCardNo());
             billMstrOrderDTO.setRemark("充值卡:" + rechargePasswordCard.getCardNo() + ",退款" + consumeBillMstr.getPayTotalAmount().negate() + "元");

+ 140 - 45
yiqi-core/src/main/resources/mapper/core/SettlementStoreStatisticsMapper.xml

@@ -205,51 +205,6 @@
         </foreach>
     </delete>
 
-    <select id="orderTotal" resultType="com.yiqi.core.domain.SettlementStoreStatistics">
-    select 
-        sum(cloth_order_amount) as clothOrderAmount,
-        sum(cloth_appoint_count) as clothAppointCount,
-        sum(cloth_receive_amount) as clothReceiveAmount,
-        sum(cloth_refund_amount) as clothRefundAmount,
-        sum(cloth_order_count) as clothOrderCount,
-        sum(cloth_count) as clothCount,
-        sum(cloth_alipay_amount) as clothAlipayAmount,
-        sum(cloth_wechat_amount) as clothWechatAmount,
-        sum(cloth_cash_amount) as clothCashAmount,
-        sum(cloth_union_amount) as clothUnionAmount,
-        sum(cloth_member_amount) as clothMemberAmount,
-        sum(cloth_alipay_refund_amount) as clothAlipayRefundAmount,
-        sum(cloth_wechat_refund_amount) as clothWechatRefundAmount,
-        sum(cloth_cash_refund_amount) as clothCashRefundAmount,
-        sum(cloth_union_refund_amount) as clothUnionRefundAmount,
-        sum(cloth_member_refund_amount) as clothMemberRefundAmount,
-        sum(goods_order_amount) as goodsOrderAmount,
-        sum(goods_receive_amount) as goodsReceiveAmount,
-        sum(goods_refund_amount) as goodsRefundAmount,
-        sum(goods_order_count) as goodsOrderCount,
-        sum(goods_count) as goodsCount,
-        sum(goods_alipay_amount) as goodsAlipayAmount,
-        sum(goods_wechat_amount) as goodsWechatAmount,
-        sum(goods_cash_amount) as goodsCashAmount,
-        sum(goods_union_amount) as goodsUnionAmount,
-        sum(goods_member_amount) as goodsMemberAmount,
-        sum(goods_order_refund_amount) as goodsOrderRefundAmount,
-        sum(goods_alipay_refund_amount) as goodsAlipayRefundAmount,
-        sum(goods_wechat_refund_amount) as goodsWechatRefundAmount,
-        sum(goods_cash_refund_amount) as goodsCashRefundAmount,
-        sum(goods_union_refund_amount) as goodsUnionRefundAmount,
-        sum(goods_member_refund_amount) as goodsMemberRefundAmount
-    from settlement_store_statistics
-    <where>
-        <if test="storeId != null">
-            and store_id = #{storeId}
-        </if>
-        <if test="day != null">
-            and day = #{day}
-        </if>
-    </where>
-    </select>
-
     <select id="chargeTotal" resultType="com.yiqi.settlement.domain.dto.StoreChargeStatistics">
         SELECT
             COALESCE(recharge.rechargeCount, 0) AS rechargeCount,
@@ -294,5 +249,145 @@
         ) refund;
     </select>
 
+    <select id="totalByDate" resultType="com.yiqi.core.domain.SettlementStoreStatistics">
+        select
+            day,
+            sum(cloth_order_amount) as clothOrderAmount,
+            sum(cloth_appoint_count) as clothAppointCount,
+            sum(cloth_receive_amount) as clothReceiveAmount,
+            sum(cloth_refund_amount) as clothRefundAmount,
+            sum(cloth_order_count) as clothOrderCount,
+            sum(cloth_count) as clothCount,
+            sum(cloth_alipay_amount) as clothAlipayAmount,
+            sum(cloth_wechat_amount) as clothWechatAmount,
+            sum(cloth_cash_amount) as clothCashAmount,
+            sum(cloth_union_amount) as clothUnionAmount,
+            sum(cloth_member_amount) as clothMemberAmount,
+            sum(cloth_alipay_refund_amount) as clothAlipayRefundAmount,
+            sum(cloth_wechat_refund_amount) as clothWechatRefundAmount,
+            sum(cloth_cash_refund_amount) as clothCashRefundAmount,
+            sum(cloth_union_refund_amount) as clothUnionRefundAmount,
+            sum(cloth_member_refund_amount) as clothMemberRefundAmount,
+            sum(goods_order_amount) as goodsOrderAmount,
+            sum(goods_receive_amount) as goodsReceiveAmount,
+            sum(goods_refund_amount) as goodsRefundAmount,
+            sum(goods_order_count) as goodsOrderCount,
+            sum(goods_count) as goodsCount,
+            sum(goods_alipay_amount) as goodsAlipayAmount,
+            sum(goods_wechat_amount) as goodsWechatAmount,
+            sum(goods_cash_amount) as goodsCashAmount,
+            sum(goods_union_amount) as goodsUnionAmount,
+            sum(goods_member_amount) as goodsMemberAmount,
+            sum(goods_order_refund_amount) as goodsOrderRefundAmount,
+            sum(goods_alipay_refund_amount) as goodsAlipayRefundAmount,
+            sum(goods_wechat_refund_amount) as goodsWechatRefundAmount,
+            sum(goods_cash_refund_amount) as goodsCashRefundAmount,
+            sum(goods_union_refund_amount) as goodsUnionRefundAmount,
+            sum(goods_member_refund_amount) as goodsMemberRefundAmount,
+
+            sum(charge_refund_arrive_amount) as chargeRefundArriveAmount,
+            sum(charge_refund_amount) as chargeRefundAmount,
+            sum(charge_arrive_amount) as chargeArriveAmount,
+            sum(charge_amount) as chargeAmount,
+            sum(charge_refund_count) as chargeRefundCount,
+            sum(charge_count) as chargeCount
+        from settlement_store_statistics where day >= #{startDay} and day &lt;= #{endDay} group by day order by day asc
+    </select>
+    <select id="totalByStore" resultType="com.yiqi.core.domain.SettlementStoreStatistics">
+        select
+            store_id as storeId,
+            sum(cloth_order_amount) as clothOrderAmount,
+            sum(cloth_appoint_count) as clothAppointCount,
+            sum(cloth_receive_amount) as clothReceiveAmount,
+            sum(cloth_refund_amount) as clothRefundAmount,
+            sum(cloth_order_count) as clothOrderCount,
+            sum(cloth_count) as clothCount,
+            sum(cloth_alipay_amount) as clothAlipayAmount,
+            sum(cloth_wechat_amount) as clothWechatAmount,
+            sum(cloth_cash_amount) as clothCashAmount,
+            sum(cloth_union_amount) as clothUnionAmount,
+            sum(cloth_member_amount) as clothMemberAmount,
+            sum(cloth_alipay_refund_amount) as clothAlipayRefundAmount,
+            sum(cloth_wechat_refund_amount) as clothWechatRefundAmount,
+            sum(cloth_cash_refund_amount) as clothCashRefundAmount,
+            sum(cloth_union_refund_amount) as clothUnionRefundAmount,
+            sum(cloth_member_refund_amount) as clothMemberRefundAmount,
+            sum(goods_order_amount) as goodsOrderAmount,
+            sum(goods_receive_amount) as goodsReceiveAmount,
+            sum(goods_refund_amount) as goodsRefundAmount,
+            sum(goods_order_count) as goodsOrderCount,
+            sum(goods_count) as goodsCount,
+            sum(goods_alipay_amount) as goodsAlipayAmount,
+            sum(goods_wechat_amount) as goodsWechatAmount,
+            sum(goods_cash_amount) as goodsCashAmount,
+            sum(goods_union_amount) as goodsUnionAmount,
+            sum(goods_member_amount) as goodsMemberAmount,
+            sum(goods_order_refund_amount) as goodsOrderRefundAmount,
+            sum(goods_alipay_refund_amount) as goodsAlipayRefundAmount,
+            sum(goods_wechat_refund_amount) as goodsWechatRefundAmount,
+            sum(goods_cash_refund_amount) as goodsCashRefundAmount,
+            sum(goods_union_refund_amount) as goodsUnionRefundAmount,
+            sum(goods_member_refund_amount) as goodsMemberRefundAmount,
+
+            sum(charge_refund_arrive_amount) as chargeRefundArriveAmount,
+            sum(charge_refund_amount) as chargeRefundAmount,
+            sum(charge_arrive_amount) as chargeArriveAmount,
+            sum(charge_amount) as chargeAmount,
+            sum(charge_refund_count) as chargeRefundCount,
+            sum(charge_count) as chargeCount
+        from settlement_store_statistics where day >= #{startDay} and day &lt;= #{endDay} and store_id !=0 group by store_id order by clothOrderAmount desc
+    </select>
+    <select id="orderStatistics" resultType="com.yiqi.core.domain.SettlementStoreStatistics">
+        select
+            sum(cloth_order_amount) as clothOrderAmount,
+            sum(cloth_appoint_count) as clothAppointCount,
+            sum(cloth_receive_amount) as clothReceiveAmount,
+            sum(cloth_refund_amount) as clothRefundAmount,
+            sum(cloth_order_count) as clothOrderCount,
+            sum(cloth_count) as clothCount,
+            sum(cloth_alipay_amount) as clothAlipayAmount,
+            sum(cloth_wechat_amount) as clothWechatAmount,
+            sum(cloth_cash_amount) as clothCashAmount,
+            sum(cloth_union_amount) as clothUnionAmount,
+            sum(cloth_member_amount) as clothMemberAmount,
+            sum(cloth_alipay_refund_amount) as clothAlipayRefundAmount,
+            sum(cloth_wechat_refund_amount) as clothWechatRefundAmount,
+            sum(cloth_cash_refund_amount) as clothCashRefundAmount,
+            sum(cloth_union_refund_amount) as clothUnionRefundAmount,
+            sum(cloth_member_refund_amount) as clothMemberRefundAmount,
+            sum(goods_order_amount) as goodsOrderAmount,
+            sum(goods_receive_amount) as goodsReceiveAmount,
+            sum(goods_refund_amount) as goodsRefundAmount,
+            sum(goods_order_count) as goodsOrderCount,
+            sum(goods_count) as goodsCount,
+            sum(goods_alipay_amount) as goodsAlipayAmount,
+            sum(goods_wechat_amount) as goodsWechatAmount,
+            sum(goods_cash_amount) as goodsCashAmount,
+            sum(goods_union_amount) as goodsUnionAmount,
+            sum(goods_member_amount) as goodsMemberAmount,
+            sum(goods_order_refund_amount) as goodsOrderRefundAmount,
+            sum(goods_alipay_refund_amount) as goodsAlipayRefundAmount,
+            sum(goods_wechat_refund_amount) as goodsWechatRefundAmount,
+            sum(goods_cash_refund_amount) as goodsCashRefundAmount,
+            sum(goods_union_refund_amount) as goodsUnionRefundAmount,
+            sum(goods_member_refund_amount) as goodsMemberRefundAmount,
+        sum(charge_refund_arrive_amount) as chargeRefundArriveAmount,
+        sum(charge_refund_amount) as chargeRefundAmount,
+        sum(charge_arrive_amount) as chargeArriveAmount,
+        sum(charge_amount) as chargeAmount,
+        sum(charge_refund_count) as chargeRefundCount,
+        sum(charge_count) as chargeCount
+        from settlement_store_statistics where 1 = 1
+        <if test="startDay!=null">
+            and  day >= #{startDay}
+        </if>
+        <if test="endDay!=null">
+             and day &lt;= #{endDay}
+        </if>
+        <if test="storeId != null and storeId != 0">
+            and store_id = #{storeId}
+        </if>
+    </select>
+
 
 </mapper>

+ 2 - 6
yiqi-core/src/main/resources/mapper/order/OrderClothItemMapper.xml

@@ -516,8 +516,8 @@
     </select>
     <select id="listFinancialStatisticsByFactoryWithToday"
             resultType="com.yiqi.order.domain.vo.FactoryFinancialClothDayVO">
-        select oci.org_id as orgId, ss.name as storeName , sum(oci.total_price) as totalPrice, count(1) as countCloth ,
-               sum(oci.factory_settlement_amount) as totalStatementPrice , oci.factory_settlement_rate as statementRate
+        select oci.org_id as orgId, ss.name as storeName , sum(oci.total_price) as totalPrice, count(1) as countCloth
+
         from order_cloth_item oci
         left join sys_store ss on oci.org_id = ss.id
         where  oci.factory_id = #{factoryId} and oci.flow_status != '102' and oci.source_type = '02' and oci.in_factory_time is not null
@@ -536,8 +536,6 @@
             resultType="com.yiqi.order.domain.vo.FactoryStatisticsListQueryVO">
         select oci.org_id as orgId, ss.name as storeName ,
                sum(oci.total_price) as totalPrice,
-                sum(oci.factory_settlement_amount) as totalStatementPrice ,
-                oci.factory_settlement_rate as statementRate,
                count(oci.wash_code) as countTotalCloth,
                count(ocif.wash_code) as countFinishCloth,
                count(ociw.wash_code) as countWashCloth,
@@ -566,8 +564,6 @@
                oci.cloth_item_name AS clothItemName, oci.cloth_speed_name as clothSpeedName ,
                oci.flow_status as flowStatus, oci.in_factory_time as inFactoryTime,
                oci.total_price as totalPrice ,
-                sum(oci.factory_settlement_amount) as totalStatementPrice ,
-                oci.factory_settlement_rate as statementRate,
                GROUP_CONCAT(occ.cloth_color_name) as clothColorName
         from order_cloth_item oci
                  LEFT JOIN order_cloth_color occ on oci.order_id = occ.order_id and oci.id = occ.order_cloth_id