Пример #1
0
        /// <summary>
        /// 审核订单
        /// </summary>
        public virtual void Audit()
        {
            //  1.  检查订单状态是否可以被审核
            //  2.  检查订单是否被锁定,锁定后不能操作
            //  3.  检查订单否满足审单条件
            AuditPreCheck(); // 1、2、3 整合到一起

            //  4.  计算订单审核后状态
            SOStatus nextStatus = GetAuditStatus();

            if (IsAuditNetPay && nextStatus == SOStatus.WaitingManagerAudit)
            {
                BizExceptionHelper.Throw("SO_AuditNetPay_NeedManagerAudit");
            }

            //  5.  如果是后台锁定了,就先解锁
            Unhold();

            //配送时间的校验
            CheckDeliveryDate();

            //  6.  保存审核结果,如果是电子卡订单,则激活电子卡。
            SaveAudit(nextStatus);

            //  7.  审核订单后重新判断订单是否并单
            CheckSOIsCombine();
            //  8.  根据仓库拆分订单价格
            SplitPrice();
            //  9.  发送邮件
            SendMessage();

            //  10. 写日志
            WriteLog("订单审核通过");
        }
Пример #2
0
        public void CancelAudit()
        {
            //  1.  业务检查:商家订单不能取消审核;订单状态不是待主管审核/待出库状态,不能取消审核
            if (CurrentSO.ShippingInfo != null && CurrentSO.ShippingInfo.StockType == ECCentral.BizEntity.Invoice.StockType.MET)
            {
                BizExceptionHelper.Throw("SO_CancelAudit_SOIsMETOrder", SOSysNo.ToString());
            }
            SOStatus status = CurrentSO.BaseInfo.Status.Value;

            if (status != SOStatus.WaitingManagerAudit && status != SOStatus.WaitingOutStock)
            {
                BizExceptionHelper.Throw("SO_CancelAudit_SOStatusIsError");
            }

            //  2.  取消审核不管本地是否是锁定都需要去检测仓库是否扫描,这里必须先锁定
            CurrentSO.BaseInfo.HoldReason = "CancelAuditSO";
            CurrentSO.BaseInfo.HoldUser   = ECCentral.Service.Utility.ServiceContext.Current.UserSysNo;
            CurrentSO.BaseInfo.HoldTime   = DateTime.Now;
            bool isSyn = Holder.Hold(SOHolder.SOHoldReason.CancelAuditOrder, OPCCallBackType.CancelAuditCallBack);

            //  3.  如果是同步锁定订单则执行取消审核操作
            if (isSyn)
            {
                SaveCancelAudit();
            }
            else
            {
                BizExceptionHelper.Throw("SO_CancelAudit_HoldIsAsyn");
            }
        }
Пример #3
0
        /// <summary>
        /// 保存主管审核
        /// </summary>
        /// <param name="nextStatus"></param>
        protected virtual void SaveManagerAudit(SOStatus nextStatus)
        {
            if (CurrentSO.BaseInfo.Status == nextStatus)
            {
                BizExceptionHelper.Throw("SO_Audit_SOIncomeIsNull");
            }
            SOStatusChangeInfo statusChangeInfo = new SOStatusChangeInfo
            {
                SOSysNo              = SOSysNo,
                ChangeTime           = DateTime.Now,
                IsSendMailToCustomer = true,
                OldStatus            = CurrentSO.BaseInfo.Status,
                OperatorSysNo        = ECCentral.Service.Utility.ServiceContext.Current.UserSysNo,
                OperatorType         = SOOperatorType.User,
                Status = nextStatus
            };

            //更新审核状态到DB
            if (SODA.UpdateSOStatusForManagerAudit(statusChangeInfo))
            {
                CurrentSO.BaseInfo.Status = statusChangeInfo.Status;
            }
            else
            {
                BizExceptionHelper.Throw("SO_ManagerAudit_SOStatusIsError");
            }
        }
Пример #4
0
        /// <summary>
        /// 主管审核订单
        /// </summary>
        /// <param name="isForce">是否强制审核</param>
        public void ManagerAudit()
        {
            //  1.  检查订单状态是否可以被审核
            //  2.  检查订单是否被锁定,锁定后不能操作
            //  3.  检查订单否满足审单条件
            ManagerAuditPreCheck(); // 1、2、3 整合到一起

            //  4.  计算订单审核后状态
            SOStatus nextStatus = GetManagerAuditStatus();

            //  5.  如果是后台锁定了,就先解锁
            Unhold();

            //  6.  保存审核结果,如果是电子卡订单,则激活电子卡。
            SaveManagerAudit(nextStatus);

            //  7.  相比订单审核,主管审核 少了订单审核中的第7步骤:审核订单后重新判断订单是否并单

            //  8.  根据仓库拆分订单价格
            SplitPrice();

            //  9.  发送邮件
            SendMessage();

            //  10. 写日志
            WriteLog("订单主管审核");
        }
Пример #5
0
        protected override SOStatus GetManagerAuditStatus()
        {
            SOStatus status = CurrentSO.BaseInfo.Status.Value;

            if (ValidateSOIncome())
            {
                //支付无误,电子卡直接完成
                status = SOStatus.OutStock;
            }
            return(status);
        }
Пример #6
0
        public static void UpdateSOStatus(int soSysNo, SOStatus status, DateTime?auditTime = null, DateTime?outTime = null, int?updateUserSysNo = null)
        {
            var command = DataCommandManager.GetDataCommand("UpdateSOStatus");

            command.SetParameterValue("@SOSysNo", soSysNo);
            command.SetParameterValue("@UpdateUserSysNo", updateUserSysNo);
            command.SetParameterValue("@AuditTime", auditTime);
            command.SetParameterValue("@OutTime", outTime);
            command.SetParameterValue("@Status", status);
            command.ExecuteNonQuery();
        }
Пример #7
0
        protected override SOStatus GetAuditStatus()
        {
            SOStatus status = CurrentSO.BaseInfo.Status.Value;

            if (ValidateSOIncome())
            {
                //支付无误,电子卡直接完成
                status = PromotionDiscountMoreThanLimit() ? SOStatus.WaitingManagerAudit : SOStatus.OutStock;
            }
            return(status);
        }
Пример #8
0
        public override void SendMessage()
        {
            SOSendMessageProcessor messageProcessor = ObjectFactory <SOSendMessageProcessor> .Instance;
            SOStatus soStatus = CurrentSO.BaseInfo.Status.Value;

            if (soStatus == SOStatus.WaitingOutStock)
            {
                // 给内部工作人员发邮件
                messageProcessor.SendSIMCardStatusMail(CurrentSO);
                base.SendMessage();
            }
        }
Пример #9
0
        public void UpdateSOStatus(int soSysNo, SOStatus newStatus, SOStatus oldStatus)
        {
            IDataCommand cmd = IocManager.Instance.Resolve <IDataCommand>();

            cmd.CreateCommand("Order_UpdateSOStatus");

            //DataCommand cmd = new DataCommand("Order_UpdateSOStatus");
            cmd.SetParameter("@SOSysNo", DbType.Int32, soSysNo);
            cmd.SetParameter("@NewStatus", DbType.Int32, (int)newStatus);
            cmd.SetParameter("@OldStatus", DbType.Int32, (int)oldStatus);
            cmd.ExecuteNonQuery();
        }
Пример #10
0
        protected override void SaveAudit(SOStatus nextStatus)
        {
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                base.SaveAudit(nextStatus);
                SODA.UpdateSOOutStockTime(SOSysNo);
                scope.Complete();
            }
        }
Пример #11
0
        public bool UpdateSOStatusToAbandon(int soSysNo, SOStatus soStatus, int userSysNo, string userName)
        {
            IDataCommand cmd = IocManager.Instance.Resolve <IDataCommand>();

            cmd.CreateCommand("UpdateSOStatusToAbandon");

            //DataCommand cmd = new DataCommand("UpdateSOStatusToAbandon");
            cmd.SetParameter("@SOSysNo", DbType.Int32, soSysNo);;
            cmd.SetParameter("@OldStatus", DbType.Int32, soStatus);
            cmd.SetParameter("@EditUserSysNo", DbType.Int32, userSysNo);
            cmd.SetParameter("@EditUserName", DbType.AnsiString, userName, 40);
            return(cmd.ExecuteScalar <int>() > 0);
        }
Пример #12
0
        protected override SOStatus GetAuditStatus()
        {
            SOStatus status = CurrentSO.BaseInfo.Status.Value;

            if (PromotionDiscountMoreThanLimit())
            {
                status = SOStatus.WaitingManagerAudit;
            }
            else
            {
                status = base.GetAuditStatus();
            }
            return(status);
        }
Пример #13
0
        protected override SOStatus GetManagerAuditStatus()
        {
            SOStatus status = CurrentSO.BaseInfo.Status.Value;

            // 创建为 0 的NetPay
            ECCentral.BizEntity.Invoice.NetPayInfo netPayInfo = ExternalDomainBroker.GetSOValidNetPay(SOSysNo);
            //支付方式必须是款到发货,才可创建NetPay
            if (netPayInfo == null && (!CurrentSO.BaseInfo.PayWhenReceived ?? true))
            {
                ExternalDomainBroker.CreatNetPay(SOSysNo, 0, CurrentSO.BaseInfo.PayTypeSysNo.Value, CurrentSO.CompanyCode);
                BizExceptionHelper.Throw("SO_ManagerAudit_GiftSO_CreateNetPay");
            }
            else
            {
                status = base.GetManagerAuditStatus();
            }
            return(status);
        }
Пример #14
0
        protected virtual SOStatus GetAuditStatus()
        {
            SOStatus status = CurrentSO.BaseInfo.Status.Value;

            //是批发则转为等待经理审核状态
            if ((CurrentSO.BaseInfo.IsWholeSale.HasValue && CurrentSO.BaseInfo.IsWholeSale.Value))
            {
                status = SOStatus.WaitingManagerAudit;
            }
            else if (CurrentSO.BaseInfo.SplitType == SOSplitType.SubSO) //拆分后子订单
            {
                status = SOStatus.WaitingOutStock;
            }
            else
            {
                status = ValidateSOPayStatus();
            }
            return(status);
        }
Пример #15
0
        /// <summary>
        /// 取得主管审核订单后的订单的状态
        /// </summary>
        /// <returns></returns>
        protected virtual SOStatus GetManagerAuditStatus()
        {
            SOStatus status = CurrentSO.BaseInfo.Status.Value;

            if (CurrentSO.BaseInfo.SplitType == SOSplitType.SubSO)
            {
                status = SOStatus.WaitingOutStock;
            }
            else if (CurrentSO.BaseInfo.PayWhenReceived.HasValue && CurrentSO.BaseInfo.PayWhenReceived.Value) //检验支付方式
            {
                //货到付款可以直接出库
                status = SOStatus.WaitingOutStock;
            }
            else if (ValidateSOIncome())
            {
                //支付无误,电子卡直接完成,其他待出库
                status = SOStatus.WaitingOutStock;
            }
            return(status);
        }
Пример #16
0
        protected override void SaveAudit(SOStatus nextStatus)
        {
            TransactionOptions options = new TransactionOptions
            {
                IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
            };

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                //更新审核状态到DB
                base.SaveAudit(nextStatus);

                if (CurrentSO.BaseInfo.Status == SOStatus.OutStock)
                {
                    //电子卡订单出库
                    ElectronicCardComplete();
                }
                scope.Complete();
            }
        }
Пример #17
0
        /// <summary>
        /// 验证订单支付状态
        /// </summary>
        /// <param name="isForce"></param>
        /// <returns></returns>
        private SOStatus ValidateSOPayStatus()
        {
            SOStatus status = CurrentSO.BaseInfo.Status.Value;

            BizEntity.Common.PayType ptInfo = ExternalDomainBroker.GetPayTypeBySysNo(CurrentSO.BaseInfo.PayTypeSysNo.Value);

            if (ptInfo == null)
            {
                BizExceptionHelper.Throw("SO_Audit_PayTypeNotExist", CurrentSO.BaseInfo.PayTypeSysNo.ToString());
            }
            else if (CurrentSO.BaseInfo.PayWhenReceived.HasValue && CurrentSO.BaseInfo.PayWhenReceived.Value)
            {
                //货到付款可以直接出库
                status = SOStatus.WaitingOutStock;
            }
            else if (ValidateSOIncome())
            {
                //支付无误,为待出库(电子卡直接完成)
                status = SOStatus.WaitingOutStock;
            }
            return(status);
        }
Пример #18
0
		public MySqlDataReader List(SOStatus postatus, DateTime StartDate, DateTime EndDate)
		{
			try
			{
				string SQL = SQLSelect() + "WHERE Status = @Status AND DeliveryDate BETWEEN @StartDate AND @EndDate ORDER BY SOID ASC";

				MySqlCommand cmd = new MySqlCommand();
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;

				MySqlParameter prmStartDate = new MySqlParameter("@StartDate",MySqlDbType.DateTime);
				prmStartDate.Value = StartDate.ToString("yyyy-MM-dd HH:mm:ss");
				cmd.Parameters.Add(prmStartDate);

				MySqlParameter prmEndDate = new MySqlParameter("@EndDate",MySqlDbType.DateTime);
				prmEndDate.Value = EndDate.ToString("yyyy-MM-dd HH:mm:ss");
				cmd.Parameters.Add(prmEndDate);

				MySqlParameter prmStatus = new MySqlParameter("@Status",MySqlDbType.Int16);
				prmStatus.Value = postatus.ToString("d");
				cmd.Parameters.Add(prmStatus);

				MySqlDataReader myReader = base.ExecuteReader(cmd);

				return myReader;
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}
		}
Пример #19
0
		public System.Data.DataTable SearchAsDataTable(SOStatus postatus, string SearchKey, string SortField, SortOption SortOrder)
		{
			try
			{
				if (SortField == string.Empty || SortField == null) SortField = "SOID";

				string SQL = SQLSelect() + "WHERE Status = @Status AND (SONo LIKE @SearchKey or SODate LIKE @SearchKey or CustomerCode LIKE @SearchKey " +
										"or CustomerContact LIKE @SearchKey or BranchCode LIKE @SearchKey or RequiredDeliveryDate LIKE @SearchKey) " +
							"ORDER BY " + SortField;

				if (SortOrder == SortOption.Ascending)
					SQL += " ASC";
				else
					SQL += " DESC";

				MySqlCommand cmd = new MySqlCommand();
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;

				MySqlParameter prmStatus = new MySqlParameter("@Status",MySqlDbType.Int16);
				prmStatus.Value = postatus.ToString("d");
				cmd.Parameters.Add(prmStatus);

				MySqlParameter prmSearchKey = new MySqlParameter("@SearchKey",MySqlDbType.String);
				prmSearchKey.Value = "%" + SearchKey + "%";
				cmd.Parameters.Add(prmSearchKey);

				System.Data.DataTable dt = new System.Data.DataTable("SO");
				MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
				adapter.Fill(dt);

				return dt;
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}
		}
Пример #20
0
		public MySqlDataReader List(SOStatus postatus, long CustomerID, string SortField, SortOption SortOrder)
		{
			try
			{
				if (SortField == string.Empty || SortField == null) SortField = "SOID";

				string SQL = SQLSelect() + "WHERE Status =@Status AND CustomerID = @CustomerID ORDER BY " + SortField;

				if (SortOrder == SortOption.Ascending)
					SQL += " ASC";
				else
					SQL += " DESC";

				MySqlCommand cmd = new MySqlCommand();
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;

				MySqlParameter prmStatus = new MySqlParameter("@Status",MySqlDbType.Int16);
				prmStatus.Value = postatus.ToString("d");
				cmd.Parameters.Add(prmStatus);

				MySqlParameter prmCustomerID = new MySqlParameter("@CustomerID",MySqlDbType.Int64);
				prmCustomerID.Value = CustomerID;
				cmd.Parameters.Add(prmCustomerID);

				MySqlDataReader myReader = base.ExecuteReader(cmd);

				return myReader;
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}
		}
Пример #21
0
		public System.Data.DataTable ListAsDataTable(SOStatus sostatus, string SortField = "SOID", SortOption SortOrder = SortOption.Ascending)
		{
			string SQL = SQLSelect() + "WHERE Status = @Status ORDER BY " + SortField;

			if (SortOrder == SortOption.Ascending)
				SQL += " ASC";
			else
				SQL += " DESC";

			MySqlCommand cmd = new MySqlCommand();
			cmd.CommandType = System.Data.CommandType.Text;
			cmd.CommandText = SQL;

			MySqlParameter prmStatus = new MySqlParameter("@Status",MySqlDbType.Int16);
			prmStatus.Value = sostatus.ToString("d");
			cmd.Parameters.Add(prmStatus);

            string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
            base.MySqlDataAdapterFill(cmd, dt);

			return dt;
		}
Пример #22
0
        private void LoadList()
        {
            SO clsSO = new SO();

            string SortField = "SOID";

            if (Request.QueryString["sortfield"] != null)
            {
                SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID);
            }

            SortOption sortoption = SortOption.Ascending;

            if (Request.QueryString["sortoption"] != null)
            {
                sortoption = (SortOption)Enum.Parse(typeof(SortOption), Common.Decrypt(Request.QueryString["sortoption"], Session.SessionID), true);
            }

            if (Request.QueryString["Search"] == null)
            {
                if (Request.QueryString["status"] == null)
                {
                    PageData.DataSource = clsSO.ListAsDataTable(SOStatus.Open, SortField, sortoption).DefaultView;
                }
                else
                {
                    SOStatus status = (SOStatus)Enum.Parse(typeof(SOStatus), Common.Decrypt((string)Request.QueryString["status"], Session.SessionID));
                    PageData.DataSource = clsSO.ListAsDataTable(status, SortField, sortoption).DefaultView;
                }
            }
            else
            {
                string SearchKey = Common.Decrypt((string)Request.QueryString["search"], Session.SessionID);
                if (Request.QueryString["status"] == null)
                {
                    PageData.DataSource = clsSO.SearchAsDataTable(SOStatus.Open, SearchKey, SortField, sortoption).DefaultView;
                }
                else
                {
                    SOStatus status = (SOStatus)Enum.Parse(typeof(SOStatus), Common.Decrypt((string)Request.QueryString["status"], Session.SessionID));
                    PageData.DataSource = clsSO.SearchAsDataTable(status, SearchKey, SortField, sortoption).DefaultView;
                }
            }

            clsSO.CommitAndDispose();

            int iPageSize = Convert.ToInt16(Session["PageSize"]);

            PageData.AllowPaging = true;
            PageData.PageSize    = iPageSize;
            try
            {
                PageData.CurrentPageIndex = Convert.ToInt16(cboCurrentPage.SelectedItem.Value) - 1;
                lstItem.DataSource        = PageData;
                lstItem.DataBind();
            }
            catch
            {
                PageData.CurrentPageIndex = 1;
                lstItem.DataSource        = PageData;
                lstItem.DataBind();
            }

            cboCurrentPage.Items.Clear();
            for (int i = 0; i < PageData.PageCount; i++)
            {
                int iValue = i + 1;
                cboCurrentPage.Items.Add(new ListItem(iValue.ToString(), iValue.ToString()));
                if (PageData.CurrentPageIndex == i)
                {
                    cboCurrentPage.Items[i].Selected = true;
                }
                else
                {
                    cboCurrentPage.Items[i].Selected = false;
                }
            }
            lblDataCount.Text = " of " + " " + PageData.PageCount;
        }
Пример #23
0
        protected void lstItem_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Header)
            {
                LoadSortFieldOptions(e);
            }
            else if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView dr = (DataRowView)e.Item.DataItem;

                HtmlInputCheckBox chkList = (HtmlInputCheckBox)e.Item.FindControl("chkList");
                chkList.Value = dr["SOID"].ToString();

                SOStatus status = (SOStatus)Enum.Parse(typeof(SOStatus), dr["Status"].ToString());
                if (status == SOStatus.Posted || status == SOStatus.Cancelled)
                {
                    chkList.Attributes.Add("disabled", "false");
                    ImageButton imgItemDelete = (ImageButton)e.Item.FindControl("imgItemDelete");
                    ImageButton imgItemEdit   = (ImageButton)e.Item.FindControl("imgItemEdit");
                    ImageButton imgItemPost   = (ImageButton)e.Item.FindControl("imgItemPost");
                    imgItemDelete.Enabled = false; imgItemDelete.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif";
                    imgItemEdit.Enabled   = false; imgItemEdit.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif";
                    imgItemPost.Enabled   = false; imgItemPost.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif";
                }

                HyperLink lnkSONo = (HyperLink)e.Item.FindControl("lnkSONo");
                lnkSONo.Text = dr["SONo"].ToString();
                string stParam = "?task=" + Common.Encrypt("details", Session.SessionID) + "&soid=" + Common.Encrypt(chkList.Value.ToString(), Session.SessionID);
                lnkSONo.NavigateUrl = "Default.aspx" + stParam;

                Label lblSODate = (Label)e.Item.FindControl("lblSODate");
                lblSODate.Text = Convert.ToDateTime(dr["SODate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");

                Label lblCustomerID = (Label)e.Item.FindControl("lblCustomerID");
                lblCustomerID.Text = dr["CustomerID"].ToString();

                HyperLink lblCustomerCode = (HyperLink)e.Item.FindControl("lblCustomerCode");
                lblCustomerCode.Text = dr["CustomerCode"].ToString();
                stParam = "?task=" + Common.Encrypt("details", Session.SessionID) + "&id=" + Common.Encrypt(lblCustomerID.Text, Session.SessionID);
                lblCustomerCode.NavigateUrl = Constants.ROOT_DIRECTORY + "/SalesAndReceivables/_Customer/Default.aspx" + stParam;

                Label lblReqDeliveryDate = (Label)e.Item.FindControl("lblReqDeliveryDate");
                lblReqDeliveryDate.Text = Convert.ToDateTime(dr["RequiredDeliveryDate"].ToString()).ToString("yyyy-MM-dd");

                Label lblBranchID = (Label)e.Item.FindControl("lblBranchID");
                lblBranchID.Text = dr["BranchID"].ToString();
                Label lblBranchCode = (Label)e.Item.FindControl("lblBranchCode");
                lblBranchCode.Text = dr["BranchCode"].ToString();

                Label lblSOSubTotal = (Label)e.Item.FindControl("lblSOSubTotal");
                lblSOSubTotal.Text = Convert.ToDecimal(dr["SubTotal"].ToString()).ToString("#,##0.#0");

                Label lblSORemarks = (Label)e.Item.FindControl("lblSORemarks");
                lblSORemarks.Text = dr["Remarks"].ToString();

                //For anchor
                //				HtmlGenericControl divExpCollAsst = (HtmlGenericControl) e.Item.FindControl("divExpCollAsst");

                //				HtmlAnchor anchorDown = (HtmlAnchor) e.Item.FindControl("anchorDown");
                //				anchorDown.HRef = "javascript:ToggleDiv('" +  divExpCollAsst.ClientID + "')";
            }
        }