コード例 #1
0
ファイル: DsDealerBo.cs プロジェクト: KqSMea8/HS.Admin
        /// <summary>
        /// 检查分销商erp代码
        /// </summary>
        /// <param name="erpCode"></param>
        /// <returns></returns>
        /// <remarks>2017-09-22 杨浩 创建</remarks>
        public bool CheckErpCode(string erpCode)
        {
            using (var service = new Pisen.Framework.Service.Proxy.ServiceProxy <Grand.Platform.Api.Contract.IErpService>())
            {
                var requset = new  IsTItemFNumberRequest()
                {
                    FNumber = erpCode
                };

                var response = service.Channel.IsExistTItemFNumber(requset);
                return(response.IsExist);
            }
        }
コード例 #2
0
ファイル: PosServiceBo.cs プロジェクト: KqSMea8/HS.Admin
        /// <summary>
        /// 减库存
        /// </summary>
        /// <param name="request">请求数据集合</param>
        /// <returns></returns>
        /// <remarks>2016-5-17 杨浩 创建</remarks>
        public bool LessProductStock(LessProductStockRequest request)
        {
            try
            {
                using (var service = new Pisen.Framework.Service.Proxy.ServiceProxy <IPosService>())
                {
                    var response = service.Channel.LessProductStock(request);

                    return(response.IsError == false);
                }
            }
            catch (Exception ex)
            {
                BLL.Log.SysLog.Instance.Error(Model.WorkflowStatus.LogStatus.系统日志来源.前台, "减库请求服务异常:LessProductStock", ex);
                return(false);
            }
        }
コード例 #3
0
ファイル: PosServiceBo.cs プロジェクト: KqSMea8/HS.Admin
        /// <summary>
        /// 从Pos系统根据仓库编码和产品编码中获取产品库存
        /// </summary>
        /// <param name="houseErpCode">仓库编码</param>
        /// <param name="productErpCode">产品库存</param>
        /// <returns></returns>
        /// <remarks>2016-5-18 杨浩 创建</remarks>
        public int GetProductStockByErpCodeAndWarehouseCode(string houseErpCode, string productErpCode)
        {
            int stock = 0;

            try
            {
                using (var service = new Pisen.Framework.Service.Proxy.ServiceProxy <IPosService>())
                {
                    var response = service.Channel.GetProductStock(houseErpCode, productErpCode);
                    stock = response;
                }
            }
            catch (Exception ex)
            {
                BLL.Log.SysLog.Instance.Error(Model.WorkflowStatus.LogStatus.系统日志来源.前台, "从Pos系统根据仓库编码和产品编码中获取产品库存请求服务异常:GetProductStockByErpCodeAndWarehouseCode", ex);
            }
            return(stock);
        }
コード例 #4
0
        /// <summary>
        /// 销售出库、退货
        /// </summary>
        /// <param name="easModel">Kis数据</param>
        /// <param name="isSave">是否保存为提交状态</param>
        /// <param name="isAgain">是否重新导入</param>
        /// <param name="enableEas">是否启用Kis</param>
        /// <param name="isData">是否只取xml数据</param>
        /// <returns>Result</returns>
        /// <remarks>2013-9-22 杨浩 创建</remarks>
        public static Result <string> SaleIssueBillFacade(Hyt.Model.LiJiaSyncLog easModel, bool isSave = false, bool isAgain = false, bool enableEas = true, bool isData = false)
        {
            var sale = easModel.Data.ToObject <SaleInfoWraper>();

            List <SaleInfo> model        = sale.Model;
            出库状态            type         = sale.Type;
            string          customer     = sale.Customer;
            string          description  = sale.Description;
            string          flowIdentify = easModel.FlowIdentify;
            string          dataMd5      = easModel.DataMd5;


            var name  = 出库状态.出库 == type ? "销售出库" : "销售退货";
            var watch = new Stopwatch();

            watch.Start();
            var result = new Eas.SaleIssueBillFacade.Result();

            #region 数据初始
            var     firstModel       = model.FirstOrDefault();
            int     warehouseSysNo   = firstModel != null ? firstModel.WarehouseSysNo : 0;              //仓库编号
            decimal voucherAmount    = model.Sum(q => q.Amount);
            var     organizationCode = firstModel != null ? firstModel.OrganizationCode : string.Empty; //组织架构
            if (出库状态.退货 == type)
            {
                voucherAmount = -voucherAmount;
            }


            if (firstModel.WarehouseNumber.Contains("-"))
            {
                firstModel.WarehouseNumber = firstModel.WarehouseNumber.Split('-')[0];
            }


            var saleInfo = model.FirstOrDefault();

            string billNo = "XSCK" + (saleInfo.ItemID ?? 0) + easModel.FlowIdentify;

            var request = new  StockOutAddRequset()
            {
                FBillNo      = billNo,
                FEntryID     = "0",
                Fdate        = DateTime.Now.ToString("yyyy-MM-dd"),
                FConsignee   = _userName,
                FDeptID      = "",
                FEmpID       = organizationCode,
                FExplanation = "",
                FFetchAdd    = "",
                FFManagerID  = "",
                FSaleStyle   = "线上电商平台",
                FSManagerID  = "",
                FCustID      = string.IsNullOrWhiteSpace(saleInfo.DeliveryCustomer) ? config.FCustID : saleInfo.DeliveryCustomer,// "01.001.003",
                FDCStockID   = firstModel.WarehouseNumber,
                FROB         = 出库状态.出库 == type?"1":"-1",
            };


            request.item = model.Select((q, i) => new JsonItem()
            {
                FItemID         = q.ErpCode,
                Fauxqty         = q.Quantity.ToString(),
                FItemName       = "",
                FDCStockID      = q.WarehouseNumber.Contains("-") ? q.WarehouseNumber.Split('-')[0] : q.WarehouseNumber,
                FUnitID         = config.FUnitID,// "ping",
                FConsignPrice   = decimal.Round(q.Amount / q.Quantity, 2).ToString("0.00"),
                FConsignAmount  = q.Amount.ToString("0.00"),
                FDiscountAmount = q.DiscountAmount.ToString("0.00"),
            }).ToList();

            string json = request.ToJson();

            var datajson = new SaleInfoWraper
            {
                Model       = model,
                Type        = type,
                Customer    = customer,
                Description = description
            }.ToJson();


            if (isData)
            {
                return(new Result <string>
                {
                    Data = json
                });
            }

            #endregion

            #region 调用利嘉接口
            步状态 status = 步状态.等待同步;
            if (enableEas && isAgain)
            {
                try
                {
                    using (var service = new Pisen.Framework.Service.Proxy.ServiceProxy <Grand.Platform.Api.Contract.IErpService>())
                    {
                        var response = service.Channel.LiJiaStockOutAdd(request);
                        status            = !response.IsError ?  步状态.成功 :  步状态.失败;
                        result.status     = !response.IsError;
                        result.message    = response.ErrMsg;
                        result.statusCode = response.ErrCode;
                        result.data       = response.FBillNo; //_result.Data != null && _result.Data.Count > 0 ? _result.Data.First().OutFBillNo : "";
                    }
                }
                catch (Exception e)
                {
                    result.message = e.Message;
                    result.status  = false;
                    status         = 步状态.失败;
                }
            }
            else
            {
                result.message = enableEas ? Model.EasConstant.EAS_WAIT : Model.EasConstant.EAS_MESSAGE_CLOSE;
                result.status  = false;
                status         = 步状态.等待同步;
            }

            #endregion

            watch.Stop();

            var resultData = new Result <string>
            {
                Data       = (result.data != null ?result.data.ToString() :""),
                Status     = result.status,
                StatusCode = result.statusCode,
                Message    = result.message
            };
            //记录日志
            int sysno = WriteLog(datajson, resultData, watch, name, 接口类型.销售出库退货, warehouseSysNo, description, flowIdentify, voucherAmount, status, isAgain);
            easModel.SysNo = sysno == 0 ? easModel.SysNo : sysno;
            //临时记录 检查是否重复
            var content = " 订单编号:" + description + " 外部编号:" + request.FBillNo + " 请求时间:" + request.Fdate +
                          " 返回结果:" + (result.status?result.data:result.message) + " 返回状态:" + result.status + "," + result.statusCode + " ElapseTime:" + watch.ElapsedMilliseconds;
            WriteLog(easModel.SysNo, content, request.Fdate, isAgain);

            return(resultData);
        }
コード例 #5
0
        /// <summary>
        /// 库存查询
        /// </summary>
        /// <param name="storageOrgNumber">组织结构编码</param>
        /// <param name="erpCode">erp商品编码</param>
        /// <param name="erpWarehouseSysNo">EAS仓库编号</param>
        /// <param name="warehouseSysNo"></param>
        /// <returns>eas库存</returns>
        /// <remarks>2013-9-18 杨浩 创建</remarks>
        public static Result <IList <Inventory> > WebInventory(string storageOrgNumber, string[] erpCode, string erpWarehouseSysNo, int warehouseSysNo)
        {
            try
            {
                if (erpWarehouseSysNo.Contains("-"))
                {
                    erpWarehouseSysNo = erpWarehouseSysNo.Split('-')[0];
                }

                var request = new Grand.Platform.Api.Contract.DataContract.WebInventoryRequest()
                {
                    FNumbers = string.Join(",", erpCode),
                    FStockID = erpWarehouseSysNo,
                };
                using (var service = new Pisen.Framework.Service.Proxy.ServiceProxy <Grand.Platform.Api.Contract.IErpService>())
                {
                    var response = service.Channel.WebInventory(request);
                    //var result = RequestApi<IList<KisInventory>>("/base/InvList", request.ToJson());
                    if ((!response.IsError && response.InventoryList == null) || (!response.IsError && response.InventoryList != null && response.InventoryList.Count <= 0) || response.IsError)
                    {
                        return(new Result <IList <Inventory> >
                        {
                            Data = null,
                            Status = false,
                            Message = string.Format("没有找到商品数据。仓库:{0},商品:{1}", erpWarehouseSysNo, string.Join(";", erpCode))
                        });
                    }


                    var data = (from item in response.InventoryList
                                select new Inventory
                    {
                        #region
                        //StorageOrgNumber = item.Element("StorageOrgNumber").Value,
                        //StorageOrgName = item.Element("StorageOrgName").Value,
                        //MeasureunitNumber = item.Element("MeasureunitNumber").Value
                        #endregion
                        MaterialNumber = item.FNumber,
                        MaterialName = item.FName,
                        WarehouseNumber = item.FStockID,
                        WarehouseName = item.FStockName,
                        Quantity = (int)item.FQty,
                    }).ToList();


                    return(new Result <IList <Inventory> >
                    {
                        Status = !response.IsError,
                        StatusCode = response.ErrCode,
                        Message = response.ErrMsg,
                        Data = data
                    });
                }
            }
            catch (Exception e)
            {
                return(new Result <IList <Inventory> >
                {
                    Data = null,
                    Status = false,
                    Message =
                        string.Format("{0}。仓库:{1},商品:{2}", e.Message, erpWarehouseSysNo, string.Join(";", erpCode) + ",kis:" + e.Message)
                });
            }
        }
コード例 #6
0
ファイル: PosServiceBo.cs プロジェクト: KqSMea8/HS.Admin
        /// <summary>
        /// 从POS系统获取更新商品价格
        /// </summary>
        /// <returns></returns>
        /// <remarks>2016-05-19 陈海裕 创建</remarks>
        public Result UpdateProductPricesFormPOS()
        {
            lock (lockObject)
            {
                Result result       = new Result();
                string ErrorProduct = "";
                try
                {
                    IList <Grand.Platform.Api.Contract.Model.BranchPrice> branchPrices = null;
                    using (var service = new Pisen.Framework.Service.Proxy.ServiceProxy <IPosService>())
                    {
                        var response = service.Channel.GetBranchPriceList();
                        branchPrices = response.BranchPrices;
                    }

                    if (branchPrices != null)
                    {
                        List <int> sysNoList = new List <int>();
                        foreach (var item in branchPrices)
                        {
                            ErrorProduct = "ERPCODE:" + item.item_no;
                            List <Model.PdPrice> tempList = new List <Model.PdPrice>();
                            Model.PdPrice        price    = null;

                            //price.ProductSysNo = Convert.ToInt32(item.item_no);
                            if (item.base_price1 != 0)
                            {
                                price             = new Model.PdPrice();
                                price.Price       = item.base_price1;
                                price.SourceSysNo = 0;
                                tempList.Add(price);
                            }

                            if (item.base_price2 != 0)
                            {
                                price             = new Model.PdPrice();
                                price.Price       = item.base_price2;
                                price.SourceSysNo = 1;
                                tempList.Add(price);
                            }

                            if (item.base_price3 != 0)
                            {
                                price             = new Model.PdPrice();
                                price.Price       = item.base_price3;
                                price.SourceSysNo = 6;
                                tempList.Add(price);
                            }

                            if (item.base_price4 != 0)
                            {
                                price             = new Model.PdPrice();
                                price.Price       = item.base_price4;
                                price.SourceSysNo = 7;
                                tempList.Add(price);
                            }

                            if (item.base_price5 != 0)
                            {
                                price             = new Model.PdPrice();
                                price.Price       = item.base_price5;
                                price.SourceSysNo = 8;
                                tempList.Add(price);
                            }

                            if (item.base_price6 != 0)
                            {
                                price             = new Model.PdPrice();
                                price.Price       = item.base_price6;
                                price.SourceSysNo = 9;
                                tempList.Add(price);
                            }

                            if (tempList.Count > 0)
                            {
                                PdProduct tempProduct = BLL.Product.PdProductBo.Instance.GetProductByErpCode(item.item_no);
                                if (tempProduct == null)
                                {
                                    continue;
                                }
                                IList <PdPrice> tempPriceList = BLL.Product.PdPriceBo.Instance.GetProductPrice(tempProduct.SysNo);
                                PdPrice         proPrice      = new PdPrice();
                                foreach (var pri in tempList)
                                {
                                    proPrice = (PdPrice)tempPriceList.Where(p => p.SourceSysNo == pri.SourceSysNo).FirstOrDefault();
                                    if ((proPrice.Price != pri.Price) && !sysNoList.Contains(tempProduct.SysNo))
                                    {
                                        sysNoList.Add(tempProduct.SysNo);
                                        proPrice.Price = pri.Price;
                                        BLL.Product.PdPriceBo.Instance.Update(proPrice);
                                    }
                                }
                            }
                        }

                        // 更新索引
                        for (int i = 0; i < sysNoList.Count; i++)
                        {
                            //缓存清理
                            Hyt.BLL.Cache.DeleteCache.ProductInfo(sysNoList[i]);
                            //更新索引
                            BLL.Web.ProductIndexBo.Instance.UpdateProductIndex(sysNoList[i]);
                        }
                    }

                    BLL.Log.SysLog.Instance.Info(Model.WorkflowStatus.LogStatus.系统日志来源.后台, "从Pos系统获取更新商品价格成功", Model.WorkflowStatus.LogStatus.系统日志目标类型.商品基本信息, 0);

                    result.Status = true;
                }
                catch (Exception ex)
                {
                    BLL.Log.SysLog.Instance.Error(Model.WorkflowStatus.LogStatus.系统日志来源.后台, "从Pos系统获取更新商品价格异常:UpdateProductPricesFormPOS;" + ErrorProduct, ex);
                }

                return(result);
            }
        }