/// <summary> /// 退款预检查.必须有退款调整单且状态为待审核&必须由退款调整单单据且状态为审核通过。 /// </summary> /// <param name="entity"></param> /// <param name="soBaseInfo"></param> /// <param name="refundBalanceInfo"></param> private void VerifyForRefund(RefundBalanceInfo entity, out SOInfo soInfo, out RefundBalanceInfo refundBalanceInfo) { refundBalanceInfo = GetRefundBalanceBySysNo(entity.SysNo.Value); if (refundBalanceInfo == null) { throw new BizException(ResouceManager.GetMessageString("RMA.RefundBalance", "RefundBalanceNotExists")); } if (refundBalanceInfo.Status != RefundBalanceStatus.WaitingRefund) { throw new BizException(ResouceManager.GetMessageString("RMA.RefundBalance", "Refund_RefundBalanceStatusValid")); } if (refundBalanceInfo.CashAmt == null) { throw new BizException(ResouceManager.GetMessageString("RMA.RefundBalance", "CashAmtRequired")); } if (refundBalanceInfo.CashAmt.Value >= 0) { SOIncomeRefundInfo incomeBankInfo = ExternalDomainBroker.GetSOIncomeRefundInfo(entity.SysNo.Value, RefundOrderType.RO_Balance); if (incomeBankInfo == null) { throw new BizException(ResouceManager.GetMessageString("RMA.RefundBalance", "Refund_SOIncomeRefundInfoValid")); } else if (incomeBankInfo.Status != ECCentral.BizEntity.Invoice.RefundStatus.Audit) { throw new BizException(ResouceManager.GetMessageString("RMA.RefundBalance", "Refund_SOIncomeStatusValid")); } } soInfo = ExternalDomainBroker.GetSOInfo(entity.OriginalSOSysNo.Value); if (soInfo == null) { throw new BizException(ResouceManager.GetMessageString("RMA.RefundBalance", "SONotExists")); } }
/// <summary> /// CS审核拒绝退款单前预检查 /// </summary> protected void PreCheckForCSReject(SOIncomeRefundInfo entity) { if (entity.Status != RefundStatus.Origin) { ThrowBizException("SOIncomeRefund_CanNotAbandon"); } }
/// <summary> /// 审核RMA物流拒收 /// </summary> /// <param name="entity"></param> public virtual void AuditAutoRMA(int sysNo) { //使用DB中的数据验证业务逻辑 SOIncomeRefundInfo entity = LoadBySysNo(sysNo); //RMA物流拒收并且状态为"待RMA退款" if (entity.HaveAutoRMA == false) { ThrowBizException("SOIncomeRefund_AuditAutoRMA_NotShipRejected"); } if (entity.Status != RefundStatus.WaitingRefund) { ThrowBizException("SOIncomeRefund_AuditAutoRMA_NotWaitingRefund"); } //根据退款单号查询退款金额,并计算积分 var roEntity = ExternalDomainBroker.GetRefundBySysNo(entity.OrderSysNo.Value); entity.RefundPoint = roEntity.PointAmt - roEntity.DeductPointFromAccount; entity.RefundCashAmt = roEntity.CashAmt; entity.Status = RefundStatus.Origin; //TODO:重写方法,判断第三方订单支付方式,比如如果是淘宝订单该作何处理 AuditAutoRMAForThirdSO(entity); m_SOIncomeRefundDA.Update(entity); }
/// <summary> /// 创建销售退款单 /// </summary> /// <param name="entity">退款信息</param> /// <param name="payAmt">实收金额,如果实收金额大于0,则优先退还现金</param> public virtual SOIncomeRefundInfo Create(SOIncomeRefundInfo entity) { PreCheckForCreate(entity); SOIncomeRefundInfo result = new SOIncomeRefundInfo(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, options)) { if (entity.OrderType == RefundOrderType.OverPayment) { ObjectFactory<SOIncomeProcessor>.Instance.CreateNegative(entity); } result = m_SOIncomeRefundDA.Create(entity); //发送cs审核退款审核Message EventPublisher.Publish(new CreateSOIncomeRefundInfoMessage() { SOIncomeRefundSysNo = result.SysNo.Value, CurrentUserSysNo = ServiceContext.Current.UserSysNo }); ts.Complete(); } return result; }
/// <summary> /// 退款转礼品卡成功则像客户发送一封邮件 /// </summary> /// <param name="entity"></param> /// <param name="giftCardResultCode"></param> protected virtual void SendGiftCardEmail(SOIncomeRefundInfo entity, string giftCardResultCode) { int code = 0; if (int.TryParse(giftCardResultCode, out code) && code == 0) { var customer = ExternalDomainBroker.GetCustomerBasicInfo(entity.CustomerSysNo.Value); KeyValueVariables vars = new KeyValueVariables(); vars.Add("CustomerID", customer.CustomerID); vars.Add("TotalValue", entity.RefundCashAmt.Value); vars.Add("ExpireYear", DateTime.Now.AddYears(2).Year); vars.Add("ExpireMonth", DateTime.Now.Month); vars.Add("ExpireDay", DateTime.Now.Day); vars.Add("Year", DateTime.Now.Year); EmailHelper.SendEmailByTemplate(customer.Email, "Refund_GiftCard_Notify", vars, true, customer.FavoriteLanguageCode); } else { //记录操作日志 ObjectFactory<ICommonBizInteract>.Instance.CreateOperationLog( GetMessageString("SOIncomeRefund_Log_GiftCardRefundFailed", entity.SOSysNo.Value) , BizLogType.AuditRefund_Update , entity.SysNo.Value , entity.CompanyCode); ThrowBizException("SOIncomeRefund_Log_GiftCardRefundFailed", entity.SOSysNo.Value); } }
/// <summary> /// CS审核退款单前预检查 /// </summary> /// <param name="entity"></param> protected virtual void PreCheckForCSAudit(SOIncomeRefundInfo entity, SOIncomeRefundInfo info) { ////创建人,客服审核人,财务审核人不能相同 //if (entity.CreateUserSysNo == info.AuditUserSysNo) //{ // ThrowBizException("SOInComeRefund_CSAudit_CreateUserAndAuditUserCanNotSame"); //} if (entity.Status != RefundStatus.Origin) { ThrowBizException("SOIncomeRefund_CSAudit_CanNotAudit"); } //多付款退款单需要NetPay或邮局电汇审核通过后才能进行审核 if (entity.OrderType == RefundOrderType.OverPayment) { NetPayInfo netPayQueryCriteria = new NetPayInfo { SOSysNo = entity.SOSysNo, Status = NetPayStatus.Approved }; List<NetPayInfo> netPayList = ObjectFactory<NetPayProcessor>.Instance.GetListByCriteria(netPayQueryCriteria); if (netPayList.Count == 0) { List<PostPayInfo> postPayList = ObjectFactory<PostPayProcessor>.Instance.GetListBySOSysNoAndStatus(entity.SOSysNo.Value, PostPayStatus.Yes, PostPayStatus.Splited); if (postPayList.Count == 0) { ThrowBizException("SOIncomeRefund_CSAudit_NoValidNetPayOrPostPay"); } } } }
/// <summary> /// 强制核收时创建多付退款单 /// </summary> /// <param name="netpayEntity">支付信息实体</param> /// <param name="refundEntity">退款信息实体</param> private void CreateRefundInfoForForceCheck(NetPayInfo netpayEntity, SOIncomeRefundInfo refundEntity) { refundEntity.RefundPoint = 0; refundEntity.RefundReason = 5; //客户多付款 refundEntity.HaveAutoRMA = false; //非物流拒收 refundEntity.Status = RefundStatus.Origin; refundEntity.OrderType = RefundOrderType.OverPayment; refundEntity.SOSysNo = netpayEntity.SOSysNo; refundEntity.OrderSysNo = netpayEntity.SOSysNo; //查询是否已经存在退款信息 var refundList = ObjectFactory <SOIncomeRefundProcessor> .Instance.GetListByCriteria(new SOIncomeRefundInfo() { OrderSysNo = netpayEntity.SOSysNo.Value, OrderType = RefundOrderType.OverPayment }); if (refundList != null && refundList.Count > 0) { refundEntity.SysNo = refundList[0].SysNo; ObjectFactory <SOIncomeRefundProcessor> .Instance.Update(refundEntity); } else { refundEntity.PayAmount = netpayEntity.PayAmount; ObjectFactory <SOIncomeRefundProcessor> .Instance.Create(refundEntity); } }
/// <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); }
/// <summary> /// CS审核拒绝退款单 /// </summary> public virtual void CSReject(int sysNo) { SOIncomeRefundInfo entity = LoadBySysNo(sysNo); PreCheckForCSReject(entity); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { m_SOIncomeRefundDA.UpdateStatus(sysNo, ServiceContext.Current.UserSysNo, RefundStatus.Abandon, DateTime.Now); //发送cs审核退款审核Message EventPublisher.Publish(new RefundCSCancelAuditMessage() { RefundSysNo = sysNo, CurrentUserSysNo = ServiceContext.Current.UserSysNo }); scope.Complete(); } ObjectFactory<ICommonBizInteract>.Instance.CreateOperationLog( GetMessageString("SOIncomeRefund_Log_CSReject", ServiceContext.Current.UserSysNo, entity.SysNo) , BizLogType.AuditRefund_Update , entity.SysNo.Value , entity.CompanyCode); }
/// <summary> /// RO作废退款单预先检查 /// </summary> /// <param name="sysNo"></param> protected virtual void PreCheckAbandonForRO(int sysNo) { SOIncomeRefundInfo entity = LoadBySysNo(sysNo); if (!(entity.Status == RefundStatus.WaitingRefund || entity.Status == RefundStatus.Origin)) { ThrowBizException("SOIncomeRefund_NotWaitRefundAbandonFailed"); } }
/// <summary> /// 创建网上支付信息 /// </summary> /// <param name="input">待创建的网上支付信息</param> /// <returns>创建后的网上支付信息</returns> public virtual NetPayInfo Create(NetPayInfo netpayEntity, SOIncomeRefundInfo refundEntity, bool isForceCheck) { if (netpayEntity.SOSysNo == null) { throw new ArgumentNullException("netpayEntity.SOSysNo"); } return(ObjectFactory <NetPayProcessor> .Instance.Create(netpayEntity, refundEntity, isForceCheck)); }
public NetPayInfo CreateNetPay(CheckNetPayReq request) { NetPayInfo netPayInfo = null; SOIncomeRefundInfo refundInfo = null; request.Convert(out netPayInfo, out refundInfo); return(ObjectFactory <NetPayAppService> .Instance.Create(netPayInfo, refundInfo, request.IsForceCheck.Value)); }
public ActionResult AjaxSOVoid() { SOIncomeRefundInfo refundInfo = SerializationUtility.JsonDeserialize2 <SOIncomeRefundInfo>(Request.Form["data"]); LoginUser user = EntityConverter <UserAuthVM, LoginUser> .Convert(UserAuthHelper.GetCurrentUser()); SOService.VoidSO(refundInfo.SOSysNo.Value, refundInfo, loginUser: user); return(new JsonResult()); }
/// <summary> /// ROBalance作废退款单预先检查 /// </summary> /// <param name="sysNo"></param> protected virtual void PreCheckAbandonForROBalance(int sysNo) { SOIncomeRefundInfo entity = LoadBySysNo(sysNo); if (entity.Status != RefundStatus.Origin) { ThrowBizException("SOIncomeRefund_CanNotAbandon"); } }
/// <summary> /// RO取消提交审核预先检查 /// </summary> /// <param name="sysNo"></param> protected virtual void PreCheckCancelSubmitAuditForRO(int sysNo) { SOIncomeRefundInfo entity = LoadBySysNo(sysNo); if (entity.Status != RefundStatus.Origin && entity.OrderType != RefundOrderType.RO) { ThrowBizException("SOIncomeRefund_CanNotCancelSubmitAudit"); } }
/// <summary> /// 更新退款单 /// </summary> /// <param name="entity"></param> public virtual void Update(SOIncomeRefundInfo entity) { DataCommand cmd = DataCommandManager.GetDataCommand("UpateSOIncomeRefund"); cmd.SetParameterValue(entity); cmd.ExecuteNonQuery(); }
/// <summary> /// RO提交审核预先检查 /// </summary> /// <param name="sysNo"></param> protected virtual void PreCheckForSubmitAuditForRO(int sysNo) { SOIncomeRefundInfo entity = LoadBySysNo(sysNo); if (entity.Status != RefundStatus.WaitingRefund) { ThrowBizException("SOIncomeRefund_CanNotSubmitAudit"); } }
/// <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); }
public void CreatePostPay(CheckPostPayReq request) { SOIncomeRefundInfo refundInfo = null; PostPayInfo postpayInfo = null; request.Convert(out postpayInfo, out refundInfo); ObjectFactory <PostPayAppService> .Instance.Create(postpayInfo, refundInfo, request.IsForceCheck.Value); }
/// <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); }
/// <summary> /// 获得单个财务退款单 /// </summary> /// <param name="sysNo"></param> /// <returns></returns> public virtual SOIncomeRefundInfo LoadBySysNo(int sysNo) { SOIncomeRefundInfo refundInfo = m_SOIncomeRefundDA.LoadBySysNo(sysNo); if (refundInfo != null) { return refundInfo; } ThrowBizException("SOIncomeRefund_RecordNotExist", sysNo); return null; }
/// <summary> /// 创建退款单 /// </summary> /// <param name="input"></param> /// <returns></returns> public virtual SOIncomeRefundInfo Create(SOIncomeRefundInfo input) { DataCommand cmd = DataCommandManager.GetDataCommand("CreateAuditRefund"); cmd.SetParameterValue <SOIncomeRefundInfo>(input); int sysNo = Convert.ToInt32(cmd.ExecuteScalar()); return(LoadBySysNo(sysNo)); }
/// <summary> /// 为强制核收创建退款信息 /// </summary> /// <param name="postpayEntity"></param> /// <param name="refundEntity"></param> /// <param name="soIncomeSysNo"></param> private void CreateRefundInfoForForceCheck(PostPayInfo postpayEntity, SOIncomeRefundInfo refundEntity) { refundEntity.OrderSysNo = postpayEntity.SOSysNo.Value; refundEntity.OrderType = RefundOrderType.OverPayment; refundEntity.SOSysNo = postpayEntity.SOSysNo.Value; //如果是现金退款,则直接审核通过 if (refundEntity.RefundPayType.Value == RefundPayType.CashRefund) { refundEntity.Status = RefundStatus.Audit; } else { refundEntity.Status = RefundStatus.Origin; } if (refundEntity.RefundPayType == RefundPayType.TransferPointRefund) { refundEntity.RefundPoint = int.Parse(refundEntity.RefundCashAmt.Value.ToString()); refundEntity.RefundCashAmt = 0; } else { refundEntity.RefundCashAmt = refundEntity.RefundCashAmt ?? 0; refundEntity.RefundPoint = 0; } //客户多付款 refundEntity.RefundReason = 5; //非物流拒收 refundEntity.HaveAutoRMA = false; var list = ObjectFactory <SOIncomeRefundProcessor> .Instance.GetListByCriteria(new SOIncomeRefundInfo { OrderSysNo = postpayEntity.SOSysNo, OrderType = RefundOrderType.OverPayment }); if (list != null && list.Count > 0) { refundEntity.SysNo = list[0].SysNo; if (refundEntity.OrderType == RefundOrderType.OverPayment) { //创建财务负收款单 refundEntity.PayAmount = postpayEntity.PayAmount; ObjectFactory <SOIncomeProcessor> .Instance.CreateNegative(refundEntity); } ObjectFactory <SOIncomeRefundProcessor> .Instance.Update(refundEntity); } else { refundEntity.PayAmount = postpayEntity.PayAmount; ObjectFactory <SOIncomeRefundProcessor> .Instance.Create(refundEntity); } }
/// <summary> /// 根据退款调整单系统编号获取退款单信息 /// </summary> /// <param name="sysNo"></param> /// <returns></returns> public virtual RefundBalanceInfo LoadRefundBalanceBySysNo(int sysNo) { SOIncomeRefundInfo soIncomRefundInfo = new SOIncomeRefundInfo(); RefundBalanceInfo refundBalanceInfo = GetRefundBalanceBySysNo(sysNo); soIncomRefundInfo = ExternalDomainBroker.GetSOIncomeRefundInfo(sysNo, RefundOrderType.RO_Balance); refundBalanceInfo.IncomeBankInfo = soIncomRefundInfo; refundBalanceInfo.CustomerID = ExternalDomainBroker.GetCustomerBasicInfo(refundBalanceInfo.CustomerSysNo.Value).CustomerID; return(refundBalanceInfo); }
protected override void CreateAOAndAbandonSO(SOIncomeInfo soIncomeInfo, SOIncomeRefundInfo soIncomeRefundInfo) { // 下面类型订单不用创建负收款单 if (!NeedCreateAO(CurrentSO.BaseInfo.SpecialSOType)) { Abandon(); } else { base.CreateAOAndAbandonSO(soIncomeInfo, soIncomeRefundInfo); } }
/// <summary> /// 财务审核退款单前预检查 /// </summary> /// <param name="entity"></param> protected void PreCheckForFinAudit(SOIncomeRefundInfo entity, SOIncomeRefundInfo info) { //创建人,客服审核人,财务审核人不能相同 //if (entity.CreateUserSysNo == info.AuditUserSysNo) //{ // ThrowBizException("SOInComeRefund_CSAudit_CreateUserAndAuditUserCanNotSame"); //} if (entity.Status != RefundStatus.WaitingFinAudit) { ThrowBizException("SOIncomeRefund_FinAudit_StatusNotMatchWaitingFinAudit"); } }
/// <summary> /// 创建预检查 /// </summary> /// <param name="entity"></param> protected virtual void PreCheckForCreate(SOIncomeRefundInfo entity) { //现在执行非空数据检查 CheckRequiredFields(entity); //如果单据类型是AO或多付款退款,则不允许"转积分退款" if ((entity.OrderType == RefundOrderType.AO || entity.OrderType == RefundOrderType.OverPayment) && entity.RefundPayType == RefundPayType.TransferPointRefund) { ThrowBizException("SOIncomeRefund_CanNotTransferPoint"); } }
/// <summary> /// 财务审核拒绝退款单前预检查 /// </summary> /// <param name="entity"></param> protected void PreCheckForFinReject(SOIncomeRefundInfo entity, string appendFinNote) { if (entity.Status != RefundStatus.WaitingFinAudit) { ThrowBizException("SOIncomeRefund_FinReject_StatusNotMatchWaitingFinAudit"); } if (entity.FinNote.EmptyIfNull().Length + appendFinNote.EmptyIfNull().Length > 500) { ThrowBizException("SOIncomeRefund_FinNoteLengthMoreThan500"); } }
/// <summary> /// 取消审核退款单前预检查 /// </summary> protected void PreCheckForCancelAudit(SOIncomeRefundInfo entity) { //审核状态不等于已审核,不能取消审核。 if (entity.Status != RefundStatus.Audit) { ThrowBizException("SOIncomeRefund_CancelAudit_StatusNotMatchAudit"); } //如果单据类型为“RO”,并且对应的RO的状态为”已经作废”或者”已经退款”,则取消审核失败。 if (entity.OrderType == RefundOrderType.RO) { var roEntity = ExternalDomainBroker.GetRefundBySysNo(entity.OrderSysNo.Value); if (roEntity.Status == RMARefundStatus.Abandon || roEntity.Status == RMARefundStatus.Refunded) { ThrowBizException("SOIncomeRefund_CancelAudit_ROStatusNotMatchAbandonOrRefunded"); } } //如果单据类型为“AO”或者”多付款退款单”或者“补偿退款单”,并且对应的“收款单”的状态为”已经审核”,则取消审核失败。 else if (entity.OrderType == RefundOrderType.AO || entity.OrderType == RefundOrderType.OverPayment ) { List<SOIncomeInfo> soIncomeList = ObjectFactory<SOIncomeProcessor>.Instance.GetListByCriteria(null , entity.OrderSysNo , (SOIncomeOrderType)((int)entity.OrderType) , new List<SOIncomeStatus> { SOIncomeStatus.Confirmed }); if (soIncomeList != null && soIncomeList.Count > 0) { ThrowBizException("SOIncomeRefund_CancelAudit_FinancialAlreadyConfirmed"); } } // 如果单据类型为“RO_Balance”, 并且对应的RO_Balance的状态为”已经作废”或者”已经退款”,则取消审核失败。 else if (entity.OrderType == RefundOrderType.RO_Balance) { if (entity.RefundPayType == RefundPayType.CashRefund) { ThrowBizException("SOIncomeRefund_CancelAudit_ROBalanceCashRefundCanNotCancel"); } var roBalanceEntity = ExternalDomainBroker.GetRefundBalanceBySysNo(entity.OrderSysNo.Value); if (roBalanceEntity.Status != RefundBalanceStatus.WaitingRefund) { ThrowBizException("SOIncomeRefund_CancelAudit_ROBalanceAbandonOrRefunded"); } } //已生成礼品卡,不能取消审核 if (entity.Status != RefundStatus.Abandon && entity.RefundCashAmt > 0 && entity.RefundPayType == RefundPayType.GiftCardRefund && (entity.OrderType == RefundOrderType.AO || entity.OrderType == RefundOrderType.OverPayment)) { ThrowBizException("SOIncomeRefund_CancelAudit_GeneratedGiftCard"); } }
/// <summary> /// 更新销售退款单 /// </summary> /// <param name="entity"></param> public virtual void Update(SOIncomeRefundInfo entity) { PreCheckForUpdate(entity); //fixbug:在财务管理-退款审核对退款信息进行编辑后,需要和RMA进行同步 if (entity.OrderType == RefundOrderType.RO) { //调用RMA服务,更新RO单的退款类型和退看原因 ExternalDomainBroker.UpdateRefundPayTypeAndReason(entity.OrderSysNo.Value, (int)entity.RefundPayType, entity.RefundReason.Value); } m_SOIncomeRefundDA.Update(entity); }