| | |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoShopInfo;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.exception.taobao.TaoBaoAuthException;
|
| | | import com.yeshi.fanli.exception.taobao.TaoBaoTokenParseException;
|
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.exception.tlj.TaoLiJinCreateException;
|
| | |
| | | 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)) {
|
| | |
| | |
|
| | | } else
|
| | | goods.setMaterialLibType(0);
|
| | |
|
| | | goods.setRootCategoryName(item.optString("cat_name"));
|
| | | goods.setLeafName(item.optString("cat_leaf_name"));
|
| | |
|
| | | goods = loadYuShouInfo(goods, item);
|
| | | return goods;
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | // 再从淘宝联盟网页搜索
|
| | | filter.setKey(goods.getAuctionUrl());
|
| | | TaoBaoSearchResult searchResult = TaoBaoUtil.searchFromAlimamaWeb(filter, null);
|
| | | if (searchResult != null && searchResult.getTaoBaoGoodsBriefs() != null
|
| | | && searchResult.getTaoBaoGoodsBriefs().size() > 0) {
|
| | | for (TaoBaoGoodsBrief g : searchResult.getTaoBaoGoodsBriefs()) {
|
| | | if (g.getAuctionId().longValue() == goods.getAuctionId()) {
|
| | | g.setImgList(goods.getImgList());
|
| | | goods = g;
|
| | | if ("无".equalsIgnoreCase(goods.getCouponInfo()))
|
| | | goods.setCouponInfo(null);
|
| | | return goods;
|
| | | // 从转链搜索
|
| | | TaoBaoGoodsBrief newGoods = specialConvertCoupon(goods.getAuctionId(),
|
| | | new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
|
| | | TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT));
|
| | |
|
| | | if (newGoods != null) {
|
| | | goods.setTkRate(newGoods.getTkRate());
|
| | | if (!StringUtil.isNullOrEmpty(newGoods.getCouponInfo())) {
|
| | | List<BigDecimal> couponInfo = TaoBaoCouponUtil.getCouponInfo(newGoods.getCouponInfo());
|
| | | if (couponInfo != null && couponInfo.size() > 1) {
|
| | | goods.setCouponStartFee(couponInfo.get(0));
|
| | | goods.setCouponAmount(couponInfo.get(1));
|
| | | goods.setCouponEffectiveStartTime(newGoods.getCouponEffectiveStartTime());
|
| | | goods.setCouponEffectiveEndTime(newGoods.getCouponEffectiveEndTime());
|
| | | goods.setCouponLeftCount(newGoods.getCouponLeftCount());
|
| | | goods.setCouponTotalCount(newGoods.getCouponTotalCount());
|
| | | goods.setCouponInfo(newGoods.getCouponInfo());
|
| | | }
|
| | | }
|
| | |
|
| | | return goods;
|
| | |
|
| | | } else {
|
| | | 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;
|
| | | }
|
| | |
|
| | | TaoKeLogHelper.error(null, "没有搜索到详情:" + id);
|
| | | 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;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | // 再从淘宝联盟网页搜索
|
| | | filter.setKey(goods.getAuctionUrl());
|
| | | TaoBaoSearchResult searchResult = TaoBaoUtil.searchFromAlimamaWeb(filter, null);
|
| | | if (searchResult != null && searchResult.getTaoBaoGoodsBriefs() != null
|
| | | && searchResult.getTaoBaoGoodsBriefs().size() > 0) {
|
| | | for (TaoBaoGoodsBrief g : searchResult.getTaoBaoGoodsBriefs()) {
|
| | | if (g.getAuctionId().longValue() == goods.getAuctionId()) {
|
| | | g.setImgList(goods.getImgList());
|
| | | goods = g;
|
| | | if ("无".equalsIgnoreCase(goods.getCouponInfo()))
|
| | | goods.setCouponInfo(null);
|
| | | return goods;
|
| | | // 从转链搜索
|
| | | TaoBaoGoodsBrief newGoods = specialConvertCoupon(goods.getAuctionId(),
|
| | | new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
|
| | | TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT));
|
| | |
|
| | | if (newGoods != null) {
|
| | | goods.setTkRate(newGoods.getTkRate());
|
| | | if (!StringUtil.isNullOrEmpty(newGoods.getCouponInfo())) {
|
| | | List<BigDecimal> couponInfo = TaoBaoCouponUtil.getCouponInfo(newGoods.getCouponInfo());
|
| | | if (couponInfo != null && couponInfo.size() > 1) {
|
| | | goods.setCouponStartFee(couponInfo.get(0));
|
| | | goods.setCouponAmount(couponInfo.get(1));
|
| | | goods.setCouponEffectiveStartTime(newGoods.getCouponEffectiveStartTime());
|
| | | goods.setCouponEffectiveEndTime(newGoods.getCouponEffectiveEndTime());
|
| | | goods.setCouponLeftCount(newGoods.getCouponLeftCount());
|
| | | goods.setCouponTotalCount(newGoods.getCouponTotalCount());
|
| | | goods.setCouponInfo(newGoods.getCouponInfo());
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | TaoKeLogHelper.error(null, "没有搜索到详情:" + id);
|
| | | 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;
|
| | | return goods;
|
| | |
|
| | | } else {
|
| | | 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;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | 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;
|
| | | }
|
| | |
| | | * @param idfa
|
| | | * @return
|
| | | */
|
| | | public static TaoBaoSearchResult guessDeviceLike(int page, int pageSize, String imei, String idfa) {
|
| | | public static TaoBaoSearchResult guessDeviceLike(int page, int pageSize, String imei, String idfa, String utdid) {
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.dg.optimus.material");
|
| | | map.put("page_no", page + "");
|
| | | map.put("page_size", pageSize + "");
|
| | | map.put("material_id", "6708");
|
| | | if (StringUtil.isNullOrEmpty(imei) && StringUtil.isNullOrEmpty(idfa))
|
| | | if (StringUtil.isNullOrEmpty(imei) && StringUtil.isNullOrEmpty(idfa) && StringUtil.isNullOrEmpty(utdid))
|
| | | return null;
|
| | | map.put("device_encrypt", "MD5");
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(imei)) {
|
| | | map.put("device_encrypt", "MD5");
|
| | | map.put("device_value", StringUtil.Md5(imei));
|
| | | map.put("device_type", "IMEI");
|
| | | } else {
|
| | | } else if (!StringUtil.isNullOrEmpty(idfa)) {
|
| | | map.put("device_encrypt", "MD5");
|
| | | map.put("device_value", StringUtil.Md5(idfa));
|
| | | map.put("device_type", "IDFA");
|
| | | } else if (!StringUtil.isNullOrEmpty(utdid)) {
|
| | | map.put("device_value", utdid);
|
| | | map.put("device_type", "UTDID");
|
| | | }
|
| | |
|
| | | JSONObject resultJSON = null;
|
| | |
| | | app.setAppKey(appKey);
|
| | | app.setAppSecret(appSecret);
|
| | | resultJSON = TaoKeBaseUtil.baseRequest(map, app);
|
| | | System.out.println(resultJSON.toString());
|
| | | return resultJSON.optJSONObject("tbk_sc_publisher_info_save_response").optJSONObject("data")
|
| | | .optString("relation_id");
|
| | | } catch (TaoKeApiException e) {
|
| | |
| | | map.put("adzone_id", sts[3]);
|
| | | try {
|
| | | String result = TaoKeBaseUtil.baseRequestForThreeTimes(map, app);
|
| | | System.out.println(result);
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONObject resultJSON = json.optJSONObject("tbk_coupon_convert_response").optJSONObject("result")
|
| | | .optJSONObject("results");
|
| | |
| | | if (!StringUtil.isNullOrEmpty(resultJSON.optString("coupon_info"))) {
|
| | | goods.setCouponLink(couponLink);
|
| | | goods.setCouponInfo(resultJSON.optString("coupon_info"));
|
| | | if (!StringUtil.isNullOrEmpty(resultJSON.optString("coupon_total_count"))) {
|
| | | goods.setCouponTotalCount(Integer.parseInt(resultJSON.optString("coupon_total_count")));
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(resultJSON.optString("coupon_remain_count"))) {
|
| | | goods.setCouponLeftCount(Integer.parseInt(resultJSON.optString("coupon_remain_count")));
|
| | | }
|
| | |
|
| | | goods.setCouponEffectiveStartTime(resultJSON.optString("coupon_start_time"));
|
| | | goods.setCouponEffectiveEndTime(resultJSON.optString("coupon_end_time"));
|
| | |
|
| | | }
|
| | | String tkRate = resultJSON.optString("max_commission_rate");
|
| | | if (!StringUtil.isNullOrEmpty(tkRate)) {
|
| | |
| | | * @param token
|
| | | * @return
|
| | | */
|
| | | public static Long tokenConvertAuctionId(String token) {
|
| | | public static Long tokenConvertAuctionId(String token) throws TaoBaoTokenParseException {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.tpwd.convert");
|
| | | map.put("password_content", token);
|
| | |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | try {
|
| | | JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
|
| | |
|
| | | try {
|
| | | return json.optJSONObject("tbk_tpwd_convert_response").optJSONObject("data").optLong("num_iid");
|
| | | } catch (Exception e) {
|
| | |
|
| | | return null;
|
| | | }
|
| | |
|
| | | } catch (TaoKeApiException e) {
|
| | | e.printStackTrace();
|
| | | JSONObject msg = null;
|
| | | try {
|
| | | msg = JSONObject.fromObject(e.getMsg());
|
| | | } catch (Exception e2) {
|
| | | }
|
| | | if (msg != null && msg.optJSONObject("error_response") != null) {
|
| | | throw new TaoBaoTokenParseException(msg.optJSONObject("error_response").optInt("sub_code"),
|
| | | msg.optJSONObject("error_response").optString("sub_msg"));
|
| | | }
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | public static List<TaoBaoGoodsBrief> guessLikeByAuctionId(Long auctionId,int count) {
|
| | | public static List<TaoBaoGoodsBrief> guessLikeByAuctionId(Long auctionId, int count) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.dg.optimus.material");
|
| | | map.put("item_id", auctionId + "");
|