From 2147d023563a7c9d05d97547c00d6b0162c0644c Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期一, 09 十一月 2020 18:37:24 +0800 Subject: [PATCH] 刷单风险规则优化 --- fanli/src/test/java/org/fanli/TaoKeTest.java | 649 +++++++++++++++++++++++++--------------------------------- 1 files changed, 283 insertions(+), 366 deletions(-) diff --git a/fanli/src/test/java/org/fanli/TaoKeTest.java b/fanli/src/test/java/org/fanli/TaoKeTest.java index a0ba7ee..4489dde 100644 --- a/fanli/src/test/java/org/fanli/TaoKeTest.java +++ b/fanli/src/test/java/org/fanli/TaoKeTest.java @@ -13,36 +13,29 @@ import java.util.List; import java.util.Map; +import com.yeshi.fanli.dto.order.OrderQuery; +import com.yeshi.fanli.util.taobao.TaoKeOrderApiUtil; import org.junit.Test; import org.yeshi.utils.HttpUtil; import com.yeshi.fanli.dao.mybatis.taobao.TBPidMapper; import com.yeshi.fanli.dto.taobao.TaoLiJinDTO; -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.SearchFilter; 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.TaoKeAppInfo; +import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult; +import com.yeshi.common.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.exception.tlj.TaoLiJinCreateException; import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService; -import com.yeshi.fanli.service.inter.taobao.TaoBaoBuyRelationMapService; -import com.yeshi.fanli.service.inter.user.TBPidService; -import com.yeshi.fanli.service.inter.user.UserInfoService; -import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService; import com.yeshi.fanli.service.manger.goods.ConvertLinkManager; import com.yeshi.fanli.util.BeanUtil; -import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TaoBaoConstant; -import com.yeshi.fanli.util.TimeUtil; -import com.yeshi.fanli.util.dataoke.DaTaoKeApiUtil; +import org.yeshi.utils.TimeUtil; import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil; import com.yeshi.fanli.util.taobao.TaoKeApiUtil; -import com.yeshi.fanli.util.taobao.TaoKeOrderApiUtil; +import com.yeshi.fanli.util.taobao.TaoKeScApiUtil; import net.sf.json.JSONArray; import net.sf.json.JSONObject; @@ -50,394 +43,318 @@ //@Ignore public class TaoKeTest { - public static int count = 0; + public static int count = 0; - @Test - public void test1() { - // List<TaoBaoGoodsBrief> list= - // TaoKeApiUtil.guessLikeByAuctionId(550439753563L,6); - // System.out.println(list); - // TaoBaoUtil.getTBDetailImageWithSize(597016140493L); - // System.out.println(goods); - // DaTaoKeApiUtil.getGoodsDetailByGoodsId(558195316187L); - // try { - // TaoKeApiUtil.specialConvertCoupon(608512721647L, new - // TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, - // TaoBaoConstant.TAOBAO_AUTH_APPSECRET, - // TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT)); - // } catch (Exception e) { - // // TODO Auto-generated catch block - // e.printStackTrace(); - // } + @Test + public void test1() { + // List<TaoBaoGoodsBrief> list= + // TaoKeApiUtil.guessLikeByAuctionId(550439753563L,6); + // System.out.println(list); + // TaoBaoUtil.getTBDetailImageWithSize(597016140493L); + // System.out.println(goods); + // DaTaoKeApiUtil.getGoodsDetailByGoodsId(558195316187L); + // try { + // TaoKeApiUtil.specialConvertCoupon(608512721647L, new + // TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, + // TaoBaoConstant.TAOBAO_AUTH_APPSECRET, + // TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT)); + // } catch (Exception e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } - // String link = TaoKeApiUtil.officialActivityConvert(87140050199L + "", - // "1571715733668", "513796574"); - // System.out.println(link); + // String link = TaoKeApiUtil.officialActivityConvert(87140050199L + "", + // "1571715733668", "513796574"); + // System.out.println(link); - // String link = - // TaoBaoUtil.getTaoBaoUnionAuthUrl(TaoBaoConstant.TAOBAO_AUTH_APPKEY, - // "http://api.flqapp.com/fanli/client/v1/auth/callback/tb", 6396582L, - // "share"); - // System.out.println(link); + // String link = + // TaoBaoUtil.getTaoBaoUnionAuthUrl(TaoBaoConstant.TAOBAO_AUTH_APPKEY, + // "http://api.flqapp.com/fanli/client/v1/auth/callback/tb", 6396582L, + // "share"); + // System.out.println(link); - // try { - // TaoKeApiUtil.searchGoodsDetail(608512721647L); - // } catch (TaobaoGoodsDownException e) { - // e.printStackTrace(); - // } + // try { + // TaoKeApiUtil.searchGoodsDetail(608512721647L); + // } catch (TaobaoGoodsDownException e) { + // e.printStackTrace(); + // } -// List<TaoBaoOrder> list = TaoKeOrderApiUtil.getTaoBaoRelationOrderList( -// TimeUtil.convertToTimeTemp("2019-12-09 10:13:52", "yyyy-MM-dd HH:mm:ss"), -// TimeUtil.convertToTimeTemp("2019-12-09 10:14:53", "yyyy-MM-dd HH:mm:ss"), 1); -// System.out.println(list); - - String result = TaoKeApiUtil.officialActivityConvert("19507100253", - "1571715733668", "20211660").getShort_click_url(); - System.out.println(result); - } + // List<TaoBaoOrder> list = + // TaoKeOrderApiUtil.getTaoBaoRelationOrderList( + // TimeUtil.convertToTimeTemp("2019-12-09 10:13:52", "yyyy-MM-dd + // HH:mm:ss"), + // TimeUtil.convertToTimeTemp("2019-12-09 10:14:53", "yyyy-MM-dd + // HH:mm:ss"), 1); + // System.out.println(list); - @Test - public void test2() { - // String result = TaoKeApiUtil.officialActivityConvert("19507100253", - // "1584519810786", "20211660"); - // System.out.println(result); +// String result = TaoKeApiUtil.officialActivityConvert("19507100253", "1571715733668", "20211660") +// .getShort_click_url(); +// System.out.println(result); - // TaoKeApiUtil.getQuanInfo(579875678934L, - // "91b8984019e24fe1b1e3d6bd15479785"); - String result = TaoKeApiUtil.getActivityInfo("1583739244161", TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT, - "511374878"); - System.out.println(result); + try { + TaoKeApiUtil.searchGoodsDetail(618071624442L); + } catch (TaobaoGoodsDownException e) { + e.printStackTrace(); + } - String token = TaoKeApiUtil.getTKToken("http://", "鍙g澶栧崠绾㈠寘", result); +// TaoKeApiUtil.specialConvertCoupon(41359311431L, "510437437",null, new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET, TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT)); + } - System.out.println(token); - } + @Test + public void test2() { + // String result = TaoKeApiUtil.officialActivityConvert("19507100253", + // "1584519810786", "20211660"); + // System.out.println(result); - @Test - public void test3() { - Long auctionId = 598165623087L; - String appKey = "27965236"; - String appSecret = "2be7a216bee767dc3a6388aa24f11140"; - String pid = "mm_502940004_754900291_109486750166"; - TaoKeAppInfo app = new TaoKeAppInfo(appKey, appSecret, pid); + // TaoKeApiUtil.getQuanInfo(579875678934L, + // "91b8984019e24fe1b1e3d6bd15479785"); +// String result = TaoKeApiUtil.getActivityInfo("1583739244161", TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT, +// "511374878"); +// System.out.println(result); + String result = "https://uland.taobao.com/taolijin/edetail?eh=2gFTo0zZuaeZuQF0XRz0iAXoB%2BDaBK5LQS0Flu%2FfbSp4QsdWMikAalrisGmre1Id0BFAqRODu11RSUolmZ1LiwZ2FMnFRDsF%2BMUwzxYlSKECGml30RY8PBx5jSVkulpmySQequ91YUPn8ckYb41tOyMTAhb7rmGydIrwSfYTDgyfcFUbN9tzknpL2ZPAakwyOfbWhbYEOF1LZWNyyCUQRu9L02t3YMA5G%2FdYx%2FWrPlG0lbyxNMIB8p2A%2Fvvgsr%2Fg9KslStkQtyrcQrNyb0ac3hVaN9HlETXhasDqmcapORh%2BOHfs5nLQGA%3D%3D&union_lens=lensId%3A0b59b01d_0bb5_172f470555e_c9b3%3Btraffic_flag%3Dlm&un=b68328d5be2676ace8f55b3b63c56d8b&share_crt_v=1&ut_sk=1.utdid_24587154_1593238990891.TaoPassword-Outside.taoketop&spm=a2159r.13376465.0.0&sp_tk=77+ld2Y1ajF3V3ZxOUbvv6U=/&relationId=20211660"; - try { - TaoLiJinDTO dto = 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); - System.out.println(dto); - } catch (Exception e) { - e.printStackTrace(); - } - } + String token = TaoKeApiUtil.getTKToken("http://", "鍙g澶栧崠绾㈠寘", result); - @Test - public void test4() { - TaoBaoOrderService taoBaoOrderService = BeanUtil.getBean(TaoBaoOrderService.class); - try { - List<TaoBaoOrder> list = TaoBaoOrderUtil.parseOrder( - new FileInputStream(new File("C:/Users/Administrator/Desktop/娣樺疂璁㈠崟/2018.1.10-2018-03-12 (2).xls"))); - for (int i = 0; i < list.size(); i++) { - // if (TimeUtil.convertToTimeTemp(list.get(i).getCreateTime(), - // "yyyy-MM-dd HH:mm:ss") > 1522339200000l) { - // list.remove(i); - // i--; - // } - } + System.out.println(token); + } - taoBaoOrderService.addTaoBaoOrderList(list); - System.out.println(list); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - } + @Test + public void test3() { + Long auctionId = 598165623087L; + String appKey = "27965236"; + String appSecret = "2be7a216bee767dc3a6388aa24f11140"; + String pid = "mm_502940004_754900291_109486750166"; + TaoKeAppInfo app = new TaoKeAppInfo(appKey, appSecret, pid); + try { + TaoLiJinDTO dto = 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); + System.out.println(dto); + } catch (Exception e) { + e.printStackTrace(); + } + } - static String cookie = "cna=Q9eYFEM1rm8CAXH7EKUDSamu; account-path-guide-s1=true; 124933865_yxjh-filter-1=true; undefined_yxjh-filter-1=true; t=9dd8d10a742dccaf3c42af830249fe39; pub-message-center=1; cookie2=102d56e20037f8d9d1edff803285bb30; v=0; _tb_token_=58995010ab130; alimamapwag=TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzczLjAuMzY4My4xMDMgU2FmYXJpLzUzNy4zNg%3D%3D; cookie32=b9eeefb51faae3c2f2d5a08032516932; alimamapw=F3AHRnRyE3slFHALR3V%2BEHIDF3Z2RndyPwhRVQAOAwAPBVMABQ0HAFMBVQtTAgdaUwAJUwUEVlFX%0A; cookie31=MTI0OTMzODY1LCVFNiVBNCVCMCVFOCVBNyU4NiVFNyVBNyU5MSVFNiU4QSU4MCw0MTI2NjE4NjlAcXEuY29tLFRC; login=VFC%2FuZ9ayeYq2g%3D%3D; rurl=aHR0cHM6Ly9wdWIuYWxpbWFtYS5jb20v; apushcbb2dd0258025fce735efc665422e16d=%7B%22ts%22%3A1556431673690%2C%22heir%22%3A1556431667417%2C%22parentId%22%3A1556431661238%7D; l=bBT2uo87vPM0bgSWBOfNquI8Lx7OPIRb8sPzw4OG5ICP_m1JWkBPWZO5aaYvC3GNa6FDR3y1Nww8BuLKsy4Eh; isg=BNLSh7GG2qh7bSaDwEb8EBBFI5h0S9cHLDtQ4pwrXwV9r3CphHO9jLWJH0M2304V"; + @Test + public void test4() { + TaoBaoOrderService taoBaoOrderService = BeanUtil.getBean(TaoBaoOrderService.class); + try { + List<TaoBaoOrder> list = TaoBaoOrderUtil.parseOrder( + new FileInputStream(new File("C:/Users/Administrator/Desktop/娣樺疂璁㈠崟/2018.1.10-2018-03-12 (2).xls"))); + for (int i = 0; i < list.size(); i++) { + // if (TimeUtil.convertToTimeTemp(list.get(i).getCreateTime(), + // "yyyy-MM-dd HH:mm:ss") > 1522339200000l) { + // list.remove(i); + // i--; + // } + } - private List<String> getPids() { + taoBaoOrderService.addTaoBaoOrderList(list); + System.out.println(list); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } - List<String> pids = new ArrayList<>(); + static String cookie = "cna=Q9eYFEM1rm8CAXH7EKUDSamu; account-path-guide-s1=true; 124933865_yxjh-filter-1=true; undefined_yxjh-filter-1=true; t=9dd8d10a742dccaf3c42af830249fe39; pub-message-center=1; cookie2=102d56e20037f8d9d1edff803285bb30; v=0; _tb_token_=58995010ab130; alimamapwag=TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzczLjAuMzY4My4xMDMgU2FmYXJpLzUzNy4zNg%3D%3D; cookie32=b9eeefb51faae3c2f2d5a08032516932; alimamapw=F3AHRnRyE3slFHALR3V%2BEHIDF3Z2RndyPwhRVQAOAwAPBVMABQ0HAFMBVQtTAgdaUwAJUwUEVlFX%0A; cookie31=MTI0OTMzODY1LCVFNiVBNCVCMCVFOCVBNyU4NiVFNyVBNyU5MSVFNiU4QSU4MCw0MTI2NjE4NjlAcXEuY29tLFRC; login=VFC%2FuZ9ayeYq2g%3D%3D; rurl=aHR0cHM6Ly9wdWIuYWxpbWFtYS5jb20v; apushcbb2dd0258025fce735efc665422e16d=%7B%22ts%22%3A1556431673690%2C%22heir%22%3A1556431667417%2C%22parentId%22%3A1556431661238%7D; l=bBT2uo87vPM0bgSWBOfNquI8Lx7OPIRb8sPzw4OG5ICP_m1JWkBPWZO5aaYvC3GNa6FDR3y1Nww8BuLKsy4Eh; isg=BNLSh7GG2qh7bSaDwEb8EBBFI5h0S9cHLDtQ4pwrXwV9r3CphHO9jLWJH0M2304V"; - String url = "https://pub.alimama.com/common/adzone/adzoneManage.json"; - Map<String, String> headers = new HashMap<>(); - headers.put("cookie", cookie); - headers.put("user-agent", - "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("toPage", "10"); - params.put("perPageSize", "500"); - params.put("_input_charset", "utf-8"); - params.put("gcid", "8");// 8 - params.put("t", System.currentTimeMillis() + ""); - params.put("_tb_token_", "78e513aee5563"); + private List<String> getPids() { - String result = HttpUtil.get(url, params, headers); - JSONObject resultJson = JSONObject.fromObject(result); - JSONArray array = resultJson.optJSONObject("data").optJSONArray("pagelist"); - for (int i = 0; i < array.size(); i++) { - 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) { - pids.add(pid); - } - } + List<String> pids = new ArrayList<>(); - return pids; - } + String url = "https://pub.alimama.com/common/adzone/adzoneManage.json"; + Map<String, String> headers = new HashMap<>(); + headers.put("cookie", cookie); + headers.put("user-agent", + "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("toPage", "10"); + params.put("perPageSize", "500"); + params.put("_input_charset", "utf-8"); + params.put("gcid", "8");// 8 + params.put("t", System.currentTimeMillis() + ""); + params.put("_tb_token_", "78e513aee5563"); - @Test - public void test5() { - String[] pids = new String[] { "mm_124933865_43788020_437192946", "mm_124933865_35320824_165774413", - "mm_124933865_43788020_381938426", "mm_124933865_46852994_1828270335", - "mm_124933865_56750082_10647300249", "mm_124933865_56750082_87140050199", - "mm_124933865_56750082_89555600043" }; - TBPidMapper tbPidMapper = BeanUtil.getBean(TBPidMapper.class); - for (int i = 200; i < 230; i++) { - List<TBPid> list = tbPidMapper.listByTypeAndUse(true, 500 * i, 500); - String adzones = ""; - for (TBPid tbPid : list) { - boolean needAdd = true; - for (String p : pids) - if (p.equalsIgnoreCase(tbPid.getPid())) { - needAdd = false; - break; - } - if (needAdd) - adzones += tbPid.getPid().split("_")[3] + ","; - } - adzones = adzones.substring(0, adzones.length() - 1); - } - } + String result = HttpUtil.get(url, params, headers); + JSONObject resultJson = JSONObject.fromObject(result); + JSONArray array = resultJson.optJSONObject("data").optJSONArray("pagelist"); + for (int i = 0; i < array.size(); i++) { + 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) { + pids.add(pid); + } + } - @Test - public void test6() { - String text = "[鐜懓]鍚勪綅浜插弸濂斤紝璁板緱棰嗗埜鍝鎰夊揩]" + "銆愪含涓�1鏈�3鏃ラ鍒哥簿閫夈�慭n" + "[绾㈠寘]鎶㈢孩鍖� 鏈�楂�888\n" + "https://u.jd.com/8xeCfl\n" - + "馃殔鐏溅绁ㄧ鍒�50鍏僜n" + "https://u.jd.com/cMReZz\n" + "馃専灞呭濂界墿9.9鍖呴偖\n" + "https://u.jd.com/AG2z4A\n" - + "馃憯鐢疯3浠�7鎶榎n" + "https://u.jd.com/kgMslr\n" + "馃憲濂宠娓呬粨5鎶樿捣\n" + "https://u.jd.com/kgMslr\n" + "馃泹鏈夌ぜ鏈夊勾璐n" - + "https://u.jd.com/qdvIiG\n" + "馃拫SK-II澶т績\n" + "https://u.jd.com/7XybkD\n" + "馃挵瓒呯骇鐧句嚎琛ヨ创\n" - + "https://u.jd.com/qVFjDL\n" + "馃嵓姣嶅┐鍒稿勾璐ц妭\n" + "https://u.jd.com/kA0scy\n" + "馃泹瓒呭競婊�199-100\n" - + "https://u.jd.com/eQSwNn\n" + "[鐧糫鍐呰喘鍒稿ぇ鍏╘n" + "https://u.jd.com/zIHmUy\n" + "[绂廬Plus鍏ㄥ搧鍒竆n" - + "https://u.jd.com/d9fcGr\n" + "鈿′含涓滅鏉�\n" + "https://u.jd.com/WSIi1z\n" + "銆愯寰椾笌鏇村濂藉弸鍒嗕韩[鎰夊揩]銆�"; - ConvertLinkManager convertLinkManager = BeanUtil.getBean(ConvertLinkManager.class); - try { - System.out.println(convertLinkManager.convertLinkFromText(text, 437032L, true)); - } catch (Exception e) { - e.printStackTrace(); - } - } + return pids; + } - @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); + @Test + public void test5() { + String[] pids = new String[]{"mm_124933865_43788020_437192946", "mm_124933865_35320824_165774413", + "mm_124933865_43788020_381938426", "mm_124933865_46852994_1828270335", + "mm_124933865_56750082_10647300249", "mm_124933865_56750082_87140050199", + "mm_124933865_56750082_89555600043"}; + TBPidMapper tbPidMapper = BeanUtil.getBean(TBPidMapper.class); + for (int i = 200; i < 230; i++) { + List<TBPid> list = tbPidMapper.listByTypeAndUse(true, 500 * i, 500); + String adzones = ""; + for (TBPid tbPid : list) { + boolean needAdd = true; + for (String p : pids) + if (p.equalsIgnoreCase(tbPid.getPid())) { + needAdd = false; + break; + } + if (needAdd) + adzones += tbPid.getPid().split("_")[3] + ","; + } + adzones = adzones.substring(0, adzones.length() - 1); + } + } - ShareGoodsService shareGoodsService = BeanUtil.getBean(ShareGoodsService.class); + @Test + public void test6() { + String text = "[鐜懓]鍚勪綅浜插弸濂斤紝璁板緱棰嗗埜鍝鎰夊揩]" + "銆愪含涓�1鏈�3鏃ラ鍒哥簿閫夈�慭n" + "[绾㈠寘]鎶㈢孩鍖� 鏈�楂�888\n" + "https://u.jd.com/8xeCfl\n" + + "馃殔鐏溅绁ㄧ鍒�50鍏僜n" + "https://u.jd.com/cMReZz\n" + "馃専灞呭濂界墿9.9鍖呴偖\n" + "https://u.jd.com/AG2z4A\n" + + "馃憯鐢疯3浠�7鎶榎n" + "https://u.jd.com/kgMslr\n" + "馃憲濂宠娓呬粨5鎶樿捣\n" + "https://u.jd.com/kgMslr\n" + "馃泹鏈夌ぜ鏈夊勾璐n" + + "https://u.jd.com/qdvIiG\n" + "馃拫SK-II澶т績\n" + "https://u.jd.com/7XybkD\n" + "馃挵瓒呯骇鐧句嚎琛ヨ创\n" + + "https://u.jd.com/qVFjDL\n" + "馃嵓姣嶅┐鍒稿勾璐ц妭\n" + "https://u.jd.com/kA0scy\n" + "馃泹瓒呭競婊�199-100\n" + + "https://u.jd.com/eQSwNn\n" + "[鐧糫鍐呰喘鍒稿ぇ鍏╘n" + "https://u.jd.com/zIHmUy\n" + "[绂廬Plus鍏ㄥ搧鍒竆n" + + "https://u.jd.com/d9fcGr\n" + "鈿′含涓滅鏉�\n" + "https://u.jd.com/WSIi1z\n" + "銆愯寰椾笌鏇村濂藉弸鍒嗕韩[鎰夊揩]銆�"; + ConvertLinkManager convertLinkManager = BeanUtil.getBean(ConvertLinkManager.class); + try { + System.out.println(convertLinkManager.convertLinkFromText(text, 437032L, true,false)); + } catch (Exception e) { + e.printStackTrace(); + } + } - UserInfo user = userInfoService.getUserByIdWithMybatis(uid); + private void deleteAdzones(String adzones) { + String url = "https://pub.alimama.com/common/adzone/adzoneDelete.json"; + Map<String, String> headers = new HashMap<>(); + headers.put("cookie", cookie); + headers.put("user-agent", + "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("adzoneids", adzones); + params.put("gcid", "8"); + params.put("t", System.currentTimeMillis() + ""); + params.put("_tb_token_", "58995010ab130"); + // System.out.println("浣嶇疆:" + i); + String result = (HttpUtil.post(url, params, headers)); + if (result != null && JSONObject.fromObject(result).optBoolean("ok") == true) { + System.out.println(result); + } else { + System.out.println("error---"); + // break; - TaoBaoGoodsBrief goods = null; + } + try { + Thread.sleep(1000 * 3 + (int) (Math.random() * 3000)); + } catch (InterruptedException e) { + } + } - try { - goods = TaoKeApiUtil.getSimpleGoodsInfo(auctionId); - } catch (TaobaoGoodsDownException e) { - return; - } catch (Exception e) { - try { - LogHelper.errorDetailInfo(e, "鑾峰彇鍟嗗搧绠�鐗堣鎯呭嚭閿�", auctionId + ""); - } catch (Exception e1) { - e1.printStackTrace(); - } - } + @Test + public void test12() { + try { + BufferedReader br = new BufferedReader(new InputStreamReader( + new FileInputStream(new File("C:/Users/Administrator/Desktop/鏂板缓鏂囨湰鏂囨。 (2).txt")))); + String text = ""; + String lineTxt = null; + while ((lineTxt = br.readLine()) != null) {// 鏁版嵁浠ラ�楀彿鍒嗛殧 + text += new String(lineTxt.getBytes("unicode"), "UTF-8"); + } + System.out.println(text); + br.close(); + } catch (Exception e) { + } - JSONObject data = new JSONObject(); - boolean isNative = false; - String pid = null; + } - boolean specialConvert = false; + @Test + public void test13() { + TaoKeApiUtil.specialConvertCoupon(579875678934L, new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, + TaoBaoConstant.TAOBAO_AUTH_APPSECRET, TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT),null,null); + try { + TaoKeApiUtil.getSimpleGoodsInfo(556371219169L); + } catch (TaobaoGoodsDownException e) { + e.printStackTrace(); + } + } - if (goods.getMaterialLibType() != null && goods.getMaterialLibType() == 1) { - specialConvert = true; - } else - specialConvert = false; + @Test + public void test14() { + String code = "jlCUH3V5wnDuH9I3ahEg1KgR1380518"; - String specialId = null; - String relationId = null; - // 鏌ヨ鐢ㄦ埛ID鏄惁缁戝畾浜嗕細鍛樿繍钀D - 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; + String result = TaoKeApiUtil.getAccessToken(code, TaoBaoConstant.TAOBAO_AUTH_APPKEY, + TaoBaoConstant.TAOBAO_AUTH_APPSECRET); + System.out.println(result); + JSONObject data = JSONObject.fromObject(result); + data = data.optJSONObject("top_auth_token_create_response").optJSONObject("token_result"); + String accessToken = data.optString("access_token"); + System.out.println(accessToken); - pid = TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT; + // access_token=620272221d6af090974a62a875452dfh3400a52ddf4c2c7759742701 - } else {// 灏氭湭缁戝畾 - isNative = true; - } + } - data.put("native", isNative); + @Test + public void test15() { + // {method=taobao.tbk.sc.material.optional, + // session=6101d231f78794fb690d4e7ecc9f1561f937e85e6a3f1393327215652, + // adzone_id=107334300197, format=json, + // sign=68930B8D27FF0B2687AE474667D23786, page_no=1, q=闉�, + // app_key=24980167, v=2.0, site_id=401250386, sign_method=md5, + // page_size=20, timestamp=2020-05-29 16:46:43} - int pidType = PidUser.TYPE_FANLI_ANDROID; - if (platform.equalsIgnoreCase("ios")) - pidType = PidUser.TYPE_FANLI_IOS; - try { + String session = "6100f00414ec21b3efd66f63a8b1b3a8e4f54bebf46f8c7759742701"; + SearchFilter sf = new SearchFilter(); + sf.setKey("杩愬姩闉�"); + TaoKeScApiUtil.searchWuLiao(sf, session, new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, + TaoBaoConstant.TAOBAO_AUTH_APPSECRET, "mm_106929643_20324269_73400452"), "30125349"); + } - 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); + @Test + public void test16() { + SearchFilter sf = new SearchFilter(); + sf.setKey("琚滃瓙"); + sf.setStartTkRate(5000); + sf.setEndTkRate(9000); + sf.setPage(25); + sf.setPageSize(50); + TaoBaoSearchResult result = TaoKeApiUtil.searchWuLiao(sf,null,null); + System.out.println(result); + } - // 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, "璇锋眰澶辫触")); - // } - } + @Test + public void test17() { + Date startTime = new Date(TimeUtil.convertToTimeTemp("2020-06-27", "yyyy-MM-dd")); + Date endTime = new Date(TimeUtil.convertToTimeTemp("2020-06-28", "yyyy-MM-dd")); + try { + TaoKeApiUtil.createTaoLiJin(550151362030L, "鍙d护", new BigDecimal("1"), 1, startTime, endTime, startTime, + endTime, new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET, TaoBaoConstant.TAOBAO_TLJ_RELATION_PID_DEFAULT)); + } catch (TaoLiJinCreateException e) { + e.printStackTrace(); + } catch (TaoKeApiException e) { + e.printStackTrace(); + } + } - } - private void deleteAdzones(String adzones) { - String url = "https://pub.alimama.com/common/adzone/adzoneDelete.json"; - Map<String, String> headers = new HashMap<>(); - headers.put("cookie", cookie); - headers.put("user-agent", - "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("adzoneids", adzones); - params.put("gcid", "8"); - params.put("t", System.currentTimeMillis() + ""); - params.put("_tb_token_", "58995010ab130"); - // System.out.println("浣嶇疆:" + i); - String result = (HttpUtil.post(url, params, headers)); - if (result != null && JSONObject.fromObject(result).optBoolean("ok") == true) { - System.out.println(result); - } else { - System.out.println("error---"); - // break; + @Test + public void test18(){ - } - try { - Thread.sleep(1000 * 3 + (int) (Math.random() * 3000)); - } catch (InterruptedException e) { - } - } - - @Test - public void test12() { - - try { - - BufferedReader br = new BufferedReader(new InputStreamReader( - new FileInputStream(new File("C:/Users/Administrator/Desktop/鏂板缓鏂囨湰鏂囨。 (2).txt")))); - String text = ""; - String lineTxt = null; - while ((lineTxt = br.readLine()) != null) {// 鏁版嵁浠ラ�楀彿鍒嗛殧 - text += new String(lineTxt.getBytes("unicode"), "UTF-8"); - } - System.out.println(text); - br.close(); - } catch (Exception e) { - } - - } - - @Test - public void test13() { - TaoKeApiUtil.specialConvertCoupon(579875678934L, new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, - TaoBaoConstant.TAOBAO_AUTH_APPSECRET, TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT)); - try { - TaoKeApiUtil.getSimpleGoodsInfo(556371219169L); - } catch (TaobaoGoodsDownException e) { - e.printStackTrace(); - } - } - - @Test - public void test14() { - - Long[] ids = new Long[] { - 547050481823L,612971793223L - }; - try { - for (Long id : ids) { - TaoBaoGoodsBrief goods = TaoKeApiUtil.getSimpleGoodsInfo(id); - System.out.println(goods.getMaterialLibType()); - } - } catch (TaobaoGoodsDownException e) { - e.printStackTrace(); - } - - // DaTaoKeApiUtil.convertLink(614847140426L, - // TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT); - } + OrderQuery q=new OrderQuery(); + q.startTime="2020-01-01"; + q.pageNo=1; + q.pageSize=20; + TaoKeOrderApiUtil.queryTaoBaoOrder(q,TaoBaoConstant.TAOBAO_AUTH_APPKEY,TaoBaoConstant.TAOBAO_AUTH_APPSECRET); + } } -- Gitblit v1.8.0