| | |
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.taobao.TaoBaoShopInfoDTO;
|
| | | import com.yeshi.goods.facade.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;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoHead;
|
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoHead;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoProvince;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchNav;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoShopInfo;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.common.entity.taobao.TaoBaoShopInfo;
|
| | | import com.yeshi.common.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.log.LogHelper;
|
| | | import com.yeshi.fanli.log.TLJLogHelper;
|
| | | import com.yeshi.fanli.log.TaoKeLogHelper;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.common.entity.PageEntity;
|
| | | import org.yeshi.utils.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import org.yeshi.utils.TimeUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
| | | /**
|
| | | * 获取商品详情,简版
|
| | | *
|
| | | * @param id
|
| | | * @param ids
|
| | | * @return
|
| | | * @throws TaobaoGoodsDownException
|
| | | */
|
| | | public static List<TaoBaoGoodsBrief> getBatchGoodsInfos(String ids) throws TaobaoGoodsDownException {
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | |
| | | /**
|
| | | * 获取商品详情,简版
|
| | | *
|
| | | * @param id
|
| | | * @param ids
|
| | | * @param ip
|
| | | * @return
|
| | | * @throws TaobaoGoodsDownException
|
| | | */
|
| | | public static List<TaoBaoGoodsBrief> getBatchGoodsInfos(String ids, String ip) throws TaobaoGoodsDownException {
|
| | | Map<String, String> map = new HashMap<>();
|
| | |
| | | filter.setPage(1);
|
| | | filter.setPageSize(50);
|
| | | TaoBaoSearchResult result = searchWuLiaoForDetail(goods.getTitle(), goods.getZkPrice(), goods.getProvcity(),
|
| | | goods.getUserType());
|
| | | goods.getUserType(), null, null);
|
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null)
|
| | | for (TaoBaoGoodsBrief g : result.getTaoBaoGoodsBriefs()) {
|
| | | System.out.println(goods.getAuctionId() + ":" + g.getAuctionId());
|
| | |
| | | // 从转链搜索
|
| | | TaoBaoGoodsBrief newGoods = specialConvertCoupon(goods.getAuctionId(),
|
| | | new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
|
| | | TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT));
|
| | | TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT),null,null);
|
| | |
|
| | | if (newGoods != null) {
|
| | | goods.setTkRate(newGoods.getTkRate());
|
| | |
| | | filter.setPage(1);
|
| | | filter.setPageSize(50);
|
| | | TaoBaoSearchResult result = searchWuLiaoForDetail(goods.getTitle(), goods.getZkPrice(), goods.getProvcity(),
|
| | | goods.getUserType(), app);
|
| | | goods.getUserType(), app, null, null);
|
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null)
|
| | | for (TaoBaoGoodsBrief g : result.getTaoBaoGoodsBriefs()) {
|
| | | if (goods.getAuctionId().longValue() == g.getAuctionId()) {
|
| | |
| | | // 从转链搜索
|
| | | TaoBaoGoodsBrief newGoods = specialConvertCoupon(goods.getAuctionId(),
|
| | | new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
|
| | | TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT));
|
| | | TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT),null,null);
|
| | |
|
| | | if (newGoods != null) {
|
| | | goods.setTkRate(newGoods.getTkRate());
|
| | |
| | | * @return
|
| | | * @throws TaobaoGoodsDownException
|
| | | */
|
| | | public static TaoBaoGoodsBrief searchGoodsDetailForConvert(Long id, TaoKeAppInfo app)
|
| | | public static TaoBaoGoodsBrief searchGoodsDetailForConvert(Long id, TaoKeAppInfo app, String specialId, String relationId)
|
| | | throws TaobaoGoodsDownException {
|
| | | TaoBaoGoodsBrief goods = getSimpleGoodsInfo(id);
|
| | | if (goods == null)
|
| | |
| | | filter.setPage(1);
|
| | | filter.setPageSize(50);
|
| | | TaoBaoSearchResult result = searchWuLiaoForDetail(goods.getTitle(), goods.getZkPrice(), goods.getProvcity(),
|
| | | goods.getUserType(), app);
|
| | | goods.getUserType(), app, specialId, relationId);
|
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null)
|
| | | for (TaoBaoGoodsBrief g : result.getTaoBaoGoodsBriefs()) {
|
| | | if (goods.getAuctionId().longValue() == g.getAuctionId()) {
|
| | |
| | | filter.setPage(1);
|
| | | filter.setPageSize(50);
|
| | | TaoBaoSearchResult result = searchWuLiaoForDetail(goods.getTitle(), goods.getZkPrice(), goods.getProvcity(),
|
| | | goods.getUserType());
|
| | | goods.getUserType(), null, null);
|
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null)
|
| | | for (TaoBaoGoodsBrief g : result.getTaoBaoGoodsBriefs()) {
|
| | | if (goods.getAuctionId().longValue() == g.getAuctionId()) {
|
| | |
| | | * 商品物料搜索
|
| | | *
|
| | | * @param filter
|
| | | * @param specialId
|
| | | * @param relationId
|
| | | * @return
|
| | | */
|
| | | public static TaoBaoSearchResult searchWuLiao(SearchFilter filter) {
|
| | | public static TaoBaoSearchResult searchWuLiao(SearchFilter filter, String specialId, String relationId) {
|
| | |
|
| | | if (filter.getKey() != null && filter.getKey().trim().equalsIgnoreCase(""))
|
| | | return null;
|
| | |
| | | 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()) + "");
|
| | | 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);
|
| | | }
|
| | |
|
| | | // map.put("material_id", "3756");
|
| | |
|
| | | pageEntity.setPageIndex(filter.getPage());
|
| | |
| | | /**
|
| | | * 商品物料搜索
|
| | | *
|
| | | * @param filter
|
| | | * @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) {
|
| | | int userType, String specialId, String relationId) {
|
| | | if (provcity.trim().contains(" "))
|
| | | provcity = provcity.split(" ")[provcity.split(" ").length - 1];
|
| | | TaoBaoSearchResult taoBaoSearchResult = new TaoBaoSearchResult();
|
| | |
| | | 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);
|
| | |
| | | /**
|
| | | * 商品物料搜索
|
| | | *
|
| | | * @param filter
|
| | | * @param title
|
| | | * @param zkPrice
|
| | | * @param provcity
|
| | | * @param userType
|
| | | * @param app
|
| | | * @param specialId
|
| | | * @param relationId
|
| | | * @return
|
| | | */
|
| | | public static TaoBaoSearchResult searchWuLiaoForDetail(String title, BigDecimal zkPrice, String provcity,
|
| | | int userType, TaoKeAppInfo app) {
|
| | | int userType, TaoKeAppInfo app, String specialId, String relationId) {
|
| | | if (provcity.trim().contains(" "))
|
| | | provcity = provcity.split(" ")[provcity.split(" ").length - 1];
|
| | | TaoBaoSearchResult taoBaoSearchResult = new TaoBaoSearchResult();
|
| | |
| | | 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, app);
|
| | | JSONObject data = JSONObject.fromObject(resultStr);
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 店铺搜索
|
| | | *
|
| | | * @param key -店铺名称
|
| | | * @param page -页码
|
| | | * @param filter
|
| | | * @return
|
| | | */
|
| | | public static List<TaoBaoShopInfo> searchShop(SearchShopFilter filter) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public static TaoBaoGoodsBrief specialConvertCoupon(Long auctionId, String specialId,String relationId, TaoKeAppInfo app) {
|
| | | public static TaoBaoGoodsBrief specialConvertCoupon(Long auctionId, TaoKeAppInfo app,String specialId, String relationId) {
|
| | | String pid = app.getPid();
|
| | | String[] sts = pid.split("_");
|
| | | Map<String, String> map = new HashMap<>();
|
| | | map.put("method", "taobao.tbk.coupon.convert");
|
| | | map.put("item_id", auctionId + "");
|
| | | map.put("adzone_id", sts[3]);
|
| | | if (!StringUtil.isNullOrEmpty(specialId)) {
|
| | | if (!StringUtil.isNullOrEmpty(specialId) && !StringUtil.isNullOrEmpty(relationId)) {
|
| | | map.put("special_id", specialId);
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(relationId)) {
|
| | | } else if (!StringUtil.isNullOrEmpty(specialId)) {
|
| | | map.put("special_id", specialId);
|
| | | } else if (!StringUtil.isNullOrEmpty(relationId)) {
|
| | | map.put("relation_id", specialId);
|
| | | }
|
| | |
|
| | | 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");
|
| | |
| | |
|
| | | }
|
| | | String tkRate = resultJSON.optString("max_commission_rate");
|
| | | if (StringUtil.isNullOrEmpty(tkRate)) {
|
| | | tkRate = resultJSON.optString("min_commission_rate");
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(tkRate)) {
|
| | | goods.setTkRate(new BigDecimal(tkRate));
|
| | | }
|
| | |
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | return null;
|
| | | }
|
| | |
|
| | |
|
| | | public static TaoBaoGoodsBrief specialConvertCoupon(Long auctionId, TaoKeAppInfo app) {
|
| | | return specialConvertCoupon(auctionId, null,null, app);
|
| | | }
|
| | |
|
| | | public static void juHuaSuan() {
|