From 15bedcc619b1edb6eb987f9288db7670e5b38c46 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 07 五月 2022 19:42:23 +0800
Subject: [PATCH] bug修复
---
app/src/main/java/com/yeshi/makemoney/app/controller/client/api/GoldCornController.java | 206 +++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 182 insertions(+), 24 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..e85e6f4 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
@@ -3,21 +3,20 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
-import com.yeshi.makemoney.app.entity.goldcorn.GoldCornConsumeRecord;
-import com.yeshi.makemoney.app.entity.goldcorn.GoldCornConsumeType;
-import com.yeshi.makemoney.app.entity.goldcorn.GoldCornGetRecord;
-import com.yeshi.makemoney.app.entity.goldcorn.GoldCornGetType;
+import com.yeshi.makemoney.app.dto.goldcorn.GoldCornMakeResultDTO;
+import com.yeshi.makemoney.app.entity.goldcorn.*;
+import com.yeshi.makemoney.app.entity.user.UserInfo;
import com.yeshi.makemoney.app.exception.goldcorn.GoldCornGetFrequencyConfigException;
import com.yeshi.makemoney.app.exception.goldcorn.GoldCornGetPriceException;
import com.yeshi.makemoney.app.exception.goldcorn.GoldCornMakeException;
import com.yeshi.makemoney.app.exception.user.UserInfoException;
-import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornConsumeRecordService;
-import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornGetPriceService;
-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.goldcorn.*;
import com.yeshi.makemoney.app.service.inter.team.TeamInviteRelationService;
+import com.yeshi.makemoney.app.service.inter.user.UserExtraInfoService;
+import com.yeshi.makemoney.app.service.inter.user.UserInfoService;
import com.yeshi.makemoney.app.service.query.goldcorn.GoldCornConsumeRecordQuery;
import com.yeshi.makemoney.app.service.query.goldcorn.GoldCornGetRecordQuery;
+import com.yeshi.makemoney.app.service.query.goldcorn.GoldCornTaskTypeInfoQuery;
import com.yeshi.makemoney.app.utils.Constant;
import com.yeshi.makemoney.app.utils.annotation.UserLogin;
import com.yeshi.makemoney.app.utils.goldcorn.GoldCornUtil;
@@ -25,6 +24,9 @@
import com.yeshi.makemoney.app.vo.goldcorn.*;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+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;
/**
@@ -45,6 +48,9 @@
@Controller
@RequestMapping("api/v1/goldcorn")
public class GoldCornController {
+
+ Logger logger = LoggerFactory.getLogger(GoldCornController.class);
+
@Resource
private GoldCornGetRecordService goldCornGetRecordService;
@@ -60,6 +66,21 @@
@Resource
private TeamInviteRelationService teamInviteRelationService;
+
+ @Resource
+ private UserExtraInfoService userExtraInfoService;
+
+ @Resource
+ private UserInfoService userInfoService;
+
+ @Resource
+ private RedisTemplate<String, Object> redisTemplate;
+
+ @Resource
+ private GoldCornTaskTypeInfoService goldCornTaskTypeInfoService;
+
+ @Resource
+ private GoldCornGetFrequencyConfigService goldCornGetFrequencyConfigService;
private Gson gson = JsonUtil.getConvertBigDecimalToStringBuilder(new GsonBuilder()).create();
@@ -194,34 +215,151 @@
@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) {
+ JSONObject data = new JSONObject();
+ GoldCornMakeResultDTO result = null;
+ if (vo.getType() == GoldCornGetType.watchVideo) {
+ result = goldCornMakeService.watchVideo(uid, vo.getDoubles(), vo.getFinishTime() == null ? new Date() : new Date(vo.getFinishTime()), vo.getTimeSeconds());
+ } else if (vo.getType() == GoldCornGetType.readNovel) {
+ result = goldCornMakeService.readNovel(uid, vo.getDoubles() == null ? false : vo.getDoubles(), vo.getFinishTime() == null ? new Date() : new Date(vo.getFinishTime()), vo.getTimeSeconds());
+ } else if (vo.getType() == GoldCornGetType.scanNews) {
+ result = goldCornMakeService.scanNews(uid, vo.getDoubles() == null ? false : vo.getDoubles(), vo.getFinishTime() == null ? new Date() : new Date(vo.getFinishTime()), vo.getNum());
+ } else {
+ return JsonUtil.loadFalseResult("浠诲姟绫诲瀷鍑洪敊");
+ }
+ data.put("goldCorn", result.getGoldCorn());
+ data.put("leftCount", result.getLeftEventCount());
+ 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());
}
- if (list == null) {
- return JsonUtil.loadFalseResult("鏁版嵁涓虹┖");
+ }
+
+
+ /**
+ * @return java.lang.String
+ * @author hxh
+ * @description 鑾峰彇浠诲姟淇℃伅
+ * @date 18:58 2022/4/28
+ * @param: acceptData
+ * @param: uid
+ * @param: vo
+ **/
+ @RequestMapping("getTaskInfo")
+ @ResponseBody
+ public String getTaskInfo(AcceptData acceptData, Long uid, String type) {
+
+ GoldCornGetType goldCornGetType = GoldCornGetType.valueOf(type);
+ if (goldCornGetType == null) {
+ return JsonUtil.loadFalseResult("绫诲瀷涓嶅瓨鍦�");
}
- for (GoldCornDoTaskVO vo : list) {
+ Date now = new Date();
+ UserInfo user = null;
+ if (uid != null) {
+ user = userInfoService.get(uid);
+ }
+ //鑾峰彇鍗曚环
+ GoldCornGetPrice price = goldCornGetPriceService.getCountPrice(goldCornGetType, user, acceptData.getSystem(), now);
+ boolean finish = true;
+ if (uid != null) {
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();
+ if (goldCornMakeService.frequencyVerify(user, goldCornGetType, now) > 0) {
+ finish = false;
+ }
} catch (GoldCornGetFrequencyConfigException e) {
e.printStackTrace();
} catch (GoldCornMakeException e) {
e.printStackTrace();
+ finish=false;
+ }
+ } else {
+ finish = false;
+ }
+ JSONObject data = new JSONObject();
+ data.put("price", price.getCornNum());
+ data.put("finish", finish);
+ return JsonUtil.loadTrueResult(data);
+ }
+
+
+ /**
+ * @return java.lang.String
+ * @author hxh
+ * @description 鑾峰彇浠诲姟鍒楄〃
+ * @date 11:27 2022/4/28
+ * @param: acceptData
+ * @param: uid
+ **/
+ @RequestMapping("getTaskList")
+ @ResponseBody
+ public String getTaskList(AcceptData acceptData, Long uid) {
+ Date now = new Date();
+
+ GoldCornTaskTypeInfoQuery query = new GoldCornTaskTypeInfoQuery();
+ query.setSystem(acceptData.getSystem());
+ query.setShow(true);
+ query.setShowTime(now);
+
+ List<GoldCornTaskTypeInfo> list = goldCornTaskTypeInfoService.list(query, 1, 100);
+
+ List<GoldCornTaskVO> voList = new ArrayList<>();
+ if (list != null) {
+ UserInfo user = null;
+ if (uid != null) {
+ user = userInfoService.get(uid);
+ }
+ //鏌ヨ浠锋牸
+ List<GoldCornGetType> typeList = list.stream().map(item -> {
+ return item.getType();
+ }).collect(Collectors.toList());
+
+ Map<GoldCornGetType, GoldCornGetPrice> priceMap = goldCornGetPriceService.getCountPrice(typeList, user, acceptData.getSystem(), now);
+
+ Map<GoldCornGetType, Long> processMap = new HashMap<>();
+ if (uid != null) {
+ GoldCornGetRecordQuery goldCornGetRecordQuery = new GoldCornGetRecordQuery();
+ goldCornGetRecordQuery.setUid(uid);
+ goldCornGetRecordQuery.setDay(GoldCornUtil.getFormatDay(now));
+ //鑾峰彇浠婃棩鐨勮繘搴�
+ processMap = goldCornGetRecordService.sumEventCount(goldCornGetRecordQuery);
+ }
+ List<GoldCornGetFrequencyConfig> frequencyConfigs = goldCornGetFrequencyConfigService.listByTypes(typeList, acceptData.getSystem(), now);
+ Map<GoldCornGetType, GoldCornGetFrequencyConfig> frequencyConfigsMaps = frequencyConfigs.stream().collect(Collectors.toMap(GoldCornGetFrequencyConfig::getType, config -> config));
+
+
+ for (GoldCornTaskTypeInfo task : list) {
+ if (priceMap.get(task.getType()) == null) {
+ continue;
+ }
+ if (frequencyConfigsMaps.get(task.getType()) == null) {
+ continue;
+ }
+ GoldCornTaskVO vo = GoldCornTaskVO.create(task, priceMap.get(task.getType()), frequencyConfigsMaps.get(task.getType()), processMap.get(task.getType()));
+ voList.add(vo);
}
}
- return JsonUtil.loadTrueResult("");
+ JSONObject data = new JSONObject();
+ data.put("list", JsonUtil.getSimpleGson().toJson(voList));
+ data.put("count", voList.size());
+ return JsonUtil.loadTrueResult(data);
}
@@ -246,6 +384,7 @@
if (uid != null) {
vo.setSignIned(goldCornMakeService.isSignIn(uid, now));
vo.setContinueSignInDay(goldCornMakeService.getContinueSignDay(uid));
+ vo.setNotify(userExtraInfoService.getSignInNotify(uid));
}
/*************绛惧埌鏃ユ湡鍒楄〃寮�濮�**************/
@@ -293,7 +432,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 +493,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