diff --git a/admin-web/config/proxy/proxy.dev.js b/admin-web/config/proxy/proxy.dev.js index bbe1d0624..9e6a576cf 100644 --- a/admin-web/config/proxy/proxy.dev.js +++ b/admin-web/config/proxy/proxy.dev.js @@ -20,7 +20,8 @@ export default { pathRewrite: {}, }, '/promotion-api/': { - target: 'http://180.167.213.26:18085/', + // target: 'http://180.167.213.26:18085/', + target: 'http://127.0.0.1:18085/', changeOrigin: true, pathRewrite: {}, }, diff --git a/admin-web/src/models/promotion/couponCardTemplateList.js b/admin-web/src/models/promotion/couponCardTemplateList.js index a0687bf51..ba7735a1b 100644 --- a/admin-web/src/models/promotion/couponCardTemplateList.js +++ b/admin-web/src/models/promotion/couponCardTemplateList.js @@ -1,16 +1,14 @@ import {message} from 'antd'; import { - addProductRecommend, - deleteProductRecommend, - queryProductRecommend, - updateProductRecommend, - updateProductRecommendStatus, addCouponCardTemplate, + updateCouponCardTemplate, + updateCouponCardTemplateStatus, + getCouponCardTemplatePage, } from '../../services/promotion'; import PaginationHelper from '../../../helpers/PaginationHelper'; const SEARCH_PARAMS_DEFAULT = { - type: 1, + title: '', }; export default { @@ -40,7 +38,10 @@ export default { }); // 请求 - const response = yield call(queryProductRecommend, payload); + const response = yield call(getCouponCardTemplatePage, { + ...payload, + type: 1 + }); // 响应 yield put({ type: 'setAll', @@ -48,7 +49,7 @@ export default { list: response.data.list, pagination: PaginationHelper.formatPagination(response.data, payload), searchParams: { - type: payload.type + title: payload.title } }, }); @@ -98,7 +99,7 @@ export default { }); // 请求 - const response = yield call(updateProductRecommend, body); + const response = yield call(updateCouponCardTemplate, body); // 响应 if (response.code === 0) { if (callback) { @@ -122,7 +123,7 @@ export default { * updateStatus({ payload }, { call, put }) { // 请求 - const response = yield call(updateProductRecommendStatus, payload); + const response = yield call(updateCouponCardTemplateStatus, payload); // 响应 if (response.code === 0) { message.info('更新状态成功!'); @@ -136,21 +137,21 @@ export default { } }, - * delete({ payload }, { call, put }) { - // 请求 - const response = yield call(deleteProductRecommend, 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 + // }, + // }); + // } + // }, }, diff --git a/admin-web/src/pages/Promotion/CouponCardTemplateList.js b/admin-web/src/pages/Promotion/CouponCardTemplateList.js index fc7461d7e..510c11240 100644 --- a/admin-web/src/pages/Promotion/CouponCardTemplateList.js +++ b/admin-web/src/pages/Promotion/CouponCardTemplateList.js @@ -32,7 +32,14 @@ const SelectOption = Select.Option; const { TreeNode } = Tree; const RangePicker = DatePicker.RangePicker; const status = ['未知', '正常', '禁用']; -const types = ['未知', '新品推荐', '热卖推荐']; +const rangeType = { + 10: '所有可用', + 20: '部分商品可用', + 21: '部分商品不可用', + 30: '部分分类可用', + 31: '部分分类不可用'}; +const preferentialType = ['未知', '代金卷', '折扣卷']; +const dateType = ['未知', '固定日期', '领取日期']; // 列表 function List ({ dataSource, loading, pagination, searchParams, dispatch, @@ -41,10 +48,10 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch, function handleStatus(record) { Modal.confirm({ title: record.status === 1 ? '确认禁用' : '取消禁用', - content: `${record.productSpuId}`, + content: `${record.title}`, onOk() { dispatch({ - type: 'productRecommendList/updateStatus', + type: 'couponCardTemplateList/updateStatus', payload: { id: record.id, status: record.status === 1 ? 2 : 1, @@ -55,48 +62,92 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch, }); } - function handleDelete(record) { - Modal.confirm({ - title: `确认删除?`, - content: `${record.productSpuId}`, - onOk() { - dispatch({ - type: 'productRecommendList/delete', - payload: { - id: record.id, - }, - }); - }, - onCancel() {}, - }); - } + // function handleDelete(record) { + // Modal.confirm({ + // title: `确认删除?`, + // content: `${record.productSpuId}`, + // onOk() { + // dispatch({ + // type: 'couponCardTemplateList/delete', + // payload: { + // id: record.id, + // }, + // }); + // }, + // onCancel() {}, + // }); + // } const columns = [ { - title: '推荐类型', - dataIndex: 'type', + title: '名称', + dataIndex: 'title', + }, + { + title: '类型', + dataIndex: 'preferentialType', render(val) { - return {types[val]}; // TODO 芋艿,此处要改 + return {preferentialType[val]}; }, }, { - title: '商品', - dataIndex: 'productSpuId', + title: '优惠内容', + render(val, record) { + let content; + // priceAvailable; + if (record.priceAvailable === 0) { + content = '无门槛,'; + } else { + content = '满 ' + record.priceAvailable / 100 + ' 元,'; + } + if (record.preferentialType === 1) { + content += '减 ' + record.priceOff / 100 + ' 元'; + } else { + content += '打' + record.percentOff / 100.0 + '折'; + if (record.discountPriceLimit) { + content += ', 最多减 ' + record.discountPriceLimit / 100 + ' 元'; + } + } + return content; + } }, { - title: '排序值', - dataIndex: 'sort', + title: '可使用商品', + dataIndex: 'rangeType', + render: val => {rangeType[val]}, + }, + { + title: '有效期', + render(val, record) { + let content = dateType[record.dateType] + ' '; + // priceAvailable; + if (record.dateType === 1) { + content += moment(new Date(record.validStartTime)).format('YYYY-MM-DD') + + '~' + moment(new Date(record.validEndTime)).format('YYYY-MM-DD'); + } else if (record.dateType === 2) { + content += record.fixedStartTerm + '-' + record.fixedEndTerm + ' 天'; + } + return content; + } + }, + { + title: '已领取/剩余', + // 已使用 TODO 芋艿 + // 支付金额(元) TODO 芋艿 + // 客单价(元) TODO 芋艿 + render(val, record) { + // debugger; + return `${record.statFetchNum} / ` + (record.total - record.statFetchNum); + } }, { title: '状态', dataIndex: 'status', - render(val) { - return {status[val]}; // TODO 芋艿,此处要改 - }, + render: val => {status[val]}, }, { - title: '备注', - dataIndex: 'memo', + title: '使用说明', + dataIndex: 'description', }, { title: '创建时间', @@ -105,7 +156,7 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch, }, { title: '操作', - width: 360, + width: 120, render: (text, record) => { const statusText = record.status === 1 ? '禁用' : '开启'; // TODO 芋艿,此处要改 return ( @@ -115,15 +166,15 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch, handleStatus(record)}> {statusText} - { - record.status === 2 ? - - - handleDelete(record)}> - 删除 - - : null - } + {/*{*/} + {/* record.status === 2 ?*/} + {/* */} + {/* */} + {/* handleDelete(record)}>*/} + {/* 删除*/} + {/* */} + {/* : null*/} + {/*}*/} ); }, @@ -132,7 +183,7 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch, function onPageChange(page) { // 翻页 dispatch({ - type: 'productRecommendList/query', + type: 'couponCardTemplateList/query', payload: { pageNo: page.current, pageSize: page.pageSize, @@ -164,7 +215,7 @@ const SearchForm = Form.create()(props => { function search() { dispatch({ - type: 'productRecommendList/query', + type: 'couponCardTemplateList/query', payload: { ...PaginationHelper.defaultPayload, ...form.getFieldsValue() @@ -252,6 +303,16 @@ const AddOrUpdateForm = Form.create()(props => { body: { id: formVals.id, ...newFileds, + priceAvailable: undefined, + dateType: undefined, + validStartTime: undefined, + validEndTime: undefined, + fixedStartTerm: undefined, + fixedEndTerm: undefined, + preferentialType: undefined, + priceOff: undefined, + percentOff: undefined, + discountPriceLimit: undefined, }, callback: () => { // 清空表单 @@ -331,14 +392,14 @@ const AddOrUpdateForm = Form.create()(props => { {form.getFieldDecorator('priceAvailable', { rules: [{ required: true, message: '请输入使用金额门槛!' },], - initialValue: formVals.priceAvailable, - })()} 元 + initialValue: formVals.priceAvailable / 100.0, + })()} 元 {form.getFieldDecorator('rangeType', { rules: [{ required: true, message: '请选择可用范围!'}, // TODO 芋艿,需要修改 ], - initialValue: formVals.rangeType, + initialValue: formVals.rangeType + '', })( + @@ -379,29 +440,29 @@ const AddOrUpdateForm = Form.create()(props => { {form.getFieldDecorator('validStartTime', { rules: [{ required: true, message: '请输入固定日期!' },], - initialValue: formVals.validStartTime, - })()} + initialValue: formVals.validStartTime ? moment(formVals.validStartTime) : undefined, + })()}  -  {form.getFieldDecorator('validEndTime', { rules: [{ required: true, message: '请输入固定日期!' },], - initialValue: formVals.validEndTime, - })()} + initialValue: formVals.validEndTime ? moment(formVals.validEndTime) : undefined, + })()} : '' } { formVals.dateType == 2 ? - {form.getFieldDecorator('fixedBeginTerm', { + {form.getFieldDecorator('fixedStartTerm', { rules: [{ required: true, message: '请输入固定日期!' }, {min: 1, type: 'number', message: '最小值为 1'}], - initialValue: formVals.fixedBeginTerm, - })()} + initialValue: formVals.fixedStartTerm, + })()}  -  {form.getFieldDecorator('fixedEndTerm', { rules: [{ required: true, message: '请输入固定日期!' }, {min: 1, type: 'number', message: '最小值为 1'}], initialValue: formVals.fixedEndTerm, - })()} 天 + })()} 天 : '' } @@ -409,9 +470,9 @@ const AddOrUpdateForm = Form.create()(props => { {form.getFieldDecorator('preferentialType', { rules: [{ required: true, message: '请选择优惠类型!'}, // TODO 芋艿,需要修改 ], - initialValue: formVals.preferentialType, + initialValue: formVals.preferentialType + '', })( - 代金卷 折扣卷 @@ -423,8 +484,8 @@ const AddOrUpdateForm = Form.create()(props => { {form.getFieldDecorator('priceOff', { rules: [{ required: true, message: '请输入优惠金额!' }, {min: 0.01, type: 'number', message: '最小值为 0.01'}], - initialValue: formVals.priceOff, - })()} + initialValue: formVals.priceOff ? formVals.priceOff / 100.0 : undefined, + })()} : '' } { @@ -436,15 +497,15 @@ const AddOrUpdateForm = Form.create()(props => { {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, - })()}元 + initialValue: formVals.discountPriceLimit ? formVals.discountPriceLimit / 100.0 : undefineds, + })()}元 : '' } @@ -452,10 +513,10 @@ const AddOrUpdateForm = Form.create()(props => { ); }); -@connect(({ productRecommendList }) => ({ +@connect(({ couponCardTemplateList }) => ({ // list: productRecommend.list, // pagination: productRecommend.pagination, - ...productRecommendList, + ...couponCardTemplateList, })) // 主界面 @@ -465,7 +526,7 @@ class CouponCardTemplateLists extends PureComponent { componentDidMount() { const { dispatch } = this.props; dispatch({ - type: 'productRecommendList/query', + type: 'couponCardTemplateList/query', payload: { ...PaginationHelper.defaultPayload }, @@ -475,7 +536,7 @@ class CouponCardTemplateLists extends PureComponent { handleModalVisible = (modalVisible, modalType, record) => { const { dispatch } = this.props; dispatch({ - type: 'productRecommendList/setAll', + type: 'couponCardTemplateList/setAll', payload: { modalVisible, modalType, diff --git a/admin-web/src/services/promotion.js b/admin-web/src/services/promotion.js index c3c9e7994..bfef93ba3 100644 --- a/admin-web/src/services/promotion.js +++ b/admin-web/src/services/promotion.js @@ -67,8 +67,26 @@ export async function deleteProductRecommend(params) { // coupon +export async function getCouponCardTemplatePage(params) { + return request(`/promotion-api/admins/coupon/template/page?${stringify(params)}`, { + method: 'GET', + }); +} + export async function addCouponCardTemplate(params) { return request(`/promotion-api/admins/coupon/template/add_card?${stringify(params)}`, { method: 'POST', }); } + +export async function updateCouponCardTemplate(params) { + return request(`/promotion-api/admins/coupon/template/update_card?${stringify(params)}`, { + method: 'POST', + }); +} + +export async function updateCouponCardTemplateStatus(params) { + return request(`/promotion-api/admins/coupon/template/update_status?${stringify(params)}`, { + method: 'POST', + }); +} diff --git a/order/order-service-impl/target/classes/mapper/OrderRecipientMapper.xml b/order/order-service-impl/target/classes/mapper/OrderRecipientMapper.xml new file mode 100644 index 000000000..b2d9f675b --- /dev/null +++ b/order/order-service-impl/target/classes/mapper/OrderRecipientMapper.xml @@ -0,0 +1,35 @@ + + + + + + id, order_id, `area_no`, `name`, mobile, address, + create_time, update_time + + + + + INSERT INTO `order_recipient` ( + order_id, `area_no`, `name`, mobile, address, + create_time, update_time + ) VALUES ( + #{orderId}, #{areaNo}, #{name}, #{mobile}, #{address}, + #{createTime}, #{updateTime} + ) + + + + + diff --git a/order/order-service-impl/target/generated-sources/annotations/cn/iocoder/mall/order/biz/convert/OrderRecipientConvertImpl.java b/order/order-service-impl/target/generated-sources/annotations/cn/iocoder/mall/order/biz/convert/OrderRecipientConvertImpl.java new file mode 100644 index 000000000..f09bb1316 --- /dev/null +++ b/order/order-service-impl/target/generated-sources/annotations/cn/iocoder/mall/order/biz/convert/OrderRecipientConvertImpl.java @@ -0,0 +1,65 @@ +package cn.iocoder.mall.order.biz.convert; + +import cn.iocoder.mall.order.api.bo.OrderRecipientBO; +import cn.iocoder.mall.order.api.dto.OrderCreateDTO; +import cn.iocoder.mall.order.biz.dataobject.OrderRecipientDO; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Generated; + +@Generated( + value = "org.mapstruct.ap.MappingProcessor", + date = "2019-04-05T22:26:02+0800", + comments = "version: 1.3.0.Final, compiler: javac, environment: Java 11.0.1 (Oracle Corporation)" +) +public class OrderRecipientConvertImpl implements OrderRecipientConvert { + + @Override + public OrderRecipientDO convert(OrderCreateDTO orderCreateDTO) { + if ( orderCreateDTO == null ) { + return null; + } + + OrderRecipientDO orderRecipientDO = new OrderRecipientDO(); + + orderRecipientDO.setAreaNo( orderCreateDTO.getAreaNo() ); + orderRecipientDO.setName( orderCreateDTO.getName() ); + orderRecipientDO.setMobile( orderCreateDTO.getMobile() ); + orderRecipientDO.setAddress( orderCreateDTO.getAddress() ); + + return orderRecipientDO; + } + + @Override + public List convert(List orderRecipientDOList) { + if ( orderRecipientDOList == null ) { + return null; + } + + List list = new ArrayList( orderRecipientDOList.size() ); + for ( OrderRecipientDO orderRecipientDO : orderRecipientDOList ) { + list.add( orderRecipientDOToOrderRecipientBO( orderRecipientDO ) ); + } + + return list; + } + + protected OrderRecipientBO orderRecipientDOToOrderRecipientBO(OrderRecipientDO orderRecipientDO) { + if ( orderRecipientDO == null ) { + return null; + } + + OrderRecipientBO orderRecipientBO = new OrderRecipientBO(); + + orderRecipientBO.setCreateTime( orderRecipientDO.getCreateTime() ); + orderRecipientBO.setUpdateTime( orderRecipientDO.getUpdateTime() ); + orderRecipientBO.setId( orderRecipientDO.getId() ); + orderRecipientBO.setOrderId( orderRecipientDO.getOrderId() ); + orderRecipientBO.setAreaNo( orderRecipientDO.getAreaNo() ); + orderRecipientBO.setName( orderRecipientDO.getName() ); + orderRecipientBO.setMobile( orderRecipientDO.getMobile() ); + orderRecipientBO.setAddress( orderRecipientDO.getAddress() ); + + return orderRecipientBO; + } +} diff --git a/promotion/promotion-application/pom.xml b/promotion/promotion-application/pom.xml index bc8ef85f5..e633ae714 100644 --- a/promotion/promotion-application/pom.xml +++ b/promotion/promotion-application/pom.xml @@ -13,6 +13,7 @@ 1.3.0.Final + 1.16.14 @@ -103,6 +104,17 @@ mapstruct ${org.mapstruct.version} + + org.mapstruct + mapstruct-jdk8 + ${org.mapstruct.version} + + + + org.projectlombok + lombok + ${org.projectlombok.version} + @@ -112,7 +124,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.5.1 + 3.8.0 1.8 1.8 @@ -122,6 +134,11 @@ mapstruct-processor ${org.mapstruct.version} + + org.projectlombok + lombok + ${org.projectlombok.version} + @@ -138,4 +155,4 @@ - \ No newline at end of file + diff --git a/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/admins/AdminsCouponTemplateController.java b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/admins/AdminsCouponTemplateController.java index d7cc19441..ce277c738 100644 --- a/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/admins/AdminsCouponTemplateController.java +++ b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/controller/admins/AdminsCouponTemplateController.java @@ -2,10 +2,15 @@ package cn.iocoder.mall.promotion.application.controller.admins; import cn.iocoder.common.framework.util.DateUtil; import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder; import cn.iocoder.mall.promotion.api.CouponService; import cn.iocoder.mall.promotion.api.bo.CouponTemplateBO; +import cn.iocoder.mall.promotion.api.bo.CouponTemplatePageBO; import cn.iocoder.mall.promotion.api.dto.CouponCardTemplateAddDTO; +import cn.iocoder.mall.promotion.api.dto.CouponCardTemplateUpdateDTO; +import cn.iocoder.mall.promotion.api.dto.CouponTemplatePageDTO; import cn.iocoder.mall.promotion.application.convert.CouponTemplateConvert; +import cn.iocoder.mall.promotion.application.vo.admins.AdminsCouponTemplatePageVO; import cn.iocoder.mall.promotion.application.vo.admins.AdminsCouponTemplateVO; import com.alibaba.dubbo.config.annotation.Reference; import io.swagger.annotations.Api; @@ -13,10 +18,7 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.format.annotation.DateTimeFormat; -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 org.springframework.web.bind.annotation.*; import java.util.Date; @@ -30,6 +32,25 @@ public class AdminsCouponTemplateController { // ========== 优惠劵(码)模板 ========== + @GetMapping("/template/page") + @ApiOperation(value = "优惠劵(码)模板分页") + @ApiImplicitParams({ + @ApiImplicitParam(name = "title", value = "标题,模糊匹配", example = "活动 A"), + @ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"), + @ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, example = "10"), + }) + public CommonResult page(@RequestParam(value = "type", required = false) Integer type, + @RequestParam(value = "title", required = false) String title, + @RequestParam(value = "status", required = false) Integer status, + @RequestParam(value = "preferentialType", required = false) Integer preferentialType, + @RequestParam(value = "pageNo", defaultValue = "0") Integer pageNo, + @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { + CommonResult result = couponService.getCouponTemplatePage(new CouponTemplatePageDTO() + .setType(type).setTitle(title).setStatus(status).setPreferentialType(preferentialType) + .setPageNo(pageNo).setPageSize(pageSize)); + return CouponTemplateConvert.INSTANCE.convert(result); + } + @PostMapping("/template/add_card") @ApiOperation(value = "创建优惠劵模板") @ApiImplicitParams({ @@ -56,7 +77,7 @@ public class AdminsCouponTemplateController { @RequestParam(value = "total", required = false) Integer total, @RequestParam(value = "priceAvailable") Integer priceAvailable, @RequestParam(value = "rangeType") Integer rangeType, - @RequestParam(value = "rangeType", required = false) String rangeValues, + @RequestParam(value = "rangeValues", required = false) String rangeValues, @RequestParam(value = "dateType") Integer dateType, @DateTimeFormat(pattern = "yyyy-MM-dd") @RequestParam(value = "validStartTime", required = false) Date validStartTime, @@ -84,6 +105,44 @@ public class AdminsCouponTemplateController { return CouponTemplateConvert.INSTANCE.convert2(result); } + @PostMapping("/template/update_card") + @ApiOperation(value = "更新优惠劵模板") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1"), + @ApiImplicitParam(name = "title", value = "标题", required = true, example = "优惠劵牛逼"), + @ApiImplicitParam(name = "description", value = "使用说明", example = "我只是描述"), + @ApiImplicitParam(name = "quota", value = "每人限领个数", required = true), + @ApiImplicitParam(name = "total", value = "发行总量"), + @ApiImplicitParam(name = "rangeType", value = "可用范围的类型", required = true, example = "参见 CouponTemplateRangeTypeEnum 枚举"), + @ApiImplicitParam(name = "rangeValues", value = "指定商品 / 分类列表,使用逗号分隔商品编号"), + }) + public CommonResult update(@RequestParam(value = "id") Integer id, + @RequestParam(value = "title") String title, + @RequestParam(value = "description", required = false) String description, + @RequestParam(value = "quota") Integer quota, + @RequestParam(value = "total", required = false) Integer total, + @RequestParam(value = "rangeType") Integer rangeType, + @RequestParam(value = "rangeValues", required = false) String rangeValues) { + // 创建 CouponCardTemplateAddDTO 对象 + CouponCardTemplateUpdateDTO couponCardTemplateUpdateDTO = new CouponCardTemplateUpdateDTO() + .setId(id) + .setTitle(title).setDescription(description) + .setQuota(quota).setTotal(total) + .setRangeType(rangeType).setRangeValues(rangeValues); + return couponService.updateCouponCardTemplate(couponCardTemplateUpdateDTO); + } + + @PostMapping("/template/update_status") + @ApiOperation(value = "更新优惠劵(码)模板状态") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "Banner 编号", required = true, example = "1"), + @ApiImplicitParam(name = "status", value = "状态。1 - 开启;2 - 禁用", required = true, example = "1"), + }) + public CommonResult updateStatus(@RequestParam("id") Integer id, + @RequestParam("status") Integer status) { + return couponService.updateCouponTemplateStatus(AdminSecurityContextHolder.getContext().getAdminId(), id, status); + } + // ========== 优惠劵 ========== // ========== 优惠码 ========== 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 index 8b82e9ae7..17a1c896d 100644 --- 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 @@ -2,26 +2,34 @@ 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.api.bo.CouponTemplatePageBO; +import cn.iocoder.mall.promotion.application.vo.admins.AdminsCouponTemplatePageVO; import cn.iocoder.mall.promotion.application.vo.admins.AdminsCouponTemplateVO; import org.mapstruct.Mapper; import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; +import java.util.List; + @Mapper public interface CouponTemplateConvert { CouponTemplateConvert INSTANCE = Mappers.getMapper(CouponTemplateConvert.class); @Mappings({}) - AdminsCouponTemplateVO convert(CouponTemplateBO bannerBO); + AdminsCouponTemplateVO convert(CouponTemplateBO template); @Mappings({}) CommonResult convert2(CommonResult result); -// @Mappings({}) -// CommonResult convert(CommonResult result); + @Mappings({}) + CommonResult convert(CommonResult result); + + @Mappings({}) + List convertList(List templates); + // // @Mappings({}) -// List convertList(List banners); +// List convertList2(List banners); } diff --git a/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/vo/admins/AdminsBannerVO.java b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/vo/admins/AdminsBannerVO.java index ef2f42e88..d73900c29 100644 --- a/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/vo/admins/AdminsBannerVO.java +++ b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/vo/admins/AdminsBannerVO.java @@ -2,10 +2,14 @@ package cn.iocoder.mall.promotion.application.vo.admins; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; import java.util.Date; @ApiModel("Banner VO") +@Data +@Accessors(chain = true) public class AdminsBannerVO { @ApiModelProperty(value = "Banner 编号", required = true, example = "1") @@ -25,75 +29,4 @@ public class AdminsBannerVO { @ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式") private Date createTime; - public Integer getId() { - return id; - } - - public AdminsBannerVO setId(Integer id) { - this.id = id; - return this; - } - - public String getTitle() { - return title; - } - - public AdminsBannerVO setTitle(String title) { - this.title = title; - return this; - } - - public String getUrl() { - return url; - } - - public AdminsBannerVO setUrl(String url) { - this.url = url; - return this; - } - - public Integer getSort() { - return sort; - } - - public AdminsBannerVO setSort(Integer sort) { - this.sort = sort; - return this; - } - - public Integer getStatus() { - return status; - } - - public AdminsBannerVO setStatus(Integer status) { - this.status = status; - return this; - } - - public String getMemo() { - return memo; - } - - public AdminsBannerVO setMemo(String memo) { - this.memo = memo; - return this; - } - - public Date getCreateTime() { - return createTime; - } - - public AdminsBannerVO setCreateTime(Date createTime) { - this.createTime = createTime; - return this; - } - - public String getPicUrl() { - return picUrl; - } - - public AdminsBannerVO setPicUrl(String picUrl) { - this.picUrl = picUrl; - return this; - } -} \ No newline at end of file +} diff --git a/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/vo/admins/AdminsCouponTemplatePageVO.java b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/vo/admins/AdminsCouponTemplatePageVO.java new file mode 100644 index 000000000..4d6568b78 --- /dev/null +++ b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/vo/admins/AdminsCouponTemplatePageVO.java @@ -0,0 +1,34 @@ +package cn.iocoder.mall.promotion.application.vo.admins; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; + +@ApiModel("优惠劵(码)分页 VO") +public class AdminsCouponTemplatePageVO { + + @ApiModelProperty(value = "优惠劵(码)数组") + private List list; + @ApiModelProperty(value = "优惠劵(码)总数") + private Integer total; + + public List getList() { + return list; + } + + public AdminsCouponTemplatePageVO setList(List list) { + this.list = list; + return this; + } + + public Integer getTotal() { + return total; + } + + public AdminsCouponTemplatePageVO setTotal(Integer total) { + this.total = total; + return this; + } + +} 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 index efaecd6c1..34e98d5cc 100644 --- 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 @@ -49,7 +49,7 @@ public class AdminsCouponTemplateVO { @ApiModelProperty(value = "固定日期-生效结束时间") private Date validEndTime; @ApiModelProperty(value = "领取日期-开始天数", example = "例如,0-当天;1-次天") - private Integer fixedBeginTerm; + private Integer fixedStartTerm; @ApiModelProperty(value = "领取日期-结束天数") private Integer fixedEndTerm; // ========== 使用规则 END ========== @@ -190,12 +190,12 @@ public class AdminsCouponTemplateVO { return this; } - public Integer getFixedBeginTerm() { - return fixedBeginTerm; + public Integer getFixedStartTerm() { + return fixedStartTerm; } - public AdminsCouponTemplateVO setFixedBeginTerm(Integer fixedBeginTerm) { - this.fixedBeginTerm = fixedBeginTerm; + public AdminsCouponTemplateVO setFixedStartTerm(Integer fixedStartTerm) { + this.fixedStartTerm = fixedStartTerm; return this; } @@ -261,4 +261,13 @@ public class AdminsCouponTemplateVO { this.createTime = createTime; return this; } + + public Integer getTotal() { + return total; + } + + public AdminsCouponTemplateVO setTotal(Integer total) { + this.total = total; + return this; + } } diff --git a/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/vo/users/UsersBannerVO.java b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/vo/users/UsersBannerVO.java index 5bf0e0627..a056b79de 100644 --- a/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/vo/users/UsersBannerVO.java +++ b/promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/vo/users/UsersBannerVO.java @@ -2,8 +2,12 @@ package cn.iocoder.mall.promotion.application.vo.users; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; @ApiModel("Banner VO") +@Data +@Accessors(chain = true) public class UsersBannerVO { @ApiModelProperty(value = "跳转链接", required = true, example = "http://www.baidu.com") @@ -11,22 +15,4 @@ public class UsersBannerVO { @ApiModelProperty(value = "图片链接", required = true, example = "http://www.iocoder.cn/01.jpg") private String picUrl; - public String getUrl() { - return url; - } - - public UsersBannerVO setUrl(String url) { - this.url = url; - return this; - } - - public String getPicUrl() { - return picUrl; - } - - public UsersBannerVO setPicUrl(String picUrl) { - this.picUrl = picUrl; - return this; - } - -} \ No newline at end of file +} diff --git a/promotion/promotion-application/target/generated-sources/annotations/cn/iocoder/mall/promotion/application/convert/BannerConvertImpl.java b/promotion/promotion-application/target/generated-sources/annotations/cn/iocoder/mall/promotion/application/convert/BannerConvertImpl.java new file mode 100644 index 000000000..35482450a --- /dev/null +++ b/promotion/promotion-application/target/generated-sources/annotations/cn/iocoder/mall/promotion/application/convert/BannerConvertImpl.java @@ -0,0 +1,122 @@ +package cn.iocoder.mall.promotion.application.convert; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.promotion.api.bo.BannerBO; +import cn.iocoder.mall.promotion.api.bo.BannerPageBO; +import cn.iocoder.mall.promotion.application.vo.admins.AdminsBannerPageVO; +import cn.iocoder.mall.promotion.application.vo.admins.AdminsBannerVO; +import cn.iocoder.mall.promotion.application.vo.users.UsersBannerVO; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Generated; + +@Generated( + value = "org.mapstruct.ap.MappingProcessor", + date = "2019-04-06T01:40:13+0800", + comments = "version: 1.3.0.Final, compiler: javac, environment: Java 1.8.0_121 (Oracle Corporation)" +) +public class BannerConvertImpl implements BannerConvert { + + @Override + public AdminsBannerVO convert(BannerBO bannerBO) { + if ( bannerBO == null ) { + return null; + } + + AdminsBannerVO adminsBannerVO = new AdminsBannerVO(); + + adminsBannerVO.setId( bannerBO.getId() ); + adminsBannerVO.setTitle( bannerBO.getTitle() ); + adminsBannerVO.setUrl( bannerBO.getUrl() ); + adminsBannerVO.setPicUrl( bannerBO.getPicUrl() ); + adminsBannerVO.setSort( bannerBO.getSort() ); + adminsBannerVO.setStatus( bannerBO.getStatus() ); + adminsBannerVO.setMemo( bannerBO.getMemo() ); + adminsBannerVO.setCreateTime( bannerBO.getCreateTime() ); + + return adminsBannerVO; + } + + @Override + public CommonResult convert2(CommonResult result) { + if ( result == null ) { + return null; + } + + CommonResult commonResult = new CommonResult(); + + commonResult.setCode( result.getCode() ); + commonResult.setMessage( result.getMessage() ); + commonResult.setData( convert( result.getData() ) ); + + return commonResult; + } + + @Override + public CommonResult convert(CommonResult result) { + if ( result == null ) { + return null; + } + + CommonResult commonResult = new CommonResult(); + + commonResult.setCode( result.getCode() ); + commonResult.setMessage( result.getMessage() ); + commonResult.setData( bannerPageBOToAdminsBannerPageVO( result.getData() ) ); + + return commonResult; + } + + @Override + public List convertList(List banners) { + if ( banners == null ) { + return null; + } + + List list = new ArrayList( banners.size() ); + for ( BannerBO bannerBO : banners ) { + list.add( bannerBOToUsersBannerVO( bannerBO ) ); + } + + return list; + } + + protected List bannerBOListToAdminsBannerVOList(List list) { + if ( list == null ) { + return null; + } + + List list1 = new ArrayList( list.size() ); + for ( BannerBO bannerBO : list ) { + list1.add( convert( bannerBO ) ); + } + + return list1; + } + + protected AdminsBannerPageVO bannerPageBOToAdminsBannerPageVO(BannerPageBO bannerPageBO) { + if ( bannerPageBO == null ) { + return null; + } + + AdminsBannerPageVO adminsBannerPageVO = new AdminsBannerPageVO(); + + adminsBannerPageVO.setList( bannerBOListToAdminsBannerVOList( bannerPageBO.getList() ) ); + adminsBannerPageVO.setTotal( bannerPageBO.getTotal() ); + + return adminsBannerPageVO; + } + + protected UsersBannerVO bannerBOToUsersBannerVO(BannerBO bannerBO) { + if ( bannerBO == null ) { + return null; + } + + UsersBannerVO usersBannerVO = new UsersBannerVO(); + + usersBannerVO.setUrl( bannerBO.getUrl() ); + usersBannerVO.setPicUrl( bannerBO.getPicUrl() ); + + return usersBannerVO; + } +} diff --git a/promotion/promotion-application/target/generated-sources/annotations/cn/iocoder/mall/promotion/application/convert/CouponTemplateConvertImpl.java b/promotion/promotion-application/target/generated-sources/annotations/cn/iocoder/mall/promotion/application/convert/CouponTemplateConvertImpl.java new file mode 100644 index 000000000..3a6ead592 --- /dev/null +++ b/promotion/promotion-application/target/generated-sources/annotations/cn/iocoder/mall/promotion/application/convert/CouponTemplateConvertImpl.java @@ -0,0 +1,109 @@ +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.api.bo.CouponTemplatePageBO; +import cn.iocoder.mall.promotion.application.vo.admins.AdminsCouponTemplatePageVO; +import cn.iocoder.mall.promotion.application.vo.admins.AdminsCouponTemplateVO; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Generated; + +@Generated( + value = "org.mapstruct.ap.MappingProcessor", + date = "2019-04-06T01:40:13+0800", + comments = "version: 1.3.0.Final, compiler: javac, environment: Java 1.8.0_121 (Oracle Corporation)" +) +public class CouponTemplateConvertImpl implements CouponTemplateConvert { + + @Override + public AdminsCouponTemplateVO convert(CouponTemplateBO template) { + if ( template == null ) { + return null; + } + + AdminsCouponTemplateVO adminsCouponTemplateVO = new AdminsCouponTemplateVO(); + + adminsCouponTemplateVO.setId( template.getId() ); + adminsCouponTemplateVO.setTitle( template.getTitle() ); + adminsCouponTemplateVO.setDescription( template.getDescription() ); + adminsCouponTemplateVO.setType( template.getType() ); + adminsCouponTemplateVO.setCodeType( template.getCodeType() ); + adminsCouponTemplateVO.setStatus( template.getStatus() ); + adminsCouponTemplateVO.setQuota( template.getQuota() ); + adminsCouponTemplateVO.setPriceAvailable( template.getPriceAvailable() ); + adminsCouponTemplateVO.setRangeType( template.getRangeType() ); + adminsCouponTemplateVO.setRangeValues( template.getRangeValues() ); + adminsCouponTemplateVO.setDateType( template.getDateType() ); + adminsCouponTemplateVO.setValidStartTime( template.getValidStartTime() ); + adminsCouponTemplateVO.setValidEndTime( template.getValidEndTime() ); + adminsCouponTemplateVO.setFixedStartTerm( template.getFixedStartTerm() ); + adminsCouponTemplateVO.setFixedEndTerm( template.getFixedEndTerm() ); + adminsCouponTemplateVO.setPreferentialType( template.getPreferentialType() ); + adminsCouponTemplateVO.setPercentOff( template.getPercentOff() ); + adminsCouponTemplateVO.setPriceOff( template.getPriceOff() ); + adminsCouponTemplateVO.setDiscountPriceLimit( template.getDiscountPriceLimit() ); + adminsCouponTemplateVO.setStatFetchNum( template.getStatFetchNum() ); + adminsCouponTemplateVO.setCreateTime( template.getCreateTime() ); + adminsCouponTemplateVO.setTotal( template.getTotal() ); + + return adminsCouponTemplateVO; + } + + @Override + public CommonResult convert2(CommonResult result) { + if ( result == null ) { + return null; + } + + CommonResult commonResult = new CommonResult(); + + commonResult.setCode( result.getCode() ); + commonResult.setMessage( result.getMessage() ); + commonResult.setData( convert( result.getData() ) ); + + return commonResult; + } + + @Override + public CommonResult convert(CommonResult result) { + if ( result == null ) { + return null; + } + + CommonResult commonResult = new CommonResult(); + + commonResult.setCode( result.getCode() ); + commonResult.setMessage( result.getMessage() ); + commonResult.setData( couponTemplatePageBOToAdminsCouponTemplatePageVO( result.getData() ) ); + + return commonResult; + } + + @Override + public List convertList(List templates) { + if ( templates == null ) { + return null; + } + + List list = new ArrayList( templates.size() ); + for ( CouponTemplateBO couponTemplateBO : templates ) { + list.add( convert( couponTemplateBO ) ); + } + + return list; + } + + protected AdminsCouponTemplatePageVO couponTemplatePageBOToAdminsCouponTemplatePageVO(CouponTemplatePageBO couponTemplatePageBO) { + if ( couponTemplatePageBO == null ) { + return null; + } + + AdminsCouponTemplatePageVO adminsCouponTemplatePageVO = new AdminsCouponTemplatePageVO(); + + adminsCouponTemplatePageVO.setList( convertList( couponTemplatePageBO.getList() ) ); + adminsCouponTemplatePageVO.setTotal( couponTemplatePageBO.getTotal() ); + + return adminsCouponTemplatePageVO; + } +} diff --git a/promotion/promotion-application/target/generated-sources/annotations/cn/iocoder/mall/promotion/application/convert/ProductRecommendConvertImpl.java b/promotion/promotion-application/target/generated-sources/annotations/cn/iocoder/mall/promotion/application/convert/ProductRecommendConvertImpl.java new file mode 100644 index 000000000..de469091f --- /dev/null +++ b/promotion/promotion-application/target/generated-sources/annotations/cn/iocoder/mall/promotion/application/convert/ProductRecommendConvertImpl.java @@ -0,0 +1,115 @@ +package cn.iocoder.mall.promotion.application.convert; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.product.api.bo.ProductSpuBO; +import cn.iocoder.mall.promotion.api.bo.ProductRecommendBO; +import cn.iocoder.mall.promotion.api.bo.ProductRecommendPageBO; +import cn.iocoder.mall.promotion.application.vo.admins.AdminsProductRecommendPageVO; +import cn.iocoder.mall.promotion.application.vo.admins.AdminsProductRecommendVO; +import cn.iocoder.mall.promotion.application.vo.users.UsersProductRecommendVO; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Generated; + +@Generated( + value = "org.mapstruct.ap.MappingProcessor", + date = "2019-04-06T01:40:13+0800", + comments = "version: 1.3.0.Final, compiler: javac, environment: Java 1.8.0_121 (Oracle Corporation)" +) +public class ProductRecommendConvertImpl implements ProductRecommendConvert { + + @Override + public AdminsProductRecommendVO convert(ProductRecommendBO bannerBO) { + if ( bannerBO == null ) { + return null; + } + + AdminsProductRecommendVO adminsProductRecommendVO = new AdminsProductRecommendVO(); + + adminsProductRecommendVO.setId( bannerBO.getId() ); + adminsProductRecommendVO.setType( bannerBO.getType() ); + adminsProductRecommendVO.setProductSpuId( bannerBO.getProductSpuId() ); + adminsProductRecommendVO.setSort( bannerBO.getSort() ); + adminsProductRecommendVO.setStatus( bannerBO.getStatus() ); + adminsProductRecommendVO.setMemo( bannerBO.getMemo() ); + adminsProductRecommendVO.setCreateTime( bannerBO.getCreateTime() ); + + return adminsProductRecommendVO; + } + + @Override + public CommonResult convert2(CommonResult result) { + if ( result == null ) { + return null; + } + + CommonResult commonResult = new CommonResult(); + + commonResult.setCode( result.getCode() ); + commonResult.setMessage( result.getMessage() ); + commonResult.setData( convert( result.getData() ) ); + + return commonResult; + } + + @Override + public CommonResult convert(CommonResult result) { + if ( result == null ) { + return null; + } + + CommonResult commonResult = new CommonResult(); + + commonResult.setCode( result.getCode() ); + commonResult.setMessage( result.getMessage() ); + commonResult.setData( productRecommendPageBOToAdminsProductRecommendPageVO( result.getData() ) ); + + return commonResult; + } + + @Override + public UsersProductRecommendVO convert(ProductSpuBO productSpu) { + if ( productSpu == null ) { + return null; + } + + UsersProductRecommendVO usersProductRecommendVO = new UsersProductRecommendVO(); + + usersProductRecommendVO.setId( productSpu.getId() ); + usersProductRecommendVO.setName( productSpu.getName() ); + usersProductRecommendVO.setSellPoint( productSpu.getSellPoint() ); + List list = productSpu.getPicUrls(); + if ( list != null ) { + usersProductRecommendVO.setPicUrls( new ArrayList( list ) ); + } + usersProductRecommendVO.setPrice( productSpu.getPrice() ); + + return usersProductRecommendVO; + } + + protected List productRecommendBOListToAdminsProductRecommendVOList(List list) { + if ( list == null ) { + return null; + } + + List list1 = new ArrayList( list.size() ); + for ( ProductRecommendBO productRecommendBO : list ) { + list1.add( convert( productRecommendBO ) ); + } + + return list1; + } + + protected AdminsProductRecommendPageVO productRecommendPageBOToAdminsProductRecommendPageVO(ProductRecommendPageBO productRecommendPageBO) { + if ( productRecommendPageBO == null ) { + return null; + } + + AdminsProductRecommendPageVO adminsProductRecommendPageVO = new AdminsProductRecommendPageVO(); + + adminsProductRecommendPageVO.setList( productRecommendBOListToAdminsProductRecommendVOList( productRecommendPageBO.getList() ) ); + adminsProductRecommendPageVO.setTotal( productRecommendPageBO.getTotal() ); + + return adminsProductRecommendPageVO; + } +} diff --git a/promotion/promotion-service-api/pom.xml b/promotion/promotion-service-api/pom.xml index d2b1af042..c49c39763 100644 --- a/promotion/promotion-service-api/pom.xml +++ b/promotion/promotion-service-api/pom.xml @@ -11,6 +11,11 @@ promotion-service-api + + 1.3.0.Final + 1.16.14 + + javax.validation @@ -22,6 +27,51 @@ 1.0-SNAPSHOT compile + + + org.mapstruct + mapstruct + ${org.mapstruct.version} + + + org.mapstruct + mapstruct-jdk8 + ${org.mapstruct.version} + + + + org.projectlombok + lombok + ${org.projectlombok.version} + - \ No newline at end of file + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + 1.8 + 1.8 + + + org.mapstruct + mapstruct-processor + ${org.mapstruct.version} + + + org.projectlombok + lombok + ${org.projectlombok.version} + + + + + + + + + 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 977ef9663..01f22c3bd 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 @@ -1,9 +1,11 @@ package cn.iocoder.mall.promotion.api; +import cn.iocoder.common.framework.validator.InEnum; import cn.iocoder.common.framework.vo.CommonResult; 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.CouponTemplateStatusEnum; import cn.iocoder.mall.promotion.api.dto.*; public interface CouponService { @@ -52,7 +54,8 @@ public interface CouponService { * @param status 状态 * @return 是否成功 */ - CommonResult updateCouponTemplateStatus(Integer adminId, Integer couponTemplateId, Integer status); + CommonResult updateCouponTemplateStatus(Integer adminId, Integer couponTemplateId, + @InEnum(value = CouponTemplateStatusEnum.class, message = "修改状态必须是 {value}") Integer status); // ========== 优惠劵 ========== diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/BannerBO.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/BannerBO.java index db6b385b1..da7d360f6 100644 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/BannerBO.java +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/BannerBO.java @@ -1,10 +1,15 @@ package cn.iocoder.mall.promotion.api.bo; +import lombok.Data; +import lombok.experimental.Accessors; + import java.util.Date; /** * Banner BO */ +@Data +@Accessors(chain = true) public class BannerBO { /** @@ -40,75 +45,4 @@ public class BannerBO { */ private Date createTime; - public Integer getId() { - return id; - } - - public BannerBO setId(Integer id) { - this.id = id; - return this; - } - - public String getTitle() { - return title; - } - - public BannerBO setTitle(String title) { - this.title = title; - return this; - } - - public String getUrl() { - return url; - } - - public BannerBO setUrl(String url) { - this.url = url; - return this; - } - - public Integer getSort() { - return sort; - } - - public BannerBO setSort(Integer sort) { - this.sort = sort; - return this; - } - - public Integer getStatus() { - return status; - } - - public BannerBO setStatus(Integer status) { - this.status = status; - return this; - } - - public String getMemo() { - return memo; - } - - public BannerBO setMemo(String memo) { - this.memo = memo; - return this; - } - - public Date getCreateTime() { - return createTime; - } - - public BannerBO setCreateTime(Date createTime) { - this.createTime = createTime; - return this; - } - - public String getPicUrl() { - return picUrl; - } - - public BannerBO setPicUrl(String picUrl) { - this.picUrl = picUrl; - return this; - } -} \ No newline at end of file +} 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 index 0b7ae7f31..9aa54d853 100644 --- 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 @@ -81,7 +81,7 @@ public class CouponTemplateBO { * 生效日期类型 * * 1-固定日期 - * 2-领取日期:领到券 {@link #fixedBeginTerm} 日开始 N 天内有效 + * 2-领取日期:领到券 {@link #fixedStartTerm} 日开始 N 天内有效 */ private Integer dateType; /** @@ -97,7 +97,7 @@ public class CouponTemplateBO { * * 例如,0-当天;1-次天 */ - private Integer fixedBeginTerm; + private Integer fixedStartTerm; /** * 领取日期-结束天数 */ @@ -323,12 +323,12 @@ public class CouponTemplateBO { return this; } - public Integer getFixedBeginTerm() { - return fixedBeginTerm; + public Integer getFixedStartTerm() { + return fixedStartTerm; } - public CouponTemplateBO setFixedBeginTerm(Integer fixedBeginTerm) { - this.fixedBeginTerm = fixedBeginTerm; + public CouponTemplateBO setFixedStartTerm(Integer fixedStartTerm) { + this.fixedStartTerm = fixedStartTerm; return this; } diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponTemplatePageBO.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponTemplatePageBO.java index 47de4338a..454d9cea2 100644 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponTemplatePageBO.java +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/CouponTemplatePageBO.java @@ -1,5 +1,33 @@ package cn.iocoder.mall.promotion.api.bo; +import java.util.List; + public class CouponTemplatePageBO { + /** + * 优惠劵(码)数组 + */ + private List list; + /** + * 总量 + */ + private Integer total; + + public CouponTemplatePageBO setList(List list) { + this.list = list; + return this; + } + + public CouponTemplatePageBO setTotal(Integer total) { + this.total = total; + return this; + } + + public List getList() { + return list; + } + + public Integer getTotal() { + return total; + } } 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 index 8714f2f92..af1b88377 100644 --- 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 @@ -1,12 +1,14 @@ package cn.iocoder.mall.promotion.api.constant; +import cn.iocoder.common.framework.core.IntArrayValuable; + import java.util.Arrays; -public enum CouponTemplateStatusEnum { +public enum CouponTemplateStatusEnum implements IntArrayValuable { ENABLE(1, "开启中"), DISABLE(2, "禁用中"), - EXPIRE(3, "已过期"), +// EXPIRE(3, "已过期"), TODO 芋艿,暂时不考虑过期的 ; public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplateStatusEnum::getValue).toArray(); @@ -33,4 +35,8 @@ public enum CouponTemplateStatusEnum { return name; } + @Override + public int[] array() { + return ARRAYS; + } } diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/PromotionErrorCodeEnum.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/PromotionErrorCodeEnum.java index 24d19f848..aa40e719e 100644 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/PromotionErrorCodeEnum.java +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/PromotionErrorCodeEnum.java @@ -15,8 +15,14 @@ public enum PromotionErrorCodeEnum { PRODUCT_RECOMMEND_PRODUCT_NOT_EXISTS(1006001001, "商品不存在"), PRODUCT_RECOMMEND_EXISTS(1006001002, "该商品推荐已经存在"), - ; + // ========== COUPON TEMPLATE 模块 ========== + PRODUCT_TEMPLATE_NOT_EXISTS(1006002000, "优惠劵模板(码)不存在"), + PRODUCT_TEMPLATE_NOT_CARD(1006002001, "不是优惠劵模板"), + PRODUCT_TEMPLATE_NOT_CODE(1006002002, "不是优惠码模板"), + PRODUCT_TEMPLATE_TOTAL_CAN_NOT_REDUCE(1006002003, "优惠劵(码)模板的发放数量不能减小"), + + ; private final int code; private final String message; @@ -34,4 +40,4 @@ public enum PromotionErrorCodeEnum { return message; } -} \ 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 3c52e6faa..3414ab30b 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 @@ -277,5 +277,4 @@ public class CouponCardTemplateAddDTO { return this; } - } diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardTemplateUpdateDTO.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardTemplateUpdateDTO.java index e64efa7a3..948ad671d 100644 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardTemplateUpdateDTO.java +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardTemplateUpdateDTO.java @@ -1,4 +1,196 @@ package cn.iocoder.mall.promotion.api.dto; +import cn.iocoder.common.framework.validator.InEnum; +import cn.iocoder.mall.promotion.api.constant.CouponTemplateRangeTypeEnum; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + public class CouponCardTemplateUpdateDTO { + + @NotNull(message = "编号不能为空") + private Integer id; + + // ========== 基本信息 BEGIN ========== + /** + * 标题 + */ + @NotEmpty(message = "标题不能为空") + @Length(min = 2, max = 16, message = "标题长度为 {min}-{max} 位") + private String title; + /** + * 使用说明 + */ + @Length(max = 255, message = "使用说明最大长度为 {max} 位") + private String description; + // ========== 基本信息 END ========== + + // ========== 领取规则 BEGIN ========== + /** + * 每人限领个数 + */ + @NotNull(message = "每人限领个数不能为空") + @Min(value = 1, message = "每人限领个数最小为 {value}") + private Integer quota; + /** + * 发放总量 + */ + @NotNull(message = "发放总量不能为空") + @Min(value = 1, message = "每人限领个数最小为 {value}") + private Integer total; + // ========== 领取规则 END ========== + + // ========== 使用规则 BEGIN ========== +// /** +// * 是否设置满多少金额可用,单位:分 +// * +// * 0-不限制 +// * 大于0-多少金额可用 +// */ +// @NotNull(message = "使用金额门槛不能为空") +// @Min(value = 0L, message = "使用金额门槛最低为 {value}") +// private Integer priceAvailable; + /** + * 可用范围的类型 + * + * 10-全部(ALL):所有可用 + * 20-部分(PART):部分商品可用,或指定商品可用 + * 21-部分(PART):部分商品不可用,或指定商品可用 + * 30-部分(PART):部分分类可用,或指定分类可用 + * 31-部分(PART):部分分类不可用,或指定分类可用 + */ + @NotNull(message = "可用范围的类型不能为空") + @InEnum(value = CouponTemplateRangeTypeEnum.class, message = "可用范围的类型必须在 {value}") + private Integer rangeType; + /** + * 指定商品 / 分类列表,使用逗号分隔商品编号 + */ + private String rangeValues; +// /** +// * 生效日期类型 +// * +// * 1-固定日期 +// * 2-领取日期:领到券 {@link #fixedEndTerm} 日开始 N 天内有效 +// */ +// @NotNull(message = "生效日期类型不能为空") +// @InEnum(value = CouponTemplateDateTypeEnum.class, message = "生效日期类型必须在 {value}") +// private Integer dateType; +// /** +// * 固定日期-生效开始时间 +// */ +// private Date validStartTime; +// /** +// * 固定日期-生效结束时间 +// */ +// private Date validEndTime; +// /** +// * 领取日期-开始天数 +// * +// * 例如,0-当天;1-次天 +// */ +// @Min(value = 0L, message = "领取日期开始时间最小为 {value}") +// private Integer fixedBeginTerm; +// /** +// * 领取日期-结束天数 +// */ +// @Min(value = 1L, message = "领取日期结束时间最小为 {value}") +// private Integer fixedEndTerm; + // ========== 使用规则 END ========== + + // ========== 使用效果 BEGIN ========== +// /** +// * 优惠类型 +// * +// * 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; +// /** +// * 折扣上限,仅在 {@link #preferentialType} 等于 2 时生效。 +// * +// * 例如,折扣上限为 20 元,当使用 8 折优惠券,订单金额为 1000 元时,最高只可折扣 20 元,而非 80 元。 +// */ +// @Min(value = 1, message = "折扣上限最小值为 {value}") +// private Integer discountPriceLimit; + // ========== 使用效果 END ========== + + public Integer getId() { + return id; + } + + public CouponCardTemplateUpdateDTO setId(Integer id) { + this.id = id; + return this; + } + + public String getTitle() { + return title; + } + + public CouponCardTemplateUpdateDTO setTitle(String title) { + this.title = title; + return this; + } + + public String getDescription() { + return description; + } + + public CouponCardTemplateUpdateDTO setDescription(String description) { + this.description = description; + return this; + } + + public Integer getQuota() { + return quota; + } + + public CouponCardTemplateUpdateDTO setQuota(Integer quota) { + this.quota = quota; + return this; + } + + public Integer getTotal() { + return total; + } + + public CouponCardTemplateUpdateDTO setTotal(Integer total) { + this.total = total; + return this; + } + + public Integer getRangeType() { + return rangeType; + } + + public CouponCardTemplateUpdateDTO setRangeType(Integer rangeType) { + this.rangeType = rangeType; + return this; + } + + public String getRangeValues() { + return rangeValues; + } + + public CouponCardTemplateUpdateDTO setRangeValues(String rangeValues) { + this.rangeValues = rangeValues; + return this; + } } diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponTemplatePageDTO.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponTemplatePageDTO.java index 39574ad21..d283eed37 100644 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponTemplatePageDTO.java +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponTemplatePageDTO.java @@ -1,10 +1,16 @@ package cn.iocoder.mall.promotion.api.dto; +import javax.validation.constraints.NotNull; + /** * 优惠劵模板分页 DTO */ public class CouponTemplatePageDTO { + /** + * 类型 + */ + private Integer type; /** * 标题 */ @@ -18,4 +24,62 @@ public class CouponTemplatePageDTO { */ private Integer preferentialType; + @NotNull(message = "页码不能为空") + private Integer pageNo; + @NotNull(message = "每页条数不能为空") + private Integer pageSize; + + public Integer getType() { + return type; + } + + public CouponTemplatePageDTO setType(Integer type) { + this.type = type; + return this; + } + + public String getTitle() { + return title; + } + + public CouponTemplatePageDTO setTitle(String title) { + this.title = title; + return this; + } + + public Integer getStatus() { + return status; + } + + public CouponTemplatePageDTO setStatus(Integer status) { + this.status = status; + return this; + } + + public Integer getPreferentialType() { + return preferentialType; + } + + public CouponTemplatePageDTO setPreferentialType(Integer preferentialType) { + this.preferentialType = preferentialType; + return this; + } + + public Integer getPageNo() { + return pageNo; + } + + public CouponTemplatePageDTO setPageNo(Integer pageNo) { + this.pageNo = pageNo; + return this; + } + + public Integer getPageSize() { + return pageSize; + } + + public CouponTemplatePageDTO setPageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } } diff --git a/promotion/promotion-service-impl/pom.xml b/promotion/promotion-service-impl/pom.xml index 222fbfc0c..ce002879a 100644 --- a/promotion/promotion-service-impl/pom.xml +++ b/promotion/promotion-service-impl/pom.xml @@ -14,6 +14,7 @@ 1.3.0.Final + 1.16.14 @@ -53,11 +54,23 @@ mybatis-spring-boot-starter 2.0.0 + org.mapstruct - mapstruct + mapstruct ${org.mapstruct.version} + + org.mapstruct + mapstruct-jdk8 + ${org.mapstruct.version} + + + + org.projectlombok + lombok + ${org.projectlombok.version} + com.google.guava @@ -103,7 +116,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.5.1 + 3.8.0 1.8 1.8 @@ -113,6 +126,11 @@ mapstruct-processor ${org.mapstruct.version} + + org.projectlombok + lombok + ${org.projectlombok.version} + 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 index 1bc2d2699..3c24e0112 100644 --- 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 @@ -2,12 +2,16 @@ 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.CouponCardTemplateUpdateDTO; import cn.iocoder.mall.promotion.api.dto.CouponCodeTemplateAddDTO; +import cn.iocoder.mall.promotion.api.dto.CouponCodeTemplateUpdateDTO; import cn.iocoder.mall.promotion.biz.dataobject.CouponTemplateDO; import org.mapstruct.Mapper; import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; +import java.util.List; + @Mapper public interface CouponTemplateConvert { @@ -16,15 +20,21 @@ public interface CouponTemplateConvert { // @Mappings({}) // CouponTemplateBO convertToBO(CouponTemplateDO banner); // -// @Mappings({}) -// List convertToBO(List bannerList); + @Mappings({}) + List convertToBO(List templateList); @Mappings({}) - CouponTemplateDO convert(CouponCodeTemplateAddDTO template); + CouponTemplateDO convert(CouponCodeTemplateUpdateDTO template); @Mappings({}) CouponTemplateDO convert(CouponCardTemplateAddDTO template); + @Mappings({}) + CouponTemplateDO convert(CouponCardTemplateUpdateDTO template); + + @Mappings({}) + CouponTemplateDO convert(CouponCodeTemplateAddDTO template); + @Mappings({}) CouponTemplateBO convert(CouponTemplateDO template); diff --git a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dao/CouponTemplateMapper.java b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dao/CouponTemplateMapper.java index 524c75d01..7bf2f1639 100644 --- a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dao/CouponTemplateMapper.java +++ b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dao/CouponTemplateMapper.java @@ -11,13 +11,15 @@ public interface CouponTemplateMapper { CouponTemplateDO selectById(@Param("id") Integer id); - List selectListByPage(@Param("title") String title, + List selectListByPage(@Param("type") Integer type, + @Param("title") String title, @Param("status") Integer status, @Param("preferentialType") Integer preferentialType, @Param("offset") Integer offset, @Param("limit") Integer limit); - Integer selectCountByPage(@Param("title") String title, + Integer selectCountByPage(@Param("type") Integer type, + @Param("title") String title, @Param("status") Integer status, @Param("preferentialType") Integer preferentialType); diff --git a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dataobject/BannerDO.java b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dataobject/BannerDO.java index 60eafd035..9e2cc22b9 100644 --- a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dataobject/BannerDO.java +++ b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dataobject/BannerDO.java @@ -1,10 +1,14 @@ package cn.iocoder.mall.promotion.biz.dataobject; import cn.iocoder.common.framework.dataobject.DeletableDO; +import lombok.Data; +import lombok.experimental.Accessors; /** * Banner 广告页 */ +@Data +@Accessors(chain = true) public class BannerDO extends DeletableDO { /** @@ -40,67 +44,4 @@ public class BannerDO extends DeletableDO { // TODO 芋艿 点击次数。&& 其他数据相关 - public Integer getId() { - return id; - } - - public BannerDO setId(Integer id) { - this.id = id; - return this; - } - - public String getTitle() { - return title; - } - - public BannerDO setTitle(String title) { - this.title = title; - return this; - } - - public String getUrl() { - return url; - } - - public BannerDO setUrl(String url) { - this.url = url; - return this; - } - - public Integer getStatus() { - return status; - } - - public BannerDO setStatus(Integer status) { - this.status = status; - return this; - } - - public String getMemo() { - return memo; - } - - public BannerDO setMemo(String memo) { - this.memo = memo; - return this; - } - - public Integer getSort() { - return sort; - } - - public BannerDO setSort(Integer sort) { - this.sort = sort; - return this; - } - - public String getPicUrl() { - return picUrl; - } - - public BannerDO setPicUrl(String picUrl) { - this.picUrl = picUrl; - return this; - } - -} \ No newline at end of file +} 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 8194b8588..4b2182200 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 @@ -120,7 +120,7 @@ public class CouponTemplateDO extends BaseDO { * 生效日期类型 * * 1-固定日期 - * 2-领取日期:领到券 {@link #fixedTerm} 日开始 N 天内有效 + * 2-领取日期:领到券 {@link #fixedStartTerm} 日开始 N 天内有效 */ private Integer dateType; /** @@ -131,16 +131,16 @@ public class CouponTemplateDO extends BaseDO { * 固定日期-生效结束时间 */ private Date validEndTime; -// /** -// * 领取日期-开始天数 -// * -// * 例如,0-当天;1-次天 -// */ -// private Integer fixedBeginTerm; + /** + * 领取日期-开始天数 + * + * 例如,0-当天;1-次天 + */ + private Integer fixedStartTerm; /** * 领取日期-结束天数 */ - private Integer fixedTerm; + private Integer fixedEndTerm; // /** // * 是否到期前4天发送提醒 // * @@ -335,12 +335,21 @@ public class CouponTemplateDO extends BaseDO { return this; } - public Integer getFixedTerm() { - return fixedTerm; + public Integer getFixedStartTerm() { + return fixedStartTerm; } - public CouponTemplateDO setFixedTerm(Integer fixedTerm) { - this.fixedTerm = fixedTerm; + public CouponTemplateDO setFixedStartTerm(Integer fixedStartTerm) { + this.fixedStartTerm = fixedStartTerm; + return this; + } + + public Integer getFixedEndTerm() { + return fixedEndTerm; + } + + public CouponTemplateDO setFixedEndTerm(Integer fixedEndTerm) { + this.fixedEndTerm = fixedEndTerm; return this; } 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 6b4f8746e..270feaeaf 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,15 +1,13 @@ package cn.iocoder.mall.promotion.biz.service; import cn.iocoder.common.framework.constant.SysErrorCodeEnum; +import cn.iocoder.common.framework.util.ServiceExceptionUtil; 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.constant.*; import cn.iocoder.mall.promotion.api.dto.*; import cn.iocoder.mall.promotion.biz.convert.CouponTemplateConvert; import cn.iocoder.mall.promotion.biz.dao.CouponTemplateMapper; @@ -26,9 +24,22 @@ public class CouponServiceImpl implements CouponService { @Autowired private CouponTemplateMapper couponTemplateMapper; + // ========== 优惠劵(码)模板 ========== + @Override public CommonResult getCouponTemplatePage(CouponTemplatePageDTO couponTemplatePageDTO) { - return null; + CouponTemplatePageBO couponTemplatePageBO = new CouponTemplatePageBO(); + // 查询分页数据 + int offset = (couponTemplatePageDTO.getPageNo() - 1) * couponTemplatePageDTO.getPageSize(); + couponTemplatePageBO.setList(CouponTemplateConvert.INSTANCE.convertToBO(couponTemplateMapper.selectListByPage( + couponTemplatePageDTO.getType(), couponTemplatePageDTO.getTitle(), + couponTemplatePageDTO.getStatus(), couponTemplatePageDTO.getPreferentialType(), + offset, couponTemplatePageDTO.getPageSize()))); + // 查询分页总数 + couponTemplatePageBO.setTotal(couponTemplateMapper.selectCountByPage( + couponTemplatePageDTO.getType(), couponTemplatePageDTO.getTitle(), + couponTemplatePageDTO.getStatus(), couponTemplatePageDTO.getPreferentialType())); + return CommonResult.success(couponTemplatePageBO); } @Override @@ -71,32 +82,38 @@ public class CouponServiceImpl implements CouponService { @Override public CommonResult updateCouponCardTemplate(CouponCardTemplateUpdateDTO couponCardTemplateUpdateDTO) { - return null; + // 校验 CouponCardTemplate 存在 + CouponTemplateDO template = couponTemplateMapper.selectById(couponCardTemplateUpdateDTO.getId()); + if (template == null) { + return ServiceExceptionUtil.error(PromotionErrorCodeEnum.PRODUCT_TEMPLATE_NOT_EXISTS.getCode()); + } + // 校验 CouponCardTemplate 是 CARD + if (!CouponTemplateTypeEnum.CARD.getValue().equals(template.getType())) { + return ServiceExceptionUtil.error(PromotionErrorCodeEnum.PRODUCT_TEMPLATE_NOT_CARD.getCode()); + } + // 校验发放数量不能减少 + if (couponCardTemplateUpdateDTO.getTotal() < template.getTotal()) { + return ServiceExceptionUtil.error(PromotionErrorCodeEnum.PRODUCT_TEMPLATE_TOTAL_CAN_NOT_REDUCE.getCode()); + } + // 更新优惠劵模板到数据库 + CouponTemplateDO updateTemplateDO = CouponTemplateConvert.INSTANCE.convert(couponCardTemplateUpdateDTO); + couponTemplateMapper.update(updateTemplateDO); + // 返回成功 + return CommonResult.success(true); } @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; + // 校验 CouponCardTemplate 存在 + CouponTemplateDO template = couponTemplateMapper.selectById(couponTemplateId); + if (template == null) { + return ServiceExceptionUtil.error(PromotionErrorCodeEnum.PRODUCT_TEMPLATE_NOT_EXISTS.getCode()); + } + // 更新到数据库 + CouponTemplateDO updateTemplateDO = new CouponTemplateDO().setId(couponTemplateId).setStatus(status); + couponTemplateMapper.update(updateTemplateDO); + // 返回成功 + return CommonResult.success(true); } private CommonResult checkCouponTemplateDateType(Integer dateType, Date validStartTime, Date validEndTime, Integer fixedBeginTerm, Integer fixedEndTerm) { @@ -142,4 +159,28 @@ public class CouponServiceImpl implements CouponService { return CommonResult.success(true); } + // ========== 优惠劵 ========== + + @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; + } + } 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 087212b19..8a4938ded 100644 --- a/promotion/promotion-service-impl/src/main/resources/mapper/CouponTemplateMapper.xml +++ b/promotion/promotion-service-impl/src/main/resources/mapper/CouponTemplateMapper.xml @@ -5,7 +5,7 @@ id, title, description, type, code_type, status, quota, total, price_available, range_type, - range_values, date_type, valid_start_time, valid_end_time, fixed_term, + range_values, date_type, valid_start_time, valid_end_time, fixed_start_term, fixed_end_term, preferential_type, percent_off, price_off, discount_price_limit, stat_fetch_num, create_time @@ -39,8 +39,11 @@ FROM coupon_template + + AND type = #{type} + - title LIKE "%"#{title}"%" + AND title LIKE "%"#{title}"%" AND status = #{status} @@ -57,8 +60,11 @@ COUNT(1) FROM coupon_template + + AND type = #{type} + - title LIKE "%"#{title}"%" + AND title LIKE "%"#{title}"%" AND status = #{status} @@ -73,13 +79,13 @@ INSERT INTO coupon_template ( title, description, type, code_type, status, quota, total, price_available, range_type, - range_values, date_type, valid_start_time, valid_end_time, fixed_term, + range_values, date_type, valid_start_time, valid_end_time, fixed_start_term, fixed_end_term, preferential_type, percent_off, price_off, discount_price_limit, stat_fetch_num, create_time ) VALUES ( #{title}, #{description}, #{type}, #{codeType}, #{status}, #{quota}, #{total}, #{priceAvailable}, #{rangeType}, - #{rangeValues}, #{dateType}, #{validStartTime}, #{validEndTime}, #{fixedTerm}, + #{rangeValues}, #{dateType}, #{validStartTime}, #{validEndTime}, #{fixedStartTerm}, #{fixedEndTerm} #{preferentialType}, #{percentOff}, #{priceOff}, #{discountPriceLimit}, #{statFetchNum}, #{createTime} ) @@ -121,8 +127,11 @@ valid_end_time = #{validEndTime}, - - fixed_term = #{fixedTerm}, + + fixed_start_term = #{fixedStartTerm}, + + + fixed_end_term = #{fixedEndTerm}, preferential_type = #{preferentialType}, diff --git a/promotion/promotion-service-impl/target/classes/mapper/CouponTemplateMapper.xml b/promotion/promotion-service-impl/target/classes/mapper/CouponTemplateMapper.xml new file mode 100644 index 000000000..8a4938ded --- /dev/null +++ b/promotion/promotion-service-impl/target/classes/mapper/CouponTemplateMapper.xml @@ -0,0 +1,152 @@ + + + + + + id, title, description, type, code_type, + status, quota, total, price_available, range_type, + range_values, date_type, valid_start_time, valid_end_time, fixed_start_term, fixed_end_term, + preferential_type, percent_off, price_off, discount_price_limit, stat_fetch_num, + create_time + + + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO coupon_template ( + title, description, type, code_type, + status, quota, total, price_available, range_type, + range_values, date_type, valid_start_time, valid_end_time, fixed_start_term, fixed_end_term, + preferential_type, percent_off, price_off, discount_price_limit, stat_fetch_num, + create_time + ) VALUES ( + #{title}, #{description}, #{type}, #{codeType}, + #{status}, #{quota}, #{total}, #{priceAvailable}, #{rangeType}, + #{rangeValues}, #{dateType}, #{validStartTime}, #{validEndTime}, #{fixedStartTerm}, #{fixedEndTerm} + #{preferentialType}, #{percentOff}, #{priceOff}, #{discountPriceLimit}, #{statFetchNum}, + #{createTime} + ) + + + + UPDATE coupon_template + + + title = #{title}, + + + description = #{description}, + + + status = #{status}, + + + quota = #{quota}, + + + total = #{total}, + + + price_available = #{priceAvailable}, + + + range_type = #{rangeType}, + + + range_values = #{rangeValues}, + + + date_type = #{dateType}, + + + valid_start_time = #{validStartTime}, + + + valid_end_time = #{validEndTime}, + + + fixed_start_term = #{fixedStartTerm}, + + + fixed_end_term = #{fixedEndTerm}, + + + preferential_type = #{preferentialType}, + + + percent_off = #{percentOff}, + + + price_off = #{priceOff}, + + + discount_price_limit = #{discountPriceLimit}, + + + WHERE id = #{id} + + + diff --git a/promotion/promotion-service-impl/target/classes/mapper/ProductRecommendMapper.xml b/promotion/promotion-service-impl/target/classes/mapper/ProductRecommendMapper.xml new file mode 100644 index 000000000..7632b2579 --- /dev/null +++ b/promotion/promotion-service-impl/target/classes/mapper/ProductRecommendMapper.xml @@ -0,0 +1,125 @@ + + + + + + id, type, product_spu_id, sort, + status, memo, create_time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO product_recommend ( + type, product_spu_id, sort, status, memo, + create_time, deleted + ) VALUES ( + #{type}, #{productSpuId}, #{sort}, #{status}, #{memo}, + #{createTime}, #{deleted} + ) + + + + UPDATE product_recommend + + + type = #{type}, + + + product_spu_id = #{productSpuId}, + + + sort = #{sort}, + + + status = #{status}, + + + memo = #{memo}, + + + deleted = #{deleted} + + + WHERE id = #{id} + + + \ No newline at end of file diff --git a/promotion/promotion-service-impl/target/generated-sources/annotations/cn/iocoder/mall/promotion/biz/convert/CouponTemplateConvertImpl.java b/promotion/promotion-service-impl/target/generated-sources/annotations/cn/iocoder/mall/promotion/biz/convert/CouponTemplateConvertImpl.java new file mode 100644 index 000000000..6cb89e9db --- /dev/null +++ b/promotion/promotion-service-impl/target/generated-sources/annotations/cn/iocoder/mall/promotion/biz/convert/CouponTemplateConvertImpl.java @@ -0,0 +1,135 @@ +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.CouponCardTemplateUpdateDTO; +import cn.iocoder.mall.promotion.api.dto.CouponCodeTemplateAddDTO; +import cn.iocoder.mall.promotion.api.dto.CouponCodeTemplateUpdateDTO; +import cn.iocoder.mall.promotion.biz.dataobject.CouponTemplateDO; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Generated; + +@Generated( + value = "org.mapstruct.ap.MappingProcessor", + date = "2019-04-06T01:40:11+0800", + comments = "version: 1.3.0.Final, compiler: javac, environment: Java 1.8.0_121 (Oracle Corporation)" +) +public class CouponTemplateConvertImpl implements CouponTemplateConvert { + + @Override + public List convertToBO(List templateList) { + if ( templateList == null ) { + return null; + } + + List list = new ArrayList( templateList.size() ); + for ( CouponTemplateDO couponTemplateDO : templateList ) { + list.add( convert( couponTemplateDO ) ); + } + + return list; + } + + @Override + public CouponTemplateDO convert(CouponCodeTemplateUpdateDTO template) { + if ( template == null ) { + return null; + } + + CouponTemplateDO couponTemplateDO = new CouponTemplateDO(); + + return couponTemplateDO; + } + + @Override + public CouponTemplateDO convert(CouponCardTemplateAddDTO template) { + if ( template == null ) { + return null; + } + + CouponTemplateDO couponTemplateDO = new CouponTemplateDO(); + + couponTemplateDO.setTitle( template.getTitle() ); + couponTemplateDO.setDescription( template.getDescription() ); + couponTemplateDO.setQuota( template.getQuota() ); + couponTemplateDO.setTotal( template.getTotal() ); + couponTemplateDO.setPriceAvailable( template.getPriceAvailable() ); + couponTemplateDO.setRangeType( template.getRangeType() ); + couponTemplateDO.setRangeValues( template.getRangeValues() ); + couponTemplateDO.setDateType( template.getDateType() ); + couponTemplateDO.setValidStartTime( template.getValidStartTime() ); + couponTemplateDO.setValidEndTime( template.getValidEndTime() ); + couponTemplateDO.setFixedEndTerm( template.getFixedEndTerm() ); + couponTemplateDO.setPreferentialType( template.getPreferentialType() ); + couponTemplateDO.setPercentOff( template.getPercentOff() ); + couponTemplateDO.setPriceOff( template.getPriceOff() ); + couponTemplateDO.setDiscountPriceLimit( template.getDiscountPriceLimit() ); + + return couponTemplateDO; + } + + @Override + public CouponTemplateDO convert(CouponCardTemplateUpdateDTO template) { + if ( template == null ) { + return null; + } + + CouponTemplateDO couponTemplateDO = new CouponTemplateDO(); + + couponTemplateDO.setId( template.getId() ); + couponTemplateDO.setTitle( template.getTitle() ); + couponTemplateDO.setDescription( template.getDescription() ); + couponTemplateDO.setQuota( template.getQuota() ); + couponTemplateDO.setTotal( template.getTotal() ); + couponTemplateDO.setRangeType( template.getRangeType() ); + couponTemplateDO.setRangeValues( template.getRangeValues() ); + + return couponTemplateDO; + } + + @Override + public CouponTemplateDO convert(CouponCodeTemplateAddDTO template) { + if ( template == null ) { + return null; + } + + CouponTemplateDO couponTemplateDO = new CouponTemplateDO(); + + return couponTemplateDO; + } + + @Override + public CouponTemplateBO convert(CouponTemplateDO template) { + if ( template == null ) { + return null; + } + + CouponTemplateBO couponTemplateBO = new CouponTemplateBO(); + + couponTemplateBO.setId( template.getId() ); + couponTemplateBO.setTitle( template.getTitle() ); + couponTemplateBO.setDescription( template.getDescription() ); + couponTemplateBO.setType( template.getType() ); + couponTemplateBO.setCodeType( template.getCodeType() ); + couponTemplateBO.setStatus( template.getStatus() ); + couponTemplateBO.setQuota( template.getQuota() ); + couponTemplateBO.setTotal( template.getTotal() ); + couponTemplateBO.setPriceAvailable( template.getPriceAvailable() ); + couponTemplateBO.setRangeType( template.getRangeType() ); + couponTemplateBO.setRangeValues( template.getRangeValues() ); + couponTemplateBO.setDateType( template.getDateType() ); + couponTemplateBO.setValidStartTime( template.getValidStartTime() ); + couponTemplateBO.setValidEndTime( template.getValidEndTime() ); + couponTemplateBO.setPreferentialType( template.getPreferentialType() ); + couponTemplateBO.setPercentOff( template.getPercentOff() ); + couponTemplateBO.setPriceOff( template.getPriceOff() ); + couponTemplateBO.setDiscountPriceLimit( template.getDiscountPriceLimit() ); + couponTemplateBO.setStatFetchNum( template.getStatFetchNum() ); + couponTemplateBO.setCreateTime( template.getCreateTime() ); + couponTemplateBO.setFixedStartTerm( template.getFixedStartTerm() ); + couponTemplateBO.setFixedEndTerm( template.getFixedEndTerm() ); + + return couponTemplateBO; + } +} diff --git a/promotion/promotion-service-impl/target/generated-sources/annotations/cn/iocoder/mall/promotion/biz/convert/ProductRecommendConvertImpl.java b/promotion/promotion-service-impl/target/generated-sources/annotations/cn/iocoder/mall/promotion/biz/convert/ProductRecommendConvertImpl.java new file mode 100644 index 000000000..e0ab55fac --- /dev/null +++ b/promotion/promotion-service-impl/target/generated-sources/annotations/cn/iocoder/mall/promotion/biz/convert/ProductRecommendConvertImpl.java @@ -0,0 +1,83 @@ +package cn.iocoder.mall.promotion.biz.convert; + +import cn.iocoder.mall.promotion.api.bo.ProductRecommendBO; +import cn.iocoder.mall.promotion.api.dto.ProductRecommendAddDTO; +import cn.iocoder.mall.promotion.api.dto.ProductRecommendUpdateDTO; +import cn.iocoder.mall.promotion.biz.dataobject.ProductRecommendDO; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Generated; + +@Generated( + value = "org.mapstruct.ap.MappingProcessor", + date = "2019-04-06T01:40:11+0800", + comments = "version: 1.3.0.Final, compiler: javac, environment: Java 1.8.0_121 (Oracle Corporation)" +) +public class ProductRecommendConvertImpl implements ProductRecommendConvert { + + @Override + public ProductRecommendBO convertToBO(ProductRecommendDO banner) { + if ( banner == null ) { + return null; + } + + ProductRecommendBO productRecommendBO = new ProductRecommendBO(); + + productRecommendBO.setId( banner.getId() ); + productRecommendBO.setType( banner.getType() ); + productRecommendBO.setProductSpuId( banner.getProductSpuId() ); + productRecommendBO.setSort( banner.getSort() ); + productRecommendBO.setStatus( banner.getStatus() ); + productRecommendBO.setMemo( banner.getMemo() ); + productRecommendBO.setCreateTime( banner.getCreateTime() ); + + return productRecommendBO; + } + + @Override + public List convertToBO(List bannerList) { + if ( bannerList == null ) { + return null; + } + + List list = new ArrayList( bannerList.size() ); + for ( ProductRecommendDO productRecommendDO : bannerList ) { + list.add( convertToBO( productRecommendDO ) ); + } + + return list; + } + + @Override + public ProductRecommendDO convert(ProductRecommendAddDTO bannerAddDTO) { + if ( bannerAddDTO == null ) { + return null; + } + + ProductRecommendDO productRecommendDO = new ProductRecommendDO(); + + productRecommendDO.setType( bannerAddDTO.getType() ); + productRecommendDO.setProductSpuId( bannerAddDTO.getProductSpuId() ); + productRecommendDO.setSort( bannerAddDTO.getSort() ); + productRecommendDO.setMemo( bannerAddDTO.getMemo() ); + + return productRecommendDO; + } + + @Override + public ProductRecommendDO convert(ProductRecommendUpdateDTO bannerUpdateDTO) { + if ( bannerUpdateDTO == null ) { + return null; + } + + ProductRecommendDO productRecommendDO = new ProductRecommendDO(); + + productRecommendDO.setId( bannerUpdateDTO.getId() ); + productRecommendDO.setType( bannerUpdateDTO.getType() ); + productRecommendDO.setProductSpuId( bannerUpdateDTO.getProductSpuId() ); + productRecommendDO.setSort( bannerUpdateDTO.getSort() ); + productRecommendDO.setMemo( bannerUpdateDTO.getMemo() ); + + return productRecommendDO; + } +}