Showing
23 changed files
with
878 additions
and
8 deletions
@@ -14,4 +14,22 @@ | @@ -14,4 +14,22 @@ | ||
14 | <packaging>jar</packaging> | 14 | <packaging>jar</packaging> |
15 | <name>ufo-platform-coupon</name> | 15 | <name>ufo-platform-coupon</name> |
16 | 16 | ||
17 | + <dependencies> | ||
18 | + <dependency> | ||
19 | + <groupId>com.yoho.ufo</groupId> | ||
20 | + <artifactId>ufo-platform-dal</artifactId> | ||
21 | + </dependency> | ||
22 | + <dependency> | ||
23 | + <groupId>com.yoho.ufo</groupId> | ||
24 | + <artifactId>ufo-platform-common</artifactId> | ||
25 | + </dependency> | ||
26 | + <dependency> | ||
27 | + <groupId>com.yoho.ufo.model</groupId> | ||
28 | + <artifactId>coupon-ufo-model</artifactId> | ||
29 | + </dependency> | ||
30 | + <dependency> | ||
31 | + <groupId>com.yoho.core</groupId> | ||
32 | + <artifactId>yoho-core-dal</artifactId> | ||
33 | + </dependency> | ||
34 | + </dependencies> | ||
17 | </project> | 35 | </project> |
1 | +package com.yoho.ufo.coupon.controller; | ||
2 | + | ||
3 | +import com.yoho.ufo.coupon.service.ICouponService; | ||
4 | +import com.yoho.ufo.service.model.ApiResponse; | ||
5 | +import com.yohobuy.ufo.coupon.req.CouponQueryReq; | ||
6 | +import com.yohobuy.ufo.coupon.req.CouponSaveUpdateReq; | ||
7 | +import org.slf4j.Logger; | ||
8 | +import org.slf4j.LoggerFactory; | ||
9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
10 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
11 | +import org.springframework.web.bind.annotation.RestController; | ||
12 | + | ||
13 | +/** | ||
14 | + * Created by shengguo.cai on 2018/11/20. | ||
15 | + */ | ||
16 | +@RestController | ||
17 | +@RequestMapping(value = "/coupon") | ||
18 | +public class CouponController { | ||
19 | + private static final Logger LOGGER = LoggerFactory.getLogger(CouponController.class); | ||
20 | + @Autowired | ||
21 | + private ICouponService couponService; | ||
22 | + | ||
23 | + @RequestMapping(value = "/queryCoupons") | ||
24 | + public ApiResponse queryCoupons(CouponQueryReq req) { | ||
25 | + LOGGER.info("enter queryCoupons,param is {}",req); | ||
26 | + if(req == null){ | ||
27 | + return new ApiResponse.ApiResponseBuilder().code(500).message("参数有误").build(); | ||
28 | + } | ||
29 | + return this.couponService.queryCoupons(req); | ||
30 | + } | ||
31 | + | ||
32 | + @RequestMapping(value = "/saveOrUpdateCoupon") | ||
33 | + public ApiResponse saveOrUpdateCoupon(CouponSaveUpdateReq req) { | ||
34 | + LOGGER.info("enter saveOrUpdateCoupon,param is {}",req); | ||
35 | + if(req == null){ | ||
36 | + return new ApiResponse.ApiResponseBuilder().code(500).message("参数有误").build(); | ||
37 | + } | ||
38 | + return this.couponService.saveOrUpdateCoupon(req); | ||
39 | + } | ||
40 | + | ||
41 | + @RequestMapping(value = "/getCouponInfo") | ||
42 | + public ApiResponse getCouponInfo(Integer id) { | ||
43 | + LOGGER.info("enter getCouponInfo,id is {}",id); | ||
44 | + if(id == null){ | ||
45 | + return new ApiResponse.ApiResponseBuilder().code(500).message("参数有误").build(); | ||
46 | + } | ||
47 | + return this.couponService.getCouponInfo(id); | ||
48 | + } | ||
49 | +} |
1 | +package com.yoho.ufo.coupon.service; | ||
2 | + | ||
3 | +import com.yoho.ufo.service.model.ApiResponse; | ||
4 | +import com.yohobuy.ufo.coupon.req.CouponQueryReq; | ||
5 | +import com.yohobuy.ufo.coupon.req.CouponSaveUpdateReq; | ||
6 | + | ||
7 | +/** | ||
8 | + * Created by shengguo.cai on 2018/11/20. | ||
9 | + */ | ||
10 | +public interface ICouponService { | ||
11 | + ApiResponse queryCoupons(CouponQueryReq req); | ||
12 | + | ||
13 | + ApiResponse saveOrUpdateCoupon(CouponSaveUpdateReq req); | ||
14 | + | ||
15 | + ApiResponse getCouponInfo(Integer id); | ||
16 | +} |
1 | +package com.yoho.ufo.coupon.service.impl; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.JSONObject; | ||
4 | +import com.yoho.core.common.utils.DateUtil; | ||
5 | +import com.yoho.service.model.order.utils.MD5Utils; | ||
6 | +import com.yoho.ufo.coupon.service.ICouponService; | ||
7 | +import com.yoho.ufo.dal.CouponMapper; | ||
8 | +import com.yoho.ufo.dal.CouponProductLimitMapper; | ||
9 | +import com.yoho.ufo.model.coupon.Coupon; | ||
10 | +import com.yoho.ufo.model.coupon.CouponProductLimit; | ||
11 | +import com.yoho.ufo.service.model.ApiResponse; | ||
12 | +import com.yohobuy.ufo.coupon.req.CouponQueryReq; | ||
13 | +import com.yohobuy.ufo.coupon.req.CouponSaveUpdateReq; | ||
14 | +import com.yohobuy.ufo.coupon.resp.CouponQueryResp; | ||
15 | +import org.apache.commons.collections.CollectionUtils; | ||
16 | +import org.apache.commons.lang3.StringUtils; | ||
17 | +import org.slf4j.Logger; | ||
18 | +import org.slf4j.LoggerFactory; | ||
19 | +import org.springframework.beans.factory.annotation.Autowired; | ||
20 | +import org.springframework.stereotype.Service; | ||
21 | + | ||
22 | +import java.util.ArrayList; | ||
23 | +import java.util.List; | ||
24 | +import java.util.UUID; | ||
25 | + | ||
26 | +/** | ||
27 | + * Created by shengguo.cai on 2018/11/20. | ||
28 | + */ | ||
29 | +@Service | ||
30 | +public class CouponServiceImpl implements ICouponService{ | ||
31 | + private static final Logger LOGGER = LoggerFactory.getLogger(CouponServiceImpl.class); | ||
32 | + @Autowired | ||
33 | + private CouponMapper couponMapper; | ||
34 | + @Autowired | ||
35 | + private CouponProductLimitMapper couponProductLimitMapper; | ||
36 | + | ||
37 | + @Override | ||
38 | + public ApiResponse queryCoupons(CouponQueryReq req) { | ||
39 | + LOGGER.info("enter queryCoupons,param is {}",req); | ||
40 | + int total = couponMapper.selectTotalByCondition(req); | ||
41 | + JSONObject jsonObject = new JSONObject(); | ||
42 | + jsonObject.put("total",total); | ||
43 | + if(total == 0){ | ||
44 | + return new ApiResponse.ApiResponseBuilder().data(jsonObject).build(); | ||
45 | + } | ||
46 | + List<Coupon> coupons = couponMapper.selectByCondition(req); | ||
47 | + List<CouponQueryResp> couponQueryResps = initCouponQueryResps(coupons); | ||
48 | + jsonObject.put("coupons",couponQueryResps); | ||
49 | + return new ApiResponse.ApiResponseBuilder().data(jsonObject).build(); | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public ApiResponse saveOrUpdateCoupon(CouponSaveUpdateReq req) { | ||
54 | + LOGGER.info("enter saveOrUpdateCoupon,param is {}",req); | ||
55 | + if(!checkSaveOrUpdateCouponParam(req)){ | ||
56 | + return new ApiResponse.ApiResponseBuilder().code(500).message("参数有误").build(); | ||
57 | + } | ||
58 | + if(req.getId() != null){ | ||
59 | + LOGGER.info("before saveOrUpdateCoupon#deleteByCouponId,couponId is {}",req.getId()); | ||
60 | + couponProductLimitMapper.deleteByCouponId(req.getId()); | ||
61 | + } | ||
62 | + if(null == req.getId()){ | ||
63 | + req.setCouponToken(MD5Utils.md5(UUID.randomUUID().toString())); | ||
64 | + req.setCreateTime(DateUtil.getCurrentTimeSecond()); | ||
65 | + //新增时暂时写死的值 | ||
66 | + req.setProductLimitType(Coupon.PRODUCTLIMITTYPE_SPECIALPRODUCT); | ||
67 | + req.setCouponType(100); | ||
68 | + } | ||
69 | + couponMapper.insertOrUpdate(req); | ||
70 | + LOGGER.info("after saveOrUpdateCoupon#couponMapper.insertOrUpdate,req is {}",req); | ||
71 | + String[] productIds = req.getProductLimitValue().split(","); | ||
72 | + LOGGER.info("before saveOrUpdateCoupon#couponProductLimitMapper.insertBatchByProductIds,productIds is {}",productIds); | ||
73 | + couponProductLimitMapper.insertBatchByProductIds(productIds,Coupon.PRODUCTLIMITTYPE_SPECIALPRODUCT,req.getId()); | ||
74 | + return new ApiResponse(); | ||
75 | + } | ||
76 | + | ||
77 | + @Override | ||
78 | + public ApiResponse getCouponInfo(Integer id) { | ||
79 | + LOGGER.info("enter getCouponInfo, id is {}",id); | ||
80 | + Coupon coupon = couponMapper.selectById(id); | ||
81 | + List<CouponProductLimit> productLimitList = couponProductLimitMapper.selectByCouponId(id); | ||
82 | + JSONObject jsonObject = new JSONObject(); | ||
83 | + jsonObject.put("coupon",coupon); | ||
84 | + jsonObject.put("productLimits",productLimitList); | ||
85 | + return new ApiResponse.ApiResponseBuilder().data(jsonObject).build(); | ||
86 | + } | ||
87 | + | ||
88 | + private boolean checkSaveOrUpdateCouponParam(CouponSaveUpdateReq req) { | ||
89 | + if(req == null){ | ||
90 | + LOGGER.info("checkSaveOrUpdateCouponParam failed! req is null"); | ||
91 | + return false; | ||
92 | + } | ||
93 | + if(StringUtils.isBlank(req.getCouponName())){ | ||
94 | + LOGGER.info("checkSaveOrUpdateCouponParam failed! couponName is blank"); | ||
95 | + return false; | ||
96 | + } | ||
97 | + if(null == req.getCouponAmount() || req.getCouponAmount()<=0){ | ||
98 | + LOGGER.info("checkSaveOrUpdateCouponParam failed! couponAmount error! couponAmount is {}",req.getCouponAmount()); | ||
99 | + return false; | ||
100 | + } | ||
101 | + if(null == req.getCouponNum() || req.getCouponNum()<=0){ | ||
102 | + LOGGER.info("checkSaveOrUpdateCouponParam failed! couponNum error! couponNum is {}",req.getCouponNum()); | ||
103 | + return false; | ||
104 | + } | ||
105 | + if(null == req.getUseNum() || req.getUseNum()<=0){ | ||
106 | + LOGGER.info("checkSaveOrUpdateCouponParam failed! useNum error! useNum is {}",req.getUseNum()); | ||
107 | + return false; | ||
108 | + } | ||
109 | + if(null == req.getStartTime() || req.getStartTime()<=0){ | ||
110 | + LOGGER.info("checkSaveOrUpdateCouponParam failed! startTime error! startTime is {}",req.getStartTime()); | ||
111 | + return false; | ||
112 | + } | ||
113 | + if(null == req.getEndTime() || req.getEndTime()<=0){ | ||
114 | + LOGGER.info("checkSaveOrUpdateCouponParam failed! endTime error! endTime is {}",req.getEndTime()); | ||
115 | + return false; | ||
116 | + } | ||
117 | + if(req.getEndTime()<req.getStartTime()){ | ||
118 | + LOGGER.info("checkSaveOrUpdateCouponParam failed! endTime < startTime!endTime is {},startTime is {}" | ||
119 | + ,req.getEndTime(),req.getStartTime()); | ||
120 | + return false; | ||
121 | + } | ||
122 | + if(StringUtils.isBlank(req.getRemark())){ | ||
123 | + LOGGER.info("checkSaveOrUpdateCouponParam failed! remark is blank."); | ||
124 | + return false; | ||
125 | + } | ||
126 | + if(StringUtils.isBlank(req.getProductLimitValue())){ | ||
127 | + LOGGER.info("checkSaveOrUpdateCouponParam failed! productLimitValue is blank."); | ||
128 | + return false; | ||
129 | + } | ||
130 | + return checkUpdateCouponParam(req); | ||
131 | + } | ||
132 | + | ||
133 | + private boolean checkUpdateCouponParam(CouponSaveUpdateReq req) { | ||
134 | + if(req.getId() == null){ | ||
135 | + return true; | ||
136 | + } | ||
137 | + Coupon coupon = couponMapper.selectById(req.getId()); | ||
138 | + if(coupon == null){ | ||
139 | + LOGGER.info("checkUpdateCouponParam failed! coupon is null.id is {}",req.getId()); | ||
140 | + return false; | ||
141 | + } | ||
142 | + if(coupon.getStartTime()< DateUtil.currentTimeSeconds()){ | ||
143 | + LOGGER.info("checkUpdateCouponParam failed! coupon is using! startTime is {}",coupon.getStartTime()); | ||
144 | + return false; | ||
145 | + } | ||
146 | + return true; | ||
147 | + } | ||
148 | + | ||
149 | + private List<CouponQueryResp> initCouponQueryResps(List<Coupon> coupons) { | ||
150 | + if(CollectionUtils.isEmpty(coupons)){ | ||
151 | + return null; | ||
152 | + } | ||
153 | + List<CouponQueryResp> resps = new ArrayList<>(); | ||
154 | + for(Coupon coupon : coupons){ | ||
155 | + CouponQueryResp resp = new CouponQueryResp(coupon.getId(),coupon.getCouponName(),coupon.getCouponAmount(), | ||
156 | + coupon.getStartTime(),coupon.getEndTime(),coupon.getRemark(), Coupon.CouponStatusEnum.getKey(coupon.getStatus())); | ||
157 | + resps.add(resp); | ||
158 | + } | ||
159 | + return resps; | ||
160 | + } | ||
161 | +} |
@@ -32,6 +32,10 @@ | @@ -32,6 +32,10 @@ | ||
32 | <artifactId>resource-ufo-model</artifactId> | 32 | <artifactId>resource-ufo-model</artifactId> |
33 | </dependency> | 33 | </dependency> |
34 | <dependency> | 34 | <dependency> |
35 | + <groupId>com.yoho.ufo.model</groupId> | ||
36 | + <artifactId>coupon-ufo-model</artifactId> | ||
37 | + </dependency> | ||
38 | + <dependency> | ||
35 | <groupId>com.yoho.ufo</groupId> | 39 | <groupId>com.yoho.ufo</groupId> |
36 | <artifactId>ufo-platform-common</artifactId> | 40 | <artifactId>ufo-platform-common</artifactId> |
37 | </dependency> | 41 | </dependency> |
1 | +package com.yoho.ufo.dal; | ||
2 | + | ||
3 | +import com.yoho.ufo.model.coupon.Coupon; | ||
4 | +import com.yohobuy.ufo.coupon.req.CouponQueryReq; | ||
5 | +import com.yohobuy.ufo.coupon.req.CouponSaveUpdateReq; | ||
6 | +import org.apache.ibatis.annotations.Param; | ||
7 | + | ||
8 | +import java.util.List; | ||
9 | + | ||
10 | +/** | ||
11 | + * Created by shengguo.cai on 2018/11/20. | ||
12 | + */ | ||
13 | +public interface CouponMapper { | ||
14 | + int selectTotalByCondition(@Param("param") CouponQueryReq param); | ||
15 | + | ||
16 | + List<Coupon> selectByCondition(@Param("param") CouponQueryReq param); | ||
17 | + | ||
18 | + Coupon selectById(@Param("id") Integer id); | ||
19 | + | ||
20 | + void insertOrUpdate(@Param("param") CouponSaveUpdateReq param); | ||
21 | +} |
1 | +package com.yoho.ufo.dal; | ||
2 | + | ||
3 | +import com.yoho.ufo.model.coupon.CouponProductLimit; | ||
4 | +import org.apache.ibatis.annotations.Param; | ||
5 | + | ||
6 | +import java.util.List; | ||
7 | + | ||
8 | +/** | ||
9 | + * Created by shengguo.cai on 2018/11/20. | ||
10 | + */ | ||
11 | +public interface CouponProductLimitMapper { | ||
12 | + void deleteByCouponId(@Param("id") Integer id); | ||
13 | + | ||
14 | + void insertBatchByProductIds(@Param("productIds") String[] productIds, @Param("limitType") int limitType, @Param("couponId") int couponId); | ||
15 | + | ||
16 | + List<CouponProductLimit> selectByCouponId(@Param("id") Integer id); | ||
17 | + | ||
18 | +} |
1 | package com.yoho.ufo.dal; | 1 | package com.yoho.ufo.dal; |
2 | 2 | ||
3 | import com.yoho.ufo.model.resource.ResourcesContentData; | 3 | import com.yoho.ufo.model.resource.ResourcesContentData; |
4 | -import com.yohobuy.ufo.model.req.ResContentDataModifyBo; | 4 | +import com.yohobuy.ufo.resource.req.ResContentDataModifyBo; |
5 | import org.apache.ibatis.annotations.Param; | 5 | import org.apache.ibatis.annotations.Param; |
6 | 6 | ||
7 | import java.util.List; | 7 | import java.util.List; |
1 | package com.yoho.ufo.dal; | 1 | package com.yoho.ufo.dal; |
2 | 2 | ||
3 | import com.yoho.ufo.model.resource.ResourcesGoodsPool; | 3 | import com.yoho.ufo.model.resource.ResourcesGoodsPool; |
4 | -import com.yohobuy.ufo.model.req.ResGoodsPoolEditBo; | 4 | +import com.yohobuy.ufo.resource.req.ResGoodsPoolEditBo; |
5 | import org.apache.ibatis.annotations.Param; | 5 | import org.apache.ibatis.annotations.Param; |
6 | 6 | ||
7 | import java.util.List; | 7 | import java.util.List; |
1 | +package com.yoho.ufo.model.coupon; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by shengguo.cai on 2018/11/20. | ||
7 | + */ | ||
8 | +public class Coupon implements Serializable { | ||
9 | + | ||
10 | + private Integer id; | ||
11 | + private String couponToken; | ||
12 | + private String couponName; | ||
13 | + private Float couponAmount; | ||
14 | + private Integer couponType; | ||
15 | + private Integer couponNum; | ||
16 | + private Integer useNum; | ||
17 | + private Integer sendNum; | ||
18 | + private Integer useLimitType; | ||
19 | + private Integer useLimitValue; | ||
20 | + private Integer productLimitType; | ||
21 | + private String productLimitValue; | ||
22 | + private Integer startTime; | ||
23 | + private Integer endTime; | ||
24 | + private Integer status; | ||
25 | + private Integer createTime; | ||
26 | + private Integer pid; | ||
27 | + private String remark; | ||
28 | + /**商品限制条件-特定商品*/ | ||
29 | + public static final int PRODUCTLIMITTYPE_SPECIALPRODUCT = 1; | ||
30 | + public enum CouponStatusEnum { | ||
31 | + //0:待审核,1:有效,2:审核驳回,3:作废 | ||
32 | + WAITE_CHECK(0,"待审核"),IN_EFFECT(1,"有效"),REVIEW_REJECTION(2,"审核驳回"),INVALID(3,"作废"); | ||
33 | + private int value; | ||
34 | + private String key; | ||
35 | + | ||
36 | + CouponStatusEnum(int value, String key) { | ||
37 | + this.value = value; | ||
38 | + this.key = key; | ||
39 | + } | ||
40 | + public static String getKey(int value){ | ||
41 | + for(CouponStatusEnum cs : values()){ | ||
42 | + if(cs.value == value){ | ||
43 | + return cs.key; | ||
44 | + } | ||
45 | + } | ||
46 | + return null; | ||
47 | + } | ||
48 | + } | ||
49 | + | ||
50 | + public Integer getId() { | ||
51 | + return id; | ||
52 | + } | ||
53 | + | ||
54 | + public void setId(Integer id) { | ||
55 | + this.id = id; | ||
56 | + } | ||
57 | + | ||
58 | + public String getCouponToken() { | ||
59 | + return couponToken; | ||
60 | + } | ||
61 | + | ||
62 | + public void setCouponToken(String couponToken) { | ||
63 | + this.couponToken = couponToken; | ||
64 | + } | ||
65 | + | ||
66 | + public String getCouponName() { | ||
67 | + return couponName; | ||
68 | + } | ||
69 | + | ||
70 | + public void setCouponName(String couponName) { | ||
71 | + this.couponName = couponName; | ||
72 | + } | ||
73 | + | ||
74 | + public Float getCouponAmount() { | ||
75 | + return couponAmount; | ||
76 | + } | ||
77 | + | ||
78 | + public void setCouponAmount(Float couponAmount) { | ||
79 | + this.couponAmount = couponAmount; | ||
80 | + } | ||
81 | + | ||
82 | + public Integer getCouponType() { | ||
83 | + return couponType; | ||
84 | + } | ||
85 | + | ||
86 | + public void setCouponType(Integer couponType) { | ||
87 | + this.couponType = couponType; | ||
88 | + } | ||
89 | + | ||
90 | + public Integer getCouponNum() { | ||
91 | + return couponNum; | ||
92 | + } | ||
93 | + | ||
94 | + public void setCouponNum(Integer couponNum) { | ||
95 | + this.couponNum = couponNum; | ||
96 | + } | ||
97 | + | ||
98 | + public Integer getUseNum() { | ||
99 | + return useNum; | ||
100 | + } | ||
101 | + | ||
102 | + public void setUseNum(Integer useNum) { | ||
103 | + this.useNum = useNum; | ||
104 | + } | ||
105 | + | ||
106 | + public Integer getSendNum() { | ||
107 | + return sendNum; | ||
108 | + } | ||
109 | + | ||
110 | + public void setSendNum(Integer sendNum) { | ||
111 | + this.sendNum = sendNum; | ||
112 | + } | ||
113 | + | ||
114 | + public Integer getUseLimitType() { | ||
115 | + return useLimitType; | ||
116 | + } | ||
117 | + | ||
118 | + public void setUseLimitType(Integer useLimitType) { | ||
119 | + this.useLimitType = useLimitType; | ||
120 | + } | ||
121 | + | ||
122 | + public Integer getUseLimitValue() { | ||
123 | + return useLimitValue; | ||
124 | + } | ||
125 | + | ||
126 | + public void setUseLimitValue(Integer useLimitValue) { | ||
127 | + this.useLimitValue = useLimitValue; | ||
128 | + } | ||
129 | + | ||
130 | + public Integer getProductLimitType() { | ||
131 | + return productLimitType; | ||
132 | + } | ||
133 | + | ||
134 | + public void setProductLimitType(Integer productLimitType) { | ||
135 | + this.productLimitType = productLimitType; | ||
136 | + } | ||
137 | + | ||
138 | + public String getProductLimitValue() { | ||
139 | + return productLimitValue; | ||
140 | + } | ||
141 | + | ||
142 | + public void setProductLimitValue(String productLimitValue) { | ||
143 | + this.productLimitValue = productLimitValue; | ||
144 | + } | ||
145 | + | ||
146 | + public Integer getStartTime() { | ||
147 | + return startTime; | ||
148 | + } | ||
149 | + | ||
150 | + public void setStartTime(Integer startTime) { | ||
151 | + this.startTime = startTime; | ||
152 | + } | ||
153 | + | ||
154 | + public Integer getEndTime() { | ||
155 | + return endTime; | ||
156 | + } | ||
157 | + | ||
158 | + public void setEndTime(Integer endTime) { | ||
159 | + this.endTime = endTime; | ||
160 | + } | ||
161 | + | ||
162 | + public Integer getStatus() { | ||
163 | + return status; | ||
164 | + } | ||
165 | + | ||
166 | + public void setStatus(Integer status) { | ||
167 | + this.status = status; | ||
168 | + } | ||
169 | + | ||
170 | + public Integer getCreateTime() { | ||
171 | + return createTime; | ||
172 | + } | ||
173 | + | ||
174 | + public void setCreateTime(Integer createTime) { | ||
175 | + this.createTime = createTime; | ||
176 | + } | ||
177 | + | ||
178 | + public Integer getPid() { | ||
179 | + return pid; | ||
180 | + } | ||
181 | + | ||
182 | + public void setPid(Integer pid) { | ||
183 | + this.pid = pid; | ||
184 | + } | ||
185 | + | ||
186 | + public String getRemark() { | ||
187 | + return remark; | ||
188 | + } | ||
189 | + | ||
190 | + public void setRemark(String remark) { | ||
191 | + this.remark = remark; | ||
192 | + } | ||
193 | +} |
1 | +package com.yoho.ufo.model.coupon; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by shengguo.cai on 2018/11/20. | ||
7 | + */ | ||
8 | +public class CouponProductLimit implements Serializable { | ||
9 | + private Integer id; | ||
10 | + private Integer couponId; | ||
11 | + private Integer limitType; | ||
12 | + private Integer productSkn; | ||
13 | + | ||
14 | + public Integer getId() { | ||
15 | + return id; | ||
16 | + } | ||
17 | + | ||
18 | + public void setId(Integer id) { | ||
19 | + this.id = id; | ||
20 | + } | ||
21 | + | ||
22 | + public Integer getCouponId() { | ||
23 | + return couponId; | ||
24 | + } | ||
25 | + | ||
26 | + public void setCouponId(Integer couponId) { | ||
27 | + this.couponId = couponId; | ||
28 | + } | ||
29 | + | ||
30 | + public Integer getLimitType() { | ||
31 | + return limitType; | ||
32 | + } | ||
33 | + | ||
34 | + public void setLimitType(Integer limitType) { | ||
35 | + this.limitType = limitType; | ||
36 | + } | ||
37 | + | ||
38 | + public Integer getProductSkn() { | ||
39 | + return productSkn; | ||
40 | + } | ||
41 | + | ||
42 | + public void setProductSkn(Integer productSkn) { | ||
43 | + this.productSkn = productSkn; | ||
44 | + } | ||
45 | +} |
1 | +package com.yoho.ufo.model.coupon; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by shengguo.cai on 2018/11/20. | ||
7 | + */ | ||
8 | +public class CouponType implements Serializable { | ||
9 | + private Integer id; | ||
10 | + private String caption; | ||
11 | + private String alphabet; | ||
12 | + | ||
13 | + public Integer getId() { | ||
14 | + return id; | ||
15 | + } | ||
16 | + | ||
17 | + public void setId(Integer id) { | ||
18 | + this.id = id; | ||
19 | + } | ||
20 | + | ||
21 | + public String getCaption() { | ||
22 | + return caption; | ||
23 | + } | ||
24 | + | ||
25 | + public void setCaption(String caption) { | ||
26 | + this.caption = caption; | ||
27 | + } | ||
28 | + | ||
29 | + public String getAlphabet() { | ||
30 | + return alphabet; | ||
31 | + } | ||
32 | + | ||
33 | + public void setAlphabet(String alphabet) { | ||
34 | + this.alphabet = alphabet; | ||
35 | + } | ||
36 | +} |
1 | +package com.yoho.ufo.model.coupon; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by shengguo.cai on 2018/11/20. | ||
7 | + */ | ||
8 | +public class UserCoupon implements Serializable { | ||
9 | + private Integer id; | ||
10 | + private Integer uid; | ||
11 | + private Integer couponId; | ||
12 | + private Integer couponType; | ||
13 | + private String couponCode; | ||
14 | + private Integer status; | ||
15 | + private Integer orderCode; | ||
16 | + private Integer useTime; | ||
17 | + private Integer startTime; | ||
18 | + private Integer endTime; | ||
19 | + private Integer createTime; | ||
20 | + private String couponToken; | ||
21 | + | ||
22 | + public Integer getId() { | ||
23 | + return id; | ||
24 | + } | ||
25 | + | ||
26 | + public void setId(Integer id) { | ||
27 | + this.id = id; | ||
28 | + } | ||
29 | + | ||
30 | + public Integer getUid() { | ||
31 | + return uid; | ||
32 | + } | ||
33 | + | ||
34 | + public void setUid(Integer uid) { | ||
35 | + this.uid = uid; | ||
36 | + } | ||
37 | + | ||
38 | + public Integer getCouponId() { | ||
39 | + return couponId; | ||
40 | + } | ||
41 | + | ||
42 | + public void setCouponId(Integer couponId) { | ||
43 | + this.couponId = couponId; | ||
44 | + } | ||
45 | + | ||
46 | + public Integer getCouponType() { | ||
47 | + return couponType; | ||
48 | + } | ||
49 | + | ||
50 | + public void setCouponType(Integer couponType) { | ||
51 | + this.couponType = couponType; | ||
52 | + } | ||
53 | + | ||
54 | + public String getCouponCode() { | ||
55 | + return couponCode; | ||
56 | + } | ||
57 | + | ||
58 | + public void setCouponCode(String couponCode) { | ||
59 | + this.couponCode = couponCode; | ||
60 | + } | ||
61 | + | ||
62 | + public Integer getStatus() { | ||
63 | + return status; | ||
64 | + } | ||
65 | + | ||
66 | + public void setStatus(Integer status) { | ||
67 | + this.status = status; | ||
68 | + } | ||
69 | + | ||
70 | + public Integer getOrderCode() { | ||
71 | + return orderCode; | ||
72 | + } | ||
73 | + | ||
74 | + public void setOrderCode(Integer orderCode) { | ||
75 | + this.orderCode = orderCode; | ||
76 | + } | ||
77 | + | ||
78 | + public Integer getUseTime() { | ||
79 | + return useTime; | ||
80 | + } | ||
81 | + | ||
82 | + public void setUseTime(Integer useTime) { | ||
83 | + this.useTime = useTime; | ||
84 | + } | ||
85 | + | ||
86 | + public Integer getStartTime() { | ||
87 | + return startTime; | ||
88 | + } | ||
89 | + | ||
90 | + public void setStartTime(Integer startTime) { | ||
91 | + this.startTime = startTime; | ||
92 | + } | ||
93 | + | ||
94 | + public Integer getEndTime() { | ||
95 | + return endTime; | ||
96 | + } | ||
97 | + | ||
98 | + public void setEndTime(Integer endTime) { | ||
99 | + this.endTime = endTime; | ||
100 | + } | ||
101 | + | ||
102 | + public Integer getCreateTime() { | ||
103 | + return createTime; | ||
104 | + } | ||
105 | + | ||
106 | + public void setCreateTime(Integer createTime) { | ||
107 | + this.createTime = createTime; | ||
108 | + } | ||
109 | + | ||
110 | + public String getCouponToken() { | ||
111 | + return couponToken; | ||
112 | + } | ||
113 | + | ||
114 | + public void setCouponToken(String couponToken) { | ||
115 | + this.couponToken = couponToken; | ||
116 | + } | ||
117 | +} |
1 | +<?xml version="1.0" encoding="UTF-8" ?> | ||
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
3 | +<mapper namespace="com.yoho.ufo.dal.CouponMapper"> | ||
4 | + <resultMap id="BaseResultMap" type="com.yoho.ufo.model.coupon.Coupon"> | ||
5 | + <result column="id" property="id" jdbcType="INTEGER" /> | ||
6 | + <result column="coupon_token" property="couponToken" jdbcType="VARCHAR" /> | ||
7 | + <result column="coupon_name" property="couponName" jdbcType="VARCHAR" /> | ||
8 | + <result column="coupon_amount" property="couponAmount" jdbcType="FLOAT" /> | ||
9 | + <result column="coupon_type" property="couponType" jdbcType="INTEGER" /> | ||
10 | + <result column="coupon_num" property="couponNum" jdbcType="INTEGER" /> | ||
11 | + <result column="use_num" property="useNum" jdbcType="INTEGER" /> | ||
12 | + <result column="send_num" property="sendNum" jdbcType="INTEGER" /> | ||
13 | + <result column="use_limit_type" property="useLimitType" jdbcType="INTEGER" /> | ||
14 | + <result column="use_limit_value" property="useLimitValue" jdbcType="INTEGER" /> | ||
15 | + <result column="product_limit_type" property="productLimitType" jdbcType="INTEGER" /> | ||
16 | + <result column="product_limit_value" property="productLimitValue" jdbcType="VARCHAR" /> | ||
17 | + <result column="start_time" property="startTime" jdbcType="INTEGER" /> | ||
18 | + <result column="end_time" property="endTime" jdbcType="INTEGER" /> | ||
19 | + <result column="status" property="status" jdbcType="INTEGER" /> | ||
20 | + <result column="create_time" property="createTime" jdbcType="INTEGER" /> | ||
21 | + <result column="pid" property="pid" jdbcType="INTEGER" /> | ||
22 | + <result column="remark" property="remark" jdbcType="VARCHAR" /> | ||
23 | + </resultMap> | ||
24 | + | ||
25 | + <sql id="Base_Column_List"> | ||
26 | + id,coupon_token,coupon_name,coupon_amount,coupon_type,coupon_num,use_num,send_num, | ||
27 | + use_limit_type,use_limit_value,product_limit_type,product_limit_value,start_time, | ||
28 | + end_time,status,create_time,pid,remark | ||
29 | + </sql> | ||
30 | + <insert id="insertOrUpdate" useGeneratedKeys="true" keyProperty="id"> | ||
31 | + insert into coupon(id,coupon_token,coupon_name,coupon_amount,coupon_type,coupon_num,use_num,send_num, | ||
32 | + use_limit_type, | ||
33 | + <if test="param.useLimitType == 2"> | ||
34 | + use_limit_value, | ||
35 | + </if> | ||
36 | + product_limit_type, | ||
37 | + <if test="param.productLimitType != 1"> | ||
38 | + product_limit_value, | ||
39 | + </if> | ||
40 | + start_time,end_time,status,create_time,pid,remark) | ||
41 | + values(#{param.id},#{param.couponToken},#{param.couponName},#{param.couponAmount},#{param.couponType} | ||
42 | + ,#{param.couponNum},#{param.useNum},#{param.sendNum},#{param.useLimitType}, | ||
43 | + <if test="param.useLimitType == 2"> | ||
44 | + #{param.useLimitValue}, | ||
45 | + </if> | ||
46 | + #{param.productLimitType}, | ||
47 | + <if test="param.productLimitType != 1"> | ||
48 | + #{param.productLimitValue}, | ||
49 | + </if> | ||
50 | + #{param.startTime},#{param.endTime},#{param.status},#{param.createTime},#{param.pid},#{param.remark}) | ||
51 | + on duplicate key update | ||
52 | + coupon_name=#{param.couponName},coupon_amount=#{param.couponAmount},coupon_type=#{param.couponType},coupon_num=#{param.couponNum} | ||
53 | + ,use_num=#{param.useNum},send_num=#{param.sendNum}, | ||
54 | + use_limit_type=#{param.useLimitType}, | ||
55 | + <if test="param.useLimitType == 2"> | ||
56 | + use_limit_value=#{param.useLimitValue}, | ||
57 | + </if> | ||
58 | + product_limit_type=#{param.productLimitType}, | ||
59 | + <if test="param.productLimitType != 1"> | ||
60 | + product_limit_value=#{param.productLimitValue}, | ||
61 | + </if> | ||
62 | + start_time=#{param.startTime},end_time=#{param.endTime},status=#{param.status},pid=#{param.pid},remark=#{param.remark} | ||
63 | + </insert> | ||
64 | + <select id="selectTotalByCondition" resultType="java.lang.Integer"> | ||
65 | + select count(1) from coupon where 1=1 | ||
66 | + <if test="param.id != null"> | ||
67 | + and id=#{param.id} | ||
68 | + </if> | ||
69 | + <if test="param.couponName != null"> | ||
70 | + and coupon_name=#{param.couponName} | ||
71 | + </if> | ||
72 | + <if test="param.status != null"> | ||
73 | + and status=#{param.status} | ||
74 | + </if> | ||
75 | + <if test="param.startTime != null"> | ||
76 | + and start_time>=#{param.startTime} | ||
77 | + </if> | ||
78 | + <if test="param.endTime != null"> | ||
79 | + and end_time <![CDATA[<= ]]> #{param.endTime} | ||
80 | + </if> | ||
81 | + </select> | ||
82 | + <select id="selectByCondition" resultType="com.yoho.ufo.model.coupon.Coupon"> | ||
83 | + select <include refid="Base_Column_List" /> from coupon where 1=1 | ||
84 | + <if test="param.id != null"> | ||
85 | + and id=#{param.id} | ||
86 | + </if> | ||
87 | + <if test="param.couponName != null"> | ||
88 | + and coupon_name=#{param.couponName} | ||
89 | + </if> | ||
90 | + <if test="param.status != null"> | ||
91 | + and status=#{param.status} | ||
92 | + </if> | ||
93 | + <if test="param.startTime != null"> | ||
94 | + and start_time>=#{param.startTime} | ||
95 | + </if> | ||
96 | + <if test="param.endTime != null"> | ||
97 | + and end_time <![CDATA[<= ]]> #{param.endTime} | ||
98 | + </if> | ||
99 | + order by id desc | ||
100 | + limit #{param.start},#{param.size} | ||
101 | + </select> | ||
102 | + <select id="selectById" resultType="com.yoho.ufo.model.coupon.Coupon"> | ||
103 | + select <include refid="Base_Column_List" /> from coupon where id=#{id} limit 1; | ||
104 | + </select> | ||
105 | +</mapper> |
1 | +<?xml version="1.0" encoding="UTF-8" ?> | ||
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
3 | +<mapper namespace="com.yoho.ufo.dal.CouponProductLimitMapper"> | ||
4 | + <resultMap id="BaseResultMap" type="com.yoho.ufo.model.coupon.CouponProductLimit"> | ||
5 | + <result column="id" property="id" jdbcType="INTEGER" /> | ||
6 | + <result column="coupon_id" property="couponId" jdbcType="INTEGER" /> | ||
7 | + <result column="limit_type" property="limitType" jdbcType="INTEGER" /> | ||
8 | + <result column="product_skn" property="productSkn" jdbcType="INTEGER" /> | ||
9 | + </resultMap> | ||
10 | + | ||
11 | + <sql id="Base_Column_List"> | ||
12 | + id,coupon_id,limit_type,product_skn | ||
13 | + </sql> | ||
14 | + <insert id="insertBatchByProductIds"> | ||
15 | + insert into coupon_product_limit( | ||
16 | + coupon_id, | ||
17 | + limit_type, | ||
18 | + product_id)values | ||
19 | + <foreach collection="productIds" separator="," item="productId"> | ||
20 | + (#{couponId},#{limitType},#{productId}) | ||
21 | + </foreach> | ||
22 | + </insert> | ||
23 | + <delete id="deleteByCouponId"> | ||
24 | + delete from coupon_product_limit where coupon_id=#{id} | ||
25 | + </delete> | ||
26 | + <select id="selectByCouponId" resultType="com.yoho.ufo.model.coupon.CouponProductLimit"> | ||
27 | + select <include refid="Base_Column_List" /> from coupon_product_limit where coupon_id=#{id} | ||
28 | + </select> | ||
29 | +</mapper> |
1 | +<?xml version="1.0" encoding="UTF-8" ?> | ||
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
3 | +<mapper namespace="com.yoho.ufo.dal.CouponTypeMapper"> | ||
4 | + <resultMap id="BaseResultMap" type="com.yoho.ufo.model.coupon.CouponType"> | ||
5 | + <result column="id" property="id" jdbcType="INTEGER" /> | ||
6 | + <result column="caption" property="caption" jdbcType="VARCHAR" /> | ||
7 | + <result column="alphabet" property="alphabet" jdbcType="VARCHAR" /> | ||
8 | + </resultMap> | ||
9 | + | ||
10 | + <sql id="Base_Column_List"> | ||
11 | + id,caption,alphabet | ||
12 | + </sql> | ||
13 | +</mapper> |
1 | +<?xml version="1.0" encoding="UTF-8" ?> | ||
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
3 | +<mapper namespace="com.yoho.ufo.dal.UserCouponMapper"> | ||
4 | + <resultMap id="BaseResultMap" type="com.yoho.ufo.model.coupon.UserCoupon"> | ||
5 | + <result column="id" property="id" jdbcType="INTEGER" /> | ||
6 | + <result column="uid" property="uid" jdbcType="INTEGER" /> | ||
7 | + <result column="coupon_id" property="couponId" jdbcType="INTEGER" /> | ||
8 | + <result column="coupon_type" property="couponType" jdbcType="INTEGER" /> | ||
9 | + <result column="coupon_code" property="couponCode" jdbcType="VARCHAR" /> | ||
10 | + <result column="status" property="status" jdbcType="INTEGER" /> | ||
11 | + <result column="order_code" property="orderCode" jdbcType="INTEGER" /> | ||
12 | + <result column="use_time" property="useTime" jdbcType="INTEGER" /> | ||
13 | + <result column="start_time" property="startTime" jdbcType="INTEGER" /> | ||
14 | + <result column="end_time" property="endTime" jdbcType="INTEGER" /> | ||
15 | + <result column="create_time" property="createTime" jdbcType="INTEGER" /> | ||
16 | + <result column="coupon_token" property="couponToken" jdbcType="VARCHAR" /> | ||
17 | + </resultMap> | ||
18 | + | ||
19 | + <sql id="Base_Column_List"> | ||
20 | + id,uid,coupon_id,coupon_type,coupon_code,status,order_code,use_time,start_time,end_time,create_time,coupon_token | ||
21 | + </sql> | ||
22 | +</mapper> |
@@ -45,6 +45,11 @@ | @@ -45,6 +45,11 @@ | ||
45 | <version>${ufo.model.version}</version> | 45 | <version>${ufo.model.version}</version> |
46 | </dependency> | 46 | </dependency> |
47 | <dependency> | 47 | <dependency> |
48 | + <groupId>com.yoho.ufo.model</groupId> | ||
49 | + <artifactId>coupon-ufo-model</artifactId> | ||
50 | + <version>${ufo.model.version}</version> | ||
51 | + </dependency> | ||
52 | + <dependency> | ||
48 | <groupId>com.yoho.ufo</groupId> | 53 | <groupId>com.yoho.ufo</groupId> |
49 | <artifactId>ufo-platform-dal</artifactId> | 54 | <artifactId>ufo-platform-dal</artifactId> |
50 | <version>${project.version}</version> | 55 | <version>${project.version}</version> |
@@ -4,9 +4,9 @@ import com.alibaba.fastjson.JSONObject; | @@ -4,9 +4,9 @@ import com.alibaba.fastjson.JSONObject; | ||
4 | import com.yoho.ufo.resource.service.IResourceService; | 4 | import com.yoho.ufo.resource.service.IResourceService; |
5 | import com.yoho.ufo.service.model.ApiResponse; | 5 | import com.yoho.ufo.service.model.ApiResponse; |
6 | import com.yoho.ufo.service.model.PageRequestBO; | 6 | import com.yoho.ufo.service.model.PageRequestBO; |
7 | -import com.yohobuy.ufo.model.req.ResContentDataModifyBo; | ||
8 | -import com.yohobuy.ufo.model.req.ResGoodsPoolEditBo; | ||
9 | -import com.yohobuy.ufo.model.resp.ResourceGetBo; | 7 | +import com.yohobuy.ufo.resource.req.ResContentDataModifyBo; |
8 | +import com.yohobuy.ufo.resource.req.ResGoodsPoolEditBo; | ||
9 | +import com.yohobuy.ufo.resource.resp.ResourceGetBo; | ||
10 | import org.apache.commons.collections.CollectionUtils; | 10 | import org.apache.commons.collections.CollectionUtils; |
11 | import org.apache.commons.lang3.StringUtils; | 11 | import org.apache.commons.lang3.StringUtils; |
12 | import org.slf4j.Logger; | 12 | import org.slf4j.Logger; |
@@ -2,9 +2,9 @@ package com.yoho.ufo.resource.service; | @@ -2,9 +2,9 @@ package com.yoho.ufo.resource.service; | ||
2 | 2 | ||
3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
4 | import com.yoho.ufo.service.model.PageRequestBO; | 4 | import com.yoho.ufo.service.model.PageRequestBO; |
5 | -import com.yohobuy.ufo.model.req.ResContentDataModifyBo; | ||
6 | -import com.yohobuy.ufo.model.req.ResGoodsPoolEditBo; | ||
7 | -import com.yohobuy.ufo.model.resp.ResourceGetBo; | 5 | +import com.yohobuy.ufo.resource.req.ResContentDataModifyBo; |
6 | +import com.yohobuy.ufo.resource.req.ResGoodsPoolEditBo; | ||
7 | +import com.yohobuy.ufo.resource.resp.ResourceGetBo; | ||
8 | 8 | ||
9 | import java.util.List; | 9 | import java.util.List; |
10 | 10 |
@@ -41,6 +41,10 @@ | @@ -41,6 +41,10 @@ | ||
41 | </dependency> | 41 | </dependency> |
42 | <dependency> | 42 | <dependency> |
43 | <groupId>com.yoho.ufo</groupId> | 43 | <groupId>com.yoho.ufo</groupId> |
44 | + <artifactId>ufo-platform-coupon</artifactId> | ||
45 | + </dependency> | ||
46 | + <dependency> | ||
47 | + <groupId>com.yoho.ufo</groupId> | ||
44 | <artifactId>ufo-platform-common</artifactId> | 48 | <artifactId>ufo-platform-common</artifactId> |
45 | </dependency> | 49 | </dependency> |
46 | <dependency> | 50 | <dependency> |
-
Please register or login to post a comment