| | |
| | | package com.yeshi.fanli.job.order.vipshop; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.dao.mybatis.vipshop.VipShopOrderMapper; |
| | | 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.vipshop.DingDanXiaApiUtil; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.xxl.job.core.biz.model.ReturnT; |
| | |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | @Resource |
| | | private VipShopOrderMapper vipShopOrderMapper; |
| | | |
| | | /** |
| | | * 保存订单 |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | //根据订单号更新 |
| | | @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("订单不存在"); |
| | | 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; |
| | | } |
| | | |
| | | VipShopQueryOrderResultDTO result = VipShopApiUtil |
| | | .getOrderList(VipShopOrderQueryModel.createOrderTime(orders.get(0).getOrderTime(), orders.get(0).getOrderTime() + 1000, null, 1)); |
| | | saveVipShopOrders(result.getOrderList()); |
| | | |
| | | /** |
| | | * 更新长时间未更新的订单号 |
| | | * |
| | | * @param param |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Resource |
| | | private CommonOrderService commonOrderService; |
| | | |
| | | @XxlJob("order-vip-updateByLongTimeNoUpdate") |
| | | public ReturnT<String> updateByLongTimeNoUpdate(String param) throws Exception { |
| | | |
| | | List<CommonOrder> commonOrders = commonOrderService.listPayStateOrder(Constant.SOURCE_TYPE_VIP, null, new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24L * 10)); |
| | | 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; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | saveVipShopOrders(vipShopOrderList); |
| | | |
| | | //订单侠的接口 |
| | | page = 1; |
| | | result = DingDanXiaApiUtil |
| | | .getOrderList(VipShopOrderQueryModel.createOrderTime(startTime, endTime, null, page)); |
| | | |
| | | while (result != null && result.getOrderList().size() > 0) { |
| | | page++; |
| | | vipShopOrderList.addAll(result.getOrderList()); |
| | | result = DingDanXiaApiUtil |
| | | .getOrderList(VipShopOrderQueryModel.createOrderTime(startTime, endTime, null, page)); |
| | | } |
| | | |
| | | saveVipShopOrders(vipShopOrderList); |
| | | } |
| | | |
| | | /** |