| | |
| | | import com.yeshi.goods.facade.dto.taobao.TaoBaoShopInfoDTO; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoHead; |
| | | import com.yeshi.goods.facade.utils.taobao.DaTaoKeApiUtil; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | import org.yeshi.utils.JsonUtil; |
| | |
| | | Map<String, String> map = new HashMap<>(); |
| | | //TODO 临时接口 taobao.tbk.item.info.get |
| | | map.put("method", "taobao.tbk.item.info.get"); |
| | | // map.put("biz_scene_id", 2 + ""); |
| | | map.put("num_iids", id + ""); |
| | | String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true); |
| | | System.out.println(resultStr); |
| | |
| | | .optJSONArray("n_tbk_item"); |
| | | if (array != null && array.size() > 0) { |
| | | JSONObject item = array.optJSONObject(0); |
| | | return parseSimpleGoodsInfo(item); |
| | | TaoBaoGoodsBrief goods = parseSimpleGoodsInfo(item); |
| | | if(goods!=null){ |
| | | goods.setAuctionId(id); |
| | | } |
| | | return goods; |
| | | } |
| | | return null; |
| | | } |
| | |
| | | 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())) { |
| | | if (TaoBaoUtil.isEqual(goods.getAuctionId(), g.getAuctionId())) { |
| | | g.setAuctionId(goods.getAuctionId()); |
| | | g.setCreatetime(new Date()); |
| | | g.setMaterialLibType(goods.getMaterialLibType()); |
| | |
| | | goods.getUserType(), app, null, null); |
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null) |
| | | for (TaoBaoGoodsBrief g : result.getTaoBaoGoodsBriefs()) { |
| | | if (TaoBaoUtil.isEqual( goods.getAuctionId() , g.getAuctionId())) { |
| | | if (TaoBaoUtil.isEqual(goods.getAuctionId(), g.getAuctionId())) { |
| | | g.setAuctionId(goods.getAuctionId()); |
| | | // 判断是否有优惠券 |
| | | if (!StringUtil.isNullOrEmpty(g.getCouponActivityId())) { |
| | |
| | | goods.getUserType(), app, specialId, relationId); |
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null) |
| | | for (TaoBaoGoodsBrief g : result.getTaoBaoGoodsBriefs()) { |
| | | if (TaoBaoUtil.isEqual( goods.getAuctionId(), g.getAuctionId())) { |
| | | if (TaoBaoUtil.isEqual(goods.getAuctionId(), g.getAuctionId())) { |
| | | g.setAuctionId(goods.getAuctionId()); |
| | | g.setCreatetime(new Date()); |
| | | return g; |
| | |
| | | goods.getUserType(), null, null); |
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null) |
| | | for (TaoBaoGoodsBrief g : result.getTaoBaoGoodsBriefs()) { |
| | | if ( TaoBaoUtil.isEqual(goods.getAuctionId(),g.getAuctionId())) { |
| | | if (TaoBaoUtil.isEqual(goods.getAuctionId(), g.getAuctionId())) { |
| | | g.setAuctionId(goods.getAuctionId()); |
| | | g.setAuctionUrl(goods.getAuctionUrl()); |
| | | g.setShopTitle(goods.getShopTitle()); |
| | |
| | | if (searchResult != null && searchResult.getTaoBaoGoodsBriefs() != null |
| | | && searchResult.getTaoBaoGoodsBriefs().size() > 0) { |
| | | for (TaoBaoGoodsBrief g : searchResult.getTaoBaoGoodsBriefs()) { |
| | | if (TaoBaoUtil.isEqual( g.getAuctionId(), goods.getAuctionId())) { |
| | | if (TaoBaoUtil.isEqual(g.getAuctionId(), goods.getAuctionId())) { |
| | | g.setImgList(goods.getImgList()); |
| | | g.setAuctionId(goods.getAuctionId()); |
| | | g.setAuctionUrl(goods.getAuctionUrl()); |
| | |
| | | if (filter.getKey() != null && filter.getKey().trim().equalsIgnoreCase("")) |
| | | return null; |
| | | |
| | | if (filter.getKey() != null && filter.getKey().length() > 100) |
| | | return null; |
| | | // if (filter.getKey() != null && filter.getKey().length() > 100) |
| | | // return null; |
| | | |
| | | PageEntity pageEntity = new PageEntity(); |
| | | TaoBaoSearchResult taoBaoSearchResult = new TaoBaoSearchResult(); |
| | |
| | | map.put("method", "taobao.tbk.dg.material.optional"); |
| | | map.put("page_size", filter.getPageSize() == 0 ? "20" : filter.getPageSize() + ""); |
| | | map.put("page_no", (filter.getPage() <= 0 ? 1 : filter.getPage()) + ""); |
| | | //1-动态ID转链场景,2-消费者比价场景(不填默认为1) |
| | | // map.put("biz_scene_id","2"); |
| | | // map.put("promotion_type","1"); |
| | | |
| | | if (!StringUtil.isNullOrEmpty(specialId) && !StringUtil.isNullOrEmpty(relationId)) { |
| | | map.put("special_id", specialId); |
| | | } else if (!StringUtil.isNullOrEmpty(specialId)) { |
| | |
| | | } |
| | | |
| | | String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true); |
| | | System.out.println("resultStr"+ resultStr); |
| | | System.out.println("resultStr" + resultStr); |
| | | JSONObject data = JSONObject.fromObject(resultStr); |
| | | //TODO 临时接口tbk_dg_material_optional_response |
| | | if (data.optJSONObject("tbk_dg_material_optional_response") != null |
| | |
| | | } |
| | | |
| | | // 解析物料 |
| | | private static TaoBaoGoodsBrief parseWuLiaoItem(JSONObject item) { |
| | | public static TaoBaoGoodsBrief parseWuLiaoItem(JSONObject item) { |
| | | TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief(); |
| | | goods.setPictUrl(item.optString("pict_url")); |
| | | |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | // 淘礼金创建 |
| | | //{"result":{"msg_code":"FAIL_CHECK_ITEM_DAILY_SEND_NUM_CHECK_ERROR","msg_info":"今日该商品淘礼金创建数已超上限,请您明日再试","success":false},"request_id":"10p30v02qadkq"} |
| | | //{"result":{"msg_code":"ASSET_ACCOUNT_BALANCE_NOT_ENOUGH","msg_info":"账户预算不足","success":false},"request_id":"5caz9izr7jqp"} |
| | |
| | | } |
| | | |
| | | /** |
| | | * @return com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinReport |
| | | * @author hxh |
| | | * @description 淘礼金报告 接口文档:https://open.taobao.com/api.htm?source=search&docId=58736&docType=2 |
| | | * @date 10:57 2022/1/11 |
| | | * @param: rightsId |
| | | * @return com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinReport |
| | | **/ |
| | | public static UserTaoLiJinReport getTaoLiJinEffective(String rightsId,String pid) { |
| | | public static UserTaoLiJinReport getTaoLiJinEffective(String rightsId, String pid) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("method", "taobao.tbk.dg.vegas.tlj.report"); |
| | | map.put("rights_id", rightsId); |
| | |
| | | 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) { |
| | | UserTaoLiJinReport report = new UserTaoLiJinReport(); |
| | | report.setId(rightsId); |
| | | report.setWinAmount(new BigDecimal(modelJson.optString("win_sum_amt"))); |
| | | report.setWinNum(modelJson.optInt("win_pv")); |
| | | report.setRefundAmount(new BigDecimal(modelJson.optString("refund_sum_amt"))); |
| | | report.setRefundNum(modelJson.optInt("refund_num")); |
| | | report.setAlipayAmount(new BigDecimal(modelJson.optString("alipay_amt"))); |
| | | report.setUseAmount(new BigDecimal(modelJson.optString("use_sum_amt"))); |
| | | report.setUseNum(modelJson.optInt("use_num")); |
| | | report.setUnfreezeAmount(new BigDecimal(modelJson.optString("remaining_amt"))); |
| | | report.setUnfreezeNum(modelJson.optInt("remaining_num")); |
| | | report.setPreCommissionAmount(new BigDecimal(modelJson.optString("pre_pub_share_fee_for_disp"))); |
| | | return report; |
| | | JSONObject modelJson = root.optJSONObject("model").optJSONObject("extra"); |
| | | if (modelJson != null && modelJson.size() > 0) { |
| | | UserTaoLiJinReport report = new UserTaoLiJinReport(); |
| | | report.setId(rightsId); |
| | | report.setWinAmount(new BigDecimal(modelJson.optString("win_sum_amt"))); |
| | | report.setWinNum(modelJson.optInt("win_pv")); |
| | | report.setRefundAmount(new BigDecimal(modelJson.optString("refund_sum_amt"))); |
| | | report.setRefundNum(modelJson.optInt("refund_num")); |
| | | report.setAlipayAmount(new BigDecimal(modelJson.optString("alipay_amt"))); |
| | | report.setUseAmount(new BigDecimal(modelJson.optString("use_sum_amt"))); |
| | | report.setUseNum(modelJson.optInt("use_num")); |
| | | report.setUnfreezeAmount(new BigDecimal(modelJson.optString("remaining_amt"))); |
| | | report.setUnfreezeNum(modelJson.optInt("remaining_num")); |
| | | report.setPreCommissionAmount(new BigDecimal(modelJson.optString("pre_pub_share_fee_for_disp"))); |
| | | return report; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | } |
| | | |
| | | public static void main(String[] args) throws TaobaoGoodsDownException { |
| | | //搜索 |
| | | TaoBaoGoodsBrief goods= searchGoodsDetail("682141395159"); |
| | | |
| | | System.out.println(goods); |
| | | |
| | | public static void main(String[] args) throws TaoBaoTokenParseException, TaobaoGoodsDownException { |
| | | TaoBaoGoodsBrief goods = getSimpleGoodsInfo("qYtrU8tgk7CWt0-GmgDAKHqqGm3XDwHZj"); |
| | | System.out.println(goods.getAuctionId()); |
| | | } |
| | | |
| | | } |