后端 + 前端:优惠劵更新功能

This commit is contained in:
YunaiV 2019-04-06 00:57:00 +08:00
parent 7f024bec9d
commit f8ae2153ba
18 changed files with 1137 additions and 53 deletions

View File

@ -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: {},
},

View File

@ -1,15 +1,14 @@
import {message} from 'antd';
import {
deleteProductRecommend,
updateProductRecommend,
updateProductRecommendStatus,
addCouponCardTemplate,
updateCouponCardTemplate,
getCouponCardTemplatePage,
} from '../../services/promotion';
import PaginationHelper from '../../../helpers/PaginationHelper';
const SEARCH_PARAMS_DEFAULT = {
// type: 1,
title: '',
};
export default {
@ -50,7 +49,7 @@ export default {
list: response.data.list,
pagination: PaginationHelper.formatPagination(response.data, payload),
searchParams: {
// type: payload.type
title: payload.title
}
},
});
@ -100,7 +99,7 @@ export default {
});
// 请求
const response = yield call(updateProductRecommend, body);
const response = yield call(updateCouponCardTemplate, body);
// 响应
if (response.code === 0) {
if (callback) {
@ -138,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
// },
// });
// }
// },
},

View File

@ -136,6 +136,7 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch,
// 支付金额(元) TODO 芋艿
// 客单价(元) TODO 芋艿
render(val, record) {
// debugger;
return `${record.statFetchNum} / ` + (record.total - record.statFetchNum);
}
},
@ -302,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: () => {
// 清空表单
@ -381,14 +392,14 @@ const AddOrUpdateForm = Form.create()(props => {
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="使用金额门槛">
{form.getFieldDecorator('priceAvailable', {
rules: [{ required: true, message: '请输入使用金额门槛!' },],
initialValue: formVals.priceAvailable,
})(<InputNumber placeholder="请输入" />)}
initialValue: formVals.priceAvailable / 100.0,
})(<InputNumber disabled={modalType != 'add'} placeholder="请输入" />)}
</FormItem>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="可用范围">
{form.getFieldDecorator('rangeType', {
rules: [{ required: true, message: '请选择可用范围!'}, // TODO 芋艿,需要修改
],
initialValue: formVals.rangeType,
initialValue: formVals.rangeType + '',
})(
<Select placeholder="请选择" style={{ maxWidth: 200, width: '100%' }} onChange={onRangeTypeChange} >
<SelectOption value="10">所有可用</SelectOption>
@ -416,10 +427,10 @@ const AddOrUpdateForm = Form.create()(props => {
{form.getFieldDecorator('dateType', {
rules: [{ required: true, message: '请选择可用范围!'}, // TODO 芋艿,需要修改
],
initialValue: formVals.dateType,
initialValue: formVals.dateType + '',
})(
<Select placeholder="请选择" style={{ maxWidth: 200, width: '100%' }} onChange={onDateTypeChange}>
<SelectOption value="1"></SelectOption>
<Select disabled={modalType != 'add'} placeholder="请选择" style={{ maxWidth: 200, width: '100%' }} onChange={onDateTypeChange}>
<SelectOption value="1">固定日期</SelectOption>
<SelectOption value="2">领取日期</SelectOption>
</Select>
)}
@ -429,29 +440,29 @@ const AddOrUpdateForm = Form.create()(props => {
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="固定日期">
{form.getFieldDecorator('validStartTime', {
rules: [{ required: true, message: '请输入固定日期!' },],
initialValue: formVals.validStartTime,
})(<DatePicker format="YYYY-MM-DD" />)}
initialValue: formVals.validStartTime ? moment(formVals.validStartTime) : undefined,
})(<DatePicker disabled={modalType != 'add'} format="YYYY-MM-DD" />)}
&nbsp;-&nbsp;
{form.getFieldDecorator('validEndTime', {
rules: [{ required: true, message: '请输入固定日期!' },],
initialValue: formVals.validEndTime,
})(<DatePicker format="YYYY-MM-DD" />)}
initialValue: formVals.validEndTime ? moment(formVals.validEndTime) : undefined,
})(<DatePicker disabled={modalType != 'add'} format="YYYY-MM-DD" />)}
</FormItem> : ''
}
{
formVals.dateType == 2 ?
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="领取日期">
{form.getFieldDecorator('fixedBeginTerm', {
{form.getFieldDecorator('fixedStartTerm', {
rules: [{ required: true, message: '请输入固定日期!' },
{min: 1, type: 'number', message: '最小值为 1'}],
initialValue: formVals.fixedBeginTerm,
})(<InputNumber placeholder="请输入" />)}
initialValue: formVals.fixedStartTerm,
})(<InputNumber disabled={modalType != 'add'} placeholder="请输入" />)}
&nbsp;-&nbsp;
{form.getFieldDecorator('fixedEndTerm', {
rules: [{ required: true, message: '请输入固定日期!' },
{min: 1, type: 'number', message: '最小值为 1'}],
initialValue: formVals.fixedEndTerm,
})(<InputNumber placeholder="请输入" />)}
})(<InputNumber disabled={modalType != 'add'} placeholder="请输入" />)}
</FormItem> : ''
}
@ -459,9 +470,9 @@ const AddOrUpdateForm = Form.create()(props => {
{form.getFieldDecorator('preferentialType', {
rules: [{ required: true, message: '请选择优惠类型!'}, // TODO 芋艿,需要修改
],
initialValue: formVals.preferentialType,
initialValue: formVals.preferentialType + '',
})(
<Select placeholder="请选择" style={{ maxWidth: 200, width: '100%' }} onChange={onPreferentialTypeChange}>
<Select disabled={modalType != 'add'} placeholder="请选择" style={{ maxWidth: 200, width: '100%' }} onChange={onPreferentialTypeChange}>
<SelectOption value="1">代金卷</SelectOption>
<SelectOption value="2">折扣卷</SelectOption>
</Select>
@ -473,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,
})(<InputNumber placeholder="请输入" />)}
initialValue: formVals.priceOff ? formVals.priceOff / 100.0 : undefined,
})(<InputNumber disabled={modalType != 'add'} placeholder="请输入" />)}
</FormItem> : ''
}
{
@ -486,15 +497,15 @@ const AddOrUpdateForm = Form.create()(props => {
{min: 1, max: 99, type: 'number', message: '范围为 [1, 99]'},
],
initialValue: formVals.percentOff,
})(<InputNumber placeholder="请输入" />)}%
})(<InputNumber disabled={modalType != 'add'} placeholder="请输入" />)}%
</FormItem>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="最多优惠">
{form.getFieldDecorator('discountPriceLimit', {
rules: [{ required: false, message: '请输入最多优惠!' },
{min: 0.01, type: 'number', message: '最小值为 0.01'},
],
initialValue: formVals.discountPriceLimit,
})(<InputNumber placeholder="请输入" />)}
initialValue: formVals.discountPriceLimit ? formVals.discountPriceLimit / 100.0 : undefineds,
})(<InputNumber disabled={modalType != 'add'} placeholder="请输入" />)}
</FormItem>
</span> : ''
}

View File

@ -78,3 +78,9 @@ export async function addCouponCardTemplate(params) {
method: 'POST',
});
}
export async function updateCouponCardTemplate(params) {
return request(`/promotion-api/admins/coupon/template/update_card?${stringify(params)}`, {
method: 'POST',
});
}

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.order.biz.dao.OrderRecipientMapper">
<sql id="FIELDS">
id, order_id, `area_no`, `name`, mobile, address,
create_time, update_time
</sql>
<!--
插入数据
-->
<insert id="insert" parameterType="OrderRecipientDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO `order_recipient` (
order_id, `area_no`, `name`, mobile, address,
create_time, update_time
) VALUES (
#{orderId}, #{areaNo}, #{name}, #{mobile}, #{address},
#{createTime}, #{updateTime}
)
</insert>
<!--
查询 - 根据 orderIds
-->
<select id="selectByOrderIds" resultType="cn.iocoder.mall.order.biz.dataobject.OrderRecipientDO">
SELECT
<include refid="FIELDS" />
FROM `order_recipient`
WHERE order_id IN
<foreach collection="orderIds" item="orderId" separator="," open="(" close=")">
#{orderId}
</foreach>
</select>
</mapper>

View File

@ -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<OrderRecipientBO> convert(List<OrderRecipientDO> orderRecipientDOList) {
if ( orderRecipientDOList == null ) {
return null;
}
List<OrderRecipientBO> list = new ArrayList<OrderRecipientBO>( 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;
}
}

View File

@ -6,6 +6,7 @@ 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;
@ -31,7 +32,7 @@ public class AdminsCouponTemplateController {
// ========== 优惠劵模板 ==========
@GetMapping("/template/page")
@ApiOperation(value = "Banner 分页")
@ApiOperation(value = "优惠劵(码)模板分页")
@ApiImplicitParams({
@ApiImplicitParam(name = "title", value = "标题,模糊匹配", example = "活动 A"),
@ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"),
@ -75,7 +76,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,
@ -103,6 +104,33 @@ 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<Boolean> 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);
}
// ========== 优惠劵 ==========
// ========== 优惠码 ==========

View File

@ -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-05T22:26:04+0800",
comments = "version: 1.3.0.Final, compiler: javac, environment: Java 11.0.1 (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<AdminsCouponTemplateVO> convert2(CommonResult<CouponTemplateBO> result) {
if ( result == null ) {
return null;
}
CommonResult<AdminsCouponTemplateVO> commonResult = new CommonResult<AdminsCouponTemplateVO>();
commonResult.setCode( result.getCode() );
commonResult.setMessage( result.getMessage() );
commonResult.setData( convert( result.getData() ) );
return commonResult;
}
@Override
public CommonResult<AdminsCouponTemplatePageVO> convert(CommonResult<CouponTemplatePageBO> result) {
if ( result == null ) {
return null;
}
CommonResult<AdminsCouponTemplatePageVO> commonResult = new CommonResult<AdminsCouponTemplatePageVO>();
commonResult.setCode( result.getCode() );
commonResult.setMessage( result.getMessage() );
commonResult.setData( couponTemplatePageBOToAdminsCouponTemplatePageVO( result.getData() ) );
return commonResult;
}
@Override
public List<AdminsCouponTemplateVO> convertList(List<CouponTemplateBO> templates) {
if ( templates == null ) {
return null;
}
List<AdminsCouponTemplateVO> list = new ArrayList<AdminsCouponTemplateVO>( 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;
}
}

View File

@ -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-05T22:26:04+0800",
comments = "version: 1.3.0.Final, compiler: javac, environment: Java 11.0.1 (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<AdminsProductRecommendVO> convert2(CommonResult<ProductRecommendBO> result) {
if ( result == null ) {
return null;
}
CommonResult<AdminsProductRecommendVO> commonResult = new CommonResult<AdminsProductRecommendVO>();
commonResult.setCode( result.getCode() );
commonResult.setMessage( result.getMessage() );
commonResult.setData( convert( result.getData() ) );
return commonResult;
}
@Override
public CommonResult<AdminsProductRecommendPageVO> convert(CommonResult<ProductRecommendPageBO> result) {
if ( result == null ) {
return null;
}
CommonResult<AdminsProductRecommendPageVO> commonResult = new CommonResult<AdminsProductRecommendPageVO>();
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<String> list = productSpu.getPicUrls();
if ( list != null ) {
usersProductRecommendVO.setPicUrls( new ArrayList<String>( list ) );
}
usersProductRecommendVO.setPrice( productSpu.getPrice() );
return usersProductRecommendVO;
}
protected List<AdminsProductRecommendVO> productRecommendBOListToAdminsProductRecommendVOList(List<ProductRecommendBO> list) {
if ( list == null ) {
return null;
}
List<AdminsProductRecommendVO> list1 = new ArrayList<AdminsProductRecommendVO>( 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;
}
}

View File

@ -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;
}
}
}

View File

@ -277,5 +277,4 @@ public class CouponCardTemplateAddDTO {
return this;
}
}

View File

@ -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;
}
}

View File

@ -2,7 +2,9 @@ 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;
@ -22,11 +24,17 @@ public interface CouponTemplateConvert {
List<CouponTemplateBO> convertToBO(List<CouponTemplateDO> 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);

View File

@ -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;
@ -82,7 +80,24 @@ public class CouponServiceImpl implements CouponService {
@Override
public CommonResult<Boolean> 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

View File

@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.iocoder.mall.promotion.biz.dao.CouponTemplateMapper">
<sql id="FIELDS">
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
</sql>
<!-- <select id="selectListByPidAndStatusOrderBySort" resultType="CouponTemplateDO">-->
<!-- SELECT-->
<!-- <include refid="FIELDS" />-->
<!-- FROM coupon_template-->
<!-- WHERE pid = #{pid}-->
<!-- AND status = #{status}-->
<!-- AND deleted = 0-->
<!-- ORDER BY sort ASC-->
<!-- </select>-->
<!-- <select id="selectList" resultType="CouponTemplateDO">-->
<!-- SELECT-->
<!-- <include refid="FIELDS" />-->
<!-- FROM coupon_template-->
<!-- WHERE deleted = 0-->
<!-- </select>-->
<select id="selectById" parameterType="Integer" resultType="CouponTemplateDO">
SELECT
<include refid="FIELDS" />
FROM coupon_template
WHERE id = #{id}
</select>
<select id="selectListByPage" resultType="CouponTemplateDO">
SELECT
<include refid="FIELDS" />
FROM coupon_template
<where>
<if test="type != null">
AND type = #{type}
</if>
<if test="title != null">
AND title LIKE "%"#{title}"%"
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="preferentialType != null">
AND preferential_type = #{preferentialType}
</if>
</where>
LIMIT #{offset}, #{limit}
</select>
<select id="selectCountByPage" resultType="Integer">
SELECT
COUNT(1)
FROM coupon_template
<where>
<if test="type != null">
AND type = #{type}
</if>
<if test="title != null">
AND title LIKE "%"#{title}"%"
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="preferentialType != null">
AND preferential_type = #{preferentialType}
</if>
</where>
</select>
<insert id="insert" parameterType="CouponTemplateDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
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}
)
</insert>
<update id="update" parameterType="CouponTemplateDO">
UPDATE coupon_template
<set>
<if test="title != null">
title = #{title},
</if>
<if test="description != null">
description = #{description},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="quota != null">
quota = #{quota},
</if>
<if test="total != null">
total = #{total},
</if>
<if test="priceAvailable != null">
price_available = #{priceAvailable},
</if>
<if test="rangeType != null">
range_type = #{rangeType},
</if>
<if test="rangeValues != null">
range_values = #{rangeValues},
</if>
<if test="dateType != null">
date_type = #{dateType},
</if>
<if test="validStartTime != null">
valid_start_time = #{validStartTime},
</if>
<if test="validEndTime != null">
valid_end_time = #{validEndTime},
</if>
<if test="fixedStartTerm != null">
fixed_start_term = #{fixedStartTerm},
</if>
<if test="fixedEndTerm != null">
fixed_end_term = #{fixedEndTerm},
</if>
<if test="preferentialType != null">
preferential_type = #{preferentialType},
</if>
<if test="percentOff != null">
percent_off = #{percentOff},
</if>
<if test="priceOff != null">
price_off = #{priceOff},
</if>
<if test="discountPriceLimit != null">
discount_price_limit = #{discountPriceLimit},
</if>
</set>
WHERE id = #{id}
</update>
</mapper>

View File

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.iocoder.mall.promotion.biz.dao.ProductRecommendMapper">
<sql id="FIELDS">
id, type, product_spu_id, sort,
status, memo, create_time
</sql>
<!-- <select id="selectListByPidAndStatusOrderBySort" resultType="ProductRecommendDO">-->
<!-- SELECT-->
<!-- <include refid="FIELDS" />-->
<!-- FROM product_recommend-->
<!-- WHERE pid = #{pid}-->
<!-- AND status = #{status}-->
<!-- AND deleted = 0-->
<!-- ORDER BY sort ASC-->
<!-- </select>-->
<!-- <select id="selectList" resultType="ProductRecommendDO">-->
<!-- SELECT-->
<!-- <include refid="FIELDS" />-->
<!-- FROM product_recommend-->
<!-- WHERE deleted = 0-->
<!-- </select>-->
<select id="selectById" parameterType="Integer" resultType="ProductRecommendDO">
SELECT
<include refid="FIELDS" />
FROM product_recommend
WHERE id = #{id}
AND deleted = 0
</select>
<select id="selectByProductSpuIdAndType" resultType="ProductRecommendDO">
SELECT
<include refid="FIELDS" />
FROM product_recommend
<where>
<if test="productSpuId != null">
product_spu_id = #{productSpuId}
</if>
<if test="type != null">
AND type = #{type}
</if>
AND deleted = 0
</where>
</select>
<select id="selectListByTypeAndStatus" parameterType="Integer" resultType="ProductRecommendDO">
SELECT
<include refid="FIELDS" />
FROM product_recommend
<where>
<if test="type != null">
type = #{type}
</if>
<if test="status != null">
AND status = #{status}
</if>
AND deleted = 0
</where>
</select>
<select id="selectPageByType" resultType="ProductRecommendDO">
SELECT
<include refid="FIELDS" />
FROM product_recommend
<where>
<if test="type != null">
type = #{type}
</if>
AND deleted = 0
</where>
LIMIT #{offset}, #{limit}
</select>
<select id="selectCountByType" resultType="Integer">
SELECT
COUNT(1)
FROM product_recommend
<where>
<if test="type != null">
type = #{type}
</if>
AND deleted = 0
</where>
</select>
<insert id="insert" parameterType="ProductRecommendDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO product_recommend (
type, product_spu_id, sort, status, memo,
create_time, deleted
) VALUES (
#{type}, #{productSpuId}, #{sort}, #{status}, #{memo},
#{createTime}, #{deleted}
)
</insert>
<update id="update" parameterType="ProductRecommendDO">
UPDATE product_recommend
<set>
<if test="type != null">
type = #{type},
</if>
<if test="productSpuId != null">
product_spu_id = #{productSpuId},
</if>
<if test="sort != null">
sort = #{sort},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="memo != null">
memo = #{memo},
</if>
<if test="deleted != null">
deleted = #{deleted}
</if>
</set>
WHERE id = #{id}
</update>
</mapper>

View File

@ -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-06T00:20:10+0800",
comments = "version: 1.3.0.Final, compiler: javac, environment: Java 11.0.1 (Oracle Corporation)"
)
public class CouponTemplateConvertImpl implements CouponTemplateConvert {
@Override
public List<CouponTemplateBO> convertToBO(List<CouponTemplateDO> templateList) {
if ( templateList == null ) {
return null;
}
List<CouponTemplateBO> list = new ArrayList<CouponTemplateBO>( 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;
}
}

View File

@ -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-06T00:20:10+0800",
comments = "version: 1.3.0.Final, compiler: javac, environment: Java 11.0.1 (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<ProductRecommendBO> convertToBO(List<ProductRecommendDO> bannerList) {
if ( bannerList == null ) {
return null;
}
List<ProductRecommendBO> list = new ArrayList<ProductRecommendBO>( 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;
}
}