From 52bc8ff0de3c7538d1401423c1cba9615c0c2082 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期四, 18 六月 2020 17:22:24 +0800 Subject: [PATCH] 发圈商品来源修改 + 云发单规则调整 --- fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java | 191 +++++++++++++++++++++++++++++++---------------- 1 files changed, 125 insertions(+), 66 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java b/fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java index 977fb72..1b8c79f 100644 --- a/fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java +++ b/fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java @@ -1,12 +1,14 @@ package com.yeshi.fanli.job; import java.math.BigDecimal; +import java.net.URLDecoder; import java.util.ArrayList; import java.util.Date; import java.util.List; import javax.annotation.Resource; +import org.apache.commons.lang.StringEscapeUtils; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.yeshi.utils.DateUtil; @@ -16,6 +18,7 @@ import com.yeshi.fanli.dto.ConfigParamsDTO; import com.yeshi.fanli.dto.dataoke.DaTaoKeGoodsResult; import com.yeshi.fanli.dto.taobao.haodanku.HDKGoodsListResultDTO; +import com.yeshi.fanli.dto.taobao.haodanku.HDKWXCircleContentDTO; import com.yeshi.fanli.entity.bus.activity.ActivityRuleUser; import com.yeshi.fanli.entity.bus.activity.ActivityUser; import com.yeshi.fanli.entity.bus.activity.RecommendActivity; @@ -26,7 +29,6 @@ import com.yeshi.fanli.entity.goods.jd.NYouHuiGoods; import com.yeshi.fanli.entity.jd.JDGoods; import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2; -import com.yeshi.fanli.entity.taobao.haodanku.HDKGoodsDetail; import com.yeshi.fanli.exception.dynamic.GoodsEvaluateException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.activity.ActivityService; @@ -362,71 +364,6 @@ /** - * 濂藉崟搴撳晢鍝佸姞鍏ュ彂鍦� - */ - @XxlJob("dynamic-insertEvaluate") - public ReturnT<String> insertEvaluate(String param) throws Exception { - try { - boolean addGoods = false; - Integer minId = 1; - while (minId != null) { - HDKGoodsListResultDTO dto = HaoDanKuApiUtil.getInstance().listHotGoods(minId, 100, 1, null); - if (dto != null) { - minId = dto.getMinId(); - addGoods = addGoodsEvaluate(dto.getGoodsList()); - } else { - minId = null; - } - - if(addGoods) { - break; - } - } - - // 澶ф窐瀹㈠鐢� - if (!addGoods) { - DaTaoKeGoodsResult result = DaTaoKeApiUtil.getRankingList(DaTaoKeApiUtil.RANK_TYPE_TIME, null); - if (result != null) { - List<DaTaoKeDetailV2> detailList = result.getGoodsList(); - if (detailList != null && detailList.size() > 0) { - for (DaTaoKeDetailV2 daTaoKeV2: detailList) { - if(goodsEvaluateService.addByDaTaoKeGoods(daTaoKeV2)) - break; - } - } - } - } - } catch (Exception e) { - LogHelper.errorDetailInfo(e); - } - return ReturnT.SUCCESS; - } - - - private boolean addGoodsEvaluate(List<HDKGoodsDetail> hdkList) { - if (hdkList == null || hdkList.size() == 0) { - return false; - } - for (HDKGoodsDetail hdkGoods: hdkList) { - try { - Long itemid = hdkGoods.getItemid(); - String itemdesc = hdkGoods.getItemdesc(); - List<ActivityRuleUser> ruleList = activityUserService.listByRuleCode(ActivityRuleUser.RULE_HAOHUO, 1, 20); - ActivityUser user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser(); - goodsEvaluateService.addGoodsEvaluate(itemid + "", null, user, itemdesc, null, new Date()); - return true; - } catch (GoodsEvaluateException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } - } - return false; - } - - - - /** * 姣忎竴涓皬鏃堕殢鏈哄湪鍒嗕韩鏁扮殑鍩虹涓婂姞10~100銆傚鍔犵殑鏃堕棿娈垫槸姣忓ぉ8~22鐐广�� * 鏃╀笂6,7,15,16,21,22,23鐐规洿鏂�1娆� */ @@ -446,4 +383,126 @@ } } } + + + /** + * 鍟嗗搧鍔犲叆鍙戝湀 + */ + @XxlJob("dynamic-insertEvaluate") + public ReturnT<String> insertEvaluate(String param) throws Exception { + // 濂藉崟搴� + boolean addResult = addHDKListSelected(); + // 澶ф窐瀹㈠鐢� + if (!addResult) { + addDTKFriendsFircleList(); + } + return ReturnT.SUCCESS; + } + + + /** + * 濂藉崟搴撳晢鍝佸姞鍏ュ彂鍦� + * @return + */ + private boolean addHDKListSelected () { + boolean addResult = false; + Integer minId = 1; + while (minId != null) { + HDKGoodsListResultDTO dto = HaoDanKuApiUtil.getInstance().listSelected(minId); + if (dto == null) { + minId = null; + } else { + minId = dto.getMinId(); + List<HDKWXCircleContentDTO> list = dto.getList(); + if (list== null || list.size() == 0) { + continue; + } + + for (HDKWXCircleContentDTO hdkGoods: list) { + try { + String itemid = hdkGoods.getItemid(); + List<String> pics = hdkGoods.getItempic(); + String copy_content = hdkGoods.getCopy_content(); + + String showtitle = StringEscapeUtils.unescapeHtml(copy_content); + showtitle = showtitle.replace("<br>", "\r\n"); + + List<ActivityRuleUser> ruleList = activityUserService.listByRuleCode(ActivityRuleUser.RULE_HAOHUO, 1, 20); + ActivityUser user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser(); + goodsEvaluateService.addGoodsEvaluate2(itemid, pics, user, showtitle, null); + addResult = true; + break; + } catch (GoodsEvaluateException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + if(addResult) + break; + } + return addResult; + } + + + /** + * 澶ф窐瀹㈠晢鍝佸姞鍏ュ彂鍦� + * @return + */ + private boolean addDTKFriendsFircleList() { + boolean addResult = false; + try { + DaTaoKeGoodsResult result = DaTaoKeApiUtil.getFriendsFircleList("1", 100); + while (result.getGoodsList() != null && result.getGoodsList().size() > 0) { + for (DaTaoKeDetailV2 v2 : result.getGoodsList()) { + try { + Long goodsId = v2.getGoodsId(); + String circleText = v2.getCircleText(); + if (circleText == null) { + continue; + } + String showtitle = URLDecoder.decode(circleText, "UTF-8"); + showtitle = showtitle.replace(" ", " "); + + ActivityUser user = null; + if (v2.getCid() != null) { + user = activityUserService.getRandomByDaTaoKeCid(v2.getCid()); + } + if (user == null) { + List<ActivityRuleUser> ruleList = activityUserService + .listByRuleCode(ActivityRuleUser.RULE_HAOHUO, 1, 20); + user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser(); + } + goodsEvaluateService.addGoodsEvaluate2(goodsId + "", null, user, showtitle, null); + addResult = true; + break; + } catch (GoodsEvaluateException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + if (addResult) { + break; + } + + try { + result = DaTaoKeApiUtil.listAll(result.getPageId()); + } catch (Exception e) { + result = DaTaoKeApiUtil.listAll(result.getPageId()); + } + try { + Thread.sleep(10); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } + return addResult; + } + } -- Gitblit v1.8.0