Exemplo n.º 1
0
        public APIResult SetShopSelfHelpInfo([FromBody] SetShopSelfHelpInfoArgsModel args)
        {
            if (!args.ShopId.HasValue)
            {
                throw new Exception("ShopID不能为空");
            }
            //权限判定
            CheckShopActor(args.ShopId.Value, ShopActorType.超级管理员);
            var model = db.Query <ShopSelfHelpInfo>()
                        .Where(m => !m.IsDel)
                        .Where(m => m.ShopId == args.ShopId)
                        .FirstOrDefault();

            if (model == null)
            {
                model = new ShopSelfHelpInfo()
                {
                    ShopId     = args.ShopId.Value,
                    BoxFee     = args.BoxFee,
                    HasTakeOut = args.HasTakeOut,
                };
                db.Add(model);
            }
            else
            {
                model.BoxFee     = args.BoxFee;
                model.HasTakeOut = args.HasTakeOut;
            }
            db.SaveChanges();
            return(Success());
        }
Exemplo n.º 2
0
        public APIResult GetShopSelfHelp([FromBody] ShopIdArgModel args)
        {
            if (!args.ShopId.HasValue)
            {
                throw new Exception("ShopID不能为空");
            }
            bool             isSelfHelp       = db.GetSingle <Shop>(args.ShopId.Value).IsSelfHelp;
            ShopSelfHelpInfo shopSelfHelpInfo = db.Query <ShopSelfHelpInfo>()
                                                .Where(m => m.ShopId == args.ShopId.Value)
                                                .FirstOrDefault();

            if (shopSelfHelpInfo == null)
            {
                shopSelfHelpInfo = new ShopSelfHelpInfo()
                {
                    HasBoxFee  = false,
                    BoxFee     = 0,
                    ShopId     = args.ShopId.Value,
                    HasTakeOut = true
                };
                db.Add(shopSelfHelpInfo);
                db.SaveChanges();
            }
            return(Success(new
            {
                isSelfHelp,
                shopSelfHelpInfo.HasBoxFee,
                shopSelfHelpInfo.BoxFee
            }));
        }
Exemplo n.º 3
0
        public APIResult SetShopSelfHelpBoxFee([FromBody] SetShopSelfHelpBoxFeeArgModel args)
        {
            if (!args.ShopId.HasValue)
            {
                throw new Exception("ShopID不能为空");
            }
            ShopSelfHelpInfo shopSelfHelpInfo = db.Query <ShopSelfHelpInfo>()
                                                .Where(m => m.ShopId == args.ShopId.Value)
                                                .FirstOrDefault();

            if (shopSelfHelpInfo == null)
            {
                throw new Exception("记录不存在");
            }
            shopSelfHelpInfo.BoxFee = args.BoxFee;
            db.SaveChanges();
            return(Success());
        }
Exemplo n.º 4
0
        //[Authorize(AuthenticationSchemes = "jwt")]
        public APIResult GetInfo([FromBody] GetSingleArgs args)
        {
            var shopModel = db.Query <Shop>()
                            .Where(m => m.Flag == args.Flag)
                            .Select(m => new GetSingleModel()
            {
                AddIp        = m.AddIp,
                AddTime      = m.AddTime,
                AddUser      = m.AddUser,
                Flag         = m.Flag,
                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,
                Cover        = m.Cover,
                IsSelfHelp   = m.IsSelfHelp,
                Logo         = m.Logo,
            })
                            .FirstOrDefault();


            if (shopModel == null)
            {
                throw new Exception("记录不存在");
            }


            shopModel.CurrentVersion = db.Query <ShopWechatOpenAuthorizer>()
                                       .Where(m => !m.IsDel)
                                       .Where(m => m.ShopId == shopModel.Id)
                                       .FirstOrDefault()?.CurrentTemplateUserVersion;

            if (shopModel.IsSelfHelp) //自助点餐
            {
                shopModel.DiningWay          = 0;
                shopModel.HasSelfHelpTakeout = true;  //当前默认都有外带
                ShopSelfHelpInfo selfHelpInfo = db.Query <ShopSelfHelpInfo>()
                                                .Where(m => !m.IsDel && m.ShopId == shopModel.Id)
                                                .FirstOrDefault();
                if (selfHelpInfo != null && selfHelpInfo.HasBoxFee)
                {
                    shopModel.SelfHelpBoxFee = selfHelpInfo.BoxFee;
                }
                //shopModel.HasSelfHelpTakeout = db.Query<ShopSelfHelpInfo>()
                //    .Where(m => !m.IsDel && m.ShopId == shopModel.Id)
                //    .FirstOrDefault()?
                //    .HasTakeOut ?? false;
            }
            else
            {
                shopModel.DiningWay = 1;
            }
            var shopMemberSet = db.Query <ShopMemberSet>()
                                .FirstOrDefault(m => !m.IsDel && m.ShopId == shopModel.Id);

            if (shopMemberSet == null)
            {
                shopModel.IsTopUpDiscount = false;
            }
            else
            {
                shopModel.IsTopUpDiscount = shopMemberSet.IsTopUpDiscount;
            }

            var viewModel = new GetInfoModel()
            {
                ShopInfo    = shopModel,
                BannerModel = Utils.ExBannerModels.GetBannerList(db, args.Flag)
            };

            viewModel.TakeOutInfo = db.Query <ShopTakeOutInfo>()
                                    .Where(m => !m.IsDel && m.ShopId == shopModel.Id)
                                    .Select(m => new TakeOutInfo()
            {
                IsUseTakeOut = m.IsUseTakeOut,
                BoxFee       = m.BoxFee / 100m,
                DeliveryFee  = m.DeliveryFee / 100m,
                IsOpen       = m.IsOpen,
                MinAmount    = m.MinAmount / 100m,
                StartTime    = m.StartTime == null ? " " : m.StartTime.Value.ToString("HH:mm"),
                EndTime      = m.EndTime == null ? " " : m.EndTime.Value.ToString("HH:mm")
            })
                                    .FirstOrDefault();

            if (shopModel.Latitude.HasValue && shopModel.Longitude.HasValue)
            {
                var TxCoordinate = BaiduMapUtil.CoverCoordinateToTX(shopModel.Latitude.Value, shopModel.Longitude.Value);
                shopModel.Latitude  = TxCoordinate.lati;
                shopModel.Longitude = TxCoordinate.logi;
            }

            //shopMember信息
            //try
            //{
            //    var memberId = GetMemberId();
            //    viewModel.ShopMember = db.Query<ShopMember>()
            //        .Where(m => !m.IsDel && m.MemberId == memberId && m.ShopId == shopModel.Id)
            //        .FirstOrDefault();
            //}
            //catch (Exception)
            //{

            //}

            return(Success(viewModel));
        }