/// <summary> /// 删除自提点 /// </summary> /// <param name="id">自提点ID</param> /// <returns>结果</returns> public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO DeleteAppSelfTakeStationExt(Guid id) { try { ContextSession contextSession = ContextFactory.CurrentThreadContext; var selfStation = AppSelfTakeStation.ObjectSet().FirstOrDefault(n => n.Id == id); if (selfStation == null) { return new ResultDTO { ResultCode = 0, Message = "Success" } } ; selfStation.ModifiedOn = DateTime.Now; selfStation.EntityState = System.Data.EntityState.Modified; selfStation.IsDel = true; contextSession.SaveChange(); } catch (Exception ex) { LogHelper.Error(string.Format("删除自提点服务异常。id:{0}", id), ex); return(new ResultDTO { ResultCode = 1, Message = "Error" }); } return(new ResultDTO { ResultCode = 0, Message = "Success" }); }
/// <summary> /// 获取所有自提点 /// </summary> /// <param name="appId">卖家id</param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <param name="rowCount"></param> /// <returns></returns> public List <AppSelfTakeStationResultDTO> GetAllAppSelfTakeStationExt(Guid appId, int pageSize, int pageIndex, out int rowCount) { List <AppSelfTakeStationResultDTO> result = new List <AppSelfTakeStationResultDTO>(); if (appId == Guid.Empty) { rowCount = 0; return(result); } var query = (from c in AppSelfTakeStation.ObjectSet() where c.AppId == appId && c.IsDel == false orderby c.SubTime descending select new AppSelfTakeStationResultDTO { Id = c.Id, AppId = c.AppId, Name = c.Name, Address = c.Address, Phone = c.Phone }).ToList(); rowCount = query.Count; result = query.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); return(result); }
/// <summary> /// 查询自提点 /// </summary> /// <param name="search">查询类</param> /// <returns>结果</returns> public SelfTakeStationResultDTO GetSelfTakeStationExt(SelfTakeStationSearchDTO search) { SelfTakeStationResultDTO result = new SelfTakeStationResultDTO(); if (search == null || search.pageIndex < 1 || search.pageSize < 1 || search.appId == Guid.Empty) { return(result); } var query = from s in AppSelfTakeStation.ObjectSet() where !s.IsDel && s.AppId == search.appId select s; if (!string.IsNullOrEmpty(search.searchContent)) { query = query.Where(n => n.Name.Contains(search.searchContent) || n.Phone.Contains(search.searchContent) || n.Address.Contains(search.searchContent)); } query = query.Distinct(); result.Count = query.Count(); query = query.OrderByDescending(n => n.SubTime).Skip((search.pageIndex - 1) * search.pageSize).Take(search.pageSize); var tmpResult = query.ToList(); if (tmpResult.Count == 0) { result.Count = 0; return(result); } try { foreach (var item in tmpResult) { SelfTakeStationSearchResultDTO data = new SelfTakeStationSearchResultDTO { Id = item.Id, Name = item.Name, Province = ProvinceCityHelper.GetAreaNameByCode(item.Province), City = ProvinceCityHelper.GetAreaNameByCode(item.City), District = ProvinceCityHelper.GetAreaNameByCode(item.District), Address = item.Address, SubTime = item.SubTime, Phone = item.Phone == null ? "" : item.Phone, ModifiedOn = item.ModifiedOn }; result.SelfTakeStationList.Add(data); } return(result); } catch (Exception ex) { LogHelper.Error(string.Format("查询自提点SV服务异常。search:{0}", JsonHelper.JsonSerializer(search)), ex); return(result); } }
/// <summary> /// 待自提订单数量 /// </summary> /// <param name="userId">自提点管理员</param> /// <returns>待自提订单数量</returns> public ResultDTO <int> GetSelfTakeManagerExt(Guid userId) { try { // 返回 是否管理员,待自提订单数量 if (userId == Guid.Empty) { return new ResultDTO <int> { Data = 0, ResultCode = 1, Message = "管理员用户ID非法." } } ; var managerInfo = (from p in AppStsManager.ObjectSet() join r in AppSelfTakeStation.ObjectSet() on p.SelfTakeStationId equals r.Id where p.UserId == userId && p.IsDel == false && r.IsDel == false select p.SelfTakeStationId ).Distinct(); if (!managerInfo.Any()) { LogHelper.Info(string.Format("该用户不是自提点管理员或没有与自提点绑定,userId:{0}", userId)); return(new ResultDTO <int> { Data = 0, ResultCode = -1, Message = "抱歉,您暂时没有权限查看此信息" }); } IQueryable <CommodityOrder> query = CommodityOrder.ObjectSet().Where(n => (n.State == 1 || n.State == 11) && n.IsDel != 1 && n.IsDel != 3); var commodityorderListCount = (from r in managerInfo join t in AppOrderPickUp.ObjectSet() on r equals t.SelfTakeStationId join p in query on t.Id equals p.Id select t.Id).Count(); if (commodityorderListCount != 0) { return(new ResultDTO <int> { Data = commodityorderListCount, ResultCode = 0, Message = "sucess" }); } else { return new ResultDTO <int> { Data = 0, ResultCode = -2, Message = "订单数量为0" } }; } catch (Exception ex) { LogHelper.Error(string.Format("BTPUserSV.GetSelfTakeManagerExt获取待自提订单数量异常。userId:{0},ex:{1}", userId, ex)); return(new ResultDTO <int> { Data = 0, ResultCode = -3, Message = "Exception" }); } }
/// <summary> /// 根据条件查询所有自提点 /// </summary> /// <param name="AppId">卖家ID</param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <param name="rowCount"></param> /// <param name="Name"></param> /// <param name="provice"></param> /// <param name="city"></param> /// <param name="district"></param> /// <returns></returns> public List <Jinher.AMP.BTP.Deploy.CustomDTO.AppSelfTakeStationResultDTO> GetAllAppSelfTakeStationByWhereExt(Guid AppId, int pageSize, int pageIndex, out int rowCount, string Name, string province, string city, string district) { List <Jinher.AMP.BTP.Deploy.CustomDTO.AppSelfTakeStationResultDTO> result = new List <AppSelfTakeStationResultDTO>(); if (AppId == Guid.Empty) { rowCount = 0; return(result); } var query = (from c in AppSelfTakeStation.ObjectSet() where c.AppId == AppId && c.IsDel == false orderby c.SubTime descending select new AppSelfTakeStationResultDTO { Id = c.Id, AppId = c.AppId, Name = c.Name, Address = c.Address, Phone = c.Phone, Province = c.Province, City = c.City, District = c.District }).ToList(); if (!String.IsNullOrEmpty(Name)) { query = query.Where(c => c.Name.Contains(Name)).ToList(); } if (!String.IsNullOrEmpty(province) && province != "000000") { query = query.Where(c => c.Province == province).ToList(); } if (!String.IsNullOrEmpty(city)) { query = query.Where(c => c.City == city).ToList(); } if (!String.IsNullOrEmpty(district)) { query = query.Where(c => c.District == district).ToList(); } rowCount = query.Count; result = query.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); return(result); }
/// <summary> /// 获取自提点信息 /// </summary> /// <param name="id">自提点ID</param> /// <returns>结果</returns> public Jinher.AMP.BTP.Deploy.CustomDTO.AppSelfTakeStationSDTO GetAppSelfTakeStationByIdExt(System.Guid id) { if (id == Guid.Empty) { return(null); } var query = AppSelfTakeStation.ObjectSet().Where(t => t.Id == id && !t.IsDel).FirstOrDefault(); if (query == null) { return(null); } Jinher.AMP.BTP.Deploy.CustomDTO.AppSelfTakeStationSDTO result = new Jinher.AMP.BTP.Deploy.CustomDTO.AppSelfTakeStationSDTO(); result.Id = query.Id; result.AppId = query.AppId; result.Name = query.Name; result.Province = query.Province; result.City = query.City; result.District = query.District; result.Address = query.Address; result.Phone = query.Phone; result.DelayDay = query.DelayDay; result.MaxBookDay = query.MaxBookDay; result.SubTime = query.SubTime; result.ModifiedOn = query.ModifiedOn; result.IsDel = query.IsDel; result.SubId = query.SubId; var selfManager = (from appStsManager in AppStsManager.ObjectSet() where appStsManager.SelfTakeStationId == id && !appStsManager.IsDel select new Jinher.AMP.BTP.Deploy.CustomDTO.AppStsManagerSDTO { Id = appStsManager.Id, SubTime = appStsManager.SubTime, ModifiedOn = appStsManager.ModifiedOn, UserCode = appStsManager.UserCode, UserId = appStsManager.UserId, SelfTakeStationId = appStsManager.SelfTakeStationId, AppId = appStsManager.AppId }).ToList(); result.AppStsManagerList = selfManager; var selfTime = (from appStsOfficeTime in AppStsOfficeTime.ObjectSet() where appStsOfficeTime.SelfTakeStationId == id select new Jinher.AMP.BTP.Deploy.CustomDTO.AppStsOfficeTimeSDTO { Id = appStsOfficeTime.Id, SubTime = appStsOfficeTime.SubTime, ModifiedOn = appStsOfficeTime.ModifiedOn, WeekDays = appStsOfficeTime.WeekDays, StartTime = appStsOfficeTime.StartTime, EndTime = appStsOfficeTime.EndTime, SelfTakeStationId = appStsOfficeTime.SelfTakeStationId, SubId = appStsOfficeTime.SubId }).ToList(); result.AppStsOfficeTimeList = selfTime; return(result); }
/// <summary> /// 修改自提点 /// </summary> /// <param name="model">自提点实体</param> /// <returns>结果</returns> public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO UpdateAppSelfTakeStationExt(Jinher.AMP.BTP.Deploy.CustomDTO.AppSelfTakeStationSDTO model) { if (model == null || model.Id == Guid.Empty || string.IsNullOrWhiteSpace(model.Name) || string.IsNullOrWhiteSpace(model.Province) || string.IsNullOrWhiteSpace(model.City) || string.IsNullOrWhiteSpace(model.Address)) { return(new ResultDTO { ResultCode = 1, Message = "参数不参为空" }); } //if (string.IsNullOrWhiteSpace(model.District)) //{ // return new ResultDTO { ResultCode = 1, Message = "参数不参为空" }; //} try { var modelExits = AppSelfTakeStation.ObjectSet().Where(t => t.Id == model.Id).FirstOrDefault(); if (modelExits == null) { return(new ResultDTO { ResultCode = 1, Message = "自提点不存在" }); } var userId = this.ContextDTO.LoginUserID; ContextSession contextSession = ContextFactory.CurrentThreadContext; modelExits.Name = model.Name; modelExits.Province = model.Province; modelExits.City = model.City; modelExits.District = string.IsNullOrWhiteSpace(model.District) ? "" : model.District; modelExits.Address = model.Address; modelExits.Phone = model.Phone; modelExits.DelayDay = model.DelayDay; modelExits.MaxBookDay = model.MaxBookDay; modelExits.ModifiedOn = DateTime.Now; modelExits.EntityState = EntityState.Modified; var appStsOfficeTimeList = AppStsOfficeTime.ObjectSet().Where(t => t.SelfTakeStationId == model.Id).ToList(); if (appStsOfficeTimeList.Any()) { foreach (var appStsOfficeTime in appStsOfficeTimeList) { appStsOfficeTime.EntityState = EntityState.Deleted; } } if (model.AppStsOfficeTimeList != null && model.AppStsOfficeTimeList.Count > 0) { foreach (var item in model.AppStsOfficeTimeList) { AppStsOfficeTime appStsOfficeTime = new AppStsOfficeTime(); appStsOfficeTime.Id = Guid.NewGuid(); appStsOfficeTime.SubTime = DateTime.Now; appStsOfficeTime.ModifiedOn = DateTime.Now; appStsOfficeTime.WeekDays = item.WeekDays; appStsOfficeTime.StartTime = item.StartTime; appStsOfficeTime.EndTime = item.EndTime; appStsOfficeTime.SelfTakeStationId = modelExits.Id; appStsOfficeTime.SubId = userId; appStsOfficeTime.EntityState = EntityState.Added; contextSession.SaveObject(appStsOfficeTime); } } if (model.AppStsManagerList != null && model.AppStsManagerList.Count > 0) { var userIds = model.AppStsManagerList.Select(t => t.UserId).ToList(); var userIdsDisCount = userIds.Distinct().Count(); if (userIdsDisCount < userIds.Count()) { return(new ResultDTO { ResultCode = 2, Message = "不能填加重复的负责人" }); } var appStsManagerListThis = AppStsManager.ObjectSet() .Where(t => t.SelfTakeStationId == model.Id && !t.IsDel) .ToList(); var addUserIdList = new List <Guid>(); var deleteUserIdList = new List <Guid>(); var updateUserIdList = new List <Guid>(); if (appStsManagerListThis.Any()) { var oldUserIdList = appStsManagerListThis.Select(t => t.UserId).ToList(); addUserIdList = userIds.Except(oldUserIdList).ToList(); deleteUserIdList = oldUserIdList.Except(userIds).ToList(); updateUserIdList = userIds.Intersect(oldUserIdList).ToList(); } else { addUserIdList = model.AppStsManagerList.Select(t => t.UserId).ToList(); } var appStsManagerList = AppStsManager.ObjectSet() .Where(t => t.AppId == model.AppId && addUserIdList.Contains(t.UserId) && !t.IsDel) .ToList(); if (appStsManagerList.Any()) { return(new ResultDTO { ResultCode = 2, Message = "联系人已存在" }); } if (addUserIdList.Any()) { var dealList = model.AppStsManagerList.Where(t => addUserIdList.Contains(t.UserId)).ToList(); foreach (var item in dealList) { AppStsManager appStsManager = new AppStsManager(); appStsManager.Id = Guid.NewGuid(); appStsManager.SubTime = DateTime.Now; appStsManager.ModifiedOn = DateTime.Now; appStsManager.UserCode = item.UserCode; appStsManager.UserId = item.UserId; appStsManager.SelfTakeStationId = model.Id; appStsManager.IsDel = false; appStsManager.AppId = model.AppId; appStsManager.EntityState = EntityState.Added; contextSession.SaveObject(appStsManager); } } if (updateUserIdList.Any()) { var dealList = model.AppStsManagerList.Where(t => updateUserIdList.Contains(t.UserId)).ToList(); foreach (var item in dealList) { var appStsManager = appStsManagerListThis.Where(t => t.UserId == item.UserId).FirstOrDefault(); if (appStsManager.UserCode == item.UserCode) { continue; } appStsManager.ModifiedOn = DateTime.Now; appStsManager.UserCode = item.UserCode; appStsManager.EntityState = EntityState.Modified; } } if (deleteUserIdList.Any()) { var dealList = appStsManagerListThis.Where(t => deleteUserIdList.Contains(t.UserId)).ToList(); foreach (var item in dealList) { var appStsManager = appStsManagerListThis.Where(t => t.UserId == item.UserId).FirstOrDefault(); if (appStsManager == null) { continue; } appStsManager.ModifiedOn = DateTime.Now; appStsManager.IsDel = true; appStsManager.EntityState = EntityState.Modified; } } } else { var appStsManagerList = AppStsManager.ObjectSet() .Where(t => t.SelfTakeStationId == model.Id && !t.IsDel).ToList(); if (appStsManagerList.Any()) { foreach (var item in appStsManagerList) { item.ModifiedOn = DateTime.Now; item.IsDel = true; item.EntityState = EntityState.Modified; } } } contextSession.SaveChanges(); } catch (Exception ex) { LogHelper.Error(string.Format("SaveAppSelfTakeStationExt接口错误。model:{0}", JsonHelper.JsonSerializer(model)), ex); return(new ResultDTO { ResultCode = 1, Message = "Error" }); } return(new ResultDTO { ResultCode = 0, Message = "Success" }); }
/// <summary> /// 下订单页获取自提点信息 /// </summary> /// <param name="search">查询类</param> /// <returns>结果</returns> public Jinher.AMP.BTP.Deploy.CustomDTO.AppSelfTakeStationDefaultInfoDTO GetAppSelfTakeStationDefaultExt(Jinher.AMP.BTP.Deploy.CustomDTO.AppSelfTakeStationSearchDTO search) { var result = new AppSelfTakeStationDefaultInfoDTO(); if (search == null) { return(null); } if (search.SearchType == 1) { if (search.Id == Guid.Empty) { return(null); } var station = AppSelfTakeStation.ObjectSet() .Where(t => t.Id == search.Id && !t.IsDel) .FirstOrDefault(); if (station == null) { return(null); } result.StationId = station.Id; result.StationName = station.Name; result.DelayDay = station.DelayDay; result.MaxBookDay = station.MaxBookDay; result.StationPhone = station.Phone; if (!string.IsNullOrWhiteSpace(station.Province)) { result.StationAddressDetails = ProvinceCityHelper.GetAreaNameByCode(station.Province) + ProvinceCityHelper.GetAreaNameByCode(station.City) + ProvinceCityHelper.GetAreaNameByCode(station.District) + station.Address; } var officeTime = AppStsOfficeTime.ObjectSet().Where(t => t.SelfTakeStationId == station.Id).ToList(); if (officeTime.Any()) { result.StationTimeList = new List <AppStationOfficeTime>(); foreach (var appStsOfficeTime in officeTime) { var officeTimeModel = new AppStationOfficeTime(); officeTimeModel.StartTime = appStsOfficeTime.StartTime; officeTimeModel.EndTime = appStsOfficeTime.EndTime; officeTimeModel.WeekDays = appStsOfficeTime.WeekDays; result.StationTimeList.Add(officeTimeModel); } } } else if (search.SearchType == 2) { if (search.EsAppId == Guid.Empty) { return(null); } var _userId = this.ContextDTO.LoginUserID; var pickUpOrder = AppOrderPickUp.ObjectSet() .Where(t => t.AppId == search.EsAppId && t.UserId == _userId).OrderByDescending(t => t.SubTime) .FirstOrDefault(); if (pickUpOrder == null) { return(null); } var station = AppSelfTakeStation.ObjectSet() .Where(t => t.Id == pickUpOrder.SelfTakeStationId && t.AppId == pickUpOrder.AppId && !t.IsDel) .FirstOrDefault(); if (station == null) { return(null); } result.StationId = station.Id; result.StationName = station.Name; result.DelayDay = station.DelayDay; result.MaxBookDay = station.MaxBookDay; result.StationPhone = station.Phone; result.PickUpName = pickUpOrder.Name; result.PickUpPhone = pickUpOrder.Phone; if (!string.IsNullOrWhiteSpace(station.Province)) { result.StationAddressDetails = ProvinceCityHelper.GetAreaNameByCode(station.Province) + ProvinceCityHelper.GetAreaNameByCode(station.City) + ProvinceCityHelper.GetAreaNameByCode(station.District) + station.Address; } var officeTime = AppStsOfficeTime.ObjectSet().Where(t => t.SelfTakeStationId == station.Id).ToList(); if (officeTime.Any()) { result.StationTimeList = new List <AppStationOfficeTime>(); foreach (var appStsOfficeTime in officeTime) { var officeTimeModel = new AppStationOfficeTime(); officeTimeModel.StartTime = appStsOfficeTime.StartTime; officeTimeModel.EndTime = appStsOfficeTime.EndTime; officeTimeModel.WeekDays = appStsOfficeTime.WeekDays; result.StationTimeList.Add(officeTimeModel); } } } else { return(null); } result.StationTimeShowList = AppSelfTakeSV.DealScrollTime(result.StationTimeList, result.DelayDay, result.MaxBookDay); return(result); }