Пример #1
0
        public void NotifyPaid(OPC_Sale saleOrder, bool enbaleCashingTimeRange, TimeSpan bein, TimeSpan end)
        {
            if (enbaleCashingTimeRange && !IsInCashingTimeRange(bein, end))
            {
                return;
            }
            Logger.InfoFormat("Notify paid to it sale order no:{0}", saleOrder.SaleOrderNo);
            var apiClient = new DefaultApiClient();
            var rsp       = apiClient.Post(new OrderNotifyRequest()
            {
                Data = new PaidOrderNotificationEntity(saleOrder).CreateNotifiedEntity()
            }, true);

            if (rsp == null)
            {
                NotifyFailed(saleOrder, SaleOrderNotificationStatus.PaidFailed, apiClient.ErrorList());
                return;
            }
            if (!rsp.Status)
            {
                Logger.Error(rsp.Data);
                Logger.Error(rsp.Message);
                var errors = new List <string> {
                    rsp.Data, rsp.Message
                };
                errors.AddRange(apiClient.ErrorList().Where(x => !string.IsNullOrEmpty(x)));
                NotifyFailed(saleOrder, SaleOrderNotificationStatus.PaidFailed, errors);
                return;
            }
            SaleOrderNotified(saleOrder, SaleOrderNotificationStatus.Paid);
        }
Пример #2
0
        public void NotifyCreate(OPC_Sale saleOrder)
        {
            var entity    = new CreateOrderNotificationEntity(saleOrder).CreateNotifiedEntity();
            var apiClient = new DefaultApiClient();

            try
            {
                var rsp = apiClient.Post(new OrderNotifyRequest()
                {
                    Data = entity
                }, true);
                if (rsp == null)
                {
                    Logger.Error("通知订单失败,信息部返回NULL");
                    NotifyFailed(saleOrder, SaleOrderNotificationStatus.CreateFailed, apiClient.ErrorList());
                    return;
                }
                if (!rsp.Status)
                {
                    Logger.Error(rsp.Data);
                    Logger.Error(rsp.Message);
                    var errors = new List <string> {
                        rsp.Data, rsp.Message
                    };
                    errors.AddRange(apiClient.ErrorList().Where(x => !string.IsNullOrEmpty(x)));
                    NotifyFailed(saleOrder, SaleOrderNotificationStatus.CreateFailed, errors);
                    return;
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                NotifyFailed(saleOrder, SaleOrderNotificationStatus.ExceptionThrow, new[] { e.Message });
                return;
            }

            SaleOrderNotified(saleOrder, SaleOrderNotificationStatus.Create);
        }