fanli/src/main/java/com/yeshi/fanli/controller/client/v1/RecommendController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/job/order/elme/UpdateElmeOrderJob.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/util/dataoke/DaTaoKeApiUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/RecommendController.java
@@ -1073,7 +1073,7 @@ return; } List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.getRelationGoodsRecommend(id, 6); List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 6); if (goodsList == null) goodsList = new ArrayList<>(); @@ -2467,7 +2467,7 @@ try { List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.getRelationGoodsRecommend(id, 10); List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 10); // 初始化 if (goodsList == null) { goodsList = new ArrayList<TaoBaoGoodsBrief>(); fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -1018,7 +1018,8 @@ BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE); ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE); for (PDDGoodsDetail goods : goodsList) { listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO)); } @@ -1036,7 +1037,7 @@ return; } List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.getRelationGoodsRecommend(id, 10); List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 10); // 初始化 if (goodsList == null) { goodsList = new ArrayList<TaoBaoGoodsBrief>(); @@ -1064,7 +1065,7 @@ BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE); goodsList.parallelStream().forEach(goods -> { if (goods != null) { // 获取详情 @@ -1084,8 +1085,7 @@ } if (taoBaoGoodsBrief != null) { listExtra.add( GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO)); listExtra.add(GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO)); } } }); fanli/src/main/java/com/yeshi/fanli/job/order/elme/UpdateElmeOrderJob.java
New file @@ -0,0 +1,58 @@ package com.yeshi.fanli.job.order.elme; import java.util.List; import javax.annotation.Resource; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import com.yeshi.fanli.entity.bus.user.HongBaoV2; import com.yeshi.fanli.entity.elme.ElmeOrder; import com.yeshi.fanli.exception.elme.ElmeOrderException; import com.yeshi.fanli.service.inter.elme.ElmeOrderProcessService; import com.yeshi.fanli.service.inter.order.OrderProcessService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.elme.ElmeOrderUtil; //饿了么爬单,到账 @Component public class UpdateElmeOrderJob { @Resource private ElmeOrderProcessService elmeOrderProcessService; @Resource private OrderProcessService orderProcessService; /** * 更新订单(每天早上凌晨0点,下午4点) */ @Scheduled(cron = "0 0 0,16 * * ? ") public void updateOrder() { if (!Constant.IS_TASK) return; try { List<ElmeOrder> orderList = ElmeOrderUtil.pullLatest5DayOrder(); try { for (ElmeOrder order : orderList) elmeOrderProcessService.processOrder(order); } catch (ElmeOrderException e) { e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } } // 每天凌晨过2分到账 @Scheduled(cron = "0 2 0 * * ? ") public void fanli() { if (!Constant.IS_TASK) return; List<HongBaoV2> hongBaoList = orderProcessService.getCanBalanceElmeFanliHongBao(); for (HongBaoV2 v2 : hongBaoList) orderProcessService.elmeFanli(v2.getId()); } } fanli/src/main/java/com/yeshi/fanli/util/dataoke/DaTaoKeApiUtil.java
@@ -358,6 +358,24 @@ } return null; } public static DaTaoKeDetailV2 getGoodsDetailByGoodsId(Long goodsId) { TaoKeAppInfo app = getRandomApp(); Map<String, String> params = new TreeMap<>(); params.put("version", "v1.1.1"); params.put("appKey", app.getAppKey()); params.put("goodsId", goodsId + ""); params.put("sign", getSign(params, app.getAppSecret())); String result = HttpUtil.get("https://openapi.dataoke.com/api/goods/get-goods-details", params, new HashMap<>()); System.out.println(result); JSONObject json = JSONObject.fromObject(result); JSONObject dataJson = json.optJSONObject("data"); if (dataJson != null) { return parseDaTaoKeDetailV2(dataJson); } return null; } public static DaTaoKeGoodsResult search(String key, List<Integer> cidList, BigDecimal priceLowerLimit, BigDecimal priceUpperLimit, int page, int pageSize, Integer sort) { fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java
@@ -1844,6 +1844,12 @@ return url; } /** * 获取淘宝的商品详情 * * @param actionId * @return */ public static TaoBaoGoodsBrief getSimpleGoodsBrief(Long actionId) { JSONObject data = new JSONObject(); data.put("itemNumId", actionId + ""); @@ -1855,6 +1861,7 @@ } catch (UnsupportedEncodingException e) { e.printStackTrace(); } HttpClient client = new HttpClient(); GetMethod gm = new GetMethod(url); String result = null; @@ -1879,25 +1886,30 @@ JSONObject resultOBJ = JSONObject.fromObject(result); if (resultOBJ.optJSONObject("data") != null) { data = resultOBJ.optJSONObject("data"); JSONObject item = data.optJSONObject("item"); JSONObject seller = data.optJSONObject("seller"); TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief(); goods.setTitle(item.optString("title")); goods.setAuctionId(item.optLong("itemId")); goods.setTitle(item.optString("title")); if (item.optJSONArray("images") != null && item.optJSONArray("images").size() > 0) { String picture = item.optJSONArray("images").optString(0); goods.setPictUrl(picture.startsWith("http") ? picture : "https:" + picture); if (data != null) { JSONObject item = data.optJSONObject("item"); if (item != null) { JSONObject seller = data.optJSONObject("seller"); TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief(); goods.setTitle(item.optString("title")); goods.setAuctionId(item.optLong("itemId")); goods.setTitle(item.optString("title")); if (item.optJSONArray("images") != null && item.optJSONArray("images").size() > 0) { String picture = item.optJSONArray("images").optString(0); goods.setPictUrl(picture.startsWith("http") ? picture : "https:" + picture); } if (seller != null) { goods.setSellerId(seller.optLong("shopId")); String shopType = seller.optString("shopType"); if ("B".equalsIgnoreCase(shopType)) { goods.setUserType(1); } else goods.setUserType(0); goods.setShopTitle(seller.optString("shopName")); } return goods; } } goods.setSellerId(seller.optLong("shopId")); String shopType = seller.optString("shopType"); if ("B".equalsIgnoreCase(shopType)) { goods.setUserType(1); } else goods.setUserType(0); goods.setShopTitle(seller.optString("shopName")); return goods; } return null; } fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java
@@ -9,11 +9,9 @@ import org.yeshi.utils.taobao.TbImgUtil; import com.taobao.api.ApiException; import com.yeshi.fanli.dto.taobao.TaoBaoShopInfoDTO; import com.yeshi.fanli.dto.taobao.TaoLiJinDTO; import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinReport; import com.yeshi.fanli.entity.taobao.RelateGoods; import com.yeshi.fanli.entity.taobao.SearchFilter; import com.yeshi.fanli.entity.taobao.SearchShopFilter; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; @@ -950,23 +948,6 @@ return null; } public static List<RelateGoods> getRelateGoodsList(long auctionId) throws ApiException { List<RelateGoods> resultList = new ArrayList<>(); List<TaoBaoGoodsBrief> list = getRelationGoodsRecommend(auctionId, 9); for (TaoBaoGoodsBrief goods : list) { if (goods != null) { RelateGoods rg = new RelateGoods(); rg.setId(goods.getAuctionId() + ""); rg.setPicUrl(goods.getPictUrl()); rg.setTitle(goods.getTitle()); rg.setZkPrice(goods.getZkPrice().toString()); rg.setUrl(goods.getAuctionUrl()); resultList.add(rg); } } return resultList; } /** * 获取券详细信息 * @@ -993,45 +974,6 @@ } else return null; return info; } /** * 获取关联商品推荐 * * @param auctionId * @return */ public static List<TaoBaoGoodsBrief> getRelationGoodsRecommend(long auctionId, int count) { List<TaoBaoGoodsBrief> list = new ArrayList<>(); Map<String, String> map = new HashMap<>(); map.put("method", "taobao.tbk.item.recommend.get"); map.put("num_iid", auctionId + ""); map.put("count", count + ""); map.put("platform", 2 + ""); map.put("fields", "num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url"); String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true); JSONObject data = JSONObject.fromObject(resultStr); if (data.optJSONObject("tbk_item_recommend_get_response") != null) { if (data.optJSONObject("tbk_item_recommend_get_response").optJSONObject("results") == null) return list; JSONArray array = data.optJSONObject("tbk_item_recommend_get_response").optJSONObject("results") .optJSONArray("n_tbk_item"); if (array != null) for (int i = 0; i < array.size(); i++) { JSONObject item = array.optJSONObject(i); TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief(); goods.setAuctionId(item.optLong("num_iid")); goods.setTitle(item.optString("title")); goods.setZkPrice(new BigDecimal(item.optString("zk_final_price"))); goods.setAuctionUrl(item.optString("item_url")); goods.setPictUrl(item.optString("pict_url")); goods.setSalesCount(item.optString("volume")); goods.setUserType(item.optInt("user_type")); list.add(goods); } } return list; } public static void taoQiangGou() { @@ -1334,14 +1276,12 @@ if (response != null && response.optJSONObject("result_list") != null) { JSONArray array = response.optJSONObject("result_list").optJSONArray("map_data"); if (array != null) { for (int i = 0; i < array.size(); i++) { JSONObject item = array.optJSONObject(i); TaoBaoGoodsBrief goods = parseWuLiaoItemFromMaterialId(item); if (goods != null) goodsList.add(goods); } pageSize = array.size(); } } @@ -2110,22 +2050,37 @@ return null; } public static void guessLikeByAuctionId(Long auctionId) { public static List<TaoBaoGoodsBrief> guessLikeByAuctionId(Long auctionId,int count) { Map<String, String> map = new HashMap<>(); map.put("method", "taobao.tbk.dg.optimus.material"); map.put("item_id", auctionId + ""); map.put("page_size", 20 + ""); map.put("page_size", count + ""); map.put("page_no", 1 + ""); map.put("material_id", 13256 + ""); List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); JSONObject resultJSON = null; try { resultJSON = TaoKeBaseUtil.baseRequest(map, true); System.out.println(resultJSON); JSONObject response = resultJSON.optJSONObject("tbk_dg_optimus_material_response"); if (response != null && response.optJSONObject("result_list") != null) { JSONArray array = response.optJSONObject("result_list").optJSONArray("map_data"); if (array != null) { for (int i = 0; i < array.size(); i++) { JSONObject item = array.optJSONObject(i); TaoBaoGoodsBrief goods = parseWuLiaoItemFromMaterialId(item); if (goods != null) goodsList.add(goods); } } } } catch (Exception e) { e.printStackTrace(); } return goodsList; } }