优惠劵模板相关逻辑的迁移
This commit is contained in:
parent
60b0043a78
commit
42c6389023
@ -1,13 +0,0 @@
|
|||||||
package cn.iocoder.mall.order.biz;
|
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
|
|
||||||
@SpringBootApplication(scanBasePackages = "cn.iocoder.mall.order")
|
|
||||||
public class OrderApplicationTest {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(OrderApplicationTest.class, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package cn.iocoder.mall.order.biz.mapper;
|
|
||||||
|
|
||||||
import cn.iocoder.mall.order.biz.OrderApplicationTest;
|
|
||||||
import cn.iocoder.mall.order.biz.dao.OrderMapper;
|
|
||||||
import cn.iocoder.mall.order.biz.dataobject.OrderDO;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* mapper test
|
|
||||||
*
|
|
||||||
* @author Sin
|
|
||||||
* @time 2019/5/13 10:45 PM
|
|
||||||
*/
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest(classes = OrderApplicationTest.class)
|
|
||||||
@Transactional
|
|
||||||
public class OrderMapperTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private OrderMapper orderMapper;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void updateByIdTest() {
|
|
||||||
int id = 47;
|
|
||||||
// int updateStatus = 99;
|
|
||||||
// int res = orderMapper.update(new OrderDO().setStatus(id), new UpdateWrapper<OrderDO>().eq("id", updateStatus));
|
|
||||||
OrderDO orderDO = orderMapper.selectById(id);
|
|
||||||
// Assert.assertTrue(orderDO.getStatus() == updateStatus);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
package cn.iocoder.mall.order.biz.service;
|
|
||||||
|
|
||||||
import cn.iocoder.mall.order.biz.OrderApplicationTest;
|
|
||||||
import cn.iocoder.mall.order.api.OrderService;
|
|
||||||
import cn.iocoder.mall.order.biz.dao.OrderMapper;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单 service test
|
|
||||||
*
|
|
||||||
* @author Sin
|
|
||||||
* @time 2019-03-17 10:34
|
|
||||||
*/
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest(classes = OrderApplicationTest.class)
|
|
||||||
@Transactional
|
|
||||||
public class OrderServiceImplTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private OrderService orderService;
|
|
||||||
@Autowired
|
|
||||||
private OrderMapper orderMapper;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void createOrderTest() {
|
|
||||||
//
|
|
||||||
// Integer userId = 1;
|
|
||||||
// OrderCreateItemDTO orderCreateItemDTO
|
|
||||||
// = new OrderCreateItemDTO()
|
|
||||||
// .setSkuId(1)
|
|
||||||
// .setQuantity(1);
|
|
||||||
//
|
|
||||||
// CommonResult<OrderCreateBO> result = orderService.createOrder(
|
|
||||||
// userId,
|
|
||||||
// new OrderCreateDTO()
|
|
||||||
// .setRemark("")
|
|
||||||
// .setName("张三")
|
|
||||||
// .setMobile("13301926050")
|
|
||||||
// .setAddress("深圳市福田区")
|
|
||||||
// .setAreaNo("1000100")
|
|
||||||
// .setOrderItems(Arrays.asList(orderCreateItemDTO)));
|
|
||||||
//
|
|
||||||
// OrderDO orderDO = orderMapper.selectById(result.getData().getId());
|
|
||||||
// Assert.assertNotNull("创建的订单不存在!", orderDO);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
package cn.iocoder.mall.promotion.application.controller.users;
|
|
||||||
|
|
||||||
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.CouponCardPageBO;
|
|
||||||
import cn.iocoder.mall.promotion.api.bo.CouponTemplateBO;
|
|
||||||
import cn.iocoder.mall.promotion.api.dto.CouponCardPageDTO;
|
|
||||||
import cn.iocoder.mall.promotion.application.convert.CouponCardConvert;
|
|
||||||
import cn.iocoder.mall.promotion.application.convert.CouponTemplateConvert;
|
|
||||||
import cn.iocoder.mall.promotion.application.vo.users.UsersCouponCardPageVO;
|
|
||||||
import cn.iocoder.mall.promotion.application.vo.users.UsersCouponCardVO;
|
|
||||||
import cn.iocoder.mall.promotion.application.vo.users.UsersCouponTemplateVO;
|
|
||||||
import cn.iocoder.mall.security.core.context.UserSecurityContextHolder;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import org.apache.dubbo.config.annotation.Reference;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("users/coupon")
|
|
||||||
@Api("优惠劵(码)模块")
|
|
||||||
public class UsersCouponController {
|
|
||||||
|
|
||||||
@Reference(validation = "true", version = "${dubbo.provider.CouponService.version}")
|
|
||||||
private CouponService couponService;
|
|
||||||
|
|
||||||
// ========== 优惠劵(码)模板 ==========
|
|
||||||
|
|
||||||
@GetMapping("/template/get")
|
|
||||||
@ApiOperation(value = "优惠劵(码)模板信息")
|
|
||||||
@ApiImplicitParam(name = "id", value = "优惠劵(码)模板编号", required = true, example = "10")
|
|
||||||
public CommonResult<UsersCouponTemplateVO> templateGet(@RequestParam("id") Integer id) {
|
|
||||||
CouponTemplateBO template = couponService.getCouponTemplate(id);
|
|
||||||
return success(CouponTemplateConvert.USERS.convert2(template));
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== 优惠劵 ==========
|
|
||||||
|
|
||||||
@GetMapping("/card/page")
|
|
||||||
@ApiOperation(value = "优惠劵分页")
|
|
||||||
@ApiImplicitParams({
|
|
||||||
@ApiImplicitParam(name = "status", value = "状态", example = "参考 CouponCardStatusEnum 枚举"),
|
|
||||||
@ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"),
|
|
||||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, example = "10"),
|
|
||||||
})
|
|
||||||
public CommonResult<UsersCouponCardPageVO> cardPage(@RequestParam(value = "status", required = false) Integer status,
|
|
||||||
@RequestParam(value = "pageNo", defaultValue = "0") Integer pageNo,
|
|
||||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
|
||||||
CouponCardPageBO result = couponService.getCouponCardPage(new CouponCardPageDTO()
|
|
||||||
.setStatus(status).setUserId(UserSecurityContextHolder.getContext().getUserId())
|
|
||||||
.setPageNo(pageNo).setPageSize(pageSize));
|
|
||||||
return success(CouponCardConvert.INSTANCE.convert2(result));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/card/add")
|
|
||||||
@ApiOperation(value = "领取优惠劵")
|
|
||||||
@ApiImplicitParam(name = "templateId", value = "优惠劵(码)模板编号", required = true, example = "10")
|
|
||||||
public CommonResult<UsersCouponCardVO> cardAdd(@RequestParam("templateId") Integer templateId) {
|
|
||||||
CouponCardBO result = couponService.addCouponCard(UserSecurityContextHolder.getContext().getUserId(), templateId);
|
|
||||||
return success(CouponCardConvert.INSTANCE.convert(result));
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== 优惠码 ==========
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
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;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@ApiModel("CouponTemplate VO")
|
|
||||||
@Data
|
|
||||||
@Accessors(chain = true)
|
|
||||||
public class UsersCouponTemplateVO {
|
|
||||||
|
|
||||||
// ========== 基本信息 BEGIN ==========
|
|
||||||
@ApiModelProperty(value = "模板编号,自增唯一", required = true, example = "1")
|
|
||||||
private Integer id;
|
|
||||||
@ApiModelProperty(value = "标题", required = true, example = "优惠劵牛逼")
|
|
||||||
private String title;
|
|
||||||
@ApiModelProperty(value = "优惠码状态", required = true, example = "参见 CouponTemplateStatusEnum 枚举")
|
|
||||||
private Integer status;
|
|
||||||
// ========== 领取规则 END ==========
|
|
||||||
|
|
||||||
// ========== 使用规则 BEGIN ==========
|
|
||||||
@ApiModelProperty(value = "是否设置满多少金额可用,单位:分", required = true, example = "0-不限制;大于0-多少金额可用")
|
|
||||||
private Integer priceAvailable;
|
|
||||||
@ApiModelProperty(value = "可用范围的类型", required = true, example = "参见 CouponTemplateRangeTypeEnum 枚举")
|
|
||||||
private Integer rangeType;
|
|
||||||
@ApiModelProperty(value = "指定商品 / 分类列表,使用逗号分隔商品编号", example = "参见 CouponTemplateRangeTypeEnum 枚举")
|
|
||||||
private String rangeValues;
|
|
||||||
@ApiModelProperty(value = "生效日期类型", example = "参见 CouponTemplateDateTypeEnum 枚举")
|
|
||||||
private Integer dateType;
|
|
||||||
@ApiModelProperty(value = "固定日期-生效开始时间")
|
|
||||||
private Date validStartTime;
|
|
||||||
@ApiModelProperty(value = "固定日期-生效结束时间")
|
|
||||||
private Date validEndTime;
|
|
||||||
@ApiModelProperty(value = "领取日期-开始天数", example = "例如,0-当天;1-次天")
|
|
||||||
private Integer fixedStartTerm;
|
|
||||||
@ApiModelProperty(value = "领取日期-结束天数")
|
|
||||||
private Integer fixedEndTerm;
|
|
||||||
// ========== 使用规则 END ==========
|
|
||||||
|
|
||||||
// ========== 使用效果 BEGIN ==========
|
|
||||||
@ApiModelProperty(value = "优惠类型", required = true, example = "参见 CouponTemplatePreferentialTypeEnum 枚举")
|
|
||||||
private Integer preferentialType;
|
|
||||||
@ApiModelProperty(value = "折扣百分比")
|
|
||||||
private Integer percentOff;
|
|
||||||
@ApiModelProperty(value = "优惠金额,单位:分")
|
|
||||||
private Integer priceOff;
|
|
||||||
@ApiModelProperty(value = "折扣上限")
|
|
||||||
private Integer discountPriceLimit;
|
|
||||||
// ========== 使用效果 END ==========
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,34 @@
|
|||||||
|
package cn.iocoder.mall.shopweb.controller.promotion;
|
||||||
|
|
||||||
|
import cn.iocoder.common.framework.vo.CommonResult;
|
||||||
|
import cn.iocoder.mall.shopweb.controller.promotion.vo.coupon.template.CouponTemplateRespVO;
|
||||||
|
import cn.iocoder.mall.shopweb.manager.promotion.CouponTemplateManager;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/promotion/coupon-template")
|
||||||
|
@Api(tags = "优惠劵(码)模板 API")
|
||||||
|
@Validated
|
||||||
|
public class CouponTemplateController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CouponTemplateManager couponTemplateManager;
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@ApiOperation(value = "优惠劵(码)模板信息")
|
||||||
|
@ApiImplicitParam(name = "id", value = "优惠劵(码)模板编号", required = true, example = "10")
|
||||||
|
public CommonResult<CouponTemplateRespVO> getCouponTemplate(@RequestParam("id") Integer id) {
|
||||||
|
return success(couponTemplateManager.getCouponTemplate(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
package cn.iocoder.mall.shopweb.controller.promotion.vo.coupon.template;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@ApiModel("优惠劵(码)模板 VO")
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class CouponTemplateRespVO {
|
||||||
|
|
||||||
|
// ========== 基本信息 BEGIN ==========
|
||||||
|
@ApiModelProperty(value = "模板编号,自增唯一", required = true, example = "1")
|
||||||
|
private Integer id;
|
||||||
|
@ApiModelProperty(value = "标题", required = true, example = "优惠劵牛逼")
|
||||||
|
private String title;
|
||||||
|
@ApiModelProperty(value = "使用说明", required = true, example = "我只是描述")
|
||||||
|
private String description;
|
||||||
|
@ApiModelProperty(value = "优惠劵类型", required = true, example = "1", notes = "参见 CouponTemplateTypeEnum 枚举")
|
||||||
|
private Integer type;
|
||||||
|
/**
|
||||||
|
* 码类型
|
||||||
|
*
|
||||||
|
* 1-一卡一码(UNIQUE)
|
||||||
|
* 2-通用码(GENERAL)
|
||||||
|
*
|
||||||
|
* 【优惠码独有】 @see CouponCodeDO
|
||||||
|
*/
|
||||||
|
private Integer codeType;
|
||||||
|
@ApiModelProperty(value = "优惠码状态", required = true, example = "1", notes = "参见 CouponTemplateStatusEnum 枚举")
|
||||||
|
private Integer status;
|
||||||
|
@ApiModelProperty(value = "每人限领个数", example = "1", notes = "null - 则表示不限制")
|
||||||
|
private Integer quota;
|
||||||
|
@ApiModelProperty(value = "发放总量", example = "100")
|
||||||
|
private Integer total;
|
||||||
|
// ========== 领取规则 END ==========
|
||||||
|
|
||||||
|
// ========== 使用规则 BEGIN ==========
|
||||||
|
@ApiModelProperty(value = "是否设置满多少金额可用,单位:分", required = true, example = "0", notes = "0-不限制;大于0-多少金额可用")
|
||||||
|
private Integer priceAvailable;
|
||||||
|
@ApiModelProperty(value = "可用范围的类型", required = true, example = "10", notes = "参见 RangeTypeEnum 枚举")
|
||||||
|
private Integer rangeType;
|
||||||
|
@ApiModelProperty(value = "指定商品 / 分类列表,使用逗号分隔商品编号", example = "1,3,5")
|
||||||
|
private List<Integer> rangeValues;
|
||||||
|
@ApiModelProperty(value = "生效日期类型", example = "1", notes = "参见 CouponTemplateDateTypeEnum 枚举")
|
||||||
|
private Integer dateType;
|
||||||
|
@ApiModelProperty(value = "固定日期-生效开始时间", notes = "当 dateType 为固定日期时,非空")
|
||||||
|
private Date validStartTime;
|
||||||
|
@ApiModelProperty(value = "固定日期-生效结束时间", notes = "当 dateType 为固定日期时,非空")
|
||||||
|
private Date validEndTime;
|
||||||
|
@ApiModelProperty(value = "领取日期-开始天数", example = "0", notes = "例如,0-当天;1-次天")
|
||||||
|
private Integer fixedStartTerm;
|
||||||
|
@ApiModelProperty(value = "领取日期-结束天数", example = "1", notes = "当 dateType 为领取日期时,非空")
|
||||||
|
private Integer fixedEndTerm;
|
||||||
|
// ========== 使用规则 END ==========
|
||||||
|
|
||||||
|
// ========== 使用效果 BEGIN ==========
|
||||||
|
@ApiModelProperty(value = "优惠类型", required = true, example = "1", notes = "参见 PreferentialTypeEnum 枚举")
|
||||||
|
private Integer preferentialType;
|
||||||
|
@ApiModelProperty(value = "折扣百分比", example = "80", notes = "当 preferentialType 为现金券时,非空")
|
||||||
|
private Integer percentOff;
|
||||||
|
@ApiModelProperty(value = "优惠金额,单位:分", example = "100", notes = "当 preferentialType 为折扣卷时,非空")
|
||||||
|
private Integer priceOff;
|
||||||
|
@ApiModelProperty(value = "折扣上限", example = "100", notes = "当 preferentialType 为折扣卷时,非空")
|
||||||
|
private Integer discountPriceLimit;
|
||||||
|
// ========== 使用效果 END ==========
|
||||||
|
|
||||||
|
// ========== 统计信息 BEGIN ==========
|
||||||
|
@ApiModelProperty(value = "领取优惠券的次数", required = true)
|
||||||
|
private Integer statFetchNum;
|
||||||
|
// ========== 统计信息 END ==========
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间", required = true)
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package cn.iocoder.mall.shopweb.convert.promotion;
|
||||||
|
|
||||||
|
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponTemplateRespDTO;
|
||||||
|
import cn.iocoder.mall.shopweb.controller.promotion.vo.coupon.template.CouponTemplateRespVO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface CouponTemplateConvert {
|
||||||
|
|
||||||
|
CouponTemplateConvert INSTANCE = Mappers.getMapper(CouponTemplateConvert.class);
|
||||||
|
|
||||||
|
CouponTemplateRespVO convert(CouponTemplateRespDTO bean);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package cn.iocoder.mall.shopweb.manager.promotion;
|
||||||
|
|
||||||
|
import cn.iocoder.common.framework.vo.CommonResult;
|
||||||
|
import cn.iocoder.mall.promotion.api.rpc.coupon.CouponTemplateRpc;
|
||||||
|
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponTemplateRespDTO;
|
||||||
|
import cn.iocoder.mall.shopweb.controller.promotion.vo.coupon.template.CouponTemplateRespVO;
|
||||||
|
import cn.iocoder.mall.shopweb.convert.promotion.CouponTemplateConvert;
|
||||||
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优惠劵(码)模板 Manager
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CouponTemplateManager {
|
||||||
|
|
||||||
|
@DubboReference(version = "${dubbo.consumer.CouponTemplateRpc.version}")
|
||||||
|
private CouponTemplateRpc couponTemplateRpc;
|
||||||
|
|
||||||
|
public CouponTemplateRespVO getCouponTemplate(Integer id) {
|
||||||
|
CommonResult<CouponTemplateRespDTO> getCouponTemplateResult = couponTemplateRpc.getCouponTemplate(id);
|
||||||
|
getCouponTemplateResult.checkError();
|
||||||
|
return CouponTemplateConvert.INSTANCE.convert(getCouponTemplateResult.getData());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user