| | |
| | |
|
| | | package org.fanli;
|
| | |
|
| | | import java.io.File;
|
| | | import java.io.FileInputStream;
|
| | | import java.io.FileNotFoundException;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.UUID;
|
| | |
|
| | | import org.junit.Ignore;
|
| | | import org.junit.Test;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TBPidMapper;
|
| | | import com.yeshi.fanli.entity.taobao.SearchFilter;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.taobao.PidUser;
|
| | | import com.yeshi.fanli.entity.taobao.TBPid;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoLink;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoBuyRelationMapService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.TBPidService;
|
| | | import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.util.BeanUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | |
| | |
|
| | | @Test
|
| | | public void test1() {
|
| | |
|
| | | SearchFilter sf = new SearchFilter();
|
| | | sf.setPage(3);
|
| | | sf.setPageSize(40);
|
| | | sf.setKey("鞋套");
|
| | | TaoBaoSearchResult result = TaoKeApiUtil.searchWuLiao(sf);
|
| | | List<TaoBaoGoodsBrief> goodsList = result.getTaoBaoGoodsBriefs();
|
| | | List<Long> list = new ArrayList<>();
|
| | | for (TaoBaoGoodsBrief tf : goodsList) {
|
| | | list.add(tf.getAuctionId());
|
| | | }
|
| | |
|
| | | try {
|
| | | TaoKeApiUtil.getBatchGoodsInfo(list);
|
| | | } catch (TaoKeApiException e1) {
|
| | | e1.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | |
|
| | | System.out.println(count);
|
| | | |
| | | }
|
| | |
|
| | | @Test
|
| | | public void test2() {
|
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | | app.setAdzoneId("44841750025");
|
| | | app.setAppKey("25070111");
|
| | | app.setAppSecret("c7809ad9cd926fc45199d1d3ab7fe2eb");
|
| | | app.setPid("mm_124933865_113050446_44841750025");
|
| | | try {
|
| | | TaoBaoGoodsBrief goods = TaoKeApiUtil.searchGoodsDetail(527893773636L, app);
|
| | | System.out.println(goods.getId());
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | System.out.println(HttpUtil.getShortLink("http://h5.flq001.com"));
|
| | | System.out.println(HttpUtil.getShortLink("http://h5.flq002.com"));
|
| | | System.out.println(HttpUtil.getShortLink("http://h5.flq003.com"));
|
| | | System.out.println(HttpUtil.getShortLink("http://h5.flq004.com"));
|
| | | System.out.println(HttpUtil.getShortLink("http://h5.flq005.com"));
|
| | | }
|
| | |
|
| | | @Test
|
| | | public void test3() {
|
| | | for (int i = 0; i < 10; i++) {
|
| | | String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
| | | System.out.println(uuid);
|
| | | Long auctionId = 598165623087L;
|
| | | String appKey = "27821872";
|
| | | String appSecret = "9277b7c40b753e142303eeabc1936c80";
|
| | | String pid = "mm_491980152_690500060_109327900051";
|
| | | TaoKeAppInfo app=new TaoKeAppInfo(appKey, appSecret, pid);
|
| | |
|
| | | try {
|
| | | TaoKeApiUtil.createTaoLiJin(auctionId, "淘礼金", new BigDecimal(1), 1, new Date(),
|
| | | new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 12L), new Date(),
|
| | | new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 12L), app);
|
| | | } catch (TaoKeApiException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36");
|
| | | headers.put("referer", "https://pub.alimama.com/myunion.htm");
|
| | | Map<String, String> params = new HashMap<>();
|
| | | params.put("tab", 3 + "");//3
|
| | | params.put("tab", 3 + "");// 3
|
| | | params.put("toPage", "10");
|
| | | params.put("perPageSize", "500");
|
| | | params.put("_input_charset", "utf-8");
|
| | | params.put("gcid", "8");//8
|
| | | params.put("gcid", "8");// 8
|
| | | params.put("t", System.currentTimeMillis() + "");
|
| | | params.put("_tb_token_", "78e513aee5563");
|
| | |
|
| | |
| | | JSONObject item = array.optJSONObject(i);
|
| | | String pid = item.optString("adzonePid");
|
| | | if ((item.optString("name").startsWith("quanqudao_") || item.optString("name").startsWith("tuiguang_"))
|
| | | && item.optInt("mixClick30day")<3000) {
|
| | | && item.optInt("mixClick30day") < 3000) {
|
| | | pids.add(pid);
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | @Test
|
| | | public void test6() {
|
| | | TaoKeApiUtil.taoKeContent();
|
| | | String token = TaoKeApiUtil.getTKToken(
|
| | | "https://img.alicdn.com/bao/uploaded/i4/1951405497/O1CN01pSRKwW1qTfhFOL6ID_!!0-item_pic.jpg",
|
| | | "进门门垫卧室地毯厨房脚垫卫浴室防滑垫子家用门口卫生间吸水地垫",
|
| | | "https://uland.taobao.com/coupon/edetail?e=ALb9e%2B%2F%2BWuEGQASttHIRqWG9PQkvBWgpe2xKTDmY89k3iJ6QLtrZTaw1YqztnqtTrnLz2cLaP4IorCkhghE4lRktOfsF9p14gPp7zT6kOnRnXdWpB0IN0xemP0hpIIPvjDppvlX%2Bob8NlNJBuapvQ2MDg9t1zp0R8pjV3C9qcwTlnMqBDl4yuer2wO%2Fohke1&traceId=0b83456615579010794213275ee3b8&union_lens=lensId:0b1832c2_0bdc_16aba23f39d_07b3&xId=hu3LxjUFR7nb3uT9e97Uy74tDuNpUuisuzrh7K8WAro72oLHXY1N6hSpx7bzQWpJ3rMAKcQf6fA0iBNYmL0GOA");
|
| | | System.out.println(token);
|
| | | }
|
| | |
|
| | | @Test
|
| | | public void test7() {
|
| | | Long uid = 1965358L;
|
| | | Long auctionId = 575009129060L;
|
| | | String platform = "ios";
|
| | | UserInfoService userInfoService = BeanUtil.getBean(UserInfoService.class);
|
| | | UserExtraTaoBaoInfoService userExtraTaoBaoInfoService = BeanUtil.getBean(UserExtraTaoBaoInfoService.class);
|
| | | TaoBaoBuyRelationMapService taoBaoBuyRelationMapService = BeanUtil.getBean(TaoBaoBuyRelationMapService.class);
|
| | | TBPidService tbPidService = BeanUtil.getBean(TBPidService.class);
|
| | |
|
| | | ShareGoodsService shareGoodsService = BeanUtil.getBean(ShareGoodsService.class);
|
| | |
|
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
|
| | |
|
| | | TaoBaoGoodsBrief goods = null;
|
| | |
|
| | | try {
|
| | | goods = TaoKeApiUtil.getSimpleGoodsInfo(auctionId);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | return;
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "获取商品简版详情出错", auctionId + "");
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | boolean isNative = false;
|
| | | String pid = null;
|
| | |
|
| | | boolean specialConvert = false;
|
| | |
|
| | | if (goods.getMaterialLibType() != null && goods.getMaterialLibType() == 1) {
|
| | | specialConvert = true;
|
| | | } else
|
| | | specialConvert = false;
|
| | |
|
| | | String specialId = null;
|
| | | String relationId = null;
|
| | | // 查询用户ID是否绑定了会员运营ID
|
| | | UserExtraTaoBaoInfo userInfo = userExtraTaoBaoInfoService.getByUid(uid);
|
| | | if (userInfo != null && !StringUtil.isNullOrEmpty(userInfo.getSpecialId()) && userInfo.getSpecialValid() != null
|
| | | && userInfo.getSpecialValid() == true) {
|
| | | specialId = userInfo.getSpecialId();
|
| | | relationId = userInfo.getRelationId();
|
| | | // 已经绑定
|
| | | if (specialConvert) {
|
| | | isNative = true;
|
| | | } else
|
| | | isNative = false;
|
| | |
|
| | | pid = TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT;
|
| | |
|
| | | } else {// 尚未绑定
|
| | | isNative = true;
|
| | | }
|
| | |
|
| | | data.put("native", isNative);
|
| | |
|
| | | int pidType = PidUser.TYPE_FANLI_ANDROID;
|
| | | if (platform.equalsIgnoreCase("ios"))
|
| | | pidType = PidUser.TYPE_FANLI_IOS;
|
| | | try {
|
| | |
|
| | | TaoBaoLink taoBaoLink = null;
|
| | | // 是返利商品库的商品
|
| | | if (specialConvert) {
|
| | | if (!StringUtil.isNullOrEmpty(specialId)) {
|
| | | taoBaoLink = shareGoodsService.getTaoBaoLinkForBuyWithSpecial(uid, specialId, auctionId);
|
| | | data.put("native", true);
|
| | | } else {
|
| | | if (!specialConvert && !isNative) {
|
| | | if (pidType == PidUser.TYPE_FANLI_ANDROID)
|
| | | taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
|
| | | tbPidService.getAndroidDefault().getPid());
|
| | | else
|
| | | taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
|
| | | tbPidService.getIOSDefault().getPid());
|
| | | } else
|
| | | taoBaoLink = shareGoodsService.getTaoBaoLinkForBuy(uid, auctionId, pidType);
|
| | | }
|
| | | } else {// 不是返利库的商品,用特殊PID替代
|
| | | try {
|
| | | relationId = taoBaoBuyRelationMapService.getRelationId(uid);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e, "uid:" + uid, null);
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(relationId)) {//
|
| | | taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId,
|
| | | TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
|
| | | data.put("native", true);
|
| | | } else {
|
| | | if (pidType == PidUser.TYPE_FANLI_ANDROID)
|
| | | taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
|
| | | tbPidService.getAndroidDefault().getPid());
|
| | | else
|
| | | taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
|
| | | tbPidService.getIOSDefault().getPid());
|
| | | }
|
| | | }
|
| | | JSONObject link = new JSONObject();
|
| | | link.put("clickUrl", taoBaoLink.getClickUrl());
|
| | | link.put("couponUrl", taoBaoLink.getCouponLink());
|
| | | data.put("type", 1);
|
| | | data.put("link", link);
|
| | | } catch (Exception e) {
|
| | | isNative = false;
|
| | | // TBPid tbPid = null;
|
| | | // if (acceptData.getPlatform().equalsIgnoreCase("android")) {
|
| | | // tbPid = tbPidService.getTBPid(uid, PidUser.TYPE_FANLI_ANDROID);
|
| | | // } else {
|
| | | // tbPid = tbPidService.getTBPid(uid, PidUser.TYPE_FANLI_IOS);
|
| | | // }
|
| | | //
|
| | | // data.put("native", isNative);
|
| | |
|
| | | // if (tbPid != null) {
|
| | | // String siteId = tbPid.getPid().split("_")[2];
|
| | | // String adzoneId = tbPid.getPid().split("_")[3];
|
| | | // TaoBaoUnionConfig config =
|
| | | // taoBaoUnionConfigService.getConfigByAppIdCache(siteId);
|
| | | // ClientTBPid clientTBPid = new ClientTBPid(config.getAppKey(),
|
| | | // tbPid.getPid(), siteId, adzoneId);
|
| | | // data.put("type", 2);
|
| | | // data.put("tbPidInfo", clientTBPid);
|
| | | // out.print(JsonUtil.loadTrueResult(data));
|
| | | // } else {
|
| | | // out.print(JsonUtil.loadFalseResult(1, "请求失败"));
|
| | | // }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | private void deleteAdzones(String adzones) {
|
| | |
| | | } catch (InterruptedException e) {
|
| | | }
|
| | | }
|
| | |
|
| | | }
|