Esempio n. 1
0
        public virtual RefundInfo LoadBySysNo(int sysNo, out string customerName,
                                              out CustomerContactInfo contactInfo,
                                              out PromotionCode_Customer_Log promotionCodeLog)
        {
            RefundInfo refund = ObjectFactory <RefundProcessor> .Instance.LoadWithItemsBySysNo(sysNo);

            CustomerInfo customer = ExternalDomainBroker.GetCustomerInfo(refund.CustomerSysNo.Value);

            customerName          = customer.BasicInfo.CustomerName;
            refund.IncomeBankInfo = ExternalDomainBroker.GetSOIncomeRefundInfo(sysNo, RefundOrderType.RO);
            contactInfo           = null;
            if (refund.RefundPayType == RefundPayType.BankRefund && refund.IncomeBankInfo != null &&
                string.IsNullOrEmpty(refund.IncomeBankInfo.CardNumber))
            {
                if (refund.RefundItems != null && refund.RefundItems.Count > 0)
                {
                    RMARequestInfo request = ObjectFactory <RequestProcessor> .Instance.LoadByRegisterSysNo(refund.RefundItems[0].RegisterSysNo.Value);

                    contactInfo = ObjectFactory <CustomerContactProcessor> .Instance.LoadByRequestSysNo(request.SysNo.Value);
                }
            }
            promotionCodeLog = ExternalDomainBroker.GetPromotionCodeLog(refund.SOSysNo.Value);
            if (promotionCodeLog != null)
            {
                promotionCodeLog.UsedOrderSysNo = ExternalDomainBroker.GetSOSysNoByCouponSysNo(promotionCodeLog.CouponCodeSysNo.Value);
            }
            return(refund);
        }
Esempio n. 2
0
        /// <summary>
        /// 计算余额支付
        /// </summary>
        /// <param name="soInfo"></param>
        public virtual void CalculatePrePay(SOInfo soInfo)
        {
            if (!soInfo.BaseInfo.IsUsePrePay.Value)
            {
                soInfo.BaseInfo.PrepayAmount = null;
                return;
            }
#warning 需要再考虑修改订单

            //获取客户可用余额
            decimal validPrePay = ExternalDomainBroker.GetCustomerInfo(soInfo.BaseInfo.CustomerSysNo.Value).ValidPrepayAmt.Value;
            if (this.IsUpdate)
            {
                validPrePay += this.OriginalSOInfo.BaseInfo.PrepayAmount.Value;
            }

            //可供余额支付的订单金额
            decimal needPayAmt = soInfo.BaseInfo.CashPay
                                 + soInfo.BaseInfo.ShipPrice.Value
                                 + soInfo.BaseInfo.PremiumAmount.Value
                                 + soInfo.BaseInfo.PromotionAmount.Value
                                 + soInfo.BaseInfo.TariffAmount.Value
                                 - soInfo.BaseInfo.GiftCardPay.Value;

            //取"可供支付金额"与"客户可用余额"中较小值做为实际余额支付金额
            soInfo.BaseInfo.PrepayAmount = Math.Min(validPrePay, needPayAmt);
            if (soInfo.BaseInfo.PrepayAmount == 0)
            {
                soInfo.BaseInfo.PrepayAmount = null;
            }
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public virtual RMARegisterInfo LoadForEditBySysNo(int sysNo,
                                                          out string businessModel,
                                                          out ProcessType processType,
                                                          out InvoiceType?invoiceType,
                                                          out CustomerInfo customerInfo,
                                                          out RMARequestInfo requestInfo,
                                                          out List <ProductInventoryInfo> productInventoryInfo,
                                                          out int?refundSysNo,
                                                          out ProductInventoryType inventoryType)
        {
            RMARegisterInfo register = ObjectFactory <RegisterProcessor> .Instance.LoadForEditBySysNo(sysNo);

            refundSysNo = default(int?);
            if (register.BasicInfo.RefundStatus != null)
            {
                refundSysNo = ObjectFactory <RefundProcessor> .Instance.GetRefundSysNoByRegisterSysNo(register.SysNo.Value);
            }
            var request = ObjectFactory <RequestProcessor> .Instance.LoadByRegisterSysNo(register.SysNo.Value);

            requestInfo = request;

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

            processType   = ProcessType.UnKnown;
            invoiceType   = request.InvoiceType;
            inventoryType = ProductInventoryType.Company;
            //设置商家处理或泰隆优选处理
            if (request.InvoiceType.HasValue && request.ShippingType.HasValue && request.StockType.HasValue)
            {
                if (request.InvoiceType == InvoiceType.SELF && request.ShippingType == BizEntity.Invoice.DeliveryType.SELF && request.StockType == BizEntity.Invoice.StockType.SELF)
                {
                    processType = ProcessType.NEG;
                }
                else if (
                    (request.StockType == BizEntity.Invoice.StockType.MET && request.ShippingType == BizEntity.Invoice.DeliveryType.SELF && request.InvoiceType == InvoiceType.SELF)
                    ||
                    (request.StockType == BizEntity.Invoice.StockType.MET && request.ShippingType == BizEntity.Invoice.DeliveryType.SELF && request.InvoiceType == InvoiceType.MET)
                    ||
                    (request.StockType == BizEntity.Invoice.StockType.MET && request.ShippingType == BizEntity.Invoice.DeliveryType.MET && request.InvoiceType == InvoiceType.SELF)
                    ||
                    (request.StockType == BizEntity.Invoice.StockType.MET && request.ShippingType == BizEntity.Invoice.DeliveryType.MET && request.InvoiceType == InvoiceType.MET)
                    )
                {
                    processType = ProcessType.MET;
                }
            }

            //获取商品信息
            var product = ExternalDomainBroker.GetProductInfo(register.BasicInfo.ProductSysNo.Value);

            if (product != null)
            {
                register.BasicInfo.ProductID   = product.ProductID;
                register.BasicInfo.ProductName = product.ProductName;
                inventoryType = product.InventoryType;
            }

            if (register.RevertInfo.RevertProductSysNo != null)
            {
                if (register.RevertInfo.RevertProductSysNo == register.BasicInfo.ProductSysNo)//如果是同一Item,不用再次查询IM接口
                {
                    register.RevertInfo.RevertProductID = register.BasicInfo.ProductID;
                }
                else
                {
                    var revertProduct = ExternalDomainBroker.GetProductInfo(register.RevertInfo.RevertProductSysNo.Value);
                    if (revertProduct != null)
                    {
                        register.RevertInfo.RevertProductID = revertProduct.ProductID;
                    }
                }
            }
            customerInfo = ExternalDomainBroker.GetCustomerInfo(request.CustomerSysNo.Value);

            //获取库存信息以及二手品信息
            var rPorductList = GetSecondProductInfoList(register.BasicInfo.ProductID);
            List <ProductInventoryInfo> inventoryInfoList = new List <ProductInventoryInfo>();

            foreach (var obj in rPorductList)
            {
                inventoryInfoList.Add(ObjectFactory <RegisterProcessor> .Instance.GetWarehouseProducts(processType, int.Parse(obj.SysNo.ToString()), register.BasicInfo.ShippedWarehouse)[0]);
            }

            productInventoryInfo = ObjectFactory <RegisterProcessor> .Instance.GetWarehouseProducts(processType, register.BasicInfo.ProductSysNo.Value, register.BasicInfo.ShippedWarehouse);

            if (productInventoryInfo != null && productInventoryInfo.Count > 0)
            {
                productInventoryInfo.ForEach(p =>
                {
                    p.ProductID = register.BasicInfo.ProductID;
                });
                if (inventoryInfoList != null && inventoryInfoList.Count > 0)
                {
                    for (int i = 0; i < inventoryInfoList.Count; i++)
                    {
                        inventoryInfoList[i].ProductID = rPorductList[i].ProductID;
                        productInventoryInfo.Add(inventoryInfoList[i]);
                    }
                }
            }
            return(register);
        }
Esempio n. 5
0
        /// <summary>
        /// 检查规则-公共部分
        /// </summary>
        /// <param name="entity"></param>
        private void CheckRules(SOInfo entity)
        {
            //初始临时审核用户
            m_auditUserSysNoTemp = m_auditUserSysNo;

            #region 已在提取的时候进行过滤

            //#region  订单金额为0

            //if (entity.BaseInfo.SOTotalAmount == 0)
            //{
            //    ThrowException(entity, "订单金额为零,不能通过自动审核");
            //}

            //#endregion

            //#region  配送区域不能为空

            //if (!entity.ReceiverInfo.AreaSysNo.HasValue || entity.ReceiverInfo.AreaSysNo.Value <= 0)
            //{
            //    ThrowException(entity, "配送区域无效,不能通过自动审核");
            //}

            //#endregion

            #endregion

            #region  Intel用户订单不能通过自动审核

            var custom = ExternalDomainBroker.GetCustomerInfo(entity.BaseInfo.CustomerSysNo.Value);
            if (custom.BasicInfo.FromLinkSource == m_interOrder)
            {
                ThrowException(entity, "Intel用户所下订单不能通过自动审核");
            }

            #endregion

            #region 订单备注,订单说明,客户备注有特殊要求 - 不能通过自动审核

            if (!string.IsNullOrEmpty(entity.BaseInfo.Memo) ||
                !string.IsNullOrEmpty(entity.BaseInfo.Note) ||
                !string.IsNullOrEmpty(entity.InvoiceInfo.InvoiceNote))
            {
                ThrowException(entity, "订单备注,订单说明,客户备注有特殊要求");
            }

            #endregion

            #region 参加团购的订单 - 不能通过自动审核

            if (entity.BaseInfo.IsWholeSale.HasValue &&
                entity.BaseInfo.IsWholeSale.Value)
            {
                ThrowException(entity, "此订单为团购订单");
            }

            #endregion

            #region 订单为:非待审核状态 - 不能通过自动审核
            //提取提单时已按此条件过滤
            #endregion

            #region 订单为:订单锁定 - 不能通过自动审核
            //提取提单时已按此条件过滤
            #endregion

            #region 订单为恶意用户下单 - 不能通过自动审核

            if (m_malevolenceCustomers.Count > 0 &&
                m_malevolenceCustomers.Exists(x =>
            {
                return(x.SysNo.Value == entity.BaseInfo.CustomerSysNo.Value);
            }))
            {
                ThrowException(entity, "订单为恶意用户下单");
            }
            #endregion

            #region 产品无现货(即产品存在“虚库不足”,“待采购”字样) - 不能通过自动审核

            //虚库不足,待采购
            if (entity.ShippingInfo.StockType == StockType.SELF &&
                entity.ShippingInfo.ShippingType == BizEntity.Invoice.DeliveryType.SELF &&
                entity.InvoiceInfo.InvoiceType == InvoiceType.SELF &&
                entity.BaseInfo.Status == SOStatus.Origin &&
                entity.FPInfo.IsFPCheck.HasValue &&
                entity.StatusChangeInfoList.Count == 0
                )
            {
                LoadItems(entity);
                //标志虚库不足和待采购
                ObjectFactory <SOProcessor> .Instance.SetItemOutStockInfo(entity);

                if (entity.Items.Exists(p => p.IsLessStock || p.IsWaitPO))
                {
                    ThrowException(entity, "产品无现货(即产品存在“虚库不足”,“待采购”字样)");
                }
            }

            #endregion

            #region 订单中的信息与关键字匹配则 - 不能通过自动审核

            if (m_auditSwitch.IsCheckKeyWords)
            {
                // 关键字(接收地址)
                if (entity.ReceiverInfo.Address.IsContains(m_dispassReceiveAddressList))
                {
                    ThrowException(entity, "订单中收货地址信息存在特殊关键字 - 不能通过自动审核");
                }

                // 关键字(手机 精确匹配)
                if (entity.ReceiverInfo.MobilePhone.IsEquals(m_dispassReceiveCellPhoneOrPhoneList))
                {
                    ThrowException(entity, "订单中的手机信息存在特殊关键字 - 不能通过自动审核");
                }

                // 关键字(电话 精确匹配)
                if (entity.ReceiverInfo.Phone.IsEquals(m_dispassReceiveCellPhoneOrPhoneList))
                {
                    ThrowException(entity, "订单中的电话信息存在特殊关键字 - 不能通过自动审核");
                }

                // 关键字(收货联系人)
                if (entity.ReceiverInfo.Name.IsContains(m_dispassReceiveContactList))
                {
                    ThrowException(entity, "订单中收货联系人信息存在特殊关键字 - 不能通过自动审核");
                }
            }

            #endregion

            #region 订单 的配送方式、支付方式 属于限定配送方式 - 不能通过自动审核
            //提取时过滤
            //if ((entity.BaseInfo.PayTypeSysNo ?? 0) == 0)
            //{
            //    ThrowException(entity, "订单的支付方式为空 - 不能通过自动审核");
            //}
            if (m_auditSwitch.IsCheckPayType && m_dispassPayTypeSysNoList.Contains(entity.BaseInfo.PayTypeSysNo.Value))
            {
                ThrowException(entity, "订单的支付方式属于限定支付方式 - 不能通过自动审核");
            }

            //提取时过滤
            //if ((entity.ShippingInfo.ShipTypeSysNo ?? 0) == 0)
            //{
            //    ThrowException(entity, "订单的配送方式为空 - 不能通过自动审核");
            //}
            if (m_auditSwitch.IsCheckShipType && m_dispassShipTypeSysNoList.Contains(entity.ShippingInfo.ShipTypeSysNo.Value))
            {
                ThrowException(entity, "订单的配送方式属于限定配送方式 - 不能通过自动审核");
            }

            #endregion

            #region 根据FP状态判断订单是否可以通过自动审核

            if (m_auditSwitch.IsCheckFPStatus)
            {
                if (m_fpSwitch.IsCheckCC &&
                    entity.FPInfo.FPSOType.HasValue &&
                    entity.FPInfo.FPSOType.Value == FPSOType.ChaoHuo)
                {
                    ThrowException(entity, "订单为炒货订单,不能通过自动审核");
                }
                else if (m_fpSwitch.IsCheckKY &&
                         entity.FPInfo.FPSOType.HasValue &&
                         entity.FPInfo.FPSOType.Value == FPSOType.KeYi)
                {
                    ThrowException(entity, "订单为可疑订单,不能通过自动审核");
                }
                else if (m_fpSwitch.IsCheckCH &&
                         entity.FPInfo.FPSOType.HasValue &&
                         entity.FPInfo.FPSOType.Value == FPSOType.ChuanHuo)
                {
                    ThrowException(entity, "订单为串货订单,不能通过自动审核");
                }

                if (m_fpSwitch.IsCheckCF &&
                    entity.IsDuplicateOrder.HasValue &&
                    entity.IsDuplicateOrder.Value)
                {
                    ThrowException(entity, "订单为重复订单,不能通过自动审核");
                }
            }

            #endregion

            #region 根据订单的客户类型判断订单是否可以通过审核

            if (m_auditSwitch.IsCheckCustomerType)
            {
                var kfcCustomer = ObjectFactory <ISOKFCDA> .Instance.GetKFCByCustomerSysNo(entity.BaseInfo.CustomerSysNo.Value);

                if (kfcCustomer != null)
                {
                    if (m_customerTypeSwitch.IsCheckCustomerZC && kfcCustomer.KFCType == KFCType.Normal)
                    {
                        ThrowException(entity, "正常用户类型,不能通过自动审核");
                    }
                    if (m_customerTypeSwitch.IsCheckCustomerKY && kfcCustomer.KFCType == KFCType.KeYi)
                    {
                        ThrowException(entity, "可疑用户类型,不能通过自动审核");
                    }
                    if (m_customerTypeSwitch.IsCheckCustomerQZ && kfcCustomer.KFCType == KFCType.QiZha)
                    {
                        ThrowException(entity, "欺诈用户类型,不能通过自动审核");
                    }
                }
            }

            #endregion

            #region 根据 自动审核检查项:增值税发票: 订单中含有增值税发票则不能通过自动审核。
            if (m_auditSwitch.IsCheckVAT)
            {
                if (entity.InvoiceInfo.IsVAT.HasValue && entity.InvoiceInfo.IsVAT.Value)
                {
                    ThrowException(entity, "订单中含有增值税发票 - 不能通过自动审核");
                }
            }
            #endregion

            #region 根据 自动审核检查项:订单中使用积分或者优惠券超过50% : 单张订单金额中使用积分或者优惠券超过50% - 不能通过自动审核

            if (m_auditSwitch.IsCheckPointPromotion)
            {
                var couponItems = entity.Items.Where(p => p.ProductType == SOProductType.Coupon);
                if ((entity.BaseInfo.PointPay / ExternalDomainBroker.GetPointToMoneyRatio() > entity.BaseInfo.SOAmount / 2.0M) ||
                    couponItems.Count() > 0)
                {
                    if (entity.BaseInfo.PointPay / ExternalDomainBroker.GetPointToMoneyRatio() > entity.BaseInfo.SOAmount / 2.0M)
                    {
                        ThrowException(entity, "单张订单金额中使用积分超过50%  - 不能通过自动审核");
                    }
                    if (couponItems.Count() > 0)
                    {
                        //获取优惠券
                        foreach (var item in couponItems)
                        {
                            if (item.Price.Value / 1.0M > entity.BaseInfo.SOAmount / 2.0M)
                            {
                                ThrowException(entity, "单张订单金额中使用优惠券超过50%  - 不能通过自动审核");
                            }
                        }
                    }
                }
            }

            #endregion

            #region 含有对应产品类别的产品的订单(C3类)将不能通过自动审核

            if (m_auditSwitch.IsCheckProductType)
            {
                //3C验证必须先满足现在情况才进行
                //SM.Status = 0 AND (SM.AuditUserSysNo IS NULL OR SM.AuditTime IS NULL)  AND SCKP.IsFPCheck IS NOT NULL AND SCKP.AuditType IS NULL
                if (entity.BaseInfo.Status == SOStatus.Origin &&
                    entity.FPInfo.IsFPCheck.HasValue &&
                    entity.StatusChangeInfoList.Count == 0)
                {
                    //商品验证才需要读取Item
                    LoadItems(entity);
                    //判断商品是否有在指定中
                    foreach (var item in entity.Items)
                    {
                        if (item.ProductType != SOProductType.Coupon)
                        {
                            //获取商品信息
                            var product = ExternalDomainBroker.GetProductSimpleInfo(item.ProductSysNo.Value);
                            if (product != null)
                            {
                                if (m_csTBOrderCheckItemList.Exists(p => p.Description == product.ProductBasicInfo.ProductCategoryInfo.SysNo.ToString() &&
                                                                    p.ReferenceType == "PC3" &&
                                                                    p.Status == OrderCheckStatus.Invalid))
                                {
                                    ThrowException(entity, "订单中有指定C3类产品 - 不能通过自动审核");
                                }
                                if (m_csTBOrderCheckItemList.Exists(p => p.ReferenceContent == product.ProductID &&
                                                                    p.ReferenceType == "PID" &&
                                                                    p.Status == OrderCheckStatus.Invalid))
                                {
                                    ThrowException(entity, "订单中有指定产品ID - 不能通过自动审核");
                                }
                            }
                        }
                    }
                }
            }

            #endregion

            #region 自动审单对配送时间按照一日一送、一日两送的规则进行检查

            if (entity.ShippingInfo.DeliveryDate.HasValue)
            {
                if (m_auditSwitch.IsCheckShipServiceType)
                {
                    //过滤 产品类别列表信息 (PC3:产品类别)
                    var csItem = m_csTBOrderCheckItemList.FirstOrDefault(x =>
                    {
                        return((x.ReferenceType == "DT11" || x.ReferenceType == "DT12") &&
                               x.Status == OrderCheckStatus.Invalid &&
                               x.ReferenceContent.Trim() == entity.ShippingInfo.ShipTypeSysNo.ToString());
                    });
                    if (csItem != null)
                    {
                        CheckDeliverDateV2(entity, csItem);
                    }
                }
            }

            #endregion

            #region 付款验证

            if (m_payTypeList.Count > 0 &&
                m_payTypeList.Exists(x =>
            {
                return(x.SysNo == entity.BaseInfo.PayTypeSysNo &&
                       (x.IsPayWhenRecv ?? false)
                       );
            }))
            {
                //分支验证货到付款
                CheckCODSO(entity, custom);
                PassCODSO(entity);
                EndAudit(entity);
            }
            else
            {
                //分支验证款到发货
                bool       isRetry;
                NetPayInfo soNetPayinfo = CheckPIASO(entity, out isRetry);
                //对于不需要再次审核的记录做处理
                if (!isRetry)
                {
                    PassPIASO(entity, soNetPayinfo);
                    EndAudit(entity);
                }
            }

            #endregion
        }