Browse Source

优惠券功能

yuhongqi 1 ngày trước cách đây
mục cha
commit
9c7463951d

+ 22 - 4
src/api/company/company.js

@@ -31,7 +31,7 @@ export function resetPwd(companyId) {
     method: 'post'
   })
 }
- 
+
 
 
 // 修改企业
@@ -80,8 +80,8 @@ export function deduct(data) {
     data: data
   })
 }
- 
- 
+
+
 
 // 查询企业列表
 export function crmDayCountlist(query) {
@@ -90,4 +90,22 @@ export function crmDayCountlist(query) {
     method: 'get',
     params: query
   })
-}
+}
+
+// 批量修改公司显示状态
+export function batchUpdateCompanyLiveShow(data) {
+  return request({
+    url: '/company/company/batchUpdateLiveShow',
+    method: 'post',
+    data: data
+  })
+}
+
+// 查询企业列表
+export function liveShowList(query) {
+  return request({
+    url: '/company/company/liveShowList',
+    method: 'get',
+    params: query
+  })
+}

+ 9 - 0
src/api/live/liveCoupon.js

@@ -125,3 +125,12 @@ export function updateLiveCouponBind(data) {
   })
 }
 
+
+// 查询直播抽奖配置列表  未开启
+export function listLiveCouponOn(query) {
+  return request({
+    url: '/live/coupon/listOn',
+    method: 'get',
+    params: query
+  })
+}

+ 1 - 0
src/components/VideoUpload/index.vue

@@ -219,6 +219,7 @@ export default {
         videoType: -1,
         sort: null,
         remark: null,
+        finishStatus:1
       },
       liveQueryParams: {
         pageNum: 1,

+ 58 - 2
src/views/live/liveConfig/task.vue

@@ -194,6 +194,21 @@
             </div>
           </el-select>
         </el-form-item>
+        <el-form-item label="优惠券" prop="content" v-if="form.taskType == 5">
+          <el-select v-model="form.content" placeholder="请选择优惠券" ref="selectCoupon" >
+            <el-option v-for="i in couponOptions" :key="i.value" :label="i.label" :value="i.value"></el-option>
+            <!-- 加载载中状态 -->
+            <div v-if="isLoading" class="loading-indicator">
+              <i class="el-icon-loading"></i>
+              <span>加载中...</span>
+            </div>
+
+            <!-- 没有更多数据 -->
+            <div v-if="!hasMore && !isLoading" class="no-more">
+              没有更多数据了
+            </div>
+          </el-select>
+        </el-form-item>
         <el-form-item label="触发时间" prop="content">
           <el-time-picker
             default-value="2025-01-01 00:00:00"
@@ -235,6 +250,8 @@ import { listTask, getTask, delTask, addTask, updateTask, exportTask } from "@/a
 import {listLiveGoods} from "@/api/live/liveGoods";
 import {listLiveRedConfOn} from "@/api/live/liveRedConf";
 import {listLiveLotteryConfOn} from "@/api/live/liveLotteryConf";
+import {listLiveCouponOn} from "@/api/live/liveCoupon";
+
 
 export default {
   name: "Task",
@@ -253,6 +270,10 @@ export default {
           value: 4,
           label: "定时抽奖"
         },
+        {
+          value: 5,
+          label: "定时优惠券"
+        }
       ],
       statusOptions:[{
         value: "0",
@@ -266,11 +287,13 @@ export default {
       haveData:{
         goods:false,
         red:false,
-        lottery:false
+        lottery:false,
+        coupon:false
       },
       redOptions:[],
       lotteryOptions:[],
       productOptions:[],
+      couponOptions:[],
       // 遮罩层
       loading: true,
       // 导出遮罩层
@@ -395,6 +418,8 @@ export default {
           return "定时发送红包";
         case 4:
           return "定时抽奖";
+        case 5:
+          return "定时优惠券";
         default:
           return "--";
       }
@@ -465,6 +490,8 @@ export default {
           await this.addRedList();
         }else if (this.form.taskType == 4) {
           await this.addLotteryList();
+        }else if(this.form.taskType == 5){
+          await this.addCouponList();
         }
       }catch ( err){
         console.error('加载数据失败:', err);
@@ -537,7 +564,7 @@ export default {
           // 判断是否还有更多数据
           this.hasMore = this.lotteryOptions.length < res.total;
           if (this.hasMore) {
-            this.addRedList();
+            this.addLotteryList();
           } else {
             this.haveData.lottery = true
           }
@@ -547,6 +574,31 @@ export default {
         }
       });
     },
+    addCouponList() {
+      if(this.haveData.coupon) return
+      listLiveCouponOn(this.listParams).then(res => {
+        if(res.rows.length > 0) {
+          res.rows.forEach(item => {
+            // 根据productName和goodsId组装成为label和value
+            this.couponOptions.push({
+              value: item.couponId,
+              label: item.title
+            })
+          })
+          this.listParams.pageNum++;
+          // 判断是否还有更多数据
+          this.hasMore = this.couponOptions.length < res.total;
+          if (this.hasMore) {
+            this.addCouponList();
+          } else {
+            this.haveData.coupon = true
+          }
+        } else {
+          this.haveData.coupon = true
+          this.hasMore = false;
+        }
+      });
+    },
     /** 查询直播间自动化任务配置列表 */
     getList() {
       if(this.liveId == null) {
@@ -620,6 +672,8 @@ export default {
         await this.addRedList();
       }else if(row.taskType == 4){
         await this.addLotteryList();
+      }else if(row.taskType == 5) {
+        await this.addCouponList();
       }
       const id = row.id || this.ids
       getTask(id).then(response => {
@@ -631,6 +685,8 @@ export default {
           this.form.content = content.desc;
         }else if (this.form.taskType == 4) {
           this.form.content = content.desc;
+        }else if(this.form.taskType == 5){
+          this.form.content = content.couponId;
         }
         this.open = true;
         this.title = "修改直播间自动化任务配置";

+ 346 - 0
src/views/live/liveMiniLives/index.vue

@@ -0,0 +1,346 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
+      <el-form-item label="公司名称" prop="companyName">
+        <el-input
+          v-model="queryParams.companyName"
+          placeholder="请输入公司名称"
+          clearable
+          size="small"
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="显示状态" prop="liveShow">
+        <el-select
+          v-model="queryParams.liveShow"
+          placeholder="请选择显示状态"
+          clearable
+          size="small"
+          style="width: 150px"
+        >
+          <el-option label="展示" :value="1"></el-option>
+          <el-option label="不展示" :value="0"></el-option>
+        </el-select>
+      </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-form-item>
+    </el-form>
+
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="3">
+        <el-select
+          v-model="batchLiveShow"
+          placeholder="批量操作"
+          size="mini"
+          style="width: 120px"
+          :disabled="selectedCompanyIds.length === 0"
+          @change="handleBatchUpdateLiveShow"
+        >
+          <el-option label="批量展示" :value="1"></el-option>
+          <el-option label="批量不展示" :value="0"></el-option>
+        </el-select>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <el-table v-loading="loading" :data="companyList" @selection-change="handleSelectionChange">
+      <el-table-column
+        type="selection"
+        width="55"
+        align="center"
+      />
+      <el-table-column label="公司ID" align="center" prop="companyId" width="100" />
+      <el-table-column label="公司名称" align="center" prop="companyName" />
+      <el-table-column label="显示状态" align="center" prop="liveShow" width="120">
+        <template slot-scope="scope">
+          <el-tag v-if="scope.row.liveShow == 1" type="success">显示</el-tag>
+          <el-tag v-else type="info">不显示</el-tag>
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleEditLiveShow(scope.row)"
+          >修改显示状态</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+
+    <!-- 修改显示状态对话框 -->
+    <el-dialog title="修改显示状态" :visible.sync="editLiveShowDialog" width="500px" append-to-body>
+      <el-form :model="editLiveShowForm" label-width="100px">
+        <el-form-item label="公司名称">
+          <el-input v-model="editLiveShowForm.companyName" :disabled="true" />
+        </el-form-item>
+        <el-form-item label="显示状态" prop="liveShow">
+          <el-select v-model="editLiveShowForm.liveShow" placeholder="请选择显示状态" style="width: 100%">
+            <el-option label="不展示" :value="0"></el-option>
+            <el-option label="展示" :value="1"></el-option>
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitEditLiveShow">确 定</el-button>
+        <el-button @click="cancelEditLiveShow">取 消</el-button>
+      </div>
+    </el-dialog>
+
+  </div>
+</template>
+
+<script>
+import { liveShowList, batchUpdateCompanyLiveShow } from "@/api/company/company";
+
+export default {
+  name: "LiveMiniLives",
+  data() {
+    return {
+      // 遮罩层
+      loading: true,
+      // 公司列表加载(对话框)
+      companyLoading: false,
+      // 选中数组
+      ids: [],
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // 公司列表总条数(对话框)
+      companyTotal: 0,
+      // 公司列表
+      companyList: [],
+      // 对话框中的公司列表
+      dialogCompanyList: [],
+      // 选中的公司
+      selectedCompanies: [],
+      // 是否显示弹出层
+      open: false,
+      // 是否显示修改显示状态对话框
+      editLiveShowDialog: false,
+      // 修改显示状态表单
+      editLiveShowForm: {
+        companyId: null,
+        companyName: '',
+        liveShow: 0
+      },
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        companyName: null,
+        liveShow: null
+      },
+      // 公司查询参数(对话框)
+      queryCompanyParams: {
+        pageNum: 1,
+        pageSize: 10,
+        companyName: null
+      },
+      // 批量操作选中的公司
+      selectedCompanyIds: [],
+      // 批量操作显示状态
+      batchLiveShow: null
+    };
+  },
+  created() {
+    this.getList();
+  },
+  methods: {
+    /** 查询公司列表 */
+    getList() {
+      this.loading = true;
+      liveShowList(this.queryParams).then(response => {
+        if (response.code === 200) {
+          this.companyList = response.rows || [];
+          this.total = response.total || 0;
+        } else {
+          this.companyList = [];
+          this.total = 0;
+        }
+        this.loading = false;
+      }).catch(() => {
+        this.companyList = [];
+        this.total = 0;
+        this.loading = false;
+      });
+    },
+    /** 查询公司列表(对话框) */
+    getCompanyList() {
+      this.companyLoading = true;
+      liveShowList(this.queryCompanyParams).then(response => {
+        if (response.code === 200) {
+          this.dialogCompanyList = response.rows || [];
+          this.companyTotal = response.total || 0;
+        } else {
+          this.dialogCompanyList = [];
+          this.companyTotal = 0;
+        }
+        this.companyLoading = false;
+      }).catch(() => {
+        this.dialogCompanyList = [];
+        this.companyTotal = 0;
+        this.companyLoading = false;
+      });
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.queryParams.companyName = null;
+      this.queryParams.liveShow = null;
+      this.handleQuery();
+    },
+    /** 公司搜索按钮操作 */
+    handleCompanyQuery() {
+      this.queryCompanyParams.pageNum = 1;
+      this.getCompanyList();
+    },
+
+    // 多选框选中数据
+    handleSelectionChange(selection) {
+      // 记录所有选中的公司ID(用于批量操作)
+      this.selectedCompanyIds = selection.map(item => item.companyId);
+      // 只记录已绑定(liveShow == 1)的公司ID(用于批量删除)
+      this.ids = selection.filter(item => item.liveShow == 1).map(item => item.companyId);
+      // 只有选中了已绑定的公司才能批量删除
+      this.multiple = this.ids.length === 0;
+    },
+
+    /** 绑定公司按钮操作 */
+    handleAdd() {
+      this.open = true;
+      this.selectedCompanies = [];
+      this.queryCompanyParams = {
+        pageNum: 1,
+        pageSize: 10,
+        companyName: null
+      };
+      this.getCompanyList();
+    },
+    /** 取消按钮 */
+    cancel() {
+      this.open = false;
+      this.selectedCompanies = [];
+    },
+    /** 检查公司是否已绑定 */
+    isCompanyBound(company) {
+      return company.liveShow == 1;
+    },
+    /** 检查行是否可选(对话框表格) */
+    checkSelectable(row) {
+      // 已绑定的公司(liveShow == 1)不可选
+      return row.liveShow != 1;
+    },
+    /** 打开修改显示状态对话框 */
+    handleEditLiveShow(row) {
+      this.editLiveShowForm = {
+        companyId: row.companyId,
+        companyName: row.companyName,
+        liveShow: row.liveShow || 0
+      };
+      this.editLiveShowDialog = true;
+    },
+    /** 取消修改显示状态 */
+    cancelEditLiveShow() {
+      this.editLiveShowDialog = false;
+      this.editLiveShowForm = {
+        companyId: null,
+        companyName: '',
+        liveShow: 0
+      };
+    },
+    /** 提交修改显示状态 */
+    submitEditLiveShow() {
+      if (this.editLiveShowForm.liveShow === null || this.editLiveShowForm.liveShow === undefined) {
+        this.msgWarning("请选择显示状态");
+        return;
+      }
+      const selectIds=[]
+      selectIds.push(this.editLiveShowForm.companyId)
+
+      const data = {
+        ids: selectIds,
+        liveShow: this.editLiveShowForm.liveShow
+      };
+
+      batchUpdateCompanyLiveShow(data).then(response => {
+        if (response.code === 200) {
+          this.msgSuccess("修改成功");
+          this.editLiveShowDialog = false;
+          this.getList();
+        } else {
+          this.msgError(response.msg || "修改失败");
+        }
+      }).catch(() => {
+        this.msgError("修改失败");
+      });
+    },
+    /** 批量修改显示状态 */
+    handleBatchUpdateLiveShow(value) {
+      if (value === null || value === undefined) {
+        return;
+      }
+
+      if (!this.selectedCompanyIds || this.selectedCompanyIds.length === 0) {
+        this.msgWarning("请先选择要操作的公司");
+        this.batchLiveShow = null;
+        return;
+      }
+
+      const statusText = value == 1 ? "展示" : "不展示";
+      this.$confirm('是否确认将所选' + this.selectedCompanyIds.length + '个公司设置为"' + statusText + '"?', "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(() => {
+        const data = {
+          ids: this.selectedCompanyIds,
+          liveShow: value
+        };
+        batchUpdateCompanyLiveShow(data).then(response => {
+          if (response.code === 200) {
+            this.msgSuccess("批量修改成功");
+            this.batchLiveShow = null;
+            this.getList();
+          } else {
+            this.msgError(response.msg || "批量修改失败");
+            this.batchLiveShow = null;
+          }
+        }).catch(() => {
+          this.msgError("批量修改失败");
+          this.batchLiveShow = null;
+        });
+      }).catch(() => {
+        this.batchLiveShow = null;
+      });
+    },
+  }
+};
+</script>
+
+<style scoped>
+::v-deep .bound-row {
+  background-color: #f0f9ff;
+  color: #909399;
+}
+</style>
+

+ 7 - 0
src/views/live/liveVideo/index.vue

@@ -42,6 +42,13 @@
         </template>
       </el-table-column>
       <el-table-column label="时长" align="center" prop="duration" :formatter="formatDuration"/>
+      <el-table-column label="转码状态" align="center" prop="finishStatus">
+        <template slot-scope="scope">
+          <el-tag v-if="scope.row.finishStatus == 1">转码成功</el-tag>
+          <el-tag v-else-if="scope.row.finishStatus == 0">转码中</el-tag>
+          <el-tag v-else>---</el-tag>
+        </template>
+      </el-table-column>
     </el-table>
 
     <pagination