public APIResult SetIsDelete([FromBody] IdArgsModel args) { var model = db.GetSingle <ShopBrandCommodityParameter>(args.Id); if (model == null) { throw new Exception("记录不存在"); } //在获取后检查是否拥有管理权限 CheckShopBrandActor(model.ShopBrandId, ShopBrandActorType.超级管理员); var records = db.Query <ShopBrandCommoditySkuItem>() .Where(m => !m.IsDel) .Where(m => m.ParameterId == model.Id) .Count(); if (records > 0) { throw new Exception("不能删除此规格,尚有使用它的商品"); } else { model.IsDel = true; db.SaveChanges(); } return(Success()); }
public APIResult GetSingle([FromBody] IdArgsModel args) { var viewModel = db.Query <CommercialDistrict>() .Where(m => m.Id == args.Id) .Select(m => new GetSingleModel() { AddIp = m.AddIp, AddTime = m.AddTime, AddUser = m.AddUser, Flag = m.Flag, Id = m.Id, Address = m.Address, Detail = m.Detail, IsDel = m.IsDel, Name = m.Name, Status = m.Status, Latitude = m.Latitude, Longitude = m.Longitude }) .FirstOrDefault(); if (viewModel == null) { throw new Exception("记录不存在"); } return(Success(viewModel)); }
public APIResult GetSingle([FromBody] IdArgsModel args) { var viewModel = db.Query <Shop>() .Where(m => m.Id == args.Id) .Select(m => new GetSingleModel() { AddIp = m.AddIp, AddTime = m.AddTime, AddUser = m.AddUser, Flag = m.Flag, Logo = m.Logo, Id = m.Id, Address = m.Address, AddressGuide = m.AddressGuide, Detail = m.Detail, IsDel = m.IsDel, Latitude = m.Latitude, Longitude = m.Longitude, Name = m.Name, OpenTime = m.OpenTime, ScoreValue = m.ScoreValue, Tel = m.Tel, UsePerUser = m.UsePerUser }) .FirstOrDefault(); if (viewModel == null) { throw new Exception("记录不存在"); } return(Success(viewModel)); }
public APIResult GetSingle([FromBody] IdArgsModel args) { var model = db.Query <ShopBrandCommodityParameter>() .Where(m => m.Id == args.Id) .Select(m => new GetSingleModel() { AddIp = m.AddIp, AddTime = m.AddTime, AddUser = m.AddUser, Id = m.Id, IsDel = m.IsDel, Name = m.Name, Flag = m.Flag, ShopBrandId = m.ShopBrandId }) .FirstOrDefault(); if (model == null) { throw new Exception("记录不存在"); } //在获取后检查是否拥有管理权限 CheckShopBrandActor(model.ShopBrandId, ShopBrandActorType.超级管理员); return(Success(model)); }
public APIResult InitShop([FromBody] IdArgsModel args) { CheckShopActor(args.Id, ShopActorType.超级管理员); var authorizerAccessToken = GetAuthorizerAccessToken(args.Id); try { var result = CodeApiExt.QRCodeJumpAddPublish(args.Id, authorizerAccessToken.authorizer_access_token, hostingEnvironment); AuthorizerHelper.CreateAndBindOpen(authorizerAccessToken.authorizer_appid); if (result.errcode == ReturnCode.请求成功) { return(Success("设置成功")); } else { return(Error(result.errmsg)); } } catch (Exception ex) { logger.LogInformation("初始化商店失败。错误路径:{0}", ex.StackTrace); return(Error(ex.Message)); } }
public APIResult GetShopOpenStatus([FromBody] IdArgsModel args) { var flag = ShopCallingQueue.GetShopOpenStatusFlag(args.Id); var v = db.GetSettingValue <bool>(flag); return(Success(v)); }
public APIResult SetIsDelete([FromBody] IdArgsModel args) { var model = db.GetSingle <ShopBrandCommodity>(args.Id); if (model == null) { throw new Exception("记录不存在"); } //在获取后检查是否拥有管理权限 CheckShopBrandActor(model.ShopBrandId, ShopBrandActorType.超级管理员); model.IsDel = true; var skus = db.Query <ShopBrandCommoditySku>() .Where(m => !m.IsDel) .Where(m => m.CommodityId == model.Id); var skuIds = skus.Select(m => m.Id); db.Query <ShopBrandCommoditySkuItem>() .Where(m => !m.IsDel) .Where(m => skuIds.Contains(m.SkuId)) .ToList() .ForEach(m => m.IsDel = true); skus.ToList().ForEach(m => m.IsDel = true); db.SaveChanges(); return(Success()); }
/// <summary> /// 获取套餐信息 /// </summary> /// <param name="args"></param> /// <returns></returns> public APIResult GetComboSingle([FromBody] IdArgsModel args) { ShopBrandCommodity combo = db.GetSingle <ShopBrandCommodity>(args.Id); if (combo == null || combo.CategoryId != 0) { throw new Exception("套餐记录不存在"); } CheckShopBrandActor(combo.ShopBrandId, ShopBrandActorType.超级管理员); GetComboSingleDto rtn = new GetComboSingleDto() { Unit = combo.Unit, Price = combo.Price, Name = combo.Name, Cover = combo.Cover, IsScanCode = combo.IsScanCode, IsSelfOrder = combo.IsSelfOrder, IsTakeout = combo.IsTakeout }; rtn.Items = db.Query <ShopOrderComboItem>() .Where(m => !m.IsDel && m.Pid == combo.Id) .Select(m => new ComboItem() { CommodityName = m.CommodityName, SalePrice = m.SalePrice, Count = m.Count, Sku = m.Sku }).ToList(); return(Success(rtn)); }
public APIResult GetSingle([FromBody] IdArgsModel args) { var viewModel = db.Query <ShopBrandCommodity>() .Where(m => m.Id == args.Id) .Select(m => new GetSingleModel() { AddIp = m.AddIp, AddTime = m.AddTime, AddUser = m.AddUser, Flag = m.Flag, Id = m.Id, Detail = m.Detail, IsDel = m.IsDel, Name = m.Name, Cover = m.Cover, IsRecommand = m.IsRecommand, Price = m.Price, SalesForMonth = m.SalesForMonth, ShopBrandId = m.ShopBrandId, Summary = m.Summary, Unit = m.Unit, Upvote = m.Upvote }) .FirstOrDefault(); if (viewModel == null) { throw new Exception("记录不存在"); } return(Success(viewModel)); }
public APIResult GetSingle([FromBody] IdArgsModel args) { //权限判定 CheckShopBrandActor(args.Id, ShopBrandActorType.超级管理员); var viewModel = db.Query <Shop>() .Where(m => m.Id == args.Id) .Select(m => new GetSingleModel() { AddIp = m.AddIp, AddTime = m.AddTime, AddUser = m.AddUser, Flag = m.Flag, Id = m.Id, Address = m.Address, Detail = m.Detail, IsDel = m.IsDel, Name = m.Name, Cover = m.Cover, Logo = m.Logo }) .FirstOrDefault(); if (viewModel == null) { throw new Exception("记录不存在"); } return(Success(viewModel)); }
public APIResult GetSingle([FromBody] IdArgsModel args) { var viewModel = db.Query <ShopBrandCommodityCategory>() .Where(m => m.Id == args.Id) .Select(m => new GetSingleModel() { Id = m.Id, Name = m.Name, OrderWeight = m.OrderWeight, Detail = m.Detail, PId = m.PId, Flag = m.Flag, Ico = m.Ico, Tags = m.Tags, Keywords = m.Keywords, Description = m.Description, ShopBrandId = m.ShopBrandId }) .FirstOrDefault(); if (viewModel == null) { throw new Exception("记录不存在"); } //在获取后检查是否拥有管理权限 CheckShopBrandActor(viewModel.ShopBrandId, ShopBrandActorType.超级管理员); return(Success(viewModel)); }
public APIResult SetCancel([FromBody] IdArgsModel args) { //这里注意,会涉及到退款操作 var memberId = GetMemberId(); var model = db.Query <ShopOrder>() .Where(m => !m.IsDel) .Where(m => m.MemberId == memberId) .Where(m => m.Id == args.Id) .FirstOrDefault(); if (model == null) { throw new Exception("指定纪录不存在"); } model.Status = ShopOrderStatus.已取消; //这里直接扣钱 //var memberAmount = db.GetMemberAmountList(memberId); //memberAmount.IncreaseAvailAmount(model.Amount, 0, $"订单{model.Flag}取消", $"订单编号:{model.Flag}", FinaceType.商品购买支出); //memberAmount.UpdateMemberAmountCache(); db.SaveChanges(); return(Success(model)); }
public APIResult SetIsDelete([FromBody] IdArgsModel args) { var model = db.Query <ShopBrandCommodityCategory>() .Where(m => m.Id == args.Id) .FirstOrDefault(); if (model == null) { throw new Exception("记录不存在"); } //在获取后检查是否拥有管理权限 CheckShopBrandActor(model.ShopBrandId, ShopBrandActorType.超级管理员); if (db.Query <ShopBrandCommodityCategory>().Where(m => m.PId == model.Id && !m.IsDel).Count() > 0) { throw new Exception("存在下级分类不能删除"); } if (db.Query <ShopBrandCommodity>().Where(m => m.CategoryId == model.Id && !m.IsDel).Count() > 0) { throw new Exception("存在商品不能删除"); } model.IsDel = true; db.SaveChanges(); return(Success()); }
public APIResult SetIsPay([FromBody] IdArgsModel args) { //这里注意,会涉及到退款操作 //var memberId = GetMemberId(); //var model = db.Query<ShopOrder>() // .Where(m => !m.IsDel) // .Where(m => m.MemberId == memberId) // .Where(m => m.Id == args.Id) // .FirstOrDefault(); //if (model == null) //{ // _logger.LogError("找不到订单,订单ID:{0},memberID:{1}", args.Id, memberId); // throw new Exception("指定纪录不存在"); //} ////if (model.PayTime.HasValue) throw new Exception("该订单已经支付"); ////取消余额 ////var memberAmount = db.GetMemberAmountList(memberId); ////var availAmount = memberAmount.GetAvailAmount(); ////if (availAmount < model.Amount) throw new Exception("余额不足"); //var shopName = db.Query<Shop>() // .Where(m => m.Id == model.ShopId) // .Select(m => m.Name) // .FirstOrDefault(); ////memberAmount.DecreaseAvailAmount(model.Amount, 0, $"{shopName}消费", Newtonsoft.Json.JsonConvert.SerializeObject(new { shopId = model.ShopId, orderFlag = model.Flag }), FinaceType.商品购买支出); ////memberAmount.UpdateMemberAmountCache(); //model.PayTime = DateTime.Now; //AfterOrderPlacing(model, shopName); ////获取订单中商品的数量 //var commodityIdAndCounts = db.Query<ShopOrderItem>() // .Where(m => m.ShopOrderId == model.Id) // .Where(m => !m.IsDel) // .Select(m => new // { // CommodityId = m.CommodityStock.Sku.CommodityId, // Count = m.Count // }) // .ToList() // .GroupBy(m => m.CommodityId) // .ToDictionary(m => m.Key, m => m.Select(x => x.Count).Sum()); ////更新商品的销售量 ////注意,这里如果有一个品牌,多个店铺的情况,会出现销售额共享的情况 //var commodityIds = commodityIdAndCounts.Select(m => m.Key).ToList(); //var commoditys = db.Query<ShopBrandCommodity>() // .Where(m => commodityIds.Contains(m.Id)) // .ToList(); //foreach (var item in commoditys) //{ // item.SalesForMonth += commodityIdAndCounts[item.Id]; //} //db.SaveChanges(); return(Success()); }
public APIResult QRCodeJumpAddPublish([FromBody] IdArgsModel args) { CheckShopActor(args.Id, ShopActorType.超级管理员); var authorizerAccessToken = GetAuthorizerAccessToken(args.Id); var result = CodeApiExt.QRCodeJumpAddPublish(args.Id, authorizerAccessToken.authorizer_access_token, hostingEnvironment); return(Success(result)); }
public APIResult DeleteId([FromBody] IdArgsModel args) { var viewModel = _db.Query <BannerConfiguration>().Where(m => m.Id == args.Id).FirstOrDefault(); if (viewModel == null) { throw new Exception("记录不存在"); } viewModel.IsDel = true; _db.SaveChanges(); return(Success()); }
public APIResult GetSingle([FromBody] IdArgsModel args) { var viewModel = _db.Query <BannerConfiguration>().Where(m => m.Id == args.Id).FirstOrDefault(); if (viewModel == null) { throw new Exception("记录不存在"); } var obj = _mapper.Map <BannerSetingAPIModels>(viewModel); return(Success(obj)); }
public APIResult DelShopOAuth([FromBody] IdArgsModel args) { var model = db.Set <ShopOrderReceiver>().Find(args.Id); if (model == null) { throw new Exception("该记录不存在"); } CheckShopActor(model.ShopId, ShopActorType.超级管理员); model.IsDel = true; db.SaveChanges(); return(Success()); }
public APIResult SetIsDelete([FromBody] IdArgsModel args) { var model = db.GetSingle <CommercialDistrict>(args.Id); if (model == null) { throw new Exception("记录不存在"); } model.IsDel = true; db.SaveChanges(); return(Success()); }
public APIResult SetIsDelete([FromBody] IdArgsModel args) { var model = db.GetSingle <ShopBrandCommodityParameter>(args.Id); if (model == null) { throw new Exception("记录不存在"); } model.IsDel = true; db.SaveChanges(); return(Success()); }
public APIResult SetIsDelete([FromBody] IdArgsModel args) { //TODO:这里还需要判定是否可以操作当前店铺 var model = db.GetSingle <ShopBooking>(args.Id); if (model == null) { throw new Exception("记录不存在"); } model.IsDel = true; db.SaveChanges(); return(Success()); }
public APIResult SetComboIsDelete([FromBody] IdArgsModel args) { //TODO:这里还需要判定是否可以操作当前店铺 var model = db.GetSingle <ShopBrandCombo>(args.Id); if (model == null) { throw new Exception("记录不存在"); } //获取到订单后判断是否拥有指定的店铺的权限 CheckShopBrandActor(model.ShopBrandId, ShopBrandActorType.超级管理员); model.IsDel = true; db.SaveChanges(); return(Success()); }
public APIResult SetIsDelete([FromBody] IdArgsModel args) { var model = printDb.Query <Data.Printer>() .Where(m => !m.IsDel) .Where(m => m.ID == args.Id) .FirstOrDefault(); if (model == null) { return(Error("该打印机不存在")); } model.IsDel = true; printDb.SaveChanges(); return(Success()); }
public APIResult GetSingle([FromBody] IdArgsModel args) { var memberId = GetMemberId(); var model = db.Query <ShopBooking>() .Where(m => !m.IsDel) .Where(m => m.MemberId == memberId) .Where(m => m.Id == args.Id) .FirstOrDefault(); if (model == null) { throw new Exception("指定纪录不存在"); } return(Success(model)); }
public APIResult SetIsDelete([FromBody] IdArgsModel args) { using (var db = dbFactory.Create(_communityService, args.CommunityFlag, args.AppFlag)) { var model = db.GetSingle <SettingBase>(args.Id); if (model == null) { throw new Exception("记录不存在"); } model.IsDel = true; db.SaveChanges(); return(Success()); } }
public APIResult SetIsDelete([FromBody] IdArgsModel args) { var model = db.GetSingle <ShopCallingQueueProduct>(args.Id); if (model == null) { throw new Exception("记录不存在"); } //获取到订单后判断是否拥有指定的店铺的权限 CheckShopActor(model.ShopId, ShopActorType.超级管理员); model.IsDel = true; db.SaveChanges(); return(Success()); }
public APIResult SetIsDelete([FromBody] IdArgsModel args) { var model = db.GetSingle <ShopCommodityStock>(args.Id); if (model == null) { throw new Exception("记录不存在"); } //获取纪录进行权限判定 CheckShopActor(model.ShopId, ShopActorType.超级管理员); model.IsDel = true; db.SaveChanges(); return(Success()); }
public APIResult SetCancel([FromBody] IdArgsModel args) { var memberId = GetMemberId(); var model = db.Query <ShopBooking>() .Where(m => !m.IsDel) .Where(m => m.MemberId == memberId) .Where(m => m.Id == args.Id) .FirstOrDefault(); if (model == null) { throw new Exception("指定纪录不存在"); } model.Status = ShopBookingStatus.取消; db.SaveChanges(); return(Success(model)); }
public APIResult GetQRCodeJumpUrl([FromBody] IdArgsModel args) { var model = db.Query <ShopPart>() .Where(m => !m.IsDel) .Where(m => m.Id == args.Id) .Select(m => new { ShopId = m.ShopId, ShopPartFlag = m.Flag }) .FirstOrDefault(); CheckShopActor(model.ShopId, ShopActorType.超级管理员); var host = _options.Host.Trim('/'); var url = $"{host}/qrcodeJump/{model.ShopId}/shopPart/{model.ShopPartFlag}"; return(Success(new { url = url })); }
public async Task <APIResult> GetShopCommodities([FromBody] IdArgsModel args) { if (args.Id == 0) { throw new Exception("ShopId不能为空"); } var res = await Task.Run(() => { Shop shop = db.GetSingle <Shop>(args.Id); if (shop == null) { throw new Exception("商铺记录不存在"); } ShopBrandCommodityServer server = new ShopBrandCommodityServer(db, shop, DiningWay.所有); CategoryAndCommodityModel rtn = server.GetCategoryAndCommodity(); return(rtn); }); return(Success(res)); }