Merge pull request '新增积分商品,新增拼团、秒杀的小程序以及后端商品查询接口' (#26) from zzw-one into master
Reviewed-on: #26
This commit is contained in:
commit
8d61fbaef7
@ -0,0 +1,66 @@
|
|||||||
|
import request from '@/config/axios'
|
||||||
|
import { Sku, Spu } from '@/api/mall/product/spu'
|
||||||
|
|
||||||
|
export interface CombinationActivityVO {
|
||||||
|
id?: number
|
||||||
|
name?: string
|
||||||
|
spuId?: number
|
||||||
|
totalLimitCount?: number
|
||||||
|
singleLimitCount?: number
|
||||||
|
startTime?: Date
|
||||||
|
endTime?: Date
|
||||||
|
userSize?: number
|
||||||
|
totalCount?: number
|
||||||
|
successCount?: number
|
||||||
|
orderUserCount?: number
|
||||||
|
virtualGroup?: number
|
||||||
|
status?: number
|
||||||
|
limitDuration?: number
|
||||||
|
products: CombinationProductVO[]
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拼团活动所需属性
|
||||||
|
export interface CombinationProductVO {
|
||||||
|
spuId: number
|
||||||
|
skuId: number
|
||||||
|
combinationPrice: number // 拼团价格
|
||||||
|
}
|
||||||
|
|
||||||
|
// 扩展 Sku 配置
|
||||||
|
export type SkuExtension = Sku & {
|
||||||
|
productConfig: CombinationProductVO
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SpuExtension extends Spu {
|
||||||
|
skus: SkuExtension[] // 重写类型
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询拼团活动列表
|
||||||
|
export const getCombinationActivityPage = async (params) => {
|
||||||
|
return await request.get({ url: '/promotion/point-mall/page', params })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询拼团活动详情
|
||||||
|
export const getCombinationActivity = async (id: number) => {
|
||||||
|
return await request.get({ url: '/promotion/combination-activity/get?id=' + id })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增拼团活动
|
||||||
|
export const createCombinationActivity = async (data: CombinationActivityVO) => {
|
||||||
|
return await request.post({ url: '/promotion/point-mall/create', data })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改拼团活动
|
||||||
|
export const updateCombinationActivity = async (data: CombinationActivityVO) => {
|
||||||
|
return await request.put({ url: '/promotion/combination-activity/update', data })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关闭拼团活动
|
||||||
|
export const closeCombinationActivity = async (id: number) => {
|
||||||
|
return await request.put({ url: '/promotion/point-mall/closePointMall?id=' + id })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除拼团活动
|
||||||
|
export const deleteCombinationActivity = async (id: number) => {
|
||||||
|
return await request.delete({ url: '/promotion/point-mall/delete?id=' + id })
|
||||||
|
}
|
48
yudao-admin-vue3/src/api/mall/promotion/pointmall/index.ts
Normal file
48
yudao-admin-vue3/src/api/mall/promotion/pointmall/index.ts
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import request from '@/config/axios'
|
||||||
|
|
||||||
|
// 积分商城 VO
|
||||||
|
export interface PointMallVO {
|
||||||
|
id: number // 编号
|
||||||
|
productPicUrl: string // 商品主图
|
||||||
|
title: string // 标题
|
||||||
|
skuIds: string // sku数组
|
||||||
|
spuId: number // spu编号
|
||||||
|
exchangePointNum: number // 兑换积分
|
||||||
|
limited: number // 限量
|
||||||
|
surplusLimited: number // 剩余限量
|
||||||
|
status: number // 状态
|
||||||
|
sort: number // 排序
|
||||||
|
}
|
||||||
|
|
||||||
|
// 积分商城 API
|
||||||
|
export const PointMallApi = {
|
||||||
|
// 查询积分商城分页
|
||||||
|
getPointMallPage: async (params: any) => {
|
||||||
|
return await request.get({ url: `/promotion/point-mall/page`, params })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 查询积分商城详情
|
||||||
|
getPointMall: async (id: number) => {
|
||||||
|
return await request.get({ url: `/promotion/point-mall/get?id=` + id })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 新增积分商城
|
||||||
|
createPointMall: async (data: PointMallVO) => {
|
||||||
|
return await request.post({ url: `/promotion/point-mall/create`, data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 修改积分商城
|
||||||
|
updatePointMall: async (data: PointMallVO) => {
|
||||||
|
return await request.put({ url: `/promotion/point-mall/update`, data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除积分商城
|
||||||
|
deletePointMall: async (id: number) => {
|
||||||
|
return await request.delete({ url: `/promotion/point-mall/delete?id=` + id })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 导出积分商城 Excel
|
||||||
|
exportPointMall: async (params) => {
|
||||||
|
return await request.download({ url: `/promotion/point-mall/export-excel`, params })
|
||||||
|
}
|
||||||
|
}
|
@ -186,6 +186,7 @@ export enum DICT_TYPE {
|
|||||||
|
|
||||||
// ========== MALL - 商品模块 ==========
|
// ========== MALL - 商品模块 ==========
|
||||||
PRODUCT_SPU_STATUS = 'product_spu_status', //商品状态
|
PRODUCT_SPU_STATUS = 'product_spu_status', //商品状态
|
||||||
|
POINT_PRODUCT_STATUS='point_product_status',//积分商品状态
|
||||||
|
|
||||||
// ========== MALL - 交易模块 ==========
|
// ========== MALL - 交易模块 ==========
|
||||||
EXPRESS_CHARGE_MODE = 'trade_delivery_express_charge_mode', //快递的计费方式
|
EXPRESS_CHARGE_MODE = 'trade_delivery_express_charge_mode', //快递的计费方式
|
||||||
|
@ -0,0 +1,205 @@
|
|||||||
|
<template>
|
||||||
|
<Dialog :title="dialogTitle" v-model="dialogVisible">
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
:rules="formRules"
|
||||||
|
label-width="100px"
|
||||||
|
v-loading="formLoading"
|
||||||
|
>
|
||||||
|
<el-form-item label="商品主图" prop="productPicUrl">
|
||||||
|
<UploadImg v-model="formData.productPicUrl" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="标题" prop="title">
|
||||||
|
<el-input v-model="formData.title" placeholder="请输入标题" />
|
||||||
|
</el-form-item>
|
||||||
|
<!-- <el-form-item label="sku数组" prop="skuIds">-->
|
||||||
|
<!-- <el-input v-model="formData.skuIds" placeholder="请输入sku数组" />-->
|
||||||
|
<!-- </el-form-item>-->
|
||||||
|
<!-- <el-form-item label="spu编号" prop="spuId">-->
|
||||||
|
<!-- <el-input v-model="formData.spuId" placeholder="请输入spu编号" />-->
|
||||||
|
<!-- </el-form-item>-->
|
||||||
|
<el-form-item label="兑换积分" prop="exchangePointNum">
|
||||||
|
<el-input v-model="formData.exchangePointNum" placeholder="请输入兑换积分" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="限量" prop="limited">
|
||||||
|
<el-input v-model="formData.limited" placeholder="请输入限量" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="剩余限量" prop="surplusLimited">
|
||||||
|
<el-input v-model="formData.surplusLimited" placeholder="请输入剩余限量" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-radio-group v-model="formData.status">
|
||||||
|
<el-radio
|
||||||
|
v-for="dict in getIntDictOptions(DICT_TYPE.POINT_PRODUCT_STATUS)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.value"
|
||||||
|
>
|
||||||
|
{{ dict.label }}
|
||||||
|
</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="排序" prop="sort">
|
||||||
|
<el-input v-model="formData.sort" placeholder="请输入排序" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-button @click="spuSelectRef.open()">选择商品</el-button>
|
||||||
|
<!-- <SpuAndSkuList-->
|
||||||
|
<!-- ref="spuAndSkuListRef"-->
|
||||||
|
<!-- :spu-list="spuList"-->
|
||||||
|
<!-- :spu-property-list-p="spuPropertyList"-->
|
||||||
|
<!-- >-->
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||||
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
<SpuSelect ref="spuSelectRef" :isSelectSku="true" @confirm="selectSpu" />
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||||
|
import { PointMallApi, PointMallVO } from '@/api/mall/promotion/pointmall'
|
||||||
|
import { SpuAndSkuList, SpuProperty, SpuSelect } from '@/views/mall/promotion/components'
|
||||||
|
import {CombinationProductVO} from "@/api/mall/promotion/combination/combinationActivity";
|
||||||
|
import * as CombinationActivityApi from "@/api/mall/promotion/combination/combinationActivity";
|
||||||
|
import * as ProductSpuApi from "@/api/mall/product/spu";
|
||||||
|
import {formatToFraction} from "@/utils";
|
||||||
|
import {getPropertyList} from "@/views/mall/product/spu/components";
|
||||||
|
|
||||||
|
|
||||||
|
/** 积分商城 表单 */
|
||||||
|
defineOptions({ name: 'PointMallForm' })
|
||||||
|
|
||||||
|
const { t } = useI18n() // 国际化
|
||||||
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||||
|
const dialogTitle = ref('') // 弹窗的标题
|
||||||
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||||
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||||
|
const spuSelectRef = ref() // 商品和属性选择 Ref
|
||||||
|
const spuList = ref<CombinationActivityApi.SpuExtension[]>([]) // 选择的 spu
|
||||||
|
const spuPropertyList = ref<SpuProperty<CombinationActivityApi.SpuExtension>[]>([])
|
||||||
|
const formData = ref({
|
||||||
|
id: undefined,
|
||||||
|
productPicUrl: undefined,
|
||||||
|
title: undefined,
|
||||||
|
skuIds: undefined,
|
||||||
|
spuId: undefined,
|
||||||
|
exchangePointNum: undefined,
|
||||||
|
limited: undefined,
|
||||||
|
surplusLimited: undefined,
|
||||||
|
status: undefined,
|
||||||
|
sort: undefined
|
||||||
|
})
|
||||||
|
const formRules = reactive({
|
||||||
|
})
|
||||||
|
const formRef = ref() // 表单 Ref
|
||||||
|
|
||||||
|
/** 打开弹窗 */
|
||||||
|
const open = async (type: string, id?: number) => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
dialogTitle.value = t('action.' + type)
|
||||||
|
formType.value = type
|
||||||
|
resetForm()
|
||||||
|
// 修改时,设置数据
|
||||||
|
if (id) {
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
formData.value = await PointMallApi.getPointMall(id)
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
|
/** 提交表单 */
|
||||||
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||||
|
const submitForm = async () => {
|
||||||
|
// 校验表单
|
||||||
|
await formRef.value.validate()
|
||||||
|
// 提交请求
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
const data = formData.value as unknown as PointMallVO
|
||||||
|
if (formType.value === 'create') {
|
||||||
|
await PointMallApi.createPointMall(data)
|
||||||
|
message.success(t('common.createSuccess'))
|
||||||
|
} else {
|
||||||
|
await PointMallApi.updatePointMall(data)
|
||||||
|
message.success(t('common.updateSuccess'))
|
||||||
|
}
|
||||||
|
dialogVisible.value = false
|
||||||
|
// 发送操作成功的事件
|
||||||
|
emit('success')
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectSpu = (spuId: number, skuIds: number[]) => {
|
||||||
|
// formRef.value.setValues({ spuId })
|
||||||
|
getSpuDetails(spuId, skuIds)
|
||||||
|
console.log(spuList,'spuList')
|
||||||
|
console.log(spuPropertyList,'spuPropertyList')
|
||||||
|
}
|
||||||
|
const getSpuDetails = async (
|
||||||
|
spuId: number,
|
||||||
|
skuIds: number[] | undefined,
|
||||||
|
products?: CombinationProductVO[]
|
||||||
|
) => {
|
||||||
|
const spuProperties: SpuProperty<CombinationActivityApi.SpuExtension>[] = []
|
||||||
|
const res = (await ProductSpuApi.getSpuDetailList([
|
||||||
|
spuId
|
||||||
|
])) as CombinationActivityApi.SpuExtension[]
|
||||||
|
if (res.length == 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
spuList.value = []
|
||||||
|
// 因为只能选择一个
|
||||||
|
const spu = res[0]
|
||||||
|
const selectSkus =
|
||||||
|
typeof skuIds === 'undefined' ? spu?.skus : spu?.skus?.filter((sku) => skuIds.includes(sku.id!))
|
||||||
|
selectSkus?.forEach((sku) => {
|
||||||
|
let config: CombinationProductVO = {
|
||||||
|
spuId: spu.id!,
|
||||||
|
skuId: sku.id!,
|
||||||
|
combinationPrice: 0
|
||||||
|
}
|
||||||
|
if (typeof products !== 'undefined') {
|
||||||
|
const product = products.find((item) => item.skuId === sku.id)
|
||||||
|
if (product) {
|
||||||
|
product.combinationPrice = formatToFraction(product.combinationPrice)
|
||||||
|
}
|
||||||
|
config = product || config
|
||||||
|
}
|
||||||
|
sku.productConfig = config
|
||||||
|
})
|
||||||
|
spu.skus = selectSkus as CombinationActivityApi.SkuExtension[]
|
||||||
|
spuProperties.push({
|
||||||
|
spuId: spu.id!,
|
||||||
|
spuDetail: spu,
|
||||||
|
propertyList: getPropertyList(spu)
|
||||||
|
})
|
||||||
|
spuList.value.push(spu)
|
||||||
|
spuPropertyList.value = spuProperties
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置表单 */
|
||||||
|
const resetForm = () => {
|
||||||
|
formData.value = {
|
||||||
|
id: undefined,
|
||||||
|
productPicUrl: undefined,
|
||||||
|
title: undefined,
|
||||||
|
skuIds: undefined,
|
||||||
|
spuId: undefined,
|
||||||
|
exchangePointNum: undefined,
|
||||||
|
limited: undefined,
|
||||||
|
surplusLimited: undefined,
|
||||||
|
status: undefined,
|
||||||
|
sort: undefined
|
||||||
|
}
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
}
|
||||||
|
</script>
|
@ -0,0 +1,192 @@
|
|||||||
|
<template>
|
||||||
|
<Dialog v-model="dialogVisible" :title="dialogTitle" width="65%">
|
||||||
|
<Form
|
||||||
|
ref="formRef"
|
||||||
|
v-loading="formLoading"
|
||||||
|
:is-col="true"
|
||||||
|
:rules="rules"
|
||||||
|
:schema="allSchemas.formSchema"
|
||||||
|
class="mt-10px"
|
||||||
|
>
|
||||||
|
<template #spuId>
|
||||||
|
<el-button @click="spuSelectRef.open()">选择商品</el-button>
|
||||||
|
<SpuAndSkuList
|
||||||
|
ref="spuAndSkuListRef"
|
||||||
|
:rule-config="ruleConfig"
|
||||||
|
:spu-list="spuList"
|
||||||
|
:spu-property-list-p="spuPropertyList"
|
||||||
|
>
|
||||||
|
<el-table-column align="center" label="兑换积分" min-width="168">
|
||||||
|
<template #default="{ row: sku }">
|
||||||
|
<el-input-number
|
||||||
|
v-model="sku.productConfig.combinationPrice"
|
||||||
|
:min="0"
|
||||||
|
:precision="0"
|
||||||
|
:step="1"
|
||||||
|
class="w-100%"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</SpuAndSkuList>
|
||||||
|
</template>
|
||||||
|
</Form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
<SpuSelect ref="spuSelectRef" :isSelectSku="true" @confirm="selectSpu" />
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import * as CombinationActivityApi from '@/api/mall/promotion/pointmall/combinationActivity'
|
||||||
|
import { CombinationProductVO } from '@/api/mall/promotion/pointmall/combinationActivity'
|
||||||
|
import { allSchemas, rules } from './combinationActivity.data'
|
||||||
|
import { SpuAndSkuList, SpuProperty, SpuSelect } from '@/views/mall/promotion/components'
|
||||||
|
import { getPropertyList, RuleConfig } from '@/views/mall/product/spu/components'
|
||||||
|
import * as ProductSpuApi from '@/api/mall/product/spu'
|
||||||
|
import { convertToInteger, formatToFraction } from '@/utils'
|
||||||
|
import { cloneDeep } from 'lodash-es'
|
||||||
|
|
||||||
|
defineOptions({ name: 'PromotionCombinationActivityForm' })
|
||||||
|
|
||||||
|
const { t } = useI18n() // 国际化
|
||||||
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||||
|
const dialogTitle = ref('') // 弹窗的标题
|
||||||
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||||
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||||
|
const formRef = ref() // 表单 Ref
|
||||||
|
|
||||||
|
// ================= 商品选择相关 =================
|
||||||
|
|
||||||
|
const spuSelectRef = ref() // 商品和属性选择 Ref
|
||||||
|
const spuAndSkuListRef = ref() // sku 秒杀配置组件Ref
|
||||||
|
const spuList = ref<CombinationActivityApi.SpuExtension[]>([]) // 选择的 spu
|
||||||
|
const spuPropertyList = ref<SpuProperty<CombinationActivityApi.SpuExtension>[]>([])
|
||||||
|
const ruleConfig: RuleConfig[] = [
|
||||||
|
{
|
||||||
|
name: 'productConfig.combinationPrice',
|
||||||
|
rule: (arg) => arg >= 1,
|
||||||
|
message: '所兑换的积分数量不能小于1 !!!'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
const selectSpu = (spuId: number, skuIds: number[]) => {
|
||||||
|
formRef.value.setValues({ spuId })
|
||||||
|
getSpuDetails(spuId, skuIds)
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取 SPU 详情
|
||||||
|
*/
|
||||||
|
const getSpuDetails = async (
|
||||||
|
spuId: number,
|
||||||
|
skuIds: number[] | undefined,
|
||||||
|
products?: CombinationProductVO[]
|
||||||
|
) => {
|
||||||
|
const spuProperties: SpuProperty<CombinationActivityApi.SpuExtension>[] = []
|
||||||
|
const res = (await ProductSpuApi.getSpuDetailList([
|
||||||
|
spuId
|
||||||
|
])) as CombinationActivityApi.SpuExtension[]
|
||||||
|
if (res.length == 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
spuList.value = []
|
||||||
|
// 因为只能选择一个
|
||||||
|
const spu = res[0]
|
||||||
|
const selectSkus =
|
||||||
|
typeof skuIds === 'undefined' ? spu?.skus : spu?.skus?.filter((sku) => skuIds.includes(sku.id!))
|
||||||
|
selectSkus?.forEach((sku) => {
|
||||||
|
let config: CombinationProductVO = {
|
||||||
|
spuId: spu.id!,
|
||||||
|
skuId: sku.id!,
|
||||||
|
combinationPrice: 0
|
||||||
|
}
|
||||||
|
if (typeof products !== 'undefined') {
|
||||||
|
const product = products.find((item) => item.skuId === sku.id)
|
||||||
|
if (product) {
|
||||||
|
product.combinationPrice = formatToFraction(product.combinationPrice)
|
||||||
|
}
|
||||||
|
config = product || config
|
||||||
|
}
|
||||||
|
sku.productConfig = config
|
||||||
|
})
|
||||||
|
spu.skus = selectSkus as CombinationActivityApi.SkuExtension[]
|
||||||
|
spuProperties.push({
|
||||||
|
spuId: spu.id!,
|
||||||
|
spuDetail: spu,
|
||||||
|
propertyList: getPropertyList(spu)
|
||||||
|
})
|
||||||
|
spuList.value.push(spu)
|
||||||
|
spuPropertyList.value = spuProperties
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= end =================
|
||||||
|
|
||||||
|
/** 打开弹窗 */
|
||||||
|
const open = async (type: string, id?: number) => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
dialogTitle.value = t('action.' + type)
|
||||||
|
formType.value = type
|
||||||
|
await resetForm()
|
||||||
|
// 修改时,设置数据
|
||||||
|
if (id) {
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
const data = (await CombinationActivityApi.getCombinationActivity(
|
||||||
|
id
|
||||||
|
)) as CombinationActivityApi.CombinationActivityVO
|
||||||
|
await getSpuDetails(data.spuId!, data.products?.map((sku) => sku.skuId), data.products)
|
||||||
|
formRef.value.setValues(data)
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
|
/** 重置表单 */
|
||||||
|
const resetForm = async () => {
|
||||||
|
spuList.value = []
|
||||||
|
spuPropertyList.value = []
|
||||||
|
await nextTick()
|
||||||
|
formRef.value.getElFormRef().resetFields()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交表单 */
|
||||||
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||||
|
const submitForm = async () => {
|
||||||
|
// 校验表单
|
||||||
|
if (!formRef) return
|
||||||
|
const valid = await formRef.value.getElFormRef().validate()
|
||||||
|
if (!valid) return
|
||||||
|
// 提交请求
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
// 获得拼团商品配置
|
||||||
|
const products = cloneDeep(spuAndSkuListRef.value.getSkuConfigs('productConfig'))
|
||||||
|
products.forEach((item: CombinationActivityApi.CombinationProductVO) => {
|
||||||
|
item.combinationPrice = convertToInteger(item.combinationPrice)
|
||||||
|
})
|
||||||
|
const data = cloneDeep(formRef.value.formModel) as CombinationActivityApi.CombinationActivityVO
|
||||||
|
data.products = products
|
||||||
|
// 真正提交
|
||||||
|
if (formType.value === 'create') {
|
||||||
|
const dataMessage = await CombinationActivityApi.createCombinationActivity(data)
|
||||||
|
if (dataMessage === 0){
|
||||||
|
message.warning("新增失败,请勿重复添加!")
|
||||||
|
}
|
||||||
|
if (dataMessage === 1){
|
||||||
|
message.success(t('common.createSuccess'))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await CombinationActivityApi.updateCombinationActivity(data)
|
||||||
|
message.success(t('common.updateSuccess'))
|
||||||
|
}
|
||||||
|
dialogVisible.value = false
|
||||||
|
// 发送操作成功的事件
|
||||||
|
emit('success')
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
@ -0,0 +1,140 @@
|
|||||||
|
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
|
||||||
|
import { dateFormatter2 } from '@/utils/formatTime'
|
||||||
|
|
||||||
|
// 表单校验
|
||||||
|
export const rules = reactive({
|
||||||
|
// name: [required],
|
||||||
|
totalLimitCount: [required],
|
||||||
|
// singleLimitCount: [required],
|
||||||
|
// startTime: [required],
|
||||||
|
// endTime: [required],
|
||||||
|
// userSize: [required],
|
||||||
|
// limitDuration: [required],
|
||||||
|
// virtualGroup: [required]
|
||||||
|
})
|
||||||
|
|
||||||
|
// CrudSchema https://doc.iocoder.cn/vue3/crud-schema/
|
||||||
|
const crudSchemas = reactive<CrudSchema[]>([
|
||||||
|
// {
|
||||||
|
// label: '拼团名称',
|
||||||
|
// field: 'name',
|
||||||
|
// isSearch: true,
|
||||||
|
// isTable: false,
|
||||||
|
// form: {
|
||||||
|
// colProps: {
|
||||||
|
// span: 24
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// label: '拼团开始时间',
|
||||||
|
// field: 'startTime',
|
||||||
|
// formatter: dateFormatter2,
|
||||||
|
// isSearch: true,
|
||||||
|
// search: {
|
||||||
|
// component: 'DatePicker',
|
||||||
|
// componentProps: {
|
||||||
|
// valueFormat: 'YYYY-MM-DD',
|
||||||
|
// type: 'daterange'
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// form: {
|
||||||
|
// component: 'DatePicker',
|
||||||
|
// componentProps: {
|
||||||
|
// type: 'date',
|
||||||
|
// valueFormat: 'x'
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// table: {
|
||||||
|
// width: 120
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// label: '拼团结束时间',
|
||||||
|
// field: 'endTime',
|
||||||
|
// formatter: dateFormatter2,
|
||||||
|
// isSearch: true,
|
||||||
|
// search: {
|
||||||
|
// component: 'DatePicker',
|
||||||
|
// componentProps: {
|
||||||
|
// valueFormat: 'YYYY-MM-DD',
|
||||||
|
// type: 'daterange'
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// form: {
|
||||||
|
// component: 'DatePicker',
|
||||||
|
// componentProps: {
|
||||||
|
// type: 'date',
|
||||||
|
// valueFormat: 'x'
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// table: {
|
||||||
|
// width: 120
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// label: '参与人数',
|
||||||
|
// field: 'userSize',
|
||||||
|
// isSearch: false,
|
||||||
|
// form: {
|
||||||
|
// component: 'InputNumber',
|
||||||
|
// labelMessage: '参与人数不能少于两人',
|
||||||
|
// value: 2
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// label: '限制时长',
|
||||||
|
// field: 'limitDuration',
|
||||||
|
// isSearch: false,
|
||||||
|
// isTable: false,
|
||||||
|
// form: {
|
||||||
|
// component: 'InputNumber',
|
||||||
|
// labelMessage: '限制时长(小时)',
|
||||||
|
// componentProps: {
|
||||||
|
// placeholder: '请输入限制时长(小时)'
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
label: '总限购数量',
|
||||||
|
field: 'totalLimitCount',
|
||||||
|
isSearch: false,
|
||||||
|
isTable: false,
|
||||||
|
form: {
|
||||||
|
component: 'InputNumber',
|
||||||
|
value: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// label: '单次限购数量',
|
||||||
|
// field: 'singleLimitCount',
|
||||||
|
// isSearch: false,
|
||||||
|
// isTable: false,
|
||||||
|
// form: {
|
||||||
|
// component: 'InputNumber',
|
||||||
|
// value: 0
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// label: '虚拟成团',
|
||||||
|
// field: 'virtualGroup',
|
||||||
|
// dictType: DICT_TYPE.INFRA_BOOLEAN_STRING,
|
||||||
|
// dictClass: 'boolean',
|
||||||
|
// isSearch: true,
|
||||||
|
// form: {
|
||||||
|
// component: 'Radio',
|
||||||
|
// value: false
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
label: '拼团商品',
|
||||||
|
field: 'spuId',
|
||||||
|
isSearch: false,
|
||||||
|
form: {
|
||||||
|
colProps: {
|
||||||
|
span: 24
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
])
|
||||||
|
export const { allSchemas } = useCrudSchemas(crudSchemas)
|
@ -0,0 +1,227 @@
|
|||||||
|
<template>
|
||||||
|
|
||||||
|
<ContentWrap>
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
|
<el-form
|
||||||
|
class="-mb-15px"
|
||||||
|
:model="queryParams"
|
||||||
|
ref="queryFormRef"
|
||||||
|
:inline="true"
|
||||||
|
label-width="68px"
|
||||||
|
>
|
||||||
|
<el-form-item label="活动名称" prop="name">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.name"
|
||||||
|
placeholder="请输入活动名称"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="活动状态" prop="status">
|
||||||
|
<el-select
|
||||||
|
v-model="queryParams.status"
|
||||||
|
placeholder="请选择活动状态"
|
||||||
|
clearable
|
||||||
|
class="!w-240px"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||||
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
@click="openForm('create')"
|
||||||
|
v-hasPermi="['promotion:combination-activity:create']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<ContentWrap>
|
||||||
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||||
|
<el-table-column label="编号" align="center" prop="id" />
|
||||||
|
<el-table-column label="商品主图" align="center" prop="productPicUrl" min-width="100">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-image
|
||||||
|
:src="scope.row.productPicUrl"
|
||||||
|
class="h-30px w-30px"
|
||||||
|
:preview-src-list="[scope.row.productPicUrl]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="标题" align="center" prop="title" />
|
||||||
|
<!-- <el-table-column label="sku数组" align="center" prop="skuIds" />-->
|
||||||
|
<!-- <el-table-column label="spu编号" align="center" prop="spuId" />-->
|
||||||
|
<el-table-column label="兑换积分" align="center" prop="exchangePointNum" />
|
||||||
|
<el-table-column label="限量" align="center" prop="limited" />
|
||||||
|
<el-table-column label="剩余限量" align="center" prop="surplusLimited" />
|
||||||
|
<el-table-column label="状态" align="center" prop="status">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.POINT_PRODUCT_STATUS" :value="scope.row.status" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<!-- <el-table-column label="排序" align="center" prop="sort" />-->
|
||||||
|
<el-table-column
|
||||||
|
label="创建时间"
|
||||||
|
align="center"
|
||||||
|
prop="createTime"
|
||||||
|
:formatter="dateFormatter"
|
||||||
|
width="180px"
|
||||||
|
/>
|
||||||
|
<el-table-column label="操作" align="center" width="150px" fixed="right">
|
||||||
|
<template #default="scope">
|
||||||
|
<!-- <el-button-->
|
||||||
|
<!-- link-->
|
||||||
|
<!-- type="primary"-->
|
||||||
|
<!-- @click="openForm('update', scope.row.id)"-->
|
||||||
|
<!-- v-hasPermi="['promotion:combination-activity:update']"-->
|
||||||
|
<!-- >-->
|
||||||
|
<!-- 编辑-->
|
||||||
|
<!-- </el-button>-->
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
@click="handleClose(scope.row.id)"
|
||||||
|
v-if="scope.row.status === 0"
|
||||||
|
v-hasPermi="['promotion:combination-activity:close']"
|
||||||
|
>
|
||||||
|
下架
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="handleClose(scope.row.id)"
|
||||||
|
v-if="scope.row.status === 1"
|
||||||
|
v-hasPermi="['promotion:combination-activity:delete']"
|
||||||
|
>
|
||||||
|
上架
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
@click="handleDelete(scope.row.id)"
|
||||||
|
v-hasPermi="['promotion:combination-activity:delete']"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<!-- 分页 -->
|
||||||
|
<Pagination
|
||||||
|
:total="total"
|
||||||
|
v-model:page="queryParams.pageNo"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<!-- 表单弹窗:添加/修改 -->
|
||||||
|
<CombinationActivityForm ref="formRef" @success="getList" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||||
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
|
import * as CombinationActivityApi from '@/api/mall/promotion/pointmall/combinationActivity'
|
||||||
|
import CombinationActivityForm from './CombinationActivityForm.vue'
|
||||||
|
import { formatDate } from '@/utils/formatTime'
|
||||||
|
import { fenToYuanFormat } from '@/utils/formatter'
|
||||||
|
import { fenToYuan } from '@/utils'
|
||||||
|
|
||||||
|
defineOptions({ name: 'PromotionBargainActivity' })
|
||||||
|
|
||||||
|
const message = useMessage() // 消息弹窗
|
||||||
|
const { t } = useI18n() // 国际化
|
||||||
|
|
||||||
|
const loading = ref(true) // 列表的加载中
|
||||||
|
const total = ref(0) // 列表的总页数
|
||||||
|
const list = ref([]) // 列表的数据
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
name: null,
|
||||||
|
status: null
|
||||||
|
})
|
||||||
|
const queryFormRef = ref() // 搜索的表单
|
||||||
|
const exportLoading = ref(false) // 导出的加载中
|
||||||
|
|
||||||
|
/** 查询列表 */
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const data = await CombinationActivityApi.getCombinationActivityPage(queryParams)
|
||||||
|
list.value = data.list
|
||||||
|
total.value = data.total
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
const handleQuery = () => {
|
||||||
|
queryParams.pageNo = 1
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
const resetQuery = () => {
|
||||||
|
queryFormRef.value.resetFields()
|
||||||
|
handleQuery()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 添加/修改操作 */
|
||||||
|
const formRef = ref()
|
||||||
|
const openForm = (type: string, id?: number) => {
|
||||||
|
formRef.value.open(type, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO 芋艿:这里要改下
|
||||||
|
/** 关闭按钮操作 */
|
||||||
|
const handleClose = async (id: number) => {
|
||||||
|
try {
|
||||||
|
// 关闭的二次确认
|
||||||
|
await message.confirm('确认操作该积分商品吗?')
|
||||||
|
// 发起关闭
|
||||||
|
await CombinationActivityApi.closeCombinationActivity(id)
|
||||||
|
message.success('操作成功')
|
||||||
|
// 刷新列表
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
const handleDelete = async (id: number) => {
|
||||||
|
try {
|
||||||
|
// 删除的二次确认
|
||||||
|
await message.delConfirm()
|
||||||
|
// 发起删除
|
||||||
|
await CombinationActivityApi.deleteCombinationActivity(id)
|
||||||
|
message.success(t('common.delSuccess'))
|
||||||
|
// 刷新列表
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatCombinationPrice = (products) => {
|
||||||
|
const combinationPrice = Math.min(...products.map((item) => item.combinationPrice))
|
||||||
|
return `¥${fenToYuan(combinationPrice)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化 **/
|
||||||
|
onMounted(async () => {
|
||||||
|
await getList()
|
||||||
|
})
|
||||||
|
</script>
|
277
yudao-admin-vue3/src/views/mall/promotion/pointmall/index.vue
Normal file
277
yudao-admin-vue3/src/views/mall/promotion/pointmall/index.vue
Normal file
@ -0,0 +1,277 @@
|
|||||||
|
<template>
|
||||||
|
<ContentWrap>
|
||||||
|
<!-- 搜索工作栏 -->
|
||||||
|
<el-form
|
||||||
|
class="-mb-15px"
|
||||||
|
:model="queryParams"
|
||||||
|
ref="queryFormRef"
|
||||||
|
:inline="true"
|
||||||
|
label-width="68px"
|
||||||
|
>
|
||||||
|
<el-form-item label="标题" prop="title">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.title"
|
||||||
|
placeholder="请输入标题"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<!-- <el-form-item label="sku数组" prop="skuIds">-->
|
||||||
|
<!-- <el-input-->
|
||||||
|
<!-- v-model="queryParams.skuIds"-->
|
||||||
|
<!-- placeholder="请输入sku数组"-->
|
||||||
|
<!-- clearable-->
|
||||||
|
<!-- @keyup.enter="handleQuery"-->
|
||||||
|
<!-- class="!w-240px"-->
|
||||||
|
<!-- />-->
|
||||||
|
<!-- </el-form-item>-->
|
||||||
|
<!-- <el-form-item label="spu编号" prop="spuId">-->
|
||||||
|
<!-- <el-input-->
|
||||||
|
<!-- v-model="queryParams.spuId"-->
|
||||||
|
<!-- placeholder="请输入spu编号"-->
|
||||||
|
<!-- clearable-->
|
||||||
|
<!-- @keyup.enter="handleQuery"-->
|
||||||
|
<!-- class="!w-240px"-->
|
||||||
|
<!-- />-->
|
||||||
|
<!-- </el-form-item>-->
|
||||||
|
<el-form-item label="兑换积分" prop="exchangePointNum">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.exchangePointNum"
|
||||||
|
placeholder="请输入兑换积分"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="限量" prop="limited">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.limited"
|
||||||
|
placeholder="请输入限量"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="剩余限量" prop="surplusLimited">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.surplusLimited"
|
||||||
|
placeholder="请输入剩余限量"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-select
|
||||||
|
v-model="queryParams.status"
|
||||||
|
placeholder="请选择状态"
|
||||||
|
clearable
|
||||||
|
class="!w-240px"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in getIntDictOptions(DICT_TYPE.POINT_PRODUCT_STATUS)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="排序" prop="sort">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.sort"
|
||||||
|
placeholder="请输入排序"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="创建时间" prop="createTime">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="queryParams.createTime"
|
||||||
|
value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
type="daterange"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||||
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
@click="openForm('create')"
|
||||||
|
v-hasPermi="['promotion:point-mall:create']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
@click="handleExport"
|
||||||
|
:loading="exportLoading"
|
||||||
|
v-hasPermi="['promotion:point-mall:export']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<ContentWrap>
|
||||||
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||||
|
<el-table-column label="编号" align="center" prop="id" />
|
||||||
|
<el-table-column label="商品主图" align="center" prop="productPicUrl" />
|
||||||
|
<el-table-column label="标题" align="center" prop="title" />
|
||||||
|
<!-- <el-table-column label="sku数组" align="center" prop="skuIds" />-->
|
||||||
|
<!-- <el-table-column label="spu编号" align="center" prop="spuId" />-->
|
||||||
|
<el-table-column label="兑换积分" align="center" prop="exchangePointNum" />
|
||||||
|
<el-table-column label="限量" align="center" prop="limited" />
|
||||||
|
<el-table-column label="剩余限量" align="center" prop="surplusLimited" />
|
||||||
|
<el-table-column label="状态" align="center" prop="status">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.POINT_PRODUCT_STATUS" :value="scope.row.status" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="排序" align="center" prop="sort" />
|
||||||
|
<el-table-column
|
||||||
|
label="创建时间"
|
||||||
|
align="center"
|
||||||
|
prop="createTime"
|
||||||
|
:formatter="dateFormatter"
|
||||||
|
width="180px"
|
||||||
|
/>
|
||||||
|
<el-table-column label="操作" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="openForm('update', scope.row.id)"
|
||||||
|
v-hasPermi="['promotion:point-mall:update']"
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
@click="handleDelete(scope.row.id)"
|
||||||
|
v-hasPermi="['promotion:point-mall:delete']"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<!-- 分页 -->
|
||||||
|
<Pagination
|
||||||
|
:total="total"
|
||||||
|
v-model:page="queryParams.pageNo"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<!-- 表单弹窗:添加/修改 -->
|
||||||
|
<PointMallForm ref="formRef" @success="getList" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||||
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
|
import download from '@/utils/download'
|
||||||
|
import { PointMallApi, PointMallVO } from '@/api/mall/promotion/pointmall'
|
||||||
|
import PointMallForm from './PointMallForm.vue'
|
||||||
|
|
||||||
|
/** 积分商城 列表 */
|
||||||
|
defineOptions({ name: 'PointMall' })
|
||||||
|
|
||||||
|
const message = useMessage() // 消息弹窗
|
||||||
|
const { t } = useI18n() // 国际化
|
||||||
|
|
||||||
|
const loading = ref(true) // 列表的加载中
|
||||||
|
const list = ref<PointMallVO[]>([]) // 列表的数据
|
||||||
|
const total = ref(0) // 列表的总页数
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
productPicUrl: undefined,
|
||||||
|
title: undefined,
|
||||||
|
skuIds: undefined,
|
||||||
|
spuId: undefined,
|
||||||
|
exchangePointNum: undefined,
|
||||||
|
limited: undefined,
|
||||||
|
surplusLimited: undefined,
|
||||||
|
status: undefined,
|
||||||
|
sort: undefined,
|
||||||
|
createTime: []
|
||||||
|
})
|
||||||
|
const queryFormRef = ref() // 搜索的表单
|
||||||
|
const exportLoading = ref(false) // 导出的加载中
|
||||||
|
|
||||||
|
/** 查询列表 */
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const data = await PointMallApi.getPointMallPage(queryParams)
|
||||||
|
list.value = data.list
|
||||||
|
total.value = data.total
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
const handleQuery = () => {
|
||||||
|
queryParams.pageNo = 1
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
const resetQuery = () => {
|
||||||
|
queryFormRef.value.resetFields()
|
||||||
|
handleQuery()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 添加/修改操作 */
|
||||||
|
const formRef = ref()
|
||||||
|
const openForm = (type: string, id?: number) => {
|
||||||
|
formRef.value.open(type, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
const handleDelete = async (id: number) => {
|
||||||
|
try {
|
||||||
|
// 删除的二次确认
|
||||||
|
await message.delConfirm()
|
||||||
|
// 发起删除
|
||||||
|
await PointMallApi.deletePointMall(id)
|
||||||
|
message.success(t('common.delSuccess'))
|
||||||
|
// 刷新列表
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
const handleExport = async () => {
|
||||||
|
try {
|
||||||
|
// 导出的二次确认
|
||||||
|
await message.exportConfirm()
|
||||||
|
// 发起导出
|
||||||
|
exportLoading.value = true
|
||||||
|
const data = await PointMallApi.exportPointMall(queryParams)
|
||||||
|
download.excel(data, '积分商城.xls')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
exportLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化 **/
|
||||||
|
onMounted(() => {
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
</script>
|
@ -103,4 +103,14 @@ public class ProductSpuRespDTO {
|
|||||||
*/
|
*/
|
||||||
private Boolean subCommissionType;
|
private Boolean subCommissionType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动编号
|
||||||
|
*/
|
||||||
|
private Long activityId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 兑换时所需积分数量
|
||||||
|
*/
|
||||||
|
private Integer pointCount;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -135,4 +135,6 @@ public interface ErrorCodeConstants {
|
|||||||
|
|
||||||
ErrorCode CIRCLE_REVIEW_NOT_EXISTS = new ErrorCode(1_013_022_000, "动态的评论不存在");
|
ErrorCode CIRCLE_REVIEW_NOT_EXISTS = new ErrorCode(1_013_022_000, "动态的评论不存在");
|
||||||
|
|
||||||
|
ErrorCode POINT_MALL_NOT_EXISTS = new ErrorCode(1_013_023_000, "积分商城不存在");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -114,5 +115,18 @@ public class CombinationActivityController {
|
|||||||
return success(CombinationActivityConvert.INSTANCE.convertPage(pageResult, products,
|
return success(CombinationActivityConvert.INSTANCE.convertPage(pageResult, products,
|
||||||
groupCountMap, groupSuccessCountMap, recordCountMap, spus));
|
groupCountMap, groupSuccessCountMap, recordCountMap, spus));
|
||||||
}
|
}
|
||||||
|
@GetMapping("/adminSpuList")
|
||||||
|
@Operation(summary = "获得拼团活动分页")
|
||||||
|
@Parameter(name = "count", description = "需要展示的数量", example = "6")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:combination-activity:query')")
|
||||||
|
public CommonResult<List<ProductSpuRespDTO>> getCombinationActivitySpuList(@RequestParam(name = "count", defaultValue = "6") Integer count){
|
||||||
|
List<CombinationActivityDO> doList = combinationActivityService.getCombinationActivityListByCount(count);
|
||||||
|
ArrayList<Long> list = new ArrayList<>();
|
||||||
|
for (CombinationActivityDO activityDO : doList) {
|
||||||
|
list.add(activityDO.getSpuId());
|
||||||
|
}
|
||||||
|
return success(productSpuApi.getSpuList(list));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,127 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.controller.admin.pointmall;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
||||||
|
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.pointmall.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.pointmall.PointMallDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.service.pointmall.PointMallService;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 积分商城")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/promotion/point-mall")
|
||||||
|
@Validated
|
||||||
|
public class PointMallController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PointMallService pointMallService;
|
||||||
|
@Resource
|
||||||
|
private ProductSpuApi productSpuApi;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建积分商城")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:point-mall:create')")
|
||||||
|
public CommonResult<Long> createPointMall(@Valid @RequestBody PointMallCombinationActivityCreateReqVO createReqVO) {
|
||||||
|
System.out.println("==============================");
|
||||||
|
System.out.println(createReqVO);
|
||||||
|
System.out.println("==============================");
|
||||||
|
// PointMallSaveReqVO createReqVO
|
||||||
|
PointMallDO mallBySpuId = pointMallService.getPointMallBySpuId(createReqVO.getSpuId());
|
||||||
|
if (mallBySpuId != null){
|
||||||
|
return success(0L);
|
||||||
|
}
|
||||||
|
PointMallSaveReqVO reqVO = new PointMallSaveReqVO();
|
||||||
|
ProductSpuRespDTO spu = productSpuApi.getSpu(createReqVO.getSpuId());
|
||||||
|
reqVO.setExchangePointNum(BigDecimal.valueOf(createReqVO.getProducts().get(0).getCombinationPrice().longValue()).divide(new BigDecimal(100)).intValue());
|
||||||
|
reqVO.setLimited(createReqVO.getTotalLimitCount());
|
||||||
|
reqVO.setSurplusLimited(createReqVO.getTotalLimitCount());
|
||||||
|
reqVO.setProductPicUrl(spu.getPicUrl());
|
||||||
|
reqVO.setSpuId(createReqVO.getSpuId());
|
||||||
|
reqVO.setTitle(spu.getName());
|
||||||
|
reqVO.setStatus(0);
|
||||||
|
pointMallService.createPointMall(reqVO);
|
||||||
|
return success(1L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新积分商城")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:point-mall:update')")
|
||||||
|
public CommonResult<Boolean> updatePointMall(@Valid @RequestBody PointMallSaveReqVO updateReqVO) {
|
||||||
|
pointMallService.updatePointMall(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/closePointMall")
|
||||||
|
@Operation(summary = "关闭积分商品")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:point-mall:update')")
|
||||||
|
public CommonResult<Boolean> closePointMall(@RequestParam("id") Long id) {
|
||||||
|
pointMallService.closePointMall(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除积分商城")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:point-mall:delete')")
|
||||||
|
public CommonResult<Boolean> deletePointMall(@RequestParam("id") Long id) {
|
||||||
|
pointMallService.deletePointMall(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得积分商城")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:point-mall:query')")
|
||||||
|
public CommonResult<PointMallRespVO> getPointMall(@RequestParam("id") Long id) {
|
||||||
|
PointMallDO pointMall = pointMallService.getPointMall(id);
|
||||||
|
return success(BeanUtils.toBean(pointMall, PointMallRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得积分商城分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:point-mall:query')")
|
||||||
|
public CommonResult<PageResult<PointMallRespVO>> getPointMallPage(@Valid PointMallPageReqVO pageReqVO) {
|
||||||
|
PageResult<PointMallDO> pageResult = pointMallService.getPointMallPage(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult, PointMallRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出积分商城 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:point-mall:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportPointMallExcel(@Valid PointMallPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<PointMallDO> list = pointMallService.getPointMallPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "积分商城.xls", "数据", PointMallRespVO.class,
|
||||||
|
BeanUtils.toBean(list, PointMallRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.controller.admin.pointmall.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼团活动 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||||
|
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||||
|
*
|
||||||
|
* @author HUIHUI
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PointMallCombinationActivityBaseVO {
|
||||||
|
|
||||||
|
@Schema(description = "拼团名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "越拼越省钱")
|
||||||
|
// @NotNull(message = "拼团名称不能为空")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
// @NotNull(message = "拼团商品不能为空")
|
||||||
|
private Long spuId;
|
||||||
|
|
||||||
|
@Schema(description = "总限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "16218")
|
||||||
|
@NotNull(message = "总限购数量不能为空")
|
||||||
|
private Integer totalLimitCount;
|
||||||
|
|
||||||
|
@Schema(description = "单次限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "28265")
|
||||||
|
// @NotNull(message = "单次限购数量不能为空")
|
||||||
|
private Integer singleLimitCount;
|
||||||
|
|
||||||
|
@Schema(description = "活动时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "[2022-07-01 23:59:59]")
|
||||||
|
// @NotNull(message = "活动时间不能为空")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
|
||||||
|
@Schema(description = "活动时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "[2022-07-01 23:59:59]")
|
||||||
|
// @NotNull(message = "活动时间不能为空")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
@Schema(description = "开团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222")
|
||||||
|
// @NotNull(message = "开团人数不能为空")
|
||||||
|
private Integer userSize;
|
||||||
|
|
||||||
|
@Schema(description = "虚拟成团", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||||
|
// @NotNull(message = "虚拟成团不能为空")
|
||||||
|
private Boolean virtualGroup;
|
||||||
|
|
||||||
|
@Schema(description = "限制时长(小时)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||||
|
// @NotNull(message = "限制时长不能为空")
|
||||||
|
private Integer limitDuration;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.controller.admin.pointmall.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityBaseVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductBaseVO;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 拼团活动创建 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class PointMallCombinationActivityCreateReqVO extends PointMallCombinationActivityBaseVO {
|
||||||
|
|
||||||
|
@Schema(description = "拼团商品", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@Valid
|
||||||
|
private List<CombinationProductBaseVO> products;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.controller.admin.pointmall.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 积分商城分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class PointMallPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "商品主图", example = "https://www.iocoder.cn")
|
||||||
|
private String productPicUrl;
|
||||||
|
|
||||||
|
@Schema(description = "标题")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@Schema(description = "sku数组")
|
||||||
|
private String skuIds;
|
||||||
|
|
||||||
|
@Schema(description = "spu编号", example = "22695")
|
||||||
|
private Long spuId;
|
||||||
|
|
||||||
|
@Schema(description = "兑换积分")
|
||||||
|
private Integer exchangePointNum;
|
||||||
|
|
||||||
|
@Schema(description = "限量")
|
||||||
|
private Integer limited;
|
||||||
|
|
||||||
|
@Schema(description = "剩余限量")
|
||||||
|
private Integer surplusLimited;
|
||||||
|
|
||||||
|
@Schema(description = "状态", example = "1")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "排序")
|
||||||
|
private Long sort;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.controller.admin.pointmall.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.alibaba.excel.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 积分商城 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class PointMallRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3913")
|
||||||
|
@ExcelProperty("编号")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "商品主图", example = "https://www.iocoder.cn")
|
||||||
|
@ExcelProperty("商品主图")
|
||||||
|
private String productPicUrl;
|
||||||
|
|
||||||
|
@Schema(description = "标题")
|
||||||
|
@ExcelProperty("标题")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@Schema(description = "sku数组")
|
||||||
|
@ExcelProperty("sku数组")
|
||||||
|
private String skuIds;
|
||||||
|
|
||||||
|
@Schema(description = "spu编号", example = "22695")
|
||||||
|
@ExcelProperty("spu编号")
|
||||||
|
private Long spuId;
|
||||||
|
|
||||||
|
@Schema(description = "兑换积分")
|
||||||
|
@ExcelProperty("兑换积分")
|
||||||
|
private Integer exchangePointNum;
|
||||||
|
|
||||||
|
@Schema(description = "限量")
|
||||||
|
@ExcelProperty("限量")
|
||||||
|
private Integer limited;
|
||||||
|
|
||||||
|
@Schema(description = "剩余限量")
|
||||||
|
@ExcelProperty("剩余限量")
|
||||||
|
private Integer surplusLimited;
|
||||||
|
|
||||||
|
@Schema(description = "状态", example = "1")
|
||||||
|
@ExcelProperty(value = "状态", converter = DictConvert.class)
|
||||||
|
@DictFormat("point_product_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "排序")
|
||||||
|
@ExcelProperty("排序")
|
||||||
|
private Long sort;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.controller.admin.pointmall.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 积分商城新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class PointMallSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3913")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "商品主图", example = "https://www.iocoder.cn")
|
||||||
|
private String productPicUrl;
|
||||||
|
|
||||||
|
@Schema(description = "标题")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@Schema(description = "sku数组")
|
||||||
|
private String skuIds;
|
||||||
|
|
||||||
|
@Schema(description = "spu编号", example = "22695")
|
||||||
|
private Long spuId;
|
||||||
|
|
||||||
|
@Schema(description = "兑换积分")
|
||||||
|
private Integer exchangePointNum;
|
||||||
|
|
||||||
|
@Schema(description = "限量")
|
||||||
|
private Integer limited;
|
||||||
|
|
||||||
|
@Schema(description = "剩余限量")
|
||||||
|
private Integer surplusLimited;
|
||||||
|
|
||||||
|
@Schema(description = "状态", example = "1")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "排序")
|
||||||
|
private Long sort;
|
||||||
|
|
||||||
|
}
|
@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
@ -96,4 +97,33 @@ public class SeckillActivityController {
|
|||||||
return success(SeckillActivityConvert.INSTANCE.convertPage(pageResult, products, spuList));
|
return success(SeckillActivityConvert.INSTANCE.convertPage(pageResult, products, spuList));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/adminSpuList")
|
||||||
|
@Operation(summary = "获得秒杀活动分页")
|
||||||
|
@Parameter(name = "count", description = "需要展示的数量", example = "6")
|
||||||
|
@PreAuthorize("@ss.hasPermission('promotion:seckill-activity:query')")
|
||||||
|
public CommonResult<List<ProductSpuRespDTO>> getSeckillActivitySupList(@RequestParam(name = "count", defaultValue = "6") Integer count) {
|
||||||
|
SeckillActivityPageReqVO pageVO = new SeckillActivityPageReqVO();
|
||||||
|
if (count == null || count == 0){
|
||||||
|
pageVO.setPageNo(1);
|
||||||
|
pageVO.setPageSize(count);
|
||||||
|
}
|
||||||
|
// 查询活动列表
|
||||||
|
PageResult<SeckillActivityDO> pageResult = seckillActivityService.getSeckillActivityPage(pageVO);
|
||||||
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||||
|
return success(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拼接数据
|
||||||
|
List<SeckillProductDO> products = seckillActivityService.getSeckillProductListByActivityId(
|
||||||
|
convertSet(pageResult.getList(), SeckillActivityDO::getId));
|
||||||
|
List<ProductSpuRespDTO> spuList = productSpuApi.getSpuList(
|
||||||
|
convertSet(pageResult.getList(), SeckillActivityDO::getSpuId));
|
||||||
|
PageResult<SeckillActivityRespVO> convertPage = SeckillActivityConvert.INSTANCE.convertPage(pageResult, products, spuList);
|
||||||
|
ArrayList<Long> list = new ArrayList<>();
|
||||||
|
for (SeckillActivityRespVO seckillActivityRespVO : convertPage.getList()) {
|
||||||
|
list.add(seckillActivityRespVO.getSpuId());
|
||||||
|
}
|
||||||
|
return success(productSpuApi.getSpuList(list));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,9 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
@ -67,6 +69,25 @@ public class AppCombinationActivityController {
|
|||||||
return success(combinationActivityListCache.getUnchecked(count));
|
return success(combinationActivityListCache.getUnchecked(count));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/spuList")
|
||||||
|
@Operation(summary = "获得拼团活动列表", description = "用于小程序首页")
|
||||||
|
@Parameter(name = "count", description = "需要展示的数量", example = "6")
|
||||||
|
public CommonResult<List<ProductSpuRespDTO>> getCombinationActivitySpuList(
|
||||||
|
@RequestParam(name = "count", defaultValue = "6") Integer count) {
|
||||||
|
List<AppCombinationActivityRespVO> list = combinationActivityListCache.getUnchecked(count);
|
||||||
|
ArrayList<Long> arrayList = new ArrayList<>();
|
||||||
|
HashMap<Long, Long> map = new HashMap<>();
|
||||||
|
for (AppCombinationActivityRespVO respVO : list) {
|
||||||
|
arrayList.add(respVO.getSpuId());
|
||||||
|
map.put(respVO.getSpuId(),respVO.getId());
|
||||||
|
}
|
||||||
|
List<ProductSpuRespDTO> spuList = spuApi.getSpuList(arrayList);
|
||||||
|
for (ProductSpuRespDTO dto : spuList) {
|
||||||
|
dto.setActivityId(map.get(dto.getId()));
|
||||||
|
}
|
||||||
|
return success(spuList);
|
||||||
|
}
|
||||||
|
|
||||||
private List<AppCombinationActivityRespVO> getCombinationActivityList0(Integer count) {
|
private List<AppCombinationActivityRespVO> getCombinationActivityList0(Integer count) {
|
||||||
List<CombinationActivityDO> activityList = activityService.getCombinationActivityListByCount(count);
|
List<CombinationActivityDO> activityList = activityService.getCombinationActivityListByCount(count);
|
||||||
if (CollUtil.isEmpty(activityList)) {
|
if (CollUtil.isEmpty(activityList)) {
|
||||||
|
@ -35,6 +35,8 @@ import java.time.Duration;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
@ -109,6 +111,39 @@ public class AppSeckillActivityController {
|
|||||||
return success(SeckillActivityConvert.INSTANCE.convertPage02(pageResult, productList, spuList));
|
return success(SeckillActivityConvert.INSTANCE.convertPage02(pageResult, productList, spuList));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/spuList")
|
||||||
|
@Parameter(name = "count", description = "需要展示的数量", example = "6")
|
||||||
|
@Operation(summary = "获得秒杀活动分页")
|
||||||
|
public CommonResult<List<ProductSpuRespDTO>> getSeckillActivitySupList(@RequestParam(name = "count", defaultValue = "6") Integer count) {
|
||||||
|
AppSeckillActivityPageReqVO pageReqVO = new AppSeckillActivityPageReqVO();
|
||||||
|
if (count == null || count == 0){
|
||||||
|
pageReqVO.setPageNo(1);
|
||||||
|
pageReqVO.setPageSize(count);
|
||||||
|
}
|
||||||
|
// 1. 查询满足当前阶段的活动
|
||||||
|
PageResult<SeckillActivityDO> pageResult = activityService.getSeckillActivityAppPageByConfigId(pageReqVO);
|
||||||
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||||
|
return success(null);
|
||||||
|
}
|
||||||
|
List<SeckillProductDO> productList = activityService.getSeckillProductListByActivityId(
|
||||||
|
convertList(pageResult.getList(), SeckillActivityDO::getId));
|
||||||
|
|
||||||
|
// 2. 拼接数据
|
||||||
|
List<ProductSpuRespDTO> spuList = spuApi.getSpuList(convertList(pageResult.getList(), SeckillActivityDO::getSpuId));
|
||||||
|
PageResult<AppSeckillActivityRespVO> result = SeckillActivityConvert.INSTANCE.convertPage02(pageResult, productList, spuList);
|
||||||
|
ArrayList<Long> arrayList = new ArrayList<>();
|
||||||
|
HashMap<Long, Long> hashMap = new HashMap<>();
|
||||||
|
for (AppSeckillActivityRespVO respVO : result.getList()) {
|
||||||
|
arrayList.add(respVO.getSpuId());
|
||||||
|
hashMap.put(respVO.getSpuId(),respVO.getId());
|
||||||
|
}
|
||||||
|
List<ProductSpuRespDTO> list = spuApi.getSpuList(arrayList);
|
||||||
|
for (ProductSpuRespDTO respDTO : list) {
|
||||||
|
respDTO.setActivityId(hashMap.get(respDTO.getId()));
|
||||||
|
}
|
||||||
|
return success(list);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/get-detail")
|
@GetMapping("/get-detail")
|
||||||
@Operation(summary = "获得秒杀活动明细")
|
@Operation(summary = "获得秒杀活动明细")
|
||||||
@Parameter(name = "id", description = "活动编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "活动编号", required = true, example = "1024")
|
||||||
|
@ -0,0 +1,69 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.dal.dataobject.pointmall;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 积分商城 DO
|
||||||
|
*
|
||||||
|
* @author 管理员
|
||||||
|
*/
|
||||||
|
@TableName("promotion_point_mall")
|
||||||
|
@KeySequence("promotion_point_mall_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class PointMallDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编号
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 商品主图
|
||||||
|
*/
|
||||||
|
private String productPicUrl;
|
||||||
|
/**
|
||||||
|
* 标题
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
/**
|
||||||
|
* sku数组
|
||||||
|
*/
|
||||||
|
private String skuIds;
|
||||||
|
/**
|
||||||
|
* spu编号
|
||||||
|
*/
|
||||||
|
private Long spuId;
|
||||||
|
/**
|
||||||
|
* 兑换积分
|
||||||
|
*/
|
||||||
|
private Integer exchangePointNum;
|
||||||
|
/**
|
||||||
|
* 限量
|
||||||
|
*/
|
||||||
|
private Integer limited;
|
||||||
|
/**
|
||||||
|
* 剩余限量
|
||||||
|
*/
|
||||||
|
private Integer surplusLimited;
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*
|
||||||
|
* 枚举 {@link TODO point_product_status 对应的类}
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
private Long sort;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.dal.mysql.pointmall;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.pointmall.PointMallDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.pointmall.vo.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 积分商城 Mapper
|
||||||
|
*
|
||||||
|
* @author 管理员
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface PointMallMapper extends BaseMapperX<PointMallDO> {
|
||||||
|
|
||||||
|
default PageResult<PointMallDO> selectPage(PointMallPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<PointMallDO>()
|
||||||
|
.eqIfPresent(PointMallDO::getProductPicUrl, reqVO.getProductPicUrl())
|
||||||
|
.eqIfPresent(PointMallDO::getTitle, reqVO.getTitle())
|
||||||
|
.eqIfPresent(PointMallDO::getSkuIds, reqVO.getSkuIds())
|
||||||
|
.eqIfPresent(PointMallDO::getSpuId, reqVO.getSpuId())
|
||||||
|
.eqIfPresent(PointMallDO::getExchangePointNum, reqVO.getExchangePointNum())
|
||||||
|
.eqIfPresent(PointMallDO::getLimited, reqVO.getLimited())
|
||||||
|
.eqIfPresent(PointMallDO::getSurplusLimited, reqVO.getSurplusLimited())
|
||||||
|
.eqIfPresent(PointMallDO::getStatus, reqVO.getStatus())
|
||||||
|
.eqIfPresent(PointMallDO::getSort, reqVO.getSort())
|
||||||
|
.betweenIfPresent(PointMallDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(PointMallDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.service.pointmall;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.pointmall.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.pointmall.PointMallDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 积分商城 Service 接口
|
||||||
|
*
|
||||||
|
* @author 管理员
|
||||||
|
*/
|
||||||
|
public interface PointMallService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建积分商城
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createPointMall(@Valid PointMallSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新积分商城
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updatePointMall(@Valid PointMallSaveReqVO updateReqVO);
|
||||||
|
void closePointMall(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除积分商城
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deletePointMall(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得积分商城
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 积分商城
|
||||||
|
*/
|
||||||
|
PointMallDO getPointMall(Long id);
|
||||||
|
PointMallDO getPointMallBySpuId(Long spuId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得积分商城分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 积分商城分页
|
||||||
|
*/
|
||||||
|
PageResult<PointMallDO> getPointMallPage(PointMallPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,91 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.service.pointmall;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.admin.pointmall.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.pointmall.PointMallDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.mysql.pointmall.PointMallMapper;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 积分商城 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 管理员
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class PointMallServiceImpl implements PointMallService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PointMallMapper pointMallMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createPointMall(PointMallSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
PointMallDO pointMall = BeanUtils.toBean(createReqVO, PointMallDO.class);
|
||||||
|
pointMallMapper.insert(pointMall);
|
||||||
|
// 返回
|
||||||
|
return pointMall.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updatePointMall(PointMallSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validatePointMallExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
PointMallDO updateObj = BeanUtils.toBean(updateReqVO, PointMallDO.class);
|
||||||
|
pointMallMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void closePointMall(Long id) {
|
||||||
|
PointMallDO pointMallDO = pointMallMapper.selectOne("id", id);
|
||||||
|
if (pointMallDO.getStatus() == 1){
|
||||||
|
pointMallDO.setStatus(0);
|
||||||
|
}else if (pointMallDO.getStatus() == 0){
|
||||||
|
pointMallDO.setStatus(1);
|
||||||
|
}
|
||||||
|
pointMallMapper.updateById(pointMallDO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deletePointMall(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validatePointMallExists(id);
|
||||||
|
// 删除
|
||||||
|
pointMallMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validatePointMallExists(Long id) {
|
||||||
|
if (pointMallMapper.selectById(id) == null) {
|
||||||
|
throw exception(POINT_MALL_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PointMallDO getPointMall(Long id) {
|
||||||
|
return pointMallMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PointMallDO getPointMallBySpuId(Long id) {
|
||||||
|
PointMallDO mallDO = pointMallMapper.selectOne("spu_id", id);
|
||||||
|
return mallDO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<PointMallDO> getPointMallPage(PointMallPageReqVO pageReqVO) {
|
||||||
|
return pointMallMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="cn.iocoder.yudao.module.promotion.dal.mysql.pointmall.PointMallMapper">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||||
|
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||||
|
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||||
|
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||||
|
-->
|
||||||
|
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue
Block a user