后端:优惠劵领取相关接口
This commit is contained in:
@@ -25,7 +25,7 @@ import java.util.Date;
|
||||
@RestController
|
||||
@RequestMapping("admins/coupon")
|
||||
@Api("优惠劵(码)模块")
|
||||
public class AdminsCouponTemplateController {
|
||||
public class AdminsCouponController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
private CouponService couponService;
|
||||
@@ -39,12 +39,12 @@ public class AdminsCouponTemplateController {
|
||||
@ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, example = "10"),
|
||||
})
|
||||
public CommonResult<AdminsCouponTemplatePageVO> 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) {
|
||||
public CommonResult<AdminsCouponTemplatePageVO> templatePage(@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<CouponTemplatePageBO> result = couponService.getCouponTemplatePage(new CouponTemplatePageDTO()
|
||||
.setType(type).setTitle(title).setStatus(status).setPreferentialType(preferentialType)
|
||||
.setPageNo(pageNo).setPageSize(pageSize));
|
||||
@@ -71,24 +71,24 @@ public class AdminsCouponTemplateController {
|
||||
@ApiImplicitParam(name = "percentOff", value = "折扣百分比", example = "当 preferentialType 为折扣卷时,非空"),
|
||||
@ApiImplicitParam(name = "discountPriceLimit", value = "折扣上限", example = "当 preferentialType 为折扣卷时,非空"),
|
||||
})
|
||||
public CommonResult<AdminsCouponTemplateVO> add(@RequestParam(value = "title") String title,
|
||||
@RequestParam(value = "description", required = false) String description,
|
||||
@RequestParam(value = "quota") Integer quota,
|
||||
@RequestParam(value = "total", required = false) Integer total,
|
||||
@RequestParam(value = "priceAvailable") Integer priceAvailable,
|
||||
@RequestParam(value = "rangeType") Integer rangeType,
|
||||
@RequestParam(value = "rangeValues", required = false) String rangeValues,
|
||||
@RequestParam(value = "dateType") Integer dateType,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
public CommonResult<AdminsCouponTemplateVO> templateCardAdd(@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 = "priceAvailable") Integer priceAvailable,
|
||||
@RequestParam(value = "rangeType") Integer rangeType,
|
||||
@RequestParam(value = "rangeValues", required = false) String rangeValues,
|
||||
@RequestParam(value = "dateType") Integer dateType,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@RequestParam(value = "validStartTime", required = false) Date validStartTime,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@RequestParam(value = "validEndTime", required = false) Date validEndTime,
|
||||
@RequestParam(value = "fixedBeginTerm", required = false) Integer fixedBeginTerm,
|
||||
@RequestParam(value = "fixedEndTerm", required = false) Integer fixedEndTerm,
|
||||
@RequestParam(value = "preferentialType") Integer preferentialType,
|
||||
@RequestParam(value = "priceOff", required = false) Integer priceOff,
|
||||
@RequestParam(value = "percentOff", required = false) Integer percentOff,
|
||||
@RequestParam(value = "discountPriceLimit", required = false) Integer discountPriceLimit) {
|
||||
@RequestParam(value = "fixedBeginTerm", required = false) Integer fixedBeginTerm,
|
||||
@RequestParam(value = "fixedEndTerm", required = false) Integer fixedEndTerm,
|
||||
@RequestParam(value = "preferentialType") Integer preferentialType,
|
||||
@RequestParam(value = "priceOff", required = false) Integer priceOff,
|
||||
@RequestParam(value = "percentOff", required = false) Integer percentOff,
|
||||
@RequestParam(value = "discountPriceLimit", required = false) Integer discountPriceLimit) {
|
||||
// 创建 CouponCardTemplateAddDTO 对象
|
||||
validStartTime = DateUtil.getDayBegin(validStartTime); // 开始时间,以当前 00:00:00 为准
|
||||
validEndTime = DateUtil.getDayBegin(validEndTime); // 结束时间,以当前 25:59:59 为准
|
||||
@@ -116,13 +116,13 @@ public class AdminsCouponTemplateController {
|
||||
@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) {
|
||||
public CommonResult<Boolean> templateCardUpdate(@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)
|
||||
@@ -138,8 +138,8 @@ public class AdminsCouponTemplateController {
|
||||
@ApiImplicitParam(name = "id", value = "Banner 编号", required = true, example = "1"),
|
||||
@ApiImplicitParam(name = "status", value = "状态。1 - 开启;2 - 禁用", required = true, example = "1"),
|
||||
})
|
||||
public CommonResult<Boolean> updateStatus(@RequestParam("id") Integer id,
|
||||
@RequestParam("status") Integer status) {
|
||||
public CommonResult<Boolean> templateUpdateStatus(@RequestParam("id") Integer id,
|
||||
@RequestParam("status") Integer status) {
|
||||
return couponService.updateCouponTemplateStatus(AdminSecurityContextHolder.getContext().getAdminId(), id, status);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("users/banner")
|
||||
@Api("Banner 模块")
|
||||
public class UsersProductCategoryController {
|
||||
public class UsersBannerController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
private BannerService bannerService;
|
||||
@@ -35,4 +35,4 @@ public class UsersProductCategoryController {
|
||||
return CommonResult.success(BannerConvert.INSTANCE.convertList(result));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
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.CouponTemplateBO;
|
||||
import cn.iocoder.mall.promotion.application.convert.CouponCardConvert;
|
||||
import cn.iocoder.mall.promotion.application.convert.CouponTemplateConvert;
|
||||
import cn.iocoder.mall.promotion.application.vo.users.UsersCouponCardVO;
|
||||
import cn.iocoder.mall.promotion.application.vo.users.UsersCouponTemplateVO;
|
||||
import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
|
||||
import com.alibaba.dubbo.config.annotation.Reference;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
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;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admins/coupon")
|
||||
@Api("优惠劵(码)模块")
|
||||
public class UsersCouponController {
|
||||
|
||||
@Reference(validation = "true")
|
||||
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).getData();
|
||||
return CommonResult.success(CouponTemplateConvert.INSTANCE.convert2(template));
|
||||
}
|
||||
|
||||
// ========== 优惠劵 ==========
|
||||
|
||||
@GetMapping("/card/add")
|
||||
@ApiOperation(value = "领取优惠劵")
|
||||
@ApiImplicitParam(name = "templateId", value = "优惠劵(码)模板编号", required = true, example = "10")
|
||||
public CommonResult<UsersCouponCardVO> cardAdd(@RequestParam("templateId") Integer templateId) {
|
||||
CommonResult<CouponCardBO> result = couponService.addCouponCard(UserSecurityContextHolder.getContext().getUserId(), templateId);
|
||||
return CouponCardConvert.INSTANCE.convert(result);
|
||||
}
|
||||
|
||||
// ========== 优惠码 ==========
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.iocoder.mall.promotion.application.convert;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.promotion.api.bo.CouponCardBO;
|
||||
import cn.iocoder.mall.promotion.application.vo.users.UsersCouponCardVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface CouponCardConvert {
|
||||
|
||||
CouponCardConvert INSTANCE = Mappers.getMapper(CouponCardConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
CommonResult<UsersCouponCardVO> convert(CommonResult<CouponCardBO> result);
|
||||
//
|
||||
// @Mappings({})
|
||||
// List<UsersCouponTemplateVO> convertList2(List<CouponTemplateBO> banners);
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ 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 cn.iocoder.mall.promotion.application.vo.users.UsersCouponTemplateVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
@@ -28,6 +29,9 @@ public interface CouponTemplateConvert {
|
||||
@Mappings({})
|
||||
List<AdminsCouponTemplateVO> convertList(List<CouponTemplateBO> templates);
|
||||
|
||||
@Mappings({})
|
||||
UsersCouponTemplateVO convert2(CouponTemplateBO template);
|
||||
|
||||
//
|
||||
// @Mappings({})
|
||||
// List<UsersCouponTemplateVO> convertList2(List<CouponTemplateBO> banners);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class AdminsCouponTemplateVO {
|
||||
// ========== 使用规则 END ==========
|
||||
|
||||
// ========== 使用效果 BEGIN ==========
|
||||
@ApiModelProperty(value = "优惠类型", example = "参见 CouponTemplatePreferentialTypeEnum 枚举")
|
||||
@ApiModelProperty(value = "优惠类型", required = true, example = "参见 CouponTemplatePreferentialTypeEnum 枚举")
|
||||
private Integer preferentialType;
|
||||
@ApiModelProperty(value = "折扣百分比")
|
||||
private Integer percentOff;
|
||||
@@ -70,11 +70,11 @@ public class AdminsCouponTemplateVO {
|
||||
// ========== 使用效果 END ==========
|
||||
|
||||
// ========== 统计信息 BEGIN ==========
|
||||
@ApiModelProperty(value = "折扣上限", required = true)
|
||||
@ApiModelProperty(value = "领取优惠券的次数", required = true)
|
||||
private Integer statFetchNum;
|
||||
// ========== 统计信息 END ==========
|
||||
|
||||
@ApiModelProperty(value = "折扣上限", required = true)
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package cn.iocoder.mall.promotion.application.vo.users;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 优惠劵 VO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class UsersCouponCardVO {
|
||||
|
||||
// ========== 基本信息 BEGIN ==========
|
||||
@ApiModelProperty(value = "优惠劵编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "模板编号,自增唯一", required = true, example = "1")
|
||||
private Integer templateId;
|
||||
@ApiModelProperty(value = "优惠码状态", required = true, example = "参见 CouponCardStatusEnum 枚举")
|
||||
private Integer status;
|
||||
|
||||
// ========== 基本信息 END ==========
|
||||
|
||||
// ========== 使用规则 BEGIN ==========
|
||||
@ApiModelProperty(value = "固定日期-生效开始时间", required = true)
|
||||
private Date validStartTime;
|
||||
@ApiModelProperty(value = "固定日期-生效结束时间", required = true)
|
||||
private Date validEndTime;
|
||||
// ========== 使用规则 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 ==========
|
||||
|
||||
// ========== 使用情况 BEGIN ==========
|
||||
/**
|
||||
* 是否使用
|
||||
*/
|
||||
@ApiModelProperty(value = "是否使用", required = true)
|
||||
private Boolean used;
|
||||
|
||||
// TODO 芋艿,后续要加优惠劵的使用日志,因为下单后,可能会取消。
|
||||
|
||||
// ========== 使用情况 END ==========
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
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 ==========
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user