From f788607ff771a47bc60d6a86e00b3433c40f3d2c Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 24 九月 2021 15:22:03 +0800 Subject: [PATCH] 接入视频直播 --- src/main/java/com/yeshi/buwan/controller/api/GoldCornController.java | 116 ++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 96 insertions(+), 20 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..d57008e 100644 --- a/src/main/java/com/yeshi/buwan/controller/api/GoldCornController.java +++ b/src/main/java/com/yeshi/buwan/controller/api/GoldCornController.java @@ -14,21 +14,24 @@ import com.yeshi.buwan.domain.goldcorn.GoldCornTaskActionDetail; import com.yeshi.buwan.domain.jump.JumpDetail; import com.yeshi.buwan.domain.jump.JumpTypeEnum; +import com.yeshi.buwan.domain.system.DetailSystem; +import com.yeshi.buwan.domain.system.DetailSystemConfig; 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.imp.DetailSystemConfigService; 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; import com.yeshi.buwan.vo.goldcorn.GoldCornTaskVO; import com.yeshi.buwan.vo.goldcorn.SignInInfoVO; import net.sf.json.JSONObject; +import org.apache.solr.common.params.ConfigSetParams; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; @@ -57,6 +60,9 @@ @Resource private GoldCornTaskActionDetailService goldCornTaskActionDetailService; + @Resource + private DetailSystemConfigService configService; + /** * 鎸i噾甯� @@ -71,17 +77,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 +90,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.length() == 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(); + logger.error("绛惧埌鍑洪敊锛�", e); + return JsonUtil.loadFalseJson(e.getMessage()); + } + } @RequestMapping("getSignInData") @@ -108,11 +155,19 @@ SignInInfoVO.SignInConfig config = new SignInInfoVO.SignInConfig(); config.setRecordUrl(systemConfigService.getConfigValueByKeyCache("goldCornRecordUrl")); config.setRuleUrl(systemConfigService.getConfigValueByKeyCache("goldCornRuleUrl")); + + String action = systemConfigService.getConfigValueByKeyCache("useGoldCornAction"); + JSONObject actionJSON = JSONObject.fromObject(action); + Gson gson = new Gson(); + config.setUserJump(gson.fromJson(actionJSON.optJSONObject("jumpDetail").toString(), JumpDetail.class)); + config.setUserJumpParams(actionJSON.optString("params")); + signInInfo.setSignInConfig(config); signInInfo.setCanSignIn(!signInService.isTodaySignIned(loginUid, new Date())); return JsonUtil.loadTrueJson(new Gson().toJson(signInInfo)); } catch (Exception e) { e.printStackTrace(); + logger.error("鑾峰彇绛惧埌淇℃伅寮傚父锛�", e); } return JsonUtil.loadFalseJson("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇�"); } @@ -136,13 +191,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(); } @@ -177,7 +232,28 @@ List<GoldCornTaskVO> voList = new ArrayList<>(); try { //鐧诲綍 - List<GoldCornGetSource> list = goldCornManager.listGetCornSource(1, 20); + List<GoldCornGetSource> list1 = goldCornManager.listGetCornSource(1, 20); + + List<GoldCornGetSource> list = new ArrayList<>(); + list.addAll(list1); + + //鍒犻櫎鍗庝负娓犻亾鐨勭湅婵�鍔辫棰戜换鍔� + if (acceptData.getChannel().equalsIgnoreCase("huawei")) { + if (list != null && list.size() > 0) + for (int i = 0; i < list.size(); i++) { + if (list.get(i).getSourceCode().equalsIgnoreCase(CodeCornGetSourceType.watchRewardAd.name())) { + //鍗庝负鏄惁姝e湪涓婄嚎 + DetailSystemConfig onLiningVersionInfo = configService.getConfigByKey("ad_hw_online_version_info", new DetailSystem("44"), 1); + JSONObject onLiningVersionInfoJson = JSONObject.fromObject(onLiningVersionInfo.getValue()); + int onLiningVersionCode = onLiningVersionInfoJson.optInt("versionCode"); + if (acceptData.getVersion() >= onLiningVersionCode) { + list.remove(i); + break; + } + } + } + } + List<String> sourceCodes = new ArrayList<>(); for (GoldCornGetSource source : list) { @@ -219,10 +295,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