dev-discount
袁野 3 years ago
parent 6c3e946bda
commit f3df6bf81b
  1. 71
      hai-bweb/src/main/java/com/bweb/controller/HighActivityController.java
  2. 2
      hai-bweb/src/main/java/com/bweb/controller/HighActivityInfoController.java
  3. 52
      hai-bweb/src/main/java/com/bweb/controller/TuanYouController.java
  4. 1
      hai-service/src/main/java/com/hai/config/WxOrderConfig.java
  5. 34
      hai-service/src/main/java/com/hai/service/HighActivityAwardService.java
  6. 122
      hai-service/src/main/java/com/hai/service/impl/HighActivityAwardServiceImpl.java

@ -59,8 +59,8 @@ public class HighActivityController {
@RequestMapping(value="/editActivityAward",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "新增中奖名次")
public ResponseData userLottery(@RequestBody JSONObject body, HttpServletRequest request) {
@ApiOperation(value = "配置奖励")
public ResponseData editActivityAward(@RequestBody JSONObject body, HttpServletRequest request) {
try {
if (body == null
@ -157,4 +157,71 @@ public class HighActivityController {
}
}
@RequestMapping(value="/getListByActivityId",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询配置奖励记录")
public ResponseData getListByActivityId(@RequestParam(name = "activityId", required = true) Long activityId) {
try {
return ResponseMsgUtil.success(highActivityAwardService.getListByActivityId(activityId));
} catch (Exception e) {
log.error("HighActivityController -> getWinLotteryList() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/deleteActivateAward",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "删除")
public ResponseData deleteActivateAward(@RequestParam(name = "activityId", required = true) Long activityId) {
try {
highActivityAwardService.deleteActivateAward(activityId);
return ResponseMsgUtil.success("删除成功");
} catch (Exception e) {
log.error("HighActivityController -> getWinLotteryList() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/checkNumberPrizes",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询剩余数量")
public ResponseData checkNumberPrizes(@RequestParam(name = "activityId", required = true) Long activityId) {
try {
return ResponseMsgUtil.success(highActivityAwardService.checkNumberPrizes(activityId));
} catch (Exception e) {
log.error("HighActivityController -> getWinLotteryList() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/numberOfNewRewards",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "根据奖励id新增奖励数量")
public ResponseData numberOfNewRewards(
@RequestBody JSONObject body
) {
try {
if (body == null
|| body.getLong("activityAwardId") == null
|| body.getInteger("num") == null
) {
log.error("HighActivityController -> editActivityAward() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
highActivityAwardService.numberOfNewRewards( body.getLong("activityAwardId") , body.getInteger("num") );
return ResponseMsgUtil.success("新增成功");
} catch (Exception e) {
log.error("HighActivityController -> getWinLotteryList() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -143,7 +143,7 @@ public class HighActivityInfoController {
highActivityInfo.setEndTime(new Date(body.getLong("endTime")));
highActivityInfoService.editActivityBusiness(highActivityInfo,partakeRuleList);
return ResponseMsgUtil.success("操作成功");
return ResponseMsgUtil.success(highActivityInfo);
} catch (Exception e) {
log.error("HighActivityInfoController --> editActivityInfo() error!", e);
return ResponseMsgUtil.exception(e);

@ -1,6 +1,8 @@
package com.bweb.controller;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.HuiLianTongUnionCardConfig;
import com.hai.config.TuanYouConfig;
import com.hai.model.ResponseData;
import io.swagger.annotations.Api;
@ -10,6 +12,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@ -41,4 +44,53 @@ public class TuanYouController {
}
}
@RequestMapping(value="/refund",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "团油退款")
public ResponseData refund(
@RequestParam(name = "refundOrderNo", required = false) String refundOrderNo,
@RequestParam(name = "origOrderNo", required = false) String origOrderNo
) {
try {
return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.refund(refundOrderNo , origOrderNo));
} catch (Exception e) {
log.error("getUserByTelephone",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/resolveResponse",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "解析")
public ResponseData resolveResponse(
@RequestParam(name = "data", required = false) String data
) {
try {
JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data);
return ResponseMsgUtil.success(cardInfoObject);
} catch (Exception e) {
log.error("getUserByTelephone",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/queryCardInfo",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询")
public ResponseData queryCardInfo(
@RequestParam(name = "card", required = false) String card
) {
try {
JSONObject cardInfo = HuiLianTongUnionCardConfig.queryCardInfo(card);
return ResponseMsgUtil.success(cardInfo);
} catch (Exception e) {
log.error("getUserByTelephone",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -11,7 +11,6 @@ import com.hai.common.utils.WxUtils;
import com.hai.entity.OutRechargeOrder;
import com.hai.model.OrderRefundModel;
import com.hai.model.ResponseData;
import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIConversion;
import io.swagger.annotations.ApiOperation;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;

@ -4,6 +4,7 @@ import com.hai.entity.HighActivityAward;
import com.hai.entity.HighActivityAwardActualPrize;
import com.hai.entity.HighActivityAwardSerialNum;
import com.hai.entity.HighActivityPrize;
import io.swagger.models.auth.In;
import java.util.List;
@ -40,4 +41,37 @@ public interface HighActivityAwardService {
**/
void editHighActivateAward(HighActivityAward highActivityAward , List<HighActivityPrize> highActivityPrizes) throws Exception ;
/**
* @Author Sum1Dream
* @name getDetailById.java
* @Description // 查询详情
* @Date 10:22 2021/9/29
* @Param [id]
* @return com.hai.entity.HighActivityAward
**/
void deleteActivateAward(Long id);
/**
* @Author Sum1Dream
* @name checkNumberPrizes.java
* @Description // 根据id查询活动奖品剩余数量
* @Date 10:22 2021/9/29
* @Param [id]
* @return com.hai.entity.HighActivityAward
**/
List<HighActivityAward> checkNumberPrizes(Long id);
/**
* @Author Sum1Dream
* @name numberOfNewRewards.java
* @Description // 根据奖励id新增奖励数量
* @Date 10:22 2021/9/29
* @Param [activityAwardId]
* @return com.hai.entity.HighActivityAward
**/
void numberOfNewRewards(Long activityAwardId , Integer num) throws Exception ;
}

@ -130,12 +130,130 @@ public class HighActivityAwardServiceImpl implements HighActivityAwardService {
}
}
}
@Override
public HighActivityAward getDetailById(Long id) {
return highActivityAwardMapper.selectByPrimaryKey(id);
}
@Override
@Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW)
public void deleteActivateAward(Long id) {
HighActivityPrizeExample example = new HighActivityPrizeExample();
example.createCriteria().andActivityAwardIdEqualTo(id);
List<HighActivityPrize> prize = highActivityPrizeMapper.selectByExample(example);
for (HighActivityPrize p : prize) {
HighActivityAwardActualPrizeExample prizeExample = new HighActivityAwardActualPrizeExample();
prizeExample.createCriteria().andActivityAwardPrizeIdEqualTo(p.getId());
List<HighActivityAwardActualPrize> actualPrizeList = highActivityAwardActualPrizeM.selectByExample(prizeExample);
for (HighActivityAwardActualPrize actualPrize: actualPrizeList ) {
highActivityAwardActualPrizeM.deleteByPrimaryKey(actualPrize.getId());
}
highActivityPrizeMapper.deleteByPrimaryKey(p.getId());
}
HighActivityAwardSerialNumExample numExample = new HighActivityAwardSerialNumExample();
numExample.createCriteria().andActivityAwardIdEqualTo(id);
List<HighActivityAwardSerialNum> serialNumList = highActivityAwardSerialNumM.selectByExample(numExample);
for (HighActivityAwardSerialNum serialNum: serialNumList) {
highActivityAwardSerialNumM.deleteByPrimaryKey(serialNum.getId());
}
highActivityAwardMapper.deleteByPrimaryKey(id);
}
@Override
public List<HighActivityAward> checkNumberPrizes(Long id) {
HighActivityAwardExample example = new HighActivityAwardExample();
example.createCriteria().andActivityInfoIdEqualTo(id);
List<HighActivityAward> activityAwardList = highActivityAwardMapper.selectByExample(example);
for (HighActivityAward activityAward : activityAwardList) {
HighActivityAwardSerialNumExample numExample = new HighActivityAwardSerialNumExample();
numExample.createCriteria().andActivityAwardIdEqualTo(activityAward.getId()).andStatusEqualTo(1);
activityAward.setExt3(String.valueOf(highActivityAwardSerialNumM.countByExample(numExample)));
}
return activityAwardList;
}
@Override
@Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW)
public void numberOfNewRewards(Long activityAwardId , Integer num) throws Exception {
HighActivityAward highActivityAward = highActivityAwardMapper.selectByPrimaryKey(activityAwardId);
HighActivityAwardSerialNum serialNum;
HighActivityAwardActualPrize actualPrize;
HighActivityPrizeExample prizeExample = new HighActivityPrizeExample();
prizeExample.createCriteria().andActivityAwardIdEqualTo(activityAwardId);
List<HighActivityPrize> highActivityPrizes = highActivityPrizeMapper.selectByExample(prizeExample);
highActivityAward.setNum(highActivityAward.getNum() + num);
highActivityAwardMapper.updateByPrimaryKey(highActivityAward);
// 生成中奖编号
for (int i = 0; i < num; i++) {
serialNum = new HighActivityAwardSerialNum();
serialNum.setActivityInfoId(highActivityAward.getActivityInfoId());
serialNum.setActivityAwardId(highActivityAward.getId());
serialNum.setSerialNum("HFA" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5));
serialNum.setStatus(1);
serialNum.setCreateTime(new Date());
highActivityAwardSerialNumM.insert(serialNum);
// 循环奖品
for (HighActivityPrize list : highActivityPrizes) {
// 奖品类型 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();
}
}
}
}
}

Loading…
Cancel
Save