Browse Source

!264 营销活动:添加拼团记录
Merge pull request !264 from puhui999/dev-to-dev

芋道源码 1 year ago
parent
commit
523784ce41

+ 2 - 2
src/api/mall/product/spu.ts

@@ -20,8 +20,8 @@ export interface Sku {
   stock?: number // 库存
   weight?: number // 商品重量,单位:kg 千克
   volume?: number // 商品体积,单位:m^3 平米
-  firstBrokerageRecord?: number | string // 一级分销的佣金
-  secondBrokerageRecord?: number | string // 二级分销的佣金
+  firstBrokeragePrice?: number | string // 一级分销的佣金
+  secondBrokeragePrice?: number | string // 二级分销的佣金
   salesCount?: number // 商品销量
 }
 

+ 33 - 0
src/api/mall/promotion/combination/combinationRecord.ts

@@ -0,0 +1,33 @@
+import request from '@/config/axios'
+
+export interface CombinationRecordVO {
+  id: number // 拼团记录编号
+  activityId: number // 拼团活动编号
+  nickname: string // 用户昵称
+  avatar: string // 用户头像
+  headId: number // 团长编号
+  expireTime: string // 过期时间
+  userSize: number // 可参团人数
+  userCount: number // 已参团人数
+  status: number // 拼团状态
+  spuName: string // 商品名字
+  picUrl: string // 商品图片
+  virtualGroup: boolean // 是否虚拟成团
+  startTime: string // 开始时间 (订单付款后开始的时间)
+  endTime: string // 结束时间(成团时间/失败时间)
+}
+
+// 查询拼团记录列表
+export const getCombinationRecordPage = async (params) => {
+  return await request.get({ url: '/promotion/combination-record/page', params })
+}
+
+// 获得拼团记录的概要信息
+export const getCombinationRecordSummary = async () => {
+  return await request.get({ url: '/promotion/combination-record/get-summary' })
+}
+
+// 获得拼团记录分页 tab count
+export const getCombinationRecordCount = async () => {
+  return await request.get({ url: '/promotion/combination-record/get-count' })
+}

+ 3 - 2
src/utils/dict.ts

@@ -24,7 +24,7 @@ export const getDictOptions = (dictType: string) => {
   return dictStore.getDictByType(dictType) || []
 }
 
-export const getIntDictOptions = (dictType: string) => {
+export const getIntDictOptions = (dictType: string): DictDataType[] => {
   const dictOption: DictDataType[] = []
   const dictOptions: DictDataType[] = getDictOptions(dictType)
   dictOptions.forEach((dict: DictDataType) => {
@@ -181,5 +181,6 @@ export enum DICT_TYPE {
   PROMOTION_COUPON_TAKE_TYPE = 'promotion_coupon_take_type', // 优惠劵的领取方式
   PROMOTION_ACTIVITY_STATUS = 'promotion_activity_status', // 优惠活动的状态
   PROMOTION_CONDITION_TYPE = 'promotion_condition_type', // 营销的条件类型枚举
-  PROMOTION_BARGAIN_RECORD_STATUS = 'promotion_bargain_record_status' // 砍价记录的状态
+  PROMOTION_BARGAIN_RECORD_STATUS = 'promotion_bargain_record_status', // 砍价记录的状态
+  PROMOTION_COMBINATION_RECORD_STATUS = 'promotion_combination_record_status' // 拼团记录的状态
 }

+ 10 - 10
src/views/mall/product/spu/components/SkuList.vue

@@ -80,7 +80,7 @@
       <el-table-column align="center" label="一级返佣(元)" min-width="168">
         <template #default="{ row }">
           <el-input-number
-            v-model="row.firstBrokerageRecord"
+            v-model="row.firstBrokeragePrice"
             :min="0"
             :precision="2"
             :step="0.1"
@@ -91,7 +91,7 @@
       <el-table-column align="center" label="二级返佣(元)" min-width="168">
         <template #default="{ row }">
           <el-input-number
-            v-model="row.secondBrokerageRecord"
+            v-model="row.secondBrokeragePrice"
             :min="0"
             :precision="2"
             :step="0.1"
@@ -181,12 +181,12 @@
     <template v-if="formData!.subCommissionType">
       <el-table-column align="center" label="一级返佣(元)" min-width="80">
         <template #default="{ row }">
-          {{ row.firstBrokerageRecord }}
+          {{ row.firstBrokeragePrice }}
         </template>
       </el-table-column>
       <el-table-column align="center" label="二级返佣(元)" min-width="80">
         <template #default="{ row }">
-          {{ row.secondBrokerageRecord }}
+          {{ row.secondBrokeragePrice }}
         </template>
       </el-table-column>
     </template>
@@ -295,8 +295,8 @@ const skuList = ref<Sku[]>([
     stock: 0, // 库存
     weight: 0, // 商品重量
     volume: 0, // 商品体积
-    firstBrokerageRecord: 0, // 一级分销的佣金
-    secondBrokerageRecord: 0 // 二级分销的佣金
+    firstBrokeragePrice: 0, // 一级分销的佣金
+    secondBrokeragePrice: 0 // 二级分销的佣金
   }
 ]) // 批量添加时的临时数据
 
@@ -415,8 +415,8 @@ const generateTableData = (propertyList: any[]) => {
       stock: 0,
       weight: 0,
       volume: 0,
-      firstBrokerageRecord: 0,
-      secondBrokerageRecord: 0
+      firstBrokeragePrice: 0,
+      secondBrokeragePrice: 0
     }
     // 如果存在属性相同的 sku 则不做处理
     const index = formData.value!.skus!.findIndex(
@@ -491,8 +491,8 @@ watch(
           stock: 0,
           weight: 0,
           volume: 0,
-          firstBrokerageRecord: 0,
-          secondBrokerageRecord: 0
+          firstBrokeragePrice: 0,
+          secondBrokeragePrice: 0
         }
       ]
     }

+ 4 - 4
src/views/mall/product/spu/form/BasicInfoForm.vue

@@ -329,8 +329,8 @@ defineExpose({ validate })
 const changeSubCommissionType = () => {
   // 默认为零,类型切换后也要重置为零
   for (const item of formData.skus) {
-    item.firstBrokerageRecord = 0
-    item.secondBrokerageRecord = 0
+    item.firstBrokeragePrice = 0
+    item.secondBrokeragePrice = 0
   }
 }
 
@@ -349,8 +349,8 @@ const onChangeSpec = () => {
       stock: 0,
       weight: 0,
       volume: 0,
-      firstBrokerageRecord: 0,
-      secondBrokerageRecord: 0
+      firstBrokeragePrice: 0,
+      secondBrokeragePrice: 0
     }
   ]
 }

+ 8 - 8
src/views/mall/product/spu/form/index.vue

@@ -82,8 +82,8 @@ const formData = ref<ProductSpuApi.Spu>({
       stock: 0, // 库存
       weight: 0, // 商品重量
       volume: 0, // 商品体积
-      firstBrokerageRecord: 0, // 一级分销的佣金
-      secondBrokerageRecord: 0 // 二级分销的佣金
+      firstBrokeragePrice: 0, // 一级分销的佣金
+      secondBrokeragePrice: 0 // 二级分销的佣金
     }
   ],
   description: '', // 商品详情
@@ -112,15 +112,15 @@ const getDetail = async () => {
           item.price = floatToFixed2(item.price)
           item.marketPrice = floatToFixed2(item.marketPrice)
           item.costPrice = floatToFixed2(item.costPrice)
-          item.firstBrokerageRecord = floatToFixed2(item.firstBrokerageRecord)
-          item.secondBrokerageRecord = floatToFixed2(item.secondBrokerageRecord)
+          item.firstBrokeragePrice = floatToFixed2(item.firstBrokeragePrice)
+          item.secondBrokeragePrice = floatToFixed2(item.secondBrokeragePrice)
         } else {
           // 回显价格分转元
           item.price = formatToFraction(item.price)
           item.marketPrice = formatToFraction(item.marketPrice)
           item.costPrice = formatToFraction(item.costPrice)
-          item.firstBrokerageRecord = formatToFraction(item.firstBrokerageRecord)
-          item.secondBrokerageRecord = formatToFraction(item.secondBrokerageRecord)
+          item.firstBrokeragePrice = formatToFraction(item.firstBrokeragePrice)
+          item.secondBrokeragePrice = formatToFraction(item.secondBrokeragePrice)
         }
       })
       formData.value = res
@@ -149,8 +149,8 @@ const submitForm = async () => {
       item.price = convertToInteger(item.price)
       item.marketPrice = convertToInteger(item.marketPrice)
       item.costPrice = convertToInteger(item.costPrice)
-      item.firstBrokerageRecord = convertToInteger(item.firstBrokerageRecord)
-      item.secondBrokerageRecord = convertToInteger(item.secondBrokerageRecord)
+      item.firstBrokeragePrice = convertToInteger(item.firstBrokeragePrice)
+      item.secondBrokeragePrice = convertToInteger(item.secondBrokeragePrice)
     })
     // 处理轮播图列表
     const newSliderPicUrls: any[] = []

+ 13 - 1
src/views/mall/promotion/combination/activity/combinationActivity.data.ts

@@ -9,7 +9,8 @@ export const rules = reactive({
   startTime: [required],
   endTime: [required],
   userSize: [required],
-  limitDuration: [required]
+  limitDuration: [required],
+  virtualGroup: [required]
 })
 
 // CrudSchema https://doc.iocoder.cn/vue3/crud-schema/
@@ -114,6 +115,17 @@ const crudSchemas = reactive<CrudSchema[]>([
       value: 0
     }
   },
+  {
+    label: '虚拟成团',
+    field: 'virtualGroup',
+    dictType: DICT_TYPE.INFRA_BOOLEAN_STRING,
+    dictClass: 'boolean',
+    isSearch: true,
+    form: {
+      component: 'Radio',
+      value: false
+    }
+  },
   {
     label: '拼团商品',
     field: 'spuId',

+ 309 - 2
src/views/mall/promotion/combination/record/index.vue

@@ -1,5 +1,312 @@
 <template>
-  <div></div>
+  <!-- 统计信息展示 -->
+  <el-row :gutter="12">
+    <el-col :span="6">
+      <ContentWrap class="h-[110px] pb-0!">
+        <div class="flex items-center">
+          <div
+            class="h-[50px] w-[50px] flex items-center justify-center"
+            style="color: rgb(24, 144, 255); background-color: rgba(24, 144, 255, 0.1)"
+          >
+            <Icon :size="23" icon="fa:user-times" />
+          </div>
+          <div class="ml-[20px]">
+            <div class="mb-8px text-14px text-gray-400">参与人数(个)</div>
+            <CountTo
+              :duration="2600"
+              :end-val="recordSummary.userCount"
+              :start-val="0"
+              class="text-20px"
+            />
+          </div>
+        </div>
+      </ContentWrap>
+    </el-col>
+    <el-col :span="6">
+      <ContentWrap class="h-[110px]">
+        <div class="flex items-center">
+          <div
+            class="h-[50px] w-[50px] flex items-center justify-center"
+            style="color: rgb(162, 119, 255); background-color: rgba(162, 119, 255, 0.1)"
+          >
+            <Icon :size="23" icon="fa:user-plus" />
+          </div>
+          <div class="ml-[20px]">
+            <div class="mb-8px text-14px text-gray-400">成团数量(个)</div>
+            <CountTo
+              :duration="2600"
+              :end-val="recordSummary.successCount"
+              :start-val="0"
+              class="text-20px"
+            />
+          </div>
+        </div>
+      </ContentWrap>
+    </el-col>
+    <el-col :span="6">
+      <ContentWrap class="h-[110px]">
+        <div class="flex items-center">
+          <div
+            class="h-[50px] w-[50px] flex items-center justify-center"
+            style="color: rgb(162, 119, 255); background-color: rgba(162, 119, 255, 0.1)"
+          >
+            <Icon :size="23" icon="fa:user-plus" />
+          </div>
+          <div class="ml-[20px]">
+            <div class="mb-8px text-14px text-gray-400">虚拟成团(个)</div>
+            <CountTo
+              :duration="2600"
+              :end-val="recordSummary.virtualGroupCount"
+              :start-val="0"
+              class="text-20px"
+            />
+          </div>
+        </div>
+      </ContentWrap>
+    </el-col>
+  </el-row>
+  <ContentWrap>
+    <!-- 搜索工作栏 -->
+    <el-form
+      ref="queryFormRef"
+      :inline="true"
+      :model="queryParams"
+      class="-mb-15px"
+      label-width="68px"
+    >
+      <el-form-item label="创建时间" prop="createTime">
+        <el-date-picker
+          v-model="queryParams.createTime"
+          :shortcuts="shortcuts"
+          class="!w-240px"
+          end-placeholder="结束日期"
+          start-placeholder="开始日期"
+          type="daterange"
+          value-format="YYYY-MM-DD HH:mm:ss"
+        />
+      </el-form-item>
+      <el-form-item label="拼团状态" prop="status">
+        <el-select v-model="queryParams.status" class="!w-240px" clearable placeholder="全部">
+          <el-option
+            v-for="(dict, index) in getIntDictOptions(
+              DICT_TYPE.PROMOTION_COMBINATION_RECORD_STATUS
+            )"
+            :key="index"
+            :label="dict.label"
+            :value="dict.value"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item>
+        <el-button @click="handleQuery">
+          <Icon class="mr-5px" icon="ep:search" />
+          搜索
+        </el-button>
+        <el-button @click="resetQuery">
+          <Icon class="mr-5px" icon="ep:refresh" />
+          重置
+        </el-button>
+      </el-form-item>
+    </el-form>
+  </ContentWrap>
+  <ContentWrap>
+    <!--   分页列表数据展示   -->
+    <el-table v-loading="loading" :data="pageList">
+      <el-table-column align="center" label="编号" prop="id" />
+      <!-- TODO 是否需要做一个点击用户头像跳转或查看用户信息的功能  -->
+      <el-table-column align="center" label="头像" prop="avatar" />
+      <el-table-column align="center" label="开团团长" prop="headId">
+        <template #default="{ row }: { row: CombinationRecordApi.CombinationRecordVO }">
+          {{
+            row.headId ? pageList.find((item) => item.id === row.headId)?.nickname : row.nickname
+          }}
+        </template>
+      </el-table-column>
+      <el-table-column
+        :formatter="dateFormatter"
+        align="center"
+        label="开团时间"
+        prop="startTime"
+        width="180"
+      />
+      <el-table-column
+        align="center"
+        label="拼团商品"
+        prop="type"
+        show-overflow-tooltip
+        width="300"
+      >
+        <template #defaul="{ row }">
+          <el-image
+            :src="row.picUrl"
+            class="mr-5px h-30px w-30px align-middle"
+            @click="imagePreview(row.picUrl)"
+          />
+          <span class="align-middle">{{ row.spuName }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column align="center" label="几人团" prop="userSize" />
+      <el-table-column align="center" label="参与人数" prop="userCount" />
+      <el-table-column
+        :formatter="dateFormatter"
+        align="center"
+        label="结束时间"
+        prop="endTime"
+        width="180"
+      />
+      <el-table-column align="center" label="拼团状态" prop="status">
+        <template #default="scope">
+          <dict-tag
+            :type="DICT_TYPE.PROMOTION_COMBINATION_RECORD_STATUS"
+            :value="scope.row.status"
+          />
+        </template>
+      </el-table-column>
+      <el-table-column align="center" fixed="right" label="操作">
+        <template #default></template>
+      </el-table-column>
+    </el-table>
+    <!-- 分页 -->
+    <Pagination
+      v-model:limit="queryParams.pageSize"
+      v-model:page="queryParams.pageNo"
+      :total="total"
+      @pagination="getList"
+    />
+  </ContentWrap>
 </template>
 
-<script lang="ts" name="CombinationRecord" setup></script>
+<script lang="ts" setup>
+import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
+import { dateFormatter } from '@/utils/formatTime'
+import { createImageViewer } from '@/components/ImageViewer'
+import * as CombinationRecordApi from '@/api/mall/promotion/combination/combinationRecord'
+
+defineOptions({ name: 'CombinationRecord' })
+const queryParams = ref({
+  dateType: 0, // 日期类型
+  status: undefined, // 拼团状态
+  createTime: undefined, // 创建时间
+  pageSize: 10,
+  pageNo: 1
+})
+const queryFormRef = ref() // 搜索的表单
+const loading = ref(true) // 列表的加载中
+const total = ref(0) // 总记录数
+const pageList = ref<CombinationRecordApi.CombinationRecordVO[]>([]) // 分页数据
+/** 查询列表 */
+const getList = async () => {
+  loading.value = true
+  try {
+    const data = await CombinationRecordApi.getCombinationRecordPage(queryParams.value)
+    pageList.value = data.list as CombinationRecordApi.CombinationRecordVO[]
+    total.value = data.total
+  } finally {
+    loading.value = false
+  }
+}
+// 拼团统计数据
+const recordSummary = ref({
+  successCount: 0,
+  userCount: 0,
+  virtualGroupCount: 0
+})
+/** 获得拼团记录统计信息 */
+const getSummary = async () => {
+  recordSummary.value = await CombinationRecordApi.getCombinationRecordSummary()
+}
+// 日期快捷选项
+const shortcuts = ref([
+  {
+    text: '今天',
+    type: 'toDay',
+    value: () => {
+      queryParams.value.dateType = 1
+      return new Date()
+    }
+  },
+  {
+    text: '昨天',
+    type: 'yesterday',
+    value: () => {
+      const date = new Date()
+      date.setTime(date.getTime() - 3600 * 1000 * 24)
+      queryParams.value.dateType = 2
+      return [date, date]
+    }
+  },
+  {
+    text: '最近七天',
+    type: 'lastSevenDays',
+    value: () => {
+      const date = new Date()
+      date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
+      queryParams.value.dateType = 3
+      return [date, new Date()]
+    }
+  },
+  {
+    text: '最近30天',
+    type: 'last30Days',
+    value: () => {
+      const date = new Date()
+      date.setTime(date.getTime() - 3600 * 1000 * 24 * 30)
+      queryParams.value.dateType = 4
+      return [date, new Date()]
+    }
+  },
+  {
+    text: '本月',
+    type: 'thisMonth',
+    value: () => {
+      const date = new Date()
+      date.setDate(1) // 设置为当前月的第一天
+      queryParams.value.dateType = 5
+      return [date, new Date()]
+    }
+  },
+  {
+    text: '今年',
+    type: 'thisYear',
+    value: () => {
+      const date = new Date()
+      queryParams.value.dateType = 6
+      return [new Date(`${date.getFullYear()}-01-01`), date]
+    }
+  }
+])
+
+/** 获得每个 Tab 的数量 */
+const getTabsCount = async () => {
+  const res = await CombinationRecordApi.getCombinationRecordCount()
+  shortcuts.value.forEach((tab) => {
+    tab.text += `(${res[tab.type]})`
+  })
+}
+
+/** 搜索按钮操作 */
+const handleQuery = () => {
+  queryParams.value.pageNo = 1
+  getList()
+}
+
+/** 重置按钮操作 */
+const resetQuery = () => {
+  queryFormRef.value.resetFields()
+  handleQuery()
+}
+
+/** 商品图预览 */
+const imagePreview = (imgUrl: string) => {
+  createImageViewer({
+    urlList: [imgUrl]
+  })
+}
+
+/** 初始化 **/
+onMounted(async () => {
+  await getSummary()
+  await getTabsCount()
+  await getList()
+})
+</script>