| | |
| | | package com.yeshi.fanli.job.order.vipshop; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.dao.mybatis.vipshop.VipShopOrderMapper; |
| | | import com.yeshi.fanli.dto.mq.order.body.CommonOrderMQMsg; |
| | | import com.yeshi.fanli.entity.order.CommonOrder; |
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.mq.cmq.order.OrdersCMQManager; |
| | | import com.yeshi.fanli.util.vipshop.DingDanXiaApiUtil; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | String result = redisManager.getCommonString(key); |
| | | // 判断 |
| | | // if (StringUtil.isNullOrEmpty(result)) { |
| | | VipShopOrderCMQManager.getInstance().addVipShopOrder(order.getOrderSn() + ""); |
| | | OrdersCMQManager.getInstance().addOrder(new CommonOrderMQMsg(order.getOrderSn() + "", Constant.SOURCE_TYPE_VIP)); |
| | | redisManager.cacheCommonString(key, "1", 60 * 60 * 2);// 2小时内不再更新 |
| | | LogHelper.test("唯品会订单消息发送成功"); |
| | | // }else{ |
| | |
| | | updateByOrderTime(endTime - 1000 * 60 * 60 * 1L, endTime); |
| | | updateByUpdateTime(endTime - 1000 * 60 * 60 * 1L, endTime); |
| | | } else if ("1day".equalsIgnoreCase(param)) {// 更新最近1天更新的数据 |
| | | updateByOrderTime(endTime - 1000 * 60 * 60 * 24L, endTime); |
| | | updateByUpdateTime(endTime - 1000 * 60 * 60 * 24L, endTime); |
| | | Long startT = endTime - 1000 * 60 * 60 * 24L; |
| | | for(long start= startT;start<startT +1000 * 60 * 60 * 24L;start+=1000 * 60 * 60 ) { |
| | | updateByOrderTime(start, start + 1000 * 60 * 60 ); |
| | | updateByUpdateTime(start, start + 1000 * 60 * 60 ); |
| | | } |
| | | } else if ("1month".equalsIgnoreCase(param)) {// 更新最近1个月的数据 |
| | | for (int i = 0; i < 30; i++) { |
| | | Long startT = endTime - 1000 * 60 * 60 * 24L*(i+1); |
| | | for(long start= startT;start<startT +1000 * 60 * 60 * 24L;start+=1000 * 60 * 60 ) { |
| | | updateByOrderTime(start, start + 1000 * 60 * 60 ); |
| | | updateByUpdateTime(start, start + 1000 * 60 * 60 ); |
| | | } |
| | | } |
| | | } |
| | | /* |
| | | * else if ("3day".equalsIgnoreCase(param)) {// 更新最近3天更新的数据 |
| | |
| | | //根据订单号更新 |
| | | @XxlJob("order-vip-updateByOrderSn") |
| | | public ReturnT<String> updateByOrderSn(String param) throws Exception { |
| | | List<VipShopOrder> orders = vipShopOrderService.listByOrderSn(param); |
| | | if (orders == null || orders.size() == 0) |
| | | throw new Exception("订单不存在"); |
| | | |
| | | VipShopOrder vipShopOrder = DingDanXiaApiUtil.getOrderDetail(param); |
| | | if (vipShopOrder != null) { |
| | | List<VipShopOrder> vipShopOrderList = new ArrayList<>(); |
| | | vipShopOrderList.add(vipShopOrder); |
| | | saveVipShopOrders(vipShopOrderList); |
| | | String[] ps = param.split(","); |
| | | for (String p : ps) { |
| | | List<VipShopOrder> orders = vipShopOrderService.listByOrderSn(p); |
| | | if (orders == null || orders.size() == 0) |
| | | throw new Exception("订单不存在"); |
| | | Thread.sleep(1000); |
| | | VipShopOrder vipShopOrder = DingDanXiaApiUtil.getOrderDetail(p); |
| | | if (vipShopOrder != null) { |
| | | List<VipShopOrder> vipShopOrderList = new ArrayList<>(); |
| | | vipShopOrderList.add(vipShopOrder); |
| | | saveVipShopOrders(vipShopOrderList); |
| | | } |
| | | } |
| | | return ReturnT.SUCCESS; |
| | | } |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Resource |
| | | private CommonOrderService commonOrderService; |
| | | |
| | | @XxlJob("order-vip-updateByLongTimeNoUpdate") |
| | | public ReturnT<String> updateByLongTimeNoUpdate(String param) throws Exception { |
| | | Date maxCreateTime = new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24L * 30); |
| | | Date minCreateTime = new Date(maxCreateTime.getTime() - 1000 * 60 * 60 * 24L * 60L); |
| | | VipShopOrderMapper.DaoQuery daoQuery = new VipShopOrderMapper.DaoQuery(); |
| | | daoQuery.orderSubStatusName = "已付款"; |
| | | daoQuery.minCreateTime = minCreateTime; |
| | | daoQuery.maxCreateTime = maxCreateTime; |
| | | long count = vipShopOrderMapper.count(daoQuery); |
| | | if (count > 0) { |
| | | daoQuery.start = 0; |
| | | daoQuery.count = (int) count; |
| | | List<VipShopOrder> orderList = vipShopOrderMapper.list(daoQuery); |
| | | for (VipShopOrder order : orderList) { |
| | | try { |
| | | updateByOrderSn(order.getOrderSn()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | List<CommonOrder> commonOrders = commonOrderService.listPayStateOrder(Constant.SOURCE_TYPE_VIP, new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24L * 60), new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24L * 10), 1, 200); |
| | | if (commonOrders == null || commonOrders.size() == 0) { |
| | | throw new Exception("没有需要更新的订单"); |
| | | } |
| | | Set<String> orderIds = new HashSet<>(); |
| | | for (CommonOrder commonOrder : commonOrders) { |
| | | orderIds.add(commonOrder.getOrderNo()); |
| | | } |
| | | for (String orderId : orderIds) { |
| | | updateByOrderSn(orderId); |
| | | } |
| | | |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | |