/// <summary> /// 上传TDP向门店供货产品品项列表 /// </summary> /// <param name="User"></param> /// <param name="TDP">供货TDP</param> /// <param name="Retailer">门店</param> /// <param name="ProductList">TDP向门店的供货目录</param> /// <returns></returns> public static int UpdateRetailerProductList(UserInfo User, int TDP, int Retailer, ref List<ClientInfo.ProductList> ProductList) { LogWriter.WriteLog("PBMIFService.UpdateRetailerProductList:UserName="******",TDP=" + TDP.ToString() + ",Retailer=" + Retailer.ToString() + ",ProductList=" + JsonConvert.SerializeObject(ProductList)); if (ProductList == null) return -1; if (User.OwnerType == 3) TDP = User.ClientID; IList<CM_ClientProductList> curlist = CM_ClientProductListBLL.GetModelList("Client=" + Retailer.ToString() + (TDP == 0 ? "" : " AND Supplier=" + TDP.ToString())); #region 将系统中存在但上传参数中不存在的产品移出供货目录 foreach (CM_ClientProductList item in curlist) { if (ProductList.FirstOrDefault(p => p.Product == item.Product) == null) new CM_ClientProductListBLL(item.ID).Delete(); } #endregion #region 逐条新增或更新参数中指定的供货目录 foreach (ClientInfo.ProductList item in ProductList) { CM_ClientProductListBLL bll = null; CM_ClientProductList info = curlist.FirstOrDefault(p => p.Product == item.Product); if (info == null) { bll = new CM_ClientProductListBLL(); bll.Model.Client = Retailer; bll.Model.Supplier = TDP; bll.Model.Product = item.Product; bll.Model.Remark = item.Remark; bll.Model.InsertStaff = User.StaffID; bll.Model.Price = PDT_StandardPriceBLL.GetSalePrice(Retailer, TDP, item.Product); bll.Add(); } else { bll = new CM_ClientProductListBLL(info.ID); bll.Model.Price = PDT_StandardPriceBLL.GetSalePrice(Retailer, TDP, item.Product); bll.Update(); } } #endregion #region 返回服务器端更新后的经营品项(向手机端反馈默认供货价格) ProductList.Clear(); foreach (CM_ClientProductList item in CM_ClientProductListBLL.GetModelList ("Client=" + Retailer.ToString() + (TDP == 0 ? "" : " AND Supplier=" + TDP.ToString()))) { ProductList.Add(new ClientInfo.ProductList(item)); } #endregion return 0; }
private void FillClientInfo(CM_Client m, int TDP) { if (m == null) { return; } CM_ClientBLL ClientBLL = new CM_ClientBLL(m.ID); if (ClientBLL.Model == null) { return; } #region 绑定基本资料 ID = m.ID; Code = m.Code; FullName = m.FullName == "" ? m.ShortName : m.FullName; ShortName = m.ShortName; OfficialCity = m.OfficialCity; Address = m.Address; ClientType = m.ClientType; LinkManName = m.LinkManName; TeleNum = m.TeleNum; Mobile = m.Mobile == "" ? m.TeleNum : m.Mobile; OfficialCityName = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OfficialCity", m.OfficialCity).Replace("->", " "); #endregion #region 绑定供货信息 CM_ClientSupplierInfo SupplierInfo = ClientBLL.GetSupplierInfo(TDP); if (SupplierInfo != null) { CodeBySupplier = SupplierInfo.Code; Supplier = SupplierInfo.Supplier; StandardPrice = SupplierInfo.StandardPrice; TDPChannel = SupplierInfo.TDPChannel; TDPSalesArea = SupplierInfo.TDPSalesArea; VisitRoute = SupplierInfo.VisitRoute; VisitSequence = SupplierInfo.VisitSequence; VisitTemplate = SupplierInfo.VisitTemplate; #region 获取供货商名称 CM_Client s = new CM_ClientBLL(Supplier).Model; if (s != null) { SupplierName = s.ShortName == "" ? s.ShortName : s.FullName; } #endregion #region 获取价表名称 if (StandardPrice != 0) { PDT_StandardPrice price = new PDT_StandardPriceBLL(StandardPrice).Model; if (price != null) { StandardPriceName = price.Name; } } #endregion #region 获取渠道名称 if (TDPChannel > 0) { CM_RTChannel_TDP channel = new CM_RTChannel_TDPBLL(TDPChannel).Model; if (channel != null) { TDPChannelName = channel.Name; } } #endregion #region 获取区域名称 if (TDPSalesArea > 0) { CM_RTSalesArea_TDP area = new CM_RTSalesArea_TDPBLL(TDPSalesArea).Model; if (area != null) { TDPSalesAreaName = area.Name; } } #endregion #region 获取路线及拜访模板名称 if (VisitRoute != 0) { VST_Route r = new VST_RouteBLL(VisitRoute).Model; if (r != null) { VisitRouteName = r.Name; } } if (VisitTemplate != 0) { VST_VisitTemplate t = new VST_VisitTemplateBLL(VisitTemplate).Model; if (t != null) { VisitTemplateName = t.Name; } } #endregion #region 获取销售员名称 if (Salesman != 0) { Org_Staff staff = new Org_StaffBLL(Salesman).Model; if (staff != null) { SalesmanName = staff.RealName; } } #endregion } #endregion #region 绑定厂商管理信息 int manufacturer = 0; //归属厂商 if (m.ClientType == 3) { //门店的归属厂商为当前TDP所归属的厂商 CM_Client supplier = new CM_ClientBLL(TDP).Model; if (supplier != null) { manufacturer = supplier.OwnerClient; } } else if (m.ClientType == 2) { //TDP经销商的归属厂商 manufacturer = m.OwnerClient; } CM_ClientManufactInfo ManufactInfo = ClientBLL.GetManufactInfo(manufacturer); if (ManufactInfo != null) { CodeByManufaturer = ManufactInfo.Code; } #endregion #region 绑定客户定位信息 CM_ClientGeoInfo geo = CM_ClientGeoInfoBLL.GetGeoInfoByClient(m.ID); if (geo != null) { Latitude = (float)geo.Latitude; Longitude = (float)geo.Longitude; } #endregion #region 绑定客户供货产品目录 ClientProductLists = new List <ProductList>(); foreach (CM_ClientProductList item in CM_ClientProductListBLL.GetModelList ("Client=" + m.ID.ToString() + (TDP == 0 ? "" : " AND Supplier=" + TDP.ToString()))) { ClientProductLists.Add(new ProductList(item)); } #endregion #region 查询预收款余额 AC_CurrentAccount ac = AC_CurrentAccountBLL.GetByTradeClient(TDP, m.ID); if (ac != null) { ARBalance = ac.PreReceivedAmount - ac.AR; } #endregion #region 获取附件明细 IList <ATMT_Attachment> atts = ATMT_AttachmentBLL.GetAttachmentList(30, m.ID, DateTime.Today.AddMonths(-3), new DateTime(2100, 1, 1)); Atts = new List <Attachment>(atts.Count); foreach (ATMT_Attachment item in atts.OrderByDescending(p => p.UploadTime)) { Atts.Add(new Attachment(item)); } #endregion }