From 2922e51a7a8e657a8467c818ae16700e41ddac77 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 10 五月 2022 19:45:58 +0800 Subject: [PATCH] bug修复 --- app/src/main/java/com/yeshi/makemoney/app/controller/client/api/GoldCornController.java | 87 ++++++++++++++++++++++++++++--------------- 1 files changed, 57 insertions(+), 30 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 e85e6f4..4a8d581 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 @@ -31,10 +31,16 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.yeshi.utils.JsonUtil; +import org.yeshi.utils.StringUtil; import org.yeshi.utils.TimeUtil; +import org.yeshi.utils.annotation.RequestSerializableByKey; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; import javax.annotation.Resource; import java.lang.reflect.Type; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -75,6 +81,9 @@ @Resource private RedisTemplate<String, Object> redisTemplate; + + @Resource + private JedisPool jedisPool; @Resource private GoldCornTaskTypeInfoService goldCornTaskTypeInfoService; @@ -167,9 +176,13 @@ List<GoldCornExchangeRecordVO> voList = new ArrayList<>(); for (GoldCornConsumeRecord record : recordList) { GoldCornExchangeRecordVO vo = new GoldCornExchangeRecordVO(); - vo.setDateTime(TimeUtil.getGernalTime(record.getCreateTime().getTime(), "yyyy.MM.dd HH:mm")); + if (record.getEventTime() == null) { + vo.setDateTime(TimeUtil.getGernalTime(record.getCreateTime().getTime(), "yyyy.MM.dd HH:mm")); + } else { + vo.setDateTime(TimeUtil.getGernalTime(record.getEventTime().getTime(), "yyyy.MM.dd")); + } vo.setNum(record.getCornNum()); - vo.setMoney(record.getMoney().setScale(2).toString()); + vo.setMoney(new BigDecimal(record.getMoney()).divide(new BigDecimal(100), 2, RoundingMode.FLOOR).toString()); voList.add(vo); } @@ -221,34 +234,48 @@ return JsonUtil.loadFalseResult("鍙傛暟涓嶅畬鏁�"); } - try { - 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()); + String key = "dotask-" + acceptData.getSign(); + Jedis jedis = jedisPool.getResource(); + try { + if (!StringUtil.isNullOrEmpty(jedis.get(key))) { + return JsonUtil.loadFalseResult("閲嶅鐨勮姹�"); + } + jedis.set(key, "1"); + //30鍒嗛挓鏈夋晥鏈� + jedis.expire(key, 60 * 30); + + try { + 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()); + } + } finally { + jedis.close(); } } @@ -288,7 +315,7 @@ e.printStackTrace(); } catch (GoldCornMakeException e) { e.printStackTrace(); - finish=false; + finish = false; } } else { finish = false; -- Gitblit v1.8.0