From eb7f3343af839a7c71f16e8ada2b25d5e2201c08 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期一, 19 四月 2021 19:27:52 +0800 Subject: [PATCH] bug修复 --- src/main/java/com/yeshi/buwan/controller/api/GoldCornController.java | 82 ++++++++++++++++++++++++++++++---------- 1 files changed, 61 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/yeshi/buwan/controller/api/GoldCornController.java b/src/main/java/com/yeshi/buwan/controller/api/GoldCornController.java index a793804..652b62e 100644 --- a/src/main/java/com/yeshi/buwan/controller/api/GoldCornController.java +++ b/src/main/java/com/yeshi/buwan/controller/api/GoldCornController.java @@ -15,14 +15,13 @@ import com.yeshi.buwan.domain.jump.JumpDetail; import com.yeshi.buwan.domain.jump.JumpTypeEnum; import com.yeshi.buwan.dto.goldcorn.SignInGoldCornDateData; +import com.yeshi.buwan.exception.goldcorn.SignInException; +import com.yeshi.buwan.exception.user.LoginUserException; import com.yeshi.buwan.service.inter.goldcorn.GoldCornTaskActionDetailService; import com.yeshi.buwan.service.inter.goldcorn.SignInService; import com.yeshi.buwan.service.inter.system.SystemConfigService; import com.yeshi.buwan.service.manager.GoldCornManager; -import com.yeshi.buwan.util.Constant; -import com.yeshi.buwan.util.JsonUtil; -import com.yeshi.buwan.util.StringUtil; -import com.yeshi.buwan.util.TimeUtil; +import com.yeshi.buwan.util.*; import com.yeshi.buwan.vo.AcceptData; import com.yeshi.buwan.vo.goldcorn.GoldCornCouponVideoVO; import com.yeshi.buwan.vo.goldcorn.GoldCornRecordVO; @@ -71,17 +70,9 @@ @RequestMapping("makeGoldCorn") @ResponseBody public String makeGoldCorn(AcceptData acceptData, String code, String loginUid, String param1, String param2) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("goldCorn", 1); - return JsonUtil.loadTrueJson(jsonObject.toString()); - } - - @RequestMapping("signIn") - @ResponseBody - public String signIn(AcceptData acceptData, String loginUid) { try { - GoldCornGetSource source = goldCornManager.getGoldCornGetSource(CodeCornGetSourceType.signIn); - goldCornManager.addGoldCorn(loginUid, CodeCornGetSourceType.signIn, null, "绛惧埌", null); + GoldCornGetSource source = goldCornManager.getGoldCornGetSource(CodeCornGetSourceType.valueOf(code)); + goldCornManager.addGoldCorn(loginUid, CodeCornGetSourceType.valueOf(code), null, source.getSourceName(), ""); JSONObject jsonObject = new JSONObject(); jsonObject.put("goldCorn", source.getGoldCorn()); return JsonUtil.loadTrueJson(jsonObject.toString()); @@ -92,8 +83,57 @@ } catch (GoldTradeException e) { return JsonUtil.loadFalseJson(e.getMessage()); } catch (Exception e) { - return JsonUtil.loadFalseJson("绛惧埌澶辫触"); + e.printStackTrace(); + logger.error("娣诲姞褰辫璞嗗嚭閿�", e); + return JsonUtil.loadFalseJson("褰辫璞嗘坊鍔犲け璐�"); } + + } + + + @RequestMapping("canDoTask") + @ResponseBody + public String canDoTask(AcceptData acceptData, String loginUid, String code, String param2) { + + long time = goldCornManager.getNextDoTaskTime(CodeCornGetSourceType.valueOf(code), loginUid); + if (time <= 0) { + return JsonUtil.loadTrueJson(""); + } else { + long span = time - System.currentTimeMillis(); + int ss = (int) (span / 1000); + int h = ss / 3600; + int m = ss % 3600 / 60; + int s = ss % 60; + String st = ""; + if (h > 0) { + st += h + "灏忔椂"; + } + if (m != 0 || h > 0) + st += m + "鍒�"; + if (s > 0) + st += s + "绉�"; + return JsonUtil.loadFalseJson(String.format("璇风瓑寰� %s 鍚庡啀鍋氫换鍔�", st)); + + } + + } + + + @RequestMapping("signIn") + @ResponseBody + public String signIn(AcceptData acceptData, String loginUid) { + try { + int goldCorn = signInService.signIn(loginUid); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("goldCorn", goldCorn); + return JsonUtil.loadTrueJson(jsonObject.toString()); + } catch (LoginUserException e) { + return JsonUtil.loadFalseJson("绛惧埌鍑洪敊"); + } catch (SignInException e) { + e.printStackTrace(); + return JsonUtil.loadFalseJson(e.getMessage()); + } + } @RequestMapping("getSignInData") @@ -136,13 +176,13 @@ List<GoldCornRecord> list = goldCornManager.getRecordList(recordQuery, loginUid); List<GoldCornRecordVO> voList = new ArrayList<>(); for (GoldCornRecord record : list) { - voList.add(new GoldCornRecordVO(record.getTitle(), TimeUtil.getGernalTime(record.getCreateTime().getTime(), "yyyy.MM.dd HH:mm"), record.getType() == GoldCornRecord.TYPE_CONSUME ? 0 - record.getGoldCorn() : record.getGoldCorn())); + voList.add(new GoldCornRecordVO(record.getTitle(), record.getDesc(), TimeUtil.getGernalTime(record.getCreateTime().getTime(), "yyyy.MM.dd HH:mm"), record.getType() == GoldCornRecord.TYPE_CONSUME ? 0 - record.getGoldCorn() : record.getGoldCorn())); } long count = goldCornManager.getRecordCount(recordQuery, loginUid); JSONObject data = new JSONObject(); data.put("list", new Gson().toJson(voList)); data.put("count", count); - return JsonUtil.loadTrueJson(data.toString()); + return JsonUtilV2.loadTrueJson(data.toString()); } catch (Exception e) { e.printStackTrace(); } @@ -162,8 +202,8 @@ voList.add(new GoldCornCouponVideoVO("https://r1.ykimg.com/058400005FA60E6A14187C0791817503?x-oss-process=image/resize,w_290/interlace,1/quality,Q_80", jumpDetail, params.toString().replace("\"", "\\" + "\""))); voList.add(new GoldCornCouponVideoVO("https://r1.ykimg.com/058400005F2BA59B6AEB660E907A2B99?x-oss-process=image/resize,w_290/interlace,1/quality,Q_80", jumpDetail, params.toString().replace("\"", "\\" + "\""))); voList.add(new GoldCornCouponVideoVO("https://r1.ykimg.com/052700005DC9247B1B769182B50A8C21?x-oss-process=image/resize,w_290/interlace,1/quality,Q_80", jumpDetail, params.toString().replace("\"", "\\" + "\""))); -// if (voList.size() < 3) - voList.clear(); + if (voList.size() < 3) + voList.clear(); JSONObject data = new JSONObject(); data.put("list", new Gson().toJson(voList)); data.put("count", voList.size()); @@ -219,10 +259,10 @@ if (!hiddenList.contains(source.getSourceCode())) { if (map.get(source.getSourceCode()) == null) { - source.setSourceDesc(String.format("浠婃棩宸插畬鎴�%s/%s", 0, source.getMaxDayCount())); + vo.setDesc(source.getSourceDesc() + "锛�" + String.format("浠婃棩宸插畬鎴�%s/%s", 0, source.getMaxDayCount())); } else { vo.setEnable(map.get(source.getSourceCode()).getCount() < source.getMaxDayCount()); - source.setSourceDesc(String.format("浠婃棩宸插畬鎴�%s/%s", map.get(source.getSourceCode()).getCount(), source.getMaxDayCount())); + vo.setDesc(source.getSourceDesc() + "锛�" + String.format("浠婃棩宸插畬鎴�%s/%s", map.get(source.getSourceCode()).getCount(), source.getMaxDayCount())); } } else { vo.setGoldCorn("瀹炰粯娆�*" + source.getGoldCorn()); -- Gitblit v1.8.0