From 36681e15e12aaa9135f69260472de65303cdcba3 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 26 四月 2022 19:10:45 +0800 Subject: [PATCH] 任务优化 --- app/src/main/java/com/yeshi/makemoney/app/controller/client/api/GoldCornController.java | 86 ++++++++++++++++++++++++++++++------------ 1 files changed, 61 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/com/yeshi/makemoney/app/controller/client/api/GoldCornController.java b/app/src/main/java/com/yeshi/makemoney/app/controller/client/api/GoldCornController.java index cfbe335..ca43199 100644 --- a/app/src/main/java/com/yeshi/makemoney/app/controller/client/api/GoldCornController.java +++ b/app/src/main/java/com/yeshi/makemoney/app/controller/client/api/GoldCornController.java @@ -16,6 +16,7 @@ import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornGetRecordService; import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornMakeService; import com.yeshi.makemoney.app.service.inter.team.TeamInviteRelationService; +import com.yeshi.makemoney.app.service.inter.user.UserExtraInfoService; import com.yeshi.makemoney.app.service.query.goldcorn.GoldCornConsumeRecordQuery; import com.yeshi.makemoney.app.service.query.goldcorn.GoldCornGetRecordQuery; import com.yeshi.makemoney.app.utils.Constant; @@ -25,6 +26,7 @@ import com.yeshi.makemoney.app.vo.goldcorn.*; import net.sf.json.JSONArray; import net.sf.json.JSONObject; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @@ -34,6 +36,7 @@ import javax.annotation.Resource; import java.lang.reflect.Type; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; /** @@ -60,6 +63,12 @@ @Resource private TeamInviteRelationService teamInviteRelationService; + + @Resource + private UserExtraInfoService userExtraInfoService; + + @Resource + private RedisTemplate<String, Object> redisTemplate; private Gson gson = JsonUtil.getConvertBigDecimalToStringBuilder(new GsonBuilder()).create(); @@ -194,34 +203,41 @@ @UserLogin(uid = "#uid") @RequestMapping("doTask") @ResponseBody - public String doTask(AcceptData acceptData, Long uid, String taskData) { - Type type = new TypeToken<List<GoldCornDoTaskVO>>() { - }.getType(); - List<GoldCornDoTaskVO> list = null; + public String doTask(AcceptData acceptData, Long uid, GoldCornDoTaskVO vo) { + + if (vo.getType() == null) { + return JsonUtil.loadFalseResult("鍙傛暟涓嶅畬鏁�"); + } try { - list = gson.fromJson(taskData, type); - } catch (Exception e) { - - } - if (list == null) { - return JsonUtil.loadFalseResult("鏁版嵁涓虹┖"); - } - - for (GoldCornDoTaskVO vo : list) { - try { - goldCornMakeService.addGoldCorn(uid, vo.getType(), vo.getDouble() == null ? false : vo.getDouble(), new Date(vo.getFinishTime() == null ? System.currentTimeMillis() : vo.getFinishTime()), null); - } catch (UserInfoException e) { - e.printStackTrace(); - } catch (GoldCornGetPriceException e) { - e.printStackTrace(); - } catch (GoldCornGetFrequencyConfigException e) { - e.printStackTrace(); - } catch (GoldCornMakeException e) { - e.printStackTrace(); + JSONObject data = new JSONObject(); + Integer result = null; + if (vo.getType() == GoldCornGetType.watchVideo) { + result = goldCornMakeService.watchVideo(uid, vo.getDouble(), vo.getFinishTime() == null ? new Date() : new Date(vo.getFinishTime()), vo.getTimeSeconds()); + } else if (vo.getType() == GoldCornGetType.readNovel) { + result = goldCornMakeService.readNovel(uid, vo.getDouble(), vo.getFinishTime() == null ? new Date() : new Date(vo.getFinishTime()), vo.getTimeSeconds()); + } else if (vo.getType() == GoldCornGetType.scanNews) { + result = goldCornMakeService.scanNews(uid, vo.getDouble(), vo.getFinishTime() == null ? new Date() : new Date(vo.getFinishTime()), vo.getNum()); + } else { + return JsonUtil.loadFalseResult("浠诲姟绫诲瀷鍑洪敊"); } + data.put("goldCorn", result); + + return JsonUtil.loadTrueResult(data); + + } catch (GoldCornGetPriceException e) { + e.printStackTrace(); + return JsonUtil.loadFalseResult("涓氬姟閿欒"); + } catch (UserInfoException e) { + e.printStackTrace(); + return JsonUtil.loadFalseResult(e.getMessage()); + } catch (GoldCornMakeException e) { + e.printStackTrace(); + return JsonUtil.loadFalseResult(e.getMessage()); + } catch (GoldCornGetFrequencyConfigException e) { + e.printStackTrace(); + return JsonUtil.loadFalseResult(e.getMessage()); } - return JsonUtil.loadTrueResult(""); } @@ -246,6 +262,7 @@ if (uid != null) { vo.setSignIned(goldCornMakeService.isSignIn(uid, now)); vo.setContinueSignInDay(goldCornMakeService.getContinueSignDay(uid)); + vo.setNotify(userExtraInfoService.getSignInNotify(uid)); } /*************绛惧埌鏃ユ湡鍒楄〃寮�濮�**************/ @@ -293,7 +310,7 @@ } else { dayDiff++; //鏈潵鐨勬椂闂� - dayInfo.setGoldCorn(goldCornGetPriceService.getSingInPrice(acceptData.getSystem(), vo.getContinueSignInDay() + 1 + dayDiff)); + dayInfo.setGoldCorn(goldCornGetPriceService.getSingInPrice(acceptData.getSystem(), vo.getContinueSignInDay() + (vo.isSignIned() ? 0 : 1) + dayDiff)); dayInfo.setState(SignInInfoVO.SignInDayInfo.STATE_NOT_GOT); } //娓呴櫎涓存椂鍙橀噺 @@ -354,4 +371,23 @@ } + + /** + * @return java.lang.String + * @author hxh + * @description 璁剧疆绛惧埌鎻愰啋 + * @date 10:39 2022/4/22 + * @param: acceptData + * @param: uid + * @param: notify 鏄惁鎻愰啋 + **/ + @UserLogin(uid = "#uid") + @RequestMapping("setSignInNotify") + @ResponseBody + public String setSignInNotify(AcceptData acceptData, Long uid, boolean notify) { + userExtraInfoService.setSignInNotify(uid, notify); + return JsonUtil.loadTrueResult(""); + } + + } -- Gitblit v1.8.0