| | |
| | | import java.util.Set;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpSession;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | |
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinDetail.TaoLiJinDetailTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.UserRank;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | | import com.yeshi.fanli.entity.integral.CodePublishRecord;
|
| | | import com.yeshi.fanli.entity.integral.IntegralExchange;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTask;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTask.TaskUniqueKeyEnum;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTaskClass.UniqueKeyEnum;
|
| | | import com.yeshi.fanli.entity.integral.IntegralTaskRecord;
|
| | | import com.yeshi.fanli.exception.integral.IntegralExchangeException;
|
| | | import com.yeshi.fanli.exception.integral.IntegralGetException;
|
| | | import com.yeshi.fanli.exception.integral.IntegralTaskRecordException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.integral.CodePublishRecordService;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralDetailService;
|
| | |
| | | @Resource
|
| | | private IntegralGetService integralGetService;
|
| | |
|
| | | @Resource
|
| | | private JumpDetailV2Service jumpDetailV2Service;
|
| | |
|
| | | /**
|
| | | * 获取任务列表
|
| | | *
|
| | |
| | | * @param page
|
| | | * @param out
|
| | | */
|
| | | // @RequestSerializableByKey(key="#acceptData.device")
|
| | | // @RequestSerializableByKey(key="#acceptData.device")
|
| | | @RequestMapping(value = "getTaskList", method = RequestMethod.POST)
|
| | | public void getTaskList(AcceptData acceptData, Long uid, Integer page, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | |
| | | }
|
| | |
|
| | | for (IntegralTaskClassVO taskClassVO : list) {
|
| | | UniqueKeyEnum uniqueKey = taskClassVO.getUniqueKey();
|
| | | |
| | | // 邀请好友:是否激活邀请码
|
| | | if (uniqueKey == UniqueKeyEnum.inviteTeam) {
|
| | | UserInfoExtraVO extraVO = userInfoExtraService.getInfoExtraVOByUid(uid);
|
| | | if (extraVO == null || StringUtil.isNullOrEmpty(extraVO.getInviteCode())) {
|
| | | JumpDetailV2 jumpDetailV2 = jumpDetailV2Service.getByTypeCache("invite_activate",
|
| | | Constant.getPlatformCode(acceptData.getPlatform()),
|
| | | Integer.parseInt(acceptData.getVersion()));
|
| | | taskClassVO.setJumpDetail(jumpDetailV2);
|
| | | }
|
| | | }
|
| | |
|
| | | String progress = taskClassVO.getProgress();
|
| | | if (StringUtil.isNullOrEmpty(progress))
|
| | | continue;
|
| | |
| | | if (taskNum == null)
|
| | | continue;
|
| | |
|
| | | UniqueKeyEnum uniqueKey = taskClassVO.getUniqueKey();
|
| | | if (uniqueKey == UniqueKeyEnum.dailySign) {
|
| | | if (signState == 0) {
|
| | | taskClassVO.setLightUp(true); // 签到失败
|
| | |
| | | taskClassVO.setLightUp(true);
|
| | | }
|
| | |
|
| | | Integer dateType = 1; // 查询当日
|
| | | if (uniqueKey == UniqueKeyEnum.orderReward)
|
| | | // 查询当日
|
| | | Integer dateType = 1; |
| | | if (uniqueKey == UniqueKeyEnum.orderReward || uniqueKey == UniqueKeyEnum.accountMaintain) |
| | | dateType = null; // 查询历史
|
| | |
|
| | | Long id = taskClassVO.getId();
|
| | |
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | Gson gson = gsonBuilder.create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("result", gson.toJson(exchange));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
| | | out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 兑换金币
|
| | |
| | | try {
|
| | | IntegralExchange exchange = integralExchangeService.exchange(uid, id);
|
| | |
|
| | | UserInfoExtra extraVO = userInfoExtraService.getUserInfoExtra(uid);
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | Gson gson = gsonBuilder.create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("result", gson.toJson(exchange));
|
| | | data.put("goldCoin", extraVO.getGoldCoin() + "枚");
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (IntegralExchangeException e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
|
| | |
| | | @RequestMapping(value = "exchangeInviteCode", method = RequestMethod.POST)
|
| | | public void exchangeInviteCode(AcceptData acceptData, Long uid, Long id, PrintWriter out) {
|
| | | try {
|
| | | integralExchangeService.exchangeInviteCode(uid, id);
|
| | | out.print(JsonUtil.loadTrueResult("邀请码激活成功"));
|
| | | String inviteCode = integralExchangeService.exchangeInviteCode(uid, id);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("msg", "兑换成功,金币已消耗 ");
|
| | | data.put("inviteCode", inviteCode);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (IntegralExchangeException e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
|
| | | }
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | List<CodePublishRecord> list = codePublishRecordService.listValid((page - 1) * Constant.PAGE_SIZE,
|
| | | Constant.PAGE_SIZE);
|
| | | if (list == null) {
|
| | | list = new ArrayList<CodePublishRecord>();
|
| | | try {
|
| | | List<CodePublishRecord> list = codePublishRecordService.listValid((page - 1) * Constant.PAGE_SIZE,
|
| | | Constant.PAGE_SIZE);
|
| | | if (list == null) {
|
| | | list = new ArrayList<CodePublishRecord>();
|
| | | }
|
| | |
|
| | | long count = codePublishRecordService.countValid();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", count);
|
| | | data.put("list", getGson().toJson(list));
|
| | | data.put("helpLink", configService.get("publish_list_help_link"));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "获取失败"));
|
| | | return;
|
| | | }
|
| | |
|
| | | long count = codePublishRecordService.countValid();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", count);
|
| | | data.put("list", getGson().toJson(list));
|
| | | data.put("helpLink", configService.get("publish_list_help_link"));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "pushEvent", method = RequestMethod.POST)
|
| | | public void pushEvent(AcceptData acceptData, String event, Long uid, PrintWriter out) {
|
| | | public void pushEvent(AcceptData acceptData, String event, Long uid, String data, PrintWriter out) {
|
| | | if (uid == null || uid == 0) {
|
| | | out.print(JsonUtil.loadFalseResult("用户尚未登录"));
|
| | | return;
|
| | |
| | | return;
|
| | | }
|
| | | IntegralTaskRecord record = null;
|
| | | try {
|
| | | record = integralGetService.addEventStatistic(uid, event, null);
|
| | | } catch (IntegralGetException e) {
|
| | | }
|
| | | if (record == null) {
|
| | | out.print(JsonUtil.loadFalseResult("添加失败"));
|
| | | return;
|
| | |
|
| | | if (TaskUniqueKeyEnum.recommendSearch.name().equalsIgnoreCase(event)) {
|
| | | record = integralGetService.addRecommendSearch(uid);
|
| | | } else if (TaskUniqueKeyEnum.shareInvite.name().equalsIgnoreCase(event)) {
|
| | | record = integralGetService.addShareInvite(uid);
|
| | | } else if (TaskUniqueKeyEnum.inShop.name().equalsIgnoreCase(event)) {
|
| | | JSONObject json = JSONObject.fromObject(data);
|
| | | record = integralGetService.addIntoShop(uid, StringUtil.Md5(json.optString("url")));
|
| | | } else if (TaskUniqueKeyEnum.scanPush.name().equalsIgnoreCase(event)) {
|
| | | record = integralGetService.addScanPushHistory(uid);
|
| | | } else if (TaskUniqueKeyEnum.scanGoods.name().equalsIgnoreCase(event)) {
|
| | | JSONObject json = JSONObject.fromObject(data);
|
| | | record = integralGetService.addScanGoodsDetail(uid, json.optInt("goodsType"), json.optLong("goodsId"));
|
| | | } else if (TaskUniqueKeyEnum.scanHomeBanner.name().equalsIgnoreCase(event)) {
|
| | | JSONObject json = JSONObject.fromObject(data);
|
| | | record = integralGetService.addScanRecommendBanner(uid, json.optString("id"));
|
| | | } else if (TaskUniqueKeyEnum.scanSpecial.name().equalsIgnoreCase(event)) {
|
| | | JSONObject json = JSONObject.fromObject(data);
|
| | | record = integralGetService.addScanRecommendSpecial(uid, json.optString("id"));
|
| | | } else if (TaskUniqueKeyEnum.scanTBCart.name().equalsIgnoreCase(event)) {
|
| | | record = integralGetService.addScanTaoBaoCart(uid);
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | if ("recommendSearch".equalsIgnoreCase(event) || "scanGoods".equalsIgnoreCase(event)
|
| | | || "scanTBCart".equalsIgnoreCase(event)) {
|
| | | JSONObject notify = new JSONObject();
|
| | | switch (event) {
|
| | | case "recommendSearch":
|
| | | notify.put("name", "完成一次智能搜索");
|
| | | break;
|
| | | case "scanGoods":
|
| | | notify.put("name", "完成一次商品浏览");
|
| | | break;
|
| | | case "scanTBCart":
|
| | | notify.put("name", "完成一次购物车浏览");
|
| | | break;
|
| | | if (record != null) {
|
| | | JSONObject notifyData = new JSONObject();
|
| | | if (TaskUniqueKeyEnum.recommendSearch.name().equalsIgnoreCase(event)
|
| | | || TaskUniqueKeyEnum.scanGoods.name().equalsIgnoreCase(event)
|
| | | || TaskUniqueKeyEnum.scanTBCart.name().equalsIgnoreCase(event)) {
|
| | | JSONObject notify = new JSONObject();
|
| | | if (TaskUniqueKeyEnum.recommendSearch.name().equalsIgnoreCase(event))
|
| | | notify.put("name", "完成一次智能搜索");
|
| | | else if (TaskUniqueKeyEnum.scanGoods.name().equalsIgnoreCase(event))
|
| | | notify.put("name", "完成一次商品浏览");
|
| | | else if (TaskUniqueKeyEnum.scanTBCart.name().equalsIgnoreCase(event))
|
| | | notify.put("name", "完成一次购物车浏览");
|
| | |
|
| | | notify.put("score", String.format("+%s金币", record.getGoldCoin()));
|
| | | notifyData.put("notify", notify);
|
| | | }
|
| | | notify.put("score", String.format("+%s金币", record.getGoldCoin()));
|
| | | data.put("notify", notify);
|
| | | out.print(JsonUtil.loadTrueResult(notifyData));
|
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult(""));
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|