Пример #1
0
        /// <summary>
        /// 根据供应商编号取得未支付的应付款(包括PO、代销结算单、代收结算单)
        /// </summary>
        /// <param name="vendorSysNo"></param>
        /// <returns></returns>
        protected virtual List <PayableInfo> GetUnPayListByVendorSysNo(int vendorSysNo)
        {
            var unpayList = ObjectFactory <PayableProcessor> .Instance.GetUnPayOrPartlyPayList();

            //调用PO接口取得PO单系统编号列表
            var poSysNoList = ExternalDomainBroker.GetPOSysNoListByVendorSysNo(vendorSysNo, null);

            //调用PO接口取得代销结算单系统编号列表
            var vendorSettleSysNoList = ExternalDomainBroker.GetVendorSettleSysNoListByVendorSysNo(vendorSysNo, null);

            //调用PO接口取得代收结算单系统编号列表
            var collectionSettleSysNoList = ExternalDomainBroker.GetCollectionSettlementSysNoListByVendorSysNo(vendorSysNo);

            unpayList = unpayList.Where(w => (w.OrderType == PayableOrderType.PO && poSysNoList.Contains(w.OrderSysNo.Value)) ||
                                        (w.OrderType == PayableOrderType.VendorSettleOrder && vendorSettleSysNoList.Contains(w.OrderSysNo.Value)) ||
                                        (w.OrderType == PayableOrderType.CollectionSettlement && collectionSettleSysNoList.Contains(w.OrderSysNo.Value)))
                        .ToList();

            return(unpayList);
        }
Пример #2
0
        /// <summary>
        /// 付款单是否被供应商锁定
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public virtual bool IsHoldByVendor(PayItemInfo entity)
        {
            var pay = ObjectFactory <PayableProcessor> .Instance.LoadBySysNo(entity.PaySysNo.Value);

            bool result = false;

            if (entity.OrderType == PayableOrderType.PO)
            {
                result = ExternalDomainBroker.IsHolderVendorByPOSysNo(pay.OrderSysNo.Value);
            }
            else if (entity.OrderType == PayableOrderType.VendorSettleOrder)
            {
                result = ExternalDomainBroker.IsHolderVendorByVendorSettleSysNo(pay.OrderSysNo.Value);
            }
            else if (entity.OrderType == PayableOrderType.CollectionSettlement)
            {
                result = ExternalDomainBroker.IsHolderVendorByCollectionSettlementSysNo(pay.OrderSysNo.Value);
            }
            return(result);
        }
Пример #3
0
        /// <summary>
        /// 根据供应商系统编号、付款单状态取得付款单列表(包括PO、代销结算单、代收结算单)
        /// </summary>
        /// <param name="vendorSysNo">供应商系统编号</param>
        /// <param name="status">付款单状态</param>
        /// <returns>满足条件的付款单列表</returns>
        protected virtual List <PayItemInfo> GetListByVendorSysNo(int vendorSysNo, PayItemStatus status)
        {
            //取得所有满足状态Status的PO单、代销结算单、代收结算单的付款单列表
            var payItemList = m_PayItemDA.GetListByStatus(status);

            //调用PO接口取得PO单系统编号列表
            var poSysNoList = ExternalDomainBroker.GetPOSysNoListByVendorSysNo(vendorSysNo, null);

            //调用PO接口取得代销结算单系统编号列表
            var vendorSettleSysNoList = ExternalDomainBroker.GetVendorSettleSysNoListByVendorSysNo(vendorSysNo, null);

            //调用PO接口取得代收结算单系统编号列表
            var collectionSettleSysNoList = ExternalDomainBroker.GetCollectionSettlementSysNoListByVendorSysNo(vendorSysNo);

            payItemList = payItemList.Where(w => (w.OrderType == PayableOrderType.PO && poSysNoList.Contains(w.OrderSysNo.Value)) ||
                                            (w.OrderType == PayableOrderType.VendorSettleOrder && vendorSettleSysNoList.Contains(w.OrderSysNo.Value)) ||
                                            (w.OrderType == PayableOrderType.CollectionSettlement && collectionSettleSysNoList.Contains(w.OrderSysNo.Value)))
                          .ToList();

            return(payItemList);
        }
Пример #4
0
        private bool IsRuleMatch(ResponsibleUserInfo responsibleUser, TrackingInfo trackingInfo)
        {
            var soIncomeBL = ObjectFactory <SOIncomeProcessor> .Instance;

            if (trackingInfo.OrderType == SOIncomeOrderType.SO)
            {
                //订单不存在直接抛出异常,这个是数据错误。
                var soInfo = ExternalDomainBroker.GetSOInfo(trackingInfo.OrderSysNo.Value);

                if (responsibleUser.CustomerSysNo == soInfo.BaseInfo.CustomerSysNo ||
                    responsibleUser.ShipTypeSysNo == soInfo.ShippingInfo.ShipTypeSysNo ||
                    responsibleUser.PayTypeSysNo == soInfo.BaseInfo.PayTypeSysNo)
                {
                    return(true);
                }

                //比较收款类型,SO单只有货到付款和款到发货两种。
                if (!responsibleUser.CustomerSysNo.HasValue &&
                    !responsibleUser.ShipTypeSysNo.HasValue &&
                    !responsibleUser.PayTypeSysNo.HasValue &&
                    (int)responsibleUser.IncomeStyle.Value == (int)trackingInfo.IncomeStyle.Value
                    )
                {
                    return(true);
                }
            }
            else
            {
                if (!responsibleUser.CustomerSysNo.HasValue &&
                    !responsibleUser.ShipTypeSysNo.HasValue &&
                    !responsibleUser.PayTypeSysNo.HasValue &&
                    responsibleUser.IncomeStyle == ResponseUserOrderStyle.RefundException)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #5
0
        /// <summary>
        /// 取得PM和TL的邮件地址,多个邮件地址之间用逗号隔开
        /// </summary>
        /// <param name="pmSysNo"></param>
        /// <returns></returns>
        private string GetPMAndTLMailMailAddress(int pmSysNo)
        {
            //调用IM服务,根据PMSysNo取得PM组信息
            var pmList = ExternalDomainBroker.GetPMListByPMSysNo(pmSysNo);

            if (pmList == null ||
                pmList.UserInfo == null ||
                pmList.ProductManagerInfoList == null)
            {
                ThrowBizException("Payable_GetPMGroupWhenSendMail_Faults", pmSysNo);
            }
            var emailList = new List <UserInfo>()
            {
                pmList.UserInfo
            }.Union(
                pmList.ProductManagerInfoList
                .Where(w => w.UserInfo.SysNo == pmSysNo)
                .Select(s => s.UserInfo))
            .Where(w => StringUtility.IsEmailAddress(w.EmailAddress))
            .Select(s => s.EmailAddress);

            return(string.Join(",", emailList));
        }
Пример #6
0
        /// <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);
        }
Пример #7
0
        protected virtual string GetResponsibleUserName(TrackingInfo entity)
        {
            if (!entity.OrderSysNo.HasValue)
            {
                throw new ArgumentNullException("entity.OrderSysNo");
            }

            if (!entity.OrderType.HasValue)
            {
                throw new ArgumentNullException("entity.OrderType");
            }

            var allResponseUsers = GetAllResponsibleUsers(entity.CompanyCode);

            //fixbug:Dictionary键重复问题
            //原来的IPP在配置责任人的时候有bug,不能判断勾选了“特殊责任人”,但是实际条件又不满足“特殊责任人”的情况,导致生成重复的责任人数据(配送方式、支付方式、客户编号相同的数据)。
            //ECCentral不会产生这样的数据,但为了兼容之前的数据,作出下面的调整。
            var vipDict = allResponseUsers.Where(x => x.CustomerSysNo.HasValue)
                          .GroupBy(g => g.CustomerSysNo).ToDictionary(x => x.Key, x => x.FirstOrDefault());

            var shipTypeDict = allResponseUsers.Where(x => x.ShipTypeSysNo.HasValue)
                               .GroupBy(g => g.ShipTypeSysNo).ToDictionary(x => x.Key, x => x.FirstOrDefault());

            var payTypeDict = allResponseUsers.Where(x => x.PayTypeSysNo.HasValue)
                              .GroupBy(g => g.PayTypeSysNo).ToDictionary(x => x.Key, x => x.FirstOrDefault());

            var incomeStyleDict = allResponseUsers.Where(x => x.IncomeStyle.HasValue &&
                                                         !x.PayTypeSysNo.HasValue &&
                                                         !x.ShipTypeSysNo.HasValue &&
                                                         !x.CustomerSysNo.HasValue &&
                                                         !x.SourceType.HasValue).ToDictionary(x => x.IncomeStyle);

            if (entity.OrderType == SOIncomeOrderType.SO)
            {
                var soInfo = ExternalDomainBroker.GetSOInfo(entity.OrderSysNo.Value);

                if (soInfo == null)
                {
                    ThrowBizException("TrackingInfo_NotExistSORecord", entity.OrderSysNo);
                }

                var soIncomeInfo = ObjectFactory <SOIncomeProcessor> .Instance.GetListByCriteria(null, soInfo.SysNo, SOIncomeOrderType.SO, null)
                                   .Select(s => s).FirstOrDefault();

                var netpayInfo = ObjectFactory <NetPayProcessor> .Instance.GetListByCriteria(
                    new NetPayInfo()
                {
                    SOSysNo = soInfo.SysNo,
                }).Where(w => w.Status > NetPayStatus.Abandon).Select(s => s).FirstOrDefault();

                //责任人来源方式
                ResponsibleSource?souceType = null;
                if (soIncomeInfo.IncomeStyle == SOIncomeOrderStyle.Advanced)
                {
                    if (netpayInfo.Source == NetPaySource.Bank)
                    {
                        souceType = ResponsibleSource.NetPay;
                    }
                    else
                    {
                        souceType = ResponsibleSource.Manual;
                    }
                }

                //款到发货
                if (soIncomeInfo.IncomeStyle == SOIncomeOrderStyle.Advanced)
                {
                    #region CRL10309 By Kilin 根据来源方式(网关、手动)匹配责任人

                    //根据来源方式匹配
                    ResponsibleUserInfo responsibleUser = allResponseUsers
                                                          .Where(w => w.IncomeStyle == ResponseUserOrderStyle.Advanced &&
                                                                 w.SourceType.HasValue &&
                                                                 souceType.HasValue &&
                                                                 w.SourceType == souceType.Value)
                                                          .Select(s => s)
                                                          .FirstOrDefault();

                    if (responsibleUser != null)
                    {
                        return(responsibleUser.ResponsibleUserName);
                    }

                    //如果是 银行电汇
                    if (soInfo.BaseInfo.PayTypeSysNo.HasValue)
                    {
                        if (payTypeDict.ContainsKey(soInfo.BaseInfo.PayTypeSysNo.Value))
                        {
                            return(payTypeDict[soInfo.BaseInfo.PayTypeSysNo.Value].ResponsibleUserName);
                        }
                    }

                    //最后一步取支付方式和来源方式都为空的数据
                    responsibleUser = allResponseUsers
                                      .Where(w => w.IncomeStyle == ResponseUserOrderStyle.Advanced &&
                                             !w.PayTypeSysNo.HasValue &&
                                             !w.SourceType.HasValue)
                                      .Select(s => s)
                                      .FirstOrDefault();

                    if (responsibleUser != null)
                    {
                        return(responsibleUser.ResponsibleUserName);
                    }

                    #endregion CRL10309 By Kilin 根据来源方式(网关、手动)匹配责任人
                }
                //货到付款
                else if (soIncomeInfo.IncomeStyle == SOIncomeOrderStyle.Normal)
                {
                    //优先按照客户编号匹配责任人
                    if (vipDict.ContainsKey(soInfo.BaseInfo.CustomerSysNo.Value))
                    {
                        return(vipDict[soInfo.BaseInfo.CustomerSysNo.Value].ResponsibleUserName);
                    }

                    //其次是按照配送方式匹配责任人
                    if (shipTypeDict.ContainsKey(soInfo.ShippingInfo.ShipTypeSysNo.Value))
                    {
                        return(shipTypeDict[soInfo.ShippingInfo.ShipTypeSysNo.Value].ResponsibleUserName);
                    }
                }

                ResponseUserOrderStyle incomeStyle = ResponseUserOrderStyle.Normal;
                if (!soInfo.BaseInfo.PayWhenReceived.Value)
                {
                    incomeStyle = ResponseUserOrderStyle.Advanced;
                }

                //最后按照是否货到付款确定责任人
                if (incomeStyleDict.ContainsKey(incomeStyle))
                {
                    return(incomeStyleDict[incomeStyle].ResponsibleUserName);
                }
            }
            else
            {
                if (incomeStyleDict.ContainsKey(ResponseUserOrderStyle.RefundException))
                {
                    return(incomeStyleDict[ResponseUserOrderStyle.RefundException].ResponsibleUserName);
                }
            }
            return(string.Empty);
        }
Пример #8
0
        protected virtual void ProcessPayedPrepay(PayableInfo entity, PayItemInfo payitem)
        {
            PayableInfo payable = null;

            if (payitem.AvailableAmt < entity.InStockAmt - entity.EIMSAmt)
            {
                ThrowBizException("Payable_ProcessPayedPrepay_InStockAmtMoreThanAvailableAmt");
            }
            //更新付款单可用金额
            payitem.AvailableAmt -= entity.InStockAmt - entity.EIMSAmt;
            ObjectFactory <PayItemProcessor> .Instance.UpdateAvailableAmt(payitem.OrderType.Value, payitem.OrderSysNo.Value, payitem.AvailableAmt.Value);

            var pEntity = m_PayableDA.GetFirstPay(entity.OrderType.Value, entity.OrderSysNo.Value);

            if (entity.BatchNumber == 1)
            {
                if (pEntity == null)
                {
                    ThrowBizException("Payable_ProcessPayedPrepay_NotExistPaidRecord");
                }
                payable             = new PayableInfo();
                payable.OrderAmt    = pEntity.OrderAmt;
                payable.SysNo       = pEntity.SysNo;
                payable.PayStatus   = PayableStatus.FullPay;
                payable.OrderStatus = entity.OrderStatus;
                payable.InStockAmt  = entity.InStockAmt;
                payable.EIMSAmt     = entity.EIMSAmt;
                payable.RawOrderAmt = entity.RawOrderAmt;
                m_PayableDA.UpdateFirstPay(payable);
            }
            else
            {
                payable               = new PayableInfo();
                payable.OrderSysNo    = entity.OrderSysNo;
                payable.OrderType     = entity.OrderType;
                payable.BatchNumber   = entity.BatchNumber;
                payable.PayStatus     = PayableStatus.FullPay;
                payable.AlreadyPayAmt = 0;
                payable.OrderAmt      = payable.AlreadyPayAmt;
                payable.RawOrderAmt   = entity.RawOrderAmt;
                payable.InStockAmt    = entity.InStockAmt;
                payable.EIMSAmt       = entity.EIMSAmt;
                payable.Note          = "auto create during in stock";
                payable.CurrencySysNo = 1;
                payable.OrderStatus   = entity.OrderStatus;
                payable               = Create(payable);
            }

            PayItemInfo pie = new PayItemInfo();

            pie.OrderSysNo  = entity.OrderSysNo;
            pie.OrderType   = (PayableOrderType)entity.OrderType;
            pie.PaySysNo    = payable.SysNo.Value;
            pie.PayAmt      = entity.InStockAmt.Value - entity.EIMSAmt.Value;
            pie.SysNo       = payitem.SysNo;
            pie.OrderStatus = entity.OrderStatus;
            pie.CompanyCode = entity.CompanyCode;

            if (entity.BatchNumber != 1)
            {
                ObjectFactory <PayItemProcessor> .Instance.CreatePayEx(pie);
            }

            if (entity.OrderStatus.Value == (int)PurchaseOrderStatus.PartlyInStocked)
            {
                //调用PO接口中止入库
                ExternalDomainBroker.StopInStock(entity.OrderSysNo.Value);
            }
        }
Пример #9
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);
            }
        }
Пример #10
0
 /// <summary>
 /// 更新销售价格
 /// </summary>
 /// <param name="productSysNo"></param>
 /// <param name="newPrice"></param>
 public virtual void UpdateProductCurrentPrice(int productSysNo, decimal newPrice)
 {
     ExternalDomainBroker.UpdateProductCurrentPrice(productSysNo, newPrice);
 }
Пример #11
0
 /// <summary>
 /// 更新商品正常采购价格
 /// </summary>
 /// <param name="productSysNo"></param>
 /// <param name="originalVirtualPrice"></param>
 /// <param name="newVirtualPrice"></param>
 public virtual void UpdateProductVirtualPrice(int productSysNo, decimal originalVirtualPrice, decimal newVirtualPrice)
 {
     ExternalDomainBroker.UpdateProductVirtualPrice(productSysNo, originalVirtualPrice, newVirtualPrice);
 }
Пример #12
0
 public VendorBasicInfo GetVendorBasicInfoBySysNo(int vendorSysNo)
 {
     return(ExternalDomainBroker.GetVendorBasicInfoBySysNo(vendorSysNo));
 }
Пример #13
0
 private void CreateOperationLog(PriceChangeMaster item, string action, BizLogType logType)
 {
     ExternalDomainBroker.CreateOperationLog(string.Format("用户:\"{0}\"{1}了编号为\"{2}\"类型为\"{3}\"的变价单", (string.IsNullOrEmpty(ServiceContext.Current.UserDisplayName) ? "Job" : ServiceContext.Current.UserDisplayName), action, item.SysNo, item.PriceType.ToDisplayText())
                                             , logType, item.SysNo, "8601");
 }
Пример #14
0
        public RefundResult Refund(RefundEntity entity)
        {
            BizLogType RefoundLogType = BizLogType.RMA_Refund_Refund;

            if (entity.OrderType.GetValueOrDefault() == SOIncomeOrderType.AO)
            {
                RefoundLogType = BizLogType.AO_Refund_Refund;
            }
            BizLogType RefountType = BizLogType.AO_Refund_Refund;

            ExternalDomainBroker.CreateOperationLog("支付宝退款开始构建请求参数", RefoundLogType, entity.RefundSysNo, entity.CompanyCode);
            RefundResult responseResult = null;

            #region 无密退款
            ////////////////////////////////////////////请求参数////////////////////////////////////////////

            //服务器异步通知页面路径
            string notify_url = string.Empty;
            //需http://格式的完整路径,不允许加?id=123这类自定义参数

            //退款批次号
            string batch_no = DateTime.Now.ToString("yyyyMMddHHmmssfff");
            //必填,每进行一次即时到账批量退款,都需要提供一个批次号,必须保证唯一性

            //退款请求时间
            string refund_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            //必填,格式为:yyyy-MM-dd hh:mm:ss

            //退款总笔数
            string batch_num = "1";
            //必填,即参数detail_data的值中,“#”字符出现的数量加1,最大支持1000笔(即“#”字符出现的最大数量999个)

            //单笔数据集
            string     detail_data = "";
            NetPayInfo netpayInfo  = ObjectFactory <NetPayProcessor> .Instance.GetValidBySOSysNo(entity.SOSysNo);

            if (netpayInfo != null && !string.IsNullOrWhiteSpace(netpayInfo.ExternalKey))
            {
                //退款详细数据
                detail_data += BuildDetailDataString(netpayInfo.ExternalKey.TrimEnd(), entity.RefundAmt.ToString("f2"), "支付宝无线支付退款");
            }
            //必填,格式详见“4.3 单笔数据集参数说明”


            ////////////////////////////////////////////////////////////////////////////////////////////////
            #endregion

            #region 请求参数 :
            //////////////////////////////////////////////请求参数////////////////////////////////////////////
            ////服务器异步通知页面路径
            //string notify_url = string.Empty;
            ////需http://格式的完整路径,不允许加?id=123这类自定义参数

            ////卖家支付宝帐户
            //string seller_email = "*****@*****.**";

            ////卖家UserID:
            //string seller_user_id = Config.Partner;

            ////退款当天日期
            //string refund_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            ////必填,格式:年[4位]-月[2位]-日[2位] 小时[2位 24小时制]:分[2位]:秒[2位],如:2007-10-01 13:13:13

            ////批次号
            //string batch_no = DateTime.Now.ToString("yyyyMMddHHmmssfff");
            ////必填,格式:当天日期[8位]+序列号[3至24位],如:201008010000001

            ////退款笔数
            //string batch_num = entity.Count.ToString() ;
            ////必填,参数detail_data的值中,“#”字符出现的数量加1,最大支持1000笔(即“#”字符出现的数量999个)
            //string detail_data = "";
            //foreach (var item in entity)
            //{
            //    NetPayInfo netpayInfo = ObjectFactory<NetPayProcessor>.Instance.GetValidBySOSysNo(item.SOSysNo);
            //    if (netpayInfo!=null&&!string.IsNullOrWhiteSpace(netpayInfo.ExternalKey))
            //    {
            //        //退款详细数据
            //        detail_data += BuildDetailDataString(netpayInfo.ExternalKey.TrimEnd(), item.RefundAmt.ToString("f2"), "支付宝无线支付退款");
            //    }
            //}

            ////必填,具体格式请参见接口技术文档
            //if (string.IsNullOrWhiteSpace(detail_data))
            //{
            //    return responseResult = new RefundResult()
            //    {
            //        Result = false,
            //        Message = "报错:无有效退款订单"
            //    };

            //}
            //else
            //{
            //    detail_data=detail_data.Remove(detail_data.Length - 1);
            //}

            //////////////////////////////////////////////////////////////////////////////////////////////////
            #endregion

            //把请求参数打包成数组
            SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();
            sParaTemp.Add("partner", Config.Partner);
            sParaTemp.Add("_input_charset", Config.Input_charset.ToLower());
            sParaTemp.Add("service", "refund_fastpay_by_platform_nopwd");
            sParaTemp.Add("notify_url", notify_url);
            sParaTemp.Add("batch_no", batch_no);
            sParaTemp.Add("refund_date", refund_date);
            sParaTemp.Add("batch_num", batch_num);
            sParaTemp.Add("detail_data", detail_data);
            ExternalDomainBroker.CreateOperationLog("开支请求支付宝退款。", RefoundLogType, entity.RefundSysNo, entity.CompanyCode);
            //建立请求
            string sHtmlText = Submit.BuildRequest(sParaTemp);

            ExternalDomainBroker.CreateOperationLog(sHtmlText, RefoundLogType, entity.RefundSysNo, entity.CompanyCode);
            //请在这里加上商户的业务逻辑程序代码

            //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——

            XmlDocument xmlDoc = new XmlDocument();
            try
            {
                xmlDoc.LoadXml(sHtmlText);
                string strXmlResponse = xmlDoc.SelectSingleNode("/alipay").InnerText;
                string result         = xmlDoc.SelectSingleNode("/alipay/is_success").InnerText;
                if (result == "F")
                {
                    string resultNote = string.Format("用户[{0}]对订单号:{1} 调用了退款接口.调用结果;{2} 调用返回信息:{3} PostUrl:{4} 退款金额:{5}", ServiceContext.Current.UserSysNo, entity.SOSysNo, "False", strXmlResponse, Submit.GATEWAY_NEW, entity.RefundAmt.ToString());
                    ExternalDomainBroker.CreateOperationLog(resultNote, RefoundLogType, entity.RefundSysNo, entity.CompanyCode);
                    Exception refundException = new Exception(strXmlResponse);
                    return(responseResult = new RefundResult()
                    {
                        Result = false,
                        Message = strXmlResponse
                    });
                }
                else
                {
                    string resultNote = string.Format("用户[{0}]对订单号:{1} 调用了退款接口.调用结果;{2} 调用返回信息:{3} PostUrl:{4} 退款金额:{5}", ServiceContext.Current.UserSysNo, entity.SOSysNo, "True", strXmlResponse, Submit.GATEWAY_NEW, entity.RefundAmt.ToString());
                    ExternalDomainBroker.CreateOperationLog(resultNote, RefoundLogType, entity.RefundSysNo, entity.CompanyCode);
                    return(responseResult = new RefundResult()
                    {
                        Result = true,
                        ExternalKey = strXmlResponse
                    });
                }
            }
            catch (Exception exp)
            {
                string resultNote = string.Format("用户[{0}]对订单号:{1} 调用了退款接口.调用结果;{2} 调用返回信息:{3} PostUrl:{4} 退款金额:{5}", ServiceContext.Current.UserSysNo, entity.SOSysNo, "False", exp.Message, Submit.GATEWAY_NEW, entity.RefundAmt.ToString());
                ExternalDomainBroker.CreateOperationLog(resultNote, RefoundLogType, entity.RefundSysNo, entity.CompanyCode);
                return(responseResult = new RefundResult()
                {
                    Result = false,
                    Message = exp.Message
                });
            }

            //——请根据您的业务逻辑来编写程序(以上代码仅作参考)——
        }
Пример #15
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 强制核收数据检查
        }
Пример #16
0
        public virtual void AuditNetPay4GroupBuy(int netPaySysNo)
        {
            //BizLogger.WriteLog<NetPayEntity>(inputNetPay, "[团购]核对网上支付",
            //    string.Format("Begin:[团购]用户\"{0}\"开始审核", inputNetPay.ApproveUserSysNo.Value, inputNetPay.SOSysNo), inputNetPay.SOSysNo.ToString(), (int)LogType.Finance_NetPay_Verify_GroupBuy);
            int userSysNo  = ServiceContext.Current.UserSysNo;
            var netPayInfo = LoadBySysNo(netPaySysNo);
            var so         = ExternalDomainBroker.GetSOBaseInfo(netPayInfo.SOSysNo.Value);

            #region PreCheck

            if (so.Status == SOStatus.Abandon)
            {
                ThrowBizException("NetPay_Audit_SOAlreadyAbandon", so.SysNo);
            }
            if (netPayInfo.Status != NetPayStatus.Origin)
            {
                ThrowBizException("NetPay_StatusNotAllowCheck");
            }

            //验证订单的付款方式是不是“网上支付”
            //if (!CommonService.IsNetPayType(so.PayTypeSysNo, so.SysNo))
            //{
            //    throw new BusinessException(MessageResource.NetPay_SOPayTypeIsNotNetCode, MessageResource.NetPay_SOPayTypeIsNotNetValue);
            //}

            if (netPayInfo.PayAmount < so.ReceivableAmount)
            {
                ThrowBizException("NetPay_PayAmoutNotEnoughNotAllowCheck");
            }
            #endregion

            #region Prepare data
            //SOIncomeInfo soIncome = new SOIncomeInfo();
            //soIncome.CompanyCode = netPayInfo.CompanyCode;
            //soIncome.IncomeStyle = SOIncomeOrderStyle.Advanced;
            //soIncome.OrderType = SOIncomeOrderType.SO;
            //soIncome.OrderSysNo = netPayInfo.SOSysNo;
            //soIncome.OrderAmt = so.SOTotalAmount;
            //soIncome.IncomeAmt = netPayInfo.PayAmount;
            //soIncome.PrepayAmt = Math.Max(0.00M, so.PrepayAmount??0M);//???
            ////soIncome.IncomeUserSysNo = userSysNo;
            //soIncome.Status = SOIncomeStatus.Origin;
            ////soIncome.MasterSoSysNo = so.;
            //soIncome.PointPay = so.PointPay;
            //soIncome.GiftCardPayAmt = so.GiftCardPay;
            //soIncome.PayAmount = netPayInfo.PayAmount;

            //是否需要生成多付退款单
            SOIncomeRefundInfo refund = null;
            if (netPayInfo.PayAmount > so.ReceivableAmount)
            {
                //构造退款信息
                refund             = new SOIncomeRefundInfo();
                refund.CompanyCode = netPayInfo.CompanyCode;
                //netPayInfo.ReturnAmt = netPayInfo.PayAmount - so.ReceivableAmount;
                refund.RefundCashAmt = netPayInfo.PayAmount - so.ReceivableAmount;

                //Jack:目前没有这个信息
                //if (netPayInfo.ToleranceAmt.HasValue)
                //{
                //    refund.ToleranceAmt = Math.Abs(netPay.ToleranceAmt.Value);
                //}

                //CRL18174:团购订单退款调整,团购订单退款需视不同的支付方式,采用不同的退款类型
                //todo:需要Check 如果团购订单的退款类型为空,则默认为“退入余额帐户”方式
                refund.RefundPayType = RefundPayType.PrepayRefund;

                refund.RefundPoint = 0;
                //todo:jack需要确认一下
                refund.CreateUserSysNo = userSysNo;
                refund.RefundReason    = 5;     //客户多付款
                refund.HaveAutoRMA     = false; //非物流拒收
                refund.Note            = "团购成团后的多付款退款";
                refund.Status          = RefundStatus.Origin;
                refund.OrderType       = RefundOrderType.OverPayment;
                refund.SOSysNo         = netPayInfo.SOSysNo;
                refund.OrderSysNo      = netPayInfo.SOSysNo;
            }

            #endregion

            //#region PreCheck
            //m_soIncomeBL.PreCheckForCreate(soIncome);
            //if (refund != null)
            //{
            //    m_soIncomeRefundBL.PreCheckCreate(refund);
            //}
            //#endregion PreCheck

            #region Action
            SOIncomeInfo       soIncomeInfo = null;
            TransactionOptions options      = new TransactionOptions
            {
                IsolationLevel = IsolationLevel.ReadCommitted,
                Timeout        = TimeSpan.FromMinutes(2)
            };
            try
            {
                using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, options))
                {
                    //Step 1:向SOIncome写入一条收款记录
                    soIncomeInfo = CreateSOIncomeInfo(netPayInfo, so);

                    //Step 2:写退款信息
                    if (refund != null)
                    {
                        refund.SOIncomeSysNo = soIncomeInfo.SysNo;
                        refund.Status        = RefundStatus.Origin;
                        ObjectFactory <SOIncomeRefundProcessor> .Instance.Create(refund);
                    }
                    //Step 3:更新NetPay记录
                    m_NetpayDA.UpdateApproveInfo(netPaySysNo, NetPayStatus.Approved);

                    ts.Complete();
                }
            }
            catch
            {
                //Do not skip out
                //Log
            }

            #endregion

            //记录业务Log
            //BizLogger.WriteLog<NetPayEntity>(netPay, LogCategories.核对网上支付.ToString(),
            //    string.Format("End:[团购]用户\"{0}\"审核了编号为\"{1}\"网上支付单", netPay.OperationUserUniqueName, netPay.SysNo), netPay.SysNo.ToString(), (int)LogType.Finance_NetPay_Verify);
            ObjectFactory <ICommonBizInteract> .Instance.CreateOperationLog(
                GetMessageString("NetPay_Log_Audit", ServiceContext.Current.UserSysNo, netPaySysNo)
                , ECCentral.BizEntity.Common.BizLogType.Finance_NetPay_Verify
                , soIncomeInfo.SysNo.Value
                , soIncomeInfo.CompanyCode);
        }
Пример #17
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);
        }
Пример #18
0
        /// <summary>
        /// 处理电汇邮局收款单
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public virtual void Handle(PostIncomeInfo entity, string confirmedSOSysNoStr)
        {
            PreCheckForHandle(entity, confirmedSOSysNoStr);

            var postIncomeInfo = LoadBySysNo(entity.SysNo.Value);

            if (postIncomeInfo.ConfirmStatus.Value != PostIncomeStatus.Confirmed)
            {
                ThrowBizException("PostIncome_Handle_ConfirmStatusNotMatch");
            }

            //保证下面对ConfirmedSOSysNoList操作时不为NULL
            if (string.IsNullOrEmpty(confirmedSOSysNoStr))
            {
                confirmedSOSysNoStr = string.Empty;
            }
            string[] confirmedSOSysNoList = confirmedSOSysNoStr.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var confirmedSOSysNo in confirmedSOSysNoList)
            {
                //验证订单号是否有效
                var so = ExternalDomainBroker.GetSOBaseInfo(Convert.ToInt32(confirmedSOSysNo));
                if (!ObjectFactory <PostPayProcessor> .Instance.IsBankOrPostPayType(so.PayTypeSysNo.Value))
                {
                    ThrowBizException("PostIncome_NotMatchSOPayTypeSysNo", confirmedSOSysNo);
                }
            }

            List <int> abandonList       = new List <int>();
            var        postIncomeConfirm = postIncomeInfo.ConfirmInfoList;

            postIncomeConfirm.ForEach(p =>
            {
                int idx = confirmedSOSysNoStr.IndexOf(p.ConfirmedSoSysNo.ToString());
                if (idx < 0)
                {
                    if (p.Status == PostIncomeConfirmStatus.Audit)
                    {
                        ThrowBizException("PostIncome_StatusNotMatchAudit", p.ConfirmedSoSysNo);
                    }
                    if (p.Status == PostIncomeConfirmStatus.Related)
                    {
                        abandonList.Add(p.SysNo.Value);
                    }
                }
            });

            List <int>    updateList = new List <int>();
            List <string> errorList  = new List <string>();

            postIncomeConfirm = GetConfirmedListBySOSysNo(string.Join(",", confirmedSOSysNoList));
            postIncomeConfirm.ForEach(p =>
            {
                if (p.Status == PostIncomeConfirmStatus.Audit || (p.Status == PostIncomeConfirmStatus.Related && p.PostIncomeSysNo != entity.SysNo))
                {
                    errorList.Add(p.ConfirmedSoSysNo.ToString());
                }
                else
                {
                    updateList.Add(p.SysNo.Value);
                }
            });

            if (errorList.Count > 0)
            {
                ThrowBizException("PostIncome_StatusNotMatchRelated", string.Join(".", errorList.ToArray()));
            }

            List <PostIncomeConfirmInfo> insertEntityList = new List <PostIncomeConfirmInfo>();

            string[] confirmedSoList = confirmedSOSysNoList;
            foreach (string confirmedSo in confirmedSoList)
            {
                int  soNo  = Convert.ToInt32(confirmedSo);
                bool exist = postIncomeConfirm.Exists(p => p.ConfirmedSoSysNo == soNo);
                if (!exist)
                {
                    insertEntityList.Add(new PostIncomeConfirmInfo()
                    {
                        PostIncomeSysNo  = entity.SysNo,
                        ConfirmedSoSysNo = soNo
                    });
                }
            }

            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;
            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                abandonList.ForEach(p =>
                {
                    UpdatePostIncomeConfirmStatus(p, PostIncomeConfirmStatus.Cancel);//作废CS确认的订单
                });

                updateList.ForEach(p =>
                {
                    UpdatePostIncomeConfirmStatus(p, PostIncomeConfirmStatus.Related);//更新CS确认的订单
                });

                insertEntityList.ForEach(p =>
                {
                    CreatePostIncomeConfirm(p);//添加CS确认的订单
                });

                m_PostIncomeDA.Handle(entity);

                scope.Complete();
            }

            //记录操作日志
            ObjectFactory <ICommonBizInteract> .Instance.CreateOperationLog(
                GetMessageString("PostIncome_Log_Handle", ServiceContext.Current.UserSysNo, postIncomeInfo.SysNo)
                , BizLogType.Invoice_PostIncome_Handle
                , postIncomeInfo.SysNo.Value
                , postIncomeInfo.CompanyCode);
        }
Пример #19
0
        /// <summary>
        /// CS审核退款单
        /// </summary>
        public virtual void CSAudit(SOIncomeRefundInfo info)
        {
            var entity = LoadBySysNo(info.SysNo.Value);

            PreCheckForCSAudit(entity, info);

            var soEntity = ExternalDomainBroker.GetSOInfo(entity.SOSysNo.Value);

            //判断订单是否是【增票订单】
            if (soEntity == null)
            {
                //ThrowBizException("没有找到对应的订单");
                ThrowBizException("SOIncomeRefund_OrderNotFound");
            }
            //add by norton 2012-11-7

            {
                if (!soEntity.InvoiceInfo.IsVAT.Value)
                {
                    //不是【增票订单】,状态直接改为【已审核】
                    using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, options))
                    {
                        var flag = m_SOIncomeRefundDA.UpdateStatus(entity.SysNo.Value, ServiceContext.Current.UserSysNo, RefundStatus.Audit, DateTime.Now);
                        if (flag)
                        {
                            PassAudit(entity);
                        }


                        //发送cs审核退款审核Message
                        EventPublisher.Publish(new RefundCSAuditMessage()
                        {
                            RefundSysNo = entity.SysNo.Value,
                            CurrentUserSysNo = ServiceContext.Current.UserSysNo
                        });
                        ts.Complete();
                    }
                    //记录操作日志
                    ObjectFactory<ICommonBizInteract>.Instance.CreateOperationLog(
                        GetMessageString("SOIncomeRefund_Log_CSAudit", ServiceContext.Current.UserSysNo, entity.SysNo)
                       , BizLogType.AuditRefund_Update
                       , entity.SysNo.Value
                       , entity.CompanyCode);
                }
                else
                {
                    //是【增票订单】,状态改为【待财务审核】
                    using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, options))
                    {
                        m_SOIncomeRefundDA.UpdateStatus(entity.SysNo.Value, ServiceContext.Current.UserSysNo, RefundStatus.WaitingFinAudit, DateTime.Now);

                        //发送cs审核退款审核Message
                        EventPublisher.Publish(new RefundCSAuditMessage()
                        {
                            RefundSysNo = entity.SysNo.Value,
                            CurrentUserSysNo = ServiceContext.Current.UserSysNo
                        });
                        ts.Complete();
                    }

                    ObjectFactory<ICommonBizInteract>.Instance.CreateOperationLog(
                        GetMessageString("SOIncomeRefund_Log_CSAuditIsVAT", ServiceContext.Current.UserSysNo, entity.SysNo)
                        , BizLogType.AuditRefund_Update
                        , entity.SysNo.Value
                        , entity.CompanyCode);
                }
            }
        }