Просмотр исходного кода

增加红包列表,退货计算问题处理

liyuan 1 неделя назад
Родитель
Сommit
480c39b039

+ 9 - 0
src/api/redPacket/index.js

@@ -0,0 +1,9 @@
+import request from "@/router/axios";
+
+export const getCouponReportList = (params) => {
+    return request({
+        url: '/api/blade-sales-part/tire/coupon/getCouponReportList',
+        method: 'get',
+        params: params
+    })
+}

+ 6 - 2
src/views/tirePartsMall/salesService/returns/detailsPage.vue

@@ -790,7 +790,11 @@ export default {
         row.returnsNumber = 0;
         this.$message.error("退货数量不能超过销售数量");
       }
-      row.returnsAmount = _.round(_.multiply(row.returnsNumber, row.price) - _.multiply(row.returnsNumber, Number(row.redPacketAmount)), 2);
+      if (Number(row.redPacketCount) > 0) {
+          row.returnsNumber = row.goodsNum;
+          this.$message.error("使用红包的退货必须全退");
+      }
+      row.returnsAmount = _.round(_.multiply(row.returnsNumber, row.price) - _.multiply((Number(row.returnsNumber) > row.redPacketCount ? row.redPacketCount : row.returnsNumber), Number(row.redPacketAmount)), 2);
     },
     generateData(data) {
       generateReturns({ id: data.id }).then(res => {
@@ -802,7 +806,7 @@ export default {
         });
         if (res.data.data.orderItemsList.length > 0) {
           res.data.data.orderItemsList.forEach(e => {
-            e.returnsAmount = _.round(_.multiply(e.returnsNumber, e.price) - _.multiply(e.returnsNumber, Number(e.redPacketAmount)), 2);
+            e.returnsAmount = _.round(_.multiply(e.returnsNumber, e.price) - _.multiply((Number(e.returnsNumber) > e.redPacketCount ? e.redPacketCount : e.returnsNumber), Number(e.redPacketAmount)), 2);
           });
         }
 

+ 148 - 0
src/views/tirePartsMall/statisticAnalysis/red-packet/index.vue

@@ -0,0 +1,148 @@
+<template>
+    <div class="coupon-statistics">
+        <el-card shadow="never">
+            <el-form :model="searchForm" inline size="small" label-width="100px">
+                <el-form-item label="客户名称">
+                    <el-input v-model="searchForm.storeName" placeholder="请输入客户名称" clearable />
+                </el-form-item>
+
+                <el-form-item label="领取日期">
+                    <el-date-picker
+                        v-model="searchForm.dateRange"
+                        type="daterange"
+                        range-separator="to"
+                        start-placeholder="请选择起始领取日期"
+                        end-placeholder="请选择结束领取日期"
+                        value-format="yyyy-MM-dd"
+                    />
+                </el-form-item>
+
+                <el-form-item>
+                    <el-button type="primary" icon="el-icon-search" @click="handleSearch">查询</el-button>
+                    <el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
+                </el-form-item>
+            </el-form>
+
+            <!-- Data Table -->
+            <el-table
+                :data="tableData"
+                border
+                style="width: 100%; margin-top: 16px;"
+                v-loading="loading"
+                element-loading-text="Loading..."
+            >
+                <el-table-column prop="storeName" label="客户名称" min-width="180" />
+                <el-table-column prop="claimDate" label="领取日期" width="150" align="center" />
+                <el-table-column prop="amount" label="金额 (¥)" width="120" align="center">
+                    <template slot-scope="scope">
+                        {{ scope.row.amount | currency }}
+                    </template>
+                </el-table-column>
+                <el-table-column prop="claimedCount" label="已领取优惠券" width="130" align="center" />
+                <el-table-column prop="usedCount" label="已使用优惠券" width="120" align="center" />
+                <el-table-column prop="returnedCouponCount" label="已退货优惠券" width="120" align="center" />
+            </el-table>
+
+            <!-- Pagination -->
+            <div class="pagination-wrapper" style="margin-top: 16px; text-align: right;">
+                <el-pagination
+                    @size-change="handleSizeChange"
+                    @current-change="handleCurrentChange"
+                    :current-page.sync="pagination.current"
+                    :page-sizes="[10, 20, 50, 100]"
+                    :page-size="pagination.size"
+                    layout="total, sizes, prev, pager, next, jumper"
+                    :total="pagination.total"
+                />
+            </div>
+        </el-card>
+    </div>
+</template>
+
+<script>
+import { getCouponReportList } from "@/api/redPacket/index";
+export default {
+    name: 'CouponStatistics',
+    filters: {
+        currency(val) {
+            if (val == null) return '0.00';
+            return parseFloat(val).toFixed(2);
+        }
+    },
+    data() {
+        return {
+            loading: false,
+            searchForm: {
+                storeName: '',
+                dateRange: []
+            },
+            tableData: [],
+            pagination: {
+                current: 1,
+                size: 20,
+                total: 0
+            }
+        };
+    },
+    created() {
+        this.fetchData();
+    },
+    methods: {
+        async fetchData() {
+            this.loading = true;
+            try {
+                const params = {
+                    current: this.pagination.current,
+                    size: this.pagination.size,
+                    storeName: this.searchForm.storeName || undefined,
+                    startDate: this.searchForm.dateRange ? this.searchForm.dateRange[0] : null,
+                    endDate: this.searchForm.dateRange ? this.searchForm.dateRange[1] : null
+                };
+
+                const res = await getCouponReportList(params)
+                console.info('res----', res);
+                this.tableData = res.data.data.records || [];
+                this.pagination.total = res.data.data.total || 0;
+            } catch (error) {
+                this.$message.error('Failed to load data');
+                console.error(error);
+            } finally {
+                this.loading = false;
+            }
+        },
+
+        handleSearch() {
+            this.pagination.current = 1;
+            this.fetchData();
+        },
+
+        handleReset() {
+            this.searchForm = {
+                storeName: '',
+                dateRange: []
+            };
+            this.pagination.current = 1;
+            this.fetchData();
+        },
+
+        handleSizeChange(val) {
+            this.pagination.size = val;
+            this.fetchData();
+        },
+
+        handleCurrentChange(val) {
+            this.pagination.current = val;
+            this.fetchData();
+        }
+    }
+};
+</script>
+
+<style scoped>
+.coupon-statistics {
+    padding: 20px;
+}
+.pagination-wrapper {
+    margin-top: 16px;
+}
+</style>