From 3824cbcaec6e6c67418d5280a53e9c2fedeef6f9 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 11 七月 2019 16:34:13 +0800
Subject: [PATCH] 订单bug,分享爆款自购修改

---
 fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java |   31 +++++++++++++++++++++++--------
 1 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java
index b97e0aa..6b87a8b 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java
+++ b/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);
 		}

--
Gitblit v1.8.0