Beispiel #1
0
        /// <summary>新架构完成订单创建所需往来账   2015-01-19  陈重文
        /// </summary>
        /// <param name="goodsOrderInfo">订单信息</param>
        /// <param name="goodsOrderDetailInfoList">订单明细</param>
        /// <param name="goodsOrderDeliverInfo">订单运费信息</param>
        /// <param name="errorMsg">错误信息</param>
        /// <returns></returns>
        public IEnumerable <ReckoningInfo> NewCreateReckoningInfoList(GoodsOrderInfo goodsOrderInfo, IList <GoodsOrderDetailInfo> goodsOrderDetailInfoList, out GoodsOrderDeliverInfo goodsOrderDeliverInfo, out string errorMsg)
        {
            if (goodsOrderInfo.HostingFilialeId == Guid.Empty)
            {
                goodsOrderInfo.HostingFilialeId = WMSSao.GetHostingFilialeIdByWarehouseIdGoodsTypes(goodsOrderInfo.DeliverWarehouseId, goodsOrderInfo.SaleFilialeId, goodsOrderDetailInfoList.Select(ent => ent.GoodsType).Distinct());
            }
            //所需添加的往来帐集合
            IList <ReckoningInfo> reckoningList = new List <ReckoningInfo>();

            goodsOrderDeliverInfo = null;
            var orderCarriageInfo = _wmsSao.GetOrderNoCarriage(goodsOrderInfo.OrderNo, out errorMsg);

            if (orderCarriageInfo == null)
            {
                return(reckoningList);
            }
            var carriage = orderCarriageInfo.Carriage;

            if (carriage != 0)
            {
                goodsOrderDeliverInfo = new GoodsOrderDeliverInfo
                {
                    OrderId       = goodsOrderInfo.OrderId,
                    TotalWeight   = orderCarriageInfo.PackageWeight == 0 ? 0 : Convert.ToDouble(orderCarriageInfo.PackageWeight) / 1000,
                    CarriageFee   = Convert.ToDouble(orderCarriageInfo.Carriage),
                    ExpressId     = goodsOrderInfo.ExpressId,
                    ExpressNo     = goodsOrderInfo.ExpressNo,
                    MaxWrongValue = 0,
                    ProvinceName  = orderCarriageInfo.Province,
                    CityName      = orderCarriageInfo.City
                };
            }

            #region [检查快递往来单位信息]

            Guid companyId = Express.Instance.Get(goodsOrderInfo.ExpressId).CompanyId;
            CompanyCussentInfo expressCompanyInfo = _companyCussent.GetCompanyCussent(companyId);
            if (expressCompanyInfo == null)
            {
                errorMsg = "快递公司的往来对账信息没有建立!";
                return(new List <ReckoningInfo>());
            }

            #endregion

            //获取销售公司名称
            string saleFilialeName    = FilialeManager.GetName(goodsOrderInfo.SaleFilialeId);
            string hostingFilialeName = FilialeManager.GetName(goodsOrderInfo.HostingFilialeId);
            #region [运费往来帐]
            if (carriage > 0)
            {
                #region [销售公司对快递公司应付快递运费帐]
                //销售公司对快递公司的应付快递运费帐
                var saleFilialeToCarriage = new ReckoningInfo
                {
                    ContructType       = ContructType.Insert,
                    ReckoningId        = Guid.NewGuid(),
                    TradeCode          = _codeManager.GetCode(CodeType.PY),
                    DateCreated        = DateTime.Now,
                    ReckoningType      = (int)ReckoningType.Defray,
                    State              = (int)ReckoningStateType.Currently,
                    IsChecked          = (int)CheckType.NotCheck,
                    AuditingState      = (int)AuditingState.Yes,
                    LinkTradeCode      = goodsOrderInfo.ExpressNo,
                    WarehouseId        = goodsOrderInfo.DeliverWarehouseId,
                    FilialeId          = goodsOrderInfo.HostingFilialeId,
                    ThirdCompanyID     = expressCompanyInfo.CompanyId,
                    Description        = string.Format("[完成订单,{0}对快递公司{1}运费应付款]", hostingFilialeName, expressCompanyInfo.CompanyName),
                    AccountReceivable  = -carriage,
                    JoinTotalPrice     = -carriage,
                    ReckoningCheckType = (int)ReckoningCheckType.Carriage,
                    IsOut              = goodsOrderInfo.IsOut,
                    LinkTradeType      = (int)ReckoningLinkTradeType.Express,
                };
                reckoningList.Add(saleFilialeToCarriage);
                #endregion
            }
            #endregion

            #region 销售公司对快递公司的订单代收帐

            if (goodsOrderInfo.PayMode == (int)PayMode.COD || goodsOrderInfo.PayMode == (int)PayMode.COM)
            {
                #region [销售公司对快递公司的订单代收帐]

                //销售公司对快递公司的订单代收帐
                var saleFilialeToRealTotalPrice = new ReckoningInfo
                {
                    ContructType       = ContructType.Insert,
                    ReckoningId        = Guid.NewGuid(),
                    TradeCode          = _codeManager.GetCode(CodeType.GT),
                    DateCreated        = DateTime.Now,
                    ReckoningType      = (int)ReckoningType.Income,
                    State              = (int)ReckoningStateType.Currently,
                    IsChecked          = (int)CheckType.NotCheck,
                    AuditingState      = (int)AuditingState.Yes,
                    LinkTradeCode      = goodsOrderInfo.ExpressNo,
                    WarehouseId        = goodsOrderInfo.DeliverWarehouseId,
                    FilialeId          = goodsOrderInfo.SaleFilialeId,
                    ThirdCompanyID     = expressCompanyInfo.CompanyId,
                    Description        = string.Format("[完成订单,{0}对快递公司{1}的订单应收货款]", saleFilialeName, expressCompanyInfo.CompanyName),
                    AccountReceivable  = WebRudder.ReadInstance.CurrencyValue(goodsOrderInfo.RealTotalPrice),
                    ReckoningCheckType = (int)ReckoningCheckType.Collection,
                    IsOut              = goodsOrderInfo.IsOut,
                    LinkTradeType      = (int)ReckoningLinkTradeType.GoodsOrder,
                };

                reckoningList.Add(saleFilialeToRealTotalPrice);
                #endregion
            }
            #endregion

            return(reckoningList);
        }