Beispiel #1
0
        /// <summary>
        /// 取消订单的使用优惠券,取消订单商品优惠券的分摊,重新设置商品价格。
        /// 注意:此方法还没有保存到数据库中,是通过 SaveCurrentSO()来保存
        /// </summary>
        protected virtual void CancelCoupon()
        {
            #region 取消优惠券使用

            int    couponSysNo = CouponList != null && CouponList.Count > 0 ? CouponList[0].ProductSysNo.Value : 0;
            string couponCode  = string.Empty;
            //取消优惠券使用
            if (couponSysNo != 0)
            {
                CurrentSO.BaseInfo.CouponAmount = 0;
                foreach (SOItemInfo item in CurrentSO.Items)
                {
                    item.Price = item.OriginalPrice;
                    item.CouponAverageDiscount = 0;
                }
                CurrentSO.SOPromotions.RemoveAll(p =>
                {
                    return(p.PromotionType == SOPromotionType.Coupon);
                });
                if (ExternalDomainBroker.CheckCouponIsValid(couponSysNo, out couponCode))
                {
                    // 作废时把礼券代码临时保存在note信息中。
                    CurrentSO.BaseInfo.Note = CurrentSO.BaseInfo.Note + ";作废前使用的礼券代码=" + couponCode;
                }

                #region 取消优惠券的使用
                if (CurrentSO.BaseInfo.SplitType != SOSplitType.SubSO)
                {
                    int shoppingCartSysNo = SODA.GetShoppingCartSysNoBySOSysNo(SOSysNo);
                    ExternalDomainBroker.CancelCoupon(couponCode, SOSysNo, shoppingCartSysNo);
                }
                #endregion
            }
            #endregion
        }
Beispiel #2
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");
            }
        }
Beispiel #3
0
        /// <summary>
        /// 处理团购
        /// </summary>
        public static void Process(JobContext context)
        {
            GetConfig();

            //获取团购信息
            List <ProductGroupBuyingEntity> groupList = SODA.GetGroupBuyNeedProcess(CompanyCode);


            if (groupList == null || groupList.Count == 0)
            {
                Console.WriteLine("没有符合的团购信息");
                return;
            }


            Console.WriteLine(string.Format("本次获取团购数量:{0}", groupList.Count));

            foreach (ProductGroupBuyingEntity group in groupList)
            {
                //团购结束未处理
                if (group.Status == "F" && group.IsSettlement == "N" && group.SuccessDate == null)
                {
                    //团购失败
                    FailedGroupBuyProcess(group, context);
                }
                else if ((group.Status == "F" && group.IsSettlement == "N" && group.SuccessDate != null) || group.IsSettlement == "C")
                {
                    //团购成功
                    SuccessfulGroupBuyProcess(group, context);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// 设置订单为作废状态并保存,同时保存订单商品信息
        /// </summary>
        protected void SaveCurrentSO()
        {
            SOStatusChangeInfo statusChangeInfo = new SOStatusChangeInfo
            {
                ChangeTime           = DateTime.Now,
                IsSendMailToCustomer = true,
                OldStatus            = CurrentSO.BaseInfo.Status,
                OperatorSysNo        = ServiceContext.Current.UserSysNo,
                OperatorType         = OperatorType,
                SOSysNo = SOSysNo,
                Status  = ToSoStatus
            };

            if (OperatorType == SOOperatorType.System)
            {
                CurrentSO.BaseInfo.Note = statusChangeInfo.Note = Note;
            }

            CurrentSO.BaseInfo.Status      = ToSoStatus;
            CurrentSO.StatusChangeInfoList = CurrentSO.StatusChangeInfoList ?? new List <SOStatusChangeInfo>();
            CurrentSO.StatusChangeInfoList.Add(statusChangeInfo);
            if (!SODA.UpdateSOForAbandon(CurrentSO))
            {
                BizExceptionHelper.Throw("SO_Abandon_SOStatus_Abandon");
            }

            //更新订单商品信息,是否要从订单商品中删除优惠券的记录?
            foreach (SOItemInfo item in CurrentSO.Items)
            {
                if (item.ProductType != SOProductType.Coupon)
                {
                    SODA.UpdateSOItemAmountInfo(item);
                }
            }
        }
Beispiel #5
0
        private SOInfo CreateSubSO()
        {
            SOInfo subSOInfo = new SOInfo();

            subSOInfo.BaseInfo   = SerializationUtility.DeepClone <SOBaseInfo>(CurrentSO.BaseInfo);
            subSOInfo.ClientInfo = SerializationUtility.DeepClone <SOClientInfo>(CurrentSO.ClientInfo);
            subSOInfo.FPInfo     = SerializationUtility.DeepClone <SOFPInfo>(CurrentSO.FPInfo);
            //添加增值税发票信息到每个仓库
            subSOInfo.InvoiceInfo  = SerializationUtility.DeepClone <SOInvoiceInfo>(CurrentSO.InvoiceInfo);
            subSOInfo.ReceiverInfo = SerializationUtility.DeepClone <SOReceiverInfo>(CurrentSO.ReceiverInfo);
            subSOInfo.ShippingInfo = SerializationUtility.DeepClone <SOShippingInfo>(CurrentSO.ShippingInfo);

            subSOInfo.CompanyCode = CurrentSO.BaseInfo.CompanyCode;
            subSOInfo.Merchant    = CurrentSO.Merchant;
            subSOInfo.WebChannel  = CurrentSO.WebChannel;
            //提前生成子单号
            int subSOSysNo = SODA.NewSOSysNo();

            subSOInfo.SysNo                  = subSOSysNo;
            subSOInfo.BaseInfo.SOID          = subSOSysNo.ToString();
            subSOInfo.BaseInfo.CreateTime    = DateTime.Now;
            subSOInfo.BaseInfo.SplitType     = SOSplitType.SubSO;
            subSOInfo.BaseInfo.SOSplitMaster = SOSysNo;
            subSOInfo.ShippingInfo.IsCombine = null;
            return(subSOInfo);
        }
Beispiel #6
0
 protected override void SaveSubSO(SOInfo subSOInfo)
 {
     base.SaveSubSO(subSOInfo);
     if (subSOInfo.SIMCardAndContractPhoneInfo != null)
     {
         SODA.InsertSOSIMCard(subSOInfo.SIMCardAndContractPhoneInfo);
     }
 }
Beispiel #7
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);
        }
Beispiel #8
0
        /// <summary>
        /// 直接锁住订单
        /// </summary>
        /// <param name="soBaseInfo"></param>
        /// <returns></returns>
        public virtual void DirectHoldSO()
        {
            CurrentSO.BaseInfo.HoldStatus = SOHoldStatus.BackHold;
            CurrentSO.BaseInfo.HoldTime   = DateTime.Now;
            CurrentSO.BaseInfo.HoldUser   = ServiceContext.Current.UserSysNo;

            //  1.  锁定订单操作
            SODA.UpdateSOHoldInfo(CurrentSO.BaseInfo);

            //  2.  添加订单操作日志
            WriteLog(ECCentral.BizEntity.Common.BizLogType.Sale_SO_HoldSO, "订单锁定");
        }
Beispiel #9
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();
            }
        }
Beispiel #10
0
        private void SendMsgToWMS(List <SOInfo> subSOList)
        {
            foreach (SOInfo subSO in subSOList)
            {
                if (SODA.WMSIsDownloadSO(subSO.SysNo.Value))
                {
                    ObjectFactory <OPCProcessor> .Instance.SendMessageToWMS(subSO, WMSAction.Abandon, OPCCallBackType.NoneCallBack);

                    WriteLog(BizEntity.Common.BizLogType.Sale_SO_EmployeeAbandon, "Res_SO_Abandon");
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// 取消订单配送,
        /// </summary>
        protected virtual void CancelDelivery()
        {
            // 1.   如果是泰隆优选快递类型,取消配送任务
            //if (CurrentSO.ShippingInfo.FreightUserSysNo != 0)
            //{
            //    ObjectFactory<DeliveryProcessor>.Instance.CancelDelivery(SOSysNo, "作废订单");
            //}

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

            if (wmsIsDownload)
            {
                ObjectFactory <OPCProcessor> .Instance.SendMessageToWMS(CurrentSO, WMSAction.Abandon, OPCCallBackType.NoneCallBack);
            }
        }
Beispiel #12
0
        /// <summary>
        /// 电子卡订单完成
        /// </summary>
        protected void ElectronicCardComplete()
        {
            //  1.  激活电子卡
            ExternalDomainBroker.CreateElectronicGiftCard(SOSysNo, CurrentSO.BaseInfo.CustomerSysNo.Value, CurrentSO.Items[0].OriginalPrice.Value, CurrentSO.Items[0].Quantity.Value, CurrentSO.CompanyCode, "");

            //  2.  更新订单的出库时间和订单中商品的出库时间
            DateTime outStockTime = DateTime.Now;

            SODA.UpdateSOOutStockTime(SOSysNo);
            CurrentSO.ShippingInfo.OutTime = outStockTime;
            CurrentSO.Items.ForEach(item =>
            {
                item.IsShippedOut   = true;
                item.ShippedOutTime = outStockTime;
            });

            //  3.  发送成功邮件。
            ObjectFactory <SOSendMessageProcessor> .Instance.ActivateElectronicSendMailToCustomer(CurrentSO);
        }
Beispiel #13
0
        /// <summary>
        /// 订单主信息持久化
        /// </summary>
        public override void SOPersistence()
        {
            // 持久化订单主体信息
            SODA.PersintenceMaster(this.CurrentSO, true);

            // 持久化订单商品信息
            SODA.PersintenceItem(this.CurrentSO, true);

            // 持久化订单促销信息
            SODA.PersintencePromotion(this.CurrentSO, true);

            // 持久化订单礼品卡信息
            SODA.PersintenceGiftCard(this.CurrentSO, true);

            //持久化订单其他相关信息
            SODA.PersintenceExtend(this.CurrentSO, true);

            //更新订单SIM卡信息
            SODA.UpdateSOSIMCardOrContractPhoneInfo(this.CurrentSO);
        }
Beispiel #14
0
        public static void FailedGroupBuyProcess(ProductGroupBuyingEntity group)
        {
            //获取需要处理的订单号
            List <int> soSysNolist = SODA.GetSOSysNoListByReferenceSysno(group.SystemNumber, CompanyCode);

            Console.WriteLine(string.Format("团购号:{0}", group.SystemNumber));

            foreach (int soSysNo in soSysNolist)
            {
                Console.WriteLine(string.Format("订单:{0}", soSysNo));

                SOEntity soEntity = SODA.GetSOEntity(soSysNo, CompanyCode);


                //审核NetPay
                try
                {
                    if (ExistsNetPay(soSysNo))
                    {
                        AuditNetPay(soSysNo);

                        CreateAO(soSysNo);
                    }

                    AbandonSO(soSysNo);
                }
                catch (Exception ex)
                {
                    UpdateSOGroupBuyStatus(soSysNo, "F");
                    Dealfault(ex);
                    continue;
                }

                UpdateSOGroupBuyStatus(soSysNo, "S");

                SendFailedMail(soEntity, group);
            }

            //EndGroupBuying(group.SystemNumber);
        }
Beispiel #15
0
        /// <summary>
        /// 处理团购
        /// </summary>
        public static void Process()
        {
            GetAutoAuditInfo();

            //获取SO
            List <int> soSysNolist = SODA.GetGroupBuySONotPayInTime(CompanyCode);

            foreach (int soSysNo in soSysNolist)
            {
                Console.WriteLine(string.Format("订单:{0}", soSysNo));
                //SOEntity soEntity = SODA.GetSOEntity(soSysNo, CompanyCode);
                try
                {
                    AbandonSO(soSysNo);
                }
                catch (Exception e)
                {
                    Dealfault(e);
                    continue;
                }
            }
        }
Beispiel #16
0
        public static void FullGroupBuyProcess(ProductGroupBuyingEntity group)
        {
            List <int> soSysNolist = SODA.GetSOSysNoListByReferenceSysno(group.SystemNumber, CompanyCode);

            Console.WriteLine(string.Format("团购号:{0}", group.SystemNumber));

            foreach (int soSysNo in soSysNolist)
            {
                Console.WriteLine(string.Format("订单:{0}", soSysNo));

                SOEntity soEntity = SODA.GetSOEntity(soSysNo, CompanyCode);


                //更新订单
                try
                {
                    UpdateSO(soSysNo);

                    if (ExistsNetPay(soSysNo))
                    {
                        AuditNetPay(soSysNo);
                    }
                }
                catch (Exception ex)
                {
                    UpdateSOGroupBuyStatus(soSysNo, "F");
                    Dealfault(ex);
                    continue;
                }

                UpdateSOGroupBuyStatus(soSysNo, "S");
            }

            if (group.Status == "F")
            {
                //EndGroupBuying(group.SystemNumber);
            }
        }
Beispiel #17
0
        /// <summary>
        /// 保存单个子订单
        /// </summary>
        /// <param name="subSOInfo"></param>
        protected virtual void SaveSubSO(SOInfo subSOInfo)
        {
            if (IsAutoSplit)
            {
                subSOInfo.StatusChangeInfoList = SerializationUtility.DeepClone(CurrentSO.StatusChangeInfoList);
            }

            //保存订单主信息
            SODA.InsertSOMainInfo(subSOInfo);

            //邮政自提
            if (IsPostShip)
            {
                subSOInfo.ShippingInfo.PostInfo.SOSysNo = subSOInfo.SysNo;
                SODA.InsertChinaPost(subSOInfo.ShippingInfo.PostInfo);
            }
            //添加增值税发票信息
            if (subSOInfo.InvoiceInfo != null && subSOInfo.InvoiceInfo.IsVAT.Value && subSOInfo.InvoiceInfo.VATInvoiceInfo != null)
            {
                SODA.UpdateSOVATInvoice(subSOInfo.InvoiceInfo.VATInvoiceInfo);
            }

            SODA.InsertSOItemInfo(subSOInfo);

            SODA.InsertSOCheckShippingInfo(subSOInfo);
            //处理赠品信息 2011-8-29
            foreach (SOPromotionInfo promotionInfo in subSOInfo.SOPromotions)
            {
                SODA.InsertSOPromotionInfo(promotionInfo, subSOInfo.CompanyCode);
            }

            //处理毛利分配信息
            foreach (ItemGrossProfitInfo gross in subSOInfo.ItemGrossProfitList)
            {
                SODA.InsertSOItemGossProfit(gross);
            }
        }
Beispiel #18
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");
            }
        }
Beispiel #19
0
        /// <summary>
        /// 订单解锁
        /// </summary>
        /// <param name="soBaseInfo">订单基本信息</param>
        /// <param name="reason">解锁原因</param>
        internal virtual void Unhold(SOUnholdReason reason)
        {
            //  1.  解锁前的业务检查
            UnholdPreCheck(reason);

            CurrentSO.BaseInfo.HoldTime   = DateTime.Now;
            CurrentSO.BaseInfo.HoldStatus = SOHoldStatus.Unhold;
            CurrentSO.BaseInfo.HoldUser   = ServiceContext.Current.UserSysNo;
            //  2.  保存订单解锁
            SODA.UpdateSOHoldInfo(CurrentSO.BaseInfo);
            //  3.  添加订单更改日志,通知WMS重新Download订单
            ObjectFactory <SOLogProcessor> .Instance.WriteSOChangeLog(new SOChangeLog
            {
                ChangeTime    = DateTime.Now,
                ChangeType    = 3,
                CompanyCode   = CurrentSO.CompanyCode,
                CustomerSysNo = CurrentSO.BaseInfo.CustomerSysNo.Value,
                Guid          = Guid.NewGuid(),
                SOSysNo       = SOSysNo,
            });

            //  4.  订单操作日志
            WriteLog(BizEntity.Common.BizLogType.Sale_SO_UnHoldSO, "取消锁定");
        }
Beispiel #20
0
        protected virtual void SaveCancelAudit()
        {
            SOStatusChangeInfo statusChangeInfo = new SOStatusChangeInfo
            {
                SOSysNo              = SOSysNo,
                ChangeTime           = DateTime.Now,
                IsSendMailToCustomer = true,
                OldStatus            = CurrentSO.BaseInfo.Status.Value,
                OperatorSysNo        = ECCentral.Service.Utility.ServiceContext.Current.UserSysNo,
                OperatorType         = ServiceContext.Current.UserSysNo == 0 ? SOOperatorType.System : SOOperatorType.User,
                Status = SOStatus.Origin
            };

            //  2.  保存修改状态
            if (SODA.UpdateSOStatusToOrigin(statusChangeInfo))
            {
                CurrentSO.BaseInfo.Status = SOStatus.Origin;
                CurrentSO.ShippingInfo.FreightUserSysNo  = 0;
                CurrentSO.ShippingInfo.AllocatedManSysNo = 0;
            }

            //  3.  写订单修改日志
            WriteLog();
        }
Beispiel #21
0
        public virtual void Split()
        {
            SubSOList = new List <SOInfo>();
            //  1.  效验是否满足基本拆分条件
            Precheck();

            //拆当前订单
            SplitCurrentSO();

            // 子订单分摊计算
            CalculateSubSO(SubSOList);

            #region 保存订单信息到数据库

            // 保存订单信息到数据库
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted;
            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                #region 保存主订单信息
                SOStatusChangeInfo statusChangeInfo = new SOStatusChangeInfo
                {
                    ChangeTime    = DateTime.Now,
                    OldStatus     = CurrentSO.BaseInfo.Status.Value,
                    OperatorSysNo = ServiceContext.Current.UserSysNo,
                    OperatorType  = SOOperatorType.User,
                    Status        = SOStatus.Split,
                    SOSysNo       = CurrentSO.SysNo
                };
                //更新主单状态
                if (!SODA.UpdateSOStatusToSplit(statusChangeInfo))
                {
                    BizExceptionHelper.Throw("SO_Split_SOStatus_NotOriginal");
                }
                //更新主单标记为已拆分
                CurrentSO.BaseInfo.Status = SOStatus.Split;
                #endregion

                //插入子单数据到数据库
                foreach (SOInfo subSOInfo in SubSOList)
                {
                    SaveSubSO(subSOInfo);
                }
                #region 调整订单相关日志
                //调整礼品卡使用日志
                List <SOBaseInfo> subSOBaseInfoList = SubSOList.Select <SOInfo, SOBaseInfo>(subSOInfo => subSOInfo.BaseInfo).ToList();
                if (CurrentSO.SOGiftCardList.Count > 0)
                {
                    Dictionary <int, List <ECCentral.BizEntity.IM.GiftCardRedeemLog> > subSOGiftCardDictionary = new Dictionary <int, List <ECCentral.BizEntity.IM.GiftCardRedeemLog> >();
                    SubSOList.ForEach(subSOInfo =>
                    {
                        subSOGiftCardDictionary.Add(subSOInfo.SysNo.Value, subSOInfo.SOGiftCardList);
                    });
                    ExternalDomainBroker.SplitSOGiftCard(CurrentSO.BaseInfo, subSOGiftCardDictionary);
                }

                //调整积分
                //调整余额支付
                //作废主单积分日志
                if (CurrentSO.BaseInfo.PointPay > 0)
                {
                    ExternalDomainBroker.SplitSOPoint(CurrentSO.BaseInfo, subSOBaseInfoList);
                }

                //作废主单余额日志
                if (CurrentSO.BaseInfo.PrepayAmount > 0)
                {
                    ExternalDomainBroker.AdjustPrePay(new BizEntity.Customer.CustomerPrepayLog
                    {
                        AdjustAmount  = CurrentSO.BaseInfo.PrepayAmount,
                        PrepayType    = ECCentral.BizEntity.Customer.PrepayType.SOPay,
                        SOSysNo       = SOSysNo,
                        Note          = "拆分订单,作废主订单余额支付",
                        CustomerSysNo = CurrentSO.BaseInfo.CustomerSysNo
                    });

                    SubSOList.ForEach(subSOInfo =>
                    {
                        if (subSOInfo.BaseInfo.PrepayAmount.Value != 0M)
                        {
                            ExternalDomainBroker.AdjustPrePay(new BizEntity.Customer.CustomerPrepayLog
                            {
                                AdjustAmount  = -subSOInfo.BaseInfo.PrepayAmount,
                                PrepayType    = ECCentral.BizEntity.Customer.PrepayType.SOPay,
                                SOSysNo       = SOSysNo,
                                Note          = "拆分订单,子订单使用余额支付",
                                CustomerSysNo = subSOInfo.BaseInfo.CustomerSysNo
                            });
                        }
                    });
                }

                //如果是款到发货订单,拆分NetPay
                if (!CurrentSO.BaseInfo.PayWhenReceived.Value)
                {
                    ExternalDomainBroker.SplitSOIncome(CurrentSO.BaseInfo, subSOBaseInfoList);
                }
                #endregion
                scope.Complete();
            }
            #endregion
            //给客户发拆分邮件
            ObjectFactory <SOSendMessageProcessor> .Instance.SendSplitSOEmail(CurrentSO, SubSOList);

            if (IsAutoSplit)
            {
                foreach (SOInfo subSO in SubSOList)
                {
                    SOAction soAction = SOActionFactory.Create(new SOCommandInfo {
                        Command = SOCommand.Audit, SOInfo = subSO
                    });
                    if (soAction is SOAudit)
                    {
                        (soAction as SOAudit).SendMessage();
                    }
                }
            }
            //记录增票更改日志记录
            if (CurrentSO.InvoiceInfo.IsVAT.Value)
            {
                WriteSOChangeVATLog(SubSOList);
            }

            //记日志
            WriteLog();
        }
Beispiel #22
0
 /// <summary>
 /// 作废虚库采购申请
 /// </summary>
 protected virtual void AbandonSOVirtualItemRequest()
 {
     // 作废虚库采购申请
     SODA.AbandonSOVirtualItemRequest(SOSysNo);
 }
Beispiel #23
0
 /// <summary>
 /// 取消使用延保,
 /// </summary>
 protected virtual void CancelExtendWarranty()
 {
     SODA.CancelSOExtendWarranty(SOSysNo);
 }
Beispiel #24
0
        /// <summary>
        /// 作废订单
        /// </summary>
        /// <param name="isSynch">是否同步作废</param>
        /// <param name="IsImmediatelyReturnStock">是否立即返还库存</param>
        /// <param name="isAO"></param>
        protected virtual void AbandonSO()
        {
            int    couponSysNo = CouponList != null && CouponList.Count > 0 ? CouponList[0].ProductSysNo.Value : 0;
            string couponCode  = string.Empty;

            var shopProducts = CurrentSO.Items.Where(p => p.InventoryType == BizEntity.IM.ProductInventoryType.GetShopInventory);

            //ERP库存调整
            ERPInventoryAdjustInfo erpAdjustInfo = new ERPInventoryAdjustInfo
            {
                OrderSysNo     = this.CurrentSO.SysNo.Value,
                OrderType      = "SO",
                AdjustItemList = new List <ERPItemInventoryInfo>(),
                Memo           = "作废减少销售数量"
            };

            foreach (var item in shopProducts)
            {
                ERPItemInventoryInfo adjustItem = new ERPItemInventoryInfo
                {
                    ProductSysNo     = item.ProductSysNo,
                    B2CSalesQuantity = -item.Quantity.Value
                };

                erpAdjustInfo.AdjustItemList.Add(adjustItem);
            }

            if (erpAdjustInfo.AdjustItemList.Count > 0)
            {
                string adjustXml = ECCentral.Service.Utility.SerializationUtility.ToXmlString(erpAdjustInfo);
                ObjectFactory <ICommonBizInteract> .Instance.CreateOperationLog(string.Format("作废减少销售数量:{0}", adjustXml)
                                                                                , BizLogType.Sale_SO_VoideSO
                                                                                , this.CurrentSO.SysNo.Value
                                                                                , this.CurrentSO.CompanyCode);

                //ObjectFactory<IAdjustERPInventory>.Instance.AdjustERPInventory(erpAdjustInfo);
            }

            //IsolationLevel与上层事务IsolationLevel有冲突,去除
            //TransactionOptions options = new TransactionOptions
            //{
            //    IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
            //};
            //using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))

            #region 如果是拆分后的子单,还需要更新主单信息。
            if (CurrentSO.BaseInfo.SplitType == SOSplitType.SubSO)
            {
                //重新计算主订单SOAmt,ShipPrice,PrepayAmt,PremiumAmt
                SOInfo masterSO = SODA.GetSOBySOSysNo(CurrentSO.BaseInfo.SOSplitMaster.Value);
                masterSO.BaseInfo.PremiumAmount   -= CurrentSO.BaseInfo.PremiumAmount;
                masterSO.BaseInfo.PrepayAmount    -= CurrentSO.BaseInfo.PrepayAmount;
                masterSO.BaseInfo.ShipPrice       -= CurrentSO.BaseInfo.ShipPrice;
                masterSO.BaseInfo.SOAmount        -= CurrentSO.BaseInfo.SOAmount;
                masterSO.BaseInfo.GainPoint       -= CurrentSO.BaseInfo.GainPoint;
                masterSO.BaseInfo.PointPay        -= CurrentSO.BaseInfo.PointPay;
                masterSO.BaseInfo.PromotionAmount -= CurrentSO.BaseInfo.PromotionAmount;
                masterSO.BaseInfo.PayPrice        -= CurrentSO.BaseInfo.PayPrice;
                masterSO.BaseInfo.CouponAmount    -= CurrentSO.BaseInfo.CouponAmount;
                masterSO.BaseInfo.PointPayAmount  -= CurrentSO.BaseInfo.PointPayAmount;

                //删除对应主单中的商品
                foreach (SOItemInfo item in CurrentSO.Items)
                {
                    //除优惠券外的商品
                    if (item.ProductType != SOProductType.Coupon)
                    {
                        SODA.DeleteSOItemBySOSysNoAndProductSysNo(masterSO.SysNo.Value, item.ProductSysNo.Value);
                    }
                }
                //更新主订单金额
                SODA.UpdateSOAmountInfo(masterSO.BaseInfo);
            }

            #endregion 如果是子单,还需要更新主单信息

            //取消优惠券使用
            CancelCoupon();

            //  保存作废订单信息
            SaveCurrentSO();
            //if (AppSettingManager.GetSetting(SOConst.DomainName, "PaymentInventory").ToString().ToLower() != "true")
            //{
            //    // 调整仓库,返还商品库存
            //    AdjustInventory();
            //}
            //SOProcessor sopro = new SOProcessor();
            //DateTime? SOCreatDate = CurrentSO.BaseInfo.CreateTime;
            //foreach (var item in CurrentSO.Items)
            //{
            //    if (sopro.CheckReturnInventory(item.ProductSysNo.Value, SOCreatDate.Value))
            //    {
            //        // 调整仓库,返还商品库存
            //        AdjustInventory();
            //    }
            //}

            //调整仓库,返还商品库存
            AdjustInventory();

            //订单支付
            CancelSOPay();

            // 如果订单有奖品,则要退还奖品。
            if (CurrentSO.Items != null && CurrentSO.Items.Exists(x => x.ProductType == SOProductType.Award))
            {
                ExternalDomainBroker.ReturnAwardForSO(SOSysNo);
            }
            // 取消配送
            CancelDelivery();

            // 作废订单的虚库申请
            AbandonSOVirtualItemRequest();
            // 提交作废订单之前,所做的操作。
            PreCommit();

            WriteLog(CurrentSO);
        }
Beispiel #25
0
        /// <summary>
        /// 创建财务负收款并作废订单
        /// </summary>
        /// <param name="refundInfo"></param>
        /// <returns></returns>
        public void CreateAOAndAbandonSO(SOIncomeRefundInfo refundInfo)
        {
            IsOutStockOrder = false;
            if (CurrentSO.BaseInfo.Status == SOStatus.CustomsPass)
            {
                IsOutStockOrder = true;
            }
            if (CurrentSO.BaseInfo.Status != SOStatus.Origin &&
                CurrentSO.BaseInfo.Status != SOStatus.WaitingOutStock
                //&& CurrentSO.BaseInfo.Status != SOStatus.OutStock
                )
            {
                BizExceptionHelper.Throw("SO_CreateAO_SOStatusIsError");
            }

            if (CurrentSOIncome == null)
            {
                BizExceptionHelper.Throw("SO_CreateAO_SOIncomeIsNull");
            }

            SOIncomeInfo soIncomeInfo = new SOIncomeInfo
            {
                OrderAmt       = -CurrentSOIncome.OrderAmt,
                OrderType      = SOIncomeOrderType.AO,
                Note           = ResourceHelper.Get("Res_SO_Abandon_CreateAO"),
                ReferenceID    = "",
                Status         = SOIncomeStatus.Origin,
                OrderSysNo     = CurrentSO.SysNo,
                IncomeAmt      = -(CurrentSOIncome.OrderAmt - CurrentSOIncome.PrepayAmt - CurrentSOIncome.GiftCardPayAmt),
                PayAmount      = -(CurrentSOIncome.OrderAmt - CurrentSOIncome.PrepayAmt - CurrentSOIncome.GiftCardPayAmt),
                IncomeStyle    = CurrentSOIncome.IncomeStyle,
                PrepayAmt      = -CurrentSOIncome.PrepayAmt,
                GiftCardPayAmt = -CurrentSOIncome.GiftCardPayAmt,
                PointPay       = -CurrentSOIncome.PointPay,
                CompanyCode    = CurrentSO.CompanyCode
            };

            SOIncomeRefundInfo soIncomeRefundInfo = new SOIncomeRefundInfo
            {
                OrderSysNo     = refundInfo.SOSysNo,
                OrderType      = RefundOrderType.AO,
                SOSysNo        = refundInfo.SOSysNo,
                RefundPayType  = refundInfo.RefundPayType,
                BankName       = refundInfo.BankName,
                BranchBankName = refundInfo.BranchBankName,
                CardNumber     = refundInfo.CardNumber,
                CardOwnerName  = refundInfo.CardOwnerName,
                PostAddress    = refundInfo.PostAddress,
                PostCode       = refundInfo.PostCode,
                ReceiverName   = refundInfo.ReceiverName,
                Note           = refundInfo.Note,
                HaveAutoRMA    = false,
                RefundPoint    = 0,
                RefundReason   = refundInfo.RefundReason,
                CompanyCode    = CurrentSO.CompanyCode
            };

            if (refundInfo.RefundPayType == RefundPayType.CashRefund)
            {
                soIncomeRefundInfo.Status = RefundStatus.Audit;
            }
            else
            {
                soIncomeRefundInfo.Status = RefundStatus.Origin;
            }
            if (refundInfo.RefundPayType == RefundPayType.TransferPointRefund)
            {
                soIncomeInfo.IncomeAmt            = 0;
                soIncomeRefundInfo.RefundCashAmt  = 0;
                soIncomeRefundInfo.RefundPoint    = Convert.ToInt32(Decimal.Round(CurrentSO.BaseInfo.SOAmount.Value * ExternalDomainBroker.GetPointToMoneyRatio(), 0));
                soIncomeRefundInfo.RefundGiftCard = CurrentSOIncome.GiftCardPayAmt;
            }
            else
            {
                soIncomeRefundInfo.RefundCashAmt  = CurrentSOIncome.OrderAmt - CurrentSOIncome.GiftCardPayAmt;
                soIncomeRefundInfo.RefundGiftCard = CurrentSOIncome.GiftCardPayAmt;
            }

            ValidateAbandonSO(false);

            bool isHold = CurrentSO.BaseInfo.HoldStatus == SOHoldStatus.BackHold;

            if (IsOutStockOrder)
            {
                isHold = true;
            }
            //如果后台锁定
            if (!isHold)
            {
                isHold = Holder.Hold(SOHolder.SOHoldReason.AbandonOrder, OPCCallBackType.AOAbandonCallBack);
                if (!isHold)
                {
                    BizExceptionHelper.Throw("SO_Abandon_HoldIsAsyn");
                }
            }
            if (isHold) //如果订单已经锁定
            {
                CreateAOAndAbandonSO(soIncomeInfo, soIncomeRefundInfo);
                if (IsOutStockOrder)
                {
                    SODA.UpdateSOStatusToReportedFailure(CurrentSO.SysNo.Value);
                    CurrentSO.BaseInfo.Status = SOStatus.Reject;
                }
                SendMessage();
            }
        }
Beispiel #26
0
        /// <summary>
        /// 如果是新客户的第一张订单,为推荐人增加经验值
        /// </summary>
        /// <param name="soInfo">订单</param>
        /// <param name="customerInfo">订单客户</param>
        public void AddExperienceByRecommend(SOInfo soInfo)
        {
            SOBaseInfo soBaseInfo = soInfo.BaseInfo;

            ECCentral.BizEntity.Customer.CustomerBasicInfo customerInfo = ExternalDomainBroker.GetCustomerInfo(soBaseInfo.CustomerSysNo.Value).BasicInfo;

            string companyCode = soInfo.CompanyCode;

            // 对象为空
            if (customerInfo == null || soInfo == null)
            {
                return;
            }

            // 该客户没有推荐人
            if (!customerInfo.RecommendedByCustomerSysNo.HasValue || customerInfo.RecommendedByCustomerSysNo.Value == 0)
            {
                return;
            }

            // 判断订单是否是该客户的第一张成功出库的订单
            if (!SODA.IsFirstSO(soInfo.SysNo.Value, soBaseInfo.CustomerSysNo.Value))
            {
                return;
            }


            // 获取推荐人信息
            ECCentral.BizEntity.Customer.CustomerBasicInfo rmdCustomerInfo = ExternalDomainBroker.GetCustomerInfo(customerInfo.RecommendedByCustomerSysNo.Value).BasicInfo;

            // 没有相应的推荐人信息
            if (rmdCustomerInfo == null)
            {
                return;
            }

            // 推荐人不能是客户自己
            if (customerInfo.CustomerSysNo == rmdCustomerInfo.CustomerSysNo)
            {
                return;
            }

            // 如果推荐人被禁用,不对其增加经验值
            if (rmdCustomerInfo.Status.Value == BizEntity.Customer.CustomerStatus.InValid)
            {
                return;
            }

            // 订单金额
            decimal soAmount = soBaseInfo.CashPay + soBaseInfo.PayPrice.Value + soBaseInfo.ShipPrice.Value + soBaseInfo.PremiumAmount.Value + soBaseInfo.PromotionAmount.Value;
            // 推荐人经验值的增加数量为订单金额的10%
            decimal rate          = AppSettingHelper.RecommendExperienceRatio;
            decimal addExperience = decimal.Round(soAmount * rate, 0); // 应该增加的经验值,4舍5入到整数

            // 如果增加值<1,
            if (addExperience > 0)
            {
                string logMemo = string.Format("SO#{0}:引荐新用户,首次购物成功,加经验值。", soInfo.SysNo);
                ExternalDomainBroker.AdjustCustomerExperience(rmdCustomerInfo.CustomerSysNo.Value, addExperience, BizEntity.Customer.ExperienceLogType.Recommend, logMemo);
                ObjectFactory <SOSendMessageProcessor> .Instance.RecommendCustomerAddExperienceSendMail(rmdCustomerInfo, customerInfo.CustomerID, addExperience);
            }
        }
Beispiel #27
0
 public static void UpdateSOGroupBuyStatus(int soSysNo, string status)
 {
     SODA.UpdateSOGroupBuyStatus(soSysNo, status, CompanyCode);
 }
Beispiel #28
0
        public void CustomsPass()
        {
            XElement orderConfig = AppSettingHelper.OrderBizConfig;
            int      userSysno   = int.Parse(orderConfig.Element(XName.Get("SellerPortalUserInfo")).Element(XName.Get("UserSysNo")).Value); // int.Parse(orderConfig.SellerPortalUserInfo.UserSysNo);

            SOInfo soInfo = CurrentSO;

            //1.检查SO信息
            //ValidateSOInfo(soInfo);
            if (soInfo.BaseInfo.Status.HasValue && soInfo.BaseInfo.Status.Value != SOStatus.Reported)
            {
                string errorMsg = string.Format("SO单{0}的状态不是“已申报待通关”,不能执行出库操作!", soInfo.BaseInfo.SOID);
                BizExceptionHelper.Throw(errorMsg);
            }

            #region 修改订单状态,调整库存,创建代销转财务记录

            TransactionOptions option = new TransactionOptions();
            option.IsolationLevel = IsolationLevel.ReadUncommitted;
            option.Timeout        = TransactionManager.DefaultTimeout;
            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, option))
            {
                soInfo.BaseInfo.Status = SOStatus.CustomsPass; //设置出库状态
                SODA.UpdateSOStatusToCustomsPass(soInfo.SysNo.Value);
                List <BizEntity.Inventory.InventoryAdjustItemInfo> adjustItemList = new List <BizEntity.Inventory.InventoryAdjustItemInfo>();
                foreach (SOItemInfo soItem in soInfo.Items)
                {
                    switch (soItem.ProductType.Value)
                    {
                    case SOProductType.Product:
                    case SOProductType.Gift:
                    case SOProductType.Award:
                    case SOProductType.SelfGift:
                    case SOProductType.Accessory:
                        adjustItemList.Add(new BizEntity.Inventory.InventoryAdjustItemInfo
                        {
                            AdjustQuantity = soItem.Quantity.Value,
                            ProductSysNo   = soItem.ProductSysNo.Value,
                            StockSysNo     = soItem.StockSysNo.Value
                        });
                        break;

                    case SOProductType.Coupon:
                    case SOProductType.ExtendWarranty:
                        break;
                    }
                }
                //调整库存
                ExternalDomainBroker.AdjustProductInventory(new BizEntity.Inventory.InventoryAdjustContractInfo
                {
                    SourceActionName      = BizEntity.Inventory.InventoryAdjustSourceAction.OutStock,
                    SourceBizFunctionName = BizEntity.Inventory.InventoryAdjustSourceBizFunction.SO_Order,
                    ReferenceSysNo        = soInfo.SysNo.Value.ToString(),
                    AdjustItemList        = adjustItemList
                });

                //Bowen:代码调整,加入事务中 2013-08-08
                //模式2,3创建代销转财务日志
                CreateConsigenToAccInfo(soInfo);


                #region 更新客户等级以及积分经验值
                //增加客户经验值
                //更新客户等级
                //调整客户经验值(内部修改客户等级)
                int     customerSysNo = soInfo.BaseInfo.CustomerSysNo.Value;
                decimal adjustValue   = soInfo.BaseInfo.CashPay + soInfo.BaseInfo.PayPrice.Value + soInfo.BaseInfo.ShipPrice.Value + soInfo.BaseInfo.PremiumAmount.Value + soInfo.BaseInfo.PromotionAmount.Value;

                string logMemo = string.Format("SO#{0}:购物加经验值。", soInfo.SysNo);

                ExternalDomainBroker.AdjustCustomerExperience(customerSysNo, adjustValue, BizEntity.Customer.ExperienceLogType.MerchantSOOutbound, logMemo);
                //增加推荐用户的经验值
                AddExperienceByRecommend(soInfo);

                //给款到发货用户加积分
                AddPointForCustomer(soInfo);
                #endregion 更新客户等级以及积分经验值

                #region 财务应收

                //创建收款单
                ECCentral.BizEntity.Invoice.SOIncomeInfo soIncomeInfo = ExternalDomainBroker.GetValidSOIncomeInfo(soInfo.SysNo.Value, BizEntity.Invoice.SOIncomeOrderType.SO);
                if (soIncomeInfo == null)
                {
                    soIncomeInfo             = new BizEntity.Invoice.SOIncomeInfo();
                    soIncomeInfo.OrderType   = BizEntity.Invoice.SOIncomeOrderType.SO;
                    soIncomeInfo.OrderSysNo  = soInfo.SysNo;
                    soIncomeInfo.OrderAmt    = UtilityHelper.TruncMoney(soInfo.BaseInfo.SOTotalAmount);
                    soIncomeInfo.IncomeAmt   = UtilityHelper.TruncMoney(soInfo.BaseInfo.OriginalReceivableAmount);
                    soIncomeInfo.PrepayAmt   = Math.Max(soInfo.BaseInfo.PrepayAmount.Value, 0);
                    soIncomeInfo.IncomeStyle = ECCentral.BizEntity.Invoice.SOIncomeOrderStyle.Normal;
                    //soIncomeInfo.IncomeUserSysNo = soInfo.LastEditUserSysNumber ?? 0;
                    //soIncomeInfo.IncomeTime = DateTime.Now;
                    soIncomeInfo.Status         = ECCentral.BizEntity.Invoice.SOIncomeStatus.Origin;
                    soIncomeInfo.GiftCardPayAmt = soInfo.BaseInfo.GiftCardPay;
                    soIncomeInfo.PointPay       = soInfo.BaseInfo.PointPay;
                    soIncomeInfo.PayAmount      = soInfo.BaseInfo.OriginalReceivableAmount;
                    if (soInfo.BaseInfo.SOSplitMaster.HasValue)
                    {
                        soIncomeInfo.MasterSoSysNo = soInfo.BaseInfo.SOSplitMaster;  //获取母单号
                    }
                    ExternalDomainBroker.CreateSOIncome(soIncomeInfo);
                }

                #endregion 财务应收

                //this.PublishMessage();
                scope.Complete();
            }


            #endregion

            SOSendMessageProcessor messageProcessor = ObjectFactory <SOSendMessageProcessor> .Instance;
            //发送邮件
            messageProcessor.SOOutStockSendEmailToCustomer(soInfo);

            //发送短信提醒
            //发送短信
            messageProcessor.SendSMS(soInfo, BizEntity.Customer.SMSType.OrderOutBound);

            if (soInfo.InvoiceInfo.IsVAT.Value && soInfo.InvoiceInfo.InvoiceType == ECCentral.BizEntity.Invoice.InvoiceType.SELF)
            {
                //增票提醒短信
                messageProcessor.SendVATSMS(soInfo);
                //发送增值税发票SSB
                EventPublisher.Publish <ECCentral.Service.EventMessage.ImportVATSSBMessage>(new ECCentral.Service.EventMessage.ImportVATSSBMessage
                {
                    SOSysNo    = soInfo.SysNo.Value,
                    StockSysNo = soInfo.Items[0].StockSysNo.Value,
                    OrderType  = EventMessage.ImportVATOrderType.SO
                });
            }

            //调用OverseaInvoiceReceiptManagement.dbo.UP_InvoiceSync
            //插入Inovice_Master
            ObjectFactory <ECCentral.Service.IBizInteract.IInvoiceBizInteract> .Instance.SOOutStockInvoiceSync(soInfo.SysNo.Value, soInfo.Items[0].StockSysNo.Value, soInfo.InvoiceInfo.InvoiceNo, soInfo.CompanyCode);

            //EventPublisher.Publish<ECCentral.Service.EventMessage.CreateInvoiceSSBMessage>(new ECCentral.Service.EventMessage.CreateInvoiceSSBMessage
            //{
            //    CompanyCode = soInfo.CompanyCode,
            //    InvoiceNo = soInfo.InvoiceInfo.InvoiceNo,
            //    SOSysNo = soInfo.SysNo.Value,
            //    StockSysNo = soInfo.Items[0].StockSysNo.Value
            //});
            //记录日志
            WriteLog(ECCentral.BizEntity.Common.BizLogType.Sale_SO_CustomsPass, "通关成功");
        }
Beispiel #29
0
        /// <summary>
        /// 恢复主单为待审核状态,并作废所有子单
        /// </summary>
        /// <param name="soSysNo">子单系统编号</param>
        /// <param name="companyCode"></param>
        /// <returns></returns>
        public void RestoreSOMaster()
        {
            SOInfo masterSO = CurrentSO;
            //查询所有子单
            List <SOInfo> subSOList = ObjectFactory <SOProcessor> .Instance.GetSubSOByMasterSOSysNo(CurrentSO.SysNo.Value);

            if (subSOList == null && subSOList.Count == 0)
            {
                BizExceptionHelper.Throw("SO_CancelSplit_NotExistSubSO");
                return;
            }

            //检查主单和子单的状态
            foreach (SOInfo subSO in subSOList)
            {
                if (subSO.BaseInfo.Status == SOStatus.Abandon ||
                    subSO.BaseInfo.Status == SOStatus.OutStock ||
                    subSO.BaseInfo.Status == SOStatus.Split)
                {
                    BizExceptionHelper.Throw("SO_CancelSplit_SubIsOutStock");
                }
            }
            if (masterSO.BaseInfo.Status != SOStatus.Split)
            {
                BizExceptionHelper.Throw("SO_CancelSplit_MasterSOStatusIsChanged");
            }

            List <SOBaseInfo> subSOBaseInfoList = subSOList.Select <SOInfo, SOBaseInfo>(subSOInfo => subSOInfo.BaseInfo).ToList();

            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted;
            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                //重新创建主单积分日志
                if (masterSO.BaseInfo.PointPay > 0)
                {
                    ExternalDomainBroker.CancelSplitSOPoint(masterSO.BaseInfo, subSOBaseInfoList);
                }

                if (masterSO.BaseInfo.PrepayAmount > 0)
                {
                    ExternalDomainBroker.AdjustPrePay(new BizEntity.Customer.CustomerPrepayLog
                    {
                        AdjustAmount  = -CurrentSO.BaseInfo.PrepayAmount,
                        PrepayType    = ECCentral.BizEntity.Customer.PrepayType.SOPay,
                        SOSysNo       = SOSysNo,
                        Note          = "Res_SO_CancelSplit_MasterSOPrePay",
                        CustomerSysNo = CurrentSO.BaseInfo.CustomerSysNo
                    });

                    subSOList.ForEach(subSOInfo =>
                    {
                        if (subSOInfo.BaseInfo.PrepayAmount.Value != 0M)
                        {
                            ExternalDomainBroker.AdjustPrePay(new BizEntity.Customer.CustomerPrepayLog
                            {
                                AdjustAmount  = subSOInfo.BaseInfo.PrepayAmount,
                                PrepayType    = ECCentral.BizEntity.Customer.PrepayType.SOPay,
                                SOSysNo       = SOSysNo,
                                Note          = "Res_SO_CancelSplit_AbandonSubSOPrePay",
                                CustomerSysNo = subSOInfo.BaseInfo.CustomerSysNo
                            });
                        }
                    });
                }
                if (masterSO.BaseInfo.GiftCardPay > 0)
                {
                    Dictionary <int, List <ECCentral.BizEntity.IM.GiftCardRedeemLog> > subSOGiftCardDictionary = new Dictionary <int, List <ECCentral.BizEntity.IM.GiftCardRedeemLog> >();
                    subSOList.ForEach(subSOInfo =>
                    {
                        subSOGiftCardDictionary.Add(subSOInfo.SysNo.Value, subSOInfo.SOGiftCardList);
                    });
                    ExternalDomainBroker.CancelSplitSOGiftCard(masterSO.BaseInfo, subSOGiftCardDictionary);
                }

                //款到发货订单,恢复主单NetPay记录
                if (!masterSO.BaseInfo.PayWhenReceived.Value)
                {
                    ExternalDomainBroker.CancelSplitSOIncome(masterSO.BaseInfo, subSOBaseInfoList);
                }

                SODA.UpdateSOStatus(new SOStatusChangeInfo
                {
                    ChangeTime    = DateTime.Now,
                    OldStatus     = masterSO.BaseInfo.Status,
                    Status        = SOStatus.Origin,
                    OperatorType  = ServiceContext.Current.UserSysNo == 0 ? SOOperatorType.System : SOOperatorType.User,
                    OperatorSysNo = ServiceContext.Current.UserSysNo,
                    SOSysNo       = CurrentSO.SysNo
                });
                masterSO.BaseInfo.Status = SOStatus.Origin;
                foreach (SOInfo subSO in subSOList)
                {
                    SODA.UpdateSOStatus(new SOStatusChangeInfo
                    {
                        ChangeTime    = DateTime.Now,
                        OldStatus     = subSO.BaseInfo.Status,
                        Status        = SOStatus.Abandon,
                        OperatorType  = ServiceContext.Current.UserSysNo == 0 ? SOOperatorType.System : SOOperatorType.User,
                        OperatorSysNo = ServiceContext.Current.UserSysNo,
                        SOSysNo       = subSO.SysNo
                    });
                }

                scope.Complete();
            }

            SendMsgToWMS(subSOList);
        }
Beispiel #30
0
 protected virtual void CheckSOIsCombine()
 {
     SODA.UpdateSOCombineInfo(SOSysNo);
 }