| | |
| | | package com.yeshi.fanli.job;
|
| | |
|
| | | 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.yeshi.fanli.entity.bus.activity.RecommendActivity;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.activity.ActivityService;
|
| | | import com.yeshi.fanli.service.inter.dynamic.DynamicInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
|
| | | @Component
|
| | | public class DynamicInfoJob {
|
| | | |
| | | @Resource
|
| | | private DynamicInfoService dynamicInfoService;
|
| | | |
| | | @Resource
|
| | | private ActivityService activityService;
|
| | | |
| | | |
| | | /**
|
| | | * 每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 0 * * ?")
|
| | | public void remove() {
|
| | | |
| | | // if (!Constant.IS_TASK) {
|
| | | // return;
|
| | | // }
|
| | | // |
| | | try {
|
| | | dynamicInfoService.removeByDate(DateUtil.reduceDay(3, 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.saveActivityRecommend(activity);
|
| | | |
| | | activity.setState(1);
|
| | | activityService.updateByPrimaryKeySelective(activity);
|
| | | |
| | | } else if (RecommendActivity.TYPE_INVITE == type) {
|
| | | // 邀请素材
|
| | | String imgUrl = null;
|
| | | List<String> imageList = activityService.getImgByActivityId(activity.getId());
|
| | | if (imageList != null && imageList.size() > 0) {
|
| | | imgUrl = imageList.get(0);
|
| | | }
|
| | | |
| | | dynamicInfoService.insertInviteMaterial(activity.getTitle(), imgUrl, activity.getId(), activity.getActivityUser());
|
| | | |
| | | activity.setState(1);
|
| | | activityService.updateByPrimaryKeySelective(activity);
|
| | | }
|
| | | }
|
| | | |
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | }
|
| | | 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(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |