提交活动配置

dev-discount
袁野 3 years ago
parent f44cf3eb71
commit 428435bdcb
  1. 114
      hai-bweb/src/main/java/com/bweb/controller/HighActivityController.java
  2. 42
      hai-service/src/main/java/com/hai/service/HighActivityAwardService.java
  3. 35
      hai-service/src/main/java/com/hai/service/impl/HighActivityAwardServiceImpl.java

@ -0,0 +1,114 @@
package com.bweb.controller;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighActivityInfo;
import com.hai.model.HighUserModel;
import com.hai.model.ResponseData;
import com.hai.service.HighActivityAwardService;
import com.hai.service.HighActivityInfoService;
import com.hai.service.HighActivityUserLotteryNumService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/**
*
* @author hurui
*/
@Controller
@RequestMapping(value = "/activity")
@Api(value = "活动业务接口")
public class HighActivityController {
private static Logger log = LoggerFactory.getLogger(HighActivityController.class);
@Resource
private UserCenter userCenter;
@Resource
private HighActivityInfoService highActivityInfoService;
@Resource
private HighActivityAwardService highActivityAwardService;
@Resource
private HighActivityUserLotteryNumService highActivityUserLotteryNumService;
@RequestMapping(value="/edit",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "用户抽奖业务")
public ResponseData userLottery(@RequestBody JSONObject body, HttpServletRequest request) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
if (body == null || body.getLong("activityId") == null) {
log.error("HighActivityController --> lottery() error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
return ResponseMsgUtil.success(highActivityUserLotteryNumService.userLottery(body.getLong("activityId"),userInfoModel.getHighUser().getId()));
} catch (Exception e) {
log.error("HighActivityController -> userLottery() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getActivityByCoupon",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据卡券查询活动信息")
public ResponseData getActivityByCoupon(@RequestParam(name = "couponId", required = true) Long couponId) {
try {
// 查询活动
Map<String, Object> activity = highActivityInfoService.getNewActivityByCouponId(couponId);
if (activity != null) {
Map<String,Object> map = new HashMap<>();
map.put("activityInfo", activity);
map.put("activityAward", highActivityAwardService.getListByActivityId(MapUtils.getLong(activity, "id")));
return ResponseMsgUtil.success(map);
}
return ResponseMsgUtil.success(null);
} catch (Exception e) {
log.error("HighActivityController -> getActivityByCoupon() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getDetail",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询活动详情")
public ResponseData getDetail(@RequestParam(name = "activityId", required = true) Long activityId) {
try {
// 查询活动
HighActivityInfo detail = highActivityInfoService.getDetailById(activityId);
if (detail != null) {
Map<String,Object> map = new HashMap<>();
map.put("activityInfo", detail);
map.put("activityAward", highActivityAwardService.getListByActivityId(detail.getId()));
return ResponseMsgUtil.success(map);
}
return ResponseMsgUtil.success(null);
} catch (Exception e) {
log.error("HighActivityController -> getDetail() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -1,6 +1,9 @@
package com.hai.service; package com.hai.service;
import com.hai.entity.HighActivityAward; import com.hai.entity.HighActivityAward;
import com.hai.entity.HighActivityAwardActualPrize;
import com.hai.entity.HighActivityAwardSerialNum;
import com.hai.entity.HighActivityPrize;
import java.util.List; import java.util.List;
@ -17,6 +20,45 @@ public interface HighActivityAwardService {
*/ */
List<HighActivityAward> getListByActivityId(Long activityId); List<HighActivityAward> getListByActivityId(Long activityId);
/**
* @params highActivityAward
* @return void
* @author sum1dream
* @description 编辑活动奖励名次
* @date 2021/9/28 11:35 下午
* @version: 1.0.0
*/
void editHighActivateAward(HighActivityAward highActivityAward);
/**
* @params highActivityPrize
* @return void
* @author sum1dream
* @description 编辑活动奖品
* @date 2021/9/28 11:37 下午
* @version: 1.0.0
*/
void editHighActivatePrize(HighActivityPrize highActivityPrize);
/**
* @params HighActivityAwardSerialNum
* @return void
* @author sum1dream
* @description 增加活动将池
* @date 2021/9/28 11:38 下午
* @version: 1.0.0
*/
void addHighActivityAwardSerialNum(HighActivityAwardSerialNum highActivityAwardSerialNum);
/**
* @params HighActivityAwardActualPrize
* @return void
* @author sum1dream
* @description 增加实际奖品
* @date 2021/9/28 11:40 下午
* @version: 1.0.0
*/
void addHighActivityAwardActualPrize(HighActivityAwardActualPrize highActivityAwardActualPrize);
} }

@ -1,8 +1,10 @@
package com.hai.service.impl; package com.hai.service.impl;
import com.hai.dao.HighActivityAwardActualPrizeMapper;
import com.hai.dao.HighActivityAwardMapper; import com.hai.dao.HighActivityAwardMapper;
import com.hai.entity.HighActivityAward; import com.hai.dao.HighActivityAwardSerialNumMapper;
import com.hai.entity.HighActivityAwardExample; import com.hai.dao.HighActivityPrizeMapper;
import com.hai.entity.*;
import com.hai.service.HighActivityAwardService; import com.hai.service.HighActivityAwardService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -15,10 +17,39 @@ public class HighActivityAwardServiceImpl implements HighActivityAwardService {
@Resource @Resource
private HighActivityAwardMapper highActivityAwardMapper; private HighActivityAwardMapper highActivityAwardMapper;
@Resource
private HighActivityPrizeMapper highActivityPrizeMapper;
@Resource
private HighActivityAwardSerialNumMapper highActivityAwardSerialNumMapper;
@Resource
private HighActivityAwardActualPrizeMapper highActivityAwardActualPrizeMapper;
@Override @Override
public List<HighActivityAward> getListByActivityId(Long activityId) { public List<HighActivityAward> getListByActivityId(Long activityId) {
HighActivityAwardExample example = new HighActivityAwardExample(); HighActivityAwardExample example = new HighActivityAwardExample();
example.createCriteria().andActivityInfoIdEqualTo(activityId).andStatusNotEqualTo(0); example.createCriteria().andActivityInfoIdEqualTo(activityId).andStatusNotEqualTo(0);
return highActivityAwardMapper.selectByExample(example); return highActivityAwardMapper.selectByExample(example);
} }
@Override
public void editHighActivateAward(HighActivityAward highActivityAward) {
highActivityAwardMapper.insert(highActivityAward);
}
@Override
public void editHighActivatePrize(HighActivityPrize highActivityPrize) {
highActivityPrizeMapper.insert(highActivityPrize);
}
@Override
public void addHighActivityAwardSerialNum(HighActivityAwardSerialNum highActivityAwardSerialNum) {
highActivityAwardSerialNumMapper.insert(highActivityAwardSerialNum);
}
@Override
public void addHighActivityAwardActualPrize(HighActivityAwardActualPrize highActivityAwardActualPrize) {
highActivityAwardActualPrizeMapper.insert(highActivityAwardActualPrize);
}
} }

Loading…
Cancel
Save