From 5943e69046c58bb9223aa9461cab8c2c06a63f3f Mon Sep 17 00:00:00 2001 From: "zhonghua.li" Date: Wed, 1 Jul 2026 16:49:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/lb-user-coupon.js | 17 ++ src/main.js | 5 +- src/store/modules/user.js | 2 +- src/views/lb-business/config-manage/index.vue | 2 +- src/views/lb-business/coupon-manage/index.vue | 165 +++++++++++++++++- src/views/lb-business/daily-trade/index.vue | 2 +- src/views/lb-business/order-manage/index.vue | 6 +- 7 files changed, 183 insertions(+), 16 deletions(-) diff --git a/src/api/lb-user-coupon.js b/src/api/lb-user-coupon.js index e50a5a7..5f3e6b2 100644 --- a/src/api/lb-user-coupon.js +++ b/src/api/lb-user-coupon.js @@ -38,3 +38,20 @@ export function syncCoupons(params) { params }) } + +export function monthlyStatistic(params) { + return request({ + url: '/lbUserCoupon/monthlyStatistic', + method: 'post', + params + }) +} + +export function exportLbUserCoupon(params) { + return request({ + url: '/lbUserCoupon/export', + method: 'get', + params, + responseType: 'blob' + }) +} diff --git a/src/main.js b/src/main.js index 373c4df..3eef9f6 100644 --- a/src/main.js +++ b/src/main.js @@ -4,7 +4,7 @@ import 'normalize.css/normalize.css' // A modern alternative to CSS resets import ElementUI from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' -import locale from 'element-ui/lib/locale/lang/en' // lang i18n +import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n import '@/styles/index.scss' // global css @@ -31,10 +31,7 @@ if (process.env.NODE_ENV === 'production') { mockXHR() } -// set ElementUI lang to EN Vue.use(ElementUI, { locale }) -// 如果想要中文版 element-ui,按如下方式声明 -// Vue.use(ElementUI) Vue.config.productionTip = false diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 2b07211..a70d841 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -89,7 +89,7 @@ const actions = { commit('SET_TOKEN', data.token) setToken(data.token) // 登录接口已返回用户信息时直接写入 store,避免路由守卫再去调 getUserInfoByToken - //(该接口若失败或未对接,会清除 token 并退回登录页,表现为「登录成功却进不了系统」) + // (该接口若失败或未对接,会清除 token 并退回登录页,表现为「登录成功却进不了系统」) const profile = pickUserDisplayFields(data, username) commit('SET_NAME', profile.userName) commit('SET_AVATAR', profile.avatar || '') diff --git a/src/views/lb-business/config-manage/index.vue b/src/views/lb-business/config-manage/index.vue index 7490f52..664488c 100644 --- a/src/views/lb-business/config-manage/index.vue +++ b/src/views/lb-business/config-manage/index.vue @@ -251,7 +251,7 @@ - + diff --git a/src/views/lb-business/coupon-manage/index.vue b/src/views/lb-business/coupon-manage/index.vue index db76a96..a15e3bc 100644 --- a/src/views/lb-business/coupon-manage/index.vue +++ b/src/views/lb-business/coupon-manage/index.vue @@ -14,6 +14,15 @@ + + + + + + + + + 新增 同步优惠券 + 按月统计 + 导出 @@ -44,6 +55,11 @@ + + + @@ -148,7 +204,9 @@ import { addLbUserCoupon, deleteLbUserCoupon, + exportLbUserCoupon, getLbUserCouponList, + monthlyStatistic, syncCoupons, updateLbUserCoupon } from '@/api/lb-user-coupon' @@ -161,6 +219,7 @@ export default { loading: false, submitLoading: false, syncLoading: false, + exportLoading: false, list: [], total: 0, couponDateRange: [], @@ -174,13 +233,20 @@ export default { syncFormRules: { recentDays: [{ required: true, message: '请输入最近天数', trigger: 'blur' }] }, + statDialogVisible: false, + statLoading: false, + statDateRange: [], + statResult: [], + statTotal: null, queryParams: { current: 1, size: 10, userPhone: '', userNickname: '', parentPhone: '', - parentNickname: '' + parentNickname: '', + dataType: '', + couponAmount: 3044 }, form: { id: '', @@ -197,14 +263,14 @@ export default { } } }, - created() { - this.fetchList() - }, computed: { tenantIdDisplay() { return this.getTenantIdFromBusinessHeaders() } }, + created() { + this.fetchList() + }, methods: { getTenantIdFromBusinessHeaders() { const headers = getBusinessHeaders() @@ -240,7 +306,9 @@ export default { userPhone: this.queryParams.userPhone || undefined, userNickname: this.queryParams.userNickname || undefined, parentPhone: this.queryParams.parentPhone || undefined, - parentNickname: this.queryParams.parentNickname || undefined + parentNickname: this.queryParams.parentNickname || undefined, + dataType: this.queryParams.dataType || undefined, + couponAmountMin: this.queryParams.couponAmount } const range = this.couponDateRange || [] if (range[0]) params.couponDateStart = range[0] @@ -261,7 +329,9 @@ export default { userPhone: '', userNickname: '', parentPhone: '', - parentNickname: '' + parentNickname: '', + dataType: '', + couponAmount: undefined } this.couponDateRange = [] this.fetchList() @@ -408,6 +478,89 @@ export default { }) }) }, + openStatDialog() { + this.statDialogVisible = true + }, + resetStatForm() { + this.statDateRange = [] + this.statResult = [] + this.statTotal = null + }, + handleStat() { + const tenantId = this.getTenantIdFromBusinessHeaders() + if (!tenantId) { + this.$message.error('未获取到租户ID,请先登录或配置业务请求头中的租户') + return + } + this.statLoading = true + const params = { tenantId } + const range = this.statDateRange || [] + if (range[0]) params.couponDateStart = range[0] + if (range[1]) params.couponDateEnd = range[1] + monthlyStatistic(params) + .then((res) => { + if (res && (res.success === true || res.code === 200 || res.code === 20000)) { + this.statResult = Array.isArray(res.data) ? res.data : [] + this.statTotal = this.statResult.reduce((sum, item) => { + const amount = typeof item.totalAmount === 'number' ? item.totalAmount : 0 + return sum + amount + }, 0) + if (!this.statResult.length) { + this.$message.info('该时间段内暂无统计数据') + } + } else { + this.$message.error((res && (res.message || res.msg)) || '统计失败') + } + }) + .catch(() => { + this.$message.error('统计失败') + }) + .finally(() => { + this.statLoading = false + }) + }, + handleExport() { + const tenantId = this.getTenantIdFromBusinessHeaders() + if (!tenantId) { + this.$message.error('未获取到租户ID,请先登录或配置业务请求头中的租户') + return + } + this.exportLoading = true + const params = { + tenantId, + userPhone: this.queryParams.userPhone || undefined, + userNickname: this.queryParams.userNickname || undefined, + parentPhone: this.queryParams.parentPhone || undefined, + parentNickname: this.queryParams.parentNickname || undefined, + dataType: this.queryParams.dataType || undefined, + couponAmountMin: this.queryParams.couponAmount + } + const range = this.couponDateRange || [] + if (range[0]) params.couponDateStart = range[0] + if (range[1]) params.couponDateEnd = range[1] + Object.keys(params).forEach((key) => { + if (params[key] === undefined || params[key] === '') delete params[key] + }) + exportLbUserCoupon(params) + .then((res) => { + const blob = new Blob([res], { type: 'application/vnd.ms-excel' }) + const url = window.URL.createObjectURL(blob) + const link = document.createElement('a') + link.href = url + link.download = '用户优惠券.xlsx' + document.body.appendChild(link) + link.click() + document.body.removeChild(link) + window.URL.revokeObjectURL(url) + this.$message.success('导出成功') + }) + .catch(() => { + this.$message.error('导出失败') + }) + .finally(() => { + this.exportLoading = false + }) + }, formatDateTime(dateTime) { if (!dateTime) return '-' const dateStr = String(dateTime).replace('T', ' ') diff --git a/src/views/lb-business/daily-trade/index.vue b/src/views/lb-business/daily-trade/index.vue index fb7dd17..b2b4dd2 100644 --- a/src/views/lb-business/daily-trade/index.vue +++ b/src/views/lb-business/daily-trade/index.vue @@ -165,8 +165,8 @@ type="date" placeholder="可选,格式 yyyy-MM-dd" value-format="yyyy-MM-dd" - @change="handleImportDateChange" style="width: 100%" + @change="handleImportDateChange" /> diff --git a/src/views/lb-business/order-manage/index.vue b/src/views/lb-business/order-manage/index.vue index 572cad9..bed638c 100644 --- a/src/views/lb-business/order-manage/index.vue +++ b/src/views/lb-business/order-manage/index.vue @@ -480,14 +480,14 @@ export default { } } }, - created() { - this.fetchList() - }, computed: { currentLoginTenantIdDisplay() { return this.getTenantIdFromBusinessHeaders() } }, + created() { + this.fetchList() + }, methods: { getTenantIdFromBusinessHeaders() { const headers = getBusinessHeaders()