From beef6a0a9478dd43c2c91d537097c169e3c156c7 Mon Sep 17 00:00:00 2001 From: owen Date: Sat, 26 Aug 2023 22:29:55 +0800 Subject: [PATCH] =?UTF-8?q?mall:=20=E5=AE=8C=E5=96=84=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E5=8F=91=E9=80=81=E4=BC=98=E6=83=A0=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mall/promotion/coupon/coupon.ts | 8 + .../mall/promotion/coupon/couponTemplate.ts | 8 + .../coupon/components/CouponSend.vue | 162 ++++++++++++++++++ src/views/mall/promotion/coupon/formatter.ts | 44 +++++ .../mall/promotion/coupon/template/index.vue | 47 ++--- src/views/member/user/index.vue | 32 +++- 6 files changed, 263 insertions(+), 38 deletions(-) create mode 100644 src/views/mall/promotion/coupon/components/CouponSend.vue create mode 100644 src/views/mall/promotion/coupon/formatter.ts diff --git a/src/api/mall/promotion/coupon/coupon.ts b/src/api/mall/promotion/coupon/coupon.ts index 565b86f7..2ebff5da 100755 --- a/src/api/mall/promotion/coupon/coupon.ts +++ b/src/api/mall/promotion/coupon/coupon.ts @@ -16,3 +16,11 @@ export const getCouponPage = async (params: PageParam) => { params: params }) } + +// 发送优惠券 +export const sendCoupon = async (data: any) => { + return request.post({ + url: '/promotion/coupon/send', + data: data + }) +} diff --git a/src/api/mall/promotion/coupon/couponTemplate.ts b/src/api/mall/promotion/coupon/couponTemplate.ts index 6a58876e..daac1334 100755 --- a/src/api/mall/promotion/coupon/couponTemplate.ts +++ b/src/api/mall/promotion/coupon/couponTemplate.ts @@ -73,6 +73,14 @@ export function getCouponTemplatePage(params: PageParam) { }) } +// 获得可用于领取的优惠劵模板分页 +export function getCanTakeCouponTemplatePage(params: PageParam) { + return request.get({ + url: '/promotion/coupon-template/can-take-page', + params: params + }) +} + // 导出优惠劵模板 Excel export function exportCouponTemplateExcel(params: PageParam) { return request.get({ diff --git a/src/views/mall/promotion/coupon/components/CouponSend.vue b/src/views/mall/promotion/coupon/components/CouponSend.vue new file mode 100644 index 00000000..7686539b --- /dev/null +++ b/src/views/mall/promotion/coupon/components/CouponSend.vue @@ -0,0 +1,162 @@ + + + diff --git a/src/views/mall/promotion/coupon/formatter.ts b/src/views/mall/promotion/coupon/formatter.ts new file mode 100644 index 00000000..60eebb5d --- /dev/null +++ b/src/views/mall/promotion/coupon/formatter.ts @@ -0,0 +1,44 @@ +import { CouponTemplateValidityTypeEnum, PromotionDiscountTypeEnum } from '@/utils/constants' +import { formatDate } from '@/utils/formatTime' +import { CouponTemplateVO } from '@/api/mall/promotion/coupon/couponTemplate' +import { floatToFixed2 } from '@/utils' + +// 格式化【优惠金额/折扣】 +export const discountFormat = (row: CouponTemplateVO) => { + if (row.discountType === PromotionDiscountTypeEnum.PRICE.type) { + return `¥${floatToFixed2(row.discountPrice)}` + } + if (row.discountType === PromotionDiscountTypeEnum.PERCENT.type) { + return `${row.discountPrice}%` + } + return '未知【' + row.discountType + '】' +} + +// 格式化【领取上限】 +export const takeLimitCountFormat = (row: CouponTemplateVO) => { + if (row.takeLimitCount === -1) { + return '无领取限制' + } + return `${row.takeLimitCount} 张/人` +} + +// 格式化【有效期限】 +export const validityTypeFormat = (row: CouponTemplateVO) => { + if (row.validityType === CouponTemplateValidityTypeEnum.DATE.type) { + return `${formatDate(row.validStartTime)} 至 ${formatDate(row.validEndTime)}` + } + if (row.validityType === CouponTemplateValidityTypeEnum.TERM.type) { + return `领取后第 ${row.fixedStartTerm} - ${row.fixedEndTerm} 天内可用` + } + return '未知【' + row.validityType + '】' +} + +// 格式化【剩余数量】 +export const remainedCountFormat = (row: CouponTemplateVO) => { + return row.totalCount - row.takeCount +} + +// 格式化【最低消费】 +export const userPriceFormat = (row: CouponTemplateVO) => { + return `¥${floatToFixed2(row.usePrice)}` +} diff --git a/src/views/mall/promotion/coupon/template/index.vue b/src/views/mall/promotion/coupon/template/index.vue index ee8dad46..ad0077ce 100755 --- a/src/views/mall/promotion/coupon/template/index.vue +++ b/src/views/mall/promotion/coupon/template/index.vue @@ -103,7 +103,7 @@ label="剩余数量" align="center" prop="totalCount" - :formatter="(row) => row.totalCount - row.takeCount" + :formatter="remainedCountFormat" /> import * as CouponTemplateApi from '@/api/mall/promotion/coupon/couponTemplate' -import { - CommonStatusEnum, - CouponTemplateValidityTypeEnum, - PromotionDiscountTypeEnum -} from '@/utils/constants' +import { CommonStatusEnum } from '@/utils/constants' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' -import { dateFormatter, formatDate } from '@/utils/formatTime' +import { dateFormatter } from '@/utils/formatTime' import CouponTemplateForm from './CouponTemplateForm.vue' +import { + discountFormat, + remainedCountFormat, + takeLimitCountFormat, + validityTypeFormat +} from '@/views/mall/promotion/coupon/formatter' defineOptions({ name: 'PromotionCouponTemplate' }) @@ -193,6 +195,7 @@ const queryParams = reactive({ pageSize: 10, name: null, status: null, + discountType: null, type: null, createTime: [] }) @@ -258,36 +261,6 @@ const handleDelete = async (id: number) => { } catch {} } -// 格式化【优惠金额/折扣】 -const discountFormat = (row: any) => { - if (row.discountType === PromotionDiscountTypeEnum.PRICE.type) { - return `¥${(row.discountPrice / 100.0).toFixed(2)}` - } - if (row.discountType === PromotionDiscountTypeEnum.PERCENT.type) { - return `¥${(row.discountPrice / 100.0).toFixed(2)}` - } - return '未知【' + row.discountType + '】' -} - -// 格式化【领取上限】 -const takeLimitCountFormat = (row: any) => { - if (row.takeLimitCount === -1) { - return '无领取限制' - } - return `${row.takeLimitCount} 张/人` -} - -// 格式化【有效期限】 -const validityTypeFormat = (row: any) => { - if (row.validityType === CouponTemplateValidityTypeEnum.DATE.type) { - return `${formatDate(row.validStartTime)} 至 ${formatDate(row.validEndTime)}` - } - if (row.validityType === CouponTemplateValidityTypeEnum.TERM.type) { - return `领取后第 ${row.fixedStartTerm} - ${row.fixedEndTerm} 天内可用` - } - return '未知【' + row.validityType + '】' -} - /** 初始化 **/ onMounted(() => { getList() diff --git a/src/views/member/user/index.vue b/src/views/member/user/index.vue index bae5c048..672e9bfc 100644 --- a/src/views/member/user/index.vue +++ b/src/views/member/user/index.vue @@ -60,13 +60,21 @@ 搜索 重置 + 发送优惠券 - + +