private void DoJob()
        {
            var data = DalGroupBuying.GetExpiredUserList();

            if (data.Any())
            {
                using (var client = new OrderApiForCClient())
                {
                    foreach (var item in data)
                    {
                        var OrderData = client.FetchOrderByOrderId(item.OrderId);
                        var result    = OrderData.Success && OrderData.Result.Status == "7Canceled";
                        if (!result)
                        {
                            result = CancelPinTuanOrder(item.UserId, item.OrderId);
                        }
                        //if (result)
                        //{
                        //    var ChangeResult = DalGroupBuying.ChangeUserOrderStatus(item.OrderId);
                        //    if (ChangeResult == 0)
                        //    {
                        //        Logger.Warn($"修改拼团用户状态为订单取消失败/{item.OrderId}");
                        //    }
                        //}
                        if (!result)
                        {
                            Logger.Warn($"取消未付款订单{item.OrderId}失败");
                        }
                    }
                }
            }
        }
예제 #2
0
        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}失败");
                            }
                        }
                    }
            }
        }