| | |
| | | package com.ks.daylucky.controller.api.client; |
| | | |
| | | import com.ks.daylucky.pojo.DO.ActivityDrawnRecieveNotifyInfo; |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | import com.ks.daylucky.pojo.VO.AcceptData; |
| | | import com.ks.daylucky.pojo.VO.SimpleUser; |
| | | import com.ks.daylucky.pojo.VO.UserActivityUnRecievedAwardVO; |
| | | import com.ks.daylucky.pojo.VO.*; |
| | | import com.ks.daylucky.service.ActivityDrawnRecieveNotifyInfoService; |
| | | import com.ks.daylucky.service.UserInfoService; |
| | | import com.ks.daylucky.util.Constant; |
| | | import com.ks.daylucky.util.UserInfoUtil; |
| | | import com.ks.daylucky.util.factory.vo.ActivityDetailVOFactory; |
| | | import com.ks.daylucky.util.factory.vo.ActivityListItemInfoVOFactory; |
| | | import com.ks.lucky.exception.LuckyActivityAwardException; |
| | | import com.ks.lucky.exception.LuckyActivityAwardResultException; |
| | | import com.ks.lucky.exception.LuckyActivityException; |
| | |
| | | @RequestMapping("api/client/activity/awards") |
| | | public class ActivityAwardsController { |
| | | |
| | | @Reference(version = "1.0") |
| | | @Reference(version = "1.0.0",check = false) |
| | | private LuckyActivityAwardResultService luckyActivityAwardResultService; |
| | | |
| | | @Reference(version = "1.0") |
| | | @Reference(version = "1.0.0",check = false) |
| | | private LuckyActivityAwardService luckyActivityAwardService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private ActivityDrawnRecieveNotifyInfoService activityDrawnRecieveNotifyInfoService; |
| | | |
| | | |
| | | /** |
| | |
| | | public String getDrawnInfo(AcceptData acceptData, Long activityId, int count) { |
| | | List<LuckyActivityAwards> list = luckyActivityAwardService.getAwardList(activityId); |
| | | JSONArray array = new JSONArray(); |
| | | int p = 0; |
| | | for (LuckyActivityAwards award : list) { |
| | | award = luckyActivityAwardService.getAwardDetail(award.getId()); |
| | | JSONObject item = new JSONObject(); |
| | | List<LuckyActivityAwardResult> awardResults = luckyActivityAwardResultService.getResultListWithAwardInfo(activityId, award.getId(), 1, count); |
| | | long resultCount = luckyActivityAwardResultService.countResultWithAwardInfo(activityId, award.getId()); |
| | | |
| | | List<SimpleUser> userList = new ArrayList<>(); |
| | | Map<Long, UserInfo> userMap = userInfoService.listUserInfoAsMap(UserInfoUtil.getBaseUserList(awardResults)); |
| | | for (LuckyActivityAwardResult info : awardResults) { |
| | |
| | | } |
| | | } |
| | | item.put("userList", userList); |
| | | item.put("award", JsonUtil.getApiCommonGson().toJson(award)); |
| | | item.put("userCount", resultCount); |
| | | item.put("award", ActivityListItemInfoVOFactory.create(award, p++)); |
| | | array.add(item); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取未领奖的奖励信息 |
| | | * 获取领奖通知弹框 |
| | | * |
| | | * @param acceptData |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("getUnRecieveAward") |
| | | public String getUnRecieveAward(AcceptData acceptData) { |
| | | List<LuckyActivityAwardResult> resultList = luckyActivityAwardResultService.getUnRecievedAward(acceptData.getApp().getId(), acceptData.getUid() + "", 1, 1); |
| | | if (resultList != null && resultList.size() > 0) { |
| | | LuckyActivityAwardResult result = resultList.get(0); |
| | | @RequestMapping("getRecieveAwardNotify") |
| | | public String getRecieveAwardNotify(AcceptData acceptData, Long activityId) { |
| | | ActivityDrawnRecieveNotifyInfo info = activityDrawnRecieveNotifyInfoService.getShowNotifyInfo(acceptData.getApp().getId(), acceptData.getUid(), activityId); |
| | | if (info != null) { |
| | | UserActivityUnRecievedAwardVO vo = new UserActivityUnRecievedAwardVO(); |
| | | LuckyActivityAwards award = luckyActivityAwardService.getAwardDetail(result.getAwardId()); |
| | | vo.setAwardName(award.getAwardName()); |
| | | vo.setAwardId(award.getId()); |
| | | vo.setPicture(award.getAwardPoster()); |
| | | LuckyActivityAwards award = info.getAwards(); |
| | | |
| | | vo.setTitle("活动期号:NO." + award.getActivityId()); |
| | | vo.setActivityId(activityId); |
| | | vo.setType(info.getType()); |
| | | vo.setId(info.getId()); |
| | | |
| | | switch (info.getType()) { |
| | | case ActivityDrawnRecieveNotifyInfo.TYPE_UNRECIEVE: |
| | | vo.setDesc("未领取,可在\"我的-全部抽奖\"中查看"); |
| | | vo.setAward(ActivityListItemInfoVOFactory.create(award, null)); |
| | | break; |
| | | case ActivityDrawnRecieveNotifyInfo.TYPE_OUTDATE: |
| | | vo.setDesc("注:中奖日起7天内未领取奖品,将会把对应奖品原路退回赞助商,切记中奖后按时领取奖品。"); |
| | | vo.setAward(ActivityListItemInfoVOFactory.create(award, award.getLevel())); |
| | | break; |
| | | } |
| | | return JsonUtil.loadTrueResult(vo); |
| | | } |
| | | return JsonUtil.loadFalseResult(""); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置中奖通知弹框已读 |
| | | * |
| | | * @param acceptData |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("setDrawnNotifyRead") |
| | | public String setDrawnNotifyRead(AcceptData acceptData, String id) { |
| | | |
| | | ActivityDrawnRecieveNotifyInfo info = activityDrawnRecieveNotifyInfoService.selectByPrimaryKey(id); |
| | | |
| | | String uid = null; |
| | | Long appId = null; |
| | | |
| | | if (info.getAwardResult() != null) { |
| | | uid = info.getAwardResult().getUid(); |
| | | appId = info.getAwardResult().getAppId(); |
| | | } |
| | | |
| | | if (uid == null || appId == null) { |
| | | return JsonUtil.loadFalseResult("信息获取出错"); |
| | | } |
| | | |
| | | if (acceptData.getUid().longValue() != Long.parseLong(uid) || acceptData.getApp().getId().longValue() != appId) { |
| | | return JsonUtil.loadFalseResult("不是自己的中奖"); |
| | | } |
| | | activityDrawnRecieveNotifyInfoService.setNotifyShown(info.getId()); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 领取奖品 |
| | | * |