Browse Source

Merge branch 'feat/v20241212-人脉银行'

GuYun-D 1 month ago
parent
commit
dd22839769

+ 9 - 1
src/api/business.js

@@ -368,4 +368,12 @@ export function exportConsumptionRecordByUserIdAndAllianceCardIdApi(params) {
     method: 'GET',
     responseType: 'blob'
   })
-}
+}
+// 编辑联盟卡的数据
+export function editAlianceInfoApi(data) {
+  return request({
+    url: '/alliance-card/updateById',
+    method: 'POST',
+    data
+  })
+}

+ 249 - 0
src/views/business/alliance/components/EditAlianceDialog.vue

@@ -0,0 +1,249 @@
+<template>
+  <el-dialog :close-on-click-modal="false" title="编辑联盟卡信息" :visible.sync="editAllianceVisible" width="890px">
+    <div style="height: 500px; overflow: auto">
+      <el-form :rules="editAllianceRules" ref="formRef" :model="editAllianceForm" label-width="auto">
+        <el-form-item label="联盟卡名称" prop="name">
+          <el-input v-model="editAllianceForm.name"></el-input>
+        </el-form-item>
+
+        <el-form-item label="封面" prop="coverUrl">
+          <ImageUpload :limit="1" v-model="editAllianceForm.coverUrl"></ImageUpload>
+        </el-form-item>
+
+        <el-form-item label="抵扣价格" prop="deductionPrice">
+          <el-input v-model="editAllianceForm.deductionPrice"></el-input>
+        </el-form-item>
+
+        <el-form-item label="发行张数" prop="receiptCount">
+          <el-input v-model="editAllianceForm.receiptCount"></el-input>
+        </el-form-item>
+
+        <el-form-item label="状态" prop="state">
+          <el-select style="width: 100%" v-model="editAllianceForm.state" placeholder="请选择状态">
+            <el-option label="审核中" :value="1"></el-option>
+            <el-option label="通过" :value="2"></el-option>
+            <el-option label="不通过" :value="3"></el-option>
+          </el-select>
+        </el-form-item>
+
+        <el-form-item label="联盟卡类型" prop="type">
+          <el-select style="width: 100%" v-model="editAllianceForm.type" placeholder="请选择联盟卡类型">
+            <el-option label="联盟卡" :value="1"></el-option>
+            <el-option label="会员卡" :value="2"></el-option>
+          </el-select>
+        </el-form-item>
+
+        <el-form-item label="是否发行" prop="isIssuance">
+          <el-select style="width: 100%" v-model="editAllianceForm.isIssuance" placeholder="请选择联盟卡是否发行">
+            <el-option label="未发行" :value="0"></el-option>
+            <el-option label="已发行" :value="1"></el-option>
+          </el-select>
+        </el-form-item>
+
+        <el-form-item label="到期时间" prop="expirationTime">
+          <el-date-picker style="width: 100%" v-model="editAllianceForm.expirationTime" type="datetime" placeholder="请选择到期时间"></el-date-picker>
+        </el-form-item>
+
+        <el-form-item label="团长佣金" prop="headOfCommission">
+          <el-input v-model="editAllianceForm.headOfCommission"></el-input>
+        </el-form-item>
+
+        <el-form-item label="合伙人佣金" prop="partnerCommission">
+          <el-input v-model="editAllianceForm.partnerCommission"></el-input>
+        </el-form-item>
+
+        <el-form-item label="联盟卡分佣比例" prop="allianceCardCommissionRatio">
+          <el-input v-model="editAllianceForm.allianceCardCommissionRatio"></el-input>
+        </el-form-item>
+
+        <el-form-item label="权益信息" prop="statement">
+          <el-input type="textarea" v-model="editAllianceForm.statement"></el-input>
+        </el-form-item>
+
+        <el-form-item label="使用说明" prop="useInstructions">
+          <el-input type="textarea" v-model="editAllianceForm.useInstructions"></el-input>
+        </el-form-item>
+      </el-form>
+    </div>
+
+    <span slot="footer" class="dialog-footer">
+      <el-button @click="editAllianceVisible = false">取 消</el-button>
+      <el-button type="primary" @click="handleConfirm" :loading="loading">确 定</el-button>
+    </span>
+  </el-dialog>
+</template>
+
+<script>
+import ImageUpload from '@/components/ImageUpload'
+import { editAlianceInfoApi } from '@/api/business'
+
+export default {
+  components: { ImageUpload },
+  data() {
+    return {
+      editAllianceVisible: false,
+      loading: false,
+      baseInfo: {},
+      editAllianceForm: {
+        id: undefined,
+        name: '',
+        coverUrl: '',
+        purchasePrice: undefined,
+        deductionPrice: undefined,
+        receiptCount: undefined,
+        state: undefined,
+        type: undefined,
+        isIssuance: undefined,
+        expirationTime: '',
+        headOfCommission: undefined,
+        partnerCommission: undefined,
+        statement: '',
+        useInstructions: '',
+        allianceCardCommissionRatio: undefined
+      },
+
+      editAllianceRules: {
+        name: [{ required: true, message: '请填写联盟卡名称', trigger: 'blur' }],
+        deductionPrice: [
+          { required: true, message: '请填写抵扣价格', trigger: 'blur' },
+          {
+            pattern: /(^[1-9]\d*(\.\d{1,2})?$)|(^0(\.\d{1,2})?$)/,
+            message: '金额必须为正数且最多两位小数',
+            trigger: 'blur'
+          }
+        ],
+        receiptCount: [
+          { required: true, message: '请填写联盟卡发行张数', trigger: 'blur' },
+          {
+            validator: (rule, value, callback) => {
+              if (!Number.isInteger(value) || value <= 0) {
+                callback(new Error('必须是大于0的整数'))
+              } else {
+                callback()
+              }
+            },
+            trigger: 'blur'
+          }
+        ],
+        state: [{ required: true, message: '请选择联盟卡状态', trigger: 'change' }],
+        type: [{ required: true, message: '请选择联盟卡类型', trigger: 'change' }],
+        isIssuance: [{ required: true, message: '请选择联盟卡是否发行', trigger: 'change' }],
+        expirationTime: [{ required: true, message: '请选择到期时间', trigger: 'change' }],
+        headOfCommission: [
+          { required: true, message: '请填写团长佣金', trigger: 'blur' },
+          {
+            pattern: /^\d+(\.\d{1,2})?$/,
+            message: '金额格式不正确(最多两位小数)',
+            trigger: 'blur'
+          }
+        ],
+        partnerCommission: [
+          { required: true, message: '请填写合伙人佣金', trigger: 'blur' },
+          {
+            pattern: /^\d+(\.\d{1,2})?$/,
+            message: '金额格式不正确(最多两位小数)',
+            trigger: 'blur'
+          }
+        ],
+        allianceCardCommissionRatio: [
+          { required: true, message: '请填写联盟卡分佣比例', trigger: 'blur' },
+          {
+            validator: (rule, value, callback) => {
+              // 首先确保值是有效的数值
+              value *= 1
+              if (isNaN(value)) {
+                callback(new Error('请输入有效数字'))
+              } else if (value < 0 || value >= 1) {
+                // 修改这里,确保范围在0-1之间
+                callback(new Error('分佣比例需在0-1之间, 不能为1'))
+              } else if (!/^\d+(\.\d{1,2})?$/.test(value)) {
+                callback(new Error('最多保留两位小数'))
+              } else {
+                callback()
+              }
+            },
+            trigger: 'blur'
+          }
+        ],
+        statement: [{ required: true, message: '请填写权益信息', trigger: 'blur' }],
+        useInstructions: [{ required: true, message: '请填写使用说明', trigger: 'blur' }]
+      }
+    }
+  },
+
+  watch: {
+    editAllianceVisible(value) {
+      if (!value) {
+        this.reset()
+      }
+    }
+  },
+
+  methods: {
+    handleOpen(row) {
+      this.editAllianceVisible = true
+      this.editAllianceForm.name = row.name
+      this.editAllianceForm.id = row.id
+      this.editAllianceForm.coverUrl = row.coverUrl
+      this.editAllianceForm.purchasePrice = row.purchasePrice
+      this.editAllianceForm.deductionPrice = row.deductionPrice
+      this.editAllianceForm.receiptCount = row.receiptCount
+      this.editAllianceForm.state = row.state
+      this.editAllianceForm.type = row.type
+      this.editAllianceForm.isIssuance = row.isIssuance
+      this.editAllianceForm.expirationTime = row.expirationTime
+      this.editAllianceForm.headOfCommission = row.headOfCommission
+      this.editAllianceForm.partnerCommission = row.partnerCommission
+      this.editAllianceForm.statement = row.statement
+      this.editAllianceForm.useInstructions = row.useInstructions
+      this.editAllianceForm.allianceCardCommissionRatio = row.allianceCardCommissionRatio
+    },
+
+    async handleConfirm() {
+      try {
+        this.loading = true
+        await this.$refs.formRef.validate()
+        await editAlianceInfoApi(this.editAllianceForm)
+        this.$message.success('编辑成功')
+        this.$emit('refresh')
+        this.reset()
+        this.close()
+      } catch (error) {
+      } finally {
+        this.loading = false
+      }
+    },
+
+    reset() {
+      this.editAllianceForm = {
+        id: undefined,
+        name: '',
+        coverUrl: '',
+        purchasePrice: undefined,
+        deductionPrice: undefined,
+        receiptCount: undefined,
+        state: undefined,
+        type: undefined,
+        isIssuance: undefined,
+        expirationTime: '',
+        headOfCommission: undefined,
+        partnerCommission: undefined,
+        statement: '',
+        useInstructions: '',
+        allianceCardCommissionRatio: undefined
+      }
+      this.baseInfo = {}
+    },
+
+    close() {
+      this.editAllianceVisible = false
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+::v-deep .el-descriptions__header {
+  margin-bottom: 10px;
+}
+</style>

+ 32 - 24
src/views/business/alliance/index.vue

@@ -16,7 +16,7 @@
     <!-- 查询结果 -->
     <div v-tableHeight>
       <el-table v-loading="listLoading" height="100%" element-loading-text="正在查询中。。。" :data="list" v-bind="{ stripe: true, size: 'small', border: true, fit: true, highlightCurrentRow: true }">
-        <el-table-column  label="#" type="index" width="80" align="center" />
+        <el-table-column label="#" type="index" width="80" align="center" />
         <el-table-column prop="shopId" label="商家Id" width="120" align="center" />
         <el-table-column prop="shopName" label="商家名称" width="150" align="center" />
         <el-table-column prop="name" label="联盟卡名称" width="150" align="center" />
@@ -77,17 +77,15 @@
         <el-table-column show-overflow-tooltip prop="useInstructions" label="使用说明" width="150" align="center" />
         <el-table-column prop="createTime" label="创建时间" width="180" align="center" />
 
-        <el-table-column align="center" label="操作" width="280" fixed="right" class-name="small-padding fixed-width">
+        <el-table-column align="center" label="操作" width="360" fixed="right" class-name="small-padding fixed-width">
           <template slot-scope="{ row }">
             <el-button @click="$refs.checkDialogRef && $refs.checkDialogRef.handleOpen(row)" :disabled="row.state !== 1" type="warning" size="mini">审核</el-button>
             <el-button type="primary" size="mini" @click="$refs.detailDialogRef && $refs.detailDialogRef.handleOpen(row)">详情</el-button>
-            <el-button
-              :type="Number(row.isClub) === 1 ? 'danger' : 'success'"
-              size="mini"
-              @click="handleSetDefaultCard(row)"
-            >
+            <el-button :type="Number(row.isClub) === 1 ? 'danger' : 'success'" size="mini" @click="handleSetDefaultCard(row)">
               {{ Number(row.isClub) === 1 ? '取消俱乐部默认卡' : '设为俱乐部默认卡' }}
             </el-button>
+
+            <el-button type="success" size="mini" @click="handleEditAliance(row)">编辑</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -109,6 +107,8 @@
     <DetailDialog ref="detailDialogRef"></DetailDialog>
     <!-- 审核 -->
     <CheckDialog @success="getList" ref="checkDialogRef"></CheckDialog>
+    <!-- 编辑联盟卡信息 -->
+    <EditAlianceDialog @refresh="handleReset" ref="editAlianceDialogRef"></EditAlianceDialog>
   </div>
 </template>
 
@@ -117,10 +117,11 @@ import { getAllianceCardListApi } from '@/api/business'
 import { setOrCancelAllianceCardIsClubApi } from '@/api/rm-bank'
 import DetailDialog from './components/DetailDialog'
 import CheckDialog from './components/CheckDialog'
+import EditAlianceDialog from './components/EditAlianceDialog.vue'
 
 export default {
   name: 'allianceCardList',
-  components: { DetailDialog, CheckDialog },
+  components: { DetailDialog, CheckDialog, EditAlianceDialog },
   data() {
     // 这里存放数据
     return {
@@ -172,35 +173,42 @@ export default {
       }
     },
 
-    handleReset(){
+    handleReset() {
       this.listQuery.search = ''
       this.listQuery.state = ''
       this.handleSearch()
     },
 
+    // 点击编辑
+    handleEditAliance(row) {
+      this.$refs.editAlianceDialogRef.handleOpen(row)
+    },
+
     handleSetDefaultCard(row) {
       const isSet = Number(row.isClub) !== 1
       const tipText = isSet ? '设置为俱乐部默认卡' : '取消俱乐部默认卡'
-      
+
       this.$confirm(`是否要${tipText}?`, '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         type: 'warning'
-      }).then(async () => {
-        try {
-          await setOrCancelAllianceCardIsClubApi({
-            allianceCardId: row.id,
-            state: isSet ? '1' : '0'
-          })
-          this.$message.success(`${tipText}成功`)
-          this.getList() // 刷新列表
-        } catch (error) {
-          console.error(error)
-          this.$message.error(`${tipText}失败`)
-        }
-      }).catch(() => {
-        this.$message.info('已取消操作')
       })
+        .then(async () => {
+          try {
+            await setOrCancelAllianceCardIsClubApi({
+              allianceCardId: row.id,
+              state: isSet ? '1' : '0'
+            })
+            this.$message.success(`${tipText}成功`)
+            this.getList() // 刷新列表
+          } catch (error) {
+            console.error(error)
+            this.$message.error(`${tipText}失败`)
+          }
+        })
+        .catch(() => {
+          this.$message.info('已取消操作')
+        })
     }
   }
 }

+ 6 - 1
src/views/finance/withdrawal/components/DetailModal.vue

@@ -166,8 +166,13 @@
               <el-tag type="primary" size="mini">{{ row.settlementRatio ? row.settlementRatio * 100 + '%' : 0 }}</el-tag>
             </template>
           </el-table-column>
+          <el-table-column align="center" prop="remark" label="备注" width="300">
+            <template slot-scope="{ row }">
+              <span>{{ row.remark || '--' }}</span>
+            </template>
+          </el-table-column>
           <el-table-column align="center" prop="withdrawalNo" label="提现单号" width="200"></el-table-column>
-          <el-table-column align="center" prop="createTime" label="消费时间"  width="200"></el-table-column>
+          <el-table-column align="center" prop="createTime" label="消费时间" width="200"></el-table-column>
         </el-table>
       </el-tab-pane>
     </el-tabs>