|
|
@ -7,7 +7,11 @@ import com.hai.common.exception.SysCode; |
|
|
|
import com.hai.common.security.SessionObject; |
|
|
|
import com.hai.common.security.SessionObject; |
|
|
|
import com.hai.common.security.UserCenter; |
|
|
|
import com.hai.common.security.UserCenter; |
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
|
|
|
|
import com.hai.entity.HighActivityAward; |
|
|
|
import com.hai.entity.HighActivityInfo; |
|
|
|
import com.hai.entity.HighActivityInfo; |
|
|
|
|
|
|
|
import com.hai.entity.HighActivityPrize; |
|
|
|
|
|
|
|
import com.hai.enum_type.ActivityAwardStatus; |
|
|
|
|
|
|
|
import com.hai.enum_type.ActivityInfoStatus; |
|
|
|
import com.hai.model.HighUserModel; |
|
|
|
import com.hai.model.HighUserModel; |
|
|
|
import com.hai.model.ResponseData; |
|
|
|
import com.hai.model.ResponseData; |
|
|
|
import com.hai.service.HighActivityAwardService; |
|
|
|
import com.hai.service.HighActivityAwardService; |
|
|
@ -16,6 +20,7 @@ import com.hai.service.HighActivityUserLotteryNumService; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
import org.springframework.stereotype.Controller; |
|
|
@ -23,8 +28,7 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.*; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* |
|
|
|
* |
|
|
@ -40,75 +44,89 @@ public class HighActivityController { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private UserCenter userCenter; |
|
|
|
private UserCenter userCenter; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private HighActivityInfoService highActivityInfoService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private HighActivityAwardService highActivityAwardService; |
|
|
|
private HighActivityAwardService highActivityAwardService; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private HighActivityUserLotteryNumService highActivityUserLotteryNumService; |
|
|
|
private HighActivityUserLotteryNumService highActivityUserLotteryNumService; |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/edit",method = RequestMethod.POST) |
|
|
|
@RequestMapping(value="/editActivityAward",method = RequestMethod.POST) |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
@ApiOperation(value = "用户抽奖业务") |
|
|
|
@ApiOperation(value = "新增中奖名次") |
|
|
|
public ResponseData userLottery(@RequestBody JSONObject body, HttpServletRequest request) { |
|
|
|
public ResponseData userLottery(@RequestBody JSONObject body, HttpServletRequest request) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
// 用户
|
|
|
|
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
|
|
|
|
|
|
|
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (body == null || body.getLong("activityId") == null) { |
|
|
|
if (body == null |
|
|
|
log.error("HighActivityController --> lottery() error!", "参数错误"); |
|
|
|
|| body.getLong("activityInfoId") == null |
|
|
|
|
|
|
|
|| StringUtils.isBlank(body.getString("img")) |
|
|
|
|
|
|
|
|| StringUtils.isBlank(body.getString("name")) |
|
|
|
|
|
|
|
|| body.getInteger("num") == null |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
log.error("HighActivityController -> editActivityAward() error!","参数错误"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(highActivityUserLotteryNumService.userLottery(body.getLong("activityId"),userInfoModel.getHighUser().getId())); |
|
|
|
HighActivityPrize activityPrize; |
|
|
|
|
|
|
|
List<HighActivityPrize> activityPrizes = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
// 组装奖品
|
|
|
|
log.error("HighActivityController -> userLottery() error!",e); |
|
|
|
if (body.getJSONArray("activityPrizes") != null && body.getJSONArray("activityPrizes").size() > 0) { |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
for (Object object : body.getJSONArray("ruleArray")) { |
|
|
|
} |
|
|
|
JSONObject activityObject = (JSONObject)object; |
|
|
|
|
|
|
|
if ( |
|
|
|
|
|
|
|
activityObject.getInteger("prizeType") == null || |
|
|
|
|
|
|
|
activityObject.getLong("prizeId") == null || |
|
|
|
|
|
|
|
StringUtils.isBlank(activityObject.getString("prizeName")) || |
|
|
|
|
|
|
|
activityObject.getInteger("prizeNum") == null |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
log.error("HighActivityController -> editActivityAward() error!","参数错误"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/getActivityByCoupon",method = RequestMethod.GET) |
|
|
|
activityPrize = new HighActivityPrize(); |
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "根据卡券查询活动信息") |
|
|
|
activityPrize.setPrizeType(activityObject.getInteger("prizeType")); |
|
|
|
public ResponseData getActivityByCoupon(@RequestParam(name = "couponId", required = true) Long couponId) { |
|
|
|
activityPrize.setPrizeId(activityObject.getLong("prizeId")); |
|
|
|
try { |
|
|
|
activityPrize.setPrizeName(activityObject.getString("prizeName")); |
|
|
|
// 查询活动
|
|
|
|
activityPrize.setPrizeNum(activityObject.getInteger("prizeNum")); |
|
|
|
Map<String, Object> activity = highActivityInfoService.getNewActivityByCouponId(couponId); |
|
|
|
activityPrize.setExt1(activityObject.getString("agentId")); |
|
|
|
if (activity != null) { |
|
|
|
activityPrizes.add(activityPrize); |
|
|
|
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) |
|
|
|
HighActivityAward highActivityAward; |
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "查询活动详情") |
|
|
|
if (body.getLong("id") != null) { |
|
|
|
public ResponseData getDetail(@RequestParam(name = "activityId", required = true) Long activityId) { |
|
|
|
highActivityAward = highActivityAwardService.getDetailById(body.getLong("id")); |
|
|
|
try { |
|
|
|
if (highActivityAward == null) { |
|
|
|
// 查询活动
|
|
|
|
log.error("HighActivityInfoController -> editActivityInfo() error!","未找到活动信息"); |
|
|
|
HighActivityInfo detail = highActivityInfoService.getDetailById(activityId); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到活动信息"); |
|
|
|
if (detail != null) { |
|
|
|
} |
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
if (highActivityAward.getStatus().equals(ActivityAwardStatus.status0.getNumber())) { |
|
|
|
map.put("activityInfo", detail); |
|
|
|
log.error("HighActivityInfoController -> editActivityInfo() error!","状态错误"); |
|
|
|
map.put("activityAward", highActivityAwardService.getListByActivityId(detail.getId())); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); |
|
|
|
return ResponseMsgUtil.success(map); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return ResponseMsgUtil.success(null); |
|
|
|
} else { |
|
|
|
|
|
|
|
highActivityAward = new HighActivityAward(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 组装奖励
|
|
|
|
|
|
|
|
highActivityAward.setActivityInfoId(body.getLong("activityInfoId")); |
|
|
|
|
|
|
|
highActivityAward.setImg(body.getString("img")); |
|
|
|
|
|
|
|
highActivityAward.setName(body.getString("name")); |
|
|
|
|
|
|
|
highActivityAward.setNum(body.getInteger("num")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
highActivityAwardService.editHighActivateAward(highActivityAward , activityPrizes); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("1"); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("HighActivityController -> getDetail() error!",e); |
|
|
|
log.error("HighActivityController -> userLottery() error!",e); |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|