Forráskód Böngészése

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

lhch2015 3 hete
szülő
commit
eb220ec6ef
24 módosított fájl, 653 hozzáadás és 183 törlés
  1. 3 3
      admin-ui/.env.development
  2. 25 19
      admin-ui/src/utils/index.js
  3. 1 1
      admin-ui/src/views/order/cloth/orderList.vue
  4. 65 21
      admin-ui/src/views/order/statistics/bystore.vue
  5. 5 0
      admin-ui/src/views/settlement/bill/factorySettlement.vue
  6. 2 2
      admin-ui/src/views/settlement/bill/index.vue
  7. 42 9
      admin-ui/src/views/settlement/bill/storeSettlement.vue
  8. 11 9
      admin-ui/src/views/settlement/rate/factoryRate.vue
  9. 4 4
      admin-ui/src/views/settlement/rate/storeRate.vue
  10. 0 9
      yiqi-admin/src/main/java/com/yiqi/admin/controller/core/SettlementManageBillController.java
  11. 75 2
      yiqi-admin/src/main/java/com/yiqi/admin/controller/order/OrderClothController.java
  12. 30 4
      yiqi-admin/src/main/java/com/yiqi/admin/controller/settlement/SettlementStoreStatisticsController.java
  13. 5 3
      yiqi-admin/src/main/java/com/yiqi/task/SettlementTask.java
  14. 192 69
      yiqi-common/src/main/java/com/yiqi/core/domain/SettlementManageStore.java
  15. 2 0
      yiqi-common/src/main/java/com/yiqi/core/service/ISettlementManageBillService.java
  16. 1 1
      yiqi-common/src/main/java/com/yiqi/core/service/ISettlementStoreStatisticsService.java
  17. 11 1
      yiqi-common/src/main/java/com/yiqi/order/domain/OrderRefundInfo.java
  18. 10 0
      yiqi-core/src/main/java/com/yiqi/core/mapper/SettlementManageStoreMapper.java
  19. 10 0
      yiqi-core/src/main/java/com/yiqi/core/mapper/SettlementStoreStatisticsMapper.java
  20. 95 19
      yiqi-core/src/main/java/com/yiqi/core/service/impl/SettlementManageBillServiceImpl.java
  21. 4 4
      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/OrderGoodsServiceImpl.java
  23. 11 2
      yiqi-core/src/main/resources/mapper/core/SettlementManageStoreMapper.xml
  24. 48 0
      yiqi-core/src/main/resources/mapper/core/SettlementStoreStatisticsMapper.xml

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

@@ -5,14 +5,14 @@ VUE_APP_TITLE = 一七管理系统
 ENV = 'development'
 
 
-# VUE_APP_BASE_API_HOST = 'http://192.168.5.176:9801'
-# VUE_APP_BASE_API = 'http://192.168.5.176:9801'
+# 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_CLI_BABEL_TRANSPILE_MODULES = true
 

+ 25 - 19
admin-ui/src/utils/index.js

@@ -473,7 +473,7 @@ export function exchangeClothPrinter(LODOP, data, lodopName) {
   LODOP.ADD_PRINT_TEXT(200, 10, 300, 20, `支付方式:${payType}`);
   LODOP.ADD_PRINT_TEXT(220, 10, 300, 20, `订单备注:${data.remark?data.remark:''}`);
   LODOP.ADD_PRINT_LINE(240, 10, 240, 295, 1, 1);
-  LODOP.ADD_PRINT_TEXT(250, 10, 300, 20, `会员额:${data.memberBeforeBalance || 0}`);
+  LODOP.ADD_PRINT_TEXT(250, 10, 300, 20, `会员额:${data.memberBeforeBalance || 0}`);
   LODOP.ADD_PRINT_TEXT(270, 10, 300, 20, `本次充值:${data.memberChangeAmount || 0}元`);
   LODOP.ADD_PRINT_TEXT(290, 10, 300, 20, `会员余额:${(data.memberAfterBalance || 0)}元`);
   LODOP.ADD_PRINT_LINE(310, 10, 310, 295, 1, 1);
@@ -555,6 +555,12 @@ export function collectClothPrinter(LODOP, data, lodopName) {
   LODOP.ADD_PRINT_TEXT(height + 15, 160, 150, 20, `总金额:${data.orderAmount}元`);
 
   LODOP.ADD_PRINT_LINE(height + 35, 10, height + 35, 295, 1, 1);
+  LODOP.ADD_PRINT_TEXT(height + 45, 10, 150, 20, `优惠金额:${(data.activityDiscountAmount || 0) + (data.cashDeductAmount || 0) + (data.couponDeductAmount || 0)}元`);
+  LODOP.ADD_PRINT_TEXT(height + 45, 160, 150, 20, `实付金额:${(data.payAmount || 0)}元`);
+  LODOP.ADD_PRINT_TEXT(height + 65, 10, 150, 20, `优惠券:${(data.couponDeductAmount || 0)}元`);
+  LODOP.ADD_PRINT_TEXT(height + 65, 160, 150, 20, `折扣活动:${(data.activityDiscountAmount || 0)}元`);
+  LODOP.ADD_PRINT_TEXT(height + 85, 10, 150, 20, `现金券:${data.cashDeductAmount || 0}元`);
+  LODOP.ADD_PRINT_LINE(height + 105, 10, height + 105, 295, 1, 1);
 
   //金额
   let payTypename = '';
@@ -572,36 +578,36 @@ export function collectClothPrinter(LODOP, data, lodopName) {
 
 
 
-  LODOP.ADD_PRINT_TEXT(height + 45, 10, 150, 20, `付款方式:${payTypename}`);
-  LODOP.ADD_PRINT_TEXT(height + 45, 160, 150, 20, `会员金额:${data.memberBeforeBalance?data.memberBeforeBalance+'元':''}`);
-  LODOP.ADD_PRINT_TEXT(height + 75, 10, 150, 20, `本次扣款:${data.memberChangeAmount?data.memberChangeAmount+'元':'0'}`);
-  LODOP.ADD_PRINT_TEXT(height + 75, 160, 150, 20, `会员余额:${data.memberBeforeBalance?data.memberBeforeBalance +'元':''}`);
+  LODOP.ADD_PRINT_TEXT(height + 115, 10, 150, 20, `付款方式:${payTypename}`);
+  LODOP.ADD_PRINT_TEXT(height + 115, 160, 150, 20, `会员金额:${data.memberBeforeBalance?data.memberBeforeBalance+'元':''}`);
+  LODOP.ADD_PRINT_TEXT(height + 135, 10, 150, 20, `本次扣款:${data.memberChangeAmount?data.memberChangeAmount+'元':'0'}`);
+  LODOP.ADD_PRINT_TEXT(height + 135, 160, 150, 20, `会员余额:${data.memberBeforeBalance?data.memberBeforeBalance +'元':''}`);
 
-  LODOP.ADD_PRINT_TEXT(height + 105, 10, 150, 20, `客户:${data.appUserInfoVO.contactName}`);
-  LODOP.ADD_PRINT_TEXT(height + 105, 160, 180, 20, `客户电话:${data.appUserInfoVO.contactPhone}`);
+  LODOP.ADD_PRINT_TEXT(height + 155, 10, 150, 20, `客户:${data.appUserInfoVO.contactName}`);
+  LODOP.ADD_PRINT_TEXT(height + 155, 160, 180, 20, `客户电话:${data.appUserInfoVO.contactPhone}`);
   let address = `客户地址:${data.appUserInfoVO.province || ''}${ data.appUserInfoVO.city|| ''}${ data.appUserInfoVO.area|| ''}${ data.appUserInfoVO.address|| ''}${ data.appUserInfoVO.addressDetail|| ''}`
-  LODOP.ADD_PRINT_TEXT(height + 135, 10, 300, 20, address);
+  LODOP.ADD_PRINT_TEXT(height + 175, 10, 300, 20, address);
   var userHeight = addDynamicText(90, address)
   height += userHeight
 
-  LODOP.ADD_PRINT_LINE(height + 140, 10, height + 140, 295, 1, 1);
+  LODOP.ADD_PRINT_LINE(height + 180, 10, height + 180, 295, 1, 1);
   console.log(data.sysOrg)
-  LODOP.ADD_PRINT_TEXT(height + 150, 10, 300, 20, `本店地址:${data.sysOrg.address || ''}`);
+  LODOP.ADD_PRINT_TEXT(height + 190, 10, 300, 20, `本店地址:${data.sysOrg.address || ''}`);
   var sysHeight = addDynamicText(90, `本店地址:${data.sysOrg.address || ''}`)
   height += sysHeight
-  LODOP.ADD_PRINT_TEXT(height + 160, 10, 300, 20, `联系电话:${data.sysOrg.contactPhone}`);
+  LODOP.ADD_PRINT_TEXT(height + 200, 10, 300, 20, `联系电话:${data.sysOrg.contactPhone}`);
 
   // LODOP.ADD_PRINT_TEXT(height + 210, 10, 180, 20, `营业时间:${data.sysOrg.businessStartTime?data.sysOrg.businessStartTime:''}-${data.sysOrg.businessEndTime?data.sysOrg.businessEndTime:''}`);
   // LODOP.ADD_PRINT_TEXT(height + 210, 200, 120, 20, `员工:${data.createBy?data.createBy:''}`);
 
-  LODOP.ADD_PRINT_LINE(height + 185, 10, height + 185, 295, 1, 1);
-  LODOP.ADD_PRINT_TEXT(height + 195, 10, 300, 20, `订单备注:${data.remark?data.remark:''}`);
+  LODOP.ADD_PRINT_LINE(height + 220, 10, height + 220, 295, 1, 1);
+  LODOP.ADD_PRINT_TEXT(height + 230, 10, 300, 20, `订单备注:${data.remark?data.remark:''}`);
   var remarkHeight = addDynamicText(90, `订单备注:${data.remark?data.remark:''}`)
   height += remarkHeight
-  LODOP.ADD_PRINT_TEXT(height + 210, 10, 300, 50, `客户签名:`);
-  LODOP.ADD_PRINT_LINE(height + 250, 10, height + 250, 295, 1, 1);
-  LODOP.ADD_PRINT_TEXT(height + 260, 50, 300, 20, `请仔细阅读店内张贴的取衣凭证注意事项`);
-  LODOP.ADD_PRINT_LINE(height + 280, 10, height + 280, 295, 1, 1);
+  LODOP.ADD_PRINT_TEXT(height + 250, 10, 300, 50, `客户签名:`);
+  LODOP.ADD_PRINT_LINE(height + 290, 10, height + 290, 295, 1, 1);
+  LODOP.ADD_PRINT_TEXT(height + 300, 50, 300, 20, `请仔细阅读店内张贴的取衣凭证注意事项`);
+  LODOP.ADD_PRINT_LINE(height + 320, 10, height + 320, 295, 1, 1);
   if (this.LODOP.SET_PRINTER_INDEXA(lodopName))
 
   // this.LODOP.PREVIEW(); //打印预览
@@ -777,12 +783,12 @@ export function barCodePrinter(LODOP, data, lodopName){
     let _flaws = ''
     let n = 0
     item.orderClothFlaws.forEach(item_n=>{
-      if (n < 10) {
+      if (n < 5) {
         _flaws += item_n.clothFlawName+';'
       } 
       n++
     })
-    if (n >= 10) {
+    if (n >= 5) {
       _flaws += '...'
     }
     let junInfo = ''

+ 1 - 1
admin-ui/src/views/order/cloth/orderList.vue

@@ -150,7 +150,7 @@
         <el-table-column label="操作" align="center" min-width="240" fixed="right">
           <template slot-scope="scope">
             <el-button type="text" icon="el-icon-s-order" size="mini" @click="handleDetail(scope.row)"> 订单详情 </el-button>
-            <el-button type="text" icon="el-icon-printer" size="mini" @click="btn_lodop(scope.row)" v-if="userInfoVO.userType != '00'"> 打印订单 </el-button>
+            <el-button type="text" icon="el-icon-printer" size="mini" @click="btn_lodop(scope.row)" v-if="userInfoVO.userType != '00' && scope.row.orderAmount"> 打印订单 </el-button>
             <el-button type="text" icon="el-icon-close" size="mini" @click="handleClose(scope.row)" v-if="scope.row.refundStatus == '0' && (scope.row.orderStatus == '0' || scope.row.orderStatus == '1' || scope.row.orderStatus == '2'  || scope.row.orderStatus == '5' )"> 撤销 </el-button>
           </template>
         </el-table-column>

+ 65 - 21
admin-ui/src/views/order/statistics/bystore.vue

@@ -4,10 +4,14 @@
       <el-form-item label="统计日期" prop="dateRange">
         <el-date-picker
           v-model="dateRange"
-          type="date"
-          placeholder="统计日期"
+          type="daterange"
+          range-separator="至"
+          start-placeholder="开始日期"
+          end-placeholder="结束日期"
           value-format="yyyy-MM-dd"
-        />
+          :picker-options="pickerOptions"
+          @change="handleDateRangeChange">
+        </el-date-picker>
       </el-form-item>
       <el-form-item>
         <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
@@ -31,11 +35,11 @@
 
     <el-table v-loading="loading" :data="statisticsList" border>
       <!-- 基本信息 -->
-      <el-table-column label="统计日期" align="center" prop="day" width="100">
+      <!-- <el-table-column label="统计日期" align="center" prop="day" width="100">1
         <template slot-scope="scope">
           {{ parseDay(scope.row.day) }}
         </template>
-      </el-table-column>
+      </el-table-column> -->
 
       <el-table-column label="统计门店" align="center" prop="day" width="100">
         <template slot-scope="scope">
@@ -103,8 +107,6 @@
           <el-table-column label="会员卡退款" align="center" prop="goodsMemberRefundAmount" width="100" />
         </el-table-column>
       </el-table-column>
-
-
     </el-table>
 
     <pagination
@@ -141,27 +143,71 @@ export default {
         pageSize: 10,
         startDate: undefined,
         endDate: undefined
+      },
+      pickerOptions: {
+        shortcuts: [{
+          text: '最近一周',
+          onClick(picker) {
+            const end = new Date();
+            const start = new Date();
+            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
+            picker.$emit('pick', [start, end]);
+          }
+        }, {
+          text: '最近半个月',
+          onClick(picker) {
+            const end = new Date();
+            const start = new Date();
+            start.setTime(start.getTime() - 3600 * 1000 * 24 * 15);
+            picker.$emit('pick', [start, end]);
+          }
+        }, {
+          text: '最近一个月',
+          onClick(picker) {
+            const end = new Date();
+            const start = new Date();
+            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
+            picker.$emit('pick', [start, end]);
+          }
+        }]
       }
     };
   },
   created() {
     // 设置默认日期范围为最近14天
+    // 设置默认日期范围为最近半个月
     const end = new Date();
     const start = new Date();
-    start.setTime(start.getTime());
-    this.dateRange = this.parseTime(start, '{y}-{m}-{d}');
+    start.setTime(start.getTime() - 3600 * 1000 * 24 * 15);
+    this.dateRange = [this.formatDate(start), this.formatDate(end)];
+    this.queryParams.startDate = this.dateRange[0];
+    this.queryParams.endDate = this.dateRange[1];
     this.userInfoVO = this.getUserInfo()
     this.getList();
   },
   methods: {
+    // 日期选择器配置
+      
+        /** 格式化日期为 yyyy-MM-dd */
+    formatDate(date) {
+      const year = date.getFullYear();
+      const month = String(date.getMonth() + 1).padStart(2, '0');
+      const day = String(date.getDate()).padStart(2, '0');
+      return `${year}-${month}-${day}`;
+    },
+        /** 日期范围变化处理 */
+    handleDateRangeChange(val) {
+      if (val) {
+        this.queryParams.startDate = val[0];
+        this.queryParams.endDate = val[1];
+      } else {
+        this.queryParams.startDate = null;
+        this.queryParams.endDate = null;
+      }
+    },
     /** 查询统计列表 */
     getList() {
       this.loading = true;
-      if (this.dateRange) {
-        this.queryParams.startDate = this.dateRange;
-      } else {
-        this.queryParams.startDate = undefined;
-      }
       listStatisticsByStore(this.queryParams).then(response => {
         this.statisticsList = response.rows;
         this.total = response.total;
@@ -184,19 +230,17 @@ export default {
         this.getList();
       });
     },
+    
     /** 导出按钮操作 */
     handleExport() {
-      const queryParams = { ...this.queryParams };
-      if (this.dateRange && this.dateRange.length > 0) {
-        queryParams.startDate = this.dateRange[0];
-        queryParams.endDate = this.dateRange[1];
-      }
-      this.$confirm('是否确认导出所有统计数据项?', "警告", {
+      this.$confirm('是否确认导出所有日期统计数据项?', "警告", {
         confirmButtonText: "确定",
         cancelButtonText: "取消",
         type: "warning"
       }).then(() => {
-        this.$download('/mapi/settlement/store/statistics/export', queryParams);
+        this.download('/mapi/settlement/store/statistics/list/bystore/export', {
+          ...this.queryParams
+        }, `门店日期报表统计_${new Date().getTime()}.xlsx`);
       });
     },
     // 解析日期显示

+ 5 - 0
admin-ui/src/views/settlement/bill/factorySettlement.vue

@@ -34,6 +34,11 @@
             <el-table-column label="材料费(元)" align="center" prop="materialAmount" width="100px" />
             <el-table-column label="管理费(元)" align="center" prop="manageAmount" width="100px" />
             <el-table-column label="实际收入(元)" align="center" prop="realIncomeAmount" width="120px" />
+            <el-table-column label="备注" align="center" prop="remark" width="120px" >
+                <template slot-scope="scope">
+                    {{ scope.row.remark || "--" }}
+                </template>
+                </el-table-column>
             <el-table-column label="状态" align="center" prop="status">
                 <template slot-scope="scope">
                     <dict-tag :options="dict.type.settlement_status_type" :value="scope.row.status" />

+ 2 - 2
admin-ui/src/views/settlement/bill/index.vue

@@ -20,13 +20,13 @@
     </el-form>
 
     <el-row :gutter="10" class="mb8">
-      <el-col :span="1.5">
+      <!-- <el-col :span="1.5">
         <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['settlement:bill:add']">新增</el-button>
       </el-col>
       <el-col :span="1.5">
         <el-button type="success" plain icon="el-icon-check" size="mini" :disabled="multiple" @click="handleBatchConfirm"
           v-hasPermi="['settlement:bill:confirm']">批量确认</el-button>
-      </el-col>
+      </el-col> -->
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 

+ 42 - 9
admin-ui/src/views/settlement/bill/storeSettlement.vue

@@ -42,10 +42,15 @@
       <el-table-column label="原材料剩余金额" align="center" prop="materialImprestRemainAmount" width="120px" />
             <el-table-column label="系统维护费" align="center" prop="systemMaintenanceAmount" width="100px" />
             <el-table-column label="洗衣费" align="center" prop="washClothAmount" width="100px" />
-            <el-table-column label="顺丰快递费" align="center" prop="sfExpressAmount" width="100px" />
+            <el-table-column label="快递费" align="center" prop="expressAmount" width="100px" />
             <el-table-column label="跨店结算金" align="center" prop="crossStoreSettlementAmount" width="100px" />
-            <el-table-column label="超额订货金额" align="center" prop="overOrderingAmount" width="100px" />
+            <!-- <el-table-column label="超额订货金额" align="center" prop="overOrderingAmount" width="100px" /> -->
             <el-table-column label="结算金额" align="center" prop="settlementAmount" width="100px" />
+                        <el-table-column label="备注" align="center" prop="remark" width="120px" >
+                <template slot-scope="scope">
+                    {{ scope.row.remark || "--" }}
+                </template>
+                </el-table-column>
             <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="150">
                 <template slot-scope="scope">
                     <el-button type="text" @click="getDetail(scope.row)">详情</el-button>
@@ -77,19 +82,25 @@
             <div slot="header">
               <span>收支明细</span>
             </div>
+            <el-descriptions :column="3" border>
+              <el-descriptions-item label="微信到账">{{ settlementManageStore.wechatAmount}}</el-descriptions-item>
+              <el-descriptions-item label="微信实收">{{settlementManageStore.wechatArriveAmount }}</el-descriptions-item>
+              <el-descriptions-item label="支付宝到账">{{ settlementManageStore.alipayAmount }}</el-descriptions-item>
+              <el-descriptions-item label="支付宝实收">{{ settlementManageStore.alipayArriveAmount  }}</el-descriptions-item>
+            </el-descriptions>
             <el-row :gutter="20">
               <el-col :span="8">
-                <el-statistic title="支付宝/微信收入" :value="settlementManageStore.alipayAndWechatAmount" :precision="2">
-                  <template slot="suffix">元</template>
-                </el-statistic>
+                <el-form-item label="会员剩余金额">
+                <el-input-number v-model="settlementManageStore.memberBalance" :disabled="true" :precision="2" :controls="false" style="width: 180px"></el-input-number>
+              </el-form-item>
               </el-col>
               <el-col :span="8">
-                <el-statistic title="微信实收" :value="settlementManageStore.wechatAmount" :precision="2">
+                <el-statistic title="微信实收" :value="settlementManageStore.wechatArriveAmount" :precision="2">
                   <template slot="suffix">元</template>
                 </el-statistic>
               </el-col>
               <el-col :span="8">
-                <el-statistic title="支付宝实收" :value="settlementManageStore.alipayAmount" :precision="2">
+                <el-statistic title="支付宝实收" :value="settlementManageStore.alipayArriveAmount" :precision="2">
                   <template slot="suffix">元</template>
                 </el-statistic>
               </el-col>
@@ -166,6 +177,29 @@
           </el-card>
         </el-col>
 
+        <!-- 卡密信息 -->
+        <el-col :span="12">
+          <el-card class="box-card">
+            <div slot="header">
+              <span>异店信息</span>
+              <el-tooltip content="跨店结算金=(本店卡:洗衣*费率-异店卡:洗衣*费率)+(本店卡:零售*费率-异店卡:零售*费率)+(本店卡:app*费率-异店卡:app*费率)+(本店卡:第三方*费率-异店卡:第三方*费率)+(本店卡:运费*费率-异店卡:运费*费率)" placement="top">
+                <i class="el-icon-question"></i>
+              </el-tooltip>
+            </div>
+            <el-form ref="cardForm" :model="form" label-width="120px">
+              <el-form-item label="本店卡异店消费金额">
+                <el-input-number v-model="settlementManageStore.otherStoreAmount" :disabled="true" :precision="2" :controls="false" style="width: 180px"></el-input-number>
+              </el-form-item>
+              <el-form-item label="异店卡本店消费金额">
+                <el-input-number v-model="settlementManageStore.otherCardAmount" :disabled="true" :precision="2" :controls="false" style="width: 180px"></el-input-number>
+              </el-form-item>
+              <el-form-item label="跨店结算金">
+                <el-input-number v-model="settlementManageStore.crossStoreSettlementAmount" :disabled="true" :precision="2" :controls="false" style="width: 180px"></el-input-number>
+              </el-form-item>
+            </el-form>
+          </el-card>
+        </el-col>
+
         <!-- 其他费用 -->
         <el-col :span="12">
           <el-card class="box-card">
@@ -456,8 +490,7 @@ export default {
          * 计算实际结算金额
          */
         calculateSettlementAmount() {
-            const baseAmount = this.settlementManageStore.alipayAndWechatAmount || 
-                (this.settlementManageStore.alipayAmount + this.settlementManageStore.wechatAmount)
+            const baseAmount = (this.settlementManageStore.alipayArriveAmount + this.settlementManageStore.wechatArriveAmount)
             
             const result = baseAmount * 1000000 -
                 this.form.settlePaidDeposit * 1000000 -

+ 11 - 9
admin-ui/src/views/settlement/rate/factoryRate.vue

@@ -21,19 +21,19 @@
       <el-table-column label="工厂名称" align="center" prop="factoryName" />
       <el-table-column label="材料费率" align="center" prop="materialRate">
         <template slot-scope="scope">
-          <span v-if="scope.row.materialRate != null && scope.row.materialRate >= 0">{{(scope.row.materialRate).toFixed(2)}}</span >
+          <span v-if="scope.row.materialRate != null && scope.row.materialRate >= 0">{{(scope.row.materialRate).toFixed(2)}}</span>
           <span v-else>--</span>
         </template>
       </el-table-column>
       <el-table-column label="系统管理费率" align="center" prop="managementRate">
         <template slot-scope="scope">
-          <span v-if="scope.row.managementRate != null && scope.row.managementRate >= 0">{{(scope.row.managementRate).toFixed(2)}}</span >
+          <span v-if="scope.row.managementRate != null && scope.row.managementRate >= 0">{{(scope.row.managementRate).toFixed(2)}}</span>
           <span v-else>--</span>
         </template>
       </el-table-column>
       <el-table-column label="押金费率" align="center" prop="depositRate">
         <template slot-scope="scope">
-          <span v-if="scope.row.depositRate != null && scope.row.depositRate >= 0">{{(scope.row.depositRate).toFixed(2)}}</span >
+          <span v-if="scope.row.depositRate != null && scope.row.depositRate >= 0">{{(scope.row.depositRate).toFixed(2)}}</span>
           <span v-else>--</span>
         </template>
       </el-table-column>
@@ -68,17 +68,19 @@
             <el-form-item label="材料费率" prop="materialRate">
               <el-input-number v-model="form.materialRate" :precision="2" :step="0.01" :max="1" />
             </el-form-item>
-            <el-form-item label="时间范围" prop="dateRange">
-              <el-date-picker clearable v-model="form.dateRange" type="daterange" value-format="yyyy-MM-dd" range-separator="至"
-                              start-placeholder="开始日期" end-placeholder="结束日期" @change="selectDateRange"> </el-date-picker>
+            <el-form-item label="押金费率" prop="depositRate">
+              <el-input-number v-model="form.depositRate" :precision="2" :step="0.01" :max="1" />
             </el-form-item>
           </el-col>
-          <el-col :span="12">
+          <el-col :span="24">
             <el-form-item label="系统管理费率" prop="managementRate">
               <el-input-number v-model="form.managementRate" :precision="2" :step="0.01" :max="1" />
             </el-form-item>
-            <el-form-item label="押金费率" prop="depositRate">
-              <el-input-number v-model="form.depositRate" :precision="2" :step="0.01" :max="1" />
+          </el-col>
+          <el-col :span="24">
+            <el-form-item label="时间范围" prop="dateRange">
+              <el-date-picker clearable v-model="form.dateRange" type="daterange" value-format="yyyy-MM-dd" range-separator="至"
+                start-placeholder="开始日期" end-placeholder="结束日期" @change="selectDateRange"> </el-date-picker>
             </el-form-item>
           </el-col>
         </el-form>

+ 4 - 4
admin-ui/src/views/settlement/rate/storeRate.vue

@@ -59,13 +59,13 @@
       </el-table-column>
       <el-table-column label="支付宝支付费率" align="center" prop="aliPayRate">
         <template slot-scope="scope">
-          <span v-if="scope.row.aliPayRate != null && scope.row.aliPayRate >= 0">{{(scope.row.aliPayRate).toFixed(2)}}</span >
+          <span v-if="scope.row.aliPayRate != null && scope.row.aliPayRate >= 0">{{(scope.row.aliPayRate).toFixed(4)}}</span >
           <span v-else>--</span>
         </template>
       </el-table-column>
       <el-table-column label="微信支付费率" align="center" prop="wxPayRate">
         <template slot-scope="scope">
-          <span v-if="scope.row.wxPayRate != null && scope.row.wxPayRate >= 0">{{(scope.row.wxPayRate).toFixed(2)}}</span >
+          <span v-if="scope.row.wxPayRate != null && scope.row.wxPayRate >= 0">{{(scope.row.wxPayRate).toFixed(4)}}</span >
           <span v-else>--</span>
         </template>
       </el-table-column>
@@ -130,10 +130,10 @@
               <el-input-number v-model="form.otherConsumeRate" :precision="2" :step="0.01" :max="1" />
             </el-form-item>
             <el-form-item label="支付宝支付费率" prop="aliPayRate">
-              <el-input-number v-model="form.aliPayRate" :precision="2" :step="0.01" :max="1" />
+              <el-input-number v-model="form.aliPayRate" :precision="4" :step="0.0001" :max="1" />
             </el-form-item>
             <el-form-item label="微信支付费率" prop="wxPayRate">
-              <el-input-number v-model="form.wxPayRate" :precision="2" :step="0.01" :max="1" />
+              <el-input-number v-model="form.wxPayRate" :precision="4" :step="0.0001" :max="1" />
             </el-form-item>
             <el-form-item label="系统管理费率" prop="managementRate">
               <el-input-number v-model="form.managementRate" :precision="2" :step="0.01" :max="1" />

+ 0 - 9
yiqi-admin/src/main/java/com/yiqi/admin/controller/core/SettlementManageBillController.java

@@ -179,7 +179,6 @@ public class SettlementManageBillController extends BaseController {
     /**
      * 新增结算账单
      */
-    @Transactional(rollbackFor = Exception.class)
     @PreAuthorize("@ss.hasPermi('settlement:bill:add')")
     @PostMapping("/insertSettlementBill")
     @ApiOperation(value = "新增结算账单")
@@ -188,14 +187,6 @@ public class SettlementManageBillController extends BaseController {
         return R.ok();
     }
 
-    public R insertSettlementManageBillJob() {
-        SettlementBillAddDTO settlementBillAddDTO = new SettlementBillAddDTO();
-        settlementBillAddDTO.setMonth("202407");
-        settlementBillAddDTO.setTitle("202407账单");
-        settlementManageBillService.insertSettlementManageBill(settlementBillAddDTO);
-        return R.ok();
-    }
-
     /**
      * 删除结算账单
      */

+ 75 - 2
yiqi-admin/src/main/java/com/yiqi/admin/controller/order/OrderClothController.java

@@ -190,9 +190,79 @@ public class OrderClothController extends BaseController {
     }
 
     @Transactional(rollbackFor = Exception.class)
-    @ApiOperation("同城配送派单")
+    @ApiOperation("三方配送派单")
     @GetMapping(value = "/setIntracityExpress")
-    public R setIntracityExpress(@RequestParam String orderNo) throws Exception {
+    public R setThirdExpress(@RequestParam String orderNo) throws Exception {
+        OrderCloth orderCloth = orderClothService.getOne(new QueryWrapper<OrderCloth>().lambda()
+                .eq(OrderCloth::getOrderNo, orderNo)
+                .eq(OrderCloth::getOrgId, SecurityUtils.getLoginUser().getOrgId())
+                .eq(OrderCloth::getSourceType, SecurityUtils.getLoginUser().getSourceType()));
+        if (orderCloth == null) {
+            throw new ServiceException("未查询到订单信息");
+        }
+        if (!orderCloth.getSourceType().equals(SourceType.STORE.getCode())) {
+            throw new ServiceException("该订单不是门店订单,无法三方派单");
+        }
+        SysStore sysStore = sysStoreService.getOne(new QueryWrapper<SysStore>().lambda().eq(SysStore::getId, orderCloth.getOrgId()));
+        if (sysStore == null) {
+            throw new ServiceException("未查询到门店");
+        }
+
+        switch (EnumUtils.getEnumByType(orderCloth.getOrderStatus(), ClothOrderStatusType.class)) {
+            case APPOINTMENT: {
+                // 预约待取,进行取件发单
+                throw new ServiceException("同城配送暂不支持上门取件");
+            }
+            case WAITING_TO_SEND: {
+                // 待送衣-送衣发单
+                // 1.获取收衣配送单
+                OrderDelivery takeDelivery = orderDeliveryService.selectOrderDeliveryByOrderId(orderCloth.getOrderNo(), ClothOrderDeliveryType.collectCloth.getCode());
+                OrderDelivery orderDelivery = new OrderDelivery(takeDelivery);
+                orderDelivery.setDeliverySn(orderNoUtils.getDeliveryOrderNo());
+                orderDelivery.setOrderSn(orderCloth.getOrderNo());
+                orderDelivery.setClothOrderType(ClothOrderDeliveryType.takeCloth.getCode());
+                orderDelivery.setCreateTime(DateUtils.getNowDate());
+                orderDelivery.setDeliveryStatus(OrderDeliveryStatusEnum.WAIT_DELIVERY.getCode());
+                orderDelivery.setStoreId(orderCloth.getOrgId());
+                // 设置未同城配送订单
+                orderDelivery.setDeliveryWay(ClothOrderDeliveryWay.intracityExpress.getCode());
+
+                if (!ClothTakeWay.DELIVERY.getCode().equals(orderCloth.getSendClothWay())) {
+                    throw new ServiceException("该订单客户未选择送货上门,无法分配配送员");
+                }
+                AppUser appUser = appUserService.getOne(new QueryWrapper<AppUser>().lambda().eq(AppUser::getId, orderCloth.getAppUserId()));
+                IntracityExpressCreateOrderResult result = sysStoreIntracityExpressService
+                        .addOrder(IntracityExpressAddOrderRequest
+                                .build(orderCloth, orderDelivery, sysStore, appUser.getWxOpenId()));
+                // 更新订单状态
+                orderClothService.update(new UpdateWrapper<OrderCloth>().lambda()
+                        .eq(OrderCloth::getId, orderCloth.getId())
+                        .set(OrderCloth::getOrderStatus, ClothOrderStatusType.SENDING.getCode()));
+                // 更新配送单状态
+                orderDelivery.setDistance(String.valueOf(result.getDistance()));
+                // 金额 分 -> 元
+                orderDelivery.setFee(BigDecimal.valueOf(result.getFee()).divide(BigDecimal.valueOf(100), 2));
+                orderDelivery.setFetchCode(result.getFetch_code());
+                orderDelivery.setServiceTransId(result.getService_trans_id());
+                orderDelivery.setTransOrderId(result.getTrans_order_id());
+                orderDelivery.buildCreateData();
+                orderDeliveryService.save(orderDelivery);
+
+                if (result.getErrcode() != 0) {
+                    throw new ServiceException("errorCode:" + result.getErrcode() + ";errorMsg:" + result.getErrmsg());
+                }
+                return R.ok(result);
+            }
+            default: {
+                throw new ServiceException("订单状态不正确,无法派单");
+            }
+        }
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @ApiOperation("同城配送派单")
+    @GetMapping(value = "/setIntracityExpress1")
+    public R setIntracityExpress1(@RequestParam String orderNo) throws Exception {
         OrderCloth orderCloth = orderClothService.getOne(new QueryWrapper<OrderCloth>().lambda()
                 .eq(OrderCloth::getOrderNo, orderNo)
                 .eq(OrderCloth::getOrgId, SecurityUtils.getLoginUser().getOrgId())
@@ -711,6 +781,9 @@ public class OrderClothController extends BaseController {
         orderClothPrintVO.setAppUserInfoVO(userInfo);
         //获取衣服明细
         List<OrderClothItemVO> orderClothItemList = orderClothItemService.queryClothItemByOrderId(orderClothPrintVO.getOrderNo());
+        if (CollUtil.isEmpty(orderClothItemList)) {
+            throw new ServiceException("未找到衣服明细");
+        }
         orderClothPrintVO.setOrderClothItemVOS(orderClothItemList);
         RechargePasswordCard rechargePasswordCard = rechargePasswordCardService.selectTotalBalanceGroupByAppUser(orderClothPrintVO.getAppUserId(), null);
         if (orderClothPrintVO.getPayType().equals(PayType.BALANCE.getCode())) {

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

@@ -195,18 +195,44 @@ public class SettlementStoreStatisticsController extends BaseController {
      */
     @GetMapping("/list/bystore")
     public TableDataInfo listByStore(@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) {
 
         startPage();
-        Date start = startDate != null ? DateUtils.parseDate(startDate) : DateUtils.addDays(new Date(), -1);
-
+        if (getStoreId() != null) {
+            storeId = getStoreId();
+        }
+        Date start = startDate != null ? DateUtils.parseDate(startDate) : DateUtils.addDays(new Date(), -7);
+        Date end = endDate != null ? DateUtils.parseDate(endDate) : DateUtils.addDays(new Date(), -1);
         List<SettlementStoreStatistics> list = settlementStoreStatisticsService
-                .generateStoreStatisticsByStore(start);
+                .generateStoreStatisticsByStore(storeId, start, end);
 
         return getDataTable(list);
     }
 
+    /**
+     * 获取门店每日交易统计列表
+     */
+    @PostMapping("/list/bystore/export")
+    public void storeExport(@RequestParam(required = false) String startDate,
+                                     @RequestParam(required = false) String endDate,
+                                     @RequestParam(required = false) Long storeId,
+                            HttpServletResponse response) {
+
+        if (getStoreId() != null) {
+            storeId = getStoreId();
+        }
+        Date start = startDate != null ? DateUtils.parseDate(startDate) : DateUtils.addDays(new Date(), -7);
+        Date end = endDate != null ? DateUtils.parseDate(endDate) : DateUtils.addDays(new Date(), -1);
+        List<SettlementStoreStatistics> list = settlementStoreStatisticsService
+                .generateStoreStatisticsByStore(storeId, start, end);
+
+        ExcelUtil<SettlementStoreStatistics> util = new ExcelUtil<>(SettlementStoreStatistics.class);
+        util.exportExcel(response, list, "按门店交易统计");
+    }
+
     /**
      * 导出门店每日交易统计
      */
@@ -221,6 +247,6 @@ public class SettlementStoreStatisticsController extends BaseController {
                 .generateStoreStatisticsByDate(storeId, start, end);
 
         ExcelUtil<SettlementStoreStatistics> util = new ExcelUtil<>(SettlementStoreStatistics.class);
-        util.exportExcel(response, list, "门店每日交易统计");
+        util.exportExcel(response, list, "门店按日期交易统计");
     }
 }

+ 5 - 3
yiqi-admin/src/main/java/com/yiqi/task/SettlementTask.java

@@ -4,6 +4,7 @@ import com.yiqi.common.utils.DateUtils;
 import com.yiqi.common.utils.StringUtils;
 import com.yiqi.core.domain.dto.SettlementBillAddDTO;
 import com.yiqi.core.service.ISettlementManageBillService;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -17,15 +18,16 @@ import java.util.Date;
  * @author ruoyi
  */
 @Component
+@Slf4j
 public class SettlementTask {
 
     @Autowired
     private ISettlementManageBillService settlementManageBillService;
 
-    public void insertSettlementBill(String date) {
-// 获取上个月的时间范围
+    public void run(String date) {
+        // 获取上个月的时间范围
         Calendar calendar = Calendar.getInstance();
-        calendar.add(Calendar.MONTH, -1);
+        calendar.add(Calendar.MONTH, 0);
 
         SimpleDateFormat monthFormat = new SimpleDateFormat("yyyy-MM");
         String month = monthFormat.format(calendar.getTime());

+ 192 - 69
yiqi-common/src/main/java/com/yiqi/core/domain/SettlementManageStore.java

@@ -2,6 +2,8 @@ package com.yiqi.core.domain;
 
 import java.math.BigDecimal;
 import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
@@ -23,315 +25,436 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 @ApiModel("门店结算详情")
 @TableName("settlement_manage_store")
 @Data
-public class SettlementManageStore
-{
-    private static final long serialVersionUID=1L;
+public class SettlementManageStore {
+    private static final long serialVersionUID = 1L;
 
-    /** 主键ID */
+    /**
+     * 主键ID
+     */
     @ApiModelProperty("主键ID")
     @TableId(type = IdType.AUTO)
     private Long id;
 
-    /** 账单ID */
+    /**
+     * 账单ID
+     */
     @Excel(name = "账单ID")
     @ApiModelProperty("账单ID")
     private Long billId;
 
-    /** 来源类型 */
+    /**
+     * 来源类型
+     */
     @Excel(name = "来源类型")
     @ApiModelProperty("来源类型")
     private String sourceType;
 
-    /** 组织ID */
+    /**
+     * 组织ID
+     */
     @Excel(name = "组织ID")
     @ApiModelProperty("组织ID")
     private Long orgId;
 
-    /** 开始时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
+    /**
+     * 开始时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd")
     @ApiModelProperty("开始时间")
     private Date beginTime;
 
-    /** 结束时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
+    /**
+     * 结束时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd")
     @ApiModelProperty("结束时间")
     private Date endTime;
 
-    /** 账单标题 */
+    /**
+     * 账单标题
+     */
     @Excel(name = "账单标题")
     @ApiModelProperty("账单标题")
     private String title;
 
-    /** 会员剩余金额 */
+    /**
+     * 会员剩余金额
+     */
     @Excel(name = "会员剩余金额")
     @ApiModelProperty("会员剩余金额")
     private BigDecimal memberBalance;
 
-    /** 应付押金 */
+    /**
+     * 应付押金
+     */
     @Excel(name = "应付押金")
     @ApiModelProperty("应付押金")
     private BigDecimal payableDeposit;
 
-    /** 已付押金 */
+    /**
+     * 已付押金
+     */
     @Excel(name = "已付押金")
     @ApiModelProperty("已付押金")
     private BigDecimal paidDeposit;
 
-    /** 福利金额 */
+    /**
+     * 福利金额
+     */
     @Excel(name = "福利金额")
     @ApiModelProperty("福利金额")
     private BigDecimal welfareAmount;
 
-    /** 福利押金 */
+    /**
+     * 福利押金
+     */
     @Excel(name = "福利押金")
     @ApiModelProperty("福利押金")
     private BigDecimal welfareDeposit;
 
-    /** 卡密押金 */
+    /**
+     * 卡密押金
+     */
     @Excel(name = "卡密押金")
     @ApiModelProperty("卡密押金")
     private BigDecimal cardPasswordDeposit;
 
-    /** 支付宝金额 */
+    /**
+     * 支付宝金额
+     */
     @Excel(name = "支付宝金额")
     @ApiModelProperty("支付宝金额")
     private BigDecimal alipayAmount;
 
-    /** 支付宝金额 */
+    /**
+     * 支付宝金额
+     */
     @Excel(name = "支付宝金额")
     @ApiModelProperty("支付宝金额")
     private BigDecimal alipayArriveAmount;
 
 
-    /** 微信金额 */
+    /**
+     * 微信金额
+     */
     @Excel(name = "微信金额")
     @ApiModelProperty("微信金额")
     private BigDecimal wechatAmount;
 
-    /** 微信金额 */
+    /**
+     * 微信金额
+     */
     @Excel(name = "微信金额")
     @ApiModelProperty("微信金额")
     private BigDecimal wechatArriveAmount;
 
-    /** 支付宝或微信费用 */
+    /**
+     * 支付宝或微信费用
+     */
     @Excel(name = "支付宝或微信费用")
     @ApiModelProperty("支付宝或微信费用")
     private BigDecimal alipayAndWechatAmount;
 
-    /** 未开卡卡密金额 */
+    /**
+     * 未开卡卡密金额
+     */
     @Excel(name = "未开卡卡密金额")
     @ApiModelProperty("未开卡卡密金额")
     private BigDecimal unopenedCardPasswordAmount;
 
-    /** 已付福利押金 */
+    /**
+     * 已付福利押金
+     */
     @Excel(name = "已付福利押金")
     @ApiModelProperty("已付福利押金")
     private BigDecimal paidWelfareDeposit;
 
-    /** 原材料备用金(材料费) */
+    /**
+     * 原材料备用金(材料费)
+     */
     @Excel(name = "原材料备用金", readConverterExp = "材=料费")
     @ApiModelProperty("原材料备用金(材料费)")
     private BigDecimal materialImprestAmount;
 
-    /** 原材料备用金 剩余金额 */
+    /**
+     * 原材料备用金 剩余金额
+     */
     @Excel(name = "原材料备用金余额", readConverterExp = "材=料费")
     @ApiModelProperty("原材料备用金(材料费)")
     private BigDecimal materialImprestRemainAmount;
 
-    /** 系统维护费 */
+    /**
+     * 系统维护费
+     */
     @Excel(name = "系统维护费")
     @ApiModelProperty("系统维护费")
     private BigDecimal systemMaintenanceAmount;
 
-    /** 洗衣费 */
+    /**
+     * 洗衣费
+     */
     @Excel(name = "洗衣费")
     @ApiModelProperty("洗衣费")
     private BigDecimal washClothAmount;
 
-    /** 跨店结算金 */
+    /**
+     * 跨店结算金
+     */
     @Excel(name = "跨店结算金")
     @ApiModelProperty("跨店结算金")
     private BigDecimal crossStoreSettlementAmount;
 
-    /** 超额订货金额 */
+    /**
+     * 超额订货金额
+     */
     @Excel(name = "超额订货金额")
     @ApiModelProperty("超额订货金额")
     private BigDecimal overOrderingAmount;
 
-    /** 结算金额 */
+    /**
+     * 结算金额
+     */
     @Excel(name = "结算金额")
     @ApiModelProperty("结算金额")
     private BigDecimal settlementAmount;
 
-    /** 现金余额 */
+    /**
+     * 现金余额
+     */
     @Excel(name = "现金余额")
     @ApiModelProperty("现金余额")
     private BigDecimal cashBalance;
 
-    /** 赠送余额 */
+    /**
+     * 赠送余额
+     */
     @Excel(name = "赠送余额")
     @ApiModelProperty("赠送余额")
     private BigDecimal giveBalance;
 
-    /** 福利余额 */
+    /**
+     * 福利余额
+     */
     @Excel(name = "福利余额")
     @ApiModelProperty("福利余额")
     private BigDecimal welfareBalance;
 
-    /** 订单金额(商品订单+洗衣订单) */
+    /**
+     * 订单金额(商品订单+洗衣订单)
+     */
     @Excel(name = "订单金额", readConverterExp = "商=品订单+洗衣订单")
     @ApiModelProperty("订单金额(商品订单+洗衣订单)")
     private BigDecimal orderAmount;
 
-    /** 洗衣件数 */
+    /**
+     * 洗衣件数
+     */
     @Excel(name = "洗衣件数")
     @ApiModelProperty("洗衣件数")
     private Integer orderClothCount;
 
-    /** 洗衣金额-去掉退款 */
+    /**
+     * 洗衣金额-去掉退款
+     */
     @Excel(name = "洗衣订单金额")
     @ApiModelProperty("洗衣订单金额")
     private BigDecimal orderClothAmount;
 
-    /** 商品金额-去掉退款 */
+    /**
+     * 商品金额-去掉退款
+     */
     @Excel(name = "商品订单金额")
     @ApiModelProperty("商品订单金额")
     private BigDecimal orderGoodsAmount;
 
-    /** 商品金额-去掉退款 */
+    /**
+     * 商品金额-去掉退款
+     */
     @Excel(name = "商品采购金额")
     @ApiModelProperty("商品采购金额")
     private BigDecimal orderPurchaseAmount;
 
-    /** 异店金额 */
+    /**
+     * 异店金额
+     */
     @Excel(name = "异店金额")
     @ApiModelProperty("异店金额")
     private BigDecimal otherStoreAmount;
 
-    /** 异卡金额 */
+    /**
+     * 异卡金额
+     */
     @Excel(name = "异卡金额")
     @ApiModelProperty("异卡金额")
     private BigDecimal otherCardAmount;
 
-    /** 异店金额 零售 */
+    /**
+     * 异店金额 零售
+     */
     @Excel(name = "异店金额 零售")
     @ApiModelProperty("异店金额 零售")
     private BigDecimal retailOtherStoreAmount;
 
-    /** 异卡金额 零售 */
+    /**
+     * 异卡金额 零售
+     */
     @Excel(name = "异卡金额 零售")
     @ApiModelProperty("异卡金额 零售")
     private BigDecimal retailOtherCardAmount;
 
-    /** 异店金额 app订单 */
+    /**
+     * 异店金额 app订单
+     */
     @Excel(name = "异店金额 app订单")
     @ApiModelProperty("异店金额 app订单")
     private BigDecimal appOtherStoreAmount;
 
-    /** 异卡金额 app订单 */
+    /**
+     * 异卡金额 app订单
+     */
     @Excel(name = "异卡金额 app订单")
     @ApiModelProperty("异卡金额 app订单")
     private BigDecimal appOtherCardAmount;
 
-    /** 异店金额 第三方 */
+    /**
+     * 异店金额 第三方
+     */
     @Excel(name = "异店金额 第三方")
     @ApiModelProperty("异店金额 第三方")
     private BigDecimal thirdOtherStoreAmount;
 
-    /** 异卡金额 第三方 */
+    /**
+     * 异卡金额 第三方
+     */
     @Excel(name = "异卡金额 第三方")
     @ApiModelProperty("异卡金额 第三方")
     private BigDecimal thirdOtherCardAmount;
 
-    /** 实际结算金额 */
+    /**
+     * 实际结算金额
+     */
     @Excel(name = "实际结算金额")
     @ApiModelProperty("实际结算金额")
     private BigDecimal realSettlementAmount;
 
-    /** 状态(0,未清算;1: 已清算 ) */
+    /**
+     * 状态(0,未清算;1: 已清算 )
+     */
     @Excel(name = "状态", readConverterExp = "0=,未清算;1:,已=清算")
     @ApiModelProperty("状态(0,未清算;1: 已清算 )")
     private String status;
 
-    /** 清算备注 */
+    /**
+     * 清算备注
+     */
     @Excel(name = "清算备注")
     @ApiModelProperty("清算备注")
     private String settleRemark;
 
-    /** 清算已付押金 */
+    /**
+     * 清算已付押金
+     */
     @Excel(name = "清算已付押金")
     @ApiModelProperty("清算已付押金")
     private BigDecimal settlePaidDeposit;
 
-    /** 清算福利金额 */
+    /**
+     * 清算福利金额
+     */
     @Excel(name = "清算福利金额")
     @ApiModelProperty("清算福利金额")
     private BigDecimal settleWelfareDeposit;
 
-    /** 清算原材料备用金(材料费) */
+    /**
+     * 清算原材料备用金(材料费)
+     */
     @Excel(name = "清算原材料备用金", readConverterExp = "材=料费")
     @ApiModelProperty("清算原材料备用金(材料费)")
     private BigDecimal settleMaterialImprestAmount;
 
-    /** 清算结算金额 */
+    /**
+     * 清算结算金额
+     */
     @Excel(name = "清算结算金额")
     @ApiModelProperty("清算结算金额")
     private BigDecimal settleSettlementAmount;
 
-    /** 清算时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
+    /**
+     * 清算时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     @Excel(name = "清算时间", width = 30, dateFormat = "yyyy-MM-dd")
     @ApiModelProperty("清算时间")
     private Date settleTime;
 
-    /** 数据是否符合 1符合 2不符合 0未检测 */
+    /**
+     * 数据是否符合 1符合 2不符合 0未检测
+     */
     @Excel(name = "数据是否符合 1符合 2不符合 0未检测")
     @ApiModelProperty("数据是否符合 1符合 2不符合 0未检测")
     private String dataCheck;
 
-    /** 数据符合检测时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
+    /**
+     * 数据符合检测时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     @Excel(name = "数据符合检测时间", width = 30, dateFormat = "yyyy-MM-dd")
     @ApiModelProperty("数据符合检测时间")
     private Date dataCheckTime;
 
-    /** 数据检测说明 */
+    /**
+     * 数据检测说明
+     */
     @Excel(name = "数据检测说明")
     @ApiModelProperty("数据检测说明")
     private String dataCheckDesc;
 
-    /** 福利结算表id */
+    /**
+     * 福利结算表id
+     */
     @Excel(name = "福利结算表id")
     @ApiModelProperty("福利结算表id")
     private Long welfareSettleId;
 
-    /** 卡密金额 */
+    /**
+     * 卡密金额
+     */
     @Excel(name = "卡密金额")
     @ApiModelProperty("卡密金额")
     private BigDecimal cardPasswordAmount;
 
-    /** 顺丰快递费 */
+    /**
+     * 顺丰快递费
+     */
     @Excel(name = "顺丰快递费")
     @ApiModelProperty("顺丰快递费")
-    private BigDecimal sfExpressAmount;
+    private BigDecimal expressAmount;
 
-    /** 顺丰订单数 */
+    /**
+     * 顺丰订单数
+     */
     @Excel(name = "顺丰订单数")
     @ApiModelProperty("顺丰订单数")
-    private Integer sfExpressCount;
+    private Integer expressCount;
 
-    /** 清算收取卡密押金 */
+    /**
+     * 清算收取卡密押金
+     */
     @Excel(name = "清算收取卡密押金")
     @ApiModelProperty("清算收取卡密押金")
     private BigDecimal settleGetCardPasswordDeposit;
 
-    /** 已付卡密押金 */
+    /**
+     * 已付卡密押金
+     */
     @Excel(name = "已付卡密押金")
     @ApiModelProperty("已付卡密押金")
     private BigDecimal paidCardPasswordDeposit;
 
+    @TableField(exist = false)
+    private Integer storeNum;
 
     private String remark;
 }

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

@@ -16,6 +16,8 @@ import com.yiqi.settlement.domain.dto.StoreBillStatistics;
  */
 public interface ISettlementManageBillService extends IService<SettlementManageBill> {
 
+
+
     void insertSettlementManageBill(SettlementBillAddDTO settlementBillAddDTO);
 
     /**

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

@@ -151,7 +151,7 @@ public interface ISettlementStoreStatisticsService extends IService<SettlementSt
      * @param date
      * @return
      */
-    List<SettlementStoreStatistics> generateStoreStatisticsByStore(Date start);
+    List<SettlementStoreStatistics> generateStoreStatisticsByStore(Long storeId, Date start, Date end);
 
     /**
      * 生成门店每日统计数据*

+ 11 - 1
yiqi-common/src/main/java/com/yiqi/order/domain/OrderRefundInfo.java

@@ -1,10 +1,13 @@
 package com.yiqi.order.domain;
 
+import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.Date;
 
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.yiqi.common.annotation.Excel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -22,7 +25,7 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 @ApiModel("第三方退款记录")
 @TableName("order_refund_info")
 @Data
-public class OrderRefundInfo extends BaseEntity {
+public class OrderRefundInfo implements Serializable {
     private static final long serialVersionUID = 1L;
 
     /**
@@ -47,6 +50,13 @@ public class OrderRefundInfo extends BaseEntity {
     @ApiModelProperty("原订单编号")
     private String originOrderNo;
 
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty("创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+
     /**
      * 退款订单编号
      */

+ 10 - 0
yiqi-core/src/main/java/com/yiqi/core/mapper/SettlementManageStoreMapper.java

@@ -4,6 +4,7 @@ import java.util.List;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
 import com.yiqi.core.domain.SettlementManageStore;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 门店结算详情Mapper接口
@@ -12,4 +13,13 @@ import com.yiqi.core.domain.SettlementManageStore;
  * @date 2024-02-15
  */
 public interface SettlementManageStoreMapper extends BaseMapper<SettlementManageStore> {
+
+    /**
+     * 查询门店结算详情
+     *
+     * @param billId 门店结算详情主键
+     * @return 门店结算详情
+     */
+    SettlementManageStore statisticsByBillId(@Param("billId") Long billId);
+
 }

+ 10 - 0
yiqi-core/src/main/java/com/yiqi/core/mapper/SettlementStoreStatisticsMapper.java

@@ -85,4 +85,14 @@ public interface SettlementStoreStatisticsMapper extends BaseMapper<SettlementSt
      * @return 结果
      */
     SettlementStoreStatistics orderStatisticsByDate(@Param("storeId") Long storeId, @Param("day") Integer day);
+
+
+    /**
+     * 查询订单统计
+     *
+     * @param storeId 门店id
+     * @param day 开始日期
+     * @return 结果
+     */
+    List<SettlementStoreStatistics> orderStatisticsByStore(@Param("storeId") Long storeId,  @Param("startDay") Integer startDay, @Param("endDay") Integer endDay);
 }

+ 95 - 19
yiqi-core/src/main/java/com/yiqi/core/service/impl/SettlementManageBillServiceImpl.java

@@ -2,12 +2,12 @@ package com.yiqi.core.service.impl;
 
 import java.math.BigDecimal;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 import java.util.concurrent.CompletableFuture;
 
 import cn.hutool.core.collection.CollUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-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.*;
@@ -17,6 +17,7 @@ import com.yiqi.common.utils.DateUtils;
 import com.yiqi.core.domain.SettlementManageFactory;
 import com.yiqi.core.domain.SettlementManageStore;
 import com.yiqi.core.domain.dto.SettlementBillAddDTO;
+import com.yiqi.core.mapper.SettlementManageStoreMapper;
 import com.yiqi.core.service.ISettlementManageFactoryService;
 import com.yiqi.core.service.ISettlementManageStoreService;
 import com.yiqi.order.domain.*;
@@ -32,11 +33,8 @@ import com.yiqi.settlement.domain.dto.StoreSettlementData;
 import com.yiqi.settlement.service.ISettlementFactoryRateService;
 import com.yiqi.settlement.service.ISettlementStoreRateService;
 import com.yiqi.system.domain.ManageFactory;
-import com.yiqi.system.domain.SysSettlementRate;
 import com.yiqi.system.domain.SysStore;
 import com.yiqi.system.service.IManageFactoryService;
-import com.yiqi.system.service.ISysConfigService;
-import com.yiqi.system.service.ISysSettlementRateService;
 import com.yiqi.system.service.ISysStoreService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@@ -45,7 +43,7 @@ import com.yiqi.core.mapper.SettlementManageBillMapper;
 import com.yiqi.core.domain.SettlementManageBill;
 import com.yiqi.core.service.ISettlementManageBillService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import lombok.Data;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 结算管理Service业务层处理
@@ -60,6 +58,8 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
     @Autowired
     private ISettlementManageStoreService settlementManageStoreService;
     @Autowired
+    private SettlementManageStoreMapper settlementManageStoreMapper;
+    @Autowired
     private IOrderClothItemService orderClothItemService;
     @Autowired
     private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@@ -78,10 +78,6 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
     @Autowired
     private IOrderRefundInfoService orderRefundInfoService;
     @Autowired
-    private ISysSettlementRateService sysSettlementRateService;
-    @Autowired
-    private ISysConfigService configService;
-    @Autowired
     private IOrderClothService orderClothService;
     @Autowired
     private IOrderClothRefundService orderClothRefundService;
@@ -95,13 +91,22 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
     private ISettlementFactoryRateService settlementFactoryRateService;
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void insertSettlementManageBill(SettlementBillAddDTO settlementBillAddDTO) {
         SettlementManageBill settlementManageBill = this.buildSettlementManageBill(settlementBillAddDTO);
-        // 工厂结算
-        this.handleCountFactorySettlement(settlementManageBill);
-
         // 门店结算
         this.handleCountStoreSettlement(settlementManageBill);
+        // 工厂结算
+        this.handleCountFactorySettlement(settlementManageBill);
+        //更新结算单
+
+        SettlementManageStore settlementManageStore = settlementManageStoreMapper.statisticsByBillId(settlementManageBill.getId());
+        settlementManageBill.setStoreNum(settlementManageStore.getStoreNum());
+        settlementManageBill.setMaterialImprestAmount(settlementManageStore.getMaterialImprestAmount());
+        settlementManageBill.setSettlementAmount(settlementManageStore.getSettlementAmount());
+        settlementManageBill.setSystemMaintenanceAmount(settlementManageStore.getSystemMaintenanceAmount());
+        settlementManageBill.setWashClothAmount(settlementManageStore.getWashClothAmount());
+        this.updateById(settlementManageBill);
     }
 
     private SettlementManageBill buildSettlementManageBill(SettlementBillAddDTO settlementBillAddDTO) {
@@ -259,7 +264,6 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         // 2. 订单金额统计
         BigDecimal totalAmount = orderList.stream()
                 .map(OrderCloth::getPayAmount)
-                .filter(Objects::nonNull)
                 .reduce(BigDecimal.ZERO, BigDecimal::add);
         stats.setTotalAmount(totalAmount);
 
@@ -310,6 +314,7 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
                 .count());
         stats.setGoodsCount(
                 orderList.stream()
+                        .filter(order -> PayStatus.HAS_PAY.getCode().equals(order.getPayStatus()))
                         .map(OrderGoods::getGoodsCount)
                         .filter(Objects::nonNull)
                         .reduce(0, Integer::sum)
@@ -358,6 +363,9 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
      * 计算洗衣订单支付方式金额
      */
     private Map<String, BigDecimal> calculateClothPayTypeAmounts(List<OrderCloth> orderList) {
+        if (orderList == null || orderList.size() == 0) {
+            return new HashMap<>();
+        }
         return orderList.stream()
                 .filter(order -> PayStatus.HAS_PAY.getCode().equals(order.getPayStatus()))
                 .collect(Collectors.groupingBy(
@@ -374,6 +382,9 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
      * 计算商品订单支付方式金额
      */
     private Map<String, BigDecimal> calculateGoodsPayTypeAmounts(List<OrderGoods> orderList) {
+        if (orderList == null || orderList.size() == 0) {
+            return new HashMap<>();
+        }
         return orderList.stream()
                 .filter(order -> PayStatus.HAS_PAY.getCode().equals(order.getPayStatus()))
                 .collect(Collectors.groupingBy(
@@ -391,7 +402,11 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
      * 计算洗衣订单支付方式金额
      */
     private Map<String, BigDecimal> calculateClothRefundTypeAmounts(List<OrderClothRefund> orderList) {
+        if (orderList == null || orderList.size() == 0) {
+            return new HashMap<>();
+        }
         return orderList.stream()
+                .filter(order -> OrderRefundStatus.REFUND_SUCCESS.getCode().equals(order.getRefundStatus()))
                 .collect(Collectors.groupingBy(
                         OrderClothRefund::getPayType,
                         Collectors.reducing(
@@ -406,7 +421,11 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
      * 计算商品订单支付方式金额
      */
     private Map<String, BigDecimal> calculateGoodsRefundTypeAmounts(List<OrderGoodsRefund> orderList) {
+        if (orderList == null || orderList.size() == 0) {
+            return new HashMap<>();
+        }
         return orderList.stream()
+                .filter(order -> OrderRefundStatus.REFUND_SUCCESS.getCode().equals(order.getRefundStatus()))
                 .collect(Collectors.groupingBy(
                         OrderGoodsRefund::getPayType,
                         Collectors.reducing(
@@ -444,15 +463,16 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
      *
      * @param settlementManageBill
      */
-    private void handleCountStoreSettlement(SettlementManageBill settlementManageBill) {
+    private Integer handleCountStoreSettlement(SettlementManageBill settlementManageBill) {
         List<SysStore> storeList = storeService.list(new QueryWrapper<SysStore>().lambda()
                 .eq(SysStore::getDelFlag, StatusType.OK.getCode()));
         if (CollUtil.isEmpty(storeList)) {
-            return;
+            return 0;
         }
         for (SysStore store : storeList) {
             this.buildStoreSettlement(settlementManageBill, store);
         }
+        return storeList.size();
     }
 
 
@@ -492,6 +512,26 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
                             .gt("order_status", purchaseGoodsStatusType.CONFIRM_PAY.getCode())
                             .between("pay_time", startTime, endTime)));
                 }),
+                //加载退款数据
+                CompletableFuture.runAsync(() -> {
+
+                    // 3. 查询衣服退款记录
+                    List<OrderClothRefund> clothRefundList = orderClothRefundService.list(new QueryWrapper<OrderClothRefund>().lambda()
+                            .eq(OrderClothRefund::getSourceType, SourceType.STORE.getCode())
+                            .eq(OrderClothRefund::getOrgId, storeId)
+                            .eq(OrderClothRefund::getRefundStatus, OrderRefundStatus.REFUND_SUCCESS.getCode())
+                            .between(OrderClothRefund::getRefundTime, startTime, endTime));
+
+                    // 4. 查询商品退款记录
+                    List<OrderGoodsRefund> goodsRefundList = orderGoodsRefundService.list(new QueryWrapper<OrderGoodsRefund>().lambda()
+                            .eq(OrderGoodsRefund::getOrgId, storeId)
+                            .eq(OrderGoodsRefund::getSourceType, SourceType.STORE.getCode())
+                            .eq(OrderGoodsRefund::getRefundStatus, OrderRefundStatus.REFUND_SUCCESS.getCode())
+                            .between(OrderGoodsRefund::getRefundTime, startTime, endTime));
+
+                    data.setClothRefunds(clothRefundList);
+                    data.setGoodsRefunds(goodsRefundList);
+                }),
 
                 // 加载支付数据
                 CompletableFuture.runAsync(() -> {
@@ -516,6 +556,7 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
                 CompletableFuture.runAsync(() -> {
                     data.setCrossStoreBills(appUserBillMstrService.list(new QueryWrapper<AppUserBillMstr>()
                             .eq("org_id", storeId)
+                            .ne("order_type", '4')
                             .or().eq("card_store_id", storeId)
                             .between("create_time", startTime, endTime)));
                 }),
@@ -567,6 +608,9 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         //计算跨店结算金
         calculateCrossStoreAmount(settlement, data);
 
+        //计算快递费
+        calculateExpressAmount(settlement, data);
+
         // 6. 计算最终结算金额
         calculateFinalSettlement(settlement);
 
@@ -575,6 +619,12 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         settlementManageStoreService.save(settlement);
     }
 
+    private void calculateExpressAmount(SettlementManageStore settlement, StoreSettlementData data) {
+        // 1. 统计快递订单数据
+        settlement.setExpressAmount(BigDecimal.ZERO);
+        settlement.setExpressCount(0);
+    }
+
     private void calculateClothAndGoodsOrderStats(SettlementManageStore settlement, StoreSettlementData data) {
         // 1. 统计洗衣订单数据
         OrderStatisticsVO clothStats = calculateClothOrderStats(data.getClothOrders(), data.getClothRefunds());
@@ -708,6 +758,9 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         Long currentStoreId = settlement.getOrgId();
 
         for (AppUserBillMstr appUserBillMstr : data.getCrossStoreBills()) {
+            if (appUserBillMstr.getSourceType() == null) {
+                continue;
+            }
             if (appUserBillMstr.getIsRefund().equals(SysBoolType.NO.getCode())) {
 
                 if (appUserBillMstr.getSourceType().equals(SourceType.MANAGER.getCode())) {
@@ -861,7 +914,6 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         settlementManageStore.setSettlementAmount(BigDecimal.ZERO);      // 结算金额
 
         // 7. 设置备注信息
-        settlementManageStore.setRemark("本期无交易数据");
     }
 
     /**
@@ -883,6 +935,7 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
             this.build0ClothFactory(settlementManageFactory);
             settlementManageFactory.setRemark("工厂暂无可用费率");
             settlementManageFactoryService.save(settlementManageFactory);
+            return;
         }
         //查询衣服订单,入场时间在上个月的,切没有撤销或者推单的衣服
         List<OrderClothItem> orderClothItemList = orderClothItemService.list(new QueryWrapper<OrderClothItem>().lambda()
@@ -902,6 +955,22 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         BigDecimal orderClothItemTotalPrice = orderClothItemList.stream().map(OrderClothItem::getTotalPrice).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
         // 总交易金额
         settlementManageFactory.setTotalTransactionAmount(orderClothItemTotalPrice);
+        //按照门店进行统计,计算每个门店的总金额
+        Map<Long, BigDecimal> storeTotalPriceMap = orderClothItemList.stream().collect(Collectors.groupingBy(OrderClothItem::getOrgId, Collectors.mapping(OrderClothItem::getTotalPrice, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
+        AtomicReference<BigDecimal> factorySettlementAmount = new AtomicReference<>(BigDecimal.ZERO);
+        storeTotalPriceMap.forEach((k, v) -> {
+            //获取门店的费率
+            SettlementStoreRate settlementStoreRate = settlementStoreRateService.getByStoreId(k, settlementManageBill.getBeginTime());
+            if (settlementStoreRate == null || settlementStoreRate.getFactoryRate() == null) {
+                settlementManageFactory.setRemark("工厂结算部分门店费率暂未设置");
+                settlementManageFactoryService.save(settlementManageFactory);
+                return;
+            }
+            BigDecimal amount = CurrencyUtil.mul(v, settlementStoreRate.getFactoryRate());
+            factorySettlementAmount.set(CurrencyUtil.add(factorySettlementAmount.get(), amount));
+        });
+        //(所有门店入厂洗衣件数对应的订单总金额-入厂后未洗退单总金额)*对应门店工厂结算费率
+        settlementManageFactory.setFactorySettlementAmount(factorySettlementAmount.get());
         //材料结算金额总和
         BigDecimal materialAmount = CurrencyUtil.mul(settlementFactoryRate.getMaterialRate(), orderClothItemTotalPrice);
         settlementManageFactory.setMaterialAmount(materialAmount);
@@ -913,8 +982,6 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         // 工厂实际收入 = 工厂结算金额总和 - 工厂消费
         settlementManageFactory.setRealIncomeAmount(settlementManageFactory.getFactorySettlementAmount().subtract(payMoney));
         settlementManageFactoryService.save(settlementManageFactory);
-//        settlementManageBill.setStatus(SettlementBillStatusType.WAITING.getCode());
-//        this.updateById(settlementManageBill);
     }
 
     /**
@@ -999,7 +1066,11 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
      */
     private Map<String, BigDecimal> calculateClothRefundAmounts(List<OrderClothRefund> refundList) {
         Map<String, BigDecimal> result = new HashMap<>();
-
+        if (refundList == null || refundList.size() == 0) {
+            result.put("count", BigDecimal.ZERO);
+            result.put("amount", BigDecimal.ZERO);
+            return result;
+        }
         // 统计退款笔数
         result.put("count", BigDecimal.valueOf(refundList.size()));
 
@@ -1018,6 +1089,11 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
      */
     private Map<String, BigDecimal> calculateGoodsRefundAmounts(List<OrderGoodsRefund> refundList) {
         Map<String, BigDecimal> result = new HashMap<>();
+        if (refundList == null || refundList.size() == 0) {
+            result.put("count", BigDecimal.ZERO);
+            result.put("amount", BigDecimal.ZERO);
+            return result;
+        }
 
         // 统计退款笔数
         result.put("count", BigDecimal.valueOf(refundList.size()));

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

@@ -119,10 +119,10 @@ public class SettlementStoreStatisticsServiceImpl extends ServiceImpl<Settlement
 
 
     @Override
-    public List<SettlementStoreStatistics> generateStoreStatisticsByStore(Date start) {
+    public List<SettlementStoreStatistics> generateStoreStatisticsByStore(Long storeId, Date start, Date end) {
         Integer startDay = Integer.parseInt(DateUtil.format(start, "yyyyMMdd"));
-        List<SettlementStoreStatistics> result = baseMapper.selectList(new QueryWrapper<SettlementStoreStatistics>().lambda()
-                .eq(SettlementStoreStatistics::getDay, startDay));
+        Integer endDay = Integer.parseInt(DateUtil.format(end, "yyyyMMdd"));
+        List<SettlementStoreStatistics> result = baseMapper.orderStatisticsByStore(storeId, startDay, endDay);
         for (SettlementStoreStatistics settlementStoreStatistics : result) {
             settlementStoreStatistics.setStoreName(storeService.getById(settlementStoreStatistics.getStoreId()).getName());
         }
@@ -152,7 +152,7 @@ public class SettlementStoreStatisticsServiceImpl extends ServiceImpl<Settlement
     public List<SettlementFactoryStatisticsDto> generateStatisticsByFactory(Long factoryId, Date start, Date end) {
         // 1. 获取日期范围内的所有日期
         List<ManageFactory> factoryList = factoryService.list(new QueryWrapper<ManageFactory>().lambda()
-                        .eq(factoryId!=null,ManageFactory::getId, factoryId)
+                .eq(factoryId != null, ManageFactory::getId, factoryId)
                 .eq(ManageFactory::getStatus, StatusType.OK.getCode())
                 .eq(ManageFactory::getDelFlag, StatusType.OK.getCode()));
         List<SettlementFactoryStatisticsDto> statisticsList = new ArrayList<>();

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

@@ -555,7 +555,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
         if (orderGoods == null) {
             throw new GlobalException("订单不存在");
         }
-        if (!OrderGoodsStatusType.SENDING.getCode().equals(orderGoods.getOrderStatus())) {
+        if (!OrderGoodsStatusType.NO_SEND.getCode().equals(orderGoods.getOrderStatus()) || !OrderGoodsStatusType.SENDING.getCode().equals(orderGoods.getOrderStatus())) {
             throw new GlobalException("订单状态不对,无法确认完成");
         }
         // 更新订单状态

+ 11 - 2
yiqi-core/src/main/resources/mapper/core/SettlementManageStoreMapper.xml

@@ -56,8 +56,8 @@
         <result property="dataCheckDesc" column="data_check_desc"/>
         <result property="welfareSettleId" column="welfare_settle_id"/>
         <result property="cardPasswordAmount" column="card_password_amount"/>
-        <result property="sfExpressAmount" column="sf_express_amount"/>
-        <result property="sfExpressCount" column="sf_express_count"/>
+        <result property="expressAmount" column="express_amount"/>
+        <result property="expressCount" column="express_count"/>
         <result property="settleGetCardPasswordDeposit" column="settle_get_card_password_deposit"/>
         <result property="paidCardPasswordDeposit" column="paid_card_password_deposit"/>
         <result property="factoryRate" column="factory_rate"/>
@@ -76,5 +76,14 @@
         from settlement_manage_store
     </sql>
 
+    <select id="statisticsByBillId" resultType="com.yiqi.core.domain.SettlementManageStore">
+        select count(*) as storeNum, IFNULL(SUM(wash_cloth_amount), 0) as washClothAmount,
+               IFNULL(SUM(order_cloth_count), 0) as order_cloth_count, IFNULL(SUM(settlement_amount), 0) as settlementAmount,
+               IFNULL(SUM(material_imprest_amount), 0) as materialImprestAmount, IFNULL(SUM(system_maintenance_amount), 0) as systemMaintenanceAmount,
+               IFNULL(SUM(cross_store_settlement_amount), 0) as crossStoreSettlementAmount,
+               IFNULL(SUM(order_amount), 0) as orderAmount, IFNULL(SUM(order_cloth_amount), 0) as orderClothAmount from
+                settlement_manage_store where bill_id = #{billId}
+    </select>
+
 
 </mapper>

+ 48 - 0
yiqi-core/src/main/resources/mapper/core/SettlementStoreStatisticsMapper.xml

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