Example #1
0
        public SOInfo CloneSO(SOInfo entity)
        {
            //获取原先的订单
            SOInfo oriSO = GetSOBySOSysNo(entity.SysNo.Value);

            if (oriSO.Items.Exists(x => x.PriceType == SOProductPriceType.GoldAcc ||
                                   x.PriceType == SOProductPriceType.GuanAiAcc ||
                                   x.PriceType == SOProductPriceType.SdoAccPrice))
            {
                BizExceptionHelper.Throw("SO_CloneSO_GuanAiAccCannotClone");
            }

            //捆绑销售不能拆分
            if (!CheckSaleRule(oriSO, entity))
            {
                BizExceptionHelper.Throw("SO_CloneSO_ComboCanNotClone");
            }

            oriSO.Items.Clear();
            oriSO.Items = entity.Items;

            oriSO.SysNo = NewSOSysNo();
            oriSO.BaseInfo.HoldStatus = SOHoldStatus.Unhold;
            oriSO.BaseInfo.HoldReason = string.Empty;
            oriSO.BaseInfo.HoldUser   = 0;

            //验证
            if (oriSO.Items.Exists(item => item.ProductType == SOProductType.SelfGift))
            {
                BizExceptionHelper.Throw("SO_CloneSO_NeweggGiftCannotClone");
            }

            //合约机订单 团购订单 依旧换新订单不能拆分
            if (oriSO.BaseInfo.SOType == SOType.GroupBuy)
            {
                BizExceptionHelper.Throw("SO_CloneSO_ParticularCannotClone");
            }

            //帐期不能拆分
            if (oriSO.BaseInfo.PayTypeSysNo.Value == 4)
            {
                BizExceptionHelper.Throw("SO_CloneSO_ZhangQiCannotClone");
            }

            //存在AO不能拆分
            if (ExternalDomainBroker.GetValidSOIncomeInfo(entity.SysNo.Value, BizEntity.Invoice.SOIncomeOrderType.AO) != null)
            {
                BizExceptionHelper.Throw("SO_CloneSO_ExistsAOCannotCannotClone");
            }

            ExternalDomainBroker.CreateOperationLog("Create SO", BizLogType.Sale_SO_Create, entity.BaseInfo.SysNo.Value, entity.CompanyCode);

            ProcessSO(new SOAction.SOCommandInfo {
                Command = SOAction.SOCommand.Create, SOInfo = oriSO
            });

            string note = oriSO.SysNo.ToString() + "[";

            oriSO.Items.ForEach(item =>
            {
                note += item.ProductSysNo.ToString();
            });
            note += "]";

            SODA.UpdateSONote(oriSO.SysNo.Value, note);

            ExternalDomainBroker.CreateOperationLog("更新订单(拆单)", BizLogType.Sale_SO_Update, entity.BaseInfo.SysNo.Value, entity.CompanyCode);

            return(oriSO);
        }