| | |
| | | import org.springframework.scheduling.annotation.Scheduled;
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.taobao.api.TaobaoObject;
|
| | | import com.yeshi.fanli.entity.bus.user.Order;
|
| | | import com.yeshi.fanli.entity.taobao.PidUser;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.TaoBaoOrderException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.common.DataMonitorService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
|
| | |
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBao110Util;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeOrderApiUtil;
|
| | |
|
| | |
| | | }
|
| | |
|
| | | public void updateOrder(long startTime, long endTime) {
|
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
|
| | | List<TaoBaoOrder> orderList = new ArrayList<>();
|
| | | try {
|
| | | orderList = TaoBaoOrderUtil.getOrderList(startTime, endTime, configList.get(0));
|
| | | } catch (TaoBaoOrderException e2) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e2);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | List<TaoBaoOrder> thirdOrderList = new ArrayList<>();
|
| | | try {
|
| | | thirdOrderList = TaoBaoOrderUtil.getThirdServiceOrderList(startTime, endTime, configList.get(0));
|
| | | } catch (TaoBaoOrderException e2) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e2);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | if (thirdOrderList != null && thirdOrderList.size() > 0)
|
| | | orderList.addAll(thirdOrderList);
|
| | | // 老版本处理方式
|
| | | // List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
|
| | | // List<TaoBaoOrder> orderList = new ArrayList<>();
|
| | | // try {
|
| | | // orderList = TaoBaoOrderUtil.getOrderList(startTime, endTime, configList.get(0));
|
| | | // } catch (TaoBaoOrderException e2) {
|
| | | // try {
|
| | | // LogHelper.errorDetailInfo(e2);
|
| | | // } catch (Exception e) {
|
| | | // e.printStackTrace();
|
| | | // }
|
| | | // }
|
| | | // List<TaoBaoOrder> thirdOrderList = new ArrayList<>();
|
| | | // try {
|
| | | // thirdOrderList = TaoBaoOrderUtil.getThirdServiceOrderList(startTime, endTime, configList.get(0));
|
| | | // } catch (TaoBaoOrderException e2) {
|
| | | // try {
|
| | | // LogHelper.errorDetailInfo(e2);
|
| | | // } catch (Exception e) {
|
| | | // e.printStackTrace();
|
| | | // }
|
| | | // }
|
| | | // if (thirdOrderList != null && thirdOrderList.size() > 0)
|
| | | // orderList.addAll(thirdOrderList);
|
| | | |
| | | List<TaoBaoOrder> orderList= getCommonOrder(startTime, endTime);
|
| | | List<TaoBaoOrder> tempOrderList2=getThirdCommonOrder(startTime, endTime);
|
| | | if(tempOrderList2!=null&&tempOrderList2.size()>0)
|
| | | orderList.addAll(tempOrderList2);
|
| | | |
| | |
|
| | | LogHelper.orderInfo("正在执行订单爬取结束,共有订单:" + orderList.size());
|
| | | addOrder(orderList);
|
| | |
| | | }
|
| | |
|
| | | return orderList;
|
| | | }
|
| | |
|
| | | private void addRelationAndSpecialOrder(List<TaoBaoOrder> orderList) {
|
| | | try {
|
| | | taoBaoOrderService.addTaoBaoOrderList(orderList);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | try {
|
| | | Map<String, List<TaoBaoOrder>> map = TaoBaoOrderUtil.classifyTaoBaoOrderByOrderId(orderList);
|
| | | if (map != null) {
|
| | | Iterator<String> its = map.keySet().iterator();
|
| | | while (its.hasNext()) {
|
| | | String key = its.next();
|
| | | List<TaoBaoOrder> orders = map.get(key);
|
| | | String redisKey = "addorderqueue-" + key;
|
| | | // redis做频率限制
|
| | | try {
|
| | | if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(redisKey))) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | |
|
| | | CMQManager.getInstance().addTaoBaoOrderMsg(key, orders);
|
| | |
|
| | | try {
|
| | | // 6小时内不再处理
|
| | | redisManager.cacheCommonString(redisKey, "1", 60 * 60 * 6);
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void addOrder(List<TaoBaoOrder> orderList) {
|
| | |
| | | public void doJob6() {
|
| | | if (!Constant.IS_TASK)
|
| | | return;
|
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
|
| | | LogHelper.orderInfo("正在执行订单爬取...");
|
| | | // 爬取1分钟以前的
|
| | | long endTime = System.currentTimeMillis() - 1000 * 60 * 1L;
|
| | | List<TaoBaoOrder> orderList = new ArrayList<TaoBaoOrder>();
|
| | | try {
|
| | | orderList = TaoBaoOrderUtil.getOrderList(endTime - 1000 * 60 * 60 * 24 * 2L, endTime, configList.get(0));
|
| | | TaoBao110Util.rightTaoBaoOrderWarning();
|
| | | } catch (TaoBaoOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | TaoBao110Util.reportTaoBaoOrderWarning(e.getCode(), e.getMessage());
|
| | | } catch (Exception e2) {
|
| | | e2.printStackTrace();
|
| | | }
|
| | | }
|
| | | List<TaoBaoOrder> thirdOrderList = new ArrayList<>();
|
| | | try {
|
| | | thirdOrderList = TaoBaoOrderUtil.getThirdServiceOrderList(endTime - 1000 * 60 * 60 * 24 * 2L, endTime,
|
| | | configList.get(0));
|
| | | } catch (TaoBaoOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e2) {
|
| | | e2.printStackTrace();
|
| | | }
|
| | | }
|
| | | if (thirdOrderList != null && thirdOrderList.size() > 0)
|
| | | orderList.addAll(thirdOrderList);
|
| | | if (orderList != null && orderList.size() > 0)
|
| | | dataMonitorService.parseTaoBaoOrderSuccess();
|
| | | LogHelper.orderInfo("正在执行订单爬取结束,共有订单:" + orderList.size());
|
| | | addOrder(orderList);
|
| | | long endTime=System.currentTimeMillis();
|
| | | updateOrder(endTime-1000*60*20L, endTime);
|
| | | }
|
| | |
|
| | | // 返利
|