From c9db68e33f90231b064b8864fc69ccf7d25f5e0b Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 25 八月 2022 17:55:40 +0800 Subject: [PATCH] 淘宝商品ID字符串化 --- facade-lijin/src/main/java/com/ks/lijin/utils/taobao/TaoKeApiUtil.java | 558 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 545 insertions(+), 13 deletions(-) diff --git a/facade-lijin/src/main/java/com/ks/lijin/utils/taobao/TaoKeApiUtil.java b/facade-lijin/src/main/java/com/ks/lijin/utils/taobao/TaoKeApiUtil.java index af88e77..a9f42c6 100644 --- a/facade-lijin/src/main/java/com/ks/lijin/utils/taobao/TaoKeApiUtil.java +++ b/facade-lijin/src/main/java/com/ks/lijin/utils/taobao/TaoKeApiUtil.java @@ -1,18 +1,19 @@ package com.ks.lijin.utils.taobao; -import com.ks.lijin.exception.LiJinException; -import com.ks.lijin.exception.TaoKeApiException; -import com.ks.lijin.pojo.DTO.taobao.TaoKeAppInfo; -import com.ks.lijin.pojo.DTO.taobao.TaoLiJinDTO; +import com.google.gson.Gson; +import com.ks.lijin.exception.*; +import com.ks.lijin.pojo.DTO.taobao.*; +import com.ks.lijin.pojo.PageEntity; import com.taobao.api.internal.util.StringUtils; +import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; +import com.yeshi.goods.facade.entity.taobao.TaoBaoHead; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.params.HttpConnectionManagerParams; import org.yeshi.utils.*; -import org.yeshi.utils.taobao.TbImgUtil; import java.math.BigDecimal; import java.net.URLEncoder; @@ -25,10 +26,9 @@ private static Map<String, Integer> invalidMap = new HashMap<>(); // 娣樼ぜ閲戝垱寤� - public static TaoLiJinDTO createTaoLiJin(Long auctionId, String name, BigDecimal perface, int totalNum, + public static TaoLiJinDTO createTaoLiJin(String auctionId, String name, BigDecimal perface, int totalNum, Date sendStartTime, Date sendEndTime, Date useStartTime, Date useEndTime, TaoKeAppInfo app) - throws LiJinException, TaoKeApiException { - + throws LiJinAccountException, LiJinAmountException, LiJinException, LiJinGoodsException { Map<String, String> map = new HashMap<>(); map.put("method", "taobao.tbk.dg.vegas.tlj.create"); map.put("adzone_id", app.getPid().split("_")[3]); @@ -69,17 +69,174 @@ // 鎺ュ彛杩斿洖寮傚父 String msgCode = root.optJSONObject("result").optString("msg_code"); + String msgInfo = root.optJSONObject("result").optString("msg_info"); if (!StringUtil.isNullOrEmpty(msgCode)) { // TLJLogHelper.info(auctionId, root.toString());// 娣樼ぜ閲戝紓甯镐俊鎭褰� TODO switch (msgCode) { case "FAIL_BIZ_ITEM_FORBIDDEN": - throw new LiJinException(LiJinException.CODE_TLJ_FORBIDDEN, "璇ュ晢鍝佷笉鏀寔鍒涘缓娣樼ぜ閲戠孩鍖�"); + throw new LiJinGoodsException(LiJinGoodsException.CODE_GOODS_NOT_SUPPORT, "璇ュ晢鍝佷笉鏀寔鍒涘缓娣樼ぜ閲戠孩鍖�"); case "FAIL_BIZ_ACCOUNT_UN_PAID": - throw new LiJinException(LiJinException.CODE_TLJ_UN_PAID, "鎮ㄧ殑娣樼ぜ閲戣处鎴锋殏鏈垱寤猴紝璇峰墠寰�璧勯噾绠$悊椤甸潰鍏呭��"); + throw new LiJinAccountException(LiJinAccountException.CODE_TLJ_UN_PAID, "鎮ㄧ殑娣樼ぜ閲戣处鎴锋殏鏈垱寤猴紝璇峰墠寰�璧勯噾绠$悊椤甸潰鍏呭��"); case "PRE_FREEZE_ASSET_ACCOUNT_ERROR": - throw new LiJinException(LiJinException.CODE_TLJ_NO_MONEY, "瀹樻柟鐜╂硶閽卞寘浣欓涓嶈冻"); + throw new LiJinAccountException(LiJinAccountException.CODE_TLJ_NO_MONEY, "瀹樻柟鐜╂硶閽卞寘浣欓涓嶈冻"); + case "ASSET_ACCOUNT_BALANCE_NOT_ENOUGH": + throw new LiJinAccountException(LiJinAccountException.CODE_TLJ_NO_MONEY, "璐︽埛棰勭畻涓嶈冻"); + case "FAIL_CHECK_MEMBER_DAILY_SEND_ITEM_ABOVE_LIMIT_ERROR": + throw new LiJinAccountException(LiJinAccountException.CODE_TLJ_NO_GOODS, "浠婃棩鍟嗗搧鍒涘缓鏁板凡瓒呬笂闄愶紝璇锋偍鏄庢棩鍐嶈瘯"); + case "DAILY_DRAW_ITEM_ABOVE_LIMIT": + case "FAIL_CHECK_ITEM_DAILY_SEND_NUM_CHECK_ERROR": + throw new LiJinGoodsException(LiJinGoodsException.CODE_GOODS_CREATED_FULL, "浠婃棩璇ュ晢鍝佹窐绀奸噾鍒涘缓鏁板凡瓒呬笂闄愶紝璇锋偍鏄庢棩鍐嶈瘯"); + + case "FAIL_CHECK_TLJ_MIN_FACE_ERROR": + throw new LiJinAmountException(LiJinAmountException.CODE_LIJIN_AMOUNT_OUTOFRANGE, msgInfo); default: - throw new TaoKeApiException(Integer.parseInt(msgCode), root.toString()); + throw new LiJinException(1, root.toString()); + } + } + } + } catch (LiJinException e) { + throw e; + } + + return null; + } + + + /** + * 娣樼ぜ閲戞姤鍛� + * + * @param rightsId + * @param app + * @return + * @throws LiJinAccountException + * @throws LiJinAmountException + * @throws LiJinException + * @throws LiJinGoodsException + */ + public static TaoLiJinReportDTO taolijinReport(String rightsId, TaoKeAppInfo app) { + Map<String, String> map = new HashMap<>(); + map.put("method", "taobao.tbk.dg.vegas.tlj.report"); + map.put("adzone_id", app.getPid().split("_")[3]); + map.put("rights_id", rightsId); + + String result = baseRequestForThreeTimes(map, app); + JSONObject json = JSONObject.fromObject(result); + System.out.println(json); + JSONObject root = json.optJSONObject("tbk_dg_vegas_tlj_report_response"); + + if (root != null && root.optBoolean("result_success")) { + JSONObject modelJson = root.optJSONObject("model").optJSONObject("extra"); + if (modelJson != null && modelJson.size() > 0) { + TaoLiJinReportDTO report = new TaoLiJinReportDTO(); + report.setWin_amount(new BigDecimal(modelJson.optString("win_sum_amt"))); + report.setWin_num(modelJson.optInt("win_pv")); + report.setRefund_amount(new BigDecimal(modelJson.optString("refund_sum_amt"))); + report.setRefund_num(modelJson.optInt("refund_num")); + report.setAlipay_amount(new BigDecimal(modelJson.optString("alipay_amt"))); + report.setUse_amount(new BigDecimal(modelJson.optString("use_sum_amt"))); + report.setUse_num(modelJson.optInt("use_num")); + report.setUnfreeze_amount(new BigDecimal(modelJson.optString("remaining_amt"))); + report.setUnfreeze_num(modelJson.optInt("remaining_num")); + report.setPre_commission_amount(new BigDecimal(modelJson.optString("pre_pub_share_fee_for_disp"))); + return report; + } + } +// if (root != null && root.optJSONObject("result") != null) { +// if (root.optJSONObject("result").optBoolean("success")) { +// JSONObject modelJson = root.optJSONObject("result").optJSONObject("model"); +// TaoLiJinReportDTO dto = new Gson().fromJson(modelJson.toString(), TaoLiJinReportDTO.class); +// return dto; +// } else { +// // 鏃ュ織璁板綍 TODO +// } +// } + + + return null; + } + + + // 瑁傛窐绀奸噾鍒涘缓 + public static TaoLiJinDTO createLieBianTaoLiJin(String auctionId, String name, BigDecimal perface, int totalNum, + Date sendStartTime, Date sendEndTime, Date useStartTime, Date useEndTime, TaoKeAppInfo app) + throws LiJinAccountException, LiJinAmountException, LiJinException, LiJinGoodsException { + Map<String, String> map = new HashMap<>(); + map.put("method", "taobao.tbk.dg.vegas.lbtlj.create"); + map.put("adzone_id", app.getPid().split("_")[3]); + map.put("item_id", auctionId + ""); + //娣樼ぜ閲戞�讳釜鏁� + map.put("rights_num", totalNum + ""); + //瑁傚彉娣樼ぜ閲戞�讳釜鏁� + map.put("task_rights_num", totalNum + ""); + //瑁傚彉鍗曚釜娣樼ぜ閲戦潰棰濓紝鏀寔涓や綅灏忔暟锛屽崟浣嶅厓 + map.put("task_rights_per_face", "1.01"); + //瑁傚彉娣樼ぜ閲戦個璇蜂汉鏁� + map.put("invite_num", "2"); + //瑁傚彉娣樼ぜ閲戦個璇锋椂闀匡紱鍗曚綅锛氬垎閽燂紱鏈�澶�120鍒嗛挓 + map.put("invite_time_limit", "60"); + + + map.put("name", name); + map.put("user_total_win_num_limit", "1"); + map.put("security_switch", "false"); + map.put("rights_per_face", perface.toString()); + map.put("send_start_time", TimeUtil.getGernalTime(sendStartTime.getTime(), "yyyy-MM-dd HH:mm:ss")); + + if (sendEndTime != null) + map.put("send_end_time", TimeUtil.getGernalTime(sendEndTime.getTime(), "yyyy-MM-dd HH:mm:ss")); + + if (useEndTime != null) { + map.put("use_end_time", TimeUtil.getGernalTime(useEndTime.getTime(), "yyyy-MM-dd")); + map.put("use_end_time_mode", "2"); + } + + map.put("accept_start_time", TimeUtil.getGernalTime(sendStartTime.getTime(), "yyyy-MM-dd HH:mm:ss")); + map.put("accept_end_time", TimeUtil.getGernalTime(sendEndTime.getTime(), "yyyy-MM-dd HH:mm:ss")); + + + if (useStartTime != null) + map.put("use_start_time", TimeUtil.getGernalTime(useStartTime.getTime(), "yyyy-MM-dd")); + try { + String result = baseRequestForThreeTimes(map, app); + JSONObject json = JSONObject.fromObject(result); + System.out.println(result); + 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 { + // 鏃ュ織璁板綍 TODO + } + + // 鎺ュ彛杩斿洖寮傚父 + String msgCode = root.optJSONObject("result").optString("msg_code"); + String msgInfo = root.optJSONObject("result").optString("msg_info"); + if (!StringUtil.isNullOrEmpty(msgCode)) { + // TLJLogHelper.info(auctionId, root.toString());// 娣樼ぜ閲戝紓甯镐俊鎭褰� TODO + switch (msgCode) { + case "FAIL_BIZ_ITEM_FORBIDDEN": + throw new LiJinGoodsException(LiJinGoodsException.CODE_GOODS_NOT_SUPPORT, "璇ュ晢鍝佷笉鏀寔鍒涘缓娣樼ぜ閲戠孩鍖�"); + case "FAIL_BIZ_ACCOUNT_UN_PAID": + throw new LiJinAccountException(LiJinAccountException.CODE_TLJ_UN_PAID, "鎮ㄧ殑娣樼ぜ閲戣处鎴锋殏鏈垱寤猴紝璇峰墠寰�璧勯噾绠$悊椤甸潰鍏呭��"); + case "PRE_FREEZE_ASSET_ACCOUNT_ERROR": + throw new LiJinAccountException(LiJinAccountException.CODE_TLJ_NO_MONEY, "瀹樻柟鐜╂硶閽卞寘浣欓涓嶈冻"); + case "ASSET_ACCOUNT_BALANCE_NOT_ENOUGH": + throw new LiJinAccountException(LiJinAccountException.CODE_TLJ_NO_MONEY, "璐︽埛棰勭畻涓嶈冻"); + case "FAIL_CHECK_MEMBER_DAILY_SEND_ITEM_ABOVE_LIMIT_ERROR": + throw new LiJinAccountException(LiJinAccountException.CODE_TLJ_NO_GOODS, "浠婃棩鍟嗗搧鍒涘缓鏁板凡瓒呬笂闄愶紝璇锋偍鏄庢棩鍐嶈瘯"); + case "DAILY_DRAW_ITEM_ABOVE_LIMIT": + case "FAIL_CHECK_ITEM_DAILY_SEND_NUM_CHECK_ERROR": + throw new LiJinGoodsException(LiJinGoodsException.CODE_GOODS_CREATED_FULL, "浠婃棩璇ュ晢鍝佹窐绀奸噾鍒涘缓鏁板凡瓒呬笂闄愶紝璇锋偍鏄庢棩鍐嶈瘯"); + + case "FAIL_CHECK_TLJ_MIN_FACE_ERROR": + throw new LiJinAmountException(LiJinAmountException.CODE_LIJIN_AMOUNT_OUTOFRANGE, msgInfo); + default: + throw new LiJinException(1, root.toString()); } } } @@ -131,8 +288,9 @@ params.put("v", "2.0"); params.put("timestamp", TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); params.put("format", "json"); - if (!StringUtil.isNullOrEmpty(app.getAdzoneId())) + if (!StringUtil.isNullOrEmpty(app.getAdzoneId())) { params.put("adzone_id", app.getAdzoneId()); + } params.put("sign", getSign(params, "md5", app).toUpperCase()); String result = taoKeGet(params); JSONObject data = JSONObject.fromObject(result); @@ -231,17 +389,391 @@ String key = keys.next(); url += String.format("%s=%s&", key, URLEncoder.encode(params.get(key), "UTF-8")); } + System.out.println("娣樺璇锋眰杩炴帴锛�" + url); GetMethod method = new GetMethod(url); // 3S鐨勫搷搴旇秴鏃� HttpConnectionManagerParams hparams = new HttpConnectionManagerParams(); hparams.setConnectionTimeout(3000); client.getHttpConnectionManager().setParams(hparams); + client.executeMethod(method); + String result = method.getResponseBodyAsString(); + System.out.println(result); return method.getResponseBodyAsString(); } catch (Exception e) { e.printStackTrace(); } return ""; } + + + public static TaoBaoGoodsBrief searchGoodsDetail(String id) throws TaoBaoGoodsDownException { + return searchGoodsDetail(id, null, null); + } + + /** + * 鎼滅储鍟嗗搧璇︽儏-璇︾粏 + * + * @param id + * @return + * @throws + */ + public static TaoBaoGoodsBrief searchGoodsDetail(String id, String specialId, String relationId) throws TaoBaoGoodsDownException { + TaoBaoGoodsBrief goods = getSimpleGoodsInfo(id); + if (goods == null) + return null; + SearchFilter filter = new SearchFilter(); + filter.setKey(goods.getTitle()); + filter.setPage(1); + filter.setPageSize(50); + TaoBaoSearchResult result = searchWuLiaoForDetail(goods.getTitle(), goods.getZkPrice(), goods.getProvcity(), + goods.getUserType(), specialId, relationId); + if (result != null && result.getTaoBaoGoodsBriefs() != null) + for (TaoBaoGoodsBrief g : result.getTaoBaoGoodsBriefs()) { + System.out.println(goods.getAuctionId() + ":" + g.getAuctionId()); + if (TaoBaoUtil.isEqual(goods.getAuctionId(), g.getAuctionId())) { + //g.setId(goods.getAuctionId()); + g.setCreatetime(new Date()); + g.setMaterialLibType(goods.getMaterialLibType()); + g.setProvcity(goods.getProvcity()); + return g; + } + } + goods.setCouponAmount(new BigDecimal("0")); + goods.setTkMktStatus("1"); + goods.setTkRate(new BigDecimal("0")); + goods.setReservePrice(new BigDecimal(0)); + goods.setTkCommFee(new BigDecimal(0)); + return goods; + } + + + /** + * 鑾峰彇鍟嗗搧璇︽儏锛岀畝鐗� + * + * @param id -鍟嗗搧AuctionId + * @return + */ + public static TaoBaoGoodsBrief getSimpleGoodsInfo(String id) throws TaoBaoGoodsDownException { + Map<String, String> map = new HashMap<>(); + map.put("method", "taobao.tbk.item.info.get"); + map.put("num_iids", id + ""); + String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true); + System.out.println(resultStr); + JSONObject data = JSONObject.fromObject(resultStr); + // 鍟嗗搧涓嬫灦 + if (data.optJSONObject("error_response") != null && data.optJSONObject("error_response").optInt("code") == 15 + && data.optJSONObject("error_response").optInt("sub_code") == 50001) { + throw new TaoBaoGoodsDownException(data.optJSONObject("error_response").optInt("code"), "鍟嗗搧涓嬫灦"); + } + + if (data.optJSONObject("tbk_item_info_get_response") == null) + return null; + JSONArray array = data.optJSONObject("tbk_item_info_get_response").optJSONObject("results") + .optJSONArray("n_tbk_item"); + if (array != null && array.size() > 0) { + JSONObject item = array.optJSONObject(0); + return parseSimpleGoodsInfo(item); + } + return null; + } + + + private static TaoBaoGoodsBrief parseSimpleGoodsInfo(JSONObject item) { + TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief(); + goods.setAuctionId(item.optString("num_iid")); + goods.setAuctionUrl(item.optString("item_url")); + goods.setBiz30day(item.optInt("volume")); + if (item.optJSONObject("small_images") != null) { + JSONArray imgArray = item.optJSONObject("small_images").optJSONArray("string"); + if (imgArray != null) { + List<String> imgList = new ArrayList<>(); + for (int n = 0; n < imgArray.size(); n++) { + imgList.add(imgArray.optString(n)); + } + goods.setImgList(imgList); + } + } + goods.setTitle(item.optString("title")); + goods.setUserType(item.optInt("user_type")); + goods.setZkPrice(new BigDecimal(item.optString("zk_final_price"))); + goods.setReservePrice(new BigDecimal(item.optString("zk_final_price"))); + goods.setAuctionUrl(item.optString("item_url")); + goods.setProvcity(item.optString("provcity")); + goods.setPictUrl(item.optString("pict_url")); + goods.setShopTitle(item.optString("nick")); + goods.setSellerId(item.optLong("seller_id")); + goods.setRootCategoryName(item.optString("cat_name")); + goods.setLeafName(item.optString("cat_leaf_name")); + + String optString = item.optString("shop_dsr"); + if (!StringUtil.isNullOrEmpty(optString)) { + goods.setShopDsr(new Integer(optString)); + } + + String ratesum = item.optString("ratesum"); + if (!StringUtil.isNullOrEmpty(ratesum)) { + goods.setRatesum(new Integer(ratesum)); + } + + if (item.optBoolean("is_prepay")) + goods.setIsPrepay(1); + + if (item.optBoolean("i_rfd_rate")) + goods.setRfdRate(1); + + if (item.optBoolean("h_good_rate")) + goods.setGoodRate(1); + + if (item.optBoolean("h_pay_rate30")) + goods.setPayRate30(1); + + if (item.optBoolean("free_shipment")) + goods.setFreeShipment(1); + + if (!StringUtil.isNullOrEmpty(item.optString("material_lib_type"))) { + try { + String materialLibType = item.optString("material_lib_type"); + goods.setMaterialLibType(Integer.parseInt(materialLibType.split(",")[0])); + } catch (Exception e) { + goods.setMaterialLibType(0); + } + + } else + goods.setMaterialLibType(0); + + goods.setRootCategoryName(item.optString("cat_name")); + goods.setLeafName(item.optString("cat_leaf_name")); + + goods = loadYuShouInfo(goods, item); + return goods; + } + + private static TaoBaoGoodsBrief loadYuShouInfo(TaoBaoGoodsBrief goods, JSONObject item) { + if (goods != null && item != null) { + // 棰勫敭鐩稿叧瑙f瀽 + goods.setYsylClickUrl(item.optString("ysyl_click_url")); + if (!StringUtil.isNullOrEmpty(item.optString("ysyl_commission_rate"))) + goods.setYsylCommissionRate(new BigDecimal(item.optString("ysyl_commission_rate"))); + goods.setYsylTljFace(item.optString("ysyl_tlj_face")); + goods.setYsylTljSendTime(item.optString("ysyl_tlj_send_time")); + goods.setYsylTljUseEndTime(item.optString("ysyl_tlj_use_end_time")); + goods.setYsylTljUseStartTime(item.optString("ysyl_tlj_use_start_time")); + + goods.setPresaleDeposit(item.optString("presale_deposit")); + goods.setPresaleDiscountFeeText(item.optString("presale_discount_fee_text")); + goods.setPresaleEndTime(item.optString("presale_end_time")); + goods.setPresaleStartTime(item.optString("presale_start_time")); + goods.setPresaleTailEndTime(item.optString("presale_tail_end_time")); + goods.setPresaleTailStartTime(item.optString("presale_tail_start_time")); + + return goods; + } + return goods; + } + + + /** + * 鍟嗗搧鐗╂枡鎼滅储 + * + * @param title + * @param zkPrice + * @param provcity + * @param userType + * @param specialId + * @param relationId + * @return + */ + public static TaoBaoSearchResult searchWuLiaoForDetail(String title, BigDecimal zkPrice, String provcity, + int userType, String specialId, String relationId) { + if (provcity.trim().contains(" ")) + provcity = provcity.split(" ")[provcity.split(" ").length - 1]; + TaoBaoSearchResult taoBaoSearchResult = new TaoBaoSearchResult(); + Map<String, String> map = new HashMap<>(); + map.put("method", "taobao.tbk.dg.material.optional"); + map.put("page_size", 50 + ""); + map.put("page_no", 1 + ""); + map.put("start_price", (int) zkPrice.subtract(new BigDecimal(1)).doubleValue() + ""); + map.put("end_price", (int) zkPrice.add(new BigDecimal(1)).doubleValue() + ""); + map.put("is_tmall", (userType == 1) + ""); + map.put("q", title); + map.put("itemloc", provcity); + + if (!StringUtil.isNullOrEmpty(specialId) && !StringUtil.isNullOrEmpty(relationId)) { + map.put("special_id", specialId); + } else if (!StringUtil.isNullOrEmpty(specialId)) { + map.put("special_id", specialId); + } else if (!StringUtil.isNullOrEmpty(relationId)) { + map.put("relation_id", relationId); + } + + String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true); + System.out.println(resultStr); + JSONObject data = JSONObject.fromObject(resultStr); + if (data.optJSONObject("tbk_dg_material_optional_response") != null + && data.optJSONObject("tbk_dg_material_optional_response").optJSONObject("result_list") != null) { + JSONArray array = data.optJSONObject("tbk_dg_material_optional_response").optJSONObject("result_list") + .optJSONArray("map_data"); + List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); + if (array != null) { + for (int i = 0; i < array.size(); i++) { + TaoBaoGoodsBrief goods = parseWuLiaoItem(array.optJSONObject(i)); + if (goods != null) + goodsList.add(goods); + } + } + taoBaoSearchResult.setTaoBaoGoodsBriefs(goodsList); + } + + List<TaoBaoSearchNav> navList = new ArrayList<>(); + + TaoBaoHead taoBaoHead = new TaoBaoHead(); + taoBaoHead.setDocsfound(1000); + taoBaoSearchResult.setTaoBaoHead(taoBaoHead); + taoBaoSearchResult.setPageEntity(new PageEntity()); + + taoBaoSearchResult.setNavList(navList); + + return taoBaoSearchResult; + } + + + // 瑙f瀽鐗╂枡 + private static TaoBaoGoodsBrief parseWuLiaoItem(JSONObject item) { + TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief(); + goods.setPictUrl(item.optString("pict_url")); + + if (!StringUtil.isNullOrEmpty(item.optString("white_image"))) { + goods.setPictUrlWhite(item.optString("white_image")); + } + + goods.setAuctionId(item.optString("num_iid")); + goods.setAuctionUrl("https:" + item.optString("url")); + goods.setBiz30day(item.optInt("volume")); + goods.setCouponInfo(item.optString("coupon_info")); + + if (goods.getCouponInfo() != null) + goods.setCouponInfo(goods.getCouponInfo().replace(".00", "")); + + if (!StringUtil.isNullOrEmpty(goods.getCouponInfo())) { + List<BigDecimal> quanInfo = TaoBaoCouponUtil.getCouponInfo(goods.getCouponInfo()); + goods.setCouponAmount(quanInfo.get(1)); + goods.setCouponEffectiveEndTime(item.optString("coupon_end_time")); + goods.setCouponEffectiveStartTime(item.optString("coupon_start_time")); + goods.setCouponStartFee(new BigDecimal(item.optString("coupon_start_fee"))); + goods.setCouponLeftCount(item.optInt("coupon_remain_count")); + goods.setCouponLink("https:" + item.optString("coupon_share_url")); + goods.setCouponTotalCount(item.optInt("coupon_total_count")); + goods.setCouponActivityId(item.optString("coupon_id")); + } else { + goods.setCouponAmount(new BigDecimal(0)); + } + + goods.setDayLeft(-1); + if (item.optJSONObject("small_images") != null) { + JSONArray imgArray = item.optJSONObject("small_images").optJSONArray("string"); + if (imgArray != null) { + List<String> imgList = new ArrayList<>(); + for (int n = 0; n < imgArray.size(); n++) { + imgList.add(imgArray.optString(n)); + } + goods.setImgList(imgList); + } + } + + if (item.optBoolean("include_mkt")) + goods.setTkMktStatus("1"); + else + goods.setTkMktStatus("0"); + + if (item.optBoolean("include_dxjh")) + goods.setIncludeDxjh(1); + + goods.setSellerId(item.optLong("seller_id")); + goods.setShopTitle(item.optString("shop_title")); + goods.setTitle(item.optString("title")); + goods.setProvcity(item.optString("provcity")); + + if (!StringUtil.isNullOrEmpty(item.optString("level_one_category_id"))) { + goods.setRootCatId(item.optInt("level_one_category_id")); + } + goods.setRootCategoryName(item.optString("level_one_category_name")); + + if (!StringUtil.isNullOrEmpty(item.optString("category_id"))) { + goods.setLeafCatId(item.optInt("category_id")); + } + goods.setLeafName(item.optString("category_name")); + + goods.setTkRate(new BigDecimal(item.optString("commission_rate")).divide(new BigDecimal(100))); + goods.setTotalNum(1000); + goods.setUserType(item.optInt("user_type")); + goods.setUserTypeName(""); + goods.setZkPrice(new BigDecimal(item.optString("zk_final_price"))); + + if (item.optBoolean("include_dxjh")) { + goods.setDxjhInfo(item.optString("info_dxjh")); + } + + if (StringUtil.isNullOrEmpty(goods.getCouponInfo())) {// 鏃犲埜 + goods.setTkCommFee(goods.getZkPrice().multiply(goods.getTkRate()).divide(new BigDecimal(100))); + } else if (goods.getZkPrice().compareTo(goods.getCouponStartFee()) >= 0// 鏈夊埜 + && goods.getZkPrice().compareTo(goods.getCouponAmount()) >= 0) { + BigDecimal finalPrice = goods.getZkPrice().subtract(goods.getCouponAmount()); + goods.setTkCommFee(finalPrice.multiply(goods.getTkRate()).divide(new BigDecimal(100))); + } else { + goods.setTkCommFee(new BigDecimal(0)); + } + if (!StringUtil.isNullOrEmpty(item.optString("reserve_price"))) + goods.setReservePrice(new BigDecimal(item.optString("reserve_price"))); + goods.setTotalFee(new BigDecimal("0")); + // 鎺ㄨ崘璇� + goods.setDescription(item.optString("item_description")); + + goods = loadYuShouInfo(goods, item); + return goods; + } + + public static Date getTaoBaoSystemTime() { + Map<String, String> map = new HashMap<>(); + map.put("method", "taobao.time.get"); + try { + JSONObject json = TaoKeBaseUtil.baseRequest(map, false); + String time = json.optJSONObject("time_get_response").optString("time"); + return new Date(TimeUtil.convertToTimeTemp(time, "yyyy-MM-dd HH:mm:ss")); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + + public static void main(String[] args) { +// TaoLiJinReportDTO dto = taolijinReport("eC2%2FoV8gigdzVO5CvuRDjDVC0SEP1L7d", new TaoKeAppInfo("27743325", "527a23554f71557d7b786bc479fcd5fe")); +// System.out.println(dto); + TaoKeAppInfo app = new TaoKeAppInfo("24980167", "e0a2e05deabf5ce039b52e5b492d5382", "mm_124933865_56750082_19511350325"); + + Long auctionId = 648785782467L; + String name = "瑁傚彉娣樼ぜ閲�"; + BigDecimal perface = new BigDecimal(1); + int totalNum = 1; + Date sendStartTime = new Date(); + Date sendEndTime = new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 4L); + Date useStartTime = sendStartTime; + Date useEndTime = sendEndTime; + + try { + createLieBianTaoLiJin(auctionId+"", name, perface, totalNum, + sendStartTime, sendEndTime, useStartTime, useEndTime, app); + } catch (LiJinAccountException e) { + e.printStackTrace(); + } catch (LiJinAmountException e) { + e.printStackTrace(); + } catch (LiJinException e) { + e.printStackTrace(); + } catch (LiJinGoodsException e) { + e.printStackTrace(); + } + } + } -- Gitblit v1.8.0