| | |
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.taobao.TaoBaoShopInfoDTO;
|
| | | import com.yeshi.fanli.dto.taobao.TaoLiJinDTO;
|
| | | import com.yeshi.fanli.dto.taobao.api.TaoKeOfficialActivityConvertResultDTO;
|
| | | import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinReport;
|
| | | import com.yeshi.fanli.entity.taobao.SearchFilter;
|
| | | import com.yeshi.fanli.entity.taobao.SearchShopFilter;
|
| | |
| | | */
|
| | | public static List<TaoBaoGoodsBrief> getBatchGoodsInfos(String ids) throws TaobaoGoodsDownException {
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | |
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.item.info.get");
|
| | | map.put("num_iids", ids + "");
|
| | | |
| | | String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true);
|
| | | JSONObject data = JSONObject.fromObject(resultStr);
|
| | | // 商品下架
|
| | |
| | | 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) {
|
| | |
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | JSONObject item = array.optJSONObject(i);
|
| | | goodsList.add(parseSimpleGoodsInfo(item));
|
| | | }
|
| | | }
|
| | | return goodsList;
|
| | | }
|
| | | |
| | | |
| | | public static List<TaoBaoGoodsBrief> getBatchGoodsInfo(List<Long> listId, String ip )
|
| | | throws TaoKeApiException, TaobaoGoodsDownException {
|
| | | if (listId == null || listId.size() == 0) {
|
| | | throw new TaobaoGoodsDownException(1, "淘宝商品ID不能为空");
|
| | | }
|
| | |
|
| | | if (listId.size() > 40) {
|
| | | throw new TaobaoGoodsDownException(1, "淘宝商品ID不能超过40个");
|
| | | }
|
| | |
|
| | | StringBuffer ids = new StringBuffer();
|
| | | for (Long id : listId) {
|
| | | ids.append(id + ",");
|
| | | }
|
| | |
|
| | | return getBatchGoodsInfos(ids.substring(0, ids.length() - 1), ip);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取商品详情,简版
|
| | | * |
| | | * @param id
|
| | | * @return
|
| | | */
|
| | | public static List<TaoBaoGoodsBrief> getBatchGoodsInfos(String ids, String ip) throws TaobaoGoodsDownException {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.item.info.get");
|
| | | map.put("num_iids", ids + "");
|
| | | if (!StringUtil.isNullOrEmpty(ip)) {
|
| | | map.put("ip", ip);
|
| | | }
|
| | | |
| | | String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true);
|
| | | 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;
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | |
| | | JSONArray array = data.optJSONObject("tbk_item_info_get_response").optJSONObject("results")
|
| | | .optJSONArray("n_tbk_item");
|
| | | if (array != null && array.size() > 0) {
|
| | |
| | | * -渠道ID
|
| | | * @return
|
| | | */
|
| | | public static String officialActivityConvert(String adZoneId, String promotionSceneId, String relationId) {
|
| | | public static TaoKeOfficialActivityConvertResultDTO officialActivityConvert(String adZoneId,
|
| | | String promotionSceneId, String relationId) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.activitylink.get");
|
| | | map.put("method", "taobao.tbk.activity.info.get");
|
| | | map.put("adzone_id", adZoneId);
|
| | | map.put("promotion_scene_id", promotionSceneId);
|
| | | map.put("activity_material_id", promotionSceneId);
|
| | | if (relationId != null)
|
| | | map.put("relation_id", relationId);
|
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | try {
|
| | | String result = TaoKeBaseUtil.baseRequestForThreeTimes(map, app);
|
| | | System.out.println(result);
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | if (json != null) {
|
| | | json = json.optJSONObject("tbk_activitylink_get_response");
|
| | | if (json.optInt("result_code") == 200) {
|
| | | return json.optString("data");
|
| | | json = json.optJSONObject("tbk_activity_info_get_response");
|
| | | if (json.optJSONObject("data") != null) {
|
| | | return JsonUtil.getSimpleGson().fromJson(json.optJSONObject("data").toString(),
|
| | | TaoKeOfficialActivityConvertResultDTO.class);
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | |
| | |
|
| | | return goodsList;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 淘宝客-推广者-官方活动信息获取
|
| | | * @Title: getActivityInfo
|
| | | * @Description: |
| | | * @param activityMaterialId
|
| | | * @param pid
|
| | | * @param relationId
|
| | | * @return |
| | | * String 返回类型
|
| | | * @throws
|
| | | */
|
| | | public static String getActivityInfo(String activityMaterialId, String pid, String relationId) {
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.activity.info.get");
|
| | | map.put("activity_material_id", activityMaterialId);
|
| | | map.put("adzone_id", pid.split("_")[3] + "");
|
| | | map.put("relation_id", relationId);
|
| | |
|
| | | JSONObject resultJSON = null;
|
| | | try {
|
| | | resultJSON = TaoKeBaseUtil.baseRequest(map,
|
| | | new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET, pid));
|
| | | JSONObject response = resultJSON.optJSONObject("tbk_activity_info_get_response");
|
| | | if (response != null && response.optJSONObject("data") != null) {
|
| | | return response.optJSONObject("data").optString("click_url");
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | return null;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | class QuanInfo {
|