admin
2020-05-19 744594ef1a2f530fc3e86ea9dc48b62247f79420
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java
@@ -35,10 +35,12 @@
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.entity.integral.CodePublishRecord;
import com.yeshi.fanli.entity.integral.IntegralExchange;
import com.yeshi.fanli.entity.integral.IntegralExchange.ExchangeTypeEnum;
import com.yeshi.fanli.entity.integral.IntegralTask;
import com.yeshi.fanli.entity.integral.IntegralTask.TaskUniqueKeyEnum;
import com.yeshi.fanli.entity.integral.IntegralTaskClass.UniqueKeyEnum;
import com.yeshi.fanli.entity.integral.IntegralTaskRecord;
import com.yeshi.fanli.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.exception.integral.IntegralExchangeException;
import com.yeshi.fanli.exception.integral.IntegralTaskRecordException;
import com.yeshi.fanli.log.LogHelper;
@@ -58,6 +60,7 @@
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
import com.yeshi.fanli.vo.integral.DailySignVO;
import com.yeshi.fanli.vo.integral.ExchangeTipVO;
@@ -344,7 +347,7 @@
         JSONObject data = new JSONObject();
         data.put("goldCoin", goldCoin);
         out.print(JsonUtil.loadTrueResult(data));
      } catch (IntegralTaskRecordException e) {
      } catch (IntegralTaskRecordException e) {
         out.print(JsonUtil.loadFalseResult(e.getMsg()));
      }
   }
@@ -377,8 +380,22 @@
      List<IntegralExchange> list = integralExchangeRecordService.listExchange((page - 1) * Constant.PAGE_SIZE,
            Constant.PAGE_SIZE, uid);
      if (list == null)
         list = new ArrayList<IntegralExchange>();
      List<IntegralExchange> listNew = new ArrayList<>();
      if (list != null)
         listNew.addAll(list);
      if (VersionUtil.greaterThan_2_0_7(acceptData.getPlatform(), acceptData.getVersion())) {
         for (int i=0; i < listNew.size(); i ++) {
            IntegralExchange integralExchange = listNew.get(i);
            ExchangeTypeEnum type = integralExchange.getType();
            if (type != null &&
                  (type == ExchangeTypeEnum.inviteCodeActivate || type == ExchangeTypeEnum.inviteCodePublish)) {
               listNew.remove(i);
               i--;
            }
         }
      }
      // Long count = integralExchangeService.countValid();
@@ -387,9 +404,31 @@
      JSONObject data = new JSONObject();
      data.put("goldCoin", extraVO.getGoldCoin() + "枚");
      data.put("count", list.size());
      data.put("list", gson.toJson(list));
      data.put("count", listNew.size());
      data.put("list", gson.toJson(listNew));
      out.print(JsonUtil.loadTrueResult(data));
   }
   @RequestMapping(value = "getExchangeDetail")
   public void getExchangeDetail(AcceptData acceptData, Long id, String callback, PrintWriter out) {
      if (id == null || id <= 0) {
         out.print(JsonUtil.loadFalseResult(1, "兑换ID有误"));
         return;
      }
      IntegralExchange exchange = integralExchangeService.selectByPrimaryKey(id);
      if (exchange != null) {
         GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
         Gson gson = gsonBuilder.create();
         if (StringUtil.isNullOrEmpty(callback))
            out.print(JsonUtil.loadTrueResult(gson.toJson(exchange)));
         else
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(gson.toJson(exchange))));
      } else {
         if (StringUtil.isNullOrEmpty(callback))
            out.print(JsonUtil.loadFalseResult("未找到"));
         else
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("未找到")));
      }
   }
   /**
@@ -400,8 +439,8 @@
    * @param id
    * @param out
    */
   @RequestMapping(value = "verifyExchange", method = RequestMethod.POST)
   public void verifyExchange(AcceptData acceptData, Long uid, Long id, PrintWriter out) {
   @RequestMapping(value = "verifyExchange")
   public void verifyExchange(AcceptData acceptData, Long uid, Long id, String callback, PrintWriter out) {
      try {
         ExchangeTipVO exchange = integralExchangeService.verifyExchange(uid, id);
@@ -409,9 +448,17 @@
         Gson gson = gsonBuilder.create();
         JSONObject data = new JSONObject();
         data.put("result", gson.toJson(exchange));
         out.print(JsonUtil.loadTrueResult(data));
         if (StringUtil.isNullOrEmpty(callback)) {
            out.print(JsonUtil.loadTrueResult(data));
         } else {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
         }
      } catch (IntegralExchangeException e) {
         out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
         if (StringUtil.isNullOrEmpty(callback)) {
            out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
         } else {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, e.getMsg())));
         }
      }
   }
@@ -424,8 +471,8 @@
    * @param out
    */
   @RequestSerializableByKey(key = "'integralexchange-'+#uid")
   @RequestMapping(value = "exchange", method = RequestMethod.POST)
   public void exchange(AcceptData acceptData, Long uid, Long id, PrintWriter out) {
   @RequestMapping(value = "exchange")
   public void exchange(AcceptData acceptData, Long uid, Long id, String callback, PrintWriter out) {
      try {
         IntegralExchange exchange = integralExchangeService.exchange(uid, id);
@@ -437,9 +484,15 @@
         JSONObject data = new JSONObject();
         data.put("result", gson.toJson(exchange));
         data.put("goldCoin", extraVO.getGoldCoin() + "枚");
         out.print(JsonUtil.loadTrueResult(data));
         if (StringUtil.isNullOrEmpty(callback))
            out.print(JsonUtil.loadTrueResult(data));
         else
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
      } catch (IntegralExchangeException e) {
         out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
         if (StringUtil.isNullOrEmpty(callback))
            out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
         else
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, e.getMsg())));
      }
   }
@@ -504,7 +557,7 @@
      }
      try {
         List<CodePublishRecord> list = codePublishRecordService.listValid((page - 1) * Constant.PAGE_SIZE,
         List<CodePublishRecord> list = codePublishRecordService.listValid(null, (page - 1) * Constant.PAGE_SIZE,
               Constant.PAGE_SIZE);
         if (list == null) {
            list = new ArrayList<CodePublishRecord>();
@@ -515,7 +568,7 @@
         JSONObject data = new JSONObject();
         data.put("count", count);
         data.put("list", getGson().toJson(list));
         data.put("helpLink", configService.get("publish_list_help_link"));
         data.put("helpLink", configService.get(ConfigKeyEnum.publishListHelpLink.getKey()));
         out.print(JsonUtil.loadTrueResult(data));
      } catch (Exception e) {
         out.print(JsonUtil.loadFalseResult(1, "获取失败"));