コード例 #1
0
        protected override void Execute(object state)
        {
            var model = state as MallOrderLateReceiveModel;

            if (null == model)
            {
                return;
            }

            try
            {
                //从备份区将备份删除
                DeleteBackAfterDone(model.OrderID);

                var lastOrder = MallOrderProvider.GetOrder(model.OrderID);

                if (null == lastOrder)
                {
                    throw new CustomException(string.Format("〖精品汇订单(ID:{0})〗信息已不存在!", model.OrderID));
                }

                if (lastOrder.OrderStatus != (int)B2COrderStatus.WaitingReceipt)
                {
                    throw new CustomException(string.Format("〖精品汇订单(ID:{0})〗状态已发生变更,不能自动完成收货!", lastOrder.OrderID));
                }

                if (model.ShipTime != model.ShipTime)
                {
                    throw new CustomException(string.Format("〖精品汇订单(ID:{0})〗不能确定发货时间,不能自动完成收货!", lastOrder.OrderID));
                }

                //结算并自动收货
                var settlement = new MallOrderSettlementCenter(model.OrderID, true);
                settlement.Execute();

                string message = string.Empty;

                if (settlement.Success)
                {
                    message = string.Format("〖精品汇订单(ID:{0}/{1})〗自动确认收货完成!", lastOrder.OrderID, lastOrder.ProductInfo);
                }
                else
                {
                    message = string.Format("〖精品汇订单(ID:{0}/{1})〗自动确认收货失败,原因:{2}", lastOrder.OrderID, lastOrder.ProductInfo, settlement.ErrorMessage);
                }

                RunLogger(message);
            }
            catch (Exception ex)
            {
                this.OnThrowException(ex);
            }
            finally
            {
                Schedulers.Remove(model.OrderID);
            }
        }
コード例 #2
0
        protected override void Execute(object state)
        {
            var model = state as MallOrderNoPaymentModel;

            if (null == model)
            {
                return;
            }

            try
            {
                //从备份区将备份删除
                DeleteBackAfterDone(model.OrderID);

                var lastOrder = MallOrderProvider.GetOrder(model.OrderID);

                if (null == lastOrder)
                {
                    throw new CustomException(string.Format("〖精品汇订单(ID:{0})〗信息已不存在!", model.OrderID));
                }

                if (lastOrder.OrderStatus != (int)B2COrderStatus.WaitingPayment)
                {
                    throw new CustomException(string.Format("〖精品汇订单(ID:{0})〗状态发生变更,不能自动取消订单", lastOrder.OrderID));
                }

                //自动取消订单
                bool cancelSuccess = MallOrderProvider.AutoCancelOrder(lastOrder.OrderID).Result;

                string message = string.Empty;

                if (cancelSuccess)
                {
                    message = string.Format("〖精品汇订单(ID:{0}/{1})〗因超时未付款,系统已自动取消订单!", lastOrder.OrderID, lastOrder.ProductInfo);
                }
                else
                {
                    message = string.Format("〖精品汇订单(ID:{0}/{1})〗因超时未付款,系统自动取消订单时操作失败!", lastOrder.OrderID, lastOrder.ProductInfo);
                }

                RunLogger(message);
            }
            catch (Exception ex)
            {
                this.OnThrowException(ex);
            }
            finally
            {
                Schedulers.Remove(model.OrderID);
            }
        }