Exemple #1
0
        /// <summary>
        /// 锁定订单。返回true表示同步锁定订单,false表示异步锁定订单
        /// </summary>
        /// <param name="soBaseInfo">订单基本信息</param>
        /// <returns>是不是已经同步锁定了订单,true 表示是,false 表示异步锁定订单(订单现在还没有锁定)</returns>
        public virtual bool Hold(SOHoldReason holdType, OPCCallBackType callBackType)
        {
            //  1.  锁定前的业务检查,订单处于以下状态时不能被锁定:1.已作废,已拆分,已出库;2.已经被锁定(前台网站和后台管理锁定后都不能再次锁定)
            HoldPreCheck(holdType);

            //  2.  判断WMS是否下载订单,如果下载则要Hold WMS
            bool wmsIsDownload = SODA.WMSIsDownloadSO(SOSysNo);

            //  3.  仓库锁定订单
            if (wmsIsDownload)
            {
                List <int> stockSysNoList = (from item in CurrentSO.Items
                                             where item.StockSysNo.HasValue && item.ProductType != SOProductType.Coupon && item.ProductType != SOProductType.ExtendWarranty
                                             select item.StockSysNo.Value).Distinct().ToList();
                try
                {
                    //同步锁定订单
                    WMSHoldMessage message = new WMSHoldMessage
                    {
                        SOSysNo            = SOSysNo,
                        ActionType         = ECCentral.Service.EventMessage.WMSActionType.Hold,
                        UserSysNo          = ServiceContext.Current.UserSysNo,
                        WarehouseSysNoList = stockSysNoList,
                        Reason             = CurrentSO.BaseInfo.HoldReason
                    };
                    EventPublisher.Publish <WMSHoldMessage>(message);
                }
                catch (ThirdPartBizException biz_ex)
                {
                    throw new BizException(biz_ex.Message);
                }
                catch
                {
                    //异步锁定订单
                    WMSAction action = WMSAction.Hold;
                    switch (holdType)
                    {
                    case SOHoldReason.AbandonOrder:
                        action = WMSAction.AbandonHold;
                        break;

                    case SOHoldReason.CancelAuditOrder:
                        action = WMSAction.CancelAuditHold;
                        break;
                    }
                    ObjectFactory <OPCProcessor> .Instance.SendMessageToWMS(CurrentSO, action, callBackType); //ExternalDomainBroker.SendMessageToWMS(CurrentSO, action, OPCCallBackType.HoldCallBack);

                    BizExceptionHelper.Throw("SO_Hold_NetErrorSysncHolding");
                }
            }
            //  3.  本地锁定订单
            DirectHoldSO();
            return(true);
        }
Exemple #2
0
        /// <summary>
        /// 订单锁定前的检查
        /// </summary>
        /// <param name="soInfo">订单信息</param>
        /// <param name="reason">订单锁定原因</param>
        private void HoldPreCheck(SOHoldReason reason)
        {
            switch (CurrentSO.BaseInfo.Status)
            {
            case SOStatus.Origin:
                CheckSOIsWebHold();
                break;

            case SOStatus.Split:
                BizExceptionHelper.Throw("SO_Hold_SplitComplete");
                break;

            case SOStatus.Abandon:
                BizExceptionHelper.Throw("SO_Hold_Abandoned");
                break;

            case SOStatus.OutStock:
                BizExceptionHelper.Throw("SO_Hold_OutStock");
                break;
            }
            if (reason != SOHoldReason.CancelAuditOrder && CurrentSO.BaseInfo.HoldStatus.Value == SOHoldStatus.BackHold)
            {
                BizExceptionHelper.Throw("SO_Hold_BackHold");
            }

            // 检查是否出库
            if (SODA.IsNeweggOutStock(SOSysNo))
            {
                BizExceptionHelper.Throw("SO_Hold_OutStock");
            }

            // 检查订单是否正在处理
            if (ObjectFactory <IOPCDA> .Instance.SOIsProcess(SOSysNo))
            {
                BizExceptionHelper.Throw("SO_Hold_IsAsyncHold");
            }
        }