admin
2019-07-11 3824cbcaec6e6c67418d5280a53e9c2fedeef6f9
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java
@@ -1392,7 +1392,7 @@
      map.put("page_no", page + "");
      map.put("page_size", pageSize + "");
      map.put("material_id", materialId + "");
      map.put("content_id", "561388751621");
//      map.put("content_id", "561388751621");
      String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true);
      System.out.println(resultStr);
@@ -1663,7 +1663,7 @@
               .optString("relation_id");
      } catch (TaoKeApiException e) {
         e.printStackTrace();
         LogHelper.error("渠道ID申请出错:" + resultJSON);
         LogHelper.error("渠道ID申请出错:" + e.getMsg());
      }
      return null;
@@ -1948,10 +1948,10 @@
   // 淘礼金创建
   public static TaoLiJinDTO createTaoLiJin(Long auctionId, String name, BigDecimal perface, int totalNum,
         Date sendStartTime, Date sendEndTime, Date useStartTime, Date useEndTime,String pid) {
         Date sendStartTime, Date sendEndTime, Date useStartTime, Date useEndTime,TaoKeAppInfo app) throws TaoKeApiException{
      Map<String, String> map = new HashMap<>();
      map.put("method", "taobao.tbk.dg.vegas.tlj.create");
      map.put("adzone_id", pid.split("_")[3]);
      map.put("adzone_id", app.getPid().split("_")[3]);
      map.put("item_id", auctionId + "");
      map.put("total_num", totalNum + "");
      map.put("name", name);
@@ -1971,24 +1971,39 @@
      
      if(useStartTime != null)
         map.put("use_start_time", TimeUtil.getGernalTime(useStartTime.getTime(), "yyyy-MM-dd"));
      TaoKeAppInfo app = new TaoKeAppInfo();
      app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
      app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
      try {
         String result = TaoKeBaseUtil.baseRequestForThreeTimes(map, app);
         JSONObject json = JSONObject.fromObject(result);
         System.out.println(json);
         JSONObject root = json.optJSONObject("tbk_dg_vegas_tlj_create_response");
         if (root != null && root.optJSONObject("result") != null) {
            if (root.optJSONObject("result").optBoolean("success")) {
               JSONObject modelJson = root.optJSONObject("result").optJSONObject("model");
               TaoLiJinDTO dto = new TaoLiJinDTO();
               dto.setRightsId(modelJson.optString("rights_id"));
               dto.setSendUrl(modelJson.optString("send_url"));
               return dto;
            }else{
               LogHelper.error(json);
            }
            // 接口返回异常
            String msgCode = root.optJSONObject("result").optString("msg_code");
            if (!StringUtil.isNullOrEmpty(msgCode)) {
                switch(msgCode){
                 case "FAIL_BIZ_ITEM_FORBIDDEN":
                    throw new TaoKeApiException(TaoKeApiException.CODE_TLJ_FORBIDDEN, "该商品不支持创建淘礼金红包");
                 case "FAIL_BIZ_ACCOUNT_UN_PAID":
                 case "PRE_FREEZE_ASSET_ACCOUNT_ERROR":
                    throw new TaoKeApiException(TaoKeApiException.CODE_TLJ_NO_MONEY, "官方玩法钱包余额不足");
                 default:
                    return null;
               }
            }
         }
      } catch (TaoKeApiException e) {
          throw e;
      } catch (Exception e) {
         LogHelper.errorDetailInfo(e);
      }