| | |
| | | package com.ks.daylucky.controller.api.client; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.ks.daylucky.pojo.DO.ActivityScanRecord; |
| | | import com.ks.daylucky.pojo.DO.AppConfig; |
| | | import com.ks.daylucky.pojo.DTO.SimpleShareInfo; |
| | | import com.ks.daylucky.pojo.VO.AlipayXCXShareInfoVO; |
| | | import com.ks.daylucky.pojo.DTO.ConfigKeyEnum; |
| | | import com.ks.daylucky.pojo.VO.AcceptData; |
| | | import com.ks.daylucky.pojo.DTO.ActivityDetailInfoDTO; |
| | | import com.ks.daylucky.pojo.VO.ActivityDetailVO; |
| | | import com.ks.daylucky.pojo.VO.ActivityListItemInfoVO; |
| | | import com.ks.daylucky.pojo.VO.SimpleUser; |
| | | import com.ks.daylucky.service.*; |
| | | import com.ks.daylucky.util.Constant; |
| | | import com.ks.daylucky.util.activity.ActivityUtil; |
| | | import com.ks.daylucky.util.factory.vo.ActivityDetailVOFactory; |
| | | import com.ks.daylucky.util.factory.vo.ActivityListItemInfoVOFactory; |
| | | import com.ks.lucky.pojo.DO.LuckyActivity; |
| | | import com.ks.lucky.remote.service.LuckyActivityJoinAssistService; |
| | | 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.yeshi.utils.JsonUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/client/activity") |
| | | public class ActivityController { |
| | | |
| | | @Reference(version = "1.0.0") |
| | | @Reference(version = "1.0.0", check = false) |
| | | private LuckyActivityService luckyActivityService; |
| | | |
| | | @Reference(version = "1.0.0") |
| | | @Reference(version = "1.0.0", check = false) |
| | | private LuckyActivityJoinAssistService luckyActivityJoinAssistService; |
| | | |
| | | @Resource |
| | |
| | | |
| | | @Resource |
| | | private AppConfigService appConfigService; |
| | | |
| | | @Resource |
| | | private ActivityExtraInfoService activityExtraInfoService; |
| | | |
| | | @Resource |
| | | private UserActivityExtraInfoService userActivityExtraInfoService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | |
| | | /** |
| | |
| | | @ResponseBody |
| | | @RequestMapping("getActivityDetail") |
| | | public String getActivityDetail(AcceptData acceptData, Long activityId) { |
| | | ActivityDetailInfoDTO dto = activityService.getActivityDetail(activityId, acceptData.getApp().getId(), acceptData.getUid(), true, 20, false); |
| | | ActivityDetailInfoDTO dto = activityService.getActivityDetail(activityId, acceptData.getApp().getId(), acceptData.getUid(), true, 8, false); |
| | | if (dto == null) { |
| | | return JsonUtil.loadFalseResult("活动不存在"); |
| | | } |
| | |
| | | assistCount = (int) count; |
| | | } |
| | | |
| | | //查询赞助商已经开始的活动数量 |
| | | |
| | | ActivityDetailVO vo = ActivityDetailVOFactory.create(dto, help != null ? help.getValue() : null, assistCount); |
| | | return JsonUtil.loadTrueResult(vo); |
| | | long count = luckyActivityService.countActivity(acceptData.getApp().getId(), dto.getActivity().getSponsorId(), ActivityUtil.getCanShowAcivityStateList(), null); |
| | | |
| | | ActivityDetailVO vo = ActivityDetailVOFactory.create(dto, help != null ? help.getValue() : null, assistCount, (int) count); |
| | | |
| | | //分享信息 |
| | | |
| | | String activityShareImage = null; |
| | | try { |
| | | activityShareImage = activityExtraInfoService.getShareImageLink(activityId, vo.getActivity().getAwardList(), acceptData.getApp().getId()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | AppConfig appConfig = appConfigService.getConfigCache(acceptData.getApp().getId(), ConfigKeyEnum.activityShareInfo, acceptData.getVersion()); |
| | | SimpleShareInfo info = new Gson().fromJson(appConfig.getValue(), SimpleShareInfo.class); |
| | | |
| | | AlipayXCXShareInfoVO shareInfoDTO = new AlipayXCXShareInfoVO(); |
| | | shareInfoDTO.setPath(String.format("/pages/activity-detail/activity-detail?id=%s&joinInfo=%s", activityId, ActivityUtil.getShareJoinInfo(acceptData.getUid(), activityId))); |
| | | shareInfoDTO.setTitle(info.getTitle()); |
| | | shareInfoDTO.setDesc(info.getDesc()); |
| | | shareInfoDTO.setBgImgUrl(activityShareImage); |
| | | vo.setShareInfo(shareInfoDTO); |
| | | |
| | | //已经加入活动就需要返回助力分享图 |
| | | if (vo.isJoined()) { |
| | | SimpleUser user = userInfoService.getSimpleUser(acceptData.getUid()); |
| | | if (user != null) { |
| | | String assistShareImage = null; |
| | | try { |
| | | assistShareImage = userActivityExtraInfoService.getShareImageLink(activityId, user, acceptData.getApp().getId()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | shareInfoDTO = new AlipayXCXShareInfoVO(); |
| | | shareInfoDTO.setPath(String.format("/pages/activity-detail/activity-detail?id=%s&joinInfo=%s", activityId, URLEncoder.encode(ActivityUtil.getShareJoinInfo(acceptData.getUid(), activityId)))); |
| | | shareInfoDTO.setTitle(info.getTitle()); |
| | | shareInfoDTO.setDesc(info.getDesc()); |
| | | shareInfoDTO.setBgImgUrl(assistShareImage); |
| | | vo.setAssistShareInfo(shareInfoDTO); |
| | | } |
| | | } |
| | | |
| | | |
| | | //加入浏览记录 |
| | | ActivityScanRecord record = new ActivityScanRecord(); |
| | | record.setActivityId(activityId); |
| | | record.setUid(acceptData.getUid()); |
| | | activityScanRecordService.addRecord(record); |
| | | |
| | | AppConfig config = appConfigService.getConfigCache(acceptData.getApp().getId(), ConfigKeyEnum.disclaimers, acceptData.getVersion()); |
| | | if (config != null) { |
| | | vo.setDisclaimers(config.getValue()); |
| | | } |
| | | return JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(vo)); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | List<ActivityDetailInfoDTO> dtoList = activityService.getActivityDetail(activityIds, acceptData.getApp().getId(), acceptData.getUid(), false); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("data", ActivityListItemInfoVOFactory.create(dtoList)); |
| | | data.put("data", JsonUtil.getSimpleGson().toJson(ActivityListItemInfoVOFactory.create(dtoList))); |
| | | data.put("count", count); |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |
| | |
| | | * @param page |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("getSponsorActivity") |
| | | public String getSponsorActivity(AcceptData acceptData, Long sponsorId, int page) { |
| | | public String getSponsorActivity(AcceptData acceptData, Long sponsorId, Long activityId, int page) { |
| | | |
| | | List<LuckyActivity> list = luckyActivityService.getActivityList(acceptData.getApp().getId(), sponsorId, getCanShowStateList(), null, page, Constant.CLIENT_ACTIVITY_LIST_PAGE_SIZE); |
| | | long count = luckyActivityService.countActivity(acceptData.getApp().getId(), sponsorId, getCanShowStateList(), null); |
| | | List<LuckyActivity> list = luckyActivityService.getActivityList(acceptData.getApp().getId(), sponsorId, getCanShowStateList(), Arrays.asList(new Long[]{activityId}), |
| | | null, page, Constant.CLIENT_ACTIVITY_LIST_PAGE_SIZE); |
| | | long count = luckyActivityService.countActivity(acceptData.getApp().getId(), sponsorId, getCanShowStateList(), null, Arrays.asList(new Long[]{activityId})); |
| | | |
| | | List<Long> activityIds = new ArrayList<>(); |
| | | if (list != null && list.size() > 0) { |
| | |
| | | } |
| | | List<ActivityDetailInfoDTO> dtoList = activityService.getActivityDetail(activityIds, acceptData.getApp().getId(), acceptData.getUid(), false); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("data", ActivityListItemInfoVOFactory.create(dtoList)); |
| | | data.put("data", JsonUtil.getSimpleGson().toJson(ActivityListItemInfoVOFactory.create(dtoList))); |
| | | data.put("count", count); |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |
| | |
| | | * @param page |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @RequestMapping("getScanActivityRecord") |
| | | public String getScanActivityRecord(AcceptData acceptData, int page) { |
| | | |
| | |
| | | } |
| | | List<ActivityDetailInfoDTO> dtoList = activityService.getActivityDetail(activityIds, acceptData.getApp().getId(), acceptData.getUid(), false); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("data", ActivityListItemInfoVOFactory.create(dtoList)); |
| | | data.put("data", JsonUtil.getSimpleGson().toJson(ActivityListItemInfoVOFactory.create(dtoList))); |
| | | data.put("count", count); |
| | | return JsonUtil.loadTrueResult(data); |
| | | } |