| | |
| | | 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;
|
| | |
| | | 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.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;
|
| | | 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.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;
|
| | | import com.yeshi.fanli.service.inter.activity.ActivityUserService;
|
| | |
| | | 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.dataoke.DaTaoKeApiUtil;
|
| | | 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.HaoDanKuApiUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
|
| | | @Component
|
| | | public class DynamicInfoJob {
|
| | |
| | |
|
| | | @Resource
|
| | | private GoodsEvaluateService goodsEvaluateService;
|
| | | |
| | | @Resource
|
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
|
| | |
|
| | | /**
|
| | | * 每10分钟 晚上00:00~06:00不下发任何一个商品
|
| | |
| | | */
|
| | | @Scheduled(cron = "0 0/3 * * * ?")
|
| | | public void activityNeedPublish() {
|
| | |
|
| | | if (!Constant.IS_TASK) {
|
| | | return;
|
| | | }
|
| | |
| | | */
|
| | | @Scheduled(cron = "0 0 6 * * ?")
|
| | | public void insertTimeInvite() {
|
| | |
|
| | | if (!Constant.IS_TASK) {
|
| | | return;
|
| | | }
|
| | |
| | | GoodsDetailVOFactory.convertJDGoods(jdGoods,
|
| | | new ConfigParamsDTO(hongBaoManageService.getFanLiRate(),
|
| | | hongBaoManageService.getShareRate(), null,
|
| | | hongBaoManageService.getVIPFanLiRate())));
|
| | | hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP))));
|
| | | picture.setGoodState(0);
|
| | | picture.setJumpDetail(jumpDetailV2Service.getByTypeCache("goodsdetail"));
|
| | | picture.setParams(null);
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 动态发圈
|
| | | * |
| | | * @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;
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 每一个小时随机在分享数的基础上加10~100。增加的时间段是每天8~22点。
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 商品加入发圈
|
| | | */
|
| | | @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 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);
|
| | | 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() {
|
| | | boolean addResult = false;
|
| | | try {
|
| | | DaTaoKeGoodsResult result = DaTaoKeApiUtil.getFriendsFircleList("1", 100);
|
| | | while (result.getGoodsList() != null && result.getGoodsList().size() > 0) {
|
| | | for (DaTaoKeDetailV2 detailV2 : result.getGoodsList()) {
|
| | | try {
|
| | | Long 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);
|
| | | 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;
|
| | | }
|
| | | |
| | | }
|