后端 + 前端:优惠劵模板添加(未完成)
parent
8e9ca19e64
commit
f6c847d104
|
@ -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',
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
|
@ -56,4 +56,5 @@ export default {
|
|||
// 营销相关
|
||||
'menu.promotion.promotion-banner-list': 'Banner 管理',
|
||||
'menu.promotion.product-recommend-list': '商品推荐',
|
||||
};
|
||||
'menu.promotion.coupon-card-template-list': '优惠劵管理',
|
||||
};
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
|
@ -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 <span>{types[val]}</span>; // TODO 芋艿,此处要改
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '商品',
|
||||
dataIndex: 'productSpuId',
|
||||
},
|
||||
{
|
||||
title: '排序值',
|
||||
dataIndex: 'sort',
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
render(val) {
|
||||
return <span>{status[val]}</span>; // TODO 芋艿,此处要改
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
dataIndex: 'memo',
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
render: val => <span>{moment(val).format('YYYY-MM-DD HH:mm')}</span>,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 360,
|
||||
render: (text, record) => {
|
||||
const statusText = record.status === 1 ? '禁用' : '开启'; // TODO 芋艿,此处要改
|
||||
return (
|
||||
<Fragment>
|
||||
<a onClick={() => handleModalVisible(true, 'update', record)}>编辑</a>
|
||||
<Divider type="vertical" />
|
||||
<a className={styles.tableDelete} onClick={() => handleStatus(record)}>
|
||||
{statusText}
|
||||
</a>
|
||||
{
|
||||
record.status === 2 ?
|
||||
<span>
|
||||
<Divider type="vertical" />
|
||||
<a className={styles.tableDelete} onClick={() => handleDelete(record)}>
|
||||
删除
|
||||
</a>
|
||||
</span> : null
|
||||
}
|
||||
</Fragment>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
function onPageChange(page) { // 翻页
|
||||
dispatch({
|
||||
type: 'productRecommendList/query',
|
||||
payload: {
|
||||
pageNo: page.current,
|
||||
pageSize: page.pageSize,
|
||||
...searchParams
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={dataSource}
|
||||
loading={loading}
|
||||
rowKey="id"
|
||||
pagination={pagination}
|
||||
onChange={onPageChange}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
// 搜索表单
|
||||
// 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 (
|
||||
<Form onSubmit={handleSubmit} layout="inline">
|
||||
<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
|
||||
<Col md={8} sm={24}>
|
||||
<FormItem label="标题">
|
||||
{getFieldDecorator('title')(<Input placeholder="请输入" />)}
|
||||
</FormItem>
|
||||
</Col>
|
||||
<Col md={8} sm={24}>
|
||||
<span className={styles.submitButtons}>
|
||||
<Button type="primary" htmlType="submit">
|
||||
查询
|
||||
</Button>
|
||||
<Button style={{ marginLeft: 8 }} onClick={handleReset}>
|
||||
重置
|
||||
</Button>
|
||||
</span>
|
||||
</Col>
|
||||
</Row>
|
||||
</Form>
|
||||
);
|
||||
});
|
||||
|
||||
// 添加 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 (
|
||||
<Modal
|
||||
destroyOnClose
|
||||
title={title}
|
||||
visible={modalVisible}
|
||||
onOk={okHandle}
|
||||
okText='保存'
|
||||
onCancel={() => handleModalVisible()}
|
||||
width={720}
|
||||
>
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="标题">
|
||||
{form.getFieldDecorator('title', {
|
||||
rules: [{ required: true, message: '请输入标题!' }],
|
||||
initialValue: formVals.title,
|
||||
})(<Input placeholder="请输入" />)}
|
||||
</FormItem>
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="使用说明">
|
||||
{form.getFieldDecorator('description', {
|
||||
rules: [{ required: false, message: '请输入使用说明!' },
|
||||
{max: 255, message: '最大长度为 255 位'},
|
||||
],
|
||||
initialValue: formVals.description,
|
||||
})(<Input.TextArea placeholder="请输入" />)}
|
||||
</FormItem>
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="限领次数">
|
||||
{form.getFieldDecorator('quota', {
|
||||
rules: [{ required: true, message: '请选择每人限领次数!'},
|
||||
],
|
||||
initialValue: formVals.quota,
|
||||
})(
|
||||
<Select placeholder="请选择" style={{ maxWidth: 200, width: '100%' }}>
|
||||
<SelectOption value="">不限次数</SelectOption>
|
||||
<SelectOption value="1">1 次</SelectOption>
|
||||
<SelectOption value="2">2 次</SelectOption>
|
||||
<SelectOption value="3">3 次</SelectOption>
|
||||
<SelectOption value="4">4 次</SelectOption>
|
||||
<SelectOption value="5">5 次</SelectOption>
|
||||
<SelectOption value="10">10 次</SelectOption>
|
||||
</Select>
|
||||
)}
|
||||
</FormItem>
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="发放总量">
|
||||
{form.getFieldDecorator('total', {
|
||||
rules: [{ required: true, message: '请输入发放总量!' },
|
||||
{min: 1, type: 'number', message: '最小值为 1'}],
|
||||
initialValue: formVals.total,
|
||||
})(<InputNumber placeholder="请输入" />)}
|
||||
</FormItem>
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="使用金额门槛">
|
||||
{form.getFieldDecorator('priceAvailable', {
|
||||
rules: [{ required: true, message: '请输入使用金额门槛!' },],
|
||||
initialValue: formVals.priceAvailable,
|
||||
})(<InputNumber placeholder="请输入" />)} 元
|
||||
</FormItem>
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="可用范围">
|
||||
{form.getFieldDecorator('rangeType', {
|
||||
rules: [{ required: true, message: '请选择可用范围!'}, // TODO 芋艿,需要修改
|
||||
],
|
||||
initialValue: formVals.rangeType,
|
||||
})(
|
||||
<Select placeholder="请选择" style={{ maxWidth: 200, width: '100%' }} onChange={onRangeTypeChange} >
|
||||
<SelectOption value="10">所有可用</SelectOption>
|
||||
<SelectOption value="20">部分商品可用</SelectOption>
|
||||
<SelectOption value="21">部分商品不可用</SelectOption>
|
||||
<SelectOption value="30">部分分类可用</SelectOption>
|
||||
<SelectOption value="31">部分分类不可用</SelectOption>
|
||||
</Select>
|
||||
)}
|
||||
</FormItem>
|
||||
{
|
||||
formVals.rangeType == 20 || formVals.rangeType == 21
|
||||
|| formVals.rangeType == 30 || formVals.rangeType == 31 ?
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="具体范围">
|
||||
{form.getFieldDecorator('rangeValues', {
|
||||
rules: [{ required: true, message: '请输入具体范围!' }, // TODO 芋艿,做成搜索
|
||||
{maxlength: 255, message: '最大长度为 255 位'},
|
||||
],
|
||||
initialValue: formVals.rangeValues,
|
||||
})(<Input.TextArea placeholder="请输入" />)}
|
||||
</FormItem>
|
||||
: ''
|
||||
}
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="生效日期类型">
|
||||
{form.getFieldDecorator('dateType', {
|
||||
rules: [{ required: true, message: '请选择可用范围!'}, // TODO 芋艿,需要修改
|
||||
],
|
||||
initialValue: formVals.dateType,
|
||||
})(
|
||||
<Select placeholder="请选择" style={{ maxWidth: 200, width: '100%' }} onChange={onDateTypeChange}>
|
||||
<SelectOption value="1">固定日期</SelectOption>
|
||||
<SelectOption value="2">领取日期</SelectOption>
|
||||
</Select>
|
||||
)}
|
||||
</FormItem>
|
||||
{
|
||||
formVals.dateType == 1 ?
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="固定日期">
|
||||
{form.getFieldDecorator('validStartTime', {
|
||||
rules: [{ required: true, message: '请输入固定日期!' },],
|
||||
initialValue: formVals.validStartTime,
|
||||
})(<DatePicker format="YYYY-MM-DD" />)}
|
||||
-
|
||||
{form.getFieldDecorator('validEndTime', {
|
||||
rules: [{ required: true, message: '请输入固定日期!' },],
|
||||
initialValue: formVals.validEndTime,
|
||||
})(<DatePicker format="YYYY-MM-DD" />)}
|
||||
</FormItem> : ''
|
||||
}
|
||||
{
|
||||
formVals.dateType == 2 ?
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="领取日期">
|
||||
{form.getFieldDecorator('fixedBeginTerm', {
|
||||
rules: [{ required: true, message: '请输入固定日期!' },],
|
||||
initialValue: formVals.fixedBeginTerm,
|
||||
})(<InputNumber placeholder="请输入" />)}
|
||||
-
|
||||
{form.getFieldDecorator('fixedEndTerm', {
|
||||
rules: [{ required: false, message: '请输入固定日期!' },],
|
||||
initialValue: formVals.fixedEndTerm,
|
||||
})(<InputNumber placeholder="请输入" />)} 天
|
||||
</FormItem> : ''
|
||||
}
|
||||
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="优惠类型">
|
||||
{form.getFieldDecorator('preferentialType', {
|
||||
rules: [{ required: true, message: '请选择优惠类型!'}, // TODO 芋艿,需要修改
|
||||
],
|
||||
initialValue: formVals.preferentialType,
|
||||
})(
|
||||
<Select placeholder="请选择" style={{ maxWidth: 200, width: '100%' }} onChange={onPreferentialTypeChange}>
|
||||
<SelectOption value="1">代金卷</SelectOption>
|
||||
<SelectOption value="2">折扣卷</SelectOption>
|
||||
</Select>
|
||||
)}
|
||||
</FormItem>
|
||||
{
|
||||
formVals.preferentialType == 1 ?
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="优惠金额">
|
||||
{form.getFieldDecorator('priceOff', {
|
||||
rules: [{ required: true, message: '请输入优惠金额!' },
|
||||
{min: 0.01, type: 'number', message: '最小值为 0.01'}],
|
||||
initialValue: formVals.priceOff,
|
||||
})(<InputNumber placeholder="请输入" />)}
|
||||
</FormItem> : ''
|
||||
}
|
||||
{
|
||||
formVals.preferentialType == 2 ?
|
||||
<span>
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="折扣百分比">
|
||||
{form.getFieldDecorator('percentOff', {
|
||||
rules: [{ required: true, message: '请输入折扣百分比!' },
|
||||
{min: 1, max: 99, type: 'number', message: '范围为 [1, 99]'},
|
||||
],
|
||||
initialValue: formVals.percentOff,
|
||||
})(<InputNumber placeholder="请输入" />)}%
|
||||
</FormItem>
|
||||
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="最多优惠">
|
||||
{form.getFieldDecorator('discountPriceLimit', {
|
||||
rules: [{ required: false, message: '请输入最多优惠!' },
|
||||
{min: 0.01, type: 'number', message: '最小值为 0.01'},
|
||||
],
|
||||
initialValue: formVals.discountPriceLimit,
|
||||
})(<InputNumber placeholder="请输入" />)}元
|
||||
</FormItem>
|
||||
</span> : ''
|
||||
}
|
||||
</Modal>
|
||||
);
|
||||
});
|
||||
|
||||
@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 (
|
||||
<PageHeaderWrapper>
|
||||
<Card bordered={false}>
|
||||
<div className={styles.tableList}>
|
||||
<div className={styles.tableListForm}>
|
||||
<SearchForm {...searchFormProps} />
|
||||
</div>
|
||||
<div className={styles.tableListOperator}>
|
||||
<Button
|
||||
icon="plus"
|
||||
type="primary"
|
||||
onClick={() => this.handleModalVisible(true, 'add', {})}
|
||||
>
|
||||
新建优惠劵
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<List {...listProps} />
|
||||
</Card>
|
||||
|
||||
<AddOrUpdateForm {...addOrUpdateFormProps} />
|
||||
|
||||
</PageHeaderWrapper>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default CouponCardTemplateLists;
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -257,7 +257,7 @@ const AddOrUpdateForm = Form.create()(props => {
|
|||
});
|
||||
};
|
||||
|
||||
const title = modalType === 'add' ? '新建 Banner' : '更新 Banner';
|
||||
const title = modalType === 'add' ? '新建商品推荐' : '更新商品推荐';
|
||||
return (
|
||||
<Modal
|
||||
destroyOnClose
|
||||
|
@ -395,4 +395,4 @@ class BannerList extends PureComponent {
|
|||
}
|
||||
}
|
||||
|
||||
export default BannerList;
|
||||
export default BannerList;
|
||||
|
|
|
@ -63,4 +63,12 @@ export async function deleteProductRecommend(params) {
|
|||
return request(`/promotion-api/admins/product_recommend/delete?${stringify(params)}`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// coupon
|
||||
|
||||
export async function addCouponCardTemplate(params) {
|
||||
return request(`/promotion-api/admins/coupon/template/add_card?${stringify(params)}`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
package cn.iocoder.mall.promotion.application.controller.admins;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.promotion.api.CouponService;
|
||||
import cn.iocoder.mall.promotion.api.bo.CouponTemplateBO;
|
||||
import cn.iocoder.mall.promotion.api.dto.CouponCardTemplateAddDTO;
|
||||
import cn.iocoder.mall.promotion.application.convert.CouponTemplateConvert;
|
||||
import cn.iocoder.mall.promotion.application.vo.admins.AdminsCouponTemplateVO;
|
||||
import com.alibaba.dubbo.config.annotation.Reference;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admins/product_recommend")
|
||||
@Api("优惠劵(码)模块")
|
||||
public class AdminsCouponTemplateController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
private CouponService couponService;
|
||||
|
||||
// ========== 优惠劵(码)模板 ==========
|
||||
|
||||
@PostMapping("/template/add_card")
|
||||
@ApiOperation(value = "创建优惠劵模板")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "title", value = "标题", required = true, example = "优惠劵牛逼"),
|
||||
@ApiImplicitParam(name = "description", value = "使用说明", example = "我只是描述"),
|
||||
@ApiImplicitParam(name = "quota", value = "每人限领个数", example = "null - 则表示不限制"),
|
||||
@ApiImplicitParam(name = "stock", value = "剩余可用库存", example = "null - 则表示无限库存"),
|
||||
@ApiImplicitParam(name = "priceAvailable", value = "是否设置满多少金额可用,单位:分", example = "0-不限制;大于0-多少金额可用"),
|
||||
@ApiImplicitParam(name = "rangeType", value = "可用范围的类型", required = true, example = "参见 CouponTemplateRangeTypeEnum 枚举"),
|
||||
@ApiImplicitParam(name = "rangeValues", value = "指定商品 / 分类列表,使用逗号分隔商品编号"),
|
||||
@ApiImplicitParam(name = "dateType", value = "生效日期类型", example = "参见 CouponTemplateDateTypeEnum 枚举"),
|
||||
@ApiImplicitParam(name = "validStartTime", value = "固定日期-生效开始时间", example = "当 dateType 为固定日期时,非空"),
|
||||
@ApiImplicitParam(name = "validEndTime", value = "固定日期-生效结束时间", example = "当 dateType 为固定日期时,非空"),
|
||||
@ApiImplicitParam(name = "fixedBeginTerm", value = "领取日期-开始天数", example = "当 dateType 为领取日期时,非空"),
|
||||
@ApiImplicitParam(name = "fixedEndTerm", value = "领取日期-结束天数", example = "当 dateType 为领取日期时,非空"),
|
||||
@ApiImplicitParam(name = "preferentialType", value = "优惠类型", example = "参见 CouponTemplatePreferentialTypeEnum 枚举"),
|
||||
@ApiImplicitParam(name = "priceOff", value = "优惠金额,单位:分", example = "当 preferentialType 为现金券时,非空"),
|
||||
@ApiImplicitParam(name = "percentOff", value = "折扣百分比", example = "当 preferentialType 为折扣卷时,非空"),
|
||||
@ApiImplicitParam(name = "discountPriceLimit", value = "折扣上限", example = "当 preferentialType 为折扣卷时,非空"),
|
||||
})
|
||||
public CommonResult<AdminsCouponTemplateVO> 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<CouponTemplateBO> result = couponService.addCouponCardTemplate(couponCardTemplateAddDTO);
|
||||
// 返回结果
|
||||
return CouponTemplateConvert.INSTANCE.convert2(result);
|
||||
}
|
||||
|
||||
// ========== 优惠劵 ==========
|
||||
|
||||
// ========== 优惠码 ==========
|
||||
|
||||
}
|
|
@ -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<AdminsCouponTemplateVO> convert2(CommonResult<CouponTemplateBO> result);
|
||||
|
||||
// @Mappings({})
|
||||
// CommonResult<AdminsCouponTemplatePageVO> convert(CommonResult<CouponTemplatePageBO> result);
|
||||
//
|
||||
// @Mappings({})
|
||||
// List<UsersCouponTemplateVO> convertList(List<CouponTemplateBO> banners);
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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<CouponCodeTemplatePageBO> getCouponCodeTemplatePage(CouponCodeTemplatePageDTO couponCodeTemplatePageDTO);
|
||||
|
||||
CommonResult<CouponCardTemplatePageBO> getCouponCardTemplatePage(CouponCardTemplatePageDTO couponCardTemplatePageDTO);
|
||||
CommonResult<CouponTemplatePageBO> getCouponTemplatePage(CouponTemplatePageDTO couponTemplatePageDTO);
|
||||
|
||||
/**
|
||||
* 创建优惠码模板
|
||||
|
@ -21,7 +18,7 @@ public interface CouponService {
|
|||
* @param couponCodeTemplateAddDTO 优惠码模板添加 DTO
|
||||
* @return 优惠码模板
|
||||
*/
|
||||
CommonResult<CouponCodeTemplateBO> addCouponCodeTemplate(CouponCodeTemplateAddDTO couponCodeTemplateAddDTO);
|
||||
CommonResult<CouponTemplateBO> addCouponCodeTemplate(CouponCodeTemplateAddDTO couponCodeTemplateAddDTO);
|
||||
|
||||
/**
|
||||
* 创建优惠劵模板
|
||||
|
@ -29,7 +26,7 @@ public interface CouponService {
|
|||
* @param couponCardTemplateAddDTO 优惠码模板添加 DTO
|
||||
* @return 优惠劵模板
|
||||
*/
|
||||
CommonResult<CouponCodeTemplateBO> addCouponCardTemplate(CouponCardTemplateAddDTO couponCardTemplateAddDTO);
|
||||
CommonResult<CouponTemplateBO> addCouponCardTemplate(CouponCardTemplateAddDTO couponCardTemplateAddDTO);
|
||||
|
||||
/**
|
||||
* 更新优惠码模板
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
package cn.iocoder.mall.promotion.api.bo;
|
||||
|
||||
public class CouponCardTemplatePageBO {
|
||||
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
package cn.iocoder.mall.promotion.api.bo;
|
||||
|
||||
public class CouponCodeTemplateBO {
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
package cn.iocoder.mall.promotion.api.bo;
|
||||
|
||||
public class CouponCodeTemplatePageBO {
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
package cn.iocoder.mall.promotion.api.bo;
|
||||
|
||||
public class CouponCardTemplateBO {
|
||||
public class CouponTemplatePageBO {
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
package cn.iocoder.mall.promotion.api.dto;
|
||||
|
||||
/**
|
||||
* 优惠码模板分页 DTO
|
||||
*/
|
||||
public class CouponCodeTemplatePageDTO {
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 优惠类型
|
||||
*/
|
||||
private Integer preferentialType;
|
||||
|
||||
}
|
|
@ -3,7 +3,7 @@ package cn.iocoder.mall.promotion.api.dto;
|
|||
/**
|
||||
* 优惠劵模板分页 DTO
|
||||
*/
|
||||
public class CouponCardTemplatePageDTO {
|
||||
public class CouponTemplatePageDTO {
|
||||
|
||||
/**
|
||||
* 标题
|
|
@ -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<CouponTemplateBO> convertToBO(List<CouponTemplateDO> bannerList);
|
||||
|
||||
@Mappings({})
|
||||
CouponTemplateDO convert(CouponCodeTemplateAddDTO template);
|
||||
|
||||
@Mappings({})
|
||||
CouponTemplateDO convert(CouponCardTemplateAddDTO template);
|
||||
|
||||
@Mappings({})
|
||||
CouponTemplateBO convert(CouponTemplateDO template);
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<CouponTemplatePageBO> getCouponTemplatePage(CouponTemplatePageDTO couponTemplatePageDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<CouponTemplateBO> addCouponCodeTemplate(CouponCodeTemplateAddDTO couponCodeTemplateAddDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<CouponTemplateBO> addCouponCardTemplate(CouponCardTemplateAddDTO couponCardTemplateAddDTO) {
|
||||
// 校验生效日期相关
|
||||
CommonResult<Boolean> checkCouponCodeTemplateDateTypeResult = this.checkCouponTemplateDateType(
|
||||
couponCardTemplateAddDTO.getDateType(),
|
||||
couponCardTemplateAddDTO.getValidStartTime(), couponCardTemplateAddDTO.getValidEndTime(),
|
||||
couponCardTemplateAddDTO.getFixedBeginTerm(), couponCardTemplateAddDTO.getFixedEndTerm());
|
||||
if (checkCouponCodeTemplateDateTypeResult.isError()) {
|
||||
return CommonResult.error(checkCouponCodeTemplateDateTypeResult);
|
||||
}
|
||||
// 校验优惠类型
|
||||
CommonResult<Boolean> 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<Boolean> updateCouponCodeTemplate(CouponCodeTemplateUpdateDTO couponCodeTemplateUpdateDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> updateCouponCardTemplate(CouponCardTemplateUpdateDTO couponCardTemplateUpdateDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> updateCouponTemplateStatus(Integer adminId, Integer couponTemplateId, Integer status) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<CouponCardBO> addCouponCard(Integer userId, Integer couponTemplateId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> useCouponCard(Integer userId, Integer couponCardId, Integer usedOrderId, Integer usedPrice) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> cancelUseCouponCard(Integer userId, Integer couponCardId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<CouponCardBO> useCouponCode(Integer userId, String code) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private CommonResult<Boolean> 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<Boolean> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -72,15 +72,15 @@
|
|||
<insert id="insert" parameterType="CouponTemplateDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||
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}
|
||||
)
|
||||
</insert>
|
||||
|
@ -104,37 +104,37 @@
|
|||
stock = #{stock},
|
||||
</if>
|
||||
<if test="priceAvailable != null">
|
||||
price_available = #{priceAvailable}
|
||||
price_available = #{priceAvailable},
|
||||
</if>
|
||||
<if test="rangeType != null">
|
||||
range_type = #{rangeType}
|
||||
range_type = #{rangeType},
|
||||
</if>
|
||||
<if test="rangeValues != null">
|
||||
range_values = #{rangeValues}
|
||||
range_values = #{rangeValues},
|
||||
</if>
|
||||
<if test="dateType != null">
|
||||
date_type = #{dateType}
|
||||
date_type = #{dateType},
|
||||
</if>
|
||||
<if test="validStartTime != null">
|
||||
valid_start_time = #{validStartTime}
|
||||
valid_start_time = #{validStartTime},
|
||||
</if>
|
||||
<if test="validEndTime != null">
|
||||
valid_end_time = #{validEndTime}
|
||||
valid_end_time = #{validEndTime},
|
||||
</if>
|
||||
<if test="fixedTerm != null">
|
||||
fixed_term = #{fixedTerm}
|
||||
fixed_term = #{fixedTerm},
|
||||
</if>
|
||||
<if test="preferentialType != null">
|
||||
preferential_type = #{preferentialType}
|
||||
preferential_type = #{preferentialType},
|
||||
</if>
|
||||
<if test="percentOff != null">
|
||||
percent_off = #{percentOff}
|
||||
percent_off = #{percentOff},
|
||||
</if>
|
||||
<if test="priceOff != null">
|
||||
price_off = #{priceOff}
|
||||
price_off = #{priceOff},
|
||||
</if>
|
||||
<if test="discountPriceLimit != null">
|
||||
discount_price_limit = #{discountPriceLimit}
|
||||
discount_price_limit = #{discountPriceLimit},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
|
|
Loading…
Reference in New Issue