Beispiel #1
0
        /// <summary>
        /// 审核netpay时加载netpay相关信息
        /// </summary>
        /// <param name="netpaySysNo"></param>
        /// <param name="refundInfo"></param>
        /// <param name="soBaseInfo"></param>
        /// <returns></returns>
        public virtual NetPayInfo LoadForAudit(int netpaySysNo
                                               , out SOIncomeRefundInfo refundInfo, out SOBaseInfo soBaseInfo)
        {
            var netpayInfo = ObjectFactory <NetPayProcessor> .Instance.LoadBySysNo(netpaySysNo);

            if (netpayInfo == null)
            {
                throw new BizException(ResouceManager.GetMessageString(InvoiceConst.ResourceTitle.NetPay, "NetPay_NeyPayRecordNotExist"));
            }

            soBaseInfo = ExternalDomainBroker.GetSOBaseInfo(netpayInfo.SOSysNo.Value);
            if (soBaseInfo == null)
            {
                throw new BizException(ResouceManager.GetMessageString(InvoiceConst.ResourceTitle.NetPay, "NetPay_SORecordNotExist"));
            }

            var query = new SOIncomeRefundInfo();

            query.OrderType  = RefundOrderType.OverPayment;
            query.OrderSysNo = netpayInfo.SOSysNo;
            query.Status     = RefundStatus.Origin;

            refundInfo = null;
            var refundList = ObjectFactory <SOIncomeRefundProcessor> .Instance.GetListByCriteria(query);

            if (refundList != null && refundList.Count > 0)
            {
                refundInfo = refundList[0];
            }

            return(netpayInfo);
        }
Beispiel #2
0
        public virtual RMARequestInfo LoadWithRegistersBySysNo(int sysNo, out CustomerInfo customer,
                                                               out SOBaseInfo soBaseInfo,
                                                               out DeliveryInfo deliveryInfo,
                                                               out string deliveryUserName,
                                                               out string businessModel)
        {
            var request = ObjectFactory <RequestProcessor> .Instance.LoadWithRegistersBySysNo(sysNo);

            businessModel = ObjectFactory <RequestProcessor> .Instance.GetBusinessModel(request);

            //配送信息
            deliveryUserName = string.Empty;
            deliveryInfo     = ExternalDomainBroker.GetDeliveryInfo(DeliveryType.RMARequest, sysNo, DeliveryStatus.OK);
            if (deliveryInfo != null && deliveryInfo.DeliveryUserSysNo.HasValue)
            {
                deliveryUserName = ExternalDomainBroker.GetUserInfoBySysNo(deliveryInfo.DeliveryUserSysNo.Value);
            }
            if (request.CreateUserSysNo != null)
            {
                request.CreateUserName = ExternalDomainBroker.GetUserInfoBySysNo(request.CreateUserSysNo.Value);
            }
            if (request.ReceiveUserSysNo.HasValue)
            {
                request.ReceiveUserName = ExternalDomainBroker.GetUserInfoBySysNo(request.ReceiveUserSysNo.Value);
            }
            customer = ExternalDomainBroker.GetCustomerInfo(request.CustomerSysNo.Value);

            soBaseInfo = ExternalDomainBroker.GetSOBaseInfo(request.SOSysNo.Value);

            return(request);
        }
Beispiel #3
0
        /// <summary>
        /// 修改团购订单的价格信息
        /// </summary>
        /// <param name="groupBuySysNo">团购编号</param>
        /// <param name="settlementStatus">处理状态</param>
        public void UpdateGroupBuySOAmount(SOBaseInfo baseInfo)
        {
            DataCommand command = DataCommandManager.GetDataCommand("SO_Update_GroupBuySOMaster");

            command.SetParameterValue(baseInfo);
            command.ExecuteNonQuery();
        }
Beispiel #4
0
        public virtual void AbandonSplitForSO(SOBaseInfo master, List <SOBaseInfo> subList)
        {
            if (master == null || subList == null)
            {
                throw new ArgumentNullException("entity");
            }

            var postIncomeConfirmList = m_PostIncomeDA.GetConfirmedListBySOSysNo(master.SysNo.ToString());

            if (postIncomeConfirmList == null || postIncomeConfirmList.Count == 0)
            {
                ThrowBizException("PostIncome_PostIncomeNotFound");
            }

            var origin = m_PostIncomeDA.LoadBySysNo(postIncomeConfirmList[0].PostIncomeSysNo.Value);

            origin.ConfirmStatus = PostIncomeStatus.Abandon;
            origin.HandleStatus  = PostIncomeHandleStatus.Handled;

            foreach (var postIncomeConfirm in postIncomeConfirmList)
            {
                m_PostIncomeDA.UpdatePostIncomeConfirmStatus(postIncomeConfirm.SysNo.Value, PostIncomeConfirmStatus.Cancel);
            }
            m_PostIncomeDA.AbandonSplitForSO(origin);
            //记录操作日志
            ObjectFactory <ICommonBizInteract> .Instance.CreateOperationLog(
                GetMessageString("PostIncome_Log_Abandon", ServiceContext.Current.UserSysNo, origin.SysNo)
                , BizLogType.Invoice_PostIncome_Abandon
                , origin.SysNo.Value
                , origin.CompanyCode);
        }
Beispiel #5
0
        /// <summary>
        /// 子订单作废,合并为原来的母单,原来的母订单启用
        /// </summary>
        /// <param name="customerSysNo"></param>
        /// <param name="master"></param>
        /// <param name="subSoList"></param>
        public virtual void CancelSplitSOPointLog(int customerSysNo, SOBaseInfo master, List <SOBaseInfo> subSoList)
        {
            //需验证子单的积分之和是否和主订单积分相等
            if (master == null || master.SysNo == null)
            {
                throw new BizException(ResouceManager.GetMessageString("Customer.CustomerPointsAddRequest", "SOSplitPoint_MasterSoIsNull"));
            }

            if (subSoList == null || subSoList.Count <= 0)
            {
                throw new BizException(ResouceManager.GetMessageString("Customer.CustomerPointsAddRequest", "SOSplitPoint_SubSoIsNull"));
            }

            int sumSubPoint = 0;

            subSoList.ForEach(item =>
            {
                sumSubPoint += Convert.ToInt32(item.PointPay.Value);
            });
            if (master.PointPay.HasValue &&
                sumSubPoint != master.PointPay.Value)
            {
                throw new BizException(ResouceManager.GetMessageString("Customer.CustomerPointsAddRequest", "SONotEqual"));
            }
            //GetOperResult(ObjectFactory<IPointDA>.Instance.CancelSplitSOPointLog(customerSysNo, master, subSoList));
            GetOperResult(ExternalDomainBroker.CancelSplitSOPointLog(customerSysNo, master, subSoList));
        }
        /// <summary>
        /// CreateRefundBalance预检查
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="soBaseInfo"></param>
        private void VerifyForCreate(RefundBalanceInfo entity, out SOBaseInfo soBaseInfo)
        {
            if (entity.CashAmt == null)
            {
                throw new BizException(ResouceManager.GetMessageString("RMA.RefundBalance", "CashAmtRequired"));
            }
            if (entity.CashAmt.Value == 0)
            {
                throw new BizException(ResouceManager.GetMessageString("RMA.RefundBalance", "CashAmtNotEqualZero"));
            }
            if (entity.RefundPayType != RefundPayType.TransferPointRefund && entity.RefundPayType != RefundPayType.NetWorkRefund &&
                entity.RefundPayType != RefundPayType.PrepayRefund && entity.CashAmt < 0)
            {
                throw new BizException(ResouceManager.GetMessageString("RMA.RefundBalance", "RefundPayTypeAndCashAmtValid"));
            }

            soBaseInfo = ExternalDomainBroker.GetSOBaseInfo(entity.OriginalSOSysNo.Value);
            if (soBaseInfo == null)
            {
                throw new BizException(ResouceManager.GetMessageString("RMA.RefundBalance", "SONotExists"));
            }

            #region 创建时加入金额验证
            decimal availShipPrice, cashRemoveGiftCard, availGiftCard, totalRoBoBalanceAmt;
            int     availPointAmt;
            CalculateAvailRefundAmt(entity, soBaseInfo, out availShipPrice, out cashRemoveGiftCard, out availGiftCard, out availPointAmt, out totalRoBoBalanceAmt);

            decimal ROAmt;
            PreCheckForRefund(entity, totalRoBoBalanceAmt, availShipPrice, out ROAmt);
            #endregion
        }
Beispiel #7
0
        /// <summary>
        /// 取消拆分,将母单和子单的收款信息都作废
        /// </summary>
        /// <param name="master">母单</param>
        /// <param name="subList">子单列表</param>
        public void AbandonSplitForSO(SOBaseInfo master, List <SOBaseInfo> subList)
        {
            CustomDataCommand cmd = DataCommandManager.CreateCustomDataCommandFromConfig("AbandonSplitSOIncomeForSO");

            cmd.CommandText = cmd.CommandText.Replace("@SoSysNoList@", subList.ToListString("SysNo"));
            cmd.AddInputParameter("@MasterSoSysNo", DbType.AnsiStringFixedLength, master.SysNo);
            cmd.ExecuteNonQuery();
        }
Beispiel #8
0
        /// <summary>
        /// 创建NetPay
        /// </summary>
        /// <param name="netpayEntity">网上支付实体</param>
        /// <param name="refundEntity">退款实体</param>
        /// <param name="isForceCheck">是否强制核收,如果是强制核收,refundEntity必须要有值</param>
        /// <returns>创建好的netpay实体</returns>
        public virtual NetPayInfo Create(NetPayInfo netpayEntity, SOIncomeRefundInfo refundEntity, bool isForceCheck)
        {
            SOBaseInfo soBaseInfo = ExternalDomainBroker.GetSOBaseInfo(netpayEntity.SOSysNo.Value);

            //创建前预检查
            PreCheckForCreate(netpayEntity, refundEntity, soBaseInfo, isForceCheck);

            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = IsolationLevel.ReadCommitted;
            options.Timeout        = TimeSpan.FromMinutes(2);
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, options))
            {
                //Step 1:写入退款信息
                bool isOverpay = netpayEntity.PayAmount > soBaseInfo.ReceivableAmount;
                if (isForceCheck && isOverpay)
                {
                    refundEntity.CompanyCode = soBaseInfo.CompanyCode;
                    CreateRefundInfoForForceCheck(netpayEntity, refundEntity);
                }

                //Step 2:写入网上支付信息
                netpayEntity.Status        = NetPayStatus.Origin;
                netpayEntity.ExternalKey   = m_NetpayDA.GetExternalKeyBySOSysNo(netpayEntity.SOSysNo.Value);
                netpayEntity.MasterSoSysNo = soBaseInfo.SOSplitMaster;
                netpayEntity.CompanyCode   = soBaseInfo.CompanyCode;
                if (string.IsNullOrEmpty(netpayEntity.Note))
                {
                    netpayEntity.Note = "add by newegg employees.";
                }
                netpayEntity = m_NetpayDA.Create(netpayEntity);

                //如果生成netpay记录的订单有母单,则更新netpay的母单信息
                if (soBaseInfo.SOSplitMaster.HasValue && soBaseInfo.SOSplitMaster.Value > 0)
                {
                    var masterSO = ExternalDomainBroker.GetSOBaseInfo(soBaseInfo.SOSplitMaster.Value);
                    m_NetpayDA.UpdateMasterSOAmt(masterSO);
                }

                //发送创建netpay消息
                EventPublisher.Publish(new CreateNetpayMessage()
                {
                    NetpaySysNo      = netpayEntity.SysNo.Value,
                    CurrentUserSysNo = ServiceContext.Current.UserSysNo
                });

                ts.Complete();
            }

            //记录业务Log
            ObjectFactory <ICommonBizInteract> .Instance.CreateOperationLog(
                GetMessageString("NetPay_Log_Create", ServiceContext.Current.UserSysNo, netpayEntity.SysNo)
                , ECCentral.BizEntity.Common.BizLogType.Finance_NetPay_AddVerified
                , netpayEntity.SysNo.Value
                , netpayEntity.CompanyCode);

            return(netpayEntity);
        }
        /// <summary>
        /// 团购Job调用,用于创建AO单
        /// </summary>
        /// <param name="soSysNo">订单系统编号</param>
        /// <param name="refundPayType">退款类型</param>
        /// <param name="note">退款备注</param>
        /// <param name="refundReason">退款原因系统编号,编号来自OverseaServiceManagement.dbo.refundReason</param>
        public virtual void CreateAOForJob(int soSysNo, RefundPayType refundPayType, string note, int? refundReason)
        {
            //0.验证
            SOBaseInfo soInfo = ExternalDomainBroker.GetSOBaseInfo(soSysNo);
            if (soInfo == null)
            {
                ThrowBizException("SOIncomeRefund_SONotFound", soSysNo);
            }
            if (soInfo.Status != SOStatus.Origin && soInfo.Status != SOStatus.WaitingOutStock)
            {   //不为Origin,WaitingOutStock 状态
                ThrowBizException("SOIncomeRefund_CreateAOForGroupJob_SOStatusInvalid", soSysNo);
            }

            var validSOIncome = ObjectFactory<SOIncomeProcessor>.Instance.GetValid(soSysNo, SOIncomeOrderType.SO);
            if (validSOIncome == null)
            {
                ThrowBizException("SOIncomeRefund_CreateAOForGroupJob_ValidSOIncomeNotFound", soSysNo);
            }

            //1.Set data
            //CRL18174:团购订单退款调整,团购订单退款需视不同的支付方式,采用不同的退款类型
            //如果团购订单的退款类型为空,则默认为“退入余额帐户”方式
            //如果退款方式为“网关直接退款",则需要填写“银行名称”
            string bankName = refundPayType == RefundPayType.NetWorkRefund ? ExternalDomainBroker.GetPayType(soInfo.PayTypeSysNo.Value).PayTypeName : "";

            SOIncomeRefundInfo soIncomeRefund = new SOIncomeRefundInfo
            {
                OrderSysNo = soSysNo,
                SOSysNo = soSysNo,
                OrderType = RefundOrderType.AO,
                Status = RefundStatus.Origin,
                Note = note,
                RefundPayType = refundPayType,
                RefundReason = refundReason,
                BankName = bankName
            };
            soIncomeRefund.CompanyCode = soInfo.CompanyCode;
            //AO退 除了礼品卡的全部金额,包括积分、余额、现金
            decimal giftCardPayAmt = validSOIncome.GiftCardPayAmt ?? 0m;
            soIncomeRefund.RefundCashAmt = validSOIncome.OrderAmt - giftCardPayAmt;
            soIncomeRefund.RefundGiftCard = giftCardPayAmt;
            soIncomeRefund.RefundPoint = 0;

            //Negative SOIncome
            validSOIncome.CompanyCode = soInfo.CompanyCode;
            validSOIncome.OrderType = SOIncomeOrderType.AO;
            validSOIncome.OrderAmt = -validSOIncome.OrderAmt;
            validSOIncome.PointPay = -validSOIncome.PointPay;
            validSOIncome.GiftCardPayAmt = -validSOIncome.GiftCardPayAmt;
            validSOIncome.IncomeAmt = -validSOIncome.IncomeAmt;

            PreCheckForCreateAOForJob(soIncomeRefund);

            ObjectFactory<SOIncomeProcessor>.Instance.Create(validSOIncome);

            ObjectFactory<ISOIncomeRefundDA>.Instance.Create(soIncomeRefund);
        }
Beispiel #10
0
        /// <summary>
        /// 更新主单收款单金额
        /// </summary>
        /// <param name="baseInfo">订单基本信息</param>
        public void UpdateMasterSOAmt(SOBaseInfo baseInfo)
        {
            DataCommand command = DataCommandManager.GetDataCommand("UpdateSOIncomeAmt");

            command.SetParameterValue("@PayAmount", baseInfo.ReceivableAmount);
            command.SetParameterValue("@OrderAmt", baseInfo.SOTotalAmount);
            command.SetParameterValue("@PointPayAmt", baseInfo.GainPoint);
            command.SetParameterValue("@PrePayAmt", baseInfo.PrepayAmount);
            command.SetParameterValue("@OrderSysNo", baseInfo.SysNo);
            command.ExecuteNonQuery();
        }
Beispiel #11
0
        /// <summary>
        /// 取消拆分订单,礼品处理
        /// </summary>
        /// <param name="masterSOBaseInfo">主订单基本信息</param>
        /// <param name="subGiftCards">所有子订单对应的礼品卡拆分,key:子订单编号,value:拆分到子订单的礼品卡</param>
        internal static void CancelSplitSOGiftCard(SOBaseInfo masterSOBaseInfo, Dictionary <int, List <ECCentral.BizEntity.IM.GiftCardRedeemLog> > subGiftCards)
        {
            List <ECCentral.BizEntity.IM.GiftCard> giftCardList = (from subSOGiftCard in subGiftCards
                                                                   from giftCard in subSOGiftCard.Value
                                                                   select new ECCentral.BizEntity.IM.GiftCard
            {
                Code = giftCard.Code,
                ConsumeAmount = giftCard.Amount.Value,
                ReferenceSOSysNo = subSOGiftCard.Key
            }).ToList();

            ObjectFactory <ECCentral.Service.IBizInteract.IIMBizInteract> .Instance.GiftCardSplitSORollback(masterSOBaseInfo.SysNo.Value, masterSOBaseInfo.CustomerSysNo.Value, giftCardList, masterSOBaseInfo.CompanyCode);
        }
Beispiel #12
0
        protected override void PreCheckForUpdate(SOIncomeRefundInfo entity)
        {
            base.PreCheckForUpdate(entity);

            //如果是“现金退款”,则调用SO服务验证订单的支付类型是不是可以选择“现金退款”
            if (entity.RefundPayType == RefundPayType.CashRefund)
            {
                //只有订单为货到"付款(OZZO奥硕物流)","现金支付","POS机刷卡","宅急送(货到付款)"才可以选择现金退款
                SOBaseInfo soBaseInfo = ExternalDomainBroker.GetSOBaseInfo(entity.SOSysNo.Value);
                if (!CheckPayTypeCanCashRefund(soBaseInfo.PayTypeSysNo.Value))
                {
                    ThrowBizException("SOIncomeRefund_CashRefundNotAllowed");
                }
            }
        }
Beispiel #13
0
        /// <summary>
        /// 审核netpay预检查
        /// </summary>
        /// <param name="netpayInfo"></param>
        /// <param name="soBaseInfo"></param>
        /// <param name="isForceCheck"></param>
        protected virtual void PreCheckForAudit(NetPayInfo netpayInfo, SOBaseInfo soBaseInfo)
        {
            if (netpayInfo.Status != NetPayStatus.Origin)
            {
                ThrowBizException("NetPay_StatusNotAllowCheck");
            }
            if (soBaseInfo.ReferenceSysNo.HasValue && soBaseInfo.SOType == SOType.GroupBuy)
            {
                //团购正在进行中,请待团购结束后再进行审核   部分失败的团购订单也予以审核通过
                if (soBaseInfo.SettlementStatus != SettlementStatus.Success && soBaseInfo.SettlementStatus != SettlementStatus.PlanFail)
                {
                    ThrowBizException("NetPay_GroupingBuyOrderNotAllowCheck", netpayInfo.SOSysNo);
                }
            }
            if (soBaseInfo.HoldStatus == SOHoldStatus.WebHold)
            {
                ThrowBizException("NetPay_HoldOrderNotAllowCheck", netpayInfo.SOSysNo);
            }

            //输入的订单的支付方式要与订单中的支付方式一致
            if (netpayInfo.PayTypeSysNo != soBaseInfo.PayTypeSysNo)
            {
                ThrowBizException("NetPay_PayTypeNotSameNotAllowCheck");
            }

            //验证订单的付款方式是不是“网上支付”
            if (!IsNetPayType(soBaseInfo.PayTypeSysNo.Value, soBaseInfo.SysNo.Value))
            {
                ThrowBizException("NetPay_SOPayTypeIsNotNet");
            }

            //Nick.Y.Zheng 实收金额与订单金额不相等,且误差超过1分钱,则不通过,否则通过
            //实收金额少于订单金额,不允许核收。
            decimal currPayAmount = netpayInfo.PayAmount.HasValue ? netpayInfo.PayAmount.Value : 0m;

            //if (netpayInfo.PayAmount != soBaseInfo.ReceivableAmount
            //    && Math.Abs(currPayAmount - soBaseInfo.ReceivableAmount) > 0.01m)
            //{
            //    ThrowBizException("NetPay_PayAmoutNotEqualNotAllowCheck");
            //}
            //实收金额少于订单金额,不允许核收。
            if (netpayInfo.PayAmount < soBaseInfo.ReceivableAmount && Math.Abs(currPayAmount - soBaseInfo.ReceivableAmount) > 0.01m)
            {
                ThrowBizException("NetPay_PayAmoutNotEnoughNotAllowCheck");
            }
        }
Beispiel #14
0
        /// <summary>
        /// 创建财务收款信息
        /// </summary>
        /// <param name="postPayInfo"></param>
        /// <param name="soBaseInfo"></param>
        /// <returns></returns>
        private SOIncomeInfo CreateSOIncomeInfo(PostPayInfo postPayInfo, SOBaseInfo soBaseInfo)
        {
            var soIncomeInfo = new SOIncomeInfo()
            {
                OrderType      = SOIncomeOrderType.SO,
                OrderSysNo     = postPayInfo.SOSysNo.Value,
                OrderAmt       = soBaseInfo.SOTotalAmount,
                IncomeStyle    = SOIncomeOrderStyle.Advanced,
                IncomeAmt      = postPayInfo.PayAmount,
                PrepayAmt      = soBaseInfo.PrepayAmount,
                Status         = SOIncomeStatus.Origin,
                PayAmount      = postPayInfo.PayAmount,
                PointPay       = soBaseInfo.PointPay,
                GiftCardPayAmt = soBaseInfo.GiftCardPay,
                CompanyCode    = soBaseInfo.CompanyCode
            };

            return(ObjectFactory <SOIncomeProcessor> .Instance.Create(soIncomeInfo));
        }
Beispiel #15
0
        /// <summary>
        /// 构造销售收款单信息
        /// </summary>
        private SOIncomeInfo CreateSOIncomeInfo(NetPayInfo netpayInfo, SOBaseInfo soBaseInfo)
        {
            var soIncomeInfo = new SOIncomeInfo()
            {
                IncomeStyle    = SOIncomeOrderStyle.Advanced,
                OrderType      = SOIncomeOrderType.SO,
                OrderSysNo     = netpayInfo.SOSysNo,
                OrderAmt       = soBaseInfo.SOTotalAmount,
                IncomeAmt      = netpayInfo.PayAmount,
                PrepayAmt      = soBaseInfo.PrepayAmount,
                Status         = SOIncomeStatus.Origin,
                MasterSoSysNo  = soBaseInfo.SOSplitMaster,
                PointPay       = soBaseInfo.PointPay / decimal.Parse(AppSettingManager.GetSetting("Invoice", "PointExChangeRate")),
                GiftCardPayAmt = soBaseInfo.GiftCardPay,
                PayAmount      = netpayInfo.PayAmount,
                CompanyCode    = soBaseInfo.CompanyCode //取订单上的CompanyCode
            };

            //SOIncomeProcessor检查,如果已经存在收款单记录,则不允许创建
            return(ObjectFactory <SOIncomeProcessor> .Instance.Create(soIncomeInfo));
        }
Beispiel #16
0
        /// <summary>
        /// 拆分订单发票
        /// </summary>
        /// <param name="soSysNo">订单系统编号</param>
        /// <param name="invoiceItems"></param>
        public virtual void CancelSplitSOInvoice(int soSysNo)
        {
            SOBaseInfo soInfo = GetSOBaseInfoBySOSysNo(soSysNo);

            switch (soInfo.Status.Value)
            {
            case SOStatus.Origin:
            case SOStatus.WaitingOutStock:
            {
                //取消拆分发票
                ExternalDomainBroker.CancelSplitInvoice(soSysNo);
                //更新订单信息
                SODA.UpdateSOForSplitInvoice(soSysNo, false);
            }
            break;

            default:
                BizExceptionHelper.Throw("SO_CacelSplitInvoice_StatusIsError");
                break;
            }
        }
Beispiel #17
0
        /// <summary>
        /// 拆分订单发票
        /// </summary>
        /// <param name="soSysNo">订单系统编号</param>
        /// <param name="invoiceItems"></param>
        public virtual void SplitSOInvoice(int soSysNo, List <ECCentral.BizEntity.Invoice.SubInvoiceInfo> invoiceItems)
        {
            SOBaseInfo soInfo = GetSOBaseInfoBySOSysNo(soSysNo);

            switch (soInfo.Status.Value)
            {
            case SOStatus.Origin:
            case SOStatus.WaitingOutStock:
            {
                //拆分发票
                ExternalDomainBroker.SplitInvoice(invoiceItems);
                //更新订单信息
                SODA.UpdateSOForSplitInvoice(soSysNo, true);
            }
            break;

            default:
                BizExceptionHelper.Throw("SO_SplitInvoice_StatusIsError");
                break;
            }
        }
Beispiel #18
0
 /// <summary>
 /// 取消拆分销售收款单
 /// </summary>
 /// <param name="soInfo">主订单</param>
 /// <param name="subSOList">子订单列表</param>
 public void CancelSplitSOIncome(SOBaseInfo soInfo, List <SOBaseInfo> subSOList)
 {
     ObjectFactory <SOIncomeProcessor> .Instance.AbandonSplitPayForSO(soInfo, subSOList);
 }
Beispiel #19
0
 protected override void PreCheckForCreate(PostPayInfo entity, SOIncomeRefundInfo refundInfo, SOBaseInfo soBaseInfo, bool isForceCheck)
 {
     if (isForceCheck && refundInfo.RefundPayType != null)
     {
         if (refundInfo.RefundPayType == RefundPayType.CashRefund)
         {
             //只有货到付款(OZZO奥硕物流)和现金支付才可以选择现金退款
             if (!CanCashRefund(soBaseInfo.PayTypeSysNo.Value))
             {
                 ThrowBizException("PostPay_CashRefundNotAllowed");
             }
         }
     }
     base.PreCheckForCreate(entity, refundInfo, soBaseInfo, isForceCheck);
 }
Beispiel #20
0
        /// <summary>
        /// 审核网上支付
        /// </summary>
        /// <param name="netpaySysNo">netpay系统编号</param>
        public virtual void Audit(int netpaySysNo)
        {
            NetPayInfo netpayInfo = LoadBySysNo(netpaySysNo);

            if (netpayInfo == null)
            {
                ThrowBizException("NetPay_NeyPayRecordNotExist", netpaySysNo);
            }

            //if (netpayInfo.InputUserSysNo != AuditInfo.AuditUserSysNo)
            //{
            //    ThrowBizException("NetPay_InputAndAuditUserCannotSame", netpaySysNo);
            //}

            SOBaseInfo soBaseInfo = ExternalDomainBroker.GetSOBaseInfo(netpayInfo.SOSysNo.Value);

            SOInfo soInfo = ExternalDomainBroker.GetSOInfo(netpayInfo.SOSysNo.Value);

            if (soBaseInfo == null)
            {
                ThrowBizException("NetPay_SORecordNotExist", netpayInfo.SOSysNo);
            }

            //审核前检查
            PreCheckForAudit(netpayInfo, soBaseInfo);

            SOIncomeInfo soIncomeInfo;

            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = IsolationLevel.ReadCommitted;
            options.Timeout        = TimeSpan.FromMinutes(2);

            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, options))
            {
                //1.创建销售收款
                //如果有主单,则更新主单的收款单金额
                soIncomeInfo = CreateSOIncomeInfo(netpayInfo, soBaseInfo);
                if (soBaseInfo.SOSplitMaster.HasValue && soBaseInfo.SOSplitMaster.Value > 0)
                {
                    var masterSO = ExternalDomainBroker.GetSOBaseInfo(soBaseInfo.SOSplitMaster.Value);
                    ObjectFactory <SOIncomeProcessor> .Instance.UpdateMasterSOAmt(masterSO);
                }

                //2.审核网上支付,将网上支付记录的状态修改为审核通过
                m_NetpayDA.UpdateApproveInfo(netpaySysNo, NetPayStatus.Approved);

                //3.审核财务多付退款记录
                var refundList = ObjectFactory <SOIncomeRefundProcessor> .Instance.GetListByCriteria(new SOIncomeRefundInfo()
                {
                    OrderSysNo = soIncomeInfo.OrderSysNo.Value,
                    OrderType  = RefundOrderType.OverPayment,
                    Status     = RefundStatus.Origin
                });

                SOIncomeRefundInfo overpayRefund = null;
                if (refundList != null && refundList.Count > 0)
                {
                    overpayRefund = refundList[0];
                }
                if (overpayRefund != null)
                {
                    //如果是现金退款,则退款信息自动审核通过
                    if (overpayRefund.RefundPayType == RefundPayType.CashRefund)
                    {
                        overpayRefund.Status = RefundStatus.Audit;
                        ObjectFactory <SOIncomeRefundProcessor> .Instance.Update(overpayRefund);
                    }
                    //创建财务负收款单
                    overpayRefund.PayAmount = netpayInfo.PayAmount;
                    ObjectFactory <SOIncomeProcessor> .Instance.CreateNegative(overpayRefund);
                }

                //发送netpay审核完成Message

                ts.Complete();
            }
            //待办事项通知,异常不处理,不影响正常业务
            try
            {
                EventPublisher.Publish <InvoiceNetpayAuditedMessage>(new InvoiceNetpayAuditedMessage()
                {
                    SoSysNo        = netpayInfo.SOSysNo.Value,
                    MerchantSysNo  = soInfo.Merchant.SysNo.GetValueOrDefault(),
                    SOType         = (int)soInfo.BaseInfo.SOType,
                    ReferenceSysNo = soInfo.BaseInfo.ReferenceSysNo ?? 0,
                    AuditUserName  = ServiceContext.Current.UserDisplayName,
                    AuditUserSysNo = ServiceContext.Current.UserSysNo,
                    NetpaySysNo    = netpayInfo.SysNo.Value,
                    SplitType      = (int)soInfo.BaseInfo.SplitType
                });
            }
            catch (Exception ex)
            {
                string ere = ex.Message;
            }
            //记录操作日志,用户审核了网上收款单
            ObjectFactory <ICommonBizInteract> .Instance.CreateOperationLog(
                GetMessageString("NetPay_Log_Audit", ServiceContext.Current.UserSysNo, netpaySysNo)
                , ECCentral.BizEntity.Common.BizLogType.Finance_NetPay_Verify
                , soIncomeInfo.SysNo.Value
                , soIncomeInfo.CompanyCode);

            //4、审核移仓单
            VerifyShiftRequest(netpayInfo);
            //库存模式同步送货单给ERP,此处仅限在线支付。货到的在订单审核时会发送
            if (soBaseInfo.PayWhenReceived == false)
            {
                SyncSHD(netpayInfo.SOSysNo.Value);
            }
        }
Beispiel #21
0
 /// <summary>
 /// 作废拆分NetPay
 /// </summary>
 /// <param name="master">主单信息</param>
 /// <param name="subList">子单列表</param>
 /// <param name="externalKey">externalKey</param>
 public virtual void AbandonSplitForSO(SOBaseInfo master, List <SOBaseInfo> subList, string externalKey)
 {
     m_NetpayDA.AbandonSplitForSO(master, subList, externalKey);
 }
Beispiel #22
0
        /// <summary>
        /// 通过订单编号加载和该订单号关联的电汇-邮局付款单关联信息,用于核对银行电汇-邮局汇款
        /// </summary>
        /// <param name="soSysNo">订单系统编号</param>
        /// <param name="soBaseInfo">订单基本信息</param>
        /// <param name="incomeAmt">实收金额</param>
        /// <param name="checkedOrderAmt">应收金额</param>
        /// <param name="refundAmt">已确认的多付金额</param>
        /// <returns>和该订单号关联的电汇-邮局付款单关联信息</returns>
        public virtual List <PostIncomeConfirmInfo> LoadForCreateBySOSysNo(int soSysNo, out SOBaseInfo soBaseInfo,
                                                                           out decimal remainAmt)
        {
            soBaseInfo = ExternalDomainBroker.GetSOBaseInfo(soSysNo);
            if (soBaseInfo == null)
            {
                throw new BizException(ResouceManager.GetMessageString("Invoice.PostPay", "PostPay_DeActiveOrderID"));
            }

            if (!PostPayBL.IsBankOrPostPayType(soBaseInfo.PayTypeSysNo.Value))
            {
                //throw new BizException("订单的付款类型不是银行电汇或邮局汇款");
                throw new BizException(ResouceManager.GetMessageString("Invoice.PostPay", "PostPay_OrderTypeError"));
            }

            var postIncomeList = PostIncomeBL.GetListBySOSysNoList(new List <int>()
            {
                soSysNo
            });

            if (postIncomeList == null || postIncomeList.Count == 0)
            {
                //throw new BizException("订单未找到有效的邮局电汇收款单");
                throw new BizException(ResouceManager.GetMessageString("Invoice.PostPay", "PostPay_DeActiveBill"));
            }
            var postIncomeInfo = postIncomeList[0];

            decimal incomeAmt       = postIncomeInfo.IncomeAmt ?? 0;
            decimal checkedOrderAmt = 0;
            decimal refundAmt       = 0;

            var confirmedOrderList = PostIncomeBL.GetConfirmedListByPostIncomeSysNo(postIncomeInfo.SysNo.Value);
            var soSysNoList        = confirmedOrderList.Where(w => w.Status == PostIncomeConfirmStatus.Audit)
                                     .Select(s => s.ConfirmedSoSysNo.Value)
                                     .ToList();

            var soList = ExternalDomainBroker.GetSOBaseInfoList(soSysNoList);

            checkedOrderAmt = soList.Sum(s => s.ReceivableAmount);

            refundAmt = PostPayBL.GetRefundAmtByConfirmedSOSysNoList(soSysNoList);

            //计算收款单剩余金额
            remainAmt = incomeAmt - checkedOrderAmt + refundAmt;

            return(confirmedOrderList);
        }
Beispiel #23
0
        public virtual int RefundPrepayCard(RefundPrepayCardInfo info)
        {
            SOIncomeRefundInfo entity = m_SOIncomeRefundDA.GetSOIncomeRefundByID(info.SOIncomeBankInfoSysNo.Value, info.CompanyCode);
            string             tNumber = string.Empty;
            decimal            refundAmt = 0M, payAmt = 0M;
            int    soSysNo = entity.SOSysNo.Value;
            string message = string.Empty;
            int    result  = 0;

            #region 业务验证
            if (entity == null)
            {
                ThrowBizException("SOIncomeRefund_NoRefundAudit", info.SOIncomeBankInfoSysNo.Value);
            }
            if (entity.Status != RefundStatus.Audit)
            {
                ThrowBizException("SOIncomeRefund_RefundStatusError", entity.OrderSysNo);
            }
            NetPayInfo netPay = null;
            SOBaseInfo so  = ExternalDomainBroker.GetSOBaseInfo(entity.SOSysNo.Value);
            //如果是子单,则需要查询母单对应的NetPay信息
            if (so.SOSplitMaster.HasValue)
            {
                soSysNo = so.SOSplitMaster.Value;
                netPay  = m_NetPayDA.GetValidBySOSysNo(soSysNo);
                if (netPay == null)
                {
                    ThrowBizException("SOIncomeRefund_NoMasterNetPay", entity.SOSysNo, soSysNo);
                }
                if (string.IsNullOrEmpty(netPay.ExternalKey))
                {
                    ThrowBizException("SOIncomeRefund_NoMasterExternalKey", entity.SOSysNo, soSysNo);
                }
                if (netPay.ExternalKey.Trim().Length == 0)
                {
                    ThrowBizException("SOIncomeRefund_MasterExternalKeyLengthError", entity.SOSysNo, soSysNo);
                }
            }

            //获取子单的NetPay信息
            netPay = m_NetPayDA.GetValidBySOSysNo(entity.SOSysNo.Value);
            if (netPay == null)
            {
                ThrowBizException("SOIncomeRefund_NoNetPay", entity.SOSysNo.Value);
            }
            //如果不是子单,则需要验证支付流水号
            if (!so.SOSplitMaster.HasValue)
            {
                if (string.IsNullOrEmpty(netPay.ExternalKey))
                {
                    ThrowBizException("SOIncomeRefund_NoExternalKey", entity.SOSysNo.Value);
                }
                if (netPay.ExternalKey.Trim().Length == 0)
                {
                    ThrowBizException("SOIncomeRefund_ExternalKeyLengthError", entity.SOSysNo.Value);
                }
            }

            tNumber = netPay.ExternalKey.Trim();

            List <SOIncomeInfo> list = m_SOIncomeDA.GetListByCriteria(null, entity.OrderSysNo, (SOIncomeOrderType)entity.OrderType, new List <SOIncomeStatus>());
            if (list == null || list.Count == 0)
            {
                ThrowBizException("SOIncomeRefund_NoIncomeInfo", entity.OrderSysNo);
            }

            SOIncomeInfo soIncome = list.Find(e => e.Status != SOIncomeStatus.Abandon);
            if (soIncome == null)
            {
                ThrowBizException("SOIncomeRefund_NoIncomeInfo", entity.OrderSysNo);
            }
            if (soIncome.Status == SOIncomeStatus.Confirmed)
            {
                ThrowBizException("SOIncomeRefund_HasConfirmed", entity.OrderSysNo);
            }
            #endregion

            refundAmt = entity.HaveAutoRMA.Value ? soIncome.IncomeAmt.Value : entity.RefundCashAmt.Value;
            payAmt    = netPay.PayAmount.Value;

            //如果存在多笔退款,则payamt应该取最后一次退款时的payamt
            if (m_SOIncomeRefundDA.GetRefundOrder(entity.SOSysNo.Value, entity.CompanyCode) > 1)
            {
                payAmt = m_SOIncomeRefundDA.GetPayAmountBeHis(entity.SOSysNo.Value, entity.CompanyCode);
            }

            payAmt = payAmt - refundAmt;

            #region 写请求日志
            RefundPointInfo log = new RefundPointInfo
            {
                RefundStatus    = RefundPointStatus.Origin,
                OrderType       = entity.OrderType,
                ReferenceID     = string.Format("{0}.{1}", entity.SysNo.Value, soIncome.SysNo.Value),
                PayAmt          = payAmt,
                InUser          = ExternalDomainBroker.GetUserInfoBySysNo(ServiceContext.Current.UserSysNo).UserDisplayName,
                EditDate        = DateTime.Now,
                CurrencySysNo   = 1,
                SOSysNo         = entity.SOSysNo,
                OrderAmt        = so.SOTotalAmount,
                ExternalKey     = netPay.ExternalKey,
                CompanyCode     = entity.CompanyCode,
                PayTypeSysNo    = so.PayTypeSysNo.Value,
                CreateUserSysNo = info.UserSysNo,
                OrderSysNo      = entity.OrderSysNo
            };

            int logSysNo = m_RefundPointDA.Insert(log);
            log.SysNo    = logSysNo;
            log.EditDate = DateTime.Now;
            log.EditUser = ExternalDomainBroker.GetUserInfoBySysNo(ServiceContext.Current.UserSysNo).UserDisplayName;
            #endregion

            #region 请求ThirdPartService,代理访问神州运通退款服务

            try
            {
                //退款状态:1.退款成功 2.退款失败(会直接抛出异常,不作特殊处理)3.神州运通需要进行人工处理
                result = ExternalDomainBroker.RefundPrepayCard(refundAmt, soSysNo, tNumber, log.ReferenceID);
                //退款成功
                if (result == 1)
                {
                    log.RefundStatus    = RefundPointStatus.Success;
                    log.ResponseContent = string.Empty;
                }
                //神州运运通需要进行人工处理,处理完成后调用Newegg的OPenAPI进行状态回写
                else if (result == 3)
                {
                    log.RefundStatus = RefundPointStatus.Processing;
                    message          = log.ResponseContent = "神州运通需要进行人工处理";
                }

                m_RefundPointDA.Update(log);

                if (result == 1)
                {
                    //更新收款单
                    m_RefundPointDA.UpdateSOIncome(log);
                }
            }
            catch (Exception ex)
            {
                result = -1;
                ExceptionHelper.HandleException(ex);
                log.RefundStatus    = RefundPointStatus.Failure;
                log.ResponseContent = string.Format("{0}|{1}", ex.Message, ex.StackTrace);
                //string errorInfo = string.Format("订单{0}远程异常:{1}", entity.OrderSysNo, ex.Message);
                string errorInfo = GetMessageString("SOIncomeRefund_OrderRemoteError", entity.OrderSysNo, ex.Message);
                throw new BizException(errorInfo);
            }

            #endregion

            return(result);
        }
Beispiel #24
0
 /// <summary>
 /// 作废拆分PostPay
 /// </summary>
 /// <param name="master"></param>
 /// <param name="subList"></param>
 public virtual void AbandonSplitForSO(SOBaseInfo master, List <SOBaseInfo> subList)
 {
     m_PostPayDA.AbandonSplitForSO(master, subList);
 }
Beispiel #25
0
 public virtual void CancelSplitSOPointLog(SOBaseInfo master, List <SOBaseInfo> subSoList)
 {
     ObjectFactory <PointProcessor> .Instance.CancelSplitSOPointLog(master.CustomerSysNo.Value, master, subSoList);
 }
Beispiel #26
0
        /// <summary>
        /// 如果是新客户的第一张订单,为推荐人增加经验值
        /// </summary>
        /// <param name="soInfo">订单</param>
        /// <param name="customerInfo">订单客户</param>
        public void AddExperienceByRecommend(SOInfo soInfo)
        {
            SOBaseInfo soBaseInfo = soInfo.BaseInfo;

            ECCentral.BizEntity.Customer.CustomerBasicInfo customerInfo = ExternalDomainBroker.GetCustomerInfo(soBaseInfo.CustomerSysNo.Value).BasicInfo;

            string companyCode = soInfo.CompanyCode;

            // 对象为空
            if (customerInfo == null || soInfo == null)
            {
                return;
            }

            // 该客户没有推荐人
            if (!customerInfo.RecommendedByCustomerSysNo.HasValue || customerInfo.RecommendedByCustomerSysNo.Value == 0)
            {
                return;
            }

            // 判断订单是否是该客户的第一张成功出库的订单
            if (!SODA.IsFirstSO(soInfo.SysNo.Value, soBaseInfo.CustomerSysNo.Value))
            {
                return;
            }


            // 获取推荐人信息
            ECCentral.BizEntity.Customer.CustomerBasicInfo rmdCustomerInfo = ExternalDomainBroker.GetCustomerInfo(customerInfo.RecommendedByCustomerSysNo.Value).BasicInfo;

            // 没有相应的推荐人信息
            if (rmdCustomerInfo == null)
            {
                return;
            }

            // 推荐人不能是客户自己
            if (customerInfo.CustomerSysNo == rmdCustomerInfo.CustomerSysNo)
            {
                return;
            }

            // 如果推荐人被禁用,不对其增加经验值
            if (rmdCustomerInfo.Status.Value == BizEntity.Customer.CustomerStatus.InValid)
            {
                return;
            }

            // 订单金额
            decimal soAmount = soBaseInfo.CashPay + soBaseInfo.PayPrice.Value + soBaseInfo.ShipPrice.Value + soBaseInfo.PremiumAmount.Value + soBaseInfo.PromotionAmount.Value;
            // 推荐人经验值的增加数量为订单金额的10%
            decimal rate          = AppSettingHelper.RecommendExperienceRatio;
            decimal addExperience = decimal.Round(soAmount * rate, 0); // 应该增加的经验值,4舍5入到整数

            // 如果增加值<1,
            if (addExperience > 0)
            {
                string logMemo = string.Format("SO#{0}:引荐新用户,首次购物成功,加经验值。", soInfo.SysNo);
                ExternalDomainBroker.AdjustCustomerExperience(rmdCustomerInfo.CustomerSysNo.Value, addExperience, BizEntity.Customer.ExperienceLogType.Recommend, logMemo);
                ObjectFactory <SOSendMessageProcessor> .Instance.RecommendCustomerAddExperienceSendMail(rmdCustomerInfo, customerInfo.CustomerID, addExperience);
            }
        }
Beispiel #27
0
        /// <summary>
        /// 根据订单中的商品编号取得此商品的赠品列表
        /// </summary>
        /// <param name="soSysNo">订单编号</param>
        /// <param name="productSysNo">商品编号</param>
        /// <returns>赠品列表</returns>
        public List <SOItemInfo> GetGiftBySOProductSysNo(int soSysNo, int productSysNo) //IPP3:OverseaOrderManagement].[dbo].[UP_OM_GetGiftInfo]
        {
            SOProcessor       processor  = ObjectFactory <SOProcessor> .Instance;
            SOBaseInfo        soBaseInfo = processor.GetSOBaseInfoBySOSysNo(soSysNo);
            List <SOItemInfo> giftList   = new List <SOItemInfo>();

            if (soBaseInfo.SOType != SOType.Gift)
            {
                List <SOInfo> soList      = null;
                List <int>    soSysNoList = new List <int>();
                if (soBaseInfo.Status == SOStatus.Split)
                {
                    soList = processor.GetSubSOByMasterSOSysNo(soSysNo);
                }
                else
                {
                    soSysNoList.Add(soSysNo);
                }
                soList = soList ?? new List <SOInfo>();

                // 如果订单的赠品(指购买订单,送给客户的商品,但此商品并没有一起同订单发给客户,请与赠品规则的赠品,厂商赠品,附件相区分。),且赠品已经下单,则取得订单的赠品的订单编号
                List <SOLogInfo> logList = new List <SOLogInfo>();
                if (soList.Count > 0)
                {
                    soList.ForEach(so =>
                    {
                        List <SOLogInfo> t = ObjectFactory <SOLogProcessor> .Instance.GetSOLogBySOSysNoAndLogType(soSysNo, BizEntity.Common.BizLogType.Sale_SO_CreateGiftSO);
                        if (t != null && t.Count > 0)
                        {
                            logList.AddRange(t);
                        }
                    });
                }

                if (logList.Count > 0)
                {
                    logList.ForEach(l =>
                    {
                        int no = int.TryParse(l.Note, out no) ? no : 0;
                        if (no != 0)
                        {
                            soSysNoList.Add(no);
                        }
                    });
                }
                var tso = processor.GetSOBySOSysNoList(soSysNoList);
                if (tso != null && tso.Count > 0)
                {
                    soList.AddRange(tso);
                }
                soList.ForEach(so =>
                {
                    List <SOItemInfo> tgList = null;
                    if (so.BaseInfo.SOType == SOType.Gift)
                    {
                        tgList = (from item in so.Items
                                  where String.Format(",{0},", item.MasterProductSysNo).IndexOf(String.Format(",{0},", productSysNo)) >= 0
                                  select item).ToList();
                    }
                    else
                    {
                        List <SOPromotionInfo.GiftInfo> gList = (from p in so.SOPromotions
                                                                 from pd in p.SOPromotionDetails
                                                                 from g in p.GiftList
                                                                 where pd.MasterProductSysNo == productSysNo && (p.PromotionType == SOPromotionType.Accessory || p.PromotionType == SOPromotionType.SelfGift || p.PromotionType == SOPromotionType.VendorGift)
                                                                 select g).ToList();
                        tgList = (from item in so.Items
                                  join g in gList on item.ProductSysNo equals g.ProductSysNo
                                  select item).ToList();
                    }
                    if (tgList != null && tgList.Count > 0)
                    {
                        giftList.AddRange(tgList);
                    }
                });
            }
            return(giftList);
        }
Beispiel #28
0
        /// <summary>
        /// 创建netpay预检查
        /// </summary>
        /// <param name="netpayEntity"></param>
        protected virtual void PreCheckForCreate(NetPayInfo netpayEntity, SOIncomeRefundInfo refundEntity, SOBaseInfo soBaseInfo, bool isForceCheck)
        {
            //1.输入的订单的支付方式要与订单中的支付方式一致
            if (netpayEntity.PayTypeSysNo != soBaseInfo.PayTypeSysNo)
            {
                ThrowBizException("NetPay_PayTypeNotSame");
            }

            //2.需要提供验证订单的付款方式是不是“网上支付”
            if (!IsNetPayType(soBaseInfo.PayTypeSysNo.Value, soBaseInfo.SysNo.Value))
            {
                ThrowBizException("NetPay_SOPayTypeIsNotNet");
            }

            //3.检查订单是否已经存在有效的网上支付信息
            if (GetValidBySOSysNo(netpayEntity.SOSysNo.Value) != null)
            {
                ThrowBizException("NetPay_AlreadyExistValidRecord");
            }

            #region 检查旧NetPay余额是否够创建新的NetPay

            SOBaseInfo originalSO = ExternalDomainBroker.GetSOBaseInfo(netpayEntity.RelatedSoSysNo.Value);
            if (originalSO == null)
            {
                ThrowBizException("NetPay_PreCheckForCreate_SONotExist", netpayEntity.RelatedSoSysNo);
            }
            if (netpayEntity.SOSysNo != netpayEntity.RelatedSoSysNo.Value)
            {
                if ((int)originalSO.Status > 0)//原订单没有被作废
                {
                    ThrowBizException("NetPay_RelatedSONotAbandon");
                }

                if (GetValidBySOSysNo(netpayEntity.RelatedSoSysNo.Value) != null)
                {
                    ThrowBizException("NetPay_RelatedSONetPayExist");
                }
            }

            //验证规则:原订单核收金额合计加当前核收金额大于原订单金额,请修改该输入的订单金额
            //2012-06-13 freegod:人工输入的不再检查。
            decimal?          totalReceivableAmt  = netpayEntity.PayAmount;
            SOBaseInfo        tempSo              = null;
            List <NetPayInfo> relatedSoNetPayList = m_NetpayDA.GetListByRelatedSoSysNo(netpayEntity.RelatedSoSysNo.Value);
            if (relatedSoNetPayList != null && relatedSoNetPayList.Count > 0)
            {
                relatedSoNetPayList.ForEach(relatedNetPay =>
                {
                    tempSo              = ExternalDomainBroker.GetSOBaseInfo(relatedNetPay.SOSysNo.Value);
                    totalReceivableAmt += tempSo.ReceivableAmount;
                });
            }

            //获取最后一笔作废的NetPay记录
            NetPayInfo lastAboundNetPay = m_NetpayDA.GetLastAboundedByRelatedSoSysNo(netpayEntity.RelatedSoSysNo.Value);
            if (lastAboundNetPay != null)
            {
                decimal avalAmount = lastAboundNetPay.PayAmount.Value;

                //关联原订单的金额合计总和大于原订单的金额,请修改该输入的订单金额
                if (totalReceivableAmt > avalAmount)
                {
                    ThrowBizException("NetPay_RelatedSOAmtNotEnough"
                                      , (totalReceivableAmt.Value - netpayEntity.PayAmount.Value).ToString(InvoiceConst.StringFormat.CurrencyFormat),
                                      netpayEntity.PayAmount.Value.ToString(InvoiceConst.StringFormat.CurrencyFormat), avalAmount.ToString(InvoiceConst.StringFormat.CurrencyFormat));
                }
            }

            #endregion 检查旧NetPay余额是否够创建新的NetPay

            #region 强制核收数据检查

            if (netpayEntity.PayAmount < soBaseInfo.ReceivableAmount)
            {
                ThrowBizException("NetPay_PayAmoutNotEnoughNotAllowCheck");
            }
            if (isForceCheck && netpayEntity.PayAmount == soBaseInfo.ReceivableAmount)
            {
                ThrowBizException("NetPay_NotAllowForceCheck");
            }
            if (!isForceCheck && netpayEntity.PayAmount > soBaseInfo.ReceivableAmount)
            {
                ThrowBizException("NetPay_MustChooseForceCheck");
            }
            if (isForceCheck && (refundEntity.RefundCashAmt ?? 0) <= 0M)
            {
                ThrowBizException("NetPay_ForceCheckReturnAmt");
            }
            if (isForceCheck && Math.Abs(refundEntity.ToleranceAmt ?? 0) > 0.1M)
            {
                ThrowBizException("NetPay_ForceCheckToleranceAmt");
            }

            #endregion 强制核收数据检查
        }
Beispiel #29
0
        /// <summary>
        /// 创建前预检查
        /// TODO:重写该方法添加额外的检查。中蛋实施时需要检查[货到付款(OZZO奥硕物流)和现金支付才可以选择现金退款]
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="refundInfo"></param>
        /// <param name="isForceCheck"></param>
        protected virtual void PreCheckForCreate(PostPayInfo entity, SOIncomeRefundInfo refundInfo, SOBaseInfo soBaseInfo, bool isForceCheck)
        {
            if (soBaseInfo.PayTypeSysNo != entity.PayTypeSysNo.Value)
            {
                ThrowBizException("PostPay_PayTypeNotMachSO");
            }

            decimal soEndMoney            = soBaseInfo.ReceivableAmount;
            var     postIncomeConfirmList = ObjectFactory <PostIncomeProcessor> .Instance.GetConfirmedListBySOSysNo(entity.SOSysNo.ToString());

            if (postIncomeConfirmList.Count == 0)
            {
                ThrowBizException("PostPay_NotExistSOValidPostIncome", entity.SOSysNo.ToString());
            }

            var postIncome = ObjectFactory <PostIncomeProcessor> .Instance.LoadBySysNo(postIncomeConfirmList[0].PostIncomeSysNo.Value);

            if (postIncome == null || postIncome.HandleStatus != PostIncomeHandleStatus.Handled)
            {
                ThrowBizException("PostPay_StatusNotMatchHandled");
            }

            postIncomeConfirmList = postIncome.ConfirmInfoList;
            var relatedConfirmList = postIncomeConfirmList.Where(w => w.Status == PostIncomeConfirmStatus.Related).Select(s => s);

            if (isForceCheck && relatedConfirmList.Count() > 1)
            {
                ThrowBizException("PostPay_HasAnotherUnConfirmedSO");
            }
            //强制核收时,实收金额必须与剩余金额一致
            if (isForceCheck && relatedConfirmList.Count() == 1)
            {
                if (entity.RemainAmt != entity.PayAmount)
                {
                    ThrowBizException("PostPay_ForcePayNotMatchAmt");
                }
            }
            //CS核收订单的退款金额,负值
            var confirmOrderList = postIncomeConfirmList.Where(w => w.Status == PostIncomeConfirmStatus.Audit).ToList();
            //取得已确认的多付金额
            decimal refundamt = GetRefundAmtByConfirmedSOSysNoList(confirmOrderList.Select(s => s.ConfirmedSoSysNo.Value).ToList());

            if (soEndMoney > entity.PayAmount)
            {
                ThrowBizException("PostPay_IncomeAmtLessThanSOAmt");
            }
            if (soEndMoney == entity.PayAmount && isForceCheck)
            {
                ThrowBizException("PostPay_CannotForcePay");
            }
            if (soEndMoney < entity.PayAmount && !isForceCheck)
            {
                ThrowBizException("PostPay_IncomeAmtMoreThanSOAmt");
            }
            if (entity.RemainAmt < entity.PayAmount)
            {
                ThrowBizException("PostPay_IncomeAmtMoreThanRemainAmt");
            }
            if (isForceCheck && refundInfo.RefundCashAmt <= 0)
            {
                ThrowBizException("PostPay_RefundCashAmtRequired");
            }
            if (isForceCheck && Math.Abs(refundInfo.ToleranceAmt ?? 0) > 0.1M)
            {
                ThrowBizException("PostPay_ToleranceAmtNotCorrect");
            }

            //减去核收订单的退款金额
            decimal incomeAmt = postIncome.IncomeAmt.Value + refundamt;
            decimal totalAmt  = soEndMoney;

            if (soEndMoney > incomeAmt || incomeAmt < 0)
            {
                ThrowBizException("PostPay_IncomeAmtMoreThanPostIncomeAmt");
            }
            foreach (var order in confirmOrderList)
            {
                totalAmt += GetTotalAmt(order.ConfirmedSoSysNo.Value);
            }

            if (totalAmt > incomeAmt)
            {
                ThrowBizException("PostPay_TotalAmtMoreThanPostIncomeAmt");
            }

            if (isForceCheck)
            {
                var list = ObjectFactory <SOIncomeProcessor> .Instance.GetListByCriteria(entity.SOSysNo, null, SOIncomeOrderType.OverPayment, null);

                if (list != null)
                {
                    var result = list.FindAll(p => p.Status != SOIncomeStatus.Abandon);
                    if (result != null && result.Count > 0)
                    {
                        ThrowBizException("PostPay_MOExists");
                    }
                }
            }
        }
Beispiel #30
0
        public virtual void VerifyCustomerAddPointRequset(CustomerPointsAddRequest requset)
        {
            if (requset.SysNo <= 0)
            {
                throw new BizException(ResouceManager.GetMessageString("Customer.CustomerPointsAddRequest", "AuditRequest_SONotFound"));
            }
            //审核人和申请人不能相同
            //if (requset.ConfirmUserSysNo == requset.CreateUserSysNo)
            //{
            //    throw new BizException(ResouceManager.GetMessageString("Customer.CustomerPointsAddRequest", "AuditRequest_ComfirmEqualCreate"));
            //}
            if (requset.Status == CustomerPointsAddRequestStatus.AuditDenied)
            {
                string            to    = ExternalDomainBroker.GetUserInfoBySysNo(requset.CreateUserSysNo).EmailAddress;
                KeyValueVariables param = new KeyValueVariables();
                param.Add("RequestSysNo", requset.SysNo);
                param.Add("Reasion", requset.ConfirmNote);
                using (TransactionScope scope = new TransactionScope())
                {
                    ObjectFactory <IPointDA> .Instance.ConfirmRequest(requset);

                    ECCentral.Service.Utility.EmailHelper.SendEmailByTemplate(to, "CustomerPointAddRequest_AuditDenied", param, true);
                    scope.Complete();
                }
                return;
            }
            else if (requset.Status == CustomerPointsAddRequestStatus.AuditPassed)
            {
                if (requset.PointsItemList != null && requset.PointsItemList.Count > 0)
                {
                    SOBaseInfo soInfo = ExternalDomainBroker.GetSOBaseInfo(requset.SOSysNo.Value);
                    if (soInfo == null)
                    {
                        throw new BizException(ResouceManager.GetMessageString("Customer.CustomerPointsAddRequest", "SOStatusNotFound"));
                    }

                    if (ExternalDomainBroker.GetAutoRMARefundCountBySOSysNo(requset.SOSysNo.Value) > 0)//出库后被物流拒收也视为未出库
                    {
                        throw new BizException(ResouceManager.GetMessageString("Customer.CustomerPointsAddRequest", "SOStatusNotOutStock"));
                    }
                    SOIncomeInfo soincomeinfo = ExternalDomainBroker.GetConfirmedSOIncomeInfo(requset.SOSysNo.Value, SOIncomeOrderType.SO);
                    if (soincomeinfo == null)
                    {
                        throw new BizException(ResouceManager.GetMessageString("Customer.CustomerPointsAddRequest", "SOIncomeNotComfirmed"));
                    }
                    if (soInfo.Status != SOStatus.OutStock && SOIncomeStatus.Confirmed != soincomeinfo.Status)
                    {
                        throw new BizException(ResouceManager.GetMessageString("Customer.CustomerPointsAddRequest", "SOStatusNotOutStockAndSOIncomeNotComfirmed"));
                    }
                    else if (soInfo.Status != SOStatus.OutStock)
                    {
                        throw new BizException(ResouceManager.GetMessageString("Customer.CustomerPointsAddRequest", "SOStatusNotOutStock"));
                    }
                    else if (soincomeinfo.Status != SOIncomeStatus.Confirmed)
                    {
                        throw new BizException(ResouceManager.GetMessageString("Customer.CustomerPointsAddRequest", "SOIncomeNotComfirmed"));
                    }
                }
                using (TransactionScope scope = new TransactionScope())
                {
                    //1.为顾客加积分
                    AdjustPointRequest pointAdjust = new AdjustPointRequest();
                    pointAdjust.CustomerSysNo = requset.CustomerSysNo;
                    pointAdjust.Memo          = ResouceManager.GetMessageString("Customer.CustomerPointsAddRequest", "PointAddMemo_ManulAdjust");
                    pointAdjust.OperationType = AdjustPointOperationType.AddOrReduce;
                    pointAdjust.Point         = requset.Point;
                    pointAdjust.PointType     = requset.PointType;
                    pointAdjust.SOSysNo       = requset.SOSysNo;
                    pointAdjust.Source        = "CustomerMgmt";
                    Adjust(pointAdjust);
                    //1.将申请单审核通过
                    ObjectFactory <IPointDA> .Instance.ConfirmRequest(requset);

                    scope.Complete();
                }
            }
        }