Showing
5 changed files
with
122 additions
and
2 deletions
1 | +package com.yohobuy.platform.operations.restapi; | ||
2 | + | ||
3 | +import com.yohobuy.platform.common.restapi.ApiResponse; | ||
4 | +import com.yohobuy.platform.model.common.ServiceException; | ||
5 | +import com.yohobuy.platform.model.operations.GroupOrderCouponConfigRespBo; | ||
6 | +import com.yohobuy.platform.model.operations.RedPacketRuleRespBo; | ||
7 | +import com.yohobuy.platform.model.operations.request.GroupOrderCouponReq; | ||
8 | +import com.yohobuy.platform.model.operations.request.RedPacketRuleReqBo; | ||
9 | +import com.yohobuy.platform.operations.service.IGroupOrderCouponConfigService; | ||
10 | +import org.slf4j.Logger; | ||
11 | +import org.slf4j.LoggerFactory; | ||
12 | +import org.springframework.beans.factory.annotation.Autowired; | ||
13 | +import org.springframework.web.bind.annotation.RequestBody; | ||
14 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
15 | +import org.springframework.web.bind.annotation.ResponseBody; | ||
16 | +import org.springframework.web.bind.annotation.RestController; | ||
17 | + | ||
18 | +@RestController | ||
19 | +public class GroupOrderCouponConfigController { | ||
20 | + | ||
21 | + private static final Logger logger = LoggerFactory.getLogger(ImageCheckController.class); | ||
22 | + | ||
23 | + @Autowired | ||
24 | + IGroupOrderCouponConfigService groupOrderCouponConfigService; | ||
25 | + | ||
26 | + /** | ||
27 | + * 查询红包规则 | ||
28 | + * @return | ||
29 | + */ | ||
30 | + @RequestMapping("/getGroupOrderConfig") | ||
31 | + @ResponseBody | ||
32 | + public ApiResponse getGroupOrderConfig(){ | ||
33 | + GroupOrderCouponConfigRespBo groupOrderConfig= groupOrderCouponConfigService.getGroupOrderConfig(); | ||
34 | + | ||
35 | + return new ApiResponse.ApiResponseBuilder().data(groupOrderConfig).build(); | ||
36 | + } | ||
37 | + | ||
38 | + | ||
39 | + /** | ||
40 | + * 保存红包规则 | ||
41 | + * @return | ||
42 | + */ | ||
43 | + @RequestMapping("/saveGroupOrderCouponConfig") | ||
44 | + @ResponseBody | ||
45 | + public ApiResponse saveGroupOrderCouponConfig(@RequestBody GroupOrderCouponReq groupOrderCouponReq){ | ||
46 | + | ||
47 | + logger.info("saveGroupOrderCouponConfig req is {}", groupOrderCouponReq); | ||
48 | + | ||
49 | + groupOrderCouponConfigService.saveGroupOrderCouponConfig(groupOrderCouponReq); | ||
50 | + return new ApiResponse.ApiResponseBuilder().build(); | ||
51 | + } | ||
52 | +} |
@@ -51,6 +51,8 @@ public class RedPacketConfigController { | @@ -51,6 +51,8 @@ public class RedPacketConfigController { | ||
51 | return new ApiResponse.ApiResponseBuilder().build(); | 51 | return new ApiResponse.ApiResponseBuilder().build(); |
52 | } | 52 | } |
53 | 53 | ||
54 | + | ||
55 | + | ||
54 | /** | 56 | /** |
55 | * 查询红包规则 | 57 | * 查询红包规则 |
56 | * @return | 58 | * @return |
@@ -79,7 +81,6 @@ public class RedPacketConfigController { | @@ -79,7 +81,6 @@ public class RedPacketConfigController { | ||
79 | }catch (ServiceException e){ | 81 | }catch (ServiceException e){ |
80 | return new ApiResponse.ApiResponseBuilder().code(e.getCode()).message(e.getMessage()).build(); | 82 | return new ApiResponse.ApiResponseBuilder().code(e.getCode()).message(e.getMessage()).build(); |
81 | } | 83 | } |
82 | - | ||
83 | } | 84 | } |
84 | 85 | ||
85 | /* @RequestMapping("/deletePacket") | 86 | /* @RequestMapping("/deletePacket") |
operations/src/main/java/com/yohobuy/platform/operations/service/IGroupOrderCouponConfigService.java
0 → 100644
1 | +package com.yohobuy.platform.operations.service; | ||
2 | + | ||
3 | + | ||
4 | +import com.yohobuy.platform.model.operations.GroupOrderCouponConfigRespBo; | ||
5 | +import com.yohobuy.platform.model.operations.request.GroupOrderCouponReq; | ||
6 | + | ||
7 | +public interface IGroupOrderCouponConfigService { | ||
8 | + | ||
9 | + GroupOrderCouponConfigRespBo getGroupOrderConfig(); | ||
10 | + | ||
11 | + void saveGroupOrderCouponConfig(GroupOrderCouponReq groupOrderCouponReq); | ||
12 | +} |
1 | +package com.yohobuy.platform.operations.service.impl; | ||
2 | + | ||
3 | + | ||
4 | +import com.yohobuy.platform.dal.promotion.IEventConfigMapper; | ||
5 | +import com.yohobuy.platform.dal.promotion.model.EventConfig; | ||
6 | +import com.yohobuy.platform.model.operations.GroupOrderCouponConfigRespBo; | ||
7 | +import com.yohobuy.platform.model.operations.request.GroupOrderCouponReq; | ||
8 | +import com.yohobuy.platform.operations.service.IGroupOrderCouponConfigService; | ||
9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
10 | +import org.springframework.stereotype.Service; | ||
11 | + | ||
12 | +@Service | ||
13 | +public class GroupOrderCouponConfigServiceImpl implements IGroupOrderCouponConfigService { | ||
14 | + | ||
15 | + @Autowired | ||
16 | + IEventConfigMapper eventConfigMapper; | ||
17 | + | ||
18 | + public static final String EVENT_CODE_GROUP_PAY_SUCCESS = "GROUP_PAY_SUCCESS"; | ||
19 | + | ||
20 | + public GroupOrderCouponConfigRespBo getGroupOrderConfig(){ | ||
21 | + | ||
22 | + EventConfig eventConfig = eventConfigMapper.selectOneByEventCode(EVENT_CODE_GROUP_PAY_SUCCESS); | ||
23 | + | ||
24 | + if (eventConfig == null){ | ||
25 | + return null; | ||
26 | + } | ||
27 | + | ||
28 | + return GroupOrderCouponConfigRespBo.builder() | ||
29 | + .coupons(eventConfig.getEventValue()) | ||
30 | + .popImgUrl(eventConfig.getMsgContent()) | ||
31 | + .isRepeated(eventConfig.getIsRepeat()) | ||
32 | + .onOff(eventConfig.getStatus()) | ||
33 | + .build(); | ||
34 | + } | ||
35 | + | ||
36 | + | ||
37 | + public void saveGroupOrderCouponConfig(GroupOrderCouponReq groupOrderCouponReq){ | ||
38 | + | ||
39 | + // 后台就不考虑并发了 | ||
40 | + EventConfig eventConfig = eventConfigMapper.selectOneByEventCode(EVENT_CODE_GROUP_PAY_SUCCESS); | ||
41 | + if (eventConfig == null){ | ||
42 | + return; | ||
43 | + } | ||
44 | + | ||
45 | + eventConfig.setEventValue(groupOrderCouponReq.getCoupons()); | ||
46 | + eventConfig.setMsgContent(groupOrderCouponReq.getPopImgUrl()); | ||
47 | + eventConfig.setIsRepeat(groupOrderCouponReq.getIsRepeated()); | ||
48 | + eventConfig.setStatus(groupOrderCouponReq.getOnOff()); | ||
49 | + | ||
50 | + eventConfigMapper.updateByPrimaryKeySelective(eventConfig); | ||
51 | + | ||
52 | + | ||
53 | + } | ||
54 | + | ||
55 | +} |
@@ -24,7 +24,7 @@ | @@ -24,7 +24,7 @@ | ||
24 | <dependency> | 24 | <dependency> |
25 | <groupId>com.yoho.service.platform.model</groupId> | 25 | <groupId>com.yoho.service.platform.model</groupId> |
26 | <artifactId>platform-service-model</artifactId> | 26 | <artifactId>platform-service-model</artifactId> |
27 | - <version>1.2.3-6.9.5-SNAPSHOT</version> | 27 | + <version>1.2.3-6.9.3-SNAPSHOT</version> |
28 | </dependency> | 28 | </dependency> |
29 | <dependency> | 29 | <dependency> |
30 | <groupId>com.yoho.dsf.yhplatform</groupId> | 30 | <groupId>com.yoho.dsf.yhplatform</groupId> |
-
Please register or login to post a comment