diff --git a/admin-web/config/router.config.js b/admin-web/config/router.config.js index caeb2563c..b3e1c1e9d 100644 --- a/admin-web/config/router.config.js +++ b/admin-web/config/router.config.js @@ -120,6 +120,11 @@ export default [ // name: 'product-category-list', // component: './Product/ProductCategoryList', // }, + { + path: '/promotion/coupon-card-template-list', + name: 'coupon-card-template-list', + component: './Promotion/CouponCardTemplateList', + } ], }, { diff --git a/admin-web/src/locales/zh-CN/menu.js b/admin-web/src/locales/zh-CN/menu.js index ec963f8b7..a41d8e51a 100644 --- a/admin-web/src/locales/zh-CN/menu.js +++ b/admin-web/src/locales/zh-CN/menu.js @@ -56,4 +56,5 @@ export default { // 营销相关 'menu.promotion.promotion-banner-list': 'Banner 管理', 'menu.promotion.product-recommend-list': '商品推荐', -}; \ No newline at end of file + 'menu.promotion.coupon-card-template-list': '优惠劵管理', +}; diff --git a/admin-web/src/models/promotion/couponCardTemplateList.js b/admin-web/src/models/promotion/couponCardTemplateList.js new file mode 100644 index 000000000..a0687bf51 --- /dev/null +++ b/admin-web/src/models/promotion/couponCardTemplateList.js @@ -0,0 +1,179 @@ +import {message} from 'antd'; +import { + addProductRecommend, + deleteProductRecommend, + queryProductRecommend, + updateProductRecommend, + updateProductRecommendStatus, + addCouponCardTemplate, +} from '../../services/promotion'; +import PaginationHelper from '../../../helpers/PaginationHelper'; + +const SEARCH_PARAMS_DEFAULT = { + type: 1, +}; + +export default { + namespace: 'couponCardTemplateList', + + state: { + // 分页列表相关 + list: [], + listLoading: false, + pagination: PaginationHelper.defaultPaginationConfig, + searchParams: SEARCH_PARAMS_DEFAULT, + + // 添加 or 修改表单相关 + modalVisible: false, + modalType: undefined, // 'add' or 'update' 表单 + formVals: {}, // 当前表单值 + modalLoading: false, + }, + + effects: { + // 查询列表 + * query({ payload }, { call, put }) { + // 显示加载中 + yield put({ + type: 'changeListLoading', + payload: true, + }); + + // 请求 + const response = yield call(queryProductRecommend, payload); + // 响应 + yield put({ + type: 'setAll', + payload: { + list: response.data.list, + pagination: PaginationHelper.formatPagination(response.data, payload), + searchParams: { + type: payload.type + } + }, + }); + + // 隐藏加载中 + yield put({ + type: 'changeListLoading', + payload: false, + }); + }, + * add({ payload }, { call, put }) { + const { callback, body } = payload; + // 显示加载中 + yield put({ + type: 'changeModalLoading', + payload: true, + }); + + // 请求 + const response = yield call(addCouponCardTemplate, body); + // 响应 + if (response.code === 0) { + if (callback) { + callback(response); + } + // 刷新列表 + yield put({ + type: 'query', + payload: { + ...PaginationHelper.defaultPayload + }, + }); + } + + // 隐藏加载中 + yield put({ + type: 'changeModalLoading', + payload: false, + }); + }, + * update({ payload }, { call, put }) { + const { callback, body } = payload; + // 显示加载中 + yield put({ + type: 'changeModalLoading', + payload: true, + }); + + // 请求 + const response = yield call(updateProductRecommend, body); + // 响应 + if (response.code === 0) { + if (callback) { + callback(response); + } + // 刷新列表 + yield put({ + type: 'query', + payload: { + ...PaginationHelper.defaultPayload + }, + }); + } + + // 隐藏加载中 + yield put({ + type: 'changeModalLoading', + payload: false, + }); + }, + + * updateStatus({ payload }, { call, put }) { + // 请求 + const response = yield call(updateProductRecommendStatus, payload); + // 响应 + if (response.code === 0) { + message.info('更新状态成功!'); + // 刷新列表 + yield put({ + type: 'query', + payload: { + ...PaginationHelper.defaultPayload + }, + }); + } + }, + + * delete({ payload }, { call, put }) { + // 请求 + const response = yield call(deleteProductRecommend, payload); + // 响应 + if (response.code === 0) { + message.info('删除成功!'); + // 刷新列表 + yield put({ + type: 'query', + payload: { + ...PaginationHelper.defaultPayload + }, + }); + } + }, + + }, + + reducers: { + // 修改加载中的状态 + changeModalLoading(state, { payload }) { + return { + ...state, + modalLoading: payload, + }; + }, + changeListLoading(state, { payload }) { + return { + ...state, + listLoading: payload, + }; + }, + // 设置所有属性 + setAll(state, { payload }) { + return { + ...state, + ...payload, + }; + } + }, +}; diff --git a/admin-web/src/pages/Promotion/CouponCardTemplateList.js b/admin-web/src/pages/Promotion/CouponCardTemplateList.js new file mode 100644 index 000000000..b8de700ac --- /dev/null +++ b/admin-web/src/pages/Promotion/CouponCardTemplateList.js @@ -0,0 +1,543 @@ +/* eslint-disable */ + +import React, { PureComponent, Fragment } from 'react'; +import { connect } from 'dva'; +import { + Card, + Form, + Input, + Button, + Modal, + message, + Table, + Divider, + Tree, + Spin, + Row, + Col, + Select, + Icon, + InputNumber, + DatePicker +} from 'antd'; +import { checkTypeWithEnglishAndNumbers } from '../../../helpers/validator' +import PageHeaderWrapper from '@/components/PageHeaderWrapper'; + +import styles from './CouponCardTemplateList.less'; +import moment from "moment"; +import PaginationHelper from "../../../helpers/PaginationHelper"; + +const FormItem = Form.Item; +const SelectOption = Select.Option; +const { TreeNode } = Tree; +const RangePicker = DatePicker.RangePicker; +const status = ['未知', '正常', '禁用']; +const types = ['未知', '新品推荐', '热卖推荐']; + +// 列表 +function List ({ dataSource, loading, pagination, searchParams, dispatch, + handleModalVisible}) { + + function handleStatus(record) { + Modal.confirm({ + title: record.status === 1 ? '确认禁用' : '取消禁用', + content: `${record.productSpuId}`, + onOk() { + dispatch({ + type: 'productRecommendList/updateStatus', + payload: { + id: record.id, + status: record.status === 1 ? 2 : 1, + }, + }); + }, + onCancel() {}, + }); + } + + function handleDelete(record) { + Modal.confirm({ + title: `确认删除?`, + content: `${record.productSpuId}`, + onOk() { + dispatch({ + type: 'productRecommendList/delete', + payload: { + id: record.id, + }, + }); + }, + onCancel() {}, + }); + } + + const columns = [ + { + title: '推荐类型', + dataIndex: 'type', + render(val) { + return {types[val]}; // TODO 芋艿,此处要改 + }, + }, + { + title: '商品', + dataIndex: 'productSpuId', + }, + { + title: '排序值', + dataIndex: 'sort', + }, + { + title: '状态', + dataIndex: 'status', + render(val) { + return {status[val]}; // TODO 芋艿,此处要改 + }, + }, + { + title: '备注', + dataIndex: 'memo', + }, + { + title: '创建时间', + dataIndex: 'createTime', + render: val => {moment(val).format('YYYY-MM-DD HH:mm')}, + }, + { + title: '操作', + width: 360, + render: (text, record) => { + const statusText = record.status === 1 ? '禁用' : '开启'; // TODO 芋艿,此处要改 + return ( + + handleModalVisible(true, 'update', record)}>编辑 + + handleStatus(record)}> + {statusText} + + { + record.status === 2 ? + + + handleDelete(record)}> + 删除 + + : null + } + + ); + }, + }, + ]; + + function onPageChange(page) { // 翻页 + dispatch({ + type: 'productRecommendList/query', + payload: { + pageNo: page.current, + pageSize: page.pageSize, + ...searchParams + } + }) + } + + return ( + + ) +} + +// 搜索表单 +// TODO 芋艿,有没办法换成上面那种写法 +const SearchForm = Form.create()(props => { + const { + form, + form: { getFieldDecorator }, + dispatch + } = props; + + function search() { + dispatch({ + type: 'productRecommendList/query', + payload: { + ...PaginationHelper.defaultPayload, + ...form.getFieldsValue() + } + }) + } + + // 提交搜索 + function handleSubmit(e) { + // 阻止默认事件 + e.preventDefault(); + // 提交搜索 + search(); + } + + // 重置搜索 + function handleReset() { + // 重置表单 + form.resetFields(); + // 执行搜索 + search(); + } + + return ( + + + + + {getFieldDecorator('title')()} + + + + + + + + + + + ); +}); + +// 添加 or 修改 Form 表单 +const AddOrUpdateForm = Form.create()(props => { + const { dispatch, modalVisible, form, handleModalVisible, modalType, formVals } = props; + + const okHandle = () => { + form.validateFields((err, fields) => { + if (err) return; + let newFileds = { + ...fields, + priceAvailable: fields['priceAvailable'] ? parseInt(fields.priceAvailable * 100) : undefined, + priceOff: fields['priceOff'] ? parseInt(fields.priceOff * 100) : undefined, + discountPriceLimit: fields['discountPriceLimit'] ? parseInt(fields.discountPriceLimit * 100) : undefined, + } + debugger; + // 添加表单 + if (modalType === 'add') { + dispatch({ + type: 'couponCardTemplateList/add', + payload: { + body: { + ...newFileds, + }, + callback: () => { + // 清空表单 + form.resetFields(); + // 提示 + message.success('添加成功'); + // 关闭弹窗 + handleModalVisible(); + }, + }, + }); + // 修改表单 + } else { + dispatch({ + type: 'couponCardTemplateList/update', + payload: { + body: { + id: formVals.id, + ...newFileds, + }, + callback: () => { + // 清空表单 + form.resetFields(); + // 提示 + message.success('更新成功'); + // 关闭弹窗 + handleModalVisible(); + }, + }, + }); + } + }); + }; + + function onRangeTypeChange(value) { + formVals.rangeType = parseInt(value); + } + + function onDateTypeChange(value) { + formVals.dateType = parseInt(value); + } + + function onPreferentialTypeChange(value) { + formVals.preferentialType = parseInt(value); + } + + const title = modalType === 'add' ? '新建优惠劵' : '更新优惠劵'; + return ( + handleModalVisible()} + width={720} + > + + {form.getFieldDecorator('title', { + rules: [{ required: true, message: '请输入标题!' }], + initialValue: formVals.title, + })()} + + + {form.getFieldDecorator('description', { + rules: [{ required: false, message: '请输入使用说明!' }, + {max: 255, message: '最大长度为 255 位'}, + ], + initialValue: formVals.description, + })()} + + + {form.getFieldDecorator('quota', { + rules: [{ required: true, message: '请选择每人限领次数!'}, + ], + initialValue: formVals.quota, + })( + + )} + + + {form.getFieldDecorator('total', { + rules: [{ required: true, message: '请输入发放总量!' }, + {min: 1, type: 'number', message: '最小值为 1'}], + initialValue: formVals.total, + })()} + + + {form.getFieldDecorator('priceAvailable', { + rules: [{ required: true, message: '请输入使用金额门槛!' },], + initialValue: formVals.priceAvailable, + })()} 元 + + + {form.getFieldDecorator('rangeType', { + rules: [{ required: true, message: '请选择可用范围!'}, // TODO 芋艿,需要修改 + ], + initialValue: formVals.rangeType, + })( + + )} + + { + formVals.rangeType == 20 || formVals.rangeType == 21 + || formVals.rangeType == 30 || formVals.rangeType == 31 ? + + {form.getFieldDecorator('rangeValues', { + rules: [{ required: true, message: '请输入具体范围!' }, // TODO 芋艿,做成搜索 + {maxlength: 255, message: '最大长度为 255 位'}, + ], + initialValue: formVals.rangeValues, + })()} + + : '' + } + + {form.getFieldDecorator('dateType', { + rules: [{ required: true, message: '请选择可用范围!'}, // TODO 芋艿,需要修改 + ], + initialValue: formVals.dateType, + })( + + )} + + { + formVals.dateType == 1 ? + + {form.getFieldDecorator('validStartTime', { + rules: [{ required: true, message: '请输入固定日期!' },], + initialValue: formVals.validStartTime, + })()} +  -  + {form.getFieldDecorator('validEndTime', { + rules: [{ required: true, message: '请输入固定日期!' },], + initialValue: formVals.validEndTime, + })()} + : '' + } + { + formVals.dateType == 2 ? + + {form.getFieldDecorator('fixedBeginTerm', { + rules: [{ required: true, message: '请输入固定日期!' },], + initialValue: formVals.fixedBeginTerm, + })()} +  -  + {form.getFieldDecorator('fixedEndTerm', { + rules: [{ required: false, message: '请输入固定日期!' },], + initialValue: formVals.fixedEndTerm, + })()} 天 + : '' + } + + + {form.getFieldDecorator('preferentialType', { + rules: [{ required: true, message: '请选择优惠类型!'}, // TODO 芋艿,需要修改 + ], + initialValue: formVals.preferentialType, + })( + + )} + + { + formVals.preferentialType == 1 ? + + {form.getFieldDecorator('priceOff', { + rules: [{ required: true, message: '请输入优惠金额!' }, + {min: 0.01, type: 'number', message: '最小值为 0.01'}], + initialValue: formVals.priceOff, + })()} + : '' + } + { + formVals.preferentialType == 2 ? + + + {form.getFieldDecorator('percentOff', { + rules: [{ required: true, message: '请输入折扣百分比!' }, + {min: 1, max: 99, type: 'number', message: '范围为 [1, 99]'}, + ], + initialValue: formVals.percentOff, + })()}% + + + {form.getFieldDecorator('discountPriceLimit', { + rules: [{ required: false, message: '请输入最多优惠!' }, + {min: 0.01, type: 'number', message: '最小值为 0.01'}, + ], + initialValue: formVals.discountPriceLimit, + })()}元 + + : '' + } + + ); +}); + +@connect(({ productRecommendList }) => ({ + // list: productRecommend.list, + // pagination: productRecommend.pagination, + ...productRecommendList, +})) + +// 主界面 +@Form.create() +class CouponCardTemplateLists extends PureComponent { + + componentDidMount() { + const { dispatch } = this.props; + dispatch({ + type: 'productRecommendList/query', + payload: { + ...PaginationHelper.defaultPayload + }, + }); + } + + handleModalVisible = (modalVisible, modalType, record) => { + const { dispatch } = this.props; + dispatch({ + type: 'productRecommendList/setAll', + payload: { + modalVisible, + modalType, + formVals: record || {} + }, + }); + }; + + render() { + // let that = this; + const { dispatch, + list, listLoading, searchParams, pagination, + modalVisible, modalType, formVals, + confirmLoading, } = this.props; + + // 列表属性 + const listProps = { + dataSource: list, + pagination, + searchParams, + dispatch, + loading: listLoading, + confirmLoading, + handleModalVisible: this.handleModalVisible, // Function + }; + + // 搜索表单属性 + const searchFormProps = { + dispatch, + }; + + // 添加 or 更新表单属性 + const addOrUpdateFormProps = { + modalVisible, + modalType, + formVals, + dispatch, + handleModalVisible: this.handleModalVisible, // Function + }; + + return ( + + +
+
+ +
+
+ +
+
+ +
+ + + +
+ ); + } +} + +export default CouponCardTemplateLists; diff --git a/admin-web/src/pages/Promotion/CouponCardTemplateList.less b/admin-web/src/pages/Promotion/CouponCardTemplateList.less new file mode 100644 index 000000000..7ad3dac3f --- /dev/null +++ b/admin-web/src/pages/Promotion/CouponCardTemplateList.less @@ -0,0 +1,47 @@ +@import '~antd/lib/style/themes/default.less'; +@import '~@/utils/utils.less'; + +.tableList { + .tableListOperator { + margin-bottom: 16px; + button { + margin-right: 8px; + } + } +} + +.tableDelete { + color: red; +} + +.tableListForm { + :global { + .ant-form-item { + display: flex; + margin-right: 0; + margin-bottom: 24px; + > .ant-form-item-label { + width: auto; + padding-right: 8px; + line-height: 32px; + } + .ant-form-item-control { + line-height: 32px; + } + } + .ant-form-item-control-wrapper { + flex: 1; + } + } + .submitButtons { + display: block; + margin-bottom: 24px; + white-space: nowrap; + } +} + +@media screen and (max-width: @screen-lg) { + .tableListForm :global(.ant-form-item) { + margin-right: 24px; + } +} \ No newline at end of file diff --git a/admin-web/src/pages/Promotion/ProductRecommendList.js b/admin-web/src/pages/Promotion/ProductRecommendList.js index 4d8cf5857..b4878dcff 100644 --- a/admin-web/src/pages/Promotion/ProductRecommendList.js +++ b/admin-web/src/pages/Promotion/ProductRecommendList.js @@ -257,7 +257,7 @@ const AddOrUpdateForm = Form.create()(props => { }); }; - const title = modalType === 'add' ? '新建 Banner' : '更新 Banner'; + const title = modalType === 'add' ? '新建商品推荐' : '更新商品推荐'; return ( add(@RequestParam(value = "title") String title, + @RequestParam(value = "description", required = false) String description, + @RequestParam(value = "quota", required = false) Integer quota, + @RequestParam(value = "stock", required = false) Integer stock, + @RequestParam(value = "priceAvailable") Integer priceAvailable, + @RequestParam(value = "rangeType") Integer rangeType, + @RequestParam(value = "rangeType", required = false) String rangeValues, + @RequestParam(value = "dateType") Integer dateType, + @RequestParam(value = "validStartTime", required = false) Date validStartTime, + @RequestParam(value = "validEndTime", required = false) Date validEndTime, + @RequestParam(value = "fixedBeginTerm", required = false) Integer fixedBeginTerm, + @RequestParam(value = "fixedEndTerm", required = false) Integer fixedEndTerm, + @RequestParam(value = "preferentialType") Integer preferentialType, + @RequestParam(value = "priceOff", required = false) Integer priceOff, + @RequestParam(value = "percentOff", required = false) Integer percentOff, + @RequestParam(value = "discountPriceLimit", required = false) Integer discountPriceLimit) { + // 创建 CouponCardTemplateAddDTO 对象 + CouponCardTemplateAddDTO couponCardTemplateAddDTO = new CouponCardTemplateAddDTO() + .setTitle(title).setDescription(description) + .setQuota(quota).setStock(stock) + .setPriceAvailable(priceAvailable).setRangeType(rangeType).setRangeValues(rangeValues) + .setDateType(dateType).setValidStartTime(validStartTime).setValidEndTime(validEndTime) + .setFixedBeginTerm(fixedBeginTerm).setFixedEndTerm(fixedEndTerm) + .setPreferentialType(preferentialType).setPriceOff(priceOff).setPercentOff(percentOff).setDiscountPriceLimit(discountPriceLimit); + // 提交请求 + CommonResult result = couponService.addCouponCardTemplate(couponCardTemplateAddDTO); + // 返回结果 + return CouponTemplateConvert.INSTANCE.convert2(result); + } + + // ========== 优惠劵 ========== + + // ========== 优惠码 ========== + +} diff --git a/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/convert/CouponTemplateConvert.java b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/convert/CouponTemplateConvert.java new file mode 100644 index 000000000..8b82e9ae7 --- /dev/null +++ b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/convert/CouponTemplateConvert.java @@ -0,0 +1,27 @@ +package cn.iocoder.mall.promotion.application.convert; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.promotion.api.bo.CouponTemplateBO; +import cn.iocoder.mall.promotion.application.vo.admins.AdminsCouponTemplateVO; +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface CouponTemplateConvert { + + CouponTemplateConvert INSTANCE = Mappers.getMapper(CouponTemplateConvert.class); + + @Mappings({}) + AdminsCouponTemplateVO convert(CouponTemplateBO bannerBO); + + @Mappings({}) + CommonResult convert2(CommonResult result); + +// @Mappings({}) +// CommonResult convert(CommonResult result); +// +// @Mappings({}) +// List convertList(List banners); + +} diff --git a/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/vo/admins/AdminsCouponTemplateVO.java b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/vo/admins/AdminsCouponTemplateVO.java new file mode 100644 index 000000000..8ad5eeca5 --- /dev/null +++ b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/vo/admins/AdminsCouponTemplateVO.java @@ -0,0 +1,273 @@ +package cn.iocoder.mall.promotion.application.vo.admins; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Date; + +@ApiModel("CouponTemplate VO") +public class AdminsCouponTemplateVO { + + // ========== 基本信息 BEGIN ========== + @ApiModelProperty(value = "模板编号,自增唯一", required = true, example = "1") + private Integer id; + @ApiModelProperty(value = "标题", required = true, example = "优惠劵牛逼") + private String title; + @ApiModelProperty(value = "使用说明", required = true, example = "我只是描述") + private String description; + @ApiModelProperty(value = "优惠劵类型", required = true, example = "参见 CouponTemplateTypeEnum 枚举") + private Integer type; + /** + * 码类型 + * + * 1-一卡一码(UNIQUE) + * 2-通用码(GENERAL) + * + * 【优惠码独有】 @see CouponCodeDO + */ + // TODO + private Integer codeType; + @ApiModelProperty(value = "优惠码状态", required = true, example = "参见 CouponTemplateStatusEnum 枚举") + private Integer status; + @ApiModelProperty(value = "每人限领个数", example = "null - 则表示不限制") + private Integer quota; + @ApiModelProperty(value = "发放总量") + private Integer total; + // ========== 领取规则 END ========== + + // ========== 使用规则 BEGIN ========== + @ApiModelProperty(value = "是否设置满多少金额可用,单位:分", required = true, example = "0-不限制;大于0-多少金额可用") + private Integer priceAvailable; + @ApiModelProperty(value = "可用范围的类型", required = true, example = "参见 CouponTemplateRangeTypeEnum 枚举") + private Integer rangeType; + @ApiModelProperty(value = "指定商品 / 分类列表,使用逗号分隔商品编号", example = "参见 CouponTemplateRangeTypeEnum 枚举") + private String rangeValues; + @ApiModelProperty(value = "生效日期类型", example = "参见 CouponTemplateDateTypeEnum 枚举") + private Integer dateType; + @ApiModelProperty(value = "固定日期-生效开始时间") + private Date validStartTime; + @ApiModelProperty(value = "固定日期-生效结束时间") + private Date validEndTime; + @ApiModelProperty(value = "领取日期-开始天数", example = "例如,0-当天;1-次天") + private Integer fixedBeginTerm; + @ApiModelProperty(value = "领取日期-结束天数") + private Integer fixedEndTerm; + // ========== 使用规则 END ========== + + // ========== 使用效果 BEGIN ========== + @ApiModelProperty(value = "优惠类型", example = "参见 CouponTemplatePreferentialTypeEnum 枚举") + private Integer preferentialType; + @ApiModelProperty(value = "折扣百分比") + private Integer percentOff; + @ApiModelProperty(value = "优惠金额,单位:分") + private Integer priceOff; + @ApiModelProperty(value = "折扣上限") + private Integer discountPriceLimit; + // ========== 使用效果 END ========== + + // ========== 统计信息 BEGIN ========== + @ApiModelProperty(value = "折扣上限", required = true) + private Integer statFetchNum; + // ========== 统计信息 END ========== + + @ApiModelProperty(value = "折扣上限", required = true) + private Date createTime; + + public Integer getId() { + return id; + } + + public AdminsCouponTemplateVO setId(Integer id) { + this.id = id; + return this; + } + + public String getTitle() { + return title; + } + + public AdminsCouponTemplateVO setTitle(String title) { + this.title = title; + return this; + } + + public String getDescription() { + return description; + } + + public AdminsCouponTemplateVO setDescription(String description) { + this.description = description; + return this; + } + + public Integer getType() { + return type; + } + + public AdminsCouponTemplateVO setType(Integer type) { + this.type = type; + return this; + } + + public Integer getCodeType() { + return codeType; + } + + public AdminsCouponTemplateVO setCodeType(Integer codeType) { + this.codeType = codeType; + return this; + } + + public Integer getStatus() { + return status; + } + + public AdminsCouponTemplateVO setStatus(Integer status) { + this.status = status; + return this; + } + + public Integer getQuota() { + return quota; + } + + public AdminsCouponTemplateVO setQuota(Integer quota) { + this.quota = quota; + return this; + } + + public Integer getStock() { + return stock; + } + + public AdminsCouponTemplateVO setStock(Integer stock) { + this.stock = stock; + return this; + } + + public Integer getPriceAvailable() { + return priceAvailable; + } + + public AdminsCouponTemplateVO setPriceAvailable(Integer priceAvailable) { + this.priceAvailable = priceAvailable; + return this; + } + + public Integer getRangeType() { + return rangeType; + } + + public AdminsCouponTemplateVO setRangeType(Integer rangeType) { + this.rangeType = rangeType; + return this; + } + + public String getRangeValues() { + return rangeValues; + } + + public AdminsCouponTemplateVO setRangeValues(String rangeValues) { + this.rangeValues = rangeValues; + return this; + } + + public Integer getDateType() { + return dateType; + } + + public AdminsCouponTemplateVO setDateType(Integer dateType) { + this.dateType = dateType; + return this; + } + + public Date getValidStartTime() { + return validStartTime; + } + + public AdminsCouponTemplateVO setValidStartTime(Date validStartTime) { + this.validStartTime = validStartTime; + return this; + } + + public Date getValidEndTime() { + return validEndTime; + } + + public AdminsCouponTemplateVO setValidEndTime(Date validEndTime) { + this.validEndTime = validEndTime; + return this; + } + + public Integer getFixedBeginTerm() { + return fixedBeginTerm; + } + + public AdminsCouponTemplateVO setFixedBeginTerm(Integer fixedBeginTerm) { + this.fixedBeginTerm = fixedBeginTerm; + return this; + } + + public Integer getFixedEndTerm() { + return fixedEndTerm; + } + + public AdminsCouponTemplateVO setFixedEndTerm(Integer fixedEndTerm) { + this.fixedEndTerm = fixedEndTerm; + return this; + } + + public Integer getPreferentialType() { + return preferentialType; + } + + public AdminsCouponTemplateVO setPreferentialType(Integer preferentialType) { + this.preferentialType = preferentialType; + return this; + } + + public Integer getPercentOff() { + return percentOff; + } + + public AdminsCouponTemplateVO setPercentOff(Integer percentOff) { + this.percentOff = percentOff; + return this; + } + + public Integer getPriceOff() { + return priceOff; + } + + public AdminsCouponTemplateVO setPriceOff(Integer priceOff) { + this.priceOff = priceOff; + return this; + } + + public Integer getDiscountPriceLimit() { + return discountPriceLimit; + } + + public AdminsCouponTemplateVO setDiscountPriceLimit(Integer discountPriceLimit) { + this.discountPriceLimit = discountPriceLimit; + return this; + } + + public Integer getStatFetchNum() { + return statFetchNum; + } + + public AdminsCouponTemplateVO setStatFetchNum(Integer statFetchNum) { + this.statFetchNum = statFetchNum; + return this; + } + + public Date getCreateTime() { + return createTime; + } + + public AdminsCouponTemplateVO setCreateTime(Date createTime) { + this.createTime = createTime; + return this; + } +} diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/CouponService.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/CouponService.java index 68800a936..977ef9663 100644 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/CouponService.java +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/CouponService.java @@ -2,18 +2,15 @@ package cn.iocoder.mall.promotion.api; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.promotion.api.bo.CouponCardBO; -import cn.iocoder.mall.promotion.api.bo.CouponCardTemplatePageBO; -import cn.iocoder.mall.promotion.api.bo.CouponCodeTemplateBO; -import cn.iocoder.mall.promotion.api.bo.CouponCodeTemplatePageBO; +import cn.iocoder.mall.promotion.api.bo.CouponTemplateBO; +import cn.iocoder.mall.promotion.api.bo.CouponTemplatePageBO; import cn.iocoder.mall.promotion.api.dto.*; public interface CouponService { // ========== 优惠劵(码)模板 ========== - CommonResult getCouponCodeTemplatePage(CouponCodeTemplatePageDTO couponCodeTemplatePageDTO); - - CommonResult getCouponCardTemplatePage(CouponCardTemplatePageDTO couponCardTemplatePageDTO); + CommonResult getCouponTemplatePage(CouponTemplatePageDTO couponTemplatePageDTO); /** * 创建优惠码模板 @@ -21,7 +18,7 @@ public interface CouponService { * @param couponCodeTemplateAddDTO 优惠码模板添加 DTO * @return 优惠码模板 */ - CommonResult addCouponCodeTemplate(CouponCodeTemplateAddDTO couponCodeTemplateAddDTO); + CommonResult addCouponCodeTemplate(CouponCodeTemplateAddDTO couponCodeTemplateAddDTO); /** * 创建优惠劵模板 @@ -29,7 +26,7 @@ public interface CouponService { * @param couponCardTemplateAddDTO 优惠码模板添加 DTO * @return 优惠劵模板 */ - CommonResult addCouponCardTemplate(CouponCardTemplateAddDTO couponCardTemplateAddDTO); + CommonResult addCouponCardTemplate(CouponCardTemplateAddDTO couponCardTemplateAddDTO); /** * 更新优惠码模板 diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponCardTemplatePageBO.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponCardTemplatePageBO.java deleted file mode 100644 index 2f9fddbe8..000000000 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponCardTemplatePageBO.java +++ /dev/null @@ -1,5 +0,0 @@ -package cn.iocoder.mall.promotion.api.bo; - -public class CouponCardTemplatePageBO { - -} diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponCodeTemplateBO.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponCodeTemplateBO.java deleted file mode 100644 index bb8902702..000000000 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponCodeTemplateBO.java +++ /dev/null @@ -1,4 +0,0 @@ -package cn.iocoder.mall.promotion.api.bo; - -public class CouponCodeTemplateBO { -} diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponCodeTemplatePageBO.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponCodeTemplatePageBO.java deleted file mode 100644 index 48fd8c69a..000000000 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponCodeTemplatePageBO.java +++ /dev/null @@ -1,4 +0,0 @@ -package cn.iocoder.mall.promotion.api.bo; - -public class CouponCodeTemplatePageBO { -} diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponTemplateBO.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponTemplateBO.java new file mode 100644 index 000000000..0b7ae7f31 --- /dev/null +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponTemplateBO.java @@ -0,0 +1,344 @@ +package cn.iocoder.mall.promotion.api.bo; + +import java.util.Date; + +public class CouponTemplateBO { + + // ========== 基本信息 BEGIN ========== + /** + * 模板编号,自增唯一。 + */ + private Integer id; + /** + * 标题 + */ + private String title; + /** + * 使用说明 + */ + private String description; + /** + * 类型 + * + * 1-优惠劵 + * 2-优惠码 + */ + private Integer type; + /** + * 码类型 + * + * 1-一卡一码(UNIQUE) + * 2-通用码(GENERAL) + * + * 【优惠码独有】 @see CouponCodeDO + */ + private Integer codeType; + /** + * 优惠码状态 + * + * 1-开启中 + * 2-禁用中 + * 3-已过期 + * + * 当优惠劵(码)开启中,可以手动操作,设置禁用中。 + */ + private Integer status; + /** + * 每人限领个数 + * + * null - 则表示不限制 + */ + private Integer quota; + /** + * 发放总量 + */ + private Integer total; + // ========== 领取规则 END ========== + + // ========== 使用规则 BEGIN ========== + /** + * 是否设置满多少金额可用,单位:分 + * + * 0-不限制 + * 大于0-多少金额可用 + */ + private Integer priceAvailable; + /** + * 可用范围的类型 + * + * 10-全部(ALL):所有可用 + * 20-部分(PART):部分商品可用,或指定商品可用 + * 21-部分(PART):部分商品不可用,或指定商品可用 + * 30-部分(PART):部分分类可用,或指定商品可用 + * 31-部分(PART):部分分类不可用,或指定商品可用 + */ + private Integer rangeType; + /** + * 指定商品 / 分类列表,使用逗号分隔商品编号 + */ + private String rangeValues; + /** + * 生效日期类型 + * + * 1-固定日期 + * 2-领取日期:领到券 {@link #fixedBeginTerm} 日开始 N 天内有效 + */ + private Integer dateType; + /** + * 固定日期-生效开始时间 + */ + private Date validStartTime; + /** + * 固定日期-生效结束时间 + */ + private Date validEndTime; + /** + * 领取日期-开始天数 + * + * 例如,0-当天;1-次天 + */ + private Integer fixedBeginTerm; + /** + * 领取日期-结束天数 + */ + private Integer fixedEndTerm; + // ========== 使用规则 END ========== + + // ========== 使用效果 BEGIN ========== + /** + * 优惠类型 + * + * 1-代金卷 + * 2-折扣卷 + */ + private Integer preferentialType; + /** + * 折扣百分比。 + * + * 例如,80% 为 80。 + * 当 100% 为 100 ,则代表免费。 + */ + private Integer percentOff; + /** + * 优惠金额,单位:分 + */ + private Integer priceOff; + /** + * 折扣上限,仅在 {@link #preferentialType} 等于 2 时生效。 + * + * 例如,折扣上限为 20 元,当使用 8 折优惠券,订单金额为 1000 元时,最高只可折扣 20 元,而非 80 元。 + */ + private Integer discountPriceLimit; + // ========== 使用效果 END ========== + + // ========== 统计信息 BEGIN ========== + /** + * 领取优惠券的次数 + */ + private Integer statFetchNum; + // ========== 统计信息 END ========== + + /** + * 创建时间 + */ + private Date createTime; + + public Integer getId() { + return id; + } + + public CouponTemplateBO setId(Integer id) { + this.id = id; + return this; + } + + public String getTitle() { + return title; + } + + public CouponTemplateBO setTitle(String title) { + this.title = title; + return this; + } + + public String getDescription() { + return description; + } + + public CouponTemplateBO setDescription(String description) { + this.description = description; + return this; + } + + public Integer getType() { + return type; + } + + public CouponTemplateBO setType(Integer type) { + this.type = type; + return this; + } + + public Integer getCodeType() { + return codeType; + } + + public CouponTemplateBO setCodeType(Integer codeType) { + this.codeType = codeType; + return this; + } + + public Integer getStatus() { + return status; + } + + public CouponTemplateBO setStatus(Integer status) { + this.status = status; + return this; + } + + public Integer getQuota() { + return quota; + } + + public CouponTemplateBO setQuota(Integer quota) { + this.quota = quota; + return this; + } + + public Integer getTotal() { + return total; + } + + public CouponTemplateBO setTotal(Integer total) { + this.total = total; + return this; + } + + public Integer getPriceAvailable() { + return priceAvailable; + } + + public CouponTemplateBO setPriceAvailable(Integer priceAvailable) { + this.priceAvailable = priceAvailable; + return this; + } + + public Integer getRangeType() { + return rangeType; + } + + public CouponTemplateBO setRangeType(Integer rangeType) { + this.rangeType = rangeType; + return this; + } + + public String getRangeValues() { + return rangeValues; + } + + public CouponTemplateBO setRangeValues(String rangeValues) { + this.rangeValues = rangeValues; + return this; + } + + public Integer getDateType() { + return dateType; + } + + public CouponTemplateBO setDateType(Integer dateType) { + this.dateType = dateType; + return this; + } + + public Date getValidStartTime() { + return validStartTime; + } + + public CouponTemplateBO setValidStartTime(Date validStartTime) { + this.validStartTime = validStartTime; + return this; + } + + public Date getValidEndTime() { + return validEndTime; + } + + public CouponTemplateBO setValidEndTime(Date validEndTime) { + this.validEndTime = validEndTime; + return this; + } + + public Integer getPreferentialType() { + return preferentialType; + } + + public CouponTemplateBO setPreferentialType(Integer preferentialType) { + this.preferentialType = preferentialType; + return this; + } + + public Integer getPercentOff() { + return percentOff; + } + + public CouponTemplateBO setPercentOff(Integer percentOff) { + this.percentOff = percentOff; + return this; + } + + public Integer getPriceOff() { + return priceOff; + } + + public CouponTemplateBO setPriceOff(Integer priceOff) { + this.priceOff = priceOff; + return this; + } + + public Integer getDiscountPriceLimit() { + return discountPriceLimit; + } + + public CouponTemplateBO setDiscountPriceLimit(Integer discountPriceLimit) { + this.discountPriceLimit = discountPriceLimit; + return this; + } + + public Integer getStatFetchNum() { + return statFetchNum; + } + + public CouponTemplateBO setStatFetchNum(Integer statFetchNum) { + this.statFetchNum = statFetchNum; + return this; + } + + public Date getCreateTime() { + return createTime; + } + + public CouponTemplateBO setCreateTime(Date createTime) { + this.createTime = createTime; + return this; + } + + public Integer getFixedBeginTerm() { + return fixedBeginTerm; + } + + public CouponTemplateBO setFixedBeginTerm(Integer fixedBeginTerm) { + this.fixedBeginTerm = fixedBeginTerm; + return this; + } + + public Integer getFixedEndTerm() { + return fixedEndTerm; + } + + public CouponTemplateBO setFixedEndTerm(Integer fixedEndTerm) { + this.fixedEndTerm = fixedEndTerm; + return this; + } + +} diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponCardTemplateBO.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponTemplatePageBO.java similarity index 54% rename from promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponCardTemplateBO.java rename to promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponTemplatePageBO.java index 3f83b06ca..47de4338a 100644 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponCardTemplateBO.java +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponTemplatePageBO.java @@ -1,4 +1,5 @@ package cn.iocoder.mall.promotion.api.bo; -public class CouponCardTemplateBO { +public class CouponTemplatePageBO { + } diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/ProductRecommendBO.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/ProductRecommendBO.java index 6abc7c560..0834296e6 100644 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/ProductRecommendBO.java +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/ProductRecommendBO.java @@ -1,5 +1,7 @@ package cn.iocoder.mall.promotion.api.bo; +import cn.iocoder.mall.promotion.api.constant.ProductRecommendTypeEnum; + import java.util.Date; /** @@ -14,7 +16,7 @@ public class ProductRecommendBO { /** * 类型 * - * {@link cn.iocoder.mall.promotion.api.constant.ProductRecommendType} + * {@link ProductRecommendTypeEnum} */ private Integer type; /** @@ -103,4 +105,4 @@ public class ProductRecommendBO { return this; } -} \ No newline at end of file +} diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplateDateTypeEnum.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplateDateTypeEnum.java new file mode 100644 index 000000000..da1ffaaa0 --- /dev/null +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplateDateTypeEnum.java @@ -0,0 +1,43 @@ +package cn.iocoder.mall.promotion.api.constant; + +import cn.iocoder.common.framework.core.IntArrayValuable; + +import java.util.Arrays; + +public enum CouponTemplateDateTypeEnum implements IntArrayValuable { + + FIXED_DATE(1, "固定日期"), + FIXED_TERM(2, "领取日期"), + ; + + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplateDateTypeEnum::getValue).toArray(); + + /** + * 值 + */ + private final Integer value; + /** + * 名字 + */ + private final String name; + + CouponTemplateDateTypeEnum(Integer value, String name) { + this.value = value; + this.name = name; + } + + public Integer getValue() { + return value; + } + + public String getName() { + return name; + } + + + @Override + public int[] array() { + return ARRAYS; + } + +} diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplatePreferentialTypeEnum.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplatePreferentialTypeEnum.java new file mode 100644 index 000000000..d958a5da7 --- /dev/null +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplatePreferentialTypeEnum.java @@ -0,0 +1,43 @@ +package cn.iocoder.mall.promotion.api.constant; + +import cn.iocoder.common.framework.core.IntArrayValuable; + +import java.util.Arrays; + +public enum CouponTemplatePreferentialTypeEnum implements IntArrayValuable { + + PRICE(1, "代金卷"), + DISCOUNT(2, "折扣卷"), + ; + + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplatePreferentialTypeEnum::getValue).toArray(); + + /** + * 值 + */ + private final Integer value; + /** + * 名字 + */ + private final String name; + + CouponTemplatePreferentialTypeEnum(Integer value, String name) { + this.value = value; + this.name = name; + } + + public Integer getValue() { + return value; + } + + public String getName() { + return name; + } + + + @Override + public int[] array() { + return ARRAYS; + } + +} diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplateRangeTypeEnum.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplateRangeTypeEnum.java new file mode 100644 index 000000000..331209c62 --- /dev/null +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplateRangeTypeEnum.java @@ -0,0 +1,46 @@ +package cn.iocoder.mall.promotion.api.constant; + +import cn.iocoder.common.framework.core.IntArrayValuable; + +import java.util.Arrays; + +public enum CouponTemplateRangeTypeEnum implements IntArrayValuable { + + ALL(10, "所有可用"), + PRODUCT_INCLUDE_PRT(20, "部分商品可用,或指定商品可用"), + PRODUCT_EXCLUDE_PRT(21, "部分商品不可用,或指定商品可用"), + CATEGORY_INCLUDE_PRT(30, "部分分类可用,或指定分类可用"), + CATEGORY_EXCLUDE_PRT(31, "部分分类不可用,或指定分类可用"), + ; + + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplateRangeTypeEnum::getValue).toArray(); + + /** + * 值 + */ + private final Integer value; + /** + * 名字 + */ + private final String name; + + CouponTemplateRangeTypeEnum(Integer value, String name) { + this.value = value; + this.name = name; + } + + public Integer getValue() { + return value; + } + + public String getName() { + return name; + } + + + @Override + public int[] array() { + return ARRAYS; + } + +} diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplateStatusEnum.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplateStatusEnum.java new file mode 100644 index 000000000..8714f2f92 --- /dev/null +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplateStatusEnum.java @@ -0,0 +1,36 @@ +package cn.iocoder.mall.promotion.api.constant; + +import java.util.Arrays; + +public enum CouponTemplateStatusEnum { + + ENABLE(1, "开启中"), + DISABLE(2, "禁用中"), + EXPIRE(3, "已过期"), + ; + + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplateStatusEnum::getValue).toArray(); + + /** + * 值 + */ + private final Integer value; + /** + * 名字 + */ + private final String name; + + CouponTemplateStatusEnum(Integer value, String name) { + this.value = value; + this.name = name; + } + + public Integer getValue() { + return value; + } + + public String getName() { + return name; + } + +} diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplateTypeEnum.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplateTypeEnum.java new file mode 100644 index 000000000..e213429f3 --- /dev/null +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplateTypeEnum.java @@ -0,0 +1,35 @@ +package cn.iocoder.mall.promotion.api.constant; + +import java.util.Arrays; + +public enum CouponTemplateTypeEnum { + + CARD(1, "优惠劵"), + CODE(2, "折扣卷"), + ; + + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplateTypeEnum::getValue).toArray(); + + /** + * 值 + */ + private final Integer value; + /** + * 名字 + */ + private final String name; + + CouponTemplateTypeEnum(Integer value, String name) { + this.value = value; + this.name = name; + } + + public Integer getValue() { + return value; + } + + public String getName() { + return name; + } + +} diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/ProductRecommendType.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/ProductRecommendTypeEnum.java similarity index 86% rename from promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/ProductRecommendType.java rename to promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/ProductRecommendTypeEnum.java index 302e69e31..c251470be 100644 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/ProductRecommendType.java +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/ProductRecommendTypeEnum.java @@ -3,7 +3,7 @@ package cn.iocoder.mall.promotion.api.constant; /** * 商品推荐类型 */ -public enum ProductRecommendType { +public enum ProductRecommendTypeEnum { HOT(1, "热卖推荐"), NEW(2, "新品推荐"), @@ -19,7 +19,7 @@ public enum ProductRecommendType { */ private final String name; - ProductRecommendType(Integer value, String name) { + ProductRecommendTypeEnum(Integer value, String name) { this.value = value; this.name = name; } @@ -40,4 +40,4 @@ public enum ProductRecommendType { || NEW.value.equals(status); } -} \ No newline at end of file +} diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardTemplateAddDTO.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardTemplateAddDTO.java index 825c01d0a..c6671ed42 100644 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardTemplateAddDTO.java +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardTemplateAddDTO.java @@ -1,7 +1,13 @@ package cn.iocoder.mall.promotion.api.dto; +import cn.iocoder.common.framework.validator.InEnum; +import cn.iocoder.mall.promotion.api.constant.CouponTemplateDateTypeEnum; +import cn.iocoder.mall.promotion.api.constant.CouponTemplatePreferentialTypeEnum; +import cn.iocoder.mall.promotion.api.constant.CouponTemplateRangeTypeEnum; import org.hibernate.validator.constraints.Length; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.util.Date; @@ -28,13 +34,14 @@ public class CouponCardTemplateAddDTO { * * null - 则表示不限制 */ + @Min(value = 1, message = "每人限领个数最小为 {value}") private Integer quota; /** - * 剩余可用库存 - * - * null - 则表示无限库存 + * 发放总量 */ - private Integer stock; + @NotNull(message = "发放总量不能为空") + @Min(value = 1, message = "每人限领个数最小为 {value}") + private Integer total; // ========== 领取规则 END ========== // ========== 使用规则 BEGIN ========== @@ -45,6 +52,7 @@ public class CouponCardTemplateAddDTO { * 大于0-多少金额可用 */ @NotNull(message = "使用金额门槛不能为空") + @Min(value = 0L, message = "使用金额门槛最低为 {value}") private Integer priceAvailable; /** * 可用范围的类型 @@ -52,10 +60,11 @@ public class CouponCardTemplateAddDTO { * 10-全部(ALL):所有可用 * 20-部分(PART):部分商品可用,或指定商品可用 * 21-部分(PART):部分商品不可用,或指定商品可用 - * 30-部分(PART):部分分类可用,或指定商品可用 - * 31-部分(PART):部分分类不可用,或指定商品可用 + * 30-部分(PART):部分分类可用,或指定分类可用 + * 31-部分(PART):部分分类不可用,或指定分类可用 */ @NotNull(message = "可用范围的类型不能为空") + @InEnum(value = CouponTemplateRangeTypeEnum.class, message = "可用范围的类型必须在 {value}") private Integer rangeType; /** * 指定商品 / 分类列表,使用逗号分隔商品编号 @@ -65,9 +74,10 @@ public class CouponCardTemplateAddDTO { * 生效日期类型 * * 1-固定日期 - * 2-领取日期:领到券 {@link #fixedTerm} 日开始 N 天内有效 + * 2-领取日期:领到券 {@link #fixedEndTerm} 日开始 N 天内有效 */ @NotNull(message = "生效日期类型不能为空") + @InEnum(value = CouponTemplateDateTypeEnum.class, message = "生效日期类型必须在 {value}") private Integer dateType; /** * 固定日期-生效开始时间 @@ -77,16 +87,18 @@ public class CouponCardTemplateAddDTO { * 固定日期-生效结束时间 */ private Date validEndTime; -// /** -// * 领取日期-开始天数 -// * -// * 例如,0-当天;1-次天 -// */ -// private Integer fixedBeginTerm; + /** + * 领取日期-开始天数 + * + * 例如,0-当天;1-次天 + */ + @Min(value = 0L, message = "领取日期开始时间最小为 {value}") + private Integer fixedBeginTerm; /** * 领取日期-结束天数 */ - private Integer fixedTerm; + @Min(value = 1L, message = "领取日期结束时间最小为 {value}") + private Integer fixedEndTerm; // ========== 使用规则 END ========== // ========== 使用效果 BEGIN ========== @@ -96,24 +108,175 @@ public class CouponCardTemplateAddDTO { * 1-代金卷 * 2-折扣卷 */ + @NotNull(message = "优惠类型不能为空") + @InEnum(value = CouponTemplatePreferentialTypeEnum.class, message = "优惠类型必须在 {value}") private Integer preferentialType; + /** + * 优惠金额,单位:分 + */ + @Min(value = 1, message = "优惠金额最小值为 {value}") + private Integer priceOff; /** * 折扣百分比。 * * 例如,80% 为 80。 * 当 100% 为 100 ,则代表免费。 */ + @Max(value = 100, message = "折扣比最大值为 {value}") private Integer percentOff; - /** - * 优惠金额,单位:分 - */ - private Integer priceOff; /** * 折扣上限,仅在 {@link #preferentialType} 等于 2 时生效。 * * 例如,折扣上限为 20 元,当使用 8 折优惠券,订单金额为 1000 元时,最高只可折扣 20 元,而非 80 元。 */ + @Min(value = 1, message = "折扣上限最小值为 {value}") private Integer discountPriceLimit; // ========== 使用效果 END ========== + + public String getTitle() { + return title; + } + + public CouponCardTemplateAddDTO setTitle(String title) { + this.title = title; + return this; + } + + public String getDescription() { + return description; + } + + public CouponCardTemplateAddDTO setDescription(String description) { + this.description = description; + return this; + } + + public Integer getQuota() { + return quota; + } + + public CouponCardTemplateAddDTO setQuota(Integer quota) { + this.quota = quota; + return this; + } + + public Integer getPriceAvailable() { + return priceAvailable; + } + + public CouponCardTemplateAddDTO setPriceAvailable(Integer priceAvailable) { + this.priceAvailable = priceAvailable; + return this; + } + + public Integer getRangeType() { + return rangeType; + } + + public CouponCardTemplateAddDTO setRangeType(Integer rangeType) { + this.rangeType = rangeType; + return this; + } + + public String getRangeValues() { + return rangeValues; + } + + public CouponCardTemplateAddDTO setRangeValues(String rangeValues) { + this.rangeValues = rangeValues; + return this; + } + + public Integer getDateType() { + return dateType; + } + + public CouponCardTemplateAddDTO setDateType(Integer dateType) { + this.dateType = dateType; + return this; + } + + public Date getValidStartTime() { + return validStartTime; + } + + public CouponCardTemplateAddDTO setValidStartTime(Date validStartTime) { + this.validStartTime = validStartTime; + return this; + } + + public Date getValidEndTime() { + return validEndTime; + } + + public CouponCardTemplateAddDTO setValidEndTime(Date validEndTime) { + this.validEndTime = validEndTime; + return this; + } + + public Integer getFixedBeginTerm() { + return fixedBeginTerm; + } + + public CouponCardTemplateAddDTO setFixedBeginTerm(Integer fixedBeginTerm) { + this.fixedBeginTerm = fixedBeginTerm; + return this; + } + + public Integer getFixedEndTerm() { + return fixedEndTerm; + } + + public CouponCardTemplateAddDTO setFixedEndTerm(Integer fixedEndTerm) { + this.fixedEndTerm = fixedEndTerm; + return this; + } + + public Integer getPreferentialType() { + return preferentialType; + } + + public CouponCardTemplateAddDTO setPreferentialType(Integer preferentialType) { + this.preferentialType = preferentialType; + return this; + } + + public Integer getPercentOff() { + return percentOff; + } + + public CouponCardTemplateAddDTO setPercentOff(Integer percentOff) { + this.percentOff = percentOff; + return this; + } + + public Integer getPriceOff() { + return priceOff; + } + + public CouponCardTemplateAddDTO setPriceOff(Integer priceOff) { + this.priceOff = priceOff; + return this; + } + + public Integer getDiscountPriceLimit() { + return discountPriceLimit; + } + + public CouponCardTemplateAddDTO setDiscountPriceLimit(Integer discountPriceLimit) { + this.discountPriceLimit = discountPriceLimit; + return this; + } + + public Integer getTotal() { + return total; + } + + public CouponCardTemplateAddDTO setTotal(Integer total) { + this.total = total; + return this; + } + + } diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCodeTemplatePageDTO.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCodeTemplatePageDTO.java deleted file mode 100644 index 98552abad..000000000 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCodeTemplatePageDTO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.mall.promotion.api.dto; - -/** - * 优惠码模板分页 DTO - */ -public class CouponCodeTemplatePageDTO { - - /** - * 标题 - */ - private String title; - /** - * 状态 - */ - private Integer status; - /** - * 优惠类型 - */ - private Integer preferentialType; - -} diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardTemplatePageDTO.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponTemplatePageDTO.java similarity index 86% rename from promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardTemplatePageDTO.java rename to promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponTemplatePageDTO.java index 098046c14..39574ad21 100644 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardTemplatePageDTO.java +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponTemplatePageDTO.java @@ -3,7 +3,7 @@ package cn.iocoder.mall.promotion.api.dto; /** * 优惠劵模板分页 DTO */ -public class CouponCardTemplatePageDTO { +public class CouponTemplatePageDTO { /** * 标题 diff --git a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/convert/CouponTemplateConvert.java b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/convert/CouponTemplateConvert.java new file mode 100644 index 000000000..1bc2d2699 --- /dev/null +++ b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/convert/CouponTemplateConvert.java @@ -0,0 +1,31 @@ +package cn.iocoder.mall.promotion.biz.convert; + +import cn.iocoder.mall.promotion.api.bo.CouponTemplateBO; +import cn.iocoder.mall.promotion.api.dto.CouponCardTemplateAddDTO; +import cn.iocoder.mall.promotion.api.dto.CouponCodeTemplateAddDTO; +import cn.iocoder.mall.promotion.biz.dataobject.CouponTemplateDO; +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface CouponTemplateConvert { + + CouponTemplateConvert INSTANCE = Mappers.getMapper(CouponTemplateConvert.class); + +// @Mappings({}) +// CouponTemplateBO convertToBO(CouponTemplateDO banner); +// +// @Mappings({}) +// List convertToBO(List bannerList); + + @Mappings({}) + CouponTemplateDO convert(CouponCodeTemplateAddDTO template); + + @Mappings({}) + CouponTemplateDO convert(CouponCardTemplateAddDTO template); + + @Mappings({}) + CouponTemplateBO convert(CouponTemplateDO template); + +} diff --git a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dataobject/CouponTemplateDO.java b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dataobject/CouponTemplateDO.java index 9fb96e4a2..ce8bdfd62 100644 --- a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dataobject/CouponTemplateDO.java +++ b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dataobject/CouponTemplateDO.java @@ -195,7 +195,7 @@ public class CouponTemplateDO extends BaseDO { private Integer discountPriceLimit; // ========== 使用效果 END ========== -// // ========== 统计信息 BEGIN ========== + // ========== 统计信息 BEGIN ========== // /** // * 领取优惠券的人数 // */ @@ -208,6 +208,186 @@ public class CouponTemplateDO extends BaseDO { // * 使用优惠券的次数 // */ // private Integer statUseNum; -// // ========== 统计信息 END ========== + // ========== 统计信息 END ========== + + public Integer getId() { + return id; + } + + public CouponTemplateDO setId(Integer id) { + this.id = id; + return this; + } + + public String getTitle() { + return title; + } + + public CouponTemplateDO setTitle(String title) { + this.title = title; + return this; + } + + public String getDescription() { + return description; + } + + public CouponTemplateDO setDescription(String description) { + this.description = description; + return this; + } + + public Integer getType() { + return type; + } + + public CouponTemplateDO setType(Integer type) { + this.type = type; + return this; + } + + public Integer getCodeType() { + return codeType; + } + + public CouponTemplateDO setCodeType(Integer codeType) { + this.codeType = codeType; + return this; + } + + public Integer getStatus() { + return status; + } + + public CouponTemplateDO setStatus(Integer status) { + this.status = status; + return this; + } + + public Integer getQuota() { + return quota; + } + + public CouponTemplateDO setQuota(Integer quota) { + this.quota = quota; + return this; + } + + public Integer getStock() { + return stock; + } + + public CouponTemplateDO setStock(Integer stock) { + this.stock = stock; + return this; + } + + public Integer getPriceAvailable() { + return priceAvailable; + } + + public CouponTemplateDO setPriceAvailable(Integer priceAvailable) { + this.priceAvailable = priceAvailable; + return this; + } + + public Integer getRangeType() { + return rangeType; + } + + public CouponTemplateDO setRangeType(Integer rangeType) { + this.rangeType = rangeType; + return this; + } + + public String getRangeValues() { + return rangeValues; + } + + public CouponTemplateDO setRangeValues(String rangeValues) { + this.rangeValues = rangeValues; + return this; + } + + public Integer getDateType() { + return dateType; + } + + public CouponTemplateDO setDateType(Integer dateType) { + this.dateType = dateType; + return this; + } + + public Date getValidStartTime() { + return validStartTime; + } + + public CouponTemplateDO setValidStartTime(Date validStartTime) { + this.validStartTime = validStartTime; + return this; + } + + public Date getValidEndTime() { + return validEndTime; + } + + public CouponTemplateDO setValidEndTime(Date validEndTime) { + this.validEndTime = validEndTime; + return this; + } + + public Integer getFixedTerm() { + return fixedTerm; + } + + public CouponTemplateDO setFixedTerm(Integer fixedTerm) { + this.fixedTerm = fixedTerm; + return this; + } + + public Integer getPreferentialType() { + return preferentialType; + } + + public CouponTemplateDO setPreferentialType(Integer preferentialType) { + this.preferentialType = preferentialType; + return this; + } + + public Integer getPercentOff() { + return percentOff; + } + + public CouponTemplateDO setPercentOff(Integer percentOff) { + this.percentOff = percentOff; + return this; + } + + public Integer getPriceOff() { + return priceOff; + } + + public CouponTemplateDO setPriceOff(Integer priceOff) { + this.priceOff = priceOff; + return this; + } + + public Integer getDiscountPriceLimit() { + return discountPriceLimit; + } + + public CouponTemplateDO setDiscountPriceLimit(Integer discountPriceLimit) { + this.discountPriceLimit = discountPriceLimit; + return this; + } + + public Integer getStatFetchNum() { + return statFetchNum; + } + + public CouponTemplateDO setStatFetchNum(Integer statFetchNum) { + this.statFetchNum = statFetchNum; + return this; + } } diff --git a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dataobject/ProductRecommendDO.java b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dataobject/ProductRecommendDO.java index 4ae5f2a28..601c2f388 100644 --- a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dataobject/ProductRecommendDO.java +++ b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dataobject/ProductRecommendDO.java @@ -1,6 +1,7 @@ package cn.iocoder.mall.promotion.biz.dataobject; import cn.iocoder.common.framework.dataobject.DeletableDO; +import cn.iocoder.mall.promotion.api.constant.ProductRecommendTypeEnum; /** * 商品推荐 DO @@ -14,7 +15,7 @@ public class ProductRecommendDO extends DeletableDO { /** * 类型 * - * {@link cn.iocoder.mall.promotion.api.constant.ProductRecommendType} + * {@link ProductRecommendTypeEnum} */ private Integer type; /** @@ -91,4 +92,4 @@ public class ProductRecommendDO extends DeletableDO { return this; } -} \ No newline at end of file +} diff --git a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/CouponServiceImpl.java b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/CouponServiceImpl.java index d285abc60..12ee3124c 100644 --- a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/CouponServiceImpl.java +++ b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/CouponServiceImpl.java @@ -1,4 +1,137 @@ package cn.iocoder.mall.promotion.biz.service; -public class CouponServiceImpl { +import cn.iocoder.common.framework.constant.SysErrorCodeEnum; +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.promotion.api.CouponService; +import cn.iocoder.mall.promotion.api.bo.CouponCardBO; +import cn.iocoder.mall.promotion.api.bo.CouponTemplateBO; +import cn.iocoder.mall.promotion.api.bo.CouponTemplatePageBO; +import cn.iocoder.mall.promotion.api.constant.CouponTemplateDateTypeEnum; +import cn.iocoder.mall.promotion.api.constant.CouponTemplatePreferentialTypeEnum; +import cn.iocoder.mall.promotion.api.constant.CouponTemplateStatusEnum; +import cn.iocoder.mall.promotion.api.constant.CouponTemplateTypeEnum; +import cn.iocoder.mall.promotion.api.dto.*; +import cn.iocoder.mall.promotion.biz.convert.CouponTemplateConvert; +import cn.iocoder.mall.promotion.biz.dao.CouponTemplateMapper; +import cn.iocoder.mall.promotion.biz.dataobject.CouponTemplateDO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; + +@Service // 实际上不用添加。添加的原因是,必须 Spring 报错提示 +@com.alibaba.dubbo.config.annotation.Service(validation = "true") +public class CouponServiceImpl implements CouponService { + + @Autowired + private CouponTemplateMapper couponTemplateMapper; + + @Override + public CommonResult getCouponTemplatePage(CouponTemplatePageDTO couponTemplatePageDTO) { + return null; + } + + @Override + public CommonResult addCouponCodeTemplate(CouponCodeTemplateAddDTO couponCodeTemplateAddDTO) { + return null; + } + + @Override + public CommonResult addCouponCardTemplate(CouponCardTemplateAddDTO couponCardTemplateAddDTO) { + // 校验生效日期相关 + CommonResult checkCouponCodeTemplateDateTypeResult = this.checkCouponTemplateDateType( + couponCardTemplateAddDTO.getDateType(), + couponCardTemplateAddDTO.getValidStartTime(), couponCardTemplateAddDTO.getValidEndTime(), + couponCardTemplateAddDTO.getFixedBeginTerm(), couponCardTemplateAddDTO.getFixedEndTerm()); + if (checkCouponCodeTemplateDateTypeResult.isError()) { + return CommonResult.error(checkCouponCodeTemplateDateTypeResult); + } + // 校验优惠类型 + CommonResult checkCouponTemplateDateTypeResult = this.checkCouponTemplatePreferentialType( + couponCardTemplateAddDTO.getPreferentialType(), couponCardTemplateAddDTO.getPercentOff(), + couponCardTemplateAddDTO.getPriceOff()); + if (checkCouponCodeTemplateDateTypeResult.isError()) { + return CommonResult.error(checkCouponTemplateDateTypeResult); + } + // 保存优惠劵模板到数据库 + CouponTemplateDO template = CouponTemplateConvert.INSTANCE.convert(couponCardTemplateAddDTO) + .setType(CouponTemplateTypeEnum.CARD.getValue()) + .setStatus(CouponTemplateStatusEnum.ENABLE.getValue()) + .setStatFetchNum(0); + couponTemplateMapper.insert(template); + // 返回成功 + return CommonResult.success(CouponTemplateConvert.INSTANCE.convert(template)); + } + + @Override + public CommonResult updateCouponCodeTemplate(CouponCodeTemplateUpdateDTO couponCodeTemplateUpdateDTO) { + return null; + } + + @Override + public CommonResult updateCouponCardTemplate(CouponCardTemplateUpdateDTO couponCardTemplateUpdateDTO) { + return null; + } + + @Override + public CommonResult updateCouponTemplateStatus(Integer adminId, Integer couponTemplateId, Integer status) { + return null; + } + + @Override + public CommonResult addCouponCard(Integer userId, Integer couponTemplateId) { + return null; + } + + @Override + public CommonResult useCouponCard(Integer userId, Integer couponCardId, Integer usedOrderId, Integer usedPrice) { + return null; + } + + @Override + public CommonResult cancelUseCouponCard(Integer userId, Integer couponCardId) { + return null; + } + + @Override + public CommonResult useCouponCode(Integer userId, String code) { + return null; + } + + private CommonResult checkCouponTemplateDateType(Integer dateType, Date validStartTime, Date validEndTime, Integer fixedBeginTerm, Integer fixedEndTerm) { + if (CouponTemplateDateTypeEnum.FIXED_DATE.getValue().equals(dateType)) { // 固定日期 + if (validStartTime == null) { + return CommonResult.error(SysErrorCodeEnum.VALIDATION_REQUEST_PARAM_ERROR.getCode(), "生效开始时间不能为空"); + } + if (validEndTime == null) { + return CommonResult.error(SysErrorCodeEnum.VALIDATION_REQUEST_PARAM_ERROR.getCode(), "生效结束时间不能为空"); + } + } else if (CouponTemplateDateTypeEnum.FIXED_TERM.getValue().equals(dateType)) { // 领取日期 + if (fixedBeginTerm == null) { + return CommonResult.error(SysErrorCodeEnum.VALIDATION_REQUEST_PARAM_ERROR.getCode(), "领取日期开始时间不能为空"); + } + if (fixedEndTerm == null) { + return CommonResult.error(SysErrorCodeEnum.VALIDATION_REQUEST_PARAM_ERROR.getCode(), "领取日期结束时间不能为空"); + } + } else { + throw new IllegalArgumentException("未知的生效日期类型:" + dateType); + } + return CommonResult.success(true); + } + + private CommonResult checkCouponTemplatePreferentialType(Integer preferentialType, Integer percentOff, Integer priceOff) { + if (CouponTemplatePreferentialTypeEnum.PRICE.getValue().equals(preferentialType)) { + if (priceOff == null) { + return CommonResult.error(SysErrorCodeEnum.VALIDATION_REQUEST_PARAM_ERROR.getCode(), "优惠金额不能为空"); + } + } else if (CouponTemplatePreferentialTypeEnum.DISCOUNT.getValue().equals(preferentialType)) { + if (percentOff == null) { + return CommonResult.error(SysErrorCodeEnum.VALIDATION_REQUEST_PARAM_ERROR.getCode(), "折扣百分比不能为空"); + } + } else { + throw new IllegalArgumentException("未知的优惠类型:" + preferentialType); + } + return CommonResult.success(true); + } + } diff --git a/promotion/promotion-service-impl/src/main/resources/mapper/CouponTemplateMapper.xml b/promotion/promotion-service-impl/src/main/resources/mapper/CouponTemplateMapper.xml index 049652c9f..eb9c26292 100644 --- a/promotion/promotion-service-impl/src/main/resources/mapper/CouponTemplateMapper.xml +++ b/promotion/promotion-service-impl/src/main/resources/mapper/CouponTemplateMapper.xml @@ -72,15 +72,15 @@ INSERT INTO coupon_template ( title, description, type, code_type, - status, quota, stock, price_available, range_type, + status, quota, total, price_available, range_type, range_values, date_type, valid_start_time, valid_end_time, fixed_term, preferential_type, percent_off, price_off, discount_price_limit, stat_fetch_num, create_time ) VALUES ( - #{title}, #{description, #{type, #{code_type}, - #{status}, #{quota, #{stock}, #{priceAvailable}, #{rangeType}, - #{rangeValues}, #{dateType}, #{validStartTime}, #{validEndTime, #{fixedTerm}, - #{preferentialType, #{percentOff}, #{priceOff}, #{discountPriceLimit}, #{statFetchNum}, + #{title}, #{description}, #{type}, #{codeType}, + #{status}, #{quota}, #{total}, #{priceAvailable}, #{rangeType}, + #{rangeValues}, #{dateType}, #{validStartTime}, #{validEndTime}, #{fixedTerm}, + #{preferentialType}, #{percentOff}, #{priceOff}, #{discountPriceLimit}, #{statFetchNum}, #{createTime} ) @@ -104,37 +104,37 @@ stock = #{stock}, - price_available = #{priceAvailable} + price_available = #{priceAvailable}, - range_type = #{rangeType} + range_type = #{rangeType}, - range_values = #{rangeValues} + range_values = #{rangeValues}, - date_type = #{dateType} + date_type = #{dateType}, - valid_start_time = #{validStartTime} + valid_start_time = #{validStartTime}, - valid_end_time = #{validEndTime} + valid_end_time = #{validEndTime}, - fixed_term = #{fixedTerm} + fixed_term = #{fixedTerm}, - preferential_type = #{preferentialType} + preferential_type = #{preferentialType}, - percent_off = #{percentOff} + percent_off = #{percentOff}, - price_off = #{priceOff} + price_off = #{priceOff}, - discount_price_limit = #{discountPriceLimit} + discount_price_limit = #{discountPriceLimit}, WHERE id = #{id}