dev-discount
yuanye 3 years ago
parent 42a04956a9
commit 9626458034
  1. 12
      hai-bweb/src/main/java/com/bweb/controller/HighActivityController.java
  2. 2
      hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java
  3. 70
      hai-service/src/main/java/com/hai/service/impl/HighActivityAwardServiceImpl.java
  4. 3
      hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java

@ -35,8 +35,8 @@ import java.util.*;
* @author hurui
*/
@Controller
@RequestMapping(value = "/activity")
@Api(value = "活动业务接口")
@RequestMapping(value = "/activityAward")
@Api(value = "活动奖励接口")
public class HighActivityController {
private static Logger log = LoggerFactory.getLogger(HighActivityController.class);
@ -71,10 +71,10 @@ public class HighActivityController {
// 组装奖品
if (body.getJSONArray("activityPrizes") != null && body.getJSONArray("activityPrizes").size() > 0) {
for (Object object : body.getJSONArray("ruleArray")) {
for (Object object : body.getJSONArray("activityPrizes")) {
JSONObject activityObject = (JSONObject)object;
if (
activityObject.getInteger("prizeType") == null ||
activityObject.getInteger("agentId") == null ||
activityObject.getLong("prizeId") == null ||
StringUtils.isBlank(activityObject.getString("prizeName")) ||
activityObject.getInteger("prizeNum") == null
@ -85,7 +85,7 @@ public class HighActivityController {
activityPrize = new HighActivityPrize();
activityPrize.setPrizeType(activityObject.getInteger("prizeType"));
activityPrize.setPrizeType(2);
activityPrize.setPrizeId(activityObject.getLong("prizeId"));
activityPrize.setPrizeName(activityObject.getString("prizeName"));
activityPrize.setPrizeNum(activityObject.getInteger("prizeNum"));
@ -120,7 +120,7 @@ public class HighActivityController {
highActivityAwardService.editHighActivateAward(highActivityAward , activityPrizes);
return ResponseMsgUtil.success("1");
return ResponseMsgUtil.success("成功");
} catch (Exception e) {
log.error("HighActivityController -> userLottery() error!",e);

@ -49,7 +49,7 @@ public interface HighDiscountAgentCodeService {
* @Param [discountAgentId]
* @return java.util.List<com.hai.entity.HighDiscountAgentCode>
**/
List<HighDiscountAgentCode> getDiscountCodeByDiscountAgentId(Long discountAgentId , Integer num);
List<HighDiscountAgentCode> getDiscountCodeByDiscountAgentId(Long discountAgentId);
/**
* @Author 胡锐

@ -1,5 +1,8 @@
package com.hai.service.impl;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.IDGenerator;
import com.hai.dao.HighActivityAwardActualPrizeMapper;
@ -38,6 +41,9 @@ public class HighActivityAwardServiceImpl implements HighActivityAwardService {
@Resource
private HighDiscountAgentCodeService highDiscountAgentCodeService;
@Resource
private HighActivityAwardActualPrizeMapper highActivityAwardActualPrizeM;
@Override
public List<HighActivityAward> getListByActivityId(Long activityId) {
@ -61,10 +67,21 @@ public class HighActivityAwardServiceImpl implements HighActivityAwardService {
highActivityAwardMapper.updateByPrimaryKey(highActivityAward);
}
HighActivityAwardSerialNum serialNum;
// 增加奖品
for (HighActivityPrize list : highActivityPrizes) {
list.setActivityAwardId(highActivityAward.getId());
list.setCreateTime(new Date());
list.setUpdateTime(new Date());
list.setStatus(1);
highActivityPrizeMapper.insert(list);
}
HighActivityAwardSerialNum serialNum;
HighActivityAwardActualPrize actualPrize;
// 生成中奖编号
for (int i = 0; i < highActivityAward.getNum(); i++) {
serialNum = new HighActivityAwardSerialNum();
serialNum.setActivityInfoId(highActivityAward.getActivityInfoId());
@ -74,28 +91,43 @@ public class HighActivityAwardServiceImpl implements HighActivityAwardService {
serialNum.setCreateTime(new Date());
highActivityAwardSerialNumM.insert(serialNum);
// 增加奖品
// 循环奖品
for (HighActivityPrize list : highActivityPrizes) {
list.setActivityAwardId(highActivityAward.getId());
list.setCreateTime(new Date());
list.setStatus(1);
highActivityPrizeMapper.insert(list);
HighDiscountAgentRel discountAgentRel = highDiscountAgentRelService.getRelByDiscountAgent(list.getPrizeId() , Long.valueOf(list.getExt1()));
List<HighDiscountAgentCode> codeList = highDiscountAgentCodeService.getDiscountCodeByDiscountAgentId(discountAgentRel.getId() , list.getPrizeNum());
for (HighDiscountAgentCode agentCode: codeList) {
actualPrize = new HighActivityAwardActualPrize();
actualPrize.setActivityAwardPrizeId(list.getId());
actualPrize.setActivityAwardSerialNumId(serialNum.getId());
actualPrize.setActualPrizeType(2);
actualPrize.setActualPrizeId(agentCode.getId());
actualPrize.setStatus(1);
actualPrize.setCreateTime(new Date());
// 奖品类型 1:卡券 2:优惠券
if (list.getPrizeType() == 2) {
int startNum = 0;
int endNum = 0;
endNum += list.getPrizeNum();
HighDiscountAgentRel discountAgentRel = highDiscountAgentRelService.getRelByDiscountAgent(list.getPrizeId() , Long.valueOf(list.getExt1()));
List<HighDiscountAgentCode> codeList = highDiscountAgentCodeService.getDiscountCodeByDiscountAgentId(discountAgentRel.getId());
if (list.getPrizeNum() > codeList.size()) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ADD_DATA_ERROR, "");
}
for (HighDiscountAgentCode agentCode: codeList.subList(startNum, endNum)) {
agentCode.setStatus(5);
actualPrize = new HighActivityAwardActualPrize();
actualPrize.setActivityAwardPrizeId(list.getId());
actualPrize.setActivityAwardSerialNumId(serialNum.getId());
actualPrize.setActualPrizeType(2);
actualPrize.setActualPrizeId(agentCode.getId());
actualPrize.setStatus(1);
actualPrize.setCreateTime(new Date());
highActivityAwardActualPrizeM.insert(actualPrize);
highDiscountAgentCodeService.updateCode(agentCode);
}
startNum += list.getPrizeNum();
}
}
}
}

@ -92,12 +92,11 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe
}
@Override
public List<HighDiscountAgentCode> getDiscountCodeByDiscountAgentId(Long discountAgentId , Integer num) {
public List<HighDiscountAgentCode> getDiscountCodeByDiscountAgentId(Long discountAgentId) {
HighDiscountAgentCodeExample example = new HighDiscountAgentCodeExample();
HighDiscountAgentCodeExample.Criteria criteria = example.createCriteria();
criteria.andDiscountAgentIdEqualTo(discountAgentId).andStatusEqualTo(1);
example.setLimit(num);
example.setOrderByClause("create_time desc");
return highDiscountAgentCodeMapper.selectByExample(example);
}

Loading…
Cancel
Save