| | |
| | | package com.ks.daylucky.controller.api.client; |
| | | |
| | | import com.ks.daylucky.pojo.DO.UserInfo; |
| | | import com.ks.daylucky.pojo.DTO.ActivityDetailInfoDTO; |
| | | import com.ks.daylucky.pojo.VO.*; |
| | | import com.ks.daylucky.service.ActivityService; |
| | | import com.ks.daylucky.service.UserInfoService; |
| | | import com.ks.daylucky.util.Constant; |
| | | import com.ks.daylucky.util.UserInfoUtil; |
| | | import com.ks.daylucky.util.activity.ActivityUtil; |
| | | import com.ks.daylucky.util.factory.vo.ActivityListItemInfoVOFactory; |
| | | import com.ks.lucky.exception.LuckyActivityException; |
| | | import com.ks.lucky.exception.LuckyActivityJoinException; |
| | | import com.ks.lucky.pojo.DO.LuckyActivity; |
| | | import com.ks.lucky.pojo.DO.LuckyActivityJoinRecord; |
| | | import com.ks.lucky.pojo.DTO.*; |
| | | import com.ks.lucky.remote.service.LuckyActivityAwardResultService; |
| | | import com.ks.lucky.remote.service.LuckyActivityJoinService; |
| | | import com.ks.lucky.remote.service.LuckyActivityService; |
| | | import net.sf.json.JSONObject; |
| | | import org.apache.dubbo.config.annotation.Reference; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | |
| | | @RequestMapping("api/client/activity/join") |
| | | public class ActivityJoinController { |
| | | |
| | | @Resource |
| | | @Reference(version = "1.0.0", check = false) |
| | | private LuckyActivityJoinService luckyActivityJoinService; |
| | | |
| | | @Resource |
| | | @Reference(version = "1.0.0", check = false) |
| | | private LuckyActivityAwardResultService luckyActivityAwardResultService; |
| | | |
| | | @Reference(version = "1.0.0", check = false) |
| | | private LuckyActivityService luckyActivityService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | |
| | | public String getRankList(AcceptData acceptData, Long activityId, int page) { |
| | | List<ActivityJoinerRankInfoVO> voList = new ArrayList<>(); |
| | | |
| | | List<ActivityJoinerRankInfo> list = luckyActivityJoinService.getWeightRankList(activityId, page, Constant.PAGE_SIZE); |
| | | List<ActivityJoinerRankInfo> list = luckyActivityJoinService.getWeightRankList(activityId, page,10); |
| | | if (list != null && list.size() > 0) { |
| | | Map<Long, UserInfo> userInfoMap = userInfoService.listUserInfoAsMap(UserInfoUtil.getBaseUserList(list)); |
| | | for (ActivityJoinerRankInfo info : list) { |
| | | UserInfo user = userInfoMap.get(info.getUid()); |
| | | UserInfo user = userInfoMap.get(Long.parseLong(info.getUid())); |
| | | |
| | | if (user != null) { |
| | | if (user.getId().longValue() == acceptData.getUid()) { |
| | | continue; |
| | | } |
| | | voList.add(new ActivityJoinerRankInfoVO(new SimpleUser(user.getId(), user.getNickName(), user.getPortrait()), info.getRank(), info.getWeight())); |
| | | } |
| | | } |
| | |
| | | public String getJoinerList(AcceptData acceptData, Long activityId, int page) { |
| | | List<SimpleUser> voList = new ArrayList<>(); |
| | | |
| | | List<ActivitySimpleUser> list = luckyActivityJoinService.getJoinerList(activityId, page, Constant.PAGE_SIZE); |
| | | List<ActivitySimpleUser> list = luckyActivityJoinService.getJoinerList(activityId, null, page, Constant.PAGE_SIZE); |
| | | if (list != null && list.size() > 0) { |
| | | Map<Long, UserInfo> userInfoMap = userInfoService.listUserInfoAsMap(UserInfoUtil.getBaseUserList(list)); |
| | | for (ActivitySimpleUser info : list) { |
| | | UserInfo user = userInfoMap.get(info.getUid()); |
| | | UserInfo user = userInfoMap.get(Long.parseLong(info.getUid())); |
| | | if (user != null) { |
| | | voList.add(new SimpleUser(user.getId(), user.getNickName(), user.getPortrait())); |
| | | } |
| | |
| | | break; |
| | | } |
| | | |
| | | List<ActivityDetailInfoVO> voList = activityService.getActivityDetail(activityIdList, appId, uid, type == 2 ? true : false); |
| | | List<ActivityDetailInfoDTO> voList = activityService.getActivityDetail(activityIdList, appId, uid, type == 2 ? true : false); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("data", JsonUtil.getApiCommonGson().toJson(voList)); |
| | | data.put("data", JsonUtil.getSimpleGson().toJson(ActivityListItemInfoVOFactory.create(voList))); |
| | | data.put("count", count); |
| | | |
| | | return JsonUtil.loadTrueResult(data); |
| | |
| | | joinInfo.setAlipayUid(userInfo.getAlipayUid()); |
| | | try { |
| | | int weight = 1; |
| | | luckyActivityJoinService.join(activityId, acceptData.getApp().getId(), acceptData.getUid() + "", 1, joinInfo); |
| | | luckyActivityJoinService.join(activityId, acceptData.getApp().getId(), acceptData.getUid() + "", 1, joinInfo, LuckyActivityJoinRecord.USER_TYPE_REAL); |
| | | |
| | | LuckyActivity activity = luckyActivityService.getActivity(activityId); |
| | | //TODO 抽奖活动的类型需要替换 |
| | | return JsonUtil.loadTrueResult(new JoinResultInfoVO(weight, String.format("活动期号:NO.%s\n抽奖活动", activityId))); |
| | | return JsonUtil.loadTrueResult(new JoinResultInfoVO(weight, String.format("活动期号:%s\n抽奖活动", ActivityUtil.getActivityDateNumber(activityId, activity.getCreateTime())))); |
| | | } catch (LuckyActivityException e) { |
| | | return JsonUtil.loadFalseResult(e.getMsg()); |
| | | } catch (LuckyActivityJoinException e) { |