/// <summary> /// 查询自提点信息 /// </summary> /// <param name="selfTakeStationSearch">查询类</param> /// <param name="rowCount">总记录数</param> /// <returns>结果</returns> public System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.CustomDTO.SelfTakeStationResult> GetAllSelfTakeStationExt(Jinher.AMP.BTP.Deploy.CustomDTO.SelfTakeStationSearchSDTO selfTakeStationSearch, out int rowCount) { List <SelfTakeStationResult> result = new List <SelfTakeStationResult>(); //总代名称 string cityOwnerName = string.Empty; if (selfTakeStationSearch == null || selfTakeStationSearch.pageIndex < 1 || selfTakeStationSearch.pageSize < 1) { rowCount = 0; return(result); } var query = SelfTakeStation.ObjectSet().Where(t => !t.IsDel); if (selfTakeStationSearch.SelfTakeStationType != null) { query = query.Where(t => t.SelfTakeStationType == selfTakeStationSearch.SelfTakeStationType); } if (selfTakeStationSearch.CityOwnerId != Guid.Empty) { query = query.Where(t => t.CityOwnerId == selfTakeStationSearch.CityOwnerId); } if (!string.IsNullOrWhiteSpace(selfTakeStationSearch.Name)) { query = query.Where(t => t.Name.Contains(selfTakeStationSearch.Name)); } if (selfTakeStationSearch.AppId != Guid.Empty) { query = query.Where(t => t.AppId == selfTakeStationSearch.AppId); } query = query.Distinct(); rowCount = query.Count(); query = query.OrderByDescending(n => n.SubTime).Skip((selfTakeStationSearch.pageIndex - 1) * selfTakeStationSearch.pageSize).Take(selfTakeStationSearch.pageSize); var tmpResult = query.ToList(); if (tmpResult.Count == 0) { rowCount = 0; return(result); } //总代名称服 //try //{ // Jinher.AMP.ZPH.ISV.Facade.ProxyFacade proxyFac = new ZPH.ISV.Facade.ProxyFacade(); // Jinher.AMP.ZPH.Deploy.CustomDTO.ReturnInfo<List<Jinher.AMP.ZPH.Deploy.CustomDTO.ProxyContentCDTO>> resultProxy = proxyFac.GetProxyById4BTP(selfTakeStationSearch.CityOwnerId); // cityOwnerName = resultProxy.Data[0].proxyName; //} //catch (Exception ex) //{ // LogHelper.Error(string.Format("获取总代名称服务异常。id:{0}", selfTakeStationSearch.CityOwnerId), ex); // rowCount = 0; // return result; //} //总代名称服 if (selfTakeStationSearch.SelfTakeStationType == 0) { try { Jinher.AMP.ZPH.Deploy.CustomDTO.QueryProxyPrarm prarm = new ZPH.Deploy.CustomDTO.QueryProxyPrarm(); prarm.changeOrg = selfTakeStationSearch.CityOwnerId; Jinher.AMP.ZPH.Deploy.CustomDTO.ProxyContentCDTO proxyContent = new ZPH.Deploy.CustomDTO.ProxyContentCDTO(); Jinher.AMP.ZPH.Deploy.CustomDTO.ReturnInfo <List <Jinher.AMP.ZPH.Deploy.CustomDTO.ProxyContentCDTO> > resultProxy = Jinher.AMP.BTP.TPS.ZPHSV.Instance.GetAllProxyList4BTP(prarm); cityOwnerName = resultProxy.Data[0].proxyName; } catch (Exception ex) { LogHelper.Error(string.Format("获取总代名称服务异常。id:{0}", selfTakeStationSearch.CityOwnerId), ex); rowCount = 0; return(result); } } //取负责人信息 var ids = tmpResult.Select(t => t.Id).ToList(); var selfTakeStationManager = SelfTakeStationManager.ObjectSet().Where(t => ids.Contains(t.SelfTakeStationId) && !t.IsDel).ToList(); try { foreach (var item in tmpResult) { SelfTakeStationResult data = new SelfTakeStationResult(); data.Id = item.Id; data.CityOwnerId = item.CityOwnerId; data.Name = item.Name; data.Province = item.Province; data.City = item.City; data.District = item.District; data.Address = item.Address; data.SpreadUrl = item.SpreadUrl; data.Remark = item.Remark; data.SubTime = item.SubTime; data.ModifiedOn = item.ModifiedOn; data.QRCodeUrl = item.QRCodeUrl; data.SpreadCode = item.SpreadCode; data.CityOwnerName = cityOwnerName; string province = Jinher.AMP.BTP.Common.ProvinceCityHelper.GetAreaNameByCode(data.Province); string city = string.Empty; ////北京110000 天津120000 上海310000 重庆500000 //List<string> specialCityList = new List<string>() { "110000", "120000", "310000", "500000" }; //if (specialCityList.Contains(data.Province)) //{ // city = ""; //} //else //{ // city = Jinher.AMP.BTP.Common.ProvinceCityHelper.GetAreaNameByCode(data.City); //} city = Jinher.AMP.BTP.Common.ProvinceCityHelper.GetAreaNameByCode(data.City); data.AddressDetail = province + city + data.Address; //附上负责人信息 var selfManager = (from manager in selfTakeStationManager where manager.SelfTakeStationId == item.Id && !manager.IsDel select new Jinher.AMP.BTP.Deploy.CustomDTO.SelfTakeStationManagerSDTO { Id = manager.Id, SubTime = manager.SubTime, ModifiedOn = manager.ModifiedOn, UserCode = manager.UserCode, UserId = manager.UserId, SelfTakeStationId = manager.SelfTakeStationId }).ToList(); data.SelfTakeStationManageList = selfManager; result.Add(data); } return(result); } catch (Exception ex) { LogHelper.Error(string.Format("查询自提点BP服务异常。selfTakeStationSearch:{0}", JsonHelper.JsonSerializer(selfTakeStationSearch)), ex); rowCount = 0; return(result); } }
/// <summary> /// 发布活动 /// </summary> public ResultDTO CreatePromotionExt(PresentPromotionCreateDTO input) { if (input.Commodities == null || input.Commodities.Count == 0) { return(new ResultDTO { isSuccess = false, Message = "请选择主商品" }); } if (input.Gifts == null || input.Gifts.Count == 0) { return(new ResultDTO { isSuccess = false, Message = "请选择赠品" }); } var comIds = input.Commodities.Select(_ => _.CommodityId); // 检查活动是否冲突 // 该商品正在参与XX(秒杀、预约、预售、拼团、限时打折、赠品促销、套餐促销)活动,请更换商品或者更改活动时间 var prop = (from item in PromotionItems.ObjectSet() join pro in Promotion.ObjectSet() on item.PromotionId equals pro.Id where !pro.IsDel && (comIds.Contains(item.CommodityId) && pro.EndTime >= input.BeginTime && pro.StartTime <= input.EndTime) select pro).FirstOrDefault(); if (prop != null) { var propName = "限时打折"; switch (prop.PromotionType) { case 1: propName = "秒杀"; break; case 2: propName = "预约"; break; case 3: propName = "拼团"; break; case 5: propName = "预售"; break; } Jinher.AMP.ZPH.ISV.Facade.CommodityFacade facadeCheck = new Jinher.AMP.ZPH.ISV.Facade.CommodityFacade(); foreach (var item in comIds) { Jinher.AMP.ZPH.Deploy.CustomDTO.CheckComdtyActInSameTimeCDTO dto = new ZPH.Deploy.CustomDTO.CheckComdtyActInSameTimeCDTO() { comdtyId = item, startTime = input.BeginTime, endTime = input.EndTime }; Jinher.AMP.ZPH.Deploy.CustomDTO.ReturnInfo requst = facadeCheck.CheckComdtyActInSameTime(dto); if (requst.Message.Contains("套装")) { propName = "套装"; break; } } return(new ResultDTO { isSuccess = false, Message = "该商品正在参与" + propName + "活动,请更换商品或者更改活动时间" }); } var ppCount = PresentPromotionCommodity.ObjectSet().Where(_ => comIds.Contains(_.CommodityId)).Join(PresentPromotion.ObjectSet().Where(p => !p.IsEnd && p.EndTime >= input.BeginTime && p.BeginTime <= input.EndTime), pc => pc.PresentPromotionId, p => p.Id, (pc, p) => 1).Count(); if (ppCount > 0) { return(new ResultDTO { isSuccess = false, Message = "该商品正在参与赠品促销活动,请更换商品或者更改活动时间" }); } ContextSession contextSession = ContextFactory.CurrentThreadContext; var presentPromotion = PresentPromotion.CreatePresentPromotion(); presentPromotion.AppId = input.AppId; presentPromotion.UserId = ContextDTO.LoginUserID; presentPromotion.Name = input.Name; presentPromotion.BeginTime = input.BeginTime; presentPromotion.EndTime = input.EndTime; presentPromotion.Limit = input.Limit; presentPromotion.IsEnd = false; contextSession.SaveObject(presentPromotion); foreach (var item in input.Commodities) { PresentPromotionCommodity ppc = PresentPromotionCommodity.CreatePresentPromotionCommodity(); ppc.PresentPromotionId = presentPromotion.Id; ppc.AppId = input.AppId; ppc.UserId = ContextDTO.LoginUserID; ppc.CommodityId = item.CommodityId; ppc.CommodityCode = item.Code; ppc.CommodityName = item.Name; ppc.CommoditySKUId = item.SKUId; ppc.CommoditySKU = item.SKUName; ppc.CommoditySKUCode = item.SKUCode; ppc.CommodityPrice = item.Price; ppc.Limit = item.Limit; contextSession.SaveObject(ppc); } foreach (var item in input.Gifts) { PresentPromotionGift ppg = PresentPromotionGift.CreatePresentPromotionGift(); ppg.PresentPromotionId = presentPromotion.Id; ppg.AppId = input.AppId; ppg.UserId = ContextDTO.LoginUserID; ppg.CommodityId = item.CommodityId; ppg.CommodityCode = item.Code; ppg.CommodityName = item.Name; ppg.CommoditySKUId = item.SKUId; ppg.CommoditySKU = item.SKUName; ppg.CommoditySKUCode = item.SKUCode; ppg.CommodityPrice = item.Price; ppg.Number = item.Limit; contextSession.SaveObject(ppg); } try { contextSession.SaveChange(Jinher.JAP.Common.SaveExceptionEnum.BF); } catch (Exception ex) { LogHelper.Error("PresentPromotionBPExt.CreatePromotionExt 异常", ex); return(new Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO { isSuccess = false, Message = ex.Message }); } return(new Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO { isSuccess = true }); }