示例#1
0
        public virtual CustomerContactInfo LoadByRequestSysNo(int sysNo)
        {
            CustomerContactInfo entity = null;

            entity = da.Load(sysNo);
            if (entity == null)
            {
                RMARequestInfo request = ObjectFactory <IRequestDA> .Instance.LoadBySysNo(sysNo);

                if (request != null)
                {
                    entity = new CustomerContactInfo();
                    entity.ReceiveAddress   = request.Address;
                    entity.ReceiveAreaSysNo = request.AreaSysNo;
                    entity.ReceiveContact   = request.Contact;
                    entity.ReceiveName      = request.Contact;
                    entity.ReceivePhone     = request.Phone;
                    if (request.SOSysNo.HasValue)
                    {
                        SOInfo so = ExternalDomainBroker.GetSOInfo(request.SOSysNo.Value);
                        if (so != null)
                        {
                            entity.ReceiveCellPhone = so.ReceiverInfo.MobilePhone;
                            entity.ReceiveZip       = so.ReceiverInfo.Zip;
                        }
                    }
                }
            }
            return(entity);
        }
示例#2
0
 /// <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"));
     }
 }
示例#3
0
        public virtual void SendDunEmail(int OutboundSysNo, int RegisterSysNo, int SendMailCount, int SOSysNo)
        {
            if (outBoundDA.UpdateOutboundItemSendEmailCount(OutboundSysNo, RegisterSysNo, SendMailCount))
            {
                #region 构建邮件模板,调用EmailService发送邮件

                RMARegisterInfo registerInfo = ObjectFactory <IRegisterDA> .Instance.LoadBySysNo(RegisterSysNo);

                int productSysNo = registerInfo.BasicInfo.ProductSysNo.Value;

                ProductManagerInfo pmInfo  = ExternalDomainBroker.GetPMInfoByProductSysNo(productSysNo);
                ProductInfo        product = ExternalDomainBroker.GetProductInfo(productSysNo);

                DataRow  dr         = outBoundDA.GetOutboundBySysNo(OutboundSysNo);
                string   vendorName = string.Empty;
                DateTime outTime    = DateTime.Now;
                if (dr != null)
                {
                    vendorName = dr["VendorName"].ToString();
                    outTime    = Convert.ToDateTime(dr["OutTime"]);
                }
                int        vendorSysNo = Convert.ToInt32(dr["VendorSysNo"]);
                VendorInfo vendorInfo  = ExternalDomainBroker.GetVendorFinanceInfoByVendorSysNo(vendorSysNo);

                SOInfo soInfo   = ExternalDomainBroker.GetSOInfo(SOSysNo);
                string SODate   = soInfo.BaseInfo.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
                string Warranty = soInfo.Items.Where(p => p.ProductSysNo == productSysNo).FirstOrDefault().Warranty;

                //填充邮件模板
                KeyValueVariables vars = new KeyValueVariables();
                vars.Add("CurrentYear", DateTime.Now.Year);
                vars.Add("CurrentMonth", DateTime.Now.Month);
                vars.Add("CurrentDay", DateTime.Now.Day);
                vars.Add("CurrentTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                ///Load单件填充的数据
                vars.Add("RegisterSysNo", registerInfo.SysNo.Value);
                vars.Add("ProductID", product.ProductID);
                vars.Add("ProductName", product.ProductName);
                vars.Add("Memo", registerInfo.BasicInfo.Memo);
                vars.Add("RefundStatus", registerInfo.BasicInfo.RefundStatus);
                vars.Add("RevertStatus", registerInfo.RevertInfo.RevertStatus);
                vars.Add("ProductCost", registerInfo.BasicInfo.Cost);

                vars.Add("PMName", pmInfo.UserInfo.UserDisplayName);

                vars.Add("Day", GetTimeSpan(outTime).Days);
                vars.Add("Hour", GetTimeSpan(outTime).Hours);
                vars.Add("Secend", GetTimeSpan(outTime).Minutes);
                vars.Add("VendorName", vendorName);
                vars.Add("OutTime", outTime.ToString("yyyy-MM-dd HH:mm:ss"));

                vars.Add("SOSysNo", SOSysNo);
                vars.Add("SODate", SODate);
                vars.Add("Warranty", Warranty);

                vars.Add("IsContact", IsContactDesc(vendorInfo));
                vars.Add("PayPeriodType", vendorInfo.VendorFinanceInfo.PayPeriodType.PayTermsName);

                string ccAddress = AppSettingManager.GetSetting("RMA", "OutBoundNotReturnEmails");
                EmailHelper.SendEmailByTemplate(pmInfo.UserInfo.EmailAddress, ccAddress, "", "SendDunMailForOutBoundNotReturn", vars, null, true, true);
                #endregion
            }
        }
        public void CreateRequest4AutoRMA(int soSysNo, string inUser)
        {
            //0. Load Data
            SOInfo soInfo = ExternalDomainBroker.GetSOInfo(soSysNo);

            //1. Validation
            ValidateSOInfo(soInfo, soSysNo);
            ValidateIfExistValidRMA(soInfo.SysNo.Value);
            ValidateCanCallRequest(soInfo);

            //2. Create Request
            int    requestSysNo    = 0;
            string requestState    = "F";
            int    wareHouseNumber = -1;
            int    vendorSysNo     = GetVendorSysNoFromInUser(inUser);
            int    userSysNo       = AutoRMAUserSysNo;

            wareHouseNumber = GetWarehouseNumber(soInfo);

            string note = string.Empty;
            string memo = string.Empty;
            SellerPortalAutoRMALog sellerPortalAutoRMALog = GetSellerPortalAutoRMALog(soSysNo);

            if (sellerPortalAutoRMALog == null)
            {
                InsertSellerPortalAutoRMALog(soSysNo, inUser);
                sellerPortalAutoRMALog = GetSellerPortalAutoRMALog(soSysNo);
            }

            try
            {
                if (CreateRequest(soSysNo, userSysNo, note, memo, wareHouseNumber, ref requestSysNo))
                {
                    //设置日志状态
                    requestState = "S";
                }
            }
            catch (Exception ex)
            {
                requestState = "F";
                ExceptionHelper.HandleException(ex);
            }
            finally
            {
                UpdateSellerPortalAutoRMALog(soSysNo, requestState, DateTime.Now, sellerPortalAutoRMALog.RefundStatus, sellerPortalAutoRMALog.RefundTime.Value);
                sellerPortalAutoRMALog = GetSellerPortalAutoRMALog(soSysNo);
            }
            //3. Create Refund
            string refundStatus = "F";

            try
            {
                if (ObjectFactory <SellerPortalRefundProcessor> .Instance.CreateRMAAutoRefund(soSysNo, memo, wareHouseNumber, userSysNo, vendorSysNo))
                {
                    refundStatus = "S";
                }
            }
            catch (Exception ex)
            {
                refundStatus = "F";
                ExceptionHelper.HandleException(ex);
            }
            finally
            {
                UpdateSellerPortalAutoRMALog(soSysNo, sellerPortalAutoRMALog.RequestStatus, sellerPortalAutoRMALog.RequestTime.Value, refundStatus, DateTime.Now);
            }
        }
        /// <summary>
        /// 创建申请单于单件
        /// </summary>
        /// <param name="soNumber"></param>
        /// <param name="userID"></param>
        /// <param name="strNote"></param>
        /// <param name="strMemo"></param>
        /// <param name="warehouseNumber"></param>
        /// <param name="refRequestSysNo"></param>
        /// <returns></returns>
        private bool CreateRequest(int soNumber, int userSysNo, string strNote, string strMemo, int warehouseNumber, ref int refRequestSysNo)
        {
            bool result = false;

            SOInfo so = ExternalDomainBroker.GetSOInfo(soNumber);

            RMARequestInfo request = new RMARequestInfo();

            int requestSysNo = rmaSellerPortalDA.CreateSequence(TableName_RMA_Request_Sequence);

            string strRequestID = GenerateID(requestSysNo);

            request.SysNo            = requestSysNo;
            request.RequestID        = strRequestID;
            request.SOSysNo          = soNumber;
            request.CustomerSysNo    = so.BaseInfo.CustomerSysNo;
            request.Address          = so.ReceiverInfo.Address;
            request.Contact          = so.ReceiverInfo.Name;
            request.Phone            = so.ReceiverInfo.Phone;
            request.ReceiveTime      = DateTime.Now;
            request.ReceiveUserSysNo = userSysNo;
            request.Note             = strNote;
            request.Memo             = strMemo;
            request.Status           = RMARequestStatus.Handling;
            request.AreaSysNo        = so.ReceiverInfo.AreaSysNo;
            request.CustomerSendTime = DateTime.Now;
            request.IsRejectRMA      = true;
            request.ReceiveWarehouse = warehouseNumber.ToString();
            request.IsSubmit         = true;
            request.ShipViaCode      = "退换货自动处理,快递方式缺省";
            refRequestSysNo          = requestSysNo;
            request.CompanyCode      = so.CompanyCode;

            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                requestDA.Create(request);

#if DEBUG
                if (Transaction.Current != null)
                {
                    Debug.WriteLine(string.Format("LocalIdentifier:[{0}] Status:[{1}]",
                                                  Transaction.Current.TransactionInformation.LocalIdentifier,
                                                  Transaction.Current.TransactionInformation.Status.ToString())
                                    );
                }
#endif
                foreach (SOItemInfo soItem in so.Items)
                {
                    if (soItem.ProductType == SOProductType.Coupon)
                    {
                        continue;
                    }

                    for (int i = 0; i < soItem.Quantity; i++)
                    {
                        RMARegisterInfo register = new RMARegisterInfo();
                        register.CompanyCode = so.CompanyCode;

                        int registerSysNo = rmaSellerPortalDA.CreateSequence(TableName_RMA_Register_Sequence);

                        register.SysNo = registerSysNo;

                        if (soItem.ProductType == SOProductType.ExtendWarranty)
                        {
                            register.BasicInfo.ProductSysNo = int.Parse(soItem.MasterProductSysNo);
                            register.BasicInfo.OwnBy        = RMAOwnBy.Origin;
                            register.BasicInfo.Location     = RMALocation.Origin;
                        }
                        else
                        {
                            register.BasicInfo.ProductSysNo = soItem.ProductSysNo;
                            register.BasicInfo.OwnBy        = RMAOwnBy.Customer;
                            register.BasicInfo.Location     = RMALocation.Self;
                        }

                        register.RequestType            = RMARequestType.Return;
                        register.BasicInfo.CustomerDesc = "物流拒收";

                        register.BasicInfo.NextHandler   = RMANextHandler.RMA;
                        register.BasicInfo.Status        = RMARequestStatus.Handling;
                        register.BasicInfo.IsWithin7Days = true;

                        register.CheckInfo.IsRecommendRefund = true;

                        //HACK:大小写 Cost
                        register.BasicInfo.Cost            = soItem.CostPrice;
                        register.BasicInfo.RMAReason       = 0;//质量问题
                        register.BasicInfo.CloseUserSysNo  = userSysNo;
                        register.BasicInfo.CloseTime       = DateTime.Now;
                        register.BasicInfo.IsHaveInvoice   = true;
                        register.BasicInfo.IsFullAccessory = true;
                        register.BasicInfo.IsFullPackage   = true;
                        //RMA Warehouse
                        register.BasicInfo.LocationWarehouse = warehouseNumber.ToString();
                        register.BasicInfo.OwnByWarehouse    = ((int)RMAOwnBy.Origin).ToString();

                        //使用传过来的warehouseNumber
                        register.BasicInfo.ShippedWarehouse = warehouseNumber.ToString();

                        register.BasicInfo.SOItemType = soItem.ProductType;

                        bool insertRegisterResult = registerDA.Create(register);

                        bool inserRequestItemResult = registerDA.InsertRequestItem(requestSysNo, registerSysNo);

                        if (insertRegisterResult && inserRequestItemResult)
                        {
                            result = true;
                        }
                    }
                }
                scope.Complete();
            }

            return(result);
        }
示例#6
0
        private string ozzShip = AppSettingManager.GetSetting("RMA", "PushShipTypeName"); // 上门取件物流  "OZZO奥硕物流";

        /// <summary>
        /// 创建申请单
        /// </summary>
        /// <param name="request">申请单信息</param>
        /// <returns>申请单信息</returns>
        public virtual RMARequestInfo Create(RMARequestInfo request)
        {
            request.VerifyForCreate();

            if (request.ShipViaCode.Trim() == ozzShip)
            {
                //奥硕上门地点判断
                //ValidOZZOFetchToHome(request);
            }

            var refundItems = ObjectFactory <IRefundDA> .Instance.GetMasterByOrderSysNo(request.SOSysNo.Value);

            if (refundItems != null)
            {
                refundItems.ForEach(p =>
                {
                    if (p.Status == RMARefundStatus.Refunded && p.RefundReason.HasValue && p.RefundReason == 2)
                    {
                        throw new BizException(ResouceManager.GetMessageString("RMA.Request", "ExsitsNotCreateRequest"));
                    }
                });
            }

            SOInfo so = ExternalDomainBroker.GetSOInfo(request.SOSysNo.Value);

            if (so.BaseInfo.Status.Value != SOStatus.OutStock && so.BaseInfo.Status.Value != SOStatus.Shipping && so.BaseInfo.Status != SOStatus.Complete && so.BaseInfo.Status != SOStatus.Reported)
            {
                throw new BizException(ResouceManager.GetMessageString("RMA.Request", "OutStockNotCreateRequest"));
            }

            if (so.BaseInfo.SOType == SOType.ElectronicCard || so.BaseInfo.SOType == SOType.PhysicalCard)
            {
                throw new BizException(ResouceManager.GetMessageString("RMA.Request", "GiftCardNoRMA"));
            }
            if (so.BaseInfo.PayTypeSysNo == 203)
            {
                throw new BizException(ResouceManager.GetMessageString("RMA.Request", "RedeemGiftCertificatesNoRMA"));
            }


            if (so.BaseInfo.PayTypeSysNo.HasValue)
            {
                int t;

                if (int.TryParse(AppSettingManager.GetSetting(SOConst.DomainName, "GiftVoucher_PayTypeSysNo"), out t))
                {
                    if (so.BaseInfo.PayTypeSysNo.Value == t)
                    {
                        throw new BizException(ResouceManager.GetMessageString("RMA.Request", "GiftCertificatesNoRMA"));
                    }
                }
            }


            CustomerContactInfo customerContactInfoEntity = GetCustomerContactInfo(request);

            BizEntity.Invoice.DeliveryType shipType = BizEntity.Invoice.DeliveryType.SELF;
            InvoiceType?invoceType    = InvoiceType.SELF;
            StockType?  stockType     = StockType.SELF;
            int         merchantSysNo = 1;

            if (so != null)
            {
                shipType      = so.ShippingInfo.ShippingType;
                invoceType    = so.InvoiceInfo.InvoiceType;
                stockType     = so.ShippingInfo.StockType;
                merchantSysNo = so.BaseInfo.Merchant.MerchantID ?? 0;
            }

            using (TransactionScope tran = new TransactionScope())
            {
                request.SysNo     = CreateSysNo();
                request.RequestID = GenerateId(request.SysNo.Value);
                //创建申请单初始状态为【待审核】 add by norton 2012.11.21
                request.Status        = RMARequestStatus.WaitingAudit;
                request.IsSubmit      = true;
                request.ShippingType  = shipType;
                request.InvoiceType   = invoceType;
                request.StockType     = stockType;
                request.MerchantSysNo = merchantSysNo;
                requestDA.Create(request);

                customerContactInfoEntity.RMARequestSysNo = request.SysNo;

                customerContactInfoEntity.ReceiveCellPhone = so.ReceiverInfo.MobilePhone;
                customerContactInfoEntity.ReceiveZip       = so.ReceiverInfo.Zip;

                ObjectFactory <CustomerContactProcessor> .Instance.Create(customerContactInfoEntity);

                request.Registers.ForEach(register =>
                {
                    register.SysNo                       = registerDA.CreateSysNo();
                    register.BasicInfo.Status            = RMARequestStatus.Origin;
                    register.BasicInfo.OwnBy             = RMAOwnBy.Origin;
                    register.BasicInfo.Location          = RMALocation.Origin;
                    register.BasicInfo.IsWithin7Days     = false;
                    register.CheckInfo.IsRecommendRefund = false;
                    register.RevertInfo.NewProductStatus = RMANewProductStatus.Origin;
                    register.BasicInfo.NextHandler       = RMANextHandler.RMA;
                    register.CompanyCode                 = request.CompanyCode;

                    SOItemInfo item = so.Items.FirstOrDefault(p => p.ProductSysNo == register.BasicInfo.ProductSysNo.Value);
                    register.BasicInfo.ShippedWarehouse = item.StockSysNo.ToString();

                    register.VerifyCreate();

                    registerDA.Create(register);

                    registerDA.InsertRequestItem(request.SysNo.Value, register.SysNo.Value);

                    //创建成功后,发送邮件
                    //if (request.VerifyForSendCreateEmail())
                    //{
                    //    var customer = ExternalDomainBroker.GetCustomerInfo(request.CustomerSysNo.Value);
                    //    SendCreateEmail(customer.BasicInfo.Email, request.RequestID);
                    //}
                });

                tran.Complete();
            }

            ExternalDomainBroker.CreateOperationLog("RMA_Request_Create", BizLogType.RMA_Request_Create, request.SysNo.Value, request.CompanyCode);

            return(request);
        }