Explorar el Código

直播优惠券添加 积分管理

yuhongqi hace 1 semana
padre
commit
fd13845afd

+ 19 - 0
src/api/live/liveRewardRecord.js

@@ -0,0 +1,19 @@
+import request from '@/utils/request'
+
+
+export function statistics(query) {
+  return request({
+    url: '/live/record/statistics',
+    method: 'post',
+    data: query
+  })
+}
+
+export function exportLiveIntegral(data) {
+  return request({
+    url: '/live/record/export',
+    method: 'post',
+    data: data
+  })
+}
+

+ 2 - 0
src/views/live/liveConfig/goods.vue

@@ -1,4 +1,5 @@
 <template>
+  <div class="app-container">
   <div class="el-container-md">
 
     <div class="selection-toolbar">
@@ -251,6 +252,7 @@
     </el-dialog>
 
   </div>
+  </div>
 </template>
 
 <script>

+ 3 - 0
src/views/live/liveConfig/liveCoupon.vue

@@ -1,4 +1,5 @@
 <template>
+  <div class="app-container">
   <div class="el-container-md">
 
     <div class="selection-toolbar">
@@ -185,6 +186,7 @@
           <el-select
             v-model="goodsForm.goodsId"
             placeholder="请选择商品"
+            filterable
             style="width: 100%;"
             @change="handleGoodsChange"
           >
@@ -203,6 +205,7 @@
       </div>
     </el-dialog>
   </div>
+  </div>
 </template>
 
 <script>

+ 13 - 0
src/views/live/liveConsole/index.vue

@@ -147,6 +147,10 @@
           <i class="el-icon-goods" style="font-size: 20px;"></i>
           <span style="font-size: 12px; margin-top: 4px;">直播订单</span>
         </div>
+        <div style="display: flex; flex-direction: column; align-items: center; cursor: pointer;" @click="handleClickCoupon">
+          <i class="el-icon-goods" style="font-size: 20px;"></i>
+          <span style="font-size: 12px; margin-top: 4px;">直播优惠券</span>
+        </div>
       </div>
       <el-radio-group v-model="tableRadio" >
         <el-radio-button label="订单数">订单数</el-radio-button>
@@ -262,6 +266,7 @@ import Hls from 'hls.js';
 import LiveLotteryConf from '@/views/live/liveConfig/liveLotteryConf.vue'
 import LiveRedConf from '@/views/live/liveConfig/liveRedConf.vue'
 import LiveGoods from '@/views/live/liveConfig/goods.vue'
+import LiveCoupon from '@/views/live/liveConfig/liveCoupon.vue'
 import echarts from 'echarts'
 
 export default {
@@ -544,6 +549,14 @@ export default {
         }
       })
     },
+    handleClickCoupon(){
+      this.$router.push({
+        name: 'LiveCoupon',
+        query: {
+          liveId: this.liveId
+        }
+      })
+    },
     getLive(){
       getLive(this.liveId).then(res => {
         if (res.code == 200) {

+ 170 - 0
src/views/live/liveRewardRecord/index.vue

@@ -0,0 +1,170 @@
+<template>
+  <div class="app-container">
+    <div class="reward-container">
+      <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
+        <el-form-item label="公司名" prop="companyId">
+          <el-select filterable  v-model="queryParams.companyId" placeholder="请选择公司名"  @change="companyChange" clearable size="small">
+            <el-option
+              v-for="item in companys"
+              :key="item.companyId"
+              :label="item.companyName"
+              :value="item.companyId"
+            />
+          </el-select>
+        </el-form-item>
+
+        <el-form-item label="查询日期" prop="step">
+          <el-date-picker
+            type="month"
+            v-model="selectedTimeStep"
+            @change="handleTimeStepChange"
+            placeholder="选择一个日期">
+          </el-date-picker>
+        </el-form-item>
+        <el-form-item>
+          <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+          <el-button
+            type="warning"
+            plain
+            icon="el-icon-download"
+            size="mini"
+            :loading="exportLoading"
+            @click="handleExport"
+            style="margin-left: 10px"
+            v-hasPermi="['live:liveRewardRecord:export']"
+          >导出</el-button>
+        </el-form-item>
+      </el-form>
+      <!-- 时间步长选择 -->
+      <span class="demonstration">月份选择(可多选)</span>
+
+    </div>
+
+    <!-- 直播间数据表格 + 总消耗 -->
+    <div style="margin-top: 24px;">
+      <h3 style="font-size: 16px; font-weight: 600; margin-bottom: 12px;">直播间积分消耗明细</h3>
+      <el-table
+        :data="tableData"
+        border
+        show-summary
+        stripe
+        style="width: 100%; margin-bottom: 12px;"
+      >
+        <el-table-column label="直播名称" prop="liveNameAndId" width="100" align="center" />
+        <el-table-column
+          v-for="(date, index) in timeSeries"
+          :key="index"
+          :label="date"
+          align="center"
+        >
+          <template #default="scope">
+            {{ scope.row.dailyData[index] || '-' }}
+          </template>
+        </el-table-column>
+        <el-table-column label="单直播间总计" prop="total" width="120" align="center" />
+      </el-table>
+    </div>
+  </div>
+</template>
+
+<script>
+import { statistics,exportLiveIntegral } from '@/api/live/liveRewardRecord'
+import Treeselect from "@riophae/vue-treeselect";
+import {getCompanyList} from "@/api/company/company";
+
+export default {
+  name: 'liveRewardRecord',
+  components: {Treeselect},
+  data() {
+    return {
+      exportLoading: false,
+      selectedTimeStep: new Date(),
+      showSearch:true,
+      companys:[],
+      tableData: [],
+      chartSeries: [],
+      timeSeries: [],
+      queryParams:{
+        companyId:0,
+        step: []
+      },
+      colorList: [
+        '#34a853', '#fbbc05', '#4285f4', '#ea4335', '#9c27b0',
+        '#ff9800', '#673ab7', '#e91e63', '#00bcd4', '#8bc34a'
+      ]
+    }
+  },
+  created() {
+    getCompanyList().then(response => {
+      this.companys = response.data;
+      this.companys.push({companyId:0,companyName:"全部公司"})
+      console.log(this.companys)
+      this.companyId=this.companys[0].companyId;
+      this.queryParams.companyId=this.companyId;
+      this.initData()
+    });
+  },
+  methods: {
+    handleExport(){
+      if(this.selectedTimeStep == null || this.selectedTimeStep.length < 1) {
+        this.$message.error('请选择导出月份')
+        return
+      }
+      this.queryParams.step=[]
+      this.queryParams.step.push(this.selectedTimeStep);
+      this.$confirm('是否确认导出所有直播积分记录?', "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(() => {
+        this.exportLoading = true;
+        return exportLiveIntegral(this.queryParams);
+      }).then(response => {
+        this.download(response.msg);
+        this.exportLoading = false;
+      }).catch(() => {});
+    },
+    handleQuery(){
+      this.initData()
+    },
+    resetQuery(){
+      this.resetForm("queryForm");
+      this.queryParams.companyId=this.companyId;
+      this.handleQuery();
+    },
+    companyChange(){
+
+    },
+    initData() {
+      this.queryParams.step=[]
+      this.queryParams.step.push(this.selectedTimeStep);
+      statistics(this.queryParams).then(res => {
+        this.timeSeries = res.timeSeries || []
+        this.tableData = res.data || []
+
+
+        this.processTableData()
+      }).catch(err => {
+        console.error('数据加载失败:', err)
+        this.$message.error('数据加载失败,请重试')
+      })
+    },
+    processTableData() {
+      const liveList = this.tableData
+      this.tableData = liveList.map(liveItem => {
+        const dailyData = liveItem.dataList || []
+        const total = dailyData.reduce((sum, num) => sum + (num || 0), 0)
+        return { liveNameAndId: liveItem.liveNameAndId, dailyData, total }
+      })
+    },
+    handleTimeStepChange() {
+      // this.initData()
+    },
+  }
+}
+</script>
+
+<style scoped>
+
+</style>