/// <summary> /// 商家折扣列表 /// </summary> /// <param name="_activityDiscountVM"></param> /// <param name="pn"></param> /// <returns></returns> public ActionResult Discount(ActivityDiscountVM _activityDiscountVM, int pn = 1) { // _activityDiscountVM.ActivityDiscount = _activityDiscountService.GetByBusinessId(int.Parse(Loginer.BusinessId)) ?? new ActivityDiscount(); _activityDiscountVM.ActivityDiscount = _businessInfoService.GetById(int.Parse(Loginer.BusinessId)).ActivityDiscount ?? new ActivityDiscount(); _activityDiscountVM.IsSupport = _activityDiscountVM.ActivityDiscount.ActivityDiscountId > 0 ? 1 : 0; var list = _activityManjianService.GetListByBusinessId(int.Parse(Loginer.BusinessId)); _activityDiscountVM.ActivityMinusList = list; return(View(_activityDiscountVM)); }
/// <summary> /// 根据商家id获取折扣信息和满减信息 /// </summary> /// <param name="Business_Id"></param> /// <returns></returns> public ResponseModel <ActivityDTO> GetDisCountByBusinessId(int Business_Id) { var result = new ResponseModel <ActivityDTO>(); result.error_code = Result.SUCCESS; string key = "GetDisCountByBusinessId" + Business_Id; if (Business_Id <= 0) { result.error_code = Result.ERROR; result.message = "参数不合法"; result.data = null; return(result); } else if (RedisDb._redisHelper_11().KeyExists(key)) { var data = RedisDb._redisHelper_11().StringGet <ActivityDTO>(key); result.data = data; result.total_count = 1; return(result); } else { var businessInfo = _businessInfoService.GetById(Business_Id); if (businessInfo != null) { var activityDTO = new ActivityDTO(); if (businessInfo.ActivityDiscount != null) { var activityDto = new ActivityDiscountDTO() { id = businessInfo.ActivityDiscount.ActivityDiscountId, discount = businessInfo.ActivityDiscount.Discount, business_id = businessInfo.BusinessInfoId }; activityDTO.discount = activityDto; } var businessMinusList = businessInfo.ActivityMinusList.Where(c => c.IsDelete == (int)IsDeleteEnum.效 && c.Status == (int)EnabledEnum.效).ToList(); if (businessMinusList != null) { var minusList = new List <ActivityMinusDTO>(); foreach (var item in businessMinusList) { minusList.Add(new ActivityMinusDTO() { achieve_amount = Convert.ToInt32(item.AchiveAmount), activityminusid = item.ActivityMinusId, business_id = item.BusinessInfoId, minus_amount = Convert.ToInt32(item.MinusAmount) }); } activityDTO.minus = minusList; } result.data = activityDTO; RedisDb._redisHelper_11().StringSet(key, result.data, RedisConfig._defaultExpiry); } } return(result); }
/// <summary> /// 编辑 /// </summary> /// <returns></returns> public ActionResult Edit(BusinessEvaluationVM vm) { var _business = _businessInfoService.GetById(vm.Id) ?? new BusinessInfo(); var pageModel = new BusinessEvaluationModel(); if (_business.BusinessEvaluation == null) { _business.BusinessEvaluation = new BusinessEvaluation(); } pageModel.BusinessEvaluationId = _business.BusinessEvaluation.BusinessEvaluationId; pageModel.Grade = _business.Grade; pageModel.BusinessInfoId = _business.BusinessInfoId; pageModel.Environment = _business.BusinessEvaluation.Environment; pageModel.Service = _business.BusinessEvaluation.Service; pageModel.Facilities = _business.BusinessEvaluation.Facilities; vm.BusinessEvaluationModel = pageModel; return(View(vm)); }
/// <summary> /// 编辑 /// </summary> /// <param name="vm"></param> /// <returns></returns> public ActionResult Edit(BusinessInfoVM vm) { //获取当前用户角色 vm.RoleId = Loginer.RoleId; if (vm.RoleId == (int)RoleTypeEnum.商家) { vm.Id = int.Parse(Loginer.BusinessId); } var _areas = _baseAreaService.GetAll(); vm.BusinessInfo = _businessInfoService.GetById(vm.Id) ?? new BusinessInfo(); vm.Provinces = _areas.Where(p => p.Grade == 1).ToList(); vm.City = _areas.Where(p => p.BaseAreaId == vm.BusinessInfo.BaseAreaId).FirstOrDefault() ?? new BaseArea(); vm.Citys = _areas.Where(p => p.Grade == 2 && p.FId == vm.City.FId).ToList(); vm.Lines = _baseLineService.GetAll(); vm.Stations = vm.Id > 0 ? _baseStationService.GetAll().Where(p => p.BaseLineId == vm.BusinessInfo.BaseLineId).ToList() : new System.Collections.Generic.List <BaseStation>(); vm.ImgInfo = vm.BusinessInfo.BaseImage ?? new BaseImage(); if (vm.BusinessInfo.BusinessInfoId > 0) { vm.BusinessGroupList = _businessGroupService.GetAll().Where(p => p.BusinessTypeId == vm.BusinessInfo.BusinessTypeId).ToList(); } return(View(vm)); }
/// <summary> /// 编辑 /// </summary> /// <param name="ActivityDiscountVM"></param> /// <returns></returns> public ActionResult Edit(ActivityDiscountVM _activityDiscountVM) { var businessInfo = _businessInfo.GetById(_activityDiscountVM.BusinessInfoId); if (businessInfo != null) { if (businessInfo.ActivityDiscount != null) { _activityDiscountVM.Name = businessInfo.Name ?? ""; _activityDiscountVM.Discount = businessInfo.ActivityDiscount.Discount; _activityDiscountVM.ActivityDiscountId = businessInfo.ActivityDiscount.ActivityDiscountId; } else { _activityDiscountVM.Name = businessInfo.Name; _activityDiscountVM.Discount = 1; _activityDiscountVM.ActivityDiscountId = 0; } _activityDiscountVM.Paging = new Paging <BusinessInfo>(); _activityDiscountVM.QueryName = ""; _activityDiscountVM.ActivityDiscount = new ActivityDiscount(); } return(View(_activityDiscountVM)); }
public ResponseModel <int> PostAppointment(PostAppointment postAppointment) { var result = new ResponseModel <int>(); result.error_code = Result.SUCCESS; if (string.IsNullOrWhiteSpace(postAppointment.value_ids)) { throw new Exception("衣品id不能为空"); } if (postAppointment.module != (int)EnumHelp.BusinessTypeEnum.食) { throw new Exception("模块id有误"); } var user = _userService.GetById(postAppointment.user_id); if (user == null || user.IsDelete == (int)EnumHelp.IsDeleteEnum.已删除 || user.Status == (int)EnumHelp.EnabledEnum.无效) { throw new Exception("用户id有误,或用户已删除"); } var business = _businessInfoService.GetById(postAppointment.business_id); if (business == null || business.IsDelete == (int)EnumHelp.IsDeleteEnum.已删除 || business.Status == (int)EnumHelp.EnabledEnum.无效) { throw new Exception("商家id有误,或商家已删除"); } DateTime appointTime; if (postAppointment.appointment_time == null) { throw new Exception("预约时间不能为空"); } else if (!DateTime.TryParse(postAppointment.ToString(), out appointTime)) { throw new Exception("预约时间有误"); } if (string.IsNullOrWhiteSpace(postAppointment.user_name)) { throw new Exception("用户名不能为空"); } if (!CheckInputHelper.RegexPhone(postAppointment.phone_no)) { throw new Exception("手机号码有误"); } DateTime createTime = System.DateTime.Now; var goodsIds = postAppointment.value_ids.Split(',').ToArray(); int[] output = Array.ConvertAll <string, int>(goodsIds, delegate(string s) { return(int.Parse(s)); }); var goods = business.BusinessGoodsList.Where(c => c.IsDelete == (int)EnumHelp.IsDeleteEnum.效 && c.Status == (int)EnumHelp.IsDeleteEnum.效).ToList(); if (goods != null && goods.Count > 0) { var searchGoods = goods.Where(c => output.Contains(c.GoodsId)).ToList(); if (searchGoods != null && searchGoods.Count == output.Length) { var insertResult = _appointmentService.Insert(new Appointment() { AppointmentTime = appointTime, BusinessInfoId = postAppointment.business_id, UserId = postAppointment.user_id, CreateTime = createTime, DenyReason = "", EditTime = createTime, ModuleId = postAppointment.module, Status = (int)EnumHelp.IsDeleteEnum.效, IsDelete = (int)EnumHelp.IsDeleteEnum.效, Remark = postAppointment.remark, ValueIds = postAppointment.value_ids, UserName = postAppointment.user_name, Phone = postAppointment.phone_no }); if (insertResult.AppointmentId <= 0) { throw new Exception("预约失败"); } result.data = insertResult.AppointmentId; } else { throw new Exception("衣品id有误"); } } else { throw new Exception("商家无衣品可以预约"); } return(result); }