Browse Source

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

DESKTOP-T5C0CIA\lhch 1 month ago
parent
commit
5ffc153c0f

+ 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://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/'
 

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

@@ -165,3 +165,19 @@ export function listplatformStatisticsByStore(query) {
     params: query
   })
 }
+
+export function listplatformStatisticsByDay(query) {
+  return request({
+    url: '/mapi/platform/statistics/order/byday',
+    method: 'get',
+    params: query
+  })
+}
+
+export function listplatformStatisticsByFactory(query) {
+  return request({
+    url: '/mapi/platform/statistics/order/byfactory',
+    method: 'get',
+    params: query
+  })
+}

+ 320 - 0
admin-ui/src/views/order/statistics/byday.vue

@@ -0,0 +1,320 @@
+<template>
+  <div class="app-container">
+    <!-- 搜索表单 -->
+    <el-form :model="queryParams" ref="queryForm" @submit.native.prevent :inline="true" v-show="showSearch" label-width="68px">
+      <el-form-item label="日期范围" prop="dateRange">
+        <el-date-picker
+          v-model="dateRange"
+          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 label="门店" prop="storeId">
+        <el-select v-model="queryParams.storeId" placeholder="请选择门店" clearable>
+          <el-option
+            v-for="store in storeOptions"
+            :key="store.id"
+            :label="store.name"
+            :value="store.id">
+          </el-option>
+        </el-select>
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+      </el-form-item>
+    </el-form>
+
+    <!-- 操作按钮 -->
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="1.5">
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          @click="handleExport">导出</el-button>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <!-- 数据表格 -->
+    <el-table v-loading="loading" :data="statisticsList" border>
+      <!-- 基本信息 -->
+      <el-table-column label="统计日期" align="center" prop="day" width="100">
+        <template slot-scope="scope">
+          {{ parseDay(scope.row.day) }}
+        </template>
+      </el-table-column>
+
+<!--      <el-table-column label="统计门店" align="center" prop="day" width="100">-->
+<!--        <template slot-scope="scope">-->
+<!--          {{ scope.row.storeName }}-->
+<!--        </template>-->
+<!--      </el-table-column>-->
+
+      <!-- 总计统计 -->
+      <el-table-column label="总计" align="center">
+        <el-table-column label="订单总数" align="center" width="100">
+          <template slot-scope="scope">
+            {{ scope.row.clothOrderCount + scope.row.goodsOrderCount }}
+          </template>
+        </el-table-column>
+        <el-table-column label="订单总额" align="center" width="120">
+          <template slot-scope="scope">
+            {{ (scope.row.clothOrderAmount + scope.row.goodsOrderAmount).toFixed(2) }}
+          </template>
+        </el-table-column>
+        <el-table-column label="总支付金额" align="center" width="120">
+          <template slot-scope="scope">
+            {{ calculateTotalPayAmount(scope.row) }}
+          </template>
+        </el-table-column>
+        <el-table-column label="总退款金额" align="center" width="120">
+          <template slot-scope="scope">
+            {{ calculateTotalRefundAmount(scope.row) }}
+          </template>
+        </el-table-column>
+      </el-table-column>
+
+      <!-- 洗衣订单统计 -->
+      <el-table-column label="洗衣订单" align="center">
+        <el-table-column label="订单数" align="center" prop="clothOrderCount" width="90" />
+        <el-table-column label="衣物件数" align="center" prop="clothCount" width="90" />
+        <el-table-column label="订单总额" align="center" prop="clothOrderAmount" width="100" />
+        <el-table-column label="支付金额" align="center">
+          <el-table-column label="微信支付" align="center" prop="clothWechatAmount" width="100" />
+          <el-table-column label="支付宝" align="center" prop="clothAlipayAmount" width="100" />
+          <el-table-column label="现金" align="center" prop="clothCashAmount" width="100" />
+          <el-table-column label="会员卡" align="center" prop="clothMemberAmount" width="100" />
+        </el-table-column>
+        <el-table-column label="退款金额" align="center">
+          <el-table-column label="微信退款" align="center" prop="clothWechatRefundAmount" width="100" />
+          <el-table-column label="支付宝退款" align="center" prop="clothAlipayRefundAmount" width="100" />
+          <el-table-column label="现金退款" align="center" prop="clothCashRefundAmount" width="100" />
+          <el-table-column label="会员卡退款" align="center" prop="clothMemberRefundAmount" width="100" />
+        </el-table-column>
+      </el-table-column>
+
+      <!-- 商品订单统计 -->
+      <el-table-column label="商品订单" align="center">
+        <el-table-column label="订单数" align="center" prop="goodsOrderCount" width="90" />
+        <el-table-column label="订单总额" align="center" prop="goodsOrderAmount" width="100" />
+        <el-table-column label="支付金额" align="center">
+          <el-table-column label="微信支付" align="center" prop="goodsWechatAmount" width="100" />
+          <el-table-column label="支付宝" align="center" prop="goodsAlipayAmount" width="100" />
+          <el-table-column label="现金" align="center" prop="goodsCashAmount" width="100" />
+          <el-table-column label="会员卡" align="center" prop="goodsMemberAmount" width="100" />
+        </el-table-column>
+        <el-table-column label="退款金额" align="center">
+          <el-table-column label="微信退款" align="center" prop="goodsWechatRefundAmount" width="100" />
+          <el-table-column label="支付宝退款" align="center" prop="goodsAlipayRefundAmount" width="100" />
+          <el-table-column label="现金退款" align="center" prop="goodsCashRefundAmount" width="100" />
+          <el-table-column label="会员卡退款" align="center" prop="goodsMemberRefundAmount" width="100" />
+        </el-table-column>
+      </el-table-column>
+    </el-table>
+
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+  </div>
+</template>
+
+<script>
+import { listStatisticsByDate, getTotalStatistics, listplatformStatisticsByDay } from '@/api/settlement/statistics'
+import { listStore } from "@/api/system/store";
+import CountTo from 'vue-count-to'
+
+export default {
+  name: "PlatformStatisticsByDate",
+  components: {
+    CountTo
+  },
+  data() {
+    return {
+      // 遮罩层
+      loading: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // 统计列表
+      statisticsList: [],
+      // 总统计数据
+      totalStatistics: {},
+      // 门店选项
+      storeOptions: [],
+      // 日期范围
+      dateRange: [],
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        startDate: null,
+        endDate: null,
+        storeId: null
+      },
+      // 日期选择器配置
+      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() {
+    // 设置默认日期范围为最近半个月
+    const end = new Date();
+    const start = new Date();
+    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.getList();
+    this.getStoreOptions();
+  },
+  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;
+      }
+    },
+    // 解析日期显示
+    parseDay(day) {
+      if (!day) return '';
+      const str = day.toString();
+      return `${str.substring(0, 4)}-${str.substring(4, 6)}-${str.substring(6, 8)}`;
+    },
+    // 计算总支付金额
+    calculateTotalPayAmount(row) {
+      const clothPay = (row.clothWechatAmount || 0) +
+        (row.clothAlipayAmount || 0) +
+        (row.clothCashAmount || 0) +
+        (row.clothMemberAmount || 0);
+      const goodsPay = (row.goodsWechatAmount || 0) +
+        (row.goodsAlipayAmount || 0) +
+        (row.goodsCashAmount || 0) +
+        (row.goodsMemberAmount || 0);
+      return (clothPay + goodsPay).toFixed(2);
+    },
+    // 计算总退款金额
+    calculateTotalRefundAmount(row) {
+      const clothRefund = (row.clothWechatRefundAmount || 0) +
+        (row.clothAlipayRefundAmount || 0) +
+        (row.clothCashRefundAmount || 0) +
+        (row.clothMemberRefundAmount || 0);
+      const goodsRefund = (row.goodsWechatRefundAmount || 0) +
+        (row.goodsAlipayRefundAmount || 0) +
+        (row.goodsCashRefundAmount || 0) +
+        (row.goodsMemberRefundAmount || 0);
+      return (clothRefund + goodsRefund).toFixed(2);
+    },
+    /** 查询统计列表 */
+    getList() {
+      this.loading = true;
+      listplatformStatisticsByDay(this.queryParams).then(response => {
+        this.statisticsList = response.rows;
+        this.total = response.total;
+        this.loading = false;
+      });
+      // 获取总统计数据
+      // getTotalStatistics(this.queryParams).then(response => {
+      //   this.totalStatistics = response.data;
+      // });
+    },
+    /** 获取门店选项 */
+    getStoreOptions() {
+      listStore().then(response => {
+        this.storeOptions = response.rows;
+      });
+
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      // 重置日期范围为最近半个月
+      const end = new Date();
+      const start = new Date();
+      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.handleQuery();
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+      this.$confirm('是否确认导出所有日期统计数据项?', "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(() => {
+        this.download('/mapi/platform/statistics/order/byday/export', {
+          ...this.queryParams
+        }, `工厂日期报表统计_${new Date().getTime()}.xlsx`);
+      });
+    }
+  }
+};
+</script>
+
+<style scoped>
+.mb8 {
+  margin-bottom: 8px;
+}
+.card-body {
+  font-size: 24px;
+  font-weight: bold;
+  text-align: center;
+  color: #409EFF;
+}
+</style>

+ 282 - 0
admin-ui/src/views/order/statistics/byfactory.vue

@@ -0,0 +1,282 @@
+<template>
+  <div class="app-container">
+    <!-- 搜索表单 -->
+    <el-form :model="queryParams" ref="queryForm" @submit.native.prevent :inline="true" v-show="showSearch" label-width="68px">
+      <el-form-item label="日期范围" prop="dateRange">
+        <el-date-picker
+          v-model="dateRange"
+          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 label="工厂" prop="factoryId">
+        <el-select v-model="queryParams.factoryId" placeholder="请选择工厂" clearable>
+          <el-option
+            v-for="store in factorys"
+            :key="store.id"
+            :label="store.factoryName"
+            :value="store.id">
+          </el-option>
+        </el-select>
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+      </el-form-item>
+    </el-form>
+
+    <!-- 操作按钮 -->
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="1.5">
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          @click="handleExport">导出</el-button>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <!-- 统计卡片 -->
+<!--    <el-row :gutter="20" class="mb8">-->
+<!--      <el-col :span="6">-->
+<!--        <el-card shadow="hover">-->
+<!--          <div slot="header">-->
+<!--            <span>总入厂衣服数</span>-->
+<!--          </div>-->
+<!--          <div class="card-body">-->
+<!--            <count-to :startVal="0" :endVal="totalStatistics.dailyInFactoryCount || 0" :duration="2000"></count-to>-->
+<!--          </div>-->
+<!--        </el-card>-->
+<!--      </el-col>-->
+<!--      <el-col :span="6">-->
+<!--        <el-card shadow="hover">-->
+<!--          <div slot="header">-->
+<!--            <span>总入厂金额</span>-->
+<!--          </div>-->
+<!--          <div class="card-body">-->
+<!--            <count-to :startVal="0" :endVal="totalStatistics.dailyInFactoryAmount || 0" :duration="2000" :decimals="2" prefix="¥"></count-to>-->
+<!--          </div>-->
+<!--        </el-card>-->
+<!--      </el-col>-->
+<!--      <el-col :span="6">-->
+<!--        <el-card shadow="hover">-->
+<!--          <div slot="header">-->
+<!--            <span>总退单数</span>-->
+<!--          </div>-->
+<!--          <div class="card-body">-->
+<!--            <count-to :startVal="0" :endVal="totalStatistics.dailyRefundCount || 0" :duration="2000"></count-to>-->
+<!--          </div>-->
+<!--        </el-card>-->
+<!--      </el-col>-->
+<!--      <el-col :span="6">-->
+<!--        <el-card shadow="hover">-->
+<!--          <div slot="header">-->
+<!--            <span>实际结算金额</span>-->
+<!--          </div>-->
+<!--          <div class="card-body">-->
+<!--            <count-to :startVal="0" :endVal="totalStatistics.dailyActualSettlementAmount || 0" :duration="2000" :decimals="2" prefix="¥"></count-to>-->
+<!--          </div>-->
+<!--        </el-card>-->
+<!--      </el-col>-->
+<!--    </el-row>-->
+
+    <!-- 数据表格 -->
+    <el-table v-loading="loading" :data="statisticsList" border>
+      <el-table-column label="工厂" align="center" prop="factoryName" />
+      <el-table-column label="入厂金额" align="center" prop="dailyInFactoryAmount">
+        <template slot-scope="scope">
+          ¥{{ scope.row.dailyInFactoryAmount }}
+        </template>
+      </el-table-column>
+      <el-table-column label="退单金额" align="center" prop="dailyRefundAmount">
+        <template slot-scope="scope">
+          ¥{{ scope.row.dailyRefundAmount }}
+        </template>
+      </el-table-column>
+      <el-table-column label="实际结算金额" align="center" prop="dailyActualSettlementAmount">
+        <template slot-scope="scope">
+          ¥{{ scope.row.dailyActualSettlementAmount }}
+        </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-column label="退单数" align="center" prop="dailyRefundCount" />
+    </el-table>
+
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+  </div>
+</template>
+
+<script>
+import { listStatisticsByDate, getTotalStatistics, listplatformStatisticsByFactory } from '@/api/settlement/statistics'
+import { listStore } from "@/api/system/store";
+import CountTo from 'vue-count-to'
+import { listFactory } from '@/api/system/factory'
+
+export default {
+  name: "FactoryStatisticsByDate",
+  components: {
+    CountTo
+  },
+  data() {
+    return {
+      // 遮罩层
+      loading: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // 统计列表
+      statisticsList: [],
+      // 总统计数据
+      totalStatistics: {},
+      // 门店选项
+      factorys: [],
+      // 日期范围
+      dateRange: [],
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        startDate: null,
+        endDate: null,
+        factoryId: null
+      },
+      // 日期选择器配置
+      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() {
+    // 设置默认日期范围为最近半个月
+    const end = new Date();
+    const start = new Date();
+    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.getList();
+    this.getStoreOptions();
+  },
+  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;
+      listplatformStatisticsByFactory(this.queryParams).then(response => {
+        this.statisticsList = response.rows;
+        this.total = response.total;
+        this.loading = false;
+      });
+      // 获取总统计数据
+      // getTotalStatistics(this.queryParams).then(response => {
+      //   this.totalStatistics = response.data;
+      // });
+    },
+    /** 获取门店选项 */
+    getStoreOptions() {
+      listFactory().then(response => {
+        this.factorys = response.rows;
+      });
+
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      // 重置日期范围为最近半个月
+      const end = new Date();
+      const start = new Date();
+      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.handleQuery();
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+      this.$confirm('是否确认导出所有工厂统计数据项?', "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(() => {
+        this.download('/mapi/platform/statistics/order/byfactory/export', {
+          ...this.queryParams
+        }, `工厂日期报表统计_${new Date().getTime()}.xlsx`);
+      });
+    }
+  }
+};
+</script>
+
+<style scoped>
+.mb8 {
+  margin-bottom: 8px;
+}
+.card-body {
+  font-size: 24px;
+  font-weight: bold;
+  text-align: center;
+  color: #409EFF;
+}
+</style>

+ 82 - 0
yiqi-admin/src/main/java/com/yiqi/admin/controller/settlement/PlatformStatisticsController.java

@@ -93,4 +93,86 @@ public class PlatformStatisticsController extends BaseController {
         return getDataTable(settlementStoreStatistics);
     }
 
+    /**
+     * 获取门店每日订单统计列表
+     */
+    @GetMapping("/order/byday")
+    public TableDataInfo generateStatisticsByDay(@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<SettlementStoreStatistics> statisticsList = settlementStoreStatisticsService.generateStatisticsByDay(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/byfactory")
+    public TableDataInfo generateStatisticsByFactory(@RequestParam(required = false) String startDate,
+                                                     @RequestParam(required = false) String endDate,
+                                                     @RequestParam(required = false) Long factoryId,
+                                                     @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 = settlementStoreStatisticsService.generateStatisticsByFactory(factoryId, 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);
+    }
+
+    /**
+     *
+     */
+    @PostMapping("/order/byday/export")
+    public void dayExport(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<SettlementStoreStatistics> statisticsList = settlementStoreStatisticsService.generateStatisticsByDay(storeId, start, end);
+        ExcelUtil<SettlementStoreStatistics> util = new ExcelUtil<>(SettlementStoreStatistics.class);
+        util.hideColumn("id", "storeId", "storeName");
+        util.exportExcel(response, statisticsList, "按日期报表统计");
+    }
+
+
+    /**
+     *
+     */
+    @PostMapping("/order/byfactory/export")
+    public void factoryExport(HttpServletResponse response,
+                              @RequestParam(required = false) String startDate,
+                              @RequestParam(required = false) String endDate,
+                              @RequestParam(required = false) Long factoryId) {
+        Date start = startDate != null ? DateUtils.parseDate(startDate) : DateUtils.addDays(new Date(), -14);
+        Date end = endDate != null ? DateUtils.parseDate(endDate) : new Date();
+        List<SettlementFactoryStatisticsDto> statisticsList = settlementStoreStatisticsService.generateStatisticsByFactory(factoryId, start, end);
+        ExcelUtil<SettlementFactoryStatisticsDto> util = new ExcelUtil<>(SettlementFactoryStatisticsDto.class);
+        util.hideColumn("id", "storeId", "storeName", "factoryId", "statisticsDate");
+        util.exportExcel(response, statisticsList, "工厂报表统计");
+    }
 }

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

@@ -64,7 +64,6 @@ public class SettlementStoreStatistics extends BaseEntity {
     /**
      * 预约数量
      */
-    @Excel(name = "预约数量")
     @ApiModelProperty("预约数量")
     private Integer clothAppointCount;
 

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

@@ -5,6 +5,7 @@ import java.util.List;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.yiqi.core.domain.SettlementStoreStatistics;
+import com.yiqi.order.domain.dto.SettlementFactoryStatisticsDto;
 import com.yiqi.settlement.domain.dto.StoreChargeStatistics;
 
 /**
@@ -152,5 +153,19 @@ public interface ISettlementStoreStatisticsService extends IService<SettlementSt
      */
     List<SettlementStoreStatistics> generateStoreStatisticsByStore(Date start);
 
+    /**
+     * 生成门店每日统计数据*
+     *
+     * @param date
+     * @return
+     */
+    List<SettlementStoreStatistics> generateStatisticsByDay(Long storeId, Date start, Date end);
 
+    /**
+     * 生成工厂每日统计数据*
+     *
+     * @param date
+     * @return
+     */
+    List<SettlementFactoryStatisticsDto> generateStatisticsByFactory(Long factoryId, Date start, Date end);
 }

+ 5 - 1
yiqi-common/src/main/java/com/yiqi/order/domain/dto/SettlementFactoryStatisticsDto.java

@@ -35,7 +35,6 @@ public class SettlementFactoryStatisticsDto implements Serializable {
 
     /** 统计日期 */
     @ApiModelProperty("统计日期")
-    @Excel(name = "统计日期")
     private Integer day;
 
     /** 工厂ID */
@@ -46,6 +45,11 @@ public class SettlementFactoryStatisticsDto implements Serializable {
     @ApiModelProperty("门店ID")
     private Long storeId;
 
+    /** 工厂名称 */
+    @Excel(name = "工厂名称")
+    @ApiModelProperty("工厂名称")
+    private String factoryName;
+
     /** 门店名称 */
     @Excel(name = "门店名称")
     @ApiModelProperty("门店名称")

+ 0 - 6
yiqi-common/src/main/java/com/yiqi/order/domain/vo/OrderRechargePrintVO.java

@@ -23,12 +23,6 @@ import java.util.List;
 @Data
 public class OrderRechargePrintVO extends OrderRecharge {
 
-    /**
-     * 订单详情
-     */
-    @ApiModelProperty("衣服详情")
-    List<OrderClothItemVO> orderClothItemVOS;
-
     @ApiModelProperty("客户信息")
     private AppUserInfoVO appUserInfoVO;
 

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

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

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

@@ -126,7 +126,7 @@ public class SettlementFactoryStatisticsServiceImpl implements ISettlementFactor
     public SettlementFactoryStatisticsDto generateTotalFactoryStatistics(Long factoryId, Long storeId, Date start, Date end) {
         // 1. 查询指定日期范围内的所有订单衣服记录
         QueryWrapper<OrderClothItem> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("factory_id", factoryId)
+        queryWrapper.eq( "factory_id", factoryId)
                 .eq(storeId != null, "org_id", storeId)
                 .ge("flow_status", 1)
                 .ge("in_factory_time", DateUtils.addDays(start, -2))

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

@@ -4,6 +4,7 @@ import java.util.*;
 import java.math.BigDecimal;
 import java.util.stream.Collectors;
 
+import cn.binarywang.wx.miniapp.api.WxMaShopAfterSaleService;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -15,6 +16,7 @@ import com.yiqi.common.utils.CurrencyUtil;
 import com.yiqi.common.utils.DateUtils;
 import com.yiqi.common.utils.SecurityUtils;
 import com.yiqi.core.service.ISettlementManageBillService;
+import com.yiqi.core.service.ISettlementStoreClothStatisticsService;
 import com.yiqi.order.domain.OrderRecharge;
 import com.yiqi.order.domain.OrderRechargeRefund;
 import com.yiqi.order.domain.dto.SettlementFactoryStatisticsDto;
@@ -24,7 +26,9 @@ import com.yiqi.settlement.domain.dto.OrderStatisticsVO;
 import com.yiqi.settlement.domain.dto.PaymentStatisticsVO;
 import com.yiqi.settlement.domain.dto.StoreBillStatistics;
 import com.yiqi.settlement.domain.dto.StoreChargeStatistics;
+import com.yiqi.system.domain.ManageFactory;
 import com.yiqi.system.domain.SysStore;
+import com.yiqi.system.service.IManageFactoryService;
 import com.yiqi.system.service.ISysStoreService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -57,6 +61,12 @@ public class SettlementStoreStatisticsServiceImpl extends ServiceImpl<Settlement
     @Autowired
     private IOrderRechargeRefundService orderRechargeRefundService;
 
+    @Autowired
+    private ISettlementStoreClothStatisticsService settlementStoreClothStatisticsService;
+
+    @Autowired
+    private IManageFactoryService factoryService;
+
     /**
      * 查询门店每日统计
      *
@@ -82,6 +92,9 @@ public class SettlementStoreStatisticsServiceImpl extends ServiceImpl<Settlement
     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;
+        if (startDay != null && startDay.equals(endDay)) {
+            return baseMapper.orderStatisticsByDate(storeId, startDay);
+        }
         return baseMapper.orderStatistics(storeId, startDay, endDay);
     }
 
@@ -116,6 +129,42 @@ public class SettlementStoreStatisticsServiceImpl extends ServiceImpl<Settlement
         return result;
     }
 
+    @Override
+    public List<SettlementStoreStatistics> generateStatisticsByDay(Long storeId, Date start, Date end) {
+        // 1. 获取日期范围内的所有日期
+        List<Date> dateList = new ArrayList<>();
+        Date currentDate = end;
+        while (currentDate.after(start)) {
+            dateList.add(currentDate);
+            currentDate = DateUtils.addDays(currentDate, -1);
+        }
+        List<SettlementStoreStatistics> statisticsList = new ArrayList<>();
+        // 3. 为每个日期生成统计数据
+        for (Date date : dateList) {
+            SettlementStoreStatistics statistics = orderStatistics(storeId, date, date);
+            statistics.setDay(Integer.parseInt(DateUtil.format(date, "yyyyMMdd")));
+            statisticsList.add(statistics);
+        }
+        return statisticsList;
+    }
+
+    @Override
+    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(ManageFactory::getStatus, StatusType.OK.getCode())
+                .eq(ManageFactory::getDelFlag, StatusType.OK.getCode()));
+        List<SettlementFactoryStatisticsDto> statisticsList = new ArrayList<>();
+        // 3. 为每个日期生成统计数据
+        for (ManageFactory factory : factoryList) {
+            SettlementFactoryStatisticsDto statistics = settlementStoreClothStatisticsService.totalByCondition(factory.getId(), null, start, end);
+            statistics.setFactoryName(factory.getFactoryName());
+            statisticsList.add(statistics);
+        }
+        return statisticsList;
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void generateDayStatistics(Date date) {

+ 1 - 0
yiqi-core/src/main/resources/mapper/core/SettlementStoreClothStatisticsMapper.xml

@@ -7,6 +7,7 @@
 
     <select id="totalByCondition" resultType="com.yiqi.order.domain.dto.SettlementFactoryStatisticsDto">
         select
+        factory_id as factoryId,
         COALESCE(SUM(daily_in_factory_amount), 0) AS dailyInFactoryAmount,
         COALESCE(SUM(daily_in_factory_count), 0) AS dailyInFactoryCount,
         COALESCE(SUM(daily_checked_count), 0) AS dailyCheckedCount,

+ 163 - 116
yiqi-core/src/main/resources/mapper/core/SettlementStoreStatisticsMapper.xml

@@ -252,131 +252,129 @@
     <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
+            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} 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
+            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} 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
+        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 1 = 1
         <if test="startDay!=null">
             and  day >= #{startDay}
@@ -389,5 +387,54 @@
         </if>
     </select>
 
+    <select id="orderStatisticsByDate" resultType="com.yiqi.core.domain.SettlementStoreStatistics">
+        select
+        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 1 = 1
+        <if test="day!=null">
+            and  day = #{day}
+        </if>
+        <if test="storeId != null">
+            and store_id = #{storeId}
+        </if>
+    </select>
+
 
 </mapper>