admin
2021-09-24 f788607ff771a47bc60d6a86e00b3433c40f3d2c
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;
    /**
     * 挣金币
@@ -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())) {
                            //华为是否正在上线
                            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());