示例#1
0
        /// <summary>
        /// 创建财务负收款并作废订单
        /// </summary>
        /// <param name="refundInfo"></param>
        /// <returns></returns>
        public void CreateAOAndAbandonSO(SOIncomeRefundInfo refundInfo)
        {
            IsOutStockOrder = false;
            if (CurrentSO.BaseInfo.Status == SOStatus.CustomsPass)
            {
                IsOutStockOrder = true;
            }
            if (CurrentSO.BaseInfo.Status != SOStatus.Origin &&
                CurrentSO.BaseInfo.Status != SOStatus.WaitingOutStock
                //&& CurrentSO.BaseInfo.Status != SOStatus.OutStock
                )
            {
                BizExceptionHelper.Throw("SO_CreateAO_SOStatusIsError");
            }

            if (CurrentSOIncome == null)
            {
                BizExceptionHelper.Throw("SO_CreateAO_SOIncomeIsNull");
            }

            SOIncomeInfo soIncomeInfo = new SOIncomeInfo
            {
                OrderAmt       = -CurrentSOIncome.OrderAmt,
                OrderType      = SOIncomeOrderType.AO,
                Note           = ResourceHelper.Get("Res_SO_Abandon_CreateAO"),
                ReferenceID    = "",
                Status         = SOIncomeStatus.Origin,
                OrderSysNo     = CurrentSO.SysNo,
                IncomeAmt      = -(CurrentSOIncome.OrderAmt - CurrentSOIncome.PrepayAmt - CurrentSOIncome.GiftCardPayAmt),
                PayAmount      = -(CurrentSOIncome.OrderAmt - CurrentSOIncome.PrepayAmt - CurrentSOIncome.GiftCardPayAmt),
                IncomeStyle    = CurrentSOIncome.IncomeStyle,
                PrepayAmt      = -CurrentSOIncome.PrepayAmt,
                GiftCardPayAmt = -CurrentSOIncome.GiftCardPayAmt,
                PointPay       = -CurrentSOIncome.PointPay,
                CompanyCode    = CurrentSO.CompanyCode
            };

            SOIncomeRefundInfo soIncomeRefundInfo = new SOIncomeRefundInfo
            {
                OrderSysNo     = refundInfo.SOSysNo,
                OrderType      = RefundOrderType.AO,
                SOSysNo        = refundInfo.SOSysNo,
                RefundPayType  = refundInfo.RefundPayType,
                BankName       = refundInfo.BankName,
                BranchBankName = refundInfo.BranchBankName,
                CardNumber     = refundInfo.CardNumber,
                CardOwnerName  = refundInfo.CardOwnerName,
                PostAddress    = refundInfo.PostAddress,
                PostCode       = refundInfo.PostCode,
                ReceiverName   = refundInfo.ReceiverName,
                Note           = refundInfo.Note,
                HaveAutoRMA    = false,
                RefundPoint    = 0,
                RefundReason   = refundInfo.RefundReason,
                CompanyCode    = CurrentSO.CompanyCode
            };

            if (refundInfo.RefundPayType == RefundPayType.CashRefund)
            {
                soIncomeRefundInfo.Status = RefundStatus.Audit;
            }
            else
            {
                soIncomeRefundInfo.Status = RefundStatus.Origin;
            }
            if (refundInfo.RefundPayType == RefundPayType.TransferPointRefund)
            {
                soIncomeInfo.IncomeAmt            = 0;
                soIncomeRefundInfo.RefundCashAmt  = 0;
                soIncomeRefundInfo.RefundPoint    = Convert.ToInt32(Decimal.Round(CurrentSO.BaseInfo.SOAmount.Value * ExternalDomainBroker.GetPointToMoneyRatio(), 0));
                soIncomeRefundInfo.RefundGiftCard = CurrentSOIncome.GiftCardPayAmt;
            }
            else
            {
                soIncomeRefundInfo.RefundCashAmt  = CurrentSOIncome.OrderAmt - CurrentSOIncome.GiftCardPayAmt;
                soIncomeRefundInfo.RefundGiftCard = CurrentSOIncome.GiftCardPayAmt;
            }

            ValidateAbandonSO(false);

            bool isHold = CurrentSO.BaseInfo.HoldStatus == SOHoldStatus.BackHold;

            if (IsOutStockOrder)
            {
                isHold = true;
            }
            //如果后台锁定
            if (!isHold)
            {
                isHold = Holder.Hold(SOHolder.SOHoldReason.AbandonOrder, OPCCallBackType.AOAbandonCallBack);
                if (!isHold)
                {
                    BizExceptionHelper.Throw("SO_Abandon_HoldIsAsyn");
                }
            }
            if (isHold) //如果订单已经锁定
            {
                CreateAOAndAbandonSO(soIncomeInfo, soIncomeRefundInfo);
                if (IsOutStockOrder)
                {
                    SODA.UpdateSOStatusToReportedFailure(CurrentSO.SysNo.Value);
                    CurrentSO.BaseInfo.Status = SOStatus.Reject;
                }
                SendMessage();
            }
        }
示例#2
0
        /// <summary>
        /// 作废订单
        /// </summary>
        /// <param name="OperatorType">作废订单的用户类型</param>
        /// <param name="IsImmediatelyReturnStock">是否立即将订单中商品的库存返回给仓库,true表示是立即返回,false表示不是</param>
        public virtual void Abandon()
        {
            //  1.  判断订单是否被前台锁定,锁定后不能作废
            Holder.CheckSOIsWebHold();

            //  2.  订单作废检查,检查是否有有效收款,积分使用,余额使用,优惠券使用,账期支付等
            try
            {
                ValidateAbandonSO(true);
            }
            catch (BizException bizex)
            {
                if (CurrentSO.BaseInfo.HoldStatus == SOHoldStatus.BackHold)
                {
                    throw bizex;
                }
                CurrentSO.BaseInfo.HoldReason = ResourceHelper.Get("Res_SO_Abandon_Hold");

                Holder.Hold(ECCentral.Service.SO.BizProcessor.SOHolder.SOHoldReason.AbandonOrder, OPCCallBackType.HoldCallBack);

                throw new BizException(String.Format("{0}\r\n{1}", bizex.Message, ResourceHelper.Get("SO_Abandon_Hold")));
            }

            //  3.  先锁定订单,再作订单。如果已经锁定就直接作废,否则先锁定订单
            bool isHold = CurrentSO.BaseInfo.HoldStatus == SOHoldStatus.BackHold;

            if (!isHold)
            {
                isHold = Holder.Hold(ECCentral.Service.SO.BizProcessor.SOHolder.SOHoldReason.AbandonOrder, OPCCallBackType.AbandonCallBack);

                if (!isHold)
                {
                    BizExceptionHelper.Throw("SO_Abandon_HoldIsAsyn");
                }
            }
            if (isHold)
            {
                //TransactionOptions option = new TransactionOptions();
                //option.IsolationLevel = IsolationLevel.ReadUncommitted;
                //option.Timeout = TransactionManager.DefaultTimeout;
                //using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, option))
                //{
                //    AbandonSO();
                //    PublishMessage();
                //    scope.Complete();
                //}
                TransactionOptions options = new TransactionOptions
                {
                    IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
                };
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
                {
                    AbandonSO();
                    scope.Complete();
                }
                PublishMessage();


                if (ServiceContext.Current.UserSysNo == 1)
                {
                    SOSendMessageProcessor soMail = new SOSendMessageProcessor();
                    //soMail.AbandonSOEmailToCustomer(this.CurrentSO);
                }
            }
        }