From 7f024bec9d668c1974f5d70297f0b34b6205e67b Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Fri, 5 Apr 2019 22:27:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E7=AB=AF=20+=20=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=EF=BC=9A=E4=BC=98=E6=83=A0=E5=8A=B5=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../promotion/couponCardTemplateList.js | 12 +- .../pages/Promotion/CouponCardTemplateList.js | 142 ++++++++++++------ admin-web/src/services/promotion.js | 6 + .../AdminsCouponTemplateController.java | 27 +++- .../convert/CouponTemplateConvert.java | 16 +- .../vo/admins/AdminsCouponTemplatePageVO.java | 34 +++++ .../vo/admins/AdminsCouponTemplateVO.java | 19 ++- .../convert/BannerConvertImpl.java | 122 +++++++++++++++ .../promotion/api/bo/CouponTemplateBO.java | 12 +- .../api/bo/CouponTemplatePageBO.java | 28 ++++ .../constant/CouponTemplateStatusEnum.java | 2 +- .../api/dto/CouponTemplatePageDTO.java | 64 ++++++++ .../biz/convert/CouponTemplateConvert.java | 6 +- .../biz/dao/CouponTemplateMapper.java | 6 +- .../biz/dataobject/CouponTemplateDO.java | 33 ++-- .../biz/service/CouponServiceImpl.java | 13 +- .../resources/mapper/CouponTemplateMapper.xml | 23 ++- 17 files changed, 470 insertions(+), 95 deletions(-) create mode 100644 promotion/promotion-application/src/main/java/cn/iocoder/mall/promotion/application/vo/admins/AdminsCouponTemplatePageVO.java create mode 100644 promotion/promotion-application/target/generated-sources/annotations/cn/iocoder/mall/promotion/application/convert/BannerConvertImpl.java diff --git a/admin-web/src/models/promotion/couponCardTemplateList.js b/admin-web/src/models/promotion/couponCardTemplateList.js index a0687bf51..3e8c00191 100644 --- a/admin-web/src/models/promotion/couponCardTemplateList.js +++ b/admin-web/src/models/promotion/couponCardTemplateList.js @@ -1,16 +1,15 @@ import {message} from 'antd'; import { - addProductRecommend, deleteProductRecommend, - queryProductRecommend, updateProductRecommend, updateProductRecommendStatus, addCouponCardTemplate, + getCouponCardTemplatePage, } from '../../services/promotion'; import PaginationHelper from '../../../helpers/PaginationHelper'; const SEARCH_PARAMS_DEFAULT = { - type: 1, + // type: 1, }; export default { @@ -40,7 +39,10 @@ export default { }); // 请求 - const response = yield call(queryProductRecommend, payload); + const response = yield call(getCouponCardTemplatePage, { + ...payload, + type: 1 + }); // 响应 yield put({ type: 'setAll', @@ -48,7 +50,7 @@ export default { list: response.data.list, pagination: PaginationHelper.formatPagination(response.data, payload), searchParams: { - type: payload.type + // type: payload.type } }, }); diff --git a/admin-web/src/pages/Promotion/CouponCardTemplateList.js b/admin-web/src/pages/Promotion/CouponCardTemplateList.js index fc7461d7e..be873532e 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, @@ -44,7 +51,7 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch, content: `${record.productSpuId}`, onOk() { dispatch({ - type: 'productRecommendList/updateStatus', + type: 'couponCardTemplateList/updateStatus', payload: { id: record.id, status: record.status === 1 ? 2 : 1, @@ -55,48 +62,91 @@ 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) { + 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 +155,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 +165,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 +182,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 +214,7 @@ const SearchForm = Form.create()(props => { function search() { dispatch({ - type: 'productRecommendList/query', + type: 'couponCardTemplateList/query', payload: { ...PaginationHelper.defaultPayload, ...form.getFieldsValue() @@ -369,7 +419,7 @@ const AddOrUpdateForm = Form.create()(props => { initialValue: formVals.dateType, })( )} @@ -452,10 +502,10 @@ const AddOrUpdateForm = Form.create()(props => { ); }); -@connect(({ productRecommendList }) => ({ +@connect(({ couponCardTemplateList }) => ({ // list: productRecommend.list, // pagination: productRecommend.pagination, - ...productRecommendList, + ...couponCardTemplateList, })) // 主界面 @@ -465,7 +515,7 @@ class CouponCardTemplateLists extends PureComponent { componentDidMount() { const { dispatch } = this.props; dispatch({ - type: 'productRecommendList/query', + type: 'couponCardTemplateList/query', payload: { ...PaginationHelper.defaultPayload }, @@ -475,7 +525,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..ed5bc5e25 100644 --- a/admin-web/src/services/promotion.js +++ b/admin-web/src/services/promotion.js @@ -67,6 +67,12 @@ 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', 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..97bf9efa7 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 @@ -4,8 +4,11 @@ import cn.iocoder.common.framework.util.DateUtil; 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.bo.CouponTemplatePageBO; import cn.iocoder.mall.promotion.api.dto.CouponCardTemplateAddDTO; +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 +16,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 +30,25 @@ public class AdminsCouponTemplateController { // ========== 优惠劵(码)模板 ========== + @GetMapping("/template/page") + @ApiOperation(value = "Banner 分页") + @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({ 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/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/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..9c965f183 --- /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-05T22:26:04+0800", + comments = "version: 1.3.0.Final, compiler: javac, environment: Java 11.0.1 (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.setSort( bannerBO.getSort() ); + adminsBannerVO.setStatus( bannerBO.getStatus() ); + adminsBannerVO.setMemo( bannerBO.getMemo() ); + adminsBannerVO.setCreateTime( bannerBO.getCreateTime() ); + adminsBannerVO.setPicUrl( bannerBO.getPicUrl() ); + + 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-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..087f1f1d5 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 @@ -6,7 +6,7 @@ public enum CouponTemplateStatusEnum { ENABLE(1, "开启中"), DISABLE(2, "禁用中"), - EXPIRE(3, "已过期"), +// EXPIRE(3, "已过期"), TODO 芋艿,暂时不考虑过期的 ; public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplateStatusEnum::getValue).toArray(); 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/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..6fbfd095c 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 @@ -8,6 +8,8 @@ import org.mapstruct.Mapper; import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; +import java.util.List; + @Mapper public interface CouponTemplateConvert { @@ -16,8 +18,8 @@ public interface CouponTemplateConvert { // @Mappings({}) // CouponTemplateBO convertToBO(CouponTemplateDO banner); // -// @Mappings({}) -// List convertToBO(List bannerList); + @Mappings({}) + List convertToBO(List templateList); @Mappings({}) CouponTemplateDO convert(CouponCodeTemplateAddDTO 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/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..02a335229 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 @@ -28,7 +28,18 @@ public class CouponServiceImpl implements CouponService { @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 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},