Authored by tanling

拼团订单发券配置

package com.yohobuy.platform.operations.restapi;
import com.yohobuy.platform.common.restapi.ApiResponse;
import com.yohobuy.platform.model.common.ServiceException;
import com.yohobuy.platform.model.operations.GroupOrderCouponConfigRespBo;
import com.yohobuy.platform.model.operations.RedPacketRuleRespBo;
import com.yohobuy.platform.model.operations.request.GroupOrderCouponReq;
import com.yohobuy.platform.model.operations.request.RedPacketRuleReqBo;
import com.yohobuy.platform.operations.service.IGroupOrderCouponConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class GroupOrderCouponConfigController {
private static final Logger logger = LoggerFactory.getLogger(ImageCheckController.class);
@Autowired
IGroupOrderCouponConfigService groupOrderCouponConfigService;
/**
* 查询红包规则
* @return
*/
@RequestMapping("/getGroupOrderConfig")
@ResponseBody
public ApiResponse getGroupOrderConfig(){
GroupOrderCouponConfigRespBo groupOrderConfig= groupOrderCouponConfigService.getGroupOrderConfig();
return new ApiResponse.ApiResponseBuilder().data(groupOrderConfig).build();
}
/**
* 保存红包规则
* @return
*/
@RequestMapping("/saveGroupOrderCouponConfig")
@ResponseBody
public ApiResponse saveGroupOrderCouponConfig(@RequestBody GroupOrderCouponReq groupOrderCouponReq){
logger.info("saveGroupOrderCouponConfig req is {}", groupOrderCouponReq);
groupOrderCouponConfigService.saveGroupOrderCouponConfig(groupOrderCouponReq);
return new ApiResponse.ApiResponseBuilder().build();
}
}
... ...
... ... @@ -51,6 +51,8 @@ public class RedPacketConfigController {
return new ApiResponse.ApiResponseBuilder().build();
}
/**
* 查询红包规则
* @return
... ... @@ -79,7 +81,6 @@ public class RedPacketConfigController {
}catch (ServiceException e){
return new ApiResponse.ApiResponseBuilder().code(e.getCode()).message(e.getMessage()).build();
}
}
/* @RequestMapping("/deletePacket")
... ...
package com.yohobuy.platform.operations.service;
import com.yohobuy.platform.model.operations.GroupOrderCouponConfigRespBo;
import com.yohobuy.platform.model.operations.request.GroupOrderCouponReq;
public interface IGroupOrderCouponConfigService {
GroupOrderCouponConfigRespBo getGroupOrderConfig();
void saveGroupOrderCouponConfig(GroupOrderCouponReq groupOrderCouponReq);
}
... ...
package com.yohobuy.platform.operations.service.impl;
import com.yohobuy.platform.dal.promotion.IEventConfigMapper;
import com.yohobuy.platform.dal.promotion.model.EventConfig;
import com.yohobuy.platform.model.operations.GroupOrderCouponConfigRespBo;
import com.yohobuy.platform.model.operations.request.GroupOrderCouponReq;
import com.yohobuy.platform.operations.service.IGroupOrderCouponConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class GroupOrderCouponConfigServiceImpl implements IGroupOrderCouponConfigService {
@Autowired
IEventConfigMapper eventConfigMapper;
public static final String EVENT_CODE_GROUP_PAY_SUCCESS = "GROUP_PAY_SUCCESS";
public GroupOrderCouponConfigRespBo getGroupOrderConfig(){
EventConfig eventConfig = eventConfigMapper.selectOneByEventCode(EVENT_CODE_GROUP_PAY_SUCCESS);
if (eventConfig == null){
return null;
}
return GroupOrderCouponConfigRespBo.builder()
.coupons(eventConfig.getEventValue())
.popImgUrl(eventConfig.getMsgContent())
.isRepeated(eventConfig.getIsRepeat())
.onOff(eventConfig.getStatus())
.build();
}
public void saveGroupOrderCouponConfig(GroupOrderCouponReq groupOrderCouponReq){
// 后台就不考虑并发了
EventConfig eventConfig = eventConfigMapper.selectOneByEventCode(EVENT_CODE_GROUP_PAY_SUCCESS);
if (eventConfig == null){
return;
}
eventConfig.setEventValue(groupOrderCouponReq.getCoupons());
eventConfig.setMsgContent(groupOrderCouponReq.getPopImgUrl());
eventConfig.setIsRepeat(groupOrderCouponReq.getIsRepeated());
eventConfig.setStatus(groupOrderCouponReq.getOnOff());
eventConfigMapper.updateByPrimaryKeySelective(eventConfig);
}
}
... ...
... ... @@ -24,7 +24,7 @@
<dependency>
<groupId>com.yoho.service.platform.model</groupId>
<artifactId>platform-service-model</artifactId>
<version>1.2.3-6.9.5-SNAPSHOT</version>
<version>1.2.3-6.9.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yoho.dsf.yhplatform</groupId>
... ...