Example #1
0
        /// <summary>
        /// 作废申请单
        /// </summary>
        /// <param name="sysNo">申请单编号</param>
        /// <returns>是否成功</returns>
        public virtual bool Abandon(int sysNo)
        {
            RMARequestInfo request = LoadBySysNo(sysNo);

            request.VerifyAbandon(request);

            request.Status    = RMARequestStatus.Abandon;
            request.Registers = registerProcessor.LoadByRequestSysNo(sysNo);
            request.Registers.ForEach(reg => { reg.BasicInfo.Status = request.Status; });

            bool result;

            TransactionOptions options = new TransactionOptions();

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

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                result = UpdateWithRegisters(request);

                scope.Complete();
            }

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

            return(result);
        }
Example #2
0
        /// <summary>
        /// 待退款
        /// </summary>
        /// <param name="sysNo"></param>
        /// <returns></returns>
        public virtual RMARegisterInfo SetWaitingRefund(int sysNo)
        {
            if (!registerDA.CanWaitingRefund(sysNo))
            {
                string msg = ResouceManager.GetMessageString("RMA.Request", "CannotSetWaitingRefund");
                throw new BizException(msg);
            }

            RMARegisterInfo register = LoadBySysNo(sysNo);

            //同步到ERP
            SyncERPAction(register);

            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted;
            options.Timeout        = TimeSpan.FromMinutes(2);
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, options))
            {
                registerDA.UpdateRefundStatus(sysNo, RMARefundStatus.WaitingRefund);

                ExternalDomainBroker.CreateOperationLog("RMA_Register_Refund", BizLogType.RMA_Register_Refund, sysNo, register.CompanyCode);

                ts.Complete();
            }

            return(LoadBySysNo(sysNo));
        }
Example #3
0
        /// <summary>
        /// 退款
        /// </summary>
        /// <param name="entity">退款实体信息</param>
        /// <returns>退款结果</returns>
        public ResponseResult Refund(ChinaPayEntity entity)
        {
            var result = new ResponseResult();

            refundPostData.OrderId = entity.SOSysNo.ToString().PadLeft(16, '0');
            //退款金额单位"分"
            refundPostData.RefundAmount = (Math.Round(entity.RefundAmt * 100)).ToString().PadLeft(12, '0');;
            refundPostData.Priv1        = entity.RefundSysNo.ToString();
            refundPostData.TransDate    = String.Format("{0:yyyyMMdd}", entity.OrderDate);
            refundPostData.ChkValue     = SignData(refundPostData.GetRawChkValue());


            byte[] data = Encoding.UTF8.GetBytes(refundPostData.ToString());

            string rawResult = PostData(data);

            //响应日志
            result = new ResponseResult(rawResult);
            string message = result.Message;

            if (result.Exception != null)
            {
                message = result.Exception.Message;
            }
            string resultNote = string.Format("用户[{0}]对订单号:{1} 调用了退款接口.调用结果;{2} 调用返回信息:{3} PostUrl:{4} ", ServiceContext.Current.UserSysNo, entity.SOSysNo, result.Result, message, RefundUrl);

            ExternalDomainBroker.CreateOperationLog(resultNote, BizLogType.RMA_Refund_Refund, entity.RefundSysNo, entity.CompanyCode);
            return(result);
        }
Example #4
0
        public virtual RMARequestInfo Adjust(int sysNo)
        {
            string ServiceCode = requestDA.CreateServiceCode();

            if (string.IsNullOrEmpty(ServiceCode) || ServiceCode.Length != 6)
            {
                throw new ArgumentNullException(ResouceManager.GetMessageString("RMA.Request", "ServiceCodeError"));
            }
            else
            {
                RMARequestInfo request = LoadBySysNo(sysNo);
                request.VerifyAuditPassed(request);
                request.ServiceCode    = ServiceCode;
                request.Status         = RMARequestStatus.Origin;
                request.Registers      = registerProcessor.LoadByRequestSysNo(request.SysNo.Value);
                request.AuditTime      = DateTime.Now;
                request.AuditUserSysNo = ServiceContext.Current.UserSysNo;
                bool result = UpdateWithRegisters(request);

                if (request.IsReceiveMsg == true && !string.IsNullOrEmpty(request.Phone) &&
                    request.ShippingType == BizEntity.Invoice.DeliveryType.SELF && request.StockType == StockType.SELF && request.InvoiceType == InvoiceType.SELF)
                {
                    string message = string.Format(ResouceManager.GetMessageString("RMA.Request", "SMSAuditRMARequest"), request.RequestID, request.ServiceCode);
                    ExternalDomainBroker.SendSMS(request.Phone, message);
                }

                if (result)
                {
                    ExternalDomainBroker.CreateOperationLog("RMA_Request_Audit", BizLogType.RMA_Request_Audit, request.SysNo.Value, request.CompanyCode);
                }
                return(request);
            }
        }
Example #5
0
        /// <summary>
        /// 更新返还信息
        /// </summary>
        /// <param name="register"></param>
        /// <returns></returns>
        public virtual RMARegisterInfo UpdateResponseInfo(RMARegisterInfo register)
        {
            if (register == null)
            {
                throw new ArgumentNullException("register");
            }
            CommonCheck.VerifyNotNull("SysNo", register.ResponseInfo.SysNo);

            RMARegisterInfo origin = LoadBySysNo(register.ResponseInfo.SysNo.Value);

            if (origin.BasicInfo.Status == RMARequestStatus.Complete || origin.BasicInfo.Status == RMARequestStatus.Abandon)
            {
                string msg = ResouceManager.GetMessageString("RMA.Request", "CannotEditWhenClosedOrAbandon");
                throw new BizException(msg);
            }

            CommonCheck.VerifyNotNull("ResponseProductNo", register.ResponseInfo.ResponseProductNo);

            string userName = ExternalDomainBroker.GetUserInfo(ServiceContext.Current.UserSysNo).UserDisplayName;

            register.ResponseInfo.ResponseDesc = string.Format(
                "{0}\r\n{1} {2}",
                register.ResponseInfo.ResponseDesc, userName, DateTime.Now.ToString("yyyy-MM-dd")
                );
            register.VerifyFieldsLength();

            registerDA.UpdateResponseInfo(register);

            ExternalDomainBroker.CreateOperationLog("RMA_Register_ResponseInfo", BizLogType.RMA_Register_ResponseInfo, register.SysNo.Value, origin.CompanyCode);

            return(LoadForEditBySysNo(register.ResponseInfo.SysNo.Value));
        }
Example #6
0
        /// <summary>
        /// 关闭申请单
        /// </summary>
        /// <param name="sysNo">系统编号</param>
        /// <returns>是否成功</returns>
        public virtual bool Close(int sysNo)
        {
            RMARequestInfo request = LoadBySysNo(sysNo);

            request.Status    = RMARequestStatus.Complete;
            request.Registers = registerProcessor.LoadByRequestSysNo(request.SysNo.Value);

            request.Registers.ForEach(register =>
            {
                register.BasicInfo.CloseTime      = DateTime.Now;
                register.BasicInfo.CloseUserSysNo = ServiceContext.Current.UserSysNo;
            });

            bool result;
            TransactionOptions options = new TransactionOptions();

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

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                result = UpdateWithRegisters(request);

                scope.Complete();
            }

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

            return(result);
        }
Example #7
0
        /// <summary>
        /// 更新全部信息
        /// </summary>
        /// <param name="register"></param>
        public virtual void Update(RMARegisterInfo register)
        {
            if (register == null)
            {
                throw new ArgumentNullException("register");
            }
            if (!register.BasicInfo.SysNo.HasValue)
            {
                throw new ArgumentNullException("register.SysNo");
            }
            RMARegisterInfo originRegister = LoadBySysNo(register.BasicInfo.SysNo.Value);

            register.VerifyUpdate(originRegister);

            if (originRegister.BasicInfo.NextHandler != register.BasicInfo.NextHandler)
            {
                BizLogType?logType = GetNextHandlerLogType(register.BasicInfo.NextHandler);

                if (logType.HasValue)
                {
                    ExternalDomainBroker.CreateOperationLog(logType.ToString(), logType.Value, register.SysNo.Value, originRegister.CompanyCode);
                }
            }
            registerDA.PurelyUpdate(register);
        }
Example #8
0
        /// <summary>
        /// 更新申请单Lable打印信息
        /// </summary>
        /// <param name="sysNo">系统编号</param>
        /// <returns>是否成功</returns>
        public virtual bool PrintLables(int sysNo)
        {
            bool result = requestDA.PrintLabels(sysNo);

            RMARequestInfo request = LoadBySysNo(sysNo);

            ExternalDomainBroker.CreateOperationLog("RMA_Request_PrintLabels", BizLogType.RMA_Request_PrintLabels, sysNo, request.CompanyCode);

            return(result);
        }
Example #9
0
        /// <summary>
        /// 取消接收申请单
        /// </summary>
        /// <param name="sysNo">系统编号</param>
        /// <returns>是否成功</returns>
        public virtual bool CancelReceive(int sysNo)
        {
            RMARequestInfo request = LoadWithRegistersBySysNo(sysNo);

            request.VerifyCancelReceive();

            using (TransactionScope tran = new TransactionScope())
            {
                //[Jay]:OZZO奥硕物流上门取返修件或返还50点积分 2010-01-28
                //VoidTransferPostage2Point(request);

                request.Status           = RMARequestStatus.Origin;
                request.ReceiveWarehouse = null;
                request.ReceiveTime      = null;
                request.ReceiveUserSysNo = null;
                request.IsViaPostOffice  = null;
                request.PostageToPoint   = null;
                request.ReturnPoint      = null;
                request.Registers        = registerProcessor.LoadByRequestSysNo(request.SysNo.Value);

                // 先更新 RMA Inventory
                // 更新后再重置 LocationWarehouse
                UpdateInventory(request.Registers, false);

                request.Registers.ForEach(reg =>
                {
                    reg.BasicInfo.OwnBy             = RMAOwnBy.Origin;
                    reg.BasicInfo.Location          = RMALocation.Origin;
                    reg.BasicInfo.Cost              = null;
                    reg.BasicInfo.Status            = request.Status;
                    reg.BasicInfo.LocationWarehouse = ((int)RMALocation.Origin).ToString();
                    reg.BasicInfo.RefundStatus      = null;
                    reg.RevertInfo.RevertStatus     = null;
                    reg.BasicInfo.OutBoundStatus    = null;
                    reg.BasicInfo.ReturnStatus      = null;
                });

                requestDA.Update(request);

                request.Registers.ForEach(reg =>
                {
                    registerProcessor.Update(reg);
                });

                tran.Complete();
            }

            ExternalDomainBroker.CreateOperationLog("RMA_Request_CancelRecieve", BizLogType.RMA_Request_CancelReceive, request.SysNo.Value, request.CompanyCode);
            return(true);
        }
Example #10
0
        /// <summary>
        /// 待送修
        /// </summary>
        /// <param name="sysNo"></param>
        /// <returns></returns>
        public virtual RMARegisterInfo SetWaitingOutbound(int sysNo)
        {
            if (!registerDA.CanWaitingOutbound(sysNo))
            {
                string msg = ResouceManager.GetMessageString("RMA.Request", "CannotSetWaitingOutbound");
                throw new BizException(msg);
            }
            registerDA.UpdateOutboundStatus(sysNo, RMAOutBoundStatus.Origin);

            RMARegisterInfo register = LoadBySysNo(sysNo);

            ExternalDomainBroker.CreateOperationLog("RMA_Register_Outbound", BizLogType.RMA_Register_Outbound, sysNo, register.CompanyCode);

            return(register);
        }
Example #11
0
        /// <summary>
        /// 取消待退货
        /// </summary>
        /// <param name="sysNo"></param>
        /// <returns></returns>
        public virtual bool CancelWaitingReturn(int sysNo)
        {
            if (!registerDA.CanCancelWaitingReturn(sysNo))
            {
                string msg = ResouceManager.GetMessageString("RMA.Request", "CannotCancelWaitingReturn");
                throw new BizException(msg);
            }

            bool result = registerDA.UpdateReturnStatus(sysNo, null);

            RMARegisterInfo register = LoadBySysNo(sysNo);

            ExternalDomainBroker.CreateOperationLog("RMA_Register_Return", BizLogType.RMA_Register_Return, sysNo, register.CompanyCode);

            return(result);
        }
Example #12
0
        /// <summary>
        /// 关闭单件
        /// </summary>
        /// <param name="register"></param>
        /// <returns></returns>
        public virtual RMARegisterInfo Close(int sysNo)
        {
            RMARegisterInfo original = LoadBySysNo(sysNo);

            original.VerifyClose(original);

            original.BasicInfo.Status = RMARequestStatus.Complete;

            TransactionOptions options = new TransactionOptions
            {
                IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted,
                Timeout        = TransactionManager.DefaultTimeout
            };

            //using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                //先关闭单件
                registerDA.Close(original);

                RMARequestInfo request = ObjectFactory <RequestProcessor> .Instance.LoadByRegisterSysNo(sysNo);

                request.Registers = LoadByRequestSysNo(request.SysNo.Value);
                //判断所有单件是否都已关闭
                bool allClosed = true;
                request.Registers.ForEach(reg =>
                {
                    if (reg.BasicInfo.Status == RMARequestStatus.Handling)
                    {
                        allClosed = false;
                    }
                });
                //关闭申请单
                if (allClosed && request.Status != RMARequestStatus.Complete)
                {
                    request.Status = RMARequestStatus.Complete;

                    ObjectFactory <RequestProcessor> .Instance.UpdateWithoutRegisters(request);
                }

                //scope.Complete();
            }

            ExternalDomainBroker.CreateOperationLog("RMA_Register_Close", BizLogType.RMA_Register_Close, sysNo, original.CompanyCode);

            return(LoadForEditBySysNo(sysNo));
        }
Example #13
0
        public virtual RMARequestInfo Refused(int sysNo)
        {
            RMARequestInfo request = LoadBySysNo(sysNo);

            request.VerifyAuditRefuesed(request);

            request.Status    = RMARequestStatus.AuditRefuesed;
            request.Registers = registerProcessor.LoadByRequestSysNo(request.SysNo.Value);

            bool result = UpdateWithRegisters(request);

            if (result)
            {
                ExternalDomainBroker.CreateOperationLog("RMA_Request_Refused", BizLogType.RMA_Request_Refused, request.SysNo.Value, request.CompanyCode);
            }
            return(request);
        }
Example #14
0
        /// <summary>
        /// 待发货
        /// </summary>
        /// <param name="register"></param>
        /// <returns></returns>
        public virtual RMARegisterInfo SetWaitingRevert(RMARegisterInfo register)
        {
            register.VerifyWaitingRevert();

            RMARegisterInfo original = LoadBySysNo(register.RevertInfo.SysNo.Value);

            original.RevertInfo.NewProductStatus     = register.RevertInfo.NewProductStatus;
            original.RevertInfo.SetWaitingRevertTime = DateTime.Now;
            // 非换货时 RevertStockSysNo 留空
            original.RevertInfo.RevertStockSysNo = register.RevertInfo.NewProductStatus == RMANewProductStatus.Origin
                ? null
                : register.RevertInfo.RevertStockSysNo;
            // 非换货或者调新品时,直接将原始 ProductSysNo 设置到 RevertProductSysNo
            original.RevertInfo.RevertProductSysNo = (register.RevertInfo.NewProductStatus == RMANewProductStatus.Origin || register.RevertInfo.NewProductStatus == RMANewProductStatus.NewProduct)
                ? register.BasicInfo.ProductSysNo
                : register.RevertInfo.RevertProductSysNo;
            // 非当前 Case 产品需要进行审批
            original.RevertInfo.RevertStatus = register.RevertInfo.NewProductStatus == RMANewProductStatus.OtherProduct
                ? RMARevertStatus.WaitingAudit
                : RMARevertStatus.WaitingRevert;
            //同步到ERP
            SyncERPAction(original);

            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted;
            options.Timeout        = TimeSpan.FromMinutes(2);
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, options))
            {
                registerDA.UpdateRevertStatus(original);

                ExternalDomainBroker.CreateOperationLog("RMA_Register_Revert", BizLogType.RMA_Register_Revert, register.SysNo.Value, original.CompanyCode);

                ts.Complete();
            }

            return(LoadBySysNo(register.SysNo.Value));
        }
Example #15
0
        /// <summary>
        /// 重新打开单件
        /// </summary>
        /// <param name="sysNo"></param>
        /// <returns></returns>
        public virtual RMARegisterInfo ReOpen(int sysNo)
        {
            if (!registerDA.CanReOpen(sysNo))
            {
                string msg = ResouceManager.GetMessageString("RMA.Request", "CannotReopen");
                throw new BizException(msg);
            }

            RMARegisterInfo register = new RMARegisterInfo();

            register.BasicInfo.SysNo          = sysNo;
            register.BasicInfo.CloseUserSysNo = null;
            register.BasicInfo.CloseTime      = null;
            register.BasicInfo.Status         = RMARequestStatus.Handling;

            bool result = registerDA.ReOpen(register);

            RMARegisterInfo re = LoadBySysNo(sysNo);

            ExternalDomainBroker.CreateOperationLog("RMA_Register_Close", BizLogType.RMA_Register_Close, sysNo, re.CompanyCode);

            return(re);
        }
Example #16
0
        /// <summary>
        /// 取消待发货
        /// </summary>
        /// <param name="sysNo"></param>
        /// <param name="revertAudit"></param>
        /// <param name="register"></param>
        /// <returns></returns>
        public virtual bool CancelWaitingRevert(int sysNo, bool revertAudit, params RMARegisterInfo[] register)
        {
            if (!registerDA.CanCancelWaitingRevert(sysNo))
            {
                string msg = ResouceManager.GetMessageString("RMA.Request", "CannotCancelWaitingRevert");
                throw new BizException(msg);
            }
            RMARegisterInfo    original   = LoadBySysNo(sysNo);
            RegisterRevertInfo revertInfo = original.RevertInfo;

            revertInfo.RevertStatus         = null;
            revertInfo.NewProductStatus     = RMANewProductStatus.Origin;
            revertInfo.RevertProductSysNo   = null;
            revertInfo.RevertStockSysNo     = null;
            revertInfo.SetWaitingRevertTime = null;
            if (revertAudit)
            {
                if (register != null && register.Length > 0)
                {
                    revertInfo.RevertAuditUserSysNo = register[0].RevertInfo.RevertAuditUserSysNo;
                    revertInfo.RevertAuditMemo      = register[0].RevertInfo.RevertAuditMemo;
                    revertInfo.RevertAuditTime      = register[0].RevertInfo.RevertAuditTime;
                }
            }
            else
            {
                revertInfo.RevertAuditUserSysNo = null;
                revertInfo.RevertAuditMemo      = null;
                revertInfo.RevertAuditTime      = null;
            }

            bool result = registerDA.UpdateRevertStatus(original);

            ExternalDomainBroker.CreateOperationLog("RMA_Register_Revert", BizLogType.RMA_Register_Revert, sysNo, original.CompanyCode);

            return(result);
        }
Example #17
0
        /// <summary>
        /// 发还审核
        /// </summary>
        /// <param name="register"></param>
        /// <param name="approved">是否通过</param>
        /// <returns></returns>
        public virtual RMARegisterInfo RevertAudit(RMARegisterInfo register, bool approved)
        {
            register.VerifyRevertAudit();

            bool result;

            if (approved)
            {
                register.RevertInfo.RevertStatus         = RMARevertStatus.WaitingRevert;
                register.RevertInfo.RevertAuditUserSysNo = ServiceContext.Current.UserSysNo;
                register.RevertInfo.RevertAuditTime      = DateTime.Now;

                result = registerDA.UpdateRevertStatus(register);
            }
            else
            {
                result = CancelWaitingRevert(register.RevertInfo.SysNo.Value, true, register);
            }


            ExternalDomainBroker.CreateOperationLog("RMA_Register_RevertAudit", BizLogType.RMA_Register_RevertAudit, register.SysNo.Value, register.CompanyCode);

            return(LoadForEditBySysNo(register.SysNo.Value));
        }
Example #18
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);
        }
Example #19
0
        /// <summary>
        /// 验证奥硕是否支持上门取件
        /// </summary>
        /// <param name="areaSysNo">申请地区编号</param>
        //void ValidOZZOFetchToHome(RMARequestInfo request)
        //{
        //    //根据行政区划判断是否可以上门取件,如不支持进行提示,且不能保存。
        //    int? areaSysNo = request.AreaSysNo;
        //    bool isFetch = true;

        //    var ozzoShipTypeAreasSysNo = new int[] { 21, 65, 370 };

        //    //获取不支持的地区的列表
        //    var unFetchAreaList = ObjectFactory<IBizInteract.ICommonBizInteract>.Instance.QueryShipAreaUnByAreaSysNo(ozzoShipTypeAreasSysNo, areaSysNo.Value);
        //    // QueryModelProxy.CommonDataQueryProvider.QueryShipAreaUnByAreaSysNo(ozzoShipTypeAreasSysNo, areaSysNo.Value);
        //    if (unFetchAreaList.Count > 0)
        //    {
        //        isFetch = false;
        //        //判断逻辑为:如果有一种配送点可支持上门取件,那判断将终止
        //        foreach (int shipTypeAreaSysNo in ozzoShipTypeAreasSysNo)
        //        {
        //            //可配送的终止条件为配送点没有在不支持地区中配置
        //            if (unFetchAreaList.Count(p => p.ShipTypeSysNo == shipTypeAreaSysNo) == 0)
        //            {
        //                isFetch = true;
        //                break;
        //            }
        //        }
        //    }

        //    //不支持抛出异常
        //    if (!isFetch)
        //    {
        //        throw new BizException("本地区不支持上门取件服务!");
        //    }

        //}


        /// <summary>
        /// 更新申请单(包括单件信息)
        /// </summary>
        /// <param name="request">申请单信息</param>
        public virtual void Update(RMARequestInfo request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            if (!request.SysNo.HasValue)
            {
                throw new ArgumentNullException("request.SysNo");
            }
            request.VerifyUpdate(LoadBySysNo(request.SysNo.Value));

            if (request.ShipViaCode.Trim() == ozzShip)
            {
                //ValidOZZOFetchToHome(request);

                #region [时间限制]

                //if (!request.ETakeDate.HasValue)
                //{
                //    request.ETakeDate = request.CustomerSendTime;
                //}
                //else
                //{
                //    request.CustomerSendTime = request.ETakeDate;
                //}
                //DateTime minReceiveDate = DateTime.Now;
                //DateTime tmpDate = DateTime.Now;
                ////周一四点后
                //if (request.CreateDate.Value.DayOfWeek == DayOfWeek.Monday && request.CreateDate.Value.Hour >= 16)
                //{

                //    tmpDate = request.CreateDate.Value.AddDays(2);
                //    minReceiveDate = new DateTime(tmpDate.Year, tmpDate.Month, tmpDate.Day, 0, 0, 0);
                //    if (request.CustomerSendTime.Value < minReceiveDate)
                //    {

                //        throw new BizException("周一下午四点之后至周二下午四点前申请,预约取货时间最早可选周三取件!");
                //    }

                //}
                ////周二四点前
                //else if (request.CreateDate.Value.DayOfWeek == DayOfWeek.Tuesday && request.CreateDate.Value.Hour < 16)
                //{

                //    tmpDate = request.CreateDate.Value.AddHours(25 - request.CreateDate.Value.Hour);
                //    minReceiveDate = new DateTime(tmpDate.Year, tmpDate.Month, tmpDate.Day, 0, 0, 0);
                //    if (request.CustomerSendTime.Value < minReceiveDate)
                //    {
                //        throw new BizException("周一下午四点之后至周二下午四点前申请,预约取货时间最早可选周三取件!");
                //    }
                //}
                ////周二四点后
                //else if (request.CreateDate.Value.DayOfWeek == DayOfWeek.Tuesday && request.CreateDate.Value.Hour >= 16)
                //{

                //    tmpDate = request.CreateDate.Value.AddDays(2);
                //    minReceiveDate = new DateTime(tmpDate.Year, tmpDate.Month, tmpDate.Day, 0, 0, 0);
                //    if (request.CustomerSendTime.Value < minReceiveDate)
                //    {
                //        throw new BizException("周二下午四点后至周三下午四点前申请,预约取货时间最早可选周四取件!");
                //    }

                //}
                ////周三四点前
                //else if (request.CreateDate.Value.DayOfWeek == DayOfWeek.Wednesday && request.CreateDate.Value.Hour < 16)
                //{

                //    tmpDate = request.CreateDate.Value.AddHours(25 - request.CreateDate.Value.Hour);
                //    minReceiveDate = new DateTime(tmpDate.Year, tmpDate.Month, tmpDate.Day, 0, 0, 0);
                //    if (request.CustomerSendTime.Value < minReceiveDate)
                //    {
                //        throw new BizException("周二下午四点后至周三下午四点前申请,预约取货时间最早可选周四取件!");
                //    }
                //}
                ////周三四点后
                //else if (request.CreateDate.Value.DayOfWeek == DayOfWeek.Wednesday && request.CreateDate.Value.Hour >= 16)
                //{

                //    tmpDate = request.CreateDate.Value.AddDays(2);
                //    minReceiveDate = new DateTime(tmpDate.Year, tmpDate.Month, tmpDate.Day, 0, 0, 0);
                //    if (request.CustomerSendTime.Value < minReceiveDate)
                //    {
                //        throw new BizException("周三下午四点后至周四下午四点前申请,预约取货时间最早可选周五取件!");

                //    }

                //}
                ////周四四点前Thursday
                //else if (request.CreateDate.Value.DayOfWeek == DayOfWeek.Thursday && request.CreateDate.Value.Hour < 16)
                //{

                //    tmpDate = request.CreateDate.Value.AddHours(25 - request.CreateDate.Value.Hour);
                //    minReceiveDate = new DateTime(tmpDate.Year, tmpDate.Month, tmpDate.Day, 0, 0, 0);
                //    if (request.CustomerSendTime.Value < minReceiveDate)
                //    {
                //        throw new BizException("周三下午四点后至周四下午四点前申请,预约取货时间最早可选周五取件!");
                //    }
                //}
                ////周四四点后
                //else if (request.CreateDate.Value.DayOfWeek == DayOfWeek.Thursday && request.CreateDate.Value.Hour >= 16)
                //{

                //    tmpDate = request.CreateDate.Value.AddDays(2);
                //    minReceiveDate = new DateTime(tmpDate.Year, tmpDate.Month, tmpDate.Day, 0, 0, 0);
                //    if (request.CustomerSendTime.Value < minReceiveDate)
                //    {
                //        throw new BizException("周四下午四点后至周五下午四点前申请,预约取货时间最早可选周六取件!");
                //    }

                //}
                ////周五四点前
                //else if (request.CreateDate.Value.DayOfWeek == DayOfWeek.Friday && request.CreateDate.Value.Hour < 16)
                //{

                //    tmpDate = request.CreateDate.Value.AddHours(25 - request.CreateDate.Value.Hour);
                //    minReceiveDate = new DateTime(tmpDate.Year, tmpDate.Month, tmpDate.Day, 0, 0, 0);
                //    if (request.CustomerSendTime.Value < minReceiveDate)
                //    {
                //        throw new BizException("周四下午四点后至周五下午四点前申请,预约取货时间最早可选周六取件!");
                //    }
                //}
                ////周五四点后
                //else if (request.CreateDate.Value.DayOfWeek == DayOfWeek.Friday && request.CreateDate.Value.Hour >= 16)
                //{

                //    tmpDate = request.CreateDate.Value.AddDays(4);
                //    minReceiveDate = new DateTime(tmpDate.Year, tmpDate.Month, tmpDate.Day, 0, 0, 0);
                //    if (request.CustomerSendTime.Value < minReceiveDate)
                //    {

                //        throw new BizException("周五下午四点之后至周一下午四点前申请,预约取货时间最早可选下周二取件!");
                //    }
                //}
                ////周六全天
                //else if (request.CreateDate.Value.DayOfWeek == DayOfWeek.Saturday)
                //{

                //    tmpDate = request.CreateDate.Value.AddDays(3);
                //    minReceiveDate = new DateTime(tmpDate.Year, tmpDate.Month, tmpDate.Day, 0, 0, 0);
                //    if (request.CustomerSendTime.Value < minReceiveDate)
                //    {
                //        throw new BizException("周五下午四点之后至周一下午四点前申请,预约取货时间最早可选下周二取件!");
                //    }
                //}
                ////周日全天
                //else if (request.CreateDate.Value.DayOfWeek == DayOfWeek.Sunday)
                //{
                //    tmpDate = request.CreateDate.Value.AddDays(2);
                //    minReceiveDate = new DateTime(tmpDate.Year, tmpDate.Month, tmpDate.Day, 0, 0, 0);
                //    if (request.CustomerSendTime.Value < minReceiveDate)
                //    {
                //        throw new BizException("周五下午四点之后至周一下午四点前申请,预约取货时间最早可选下周二取件!");
                //    }
                //}
                ////周一四点前
                //else if (request.CreateDate.Value.DayOfWeek == DayOfWeek.Monday && request.CreateDate.Value.Hour < 16)
                //{

                //    tmpDate = request.CreateDate.Value.AddHours(25 - request.CreateDate.Value.Hour);
                //    minReceiveDate = new DateTime(tmpDate.Year, tmpDate.Month, tmpDate.Day, 0, 0, 0);
                //    if (request.CustomerSendTime.Value < minReceiveDate)
                //    {
                //        throw new BizException("周五下午四点之后至周一下午四点前申请,预约取货时间最早可选下周二取件!");
                //    }
                //}

                #endregion
            }

            if (request.CreateDate.Value.Year > request.CustomerSendTime.Value.Year ||
                (request.CreateDate.Value.Year == request.CustomerSendTime.Value.Year && (request.CreateDate.Value.DayOfYear - request.CustomerSendTime.Value.DayOfYear) > 7))
            {
                throw new BizException(ResouceManager.GetMessageString("RMA.Request", "OrderTimeNotPreviousWeek"));
            }


            request.Registers = registerProcessor.LoadByRequestSysNo(request.SysNo.Value);

            CustomerContactInfo customerContactInfo = GetCustomerContactInfo(request);

            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                customerContactDA.UpdateByRequestSysNo(customerContactInfo);

                bool?isWithin7Days = null;
                if (request.CustomerSendTime.HasValue)
                {
                    isWithin7Days = IsWithin7Days(request.SOSysNo.Value, request.CustomerSendTime.Value);
                }
                request.Registers.ForEach(reg =>
                {
                    reg.BasicInfo.IsWithin7Days = isWithin7Days;
                });

                UpdateWithRegisters(request);

                scope.Complete();
            }

            ExternalDomainBroker.CreateOperationLog("RMA_Request_Update", BizLogType.RMA_Request_Update, request.SysNo.Value, request.CompanyCode);
        }
Example #20
0
        /// <summary>
        /// 接收申请单
        /// </summary>
        /// <param name="request">申请单信息</param>
        /// <returns>申请单信息</returns>
        public virtual RMARequestInfo Receive(RMARequestInfo request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request is required!");
            }
            if (!request.SysNo.HasValue)
            {
                throw new ArgumentNullException("request.SysNo is required!");
            }

            RMARequestInfo original = LoadWithRegistersBySysNo(request.SysNo.Value);

            request.VerifyReceive(original);

            original.ReceiveWarehouse = request.ReceiveWarehouse;
            original.ReceiveTime      = DateTime.Now;
            original.ReceiveUserSysNo = ServiceContext.Current.UserSysNo;
            //获取UI上需要的接收人名称
            original.ReceiveUserName  = ExternalDomainBroker.GetUserInfoBySysNo(original.ReceiveUserSysNo.Value);
            original.IsViaPostOffice  = request.IsViaPostOffice;
            original.PostageToPoint   = request.PostageToPoint;
            original.Status           = RMARequestStatus.Handling;
            original.CustomerSendTime = request.CustomerSendTime;
            original.ShipViaCode      = request.ShipViaCode;
            original.IsRejectRMA      = request.IsRejectRMA;
            original.TrackingNumber   = request.TrackingNumber;
            original.Phone            = request.Phone;
            original.Contact          = request.Contact;
            original.Address          = request.Address;
            original.ETakeDate        = request.ETakeDate;
            original.AreaSysNo        = request.AreaSysNo;
            original.Memo             = request.Memo;
            original.Note             = request.Note;
            original.IsReceiveMsg     = request.IsReceiveMsg;

            request.ReturnPoint = request.PostageToPoint;

            // data format:
            // { RegisterSysNo: [ HaveInvoice, IsFullAccessory, IsFullPackage ] }
            Dictionary <int, bool?[]> dic = new Dictionary <int, bool?[]>();

            request.Registers.ForEach(reg =>
            {
                dic.Add(
                    reg.BasicInfo.SysNo.Value,
                    new bool?[] { reg.BasicInfo.IsHaveInvoice, reg.BasicInfo.IsFullAccessory, reg.BasicInfo.IsFullPackage }
                    );
            });

            Dictionary <int, decimal> costs = GetSOItemsCost(request.SysNo.Value);
            bool isWithin7Days = IsWithin7Days(request.SOSysNo.Value, request.CustomerSendTime.Value);

            original.Registers.ForEach(reg =>
            {
                reg.BasicInfo.OwnBy             = RMAOwnBy.Customer;
                reg.BasicInfo.Location          = RMALocation.Self;
                reg.BasicInfo.LocationWarehouse = request.ReceiveWarehouse;
                reg.BasicInfo.OwnByWarehouse    = ((int)RMAOwnBy.Origin).ToString();
                reg.BasicInfo.Cost            = costs[reg.BasicInfo.ProductSysNo.Value];
                reg.BasicInfo.IsWithin7Days   = isWithin7Days;
                reg.BasicInfo.Status          = request.Status;
                reg.BasicInfo.IsHaveInvoice   = dic[reg.BasicInfo.SysNo.Value][0];
                reg.BasicInfo.IsFullAccessory = dic[reg.BasicInfo.SysNo.Value][1];
                reg.BasicInfo.IsFullPackage   = dic[reg.BasicInfo.SysNo.Value][2];
            });

            TransactionOptions options = new TransactionOptions();

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

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                UpdateWithRegisters(original);

                UpdateInventory(original.Registers, true);

                scope.Complete();
            }

            var customer = ExternalDomainBroker.GetCustomerInfo(request.CustomerSysNo.Value);

            //SendEmail(customer.BasicInfo.Email, request.RequestID);

            ExternalDomainBroker.CreateOperationLog("RMA_Request_Recieve", BizLogType.RMA_Request_Receive, request.SysNo.Value, original.CompanyCode);

            return(original);
        }