Pārlūkot izejas kodu

Merge branch 'master' of http://git.echepei.com/tire-platform/tire-platform-ui

Qukatie 1 dienu atpakaļ
vecāks
revīzija
7bd45bbeb6

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

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

+ 77 - 0
src/views/tirePartsMall/statisticAnalysis/red-packet/customer-order.vue

@@ -0,0 +1,77 @@
+<template>
+    <el-dialog
+        title="列表"
+        :visible.sync="centerDialogVisible"
+        width="60%"
+        append-to-body
+        center>
+
+        <el-table :data="orderData" border style="width: 100%; font-size: 14px;">
+            <el-table-column prop="customerName" label="客户名称"/>
+            <el-table-column prop="orderNo" label="订单编号">
+            </el-table-column>
+            <el-table-column prop="numberRows" label="行数"/>
+            <el-table-column prop="goodsNameJoin" show-overflow-tooltip label="商品名称"/>
+            <el-table-column prop="goodsTotalNum" label="总数量">
+                <template slot-scope="scope">
+                    {{ formatDecimal(scope.row.goodsTotalNum) }}
+                </template>
+            </el-table-column>
+
+            <el-table-column prop="totalMoney" label="总金额(元)">
+                <template slot-scope="scope">
+                    ¥{{ formatDecimal(scope.row.totalMoney) }}
+                </template>
+            </el-table-column>
+
+            <el-table-column prop="redPacketAmount" label="红包金额(元)">
+                <template slot-scope="scope">
+                    ¥{{ formatDecimal(scope.row.redPacketAmount) }}
+                </template>
+            </el-table-column>
+            <el-table-column prop="status" label="状态"/>
+            <el-table-column prop="businessDate" label="业务日期">
+                <template slot-scope="scope">
+                    {{ scope.row.businessDate }}
+                </template>
+            </el-table-column>
+        </el-table>
+
+<!--        <span slot="footer" class="dialog-footer">
+    <el-button @click="centerDialogVisible = false">取 消</el-button>
+    <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
+  </span>-->
+    </el-dialog>
+</template>
+
+<script>
+import { getCouponReportOrderList } from "@/api/redPacket/index";
+
+export default {
+    name: "CouponStatistics",
+    data() {
+        return {
+            centerDialogVisible: false,
+            orderData: []
+        };
+    },
+    created() {
+    },
+    methods: {
+        formatDecimal(value) {
+            if (value == null || value === '') return '0.00'
+            return parseFloat(value).toFixed(2)
+        },
+        getOrderDataList(customerId,checkType){
+            getCouponReportOrderList({customerId: customerId, checkType: checkType}).then(res => {
+                console.info('res---', res);
+                this.orderData = res.data.data;
+            })
+        }
+    }
+};
+</script>
+
+<style scoped>
+
+</style>

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

@@ -0,0 +1,165 @@
+<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="到"
+                        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">
+                    <template slot-scope="scope">
+                        <span style="color: blue" @click="openOrderData(scope.row.storeId, 1)">{{scope.row.usedCount}}</span>
+                    </template>
+                </el-table-column>
+                <el-table-column prop="returnedCouponCount" label="已退货优惠券" width="120" align="center">
+                    <template slot-scope="scope">
+                        <span style="color: blue" @click="openOrderData(scope.row.storeId, 0)">{{scope.row.returnedCouponCount}}</span>
+                    </template>
+                </el-table-column>
+            </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>
+        <customer-order ref="customerOrderRef" />
+    </div>
+</template>
+
+<script>
+import { getCouponReportList } from "@/api/redPacket/index";
+import customerOrder from "@/views/tirePartsMall/statisticAnalysis/red-packet/customer-order.vue";
+export default {
+    name: 'CouponStatistics',
+    components: {
+        customerOrder
+    },
+    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: {
+        openOrderData(customerId, checkType){
+            this.$refs.customerOrderRef.getOrderDataList(customerId, checkType)
+            this.$refs.customerOrderRef.centerDialogVisible = true
+        },
+        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>