yujian
2020-06-12 8a54915d3c39d9d8d7e90c0971d1e19d0eb76622
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserCloudControllerV2.java
@@ -8,8 +8,6 @@
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -35,9 +33,6 @@
import com.yeshi.fanli.entity.dynamic.GoodsEvaluate;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.exception.taobao.TaoKeApiException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.exception.user.cloud.UserCloudException;
import com.yeshi.fanli.exception.user.cloud.UserCloudGroupException;
import com.yeshi.fanli.log.LogHelper;
@@ -59,7 +54,6 @@
import com.yeshi.fanli.util.aitaoker.AitaokerApiUtil;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.util.suning.SuningUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import com.yeshi.fanli.vo.user.cloud.CloudOrderMenuVO;
import com.yeshi.fanli.vo.user.cloud.UserCloudInfoVO;
@@ -398,7 +392,7 @@
    * @param out
    */
   @RequestMapping(value = "switchCircleState")
   public void switchCircleState(String callback, AcceptData acceptData, Long uid, Boolean state, PrintWriter out) {
   public void switchCircleState(String callback, AcceptData acceptData, Long uid, Integer state, PrintWriter out) {
      if (uid == null) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
         return;
@@ -407,8 +401,14 @@
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "状态不能为空"));
         return;
      }
      boolean reslut = false;
      if (state == 1) {
         reslut = true;
      }
      try {
         userCloudGroupService.switchCircleState(uid, state);
         userCloudGroupService.switchCircleState(uid, reslut);
      } catch (UserCloudGroupException e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
      }
@@ -457,7 +457,7 @@
    * @param out
    */
   @RequestMapping(value = "switchGroupState")
   public void switchGroupState(String callback, AcceptData acceptData, Long uid, Long id, Boolean state,
   public void switchGroupState(String callback, AcceptData acceptData, Long uid, Long id, Integer state,
         PrintWriter out) {
      if (uid == null) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
@@ -467,12 +467,60 @@
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "参数不能为空"));
         return;
      }
      boolean reslut = false;
      if (state == 1) {
         reslut = true;
      }
      try {
         userCloudGroupService.switchGroupState(uid, id, state);
         userCloudGroupService.switchGroupState(uid, id, reslut);
         // 获取最新群
         List<UserCloudGroup> list = userCloudGroupService.listGroupByUid(uid);
         if (list == null)
            list = new ArrayList<>();
         JSONObject data = new JSONObject();
         data.put("listGroup", list);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (UserCloudGroupException e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
      }
      JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
   }
   /**
    * 设置状态
    *
    * @param callback
    * @param acceptData
    * @param uid
    * @param type
    * @param out
    */
   @RequestMapping(value = "deleteGroup")
   public void switchGroupState(String callback, AcceptData acceptData, Long uid, Long id,
         PrintWriter out) {
      if (uid == null || id == null) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "参数不完整"));
         return;
      }
      try {
         userCloudGroupService.deleteGroup(uid, id);
         // 获取最新群
         List<UserCloudGroup> list = userCloudGroupService.listGroupByUid(uid);
         if (list == null)
            list = new ArrayList<>();
         JSONObject data = new JSONObject();
         data.put("listGroup", list);
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
      } catch (UserCloudGroupException e) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
      }
   }
   /**
@@ -502,27 +550,6 @@
      JSONArray array = new JSONArray();
      JSONObject data = new JSONObject();
      if (list.size() > 0) {
         List<Long> listGid = new ArrayList<Long>();
         for (UserCloudGoods cloudGoods : list) {
            CommonGoods commonGoods = cloudGoods.getCommonGoods();
            if (commonGoods == null) {
               continue;
            }
            listGid.add(commonGoods.getGoodsId());
         }
         // API网络接口验证是否在售
         List<TaoBaoGoodsBrief> listTaoKeGoods = null;
         try {
            listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
         } catch (TaoKeApiException e) {
            e.printStackTrace();
         } catch (TaobaoGoodsDownException e) {
            e.printStackTrace();
         } catch (Exception e) {
            e.printStackTrace();
         }
         Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
               .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
         ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
@@ -534,22 +561,6 @@
               continue;
            }
            // 淘宝商品验证在售
            if (commonGoods.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
               if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) {
                  int state = 1; // 默认停售
                  Long goodsId = commonGoods.getGoodsId();
                  for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
                     Long auctionId = taoKeGoods.getAuctionId();
                     if (goodsId == auctionId || goodsId.equals(auctionId)) {
                        state = 0; // 在售
                        break;
                     }
                  }
                  commonGoods.setState(state);
               }
            }
            // 判断是否已分享, 已分享显示已下架
            Integer state = cloudGoods.getState();
            if (state != null && state == UserCloudGoods.STATE_SHARED) {
@@ -558,7 +569,11 @@
                  commonGoods.setState(2);
               }
            }
            if (state != null && state == UserCloudGoods.STATE_INVALID) {
               commonGoods.setState(1);
            }
            GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, paramsDTO);
            detailVO.setId(commonGoods.getId());
@@ -624,18 +639,26 @@
    * @param out
    */
   @RequestMapping(value = "switchState")
   public void switchState(String callback, AcceptData acceptData, Long uid, Integer type, Boolean state,
   public void switchState(String callback, AcceptData acceptData, Long uid, Integer type, Integer state,
         PrintWriter out) {
      if (uid == null) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
      if (uid == null || type == null || state == null) {
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "参数不完整"));
         return;
      }
      if (type == 1) {
         userCloudManageService.save(uid, state, null);
      } else {
         userCloudManageService.save(uid, null, state);
      boolean reslut = false;
      if (state == 1) {
         reslut = true;
      }
      JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
      if (type == 1) {
         userCloudManageService.save(uid, reslut, null);
      } else {
         userCloudManageService.save(uid, null, reslut);
      }
      JSONObject data = new JSONObject();
      data.put("state", reslut);
      JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
   }
   /**
@@ -674,9 +697,7 @@
         key = StringUtil.Md5(key);
         redisManager.cacheCommonString(key , builder.toString() , 60*10);
         
         System.out.println(builder.toString());
         String link = "http://192.168.1.200:8008/fanli/client/v1/cloud/callback/payUrl?key=%s";
         String link = configService.get(ConfigKeyEnum.cloudAlipayJumpLink.getKey()) +"?key=%s";
         JSONObject dataObject = new JSONObject();
         dataObject.put("link", String.format(link, key));
         JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(dataObject));