/// <summary> /// 作废 /// </summary> /// <param name="sysNo"></param> public virtual void Abandon(int sysNo) { var balanceRefundInfo = LoadBySysNo(sysNo); if (balanceRefundInfo.Status != BalanceRefundStatus.Origin && balanceRefundInfo.Status != BalanceRefundStatus.CSConfirmed) { //throw new BizException("只有待审核或客服审核通过的单据才能作废."); ThrowBizException("BalanceRefund_JustWaitOrAuditPassCanDeactive"); } TransactionOptions options = new TransactionOptions(); options.IsolationLevel = IsolationLevel.ReadUncommitted; using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, options)) { ExternalDomainBroker.AdjustCustomerPerpayAmount(balanceRefundInfo.CustomerSysNo.Value, 0, balanceRefundInfo.ReturnPrepayAmt.Value, PrepayType.BalanceReturn, "作废余额账户转银行退款加余额"); m_BalanceRefundDA.UpdateStatus(sysNo, BalanceRefundStatus.Abandon); //发送作废Message EventPublisher.Publish(new BalanceRefundAbandonedMessage() { ReturnPrepaySysNo = sysNo, CurrentUserSysNo = ServiceContext.Current.UserSysNo, LastRefundStatus = (int)balanceRefundInfo.Status }); ts.Complete(); } }
/// <summary> /// 取消审核退款单 /// </summary> public virtual void CancelAudit(int sysNo) { SOIncomeRefundInfo entity = LoadBySysNo(sysNo); PreCheckForCancelAudit(entity); TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, options)) { //如果是补偿退款单,需要回写状态,并且作废对应的销售-收款单 bool flag = m_SOIncomeRefundDA.UpdateStatus(sysNo, ServiceContext.Current.UserSysNo, RefundStatus.Origin, DateTime.Now); if (flag) { if (entity.RefundPayType == RefundPayType.PrepayRefund && entity.RefundCashAmt != 0) { if (entity.OrderType == RefundOrderType.AO) { ExternalDomainBroker.AdjustCustomerPerpayAmount(entity.CustomerSysNo.Value, entity.OrderSysNo.Value, -entity.RefundCashAmt.Value, PrepayType.BOReturn , GetMessageString("SOIncomeRefund_CancelAudit_AOAdjustBalanceNote")); } else if (entity.OrderType == RefundOrderType.OverPayment) { ExternalDomainBroker.AdjustCustomerPerpayAmount(entity.CustomerSysNo.Value, entity.OrderSysNo.Value, -entity.RefundCashAmt.Value, PrepayType.RemitReturn , GetMessageString("SOIncomeRefund_CancelAudit_OverPayAdjustBalanceNote")); } else if (entity.OrderType == RefundOrderType.RO && entity.HaveAutoRMA == true) { ExternalDomainBroker.AdjustCustomerPerpayAmount(entity.CustomerSysNo.Value, entity.OrderSysNo.Value, -entity.RefundCashAmt.Value, PrepayType.ROReturn, GetMessageString("SOIncomeRefund_CancelAudit_ROAdjustShipRejectPrepayRefundNote")); } //else if (entity.OrderType == RefundOrderType.RO_Adjsut) //{ // ExternalDomainBroker.AdjustCustomerPerpayAmount(entity.CustomerSysNo.Value, entity.OrderSysNo.Value, -entity.RefundCashAmt.Value, PrepayType.RO_AdjustReturn, // GetMessageString("SOIncomeRefund_CancelAudit_ROAdjustNote")); //} } ts.Complete(); } } //记录操作日志 ObjectFactory<ICommonBizInteract>.Instance.CreateOperationLog( GetMessageString("SOIncomeRefund_Log_CancelAudit", ServiceContext.Current.UserSysNo, entity.SysNo) , BizLogType.AuditRefund_Update , entity.SysNo.Value , entity.CompanyCode); }
/// <summary> /// 审核通过的处理 /// </summary> /// <param name="entity"></param> protected virtual void PassAudit(SOIncomeRefundInfo entity) { if (entity.RefundCashAmt > 0 && entity.RefundPayType == RefundPayType.GiftCardRefund && (entity.OrderType == RefundOrderType.AO || entity.OrderType == RefundOrderType.OverPayment)) { //调用IM接口创建一张电子礼品卡,礼品卡类型为[CS补偿电子卡] var giftCardResultCode = ExternalDomainBroker.CreateElectronicGiftCard(entity.SOSysNo.Value, entity.CustomerSysNo.Value, 1, entity.RefundCashAmt.Value , ECCentral.BizEntity.IM.GiftCardType.Compensate, "退款转礼品卡", entity.CompanyCode); //发送邮件通知用户 SendGiftCardEmail(entity, giftCardResultCode); //记录操作日志 ObjectFactory<ICommonBizInteract>.Instance.CreateOperationLog( GetMessageString("SOIncomeRefund_Log_PassAudit", ServiceContext.Current.UserSysNo, entity.SysNo, entity.RefundCashAmt) , BizLogType.AuditRefund_Update , entity.SysNo.Value , entity.CompanyCode); } //更新用户账户余额 if (entity.RefundPayType == RefundPayType.PrepayRefund && entity.RefundCashAmt != 0) { if (entity.OrderType == RefundOrderType.AO) { ExternalDomainBroker.AdjustCustomerPerpayAmount(entity.CustomerSysNo.Value, entity.OrderSysNo.Value, entity.RefundCashAmt.Value, PrepayType.BOReturn, GetMessageString("SOIncomeRefund_AuditAOAdjustBalanceNote")); } else if (entity.OrderType == RefundOrderType.OverPayment) { ExternalDomainBroker.AdjustCustomerPerpayAmount(entity.CustomerSysNo.Value, entity.OrderSysNo.Value, entity.RefundCashAmt.Value, PrepayType.RemitReturn, GetMessageString("SOIncomeRefund_AuditOverPayAdjustBalanceNote")); } else if (entity.OrderType == RefundOrderType.RO && entity.HaveAutoRMA == true) { ExternalDomainBroker.AdjustCustomerPerpayAmount(entity.CustomerSysNo.Value, entity.OrderSysNo.Value, entity.RefundCashAmt.Value, PrepayType.ROReturn, GetMessageString("SOIncomeRefund_AuditROShipRejectPrepayRefundNote")); } //else if (entity.OrderType == RefundOrderType.RO_Adjsut) //{ // ExternalDomainBroker.AdjustCustomerPerpayAmount(entity.CustomerSysNo.Value, entity.OrderSysNo.Value, entity.RefundCashAmt.Value, PrepayType.RO_AdjustReturn, GetMessageString("SOIncomeRefund_AuditROAdjustNote")); //} } }
/// <summary> /// 创建顾客余额退款信息 /// </summary> /// <param name="entity"></param> /// <returns></returns> public virtual BalanceRefundInfo Create(BalanceRefundInfo entity) { if (entity.ReturnPrepayAmt <= 0) { //throw new BizException("退款金额必须大于等于0。"); ThrowBizException("BalanceRefund_RefundAmoutNeedMoreThan0"); } if (!ExternalDomainBroker.ExistsCustomer(entity.CustomerSysNo.Value)) { //throw new BizException(string.Format("编号为{0}的顾客不存在。", entity.CustomerSysNo)); ThrowBizException("BalanceRefund_NotExsistCustomer", entity.CustomerSysNo); } TransactionOptions options = new TransactionOptions(); options.IsolationLevel = IsolationLevel.ReadUncommitted; using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, options)) { ExternalDomainBroker.AdjustCustomerPerpayAmount(entity.CustomerSysNo.Value, 0, -entity.ReturnPrepayAmt.Value, PrepayType.BalanceReturn, "余额账户转银行退款"); entity.Status = BalanceRefundStatus.Origin; entity = m_BalanceRefundDA.Create(entity); //发送创建Message EventPublisher.Publish(new CreateBalanceRefundMessage() { ReturnPrepaySysNo = entity.SysNo.Value, CurrentUserSysNo = ServiceContext.Current.UserSysNo }); ts.Complete(); } return(entity); }