コード例 #1
0
        /// <summary>
        /// 提交审核(审核银行信息)
        /// </summary>
        /// <param name="entity"></param>
        public virtual RefundBalanceInfo SubmitAudit(RefundBalanceInfo entity)
        {
            RefundBalanceInfo refundBalanceInfo = GetRefundBalanceBySysNo(entity.SysNo.Value);

            if (refundBalanceInfo == null)
            {
                throw new BizException(ResouceManager.GetMessageString("RMA.RefundBalance", "RefundBalanceNotExists"));
            }
            refundBalanceInfo.PointAmt = refundBalanceInfo.PointAmt ?? 0;

            if (refundBalanceInfo.Status != RefundBalanceStatus.WaitingRefund)
            {
                throw new BizException(ResouceManager.GetMessageString("RMA.RefundBalance", "Audit_RefundBalanceWaitingRefundValid"));
            }
            if (refundBalanceInfo.CashAmt == null)
            {
                throw new BizException(ResouceManager.GetMessageString("RMA.RefundBalance", "CashAmtRequired"));
            }
            if (refundBalanceInfo.CashAmt.Value < 0)
            {
                throw new BizException(ResouceManager.GetMessageString("RMA.RefundBalance", "Audit_CashAmtValid"));
            }
            SOIncomeRefundInfo oldIncomeBankInfo = ExternalDomainBroker.GetSOIncomeRefundInfo(entity.SysNo.Value, RefundOrderType.RO_Balance);
            SOIncomeRefundInfo newIncomeBankInfo = new SOIncomeRefundInfo()
            {
                RefundReason   = 9, // RefundReason.RefundBalance
                BankName       = entity.IncomeBankInfo.BankName,
                BranchBankName = entity.IncomeBankInfo.BranchBankName,
                CardNumber     = entity.IncomeBankInfo.CardNumber,
                CardOwnerName  = entity.IncomeBankInfo.CardOwnerName,
                PostAddress    = entity.IncomeBankInfo.PostAddress,
                PostCode       = entity.IncomeBankInfo.PostCode,
                ReceiverName   = entity.IncomeBankInfo.ReceiverName,
                Note           = entity.IncomeBankInfo.Note,
                CompanyCode    = refundBalanceInfo.CompanyCode
            };

            TransactionScopeFactory.TransactionAction(() =>
            {
                if (oldIncomeBankInfo == null)
                {
                    newIncomeBankInfo.RefundPayType = refundBalanceInfo.RefundPayType;
                    newIncomeBankInfo.SOSysNo       = refundBalanceInfo.OriginalSOSysNo;
                    newIncomeBankInfo.OrderType     = RefundOrderType.RO_Balance;
                    newIncomeBankInfo.OrderSysNo    = refundBalanceInfo.SysNo;
                    newIncomeBankInfo.HaveAutoRMA   = false;

                    if (newIncomeBankInfo.RefundPayType == RefundPayType.CashRefund)
                    {
                        newIncomeBankInfo.Status = ECCentral.BizEntity.Invoice.RefundStatus.Audit;
                    }
                    else
                    {
                        newIncomeBankInfo.Status = ECCentral.BizEntity.Invoice.RefundStatus.Origin;
                    }

                    if (newIncomeBankInfo.RefundPayType == RefundPayType.TransferPointRefund)
                    {
                        newIncomeBankInfo.RefundCashAmt = 0;
                        newIncomeBankInfo.RefundPoint   = Convert.ToInt32(Decimal.Round((refundBalanceInfo.CashAmt ?? 0M)
                                                                                        * pointExchangeRate, 0));
                        if (refundBalanceInfo.PointAmt > 0)//如果有积分累加到bankInfo的PointAmt字段上
                        {
                            newIncomeBankInfo.RefundPoint += refundBalanceInfo.PointAmt;
                        }
                    }
                    else
                    {
                        newIncomeBankInfo.RefundCashAmt = refundBalanceInfo.CashAmt;
                        newIncomeBankInfo.RefundPoint   = refundBalanceInfo.PointAmt;
                    }
                    newIncomeBankInfo.RefundGiftCard = refundBalanceInfo.GiftCardAmt;

                    ExternalDomainBroker.CreateSOIncomeRefundInfo(newIncomeBankInfo);
                }
                else if (oldIncomeBankInfo.Status == RefundStatus.Origin ||
                         (oldIncomeBankInfo.Status != RefundStatus.Origin && oldIncomeBankInfo.RefundPayType == RefundPayType.CashRefund))
                {
                    newIncomeBankInfo.SysNo          = oldIncomeBankInfo.SysNo;
                    newIncomeBankInfo.OrderType      = oldIncomeBankInfo.OrderType;
                    newIncomeBankInfo.RefundPayType  = oldIncomeBankInfo.RefundPayType;
                    newIncomeBankInfo.RefundReason   = oldIncomeBankInfo.RefundReason;
                    newIncomeBankInfo.HaveAutoRMA    = oldIncomeBankInfo.HaveAutoRMA;
                    newIncomeBankInfo.RefundCashAmt  = oldIncomeBankInfo.RefundCashAmt;
                    newIncomeBankInfo.RefundGiftCard = oldIncomeBankInfo.RefundGiftCard;
                    newIncomeBankInfo.RefundPoint    = oldIncomeBankInfo.RefundPoint;
                    newIncomeBankInfo.ToleranceAmt   = oldIncomeBankInfo.ToleranceAmt;
                    newIncomeBankInfo.Status         = oldIncomeBankInfo.Status;

                    ExternalDomainBroker.UpdateSOIncomeRefundInfo(newIncomeBankInfo);
                }
                else if (oldIncomeBankInfo.Status == RefundStatus.Abandon)
                {
                    throw new BizException(ResouceManager.GetMessageString("RMA.RefundBalance", "Audit_RefundBalanceAbandonStatusValid"));
                }
                else
                {
                    throw new BizException(ResouceManager.GetMessageString("RMA.RefundBalance", "Audit_RefundBalanceStatusValid"));
                }
                entity.IncomeBankInfo = newIncomeBankInfo;

                //完成RMA退款调整单待审核 - 待办事项:
                EventPublisher.Publish <RMACompleteRefundBalanceWaitingForAuditMessage>(new RMACompleteRefundBalanceWaitingForAuditMessage()
                {
                    RefundBalanceSysNo = entity.SysNo.Value,
                    RefundSysNo        = entity.OriginalRefundSysNo.Value,
                    CurrentUserSysNo   = ServiceContext.Current.UserSysNo
                });
            });
            return(entity);
        }