From 81da61b828e29b7745e1382dfbbaeb685dc083ef Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 23 一月 2024 17:17:55 +0800 Subject: [PATCH] 抖音转链修改 --- fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java | 944 +++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 571 insertions(+), 373 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 a2810b9..6eebec6 100644 --- a/fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java +++ b/fanli/src/main/java/com/yeshi/fanli/job/DynamicInfoJob.java @@ -1,373 +1,571 @@ -package com.yeshi.fanli.job; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.annotation.Resource; - -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; -import org.yeshi.utils.DateUtil; - -import com.xxl.job.core.biz.model.ReturnT; -import com.xxl.job.core.handler.annotation.XxlJob; -import com.yeshi.fanli.dto.ConfigParamsDTO; -import com.yeshi.fanli.entity.bus.activity.RecommendActivity; -import com.yeshi.fanli.entity.bus.activity.RecommendActivityInviteInfo; -import com.yeshi.fanli.entity.dynamic.GoodsPicture; -import com.yeshi.fanli.entity.dynamic.WXMPDynamicInfo; -import com.yeshi.fanli.entity.goods.jd.NYouHuiGoods; -import com.yeshi.fanli.entity.jd.JDGoods; -import com.yeshi.fanli.log.LogHelper; -import com.yeshi.fanli.service.inter.activity.ActivityService; -import com.yeshi.fanli.service.inter.activity.ActivityUserService; -import com.yeshi.fanli.service.inter.common.JumpDetailV2Service; -import com.yeshi.fanli.service.inter.dynamic.DynamicInfoService; -import com.yeshi.fanli.service.inter.dynamic.GoodsEvaluateService; -import com.yeshi.fanli.service.inter.dynamic.WXMPDynamicInfoService; -import com.yeshi.fanli.service.inter.goods.jd.NYouHuiService; -import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; -import com.yeshi.fanli.service.manger.goods.ConvertLinkManager; -import com.yeshi.fanli.util.Constant; -import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; -import com.yeshi.fanli.util.jd.JDApiUtil; -import com.yeshi.fanli.util.jd.JDUtil; - -@Component -public class DynamicInfoJob { - - @Resource - private DynamicInfoService dynamicInfoService; - - @Resource - private ActivityService activityService; - - @Resource - private NYouHuiService nyouHuiService; - - @Resource - private ActivityUserService activityUserService; - - @Resource - private WXMPDynamicInfoService wxmpDynamicInfoService; - - @Resource - private ConvertLinkManager convertLinkManager; - - @Resource - private HongBaoManageService hongBaoManageService; - - @Resource - private JumpDetailV2Service jumpDetailV2Service; - - @Resource - private GoodsEvaluateService goodsEvaluateService; - - /** - * 姣�10鍒嗛挓 鏅氫笂00:00~06:00涓嶄笅鍙戜换浣曚竴涓晢鍝� - */ - @Scheduled(cron = "0 0/10 6-23 * * ?") - public void insetDynamicInfo() { - - if (!Constant.IS_TASK) { - return; - } - - try { - dynamicInfoService.insertTimeHotSale(); - } catch (Exception e) { - try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - - try { - dynamicInfoService.insertTimeRecommend(); - } catch (Exception e) { - try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - } - - /** - * 鏃╀笂6,7,15,16,21,22,23鐐规洿鏂�1娆� - */ - @Scheduled(cron = "0 0 6,7,15,16,21,22,23 * * ? ") - public void insetShopInfo1() { - - if (!Constant.IS_TASK) { - return; - } - - try { - dynamicInfoService.insertShopInfo(); - } catch (Exception e) { - try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - } - - /** - * 鏃╀笂8:00~10:00姣忓崐涓皬鏃舵洿鏂� - */ - @Scheduled(cron = "0 0/30 8,9,10 * * ?") - public void insetShopInfo2() { - - if (!Constant.IS_TASK) { - return; - } - - try { - dynamicInfoService.insertShopInfo(); - } catch (Exception e) { - try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - } - - /** - * 鏃╀笂11:00~14:00姣忓崐涓皬鏃舵洿鏂� - */ - @Scheduled(cron = "0 0/30 11,12,13,14 * * ?") - public void insetShopInfo3() { - - if (!Constant.IS_TASK) { - return; - } - - try { - dynamicInfoService.insertShopInfo(); - } catch (Exception e) { - try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - } - - /** - * 涓嬪崍17:00~20:00姣忓崐涓皬鏃舵洿鏂� - */ - @Scheduled(cron = "0 0/30 17,18,19,20 * * ? ") - public void insetShopInfo4() { - - if (!Constant.IS_TASK) { - return; - } - - try { - dynamicInfoService.insertShopInfo(); - } catch (Exception e) { - try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - } - - /** - * 姣忓ぉ闆剁偣鍒犻櫎3澶╀箣鍓嶆暟鎹� - */ - @Scheduled(cron = "0 0 1,10 * * ?") - public void remove() { - - if (!Constant.IS_TASK) { - return; - } - - try { - LogHelper.test("DynamicInfoJob-remove-寮�濮嬫墽琛屾��"); - dynamicInfoService.removeByDate(DateUtil.reduceDay(2, new Date())); - } catch (Exception e) { - try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - } - - /** - * 鍚庡彴缂栬緫鍔ㄦ�侊細 姣�3鍒嗛挓妫�绱� - */ - @Scheduled(cron = "0 0/3 * * * ?") - public void activityNeedPublish() { - - if (!Constant.IS_TASK) { - return; - } - - try { - List<RecommendActivity> list = activityService.getNeedPublish(); - if (list == null || list.size() == 0) { - return; - } - - for (RecommendActivity activity : list) { - Integer type = activity.getType(); - if (RecommendActivity.TYPE_SHARE_GOODS == type) { - // 鍟嗗搧鍔ㄦ�� - dynamicInfoService.insertActivityRecommend(activity); - - activity.setState(1); - activityService.updateByPrimaryKeySelective(activity); - - } else if (RecommendActivity.TYPE_INVITE == type) { - // 閭�璇风礌鏉� - RecommendActivityInviteInfo inviteInfo = activityService - .getRecommendActivityInviteInfoByActivityId(activity.getId()); - activity.setInviteInfo(inviteInfo); - - dynamicInfoService.insertInviteActivity(activity); - - activity.setState(1); - activityService.updateByPrimaryKeySelective(activity); - } - } - - } catch (Exception e) { - try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - } - - /** - * 姣忓ぉ6鐐瑰ぉ鏇存柊閭�璇风礌鏉� - */ - @Scheduled(cron = "0 0 6 * * ?") - public void insertTimeInvite() { - - if (!Constant.IS_TASK) { - return; - } - - try { - dynamicInfoService.insertTimeInvite(); - } catch (Exception e) { - try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - } - - /** - * - * @Title: demoJobHandler @Description: 鏇存柊灏忕▼搴忓姩鎬佸晢鍝� @param - * param @return @throws Exception ReturnT<String> 杩斿洖绫诲瀷 @throws - */ - @XxlJob("dynamic-updateWXMPDynamicInfo") - public ReturnT<String> updateWXMPDynamicInfoHandler(String param) throws Exception { - addJDNYHInfo(); - return ReturnT.SUCCESS; - } - - /** - * 娣诲姞鍐呬紭鎯犵浉鍏冲晢鍝� @Title: addJDNYHInfo @Description: void 杩斿洖绫诲瀷 @throws - */ - private void addJDNYHInfo() throws Exception { - - List<NYouHuiGoods> list = nyouHuiService.list(1, 1); - if (list != null && list.size() > 0) { - NYouHuiGoods goods = list.get(0); - String id = goods.toId(); - WXMPDynamicInfo info = new WXMPDynamicInfo(); - info.setId(WXMPDynamicInfo.SOURCE_NYH + "#" + id); - String desc = goods.getDesc(); - - info.setSource(WXMPDynamicInfo.SOURCE_NYH); - info.setUser(activityUserService.getRandomHaoHuo()); - // 鍋氶摼鎺ヨ浆鎹� - for (String link : goods.getLinkList()) { - desc = desc.replaceFirst("\\[閾炬帴\\]", link); - } - - desc = convertLinkManager.convertJDLinkFromText(desc, 0L, true); - info.setContent(desc); - - List<JDGoods> goodsList = JDApiUtil.queryGoodsDetail(goods.getSkuList()); - List<GoodsPicture> imgs = new ArrayList<>(); - - BigDecimal totalMoney = new BigDecimal(0); - List<String> lastPicture = new ArrayList<>(); - for (JDGoods jdGoods : goodsList) { - GoodsPicture picture = new GoodsPicture(); - BigDecimal money = JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getShareRate()); - totalMoney = totalMoney.add(money); - picture.setGoodsVO( - GoodsDetailVOFactory.convertJDGoods(jdGoods, - new ConfigParamsDTO(hongBaoManageService.getFanLiRate(), - hongBaoManageService.getShareRate(), null, - hongBaoManageService.getVIPFanLiRate()))); - picture.setGoodState(0); - picture.setJumpDetail(jumpDetailV2Service.getByTypeCache("goodsdetail")); - picture.setParams(null); - picture.setUrl(jdGoods.getPicUrl()); - imgs.add(picture); - if (jdGoods.getImageList() != null) - if (jdGoods.getImageList().size() > 4) - lastPicture.addAll(jdGoods.getImageList().subList(1, 4)); - else if (jdGoods.getImageList().size() > 1) - lastPicture.addAll(jdGoods.getImageList().subList(1, jdGoods.getImageList().size())); - } - info.setShareMoney(totalMoney); - int count = 0; - while (imgs.size() < 4 && count < 4) { - count++; - String picurl = lastPicture.get((int) (lastPicture.size() * Math.random())); - if (picurl != null) { - lastPicture.remove(picurl); - GoodsPicture picture = new GoodsPicture(); - picture.setUrl(picurl); - imgs.add(picture); - } - } - - info.setImgs(imgs); - - wxmpDynamicInfoService.addWXMPDynamicInfo(info); - } - } - - /** - * 鍔ㄦ�佸彂鍦� - * - * @param param - * @return - * @throws Exception - */ - // @Scheduled(cron = "0 0 6,7,15,16,21,22,23 * * ? ") - @XxlJob("dynamic-insertEvaluate") - public ReturnT<String> insertEvaluate(String param) throws Exception { - try { - goodsEvaluateService.addGoodsEvaluateByDaTaoKe(); - } catch (Exception e) { - try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - return ReturnT.SUCCESS; - } - -} +package com.yeshi.fanli.job; + +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.handler.annotation.XxlJob; +import com.yeshi.fanli.dto.GoodsMoneyConfigParamsDTO; +import com.yeshi.fanli.entity.SystemEnum; +import com.yeshi.fanli.entity.SystemFunction; +import com.yeshi.fanli.entity.bus.activity.ActivityRuleUser; +import com.yeshi.fanli.entity.bus.activity.ActivityUser; +import com.yeshi.fanli.entity.bus.activity.RecommendActivity; +import com.yeshi.fanli.entity.bus.activity.RecommendActivityInviteInfo; +import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; +import com.yeshi.fanli.entity.dynamic.GoodsPicture; +import com.yeshi.fanli.entity.dynamic.WXMPDynamicInfo; +import com.yeshi.fanli.entity.goods.jd.NYouHuiGoods; +import com.yeshi.fanli.entity.jd.JDGoods; +import com.yeshi.fanli.exception.dynamic.GoodsEvaluateException; +import com.yeshi.fanli.log.LogHelper; +import com.yeshi.fanli.service.inter.activity.ActivityService; +import com.yeshi.fanli.service.inter.activity.ActivityUserService; +import com.yeshi.fanli.service.inter.common.JumpDetailV2Service; +import com.yeshi.fanli.service.inter.dynamic.DynamicInfoService; +import com.yeshi.fanli.service.inter.dynamic.GoodsEvaluateService; +import com.yeshi.fanli.service.inter.dynamic.WXMPDynamicInfoService; +import com.yeshi.fanli.service.inter.goods.jd.NYouHuiService; +import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; +import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; +import com.yeshi.fanli.service.manger.goods.ConvertLinkManager; +import com.yeshi.fanli.util.Constant; +import com.yeshi.fanli.util.SystemInfoUtil; +import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; +import com.yeshi.fanli.util.factory.goods.TaoBaoGoodsFactory; +import com.yeshi.fanli.util.jd.JDApiUtil; +import com.yeshi.fanli.util.jd.JDUtil; +import com.yeshi.fanli.util.taobao.TaoBaoUtil; +import com.yeshi.goods.facade.dto.taobao.dataoke.DaTaoKeGoodsResult; +import com.yeshi.goods.facade.dto.taobao.dataoke.DaTaoKeListTopOffDTO; +import com.yeshi.goods.facade.dto.taobao.dataoke.DaTaoKeResult; +import com.yeshi.goods.facade.dto.taobao.haodanku.HDKGoodsListResultDTO; +import com.yeshi.goods.facade.dto.taobao.haodanku.HDKWXCircleContentDTO; +import com.yeshi.goods.facade.entity.taobao.dataoke.DaTaoKeDetailV2; +import com.yeshi.goods.facade.entity.taobao.haodanku.HDKGoodsDetail; +import com.yeshi.goods.facade.utils.taobao.DaTaoKeApiUtil; +import com.yeshi.goods.facade.utils.taobao.HaoDanKuApiUtil; +import org.apache.commons.lang.StringEscapeUtils; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import org.yeshi.utils.DateUtil; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.net.URLDecoder; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@Component +public class DynamicInfoJob { + + @Resource + private DynamicInfoService dynamicInfoService; + + @Resource + private ActivityService activityService; + + @Resource + private NYouHuiService nyouHuiService; + + @Resource + private ActivityUserService activityUserService; + + @Resource + private WXMPDynamicInfoService wxmpDynamicInfoService; + + @Resource + private ConvertLinkManager convertLinkManager; + + @Resource + private HongBaoManageService hongBaoManageService; + + @Resource + private JumpDetailV2Service jumpDetailV2Service; + + @Resource + private GoodsEvaluateService goodsEvaluateService; + + @Resource + private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; + + /** + * 姣�10鍒嗛挓 鏅氫笂00:00~06:00涓嶄笅鍙戜换浣曚竴涓晢鍝� + */ + @Scheduled(cron = "0 0/10 6-23 * * ?") + public void insetDynamicInfo() { + + if (!Constant.IS_TASK) { + return; + } + + try { + dynamicInfoService.insertTimeHotSale(); + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + + try { + dynamicInfoService.insertTimeRecommend(); + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + + /** + * 鏃╀笂6,7,15,16,21,22,23鐐规洿鏂�1娆� + */ + @Scheduled(cron = "0 0 6,7,15,16,21,22,23 * * ? ") + public void insetShopInfo1() { + + if (!Constant.IS_TASK) { + return; + } + + try { + dynamicInfoService.insertShopInfo(); + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + + /** + * 鏃╀笂8:00~10:00姣忓崐涓皬鏃舵洿鏂� + */ + @Scheduled(cron = "0 0/30 8,9,10 * * ?") + public void insetShopInfo2() { + + if (!Constant.IS_TASK) { + return; + } + + try { + dynamicInfoService.insertShopInfo(); + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + + /** + * 鏃╀笂11:00~14:00姣忓崐涓皬鏃舵洿鏂� + */ + @Scheduled(cron = "0 0/30 11,12,13,14 * * ?") + public void insetShopInfo3() { + + if (!Constant.IS_TASK) { + return; + } + + try { + dynamicInfoService.insertShopInfo(); + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + + /** + * 涓嬪崍17:00~20:00姣忓崐涓皬鏃舵洿鏂� + */ + @Scheduled(cron = "0 0/30 17,18,19,20 * * ? ") + public void insetShopInfo4() { + + if (!Constant.IS_TASK) { + return; + } + + try { + dynamicInfoService.insertShopInfo(); + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + + /** + * 姣忓ぉ闆剁偣鍒犻櫎3澶╀箣鍓嶆暟鎹� + */ + @Scheduled(cron = "0 0 1,10 * * ?") + public void remove() { + + if (!Constant.IS_TASK) { + return; + } + + try { + LogHelper.test("DynamicInfoJob-remove-寮�濮嬫墽琛屾��"); + dynamicInfoService.removeByDate(DateUtil.reduceDay(2, new Date())); + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + + /** + * 鍚庡彴缂栬緫鍔ㄦ�侊細 姣�3鍒嗛挓妫�绱� + */ + @Scheduled(cron = "0 0/3 * * * ?") + public void activityNeedPublish() { + if (!Constant.IS_TASK) { + return; + } + + try { + List<RecommendActivity> list = activityService.getNeedPublish(); + if (list == null || list.size() == 0) { + return; + } + + for (RecommendActivity activity : list) { + Integer type = activity.getType(); + if (RecommendActivity.TYPE_SHARE_GOODS == type) { + // 鍟嗗搧鍔ㄦ�� + dynamicInfoService.insertActivityRecommend(activity); + + activity.setState(1); + activityService.updateByPrimaryKeySelective(activity); + + } else if (RecommendActivity.TYPE_INVITE == type) { + // 閭�璇风礌鏉� + RecommendActivityInviteInfo inviteInfo = activityService + .getRecommendActivityInviteInfoByActivityId(activity.getId()); + activity.setInviteInfo(inviteInfo); + + dynamicInfoService.insertInviteActivity(activity); + + activity.setState(1); + activityService.updateByPrimaryKeySelective(activity); + } + } + + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + + /** + * 姣忓ぉ6鐐瑰ぉ鏇存柊閭�璇风礌鏉� + */ + @Scheduled(cron = "0 0 6 * * ?") + public void insertTimeInvite() { + if (!Constant.IS_TASK) { + return; + } + + try { + dynamicInfoService.insertTimeInvite(); + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + + /** + * @Title: demoJobHandler @Description: 鏇存柊灏忕▼搴忓姩鎬佸晢鍝� @param + * param @return @throws Exception ReturnT<String> 杩斿洖绫诲瀷 @throws + */ + @XxlJob("dynamic-updateWXMPDynamicInfo") + public ReturnT<String> updateWXMPDynamicInfoHandler(String param) throws Exception { + addJDNYHInfo(); + return ReturnT.SUCCESS; + } + + /** + * 娣诲姞鍐呬紭鎯犵浉鍏冲晢鍝� @Title: addJDNYHInfo @Description: void 杩斿洖绫诲瀷 @throws + */ + private void addJDNYHInfo() throws Exception { + + List<NYouHuiGoods> list = nyouHuiService.list(1, 1); + if (list != null && list.size() > 0) { + NYouHuiGoods goods = list.get(0); + String id = goods.toId(); + WXMPDynamicInfo info = new WXMPDynamicInfo(); + info.setId(WXMPDynamicInfo.SOURCE_NYH + "#" + id); + String desc = goods.getDesc(); + + info.setSource(WXMPDynamicInfo.SOURCE_NYH); + info.setUser(activityUserService.getRandomHaoHuo()); + // 鍋氶摼鎺ヨ浆鎹� + for (String link : goods.getLinkList()) { + desc = desc.replaceFirst("\\[閾炬帴\\]", link); + } + + desc = convertLinkManager.convertJDLinkFromText(SystemEnum.blks, desc, 0L, true, false); + info.setContent(desc); + + List<JDGoods> goodsList = JDApiUtil.queryGoodsDetail(goods.getSkuList()); + List<GoodsPicture> imgs = new ArrayList<>(); + + BigDecimal totalMoney = new BigDecimal(0); + List<String> lastPicture = new ArrayList<>(); + for (JDGoods jdGoods : goodsList) { + GoodsPicture picture = new GoodsPicture(); + BigDecimal money = JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getShareRate(SystemEnum.blks)); + totalMoney = totalMoney.add(money); + picture.setGoodsVO( + GoodsDetailVOFactory.convertJDGoods(jdGoods, + new GoodsMoneyConfigParamsDTO(hongBaoManageService.getFanLiRate(SystemEnum.blks), + hongBaoManageService.getShareRate(SystemEnum.blks), null, + hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP, SystemEnum.blks)))); + picture.setGoodState(0); + picture.setJumpDetail(jumpDetailV2Service.getByTypeCache("goodsdetail",SystemEnum.blks)); + picture.setParams(null); + picture.setUrl(jdGoods.getPicUrl()); + imgs.add(picture); + if (jdGoods.getImageList() != null) + if (jdGoods.getImageList().size() > 4) + lastPicture.addAll(jdGoods.getImageList().subList(1, 4)); + else if (jdGoods.getImageList().size() > 1) + lastPicture.addAll(jdGoods.getImageList().subList(1, jdGoods.getImageList().size())); + } + info.setShareMoney(totalMoney); + int count = 0; + while (imgs.size() < 4 && count < 4) { + count++; + String picurl = lastPicture.get((int) (lastPicture.size() * Math.random())); + if (picurl != null) { + lastPicture.remove(picurl); + GoodsPicture picture = new GoodsPicture(); + picture.setUrl(picurl); + imgs.add(picture); + } + } + + info.setImgs(imgs); + + wxmpDynamicInfoService.addWXMPDynamicInfo(info); + } + } + + + /** + * 姣忎竴涓皬鏃堕殢鏈哄湪鍒嗕韩鏁扮殑鍩虹涓婂姞10~100銆傚鍔犵殑鏃堕棿娈垫槸姣忓ぉ8~22鐐广�� + * 鏃╀笂6,7,15,16,21,22,23鐐规洿鏂�1娆� + */ + @Scheduled(cron = "0 0 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 * * ? ") + public void addRanDomShareCount() { + if (!Constant.IS_TASK) { + return; + } + + try { + for (SystemEnum system : SystemEnum.values()) + goodsEvaluateService.addRanDomShareCount(system); + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + + + /** + * 鍟嗗搧鍔犲叆鍙戝湀 + */ + @XxlJob("dynamic-insertEvaluate") + public ReturnT<String> insertEvaluate(String param) throws Exception { + + for (SystemEnum system : SystemEnum.values()) { + if (!SystemInfoUtil.hasFunctions(system, SystemFunction.faQuan)) + continue; + if(system!=SystemEnum.blks) + continue; + // 濂藉崟搴� + boolean addResult = false;//addHDKListSelected(system); + // 澶ф窐瀹㈠鐢� + if (!addResult) { + addDTKFriendsFircleList(system); + } + } + return ReturnT.SUCCESS; + } + + + /** + * 濂藉崟搴撳晢鍝佸姞鍏ュ彂鍦� + * + * @return + */ + private boolean addHDKListSelected(SystemEnum system) { + 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 circleContentDTO : list) { + try { + String itemid = circleContentDTO.getItemid(); + HDKGoodsDetail hdkGoods = HaoDanKuApiUtil.getInstance().getItemDetail(itemid); + if (hdkGoods == null) { + continue; + } + + List<String> pics = circleContentDTO.getItempic(); + String copy_content = circleContentDTO.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(); + + int addProcess = goodsEvaluateService.addGoodsEvaluate(TaoBaoGoodsFactory.create(hdkGoods), pics, user, showtitle, system); + if (addProcess == 0) { + addResult = true; + break; + } + } catch (GoodsEvaluateException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + if (addResult) + break; + } + return addResult; + } + + + /** + * 澶ф窐瀹㈠晢鍝佸姞鍏ュ彂鍦� + * + * @return + */ + private boolean addDTKFriendsFircleList(SystemEnum system) { + boolean addResult = false; + try { + DaTaoKeGoodsResult result = DaTaoKeApiUtil.getFriendsFircleList("1", 100); + while (result.getGoodsList() != null && result.getGoodsList().size() > 0) { + for (DaTaoKeDetailV2 detailV2 : result.getGoodsList()) { + try { + String goodsId = detailV2.getGoodsId(); + + String circleText = detailV2.getCircleText(); + if (circleText == null) { + continue; + } + String showtitle = URLDecoder.decode(circleText, "UTF-8"); + showtitle = showtitle.replace(" ", " "); + + DaTaoKeDetailV2 tkGoods = DaTaoKeApiUtil.getGoodsDetailByGoodsId(goodsId); + if (tkGoods == null) { + continue; + } + + ActivityUser user = null; + if (detailV2.getCid() != null) { + user = activityUserService.getRandomByDaTaoKeCid(detailV2.getCid()); + } + if (user == null) { + List<ActivityRuleUser> ruleList = activityUserService + .listByRuleCode(ActivityRuleUser.RULE_HAOHUO, 1, 20); + user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser(); + } + + int addProcess = goodsEvaluateService.addGoodsEvaluate(TaoBaoUtil.convert(tkGoods), null, user, showtitle, system); + if (addProcess == 0) { + addResult = true; + break; + } + } catch (GoodsEvaluateException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + if (addResult) { + break; + } + + try { + result = DaTaoKeApiUtil.getFriendsFircleList(result.getPageId(), 100); + } catch (Exception e) { + result = DaTaoKeApiUtil.getFriendsFircleList(result.getPageId(), 100); + } + try { + Thread.sleep(10); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } + return addResult; + } + + + @XxlJob("dynamic-tejia-updateBetterGoods") + public ReturnT<String> updateTejiaBetterGoods(String param) throws Exception { + addDTKTipOffList(SystemEnum.yhqjx); + addDTKTipOffList(SystemEnum.hsb); + return ReturnT.SUCCESS; + } + + /** + * 澶ф窐瀹㈢嚎鎶� + * + * @param system + * @return + */ + private void addDTKTipOffList(SystemEnum system) { + DaTaoKeResult result = DaTaoKeApiUtil.listTipOff(null, null, 50); + if (result != null) { + List<DaTaoKeListTopOffDTO> list = (List<DaTaoKeListTopOffDTO>) result.getList(); + for (int i = list.size() - 1; i >= 0; i--) { + try { + DaTaoKeListTopOffDTO dto = list.get(i); + List<ActivityRuleUser> ruleList = activityUserService + .listByRuleCode(ActivityRuleUser.RULE_HAOHUO, 1, 20); + ActivityUser user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser(); + goodsEvaluateService.addGoodsEvaluate(dto, user, system); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + +} -- Gitblit v1.8.0