private void DoJob() { // 获取超时的订单 var data = DalGroupBuying.GetExpiredUserList(); if (data.Any()) { using (var client = new OrderApiForCClient()) using (var clientPinTuna = new PinTuanClient()) { foreach (var item in data) { var OrderData = client.FetchOrderByOrderId(item.OrderId); var result = OrderData.Success && OrderData.Result?.Status == "7Canceled"; if (!result && OrderData.Result != null) { //判断状态能不能取消 if (new[] { "0NewPingTuan", "0New" }.Contains(OrderData.Result.Status)) { result = CancelPinTuanOrder(item.UserId, item.OrderId); } else { result = true; //调用补足服务,订单已取消 ,拼团状态未改变 clientPinTuna.RepairPinTuanOrderStatus(new List <int> { item.OrderId }); } Logger.Info($"当前订单:{item.OrderId} {OrderData.Result.Status} "); } //if (result) //{ // var ChangeResult = DalGroupBuying.ChangeUserOrderStatus(item.OrderId); // if (ChangeResult == 0) // { // Logger.Warn($"修改拼团用户状态为订单取消失败/{item.OrderId}"); // } //} if (!result) { Logger.Warn($"取消未付款订单{item.OrderId}失败"); } } } } }
public void DoJob() { var orderList = (DalGroupBuying.GetPinTuanOrderList()).Distinct()?.ToList() ?? new List <int>(); if (orderList.Any()) { Logger.Warn($"查出{orderList.Count}个异常订单待补偿-->{string.Join("/", orderList)}"); using (var client = new PinTuanClient()) { var result = client.RepairPinTuanOrderStatus(orderList); if (result.Success && !string.IsNullOrWhiteSpace(result.Result.Info)) { Logger.Info(result.Result.Info); Email(result.Result.Info); } else { Logger.Error($"拼团异常订单处理失败-->{string.Join("/", orderList)}"); } } } }