Example #1
0
        public Product GetProduct(string productCodeOrBarCode)
        {
            // 查找区域价格,门店价格,优先级按照 门店价 > 区域价 > 基础售价
            // var model = _db.Products.FirstOrDefault(n => n.Code == productCodeOrBarCode || n.BarCode == productCodeOrBarCode);
            string sql   = "select * from Product where Code=@ProductCodeOrBarCode Or BarCode=@ProductCodeOrBarCode";
            var    model = _query.First <Product>(sql, new { ProductCodeOrBarCode = productCodeOrBarCode });

            if (model == null)
            {
                return(null);
            }
            //区域价
            string sqlArea     = "select * from ProductAreaPrice where ProductId=@ProductId";
            var    areaProduct = _query.First <Product>(sqlArea, new { ProductId = model.Id });

            if (areaProduct != null)
            {
                model.SalePrice = areaProduct.SalePrice;
            }
            //门店价
            var sqlStore     = "select * from ProductStorePrice where ProductId=@ProductId";
            var storeProduct = _query.First <Product>(sqlStore, new { ProductId = model.Id });

            if (storeProduct != null)
            {
                model.SalePrice = storeProduct.SalePrice;
            }
            return(model);
        }
Example #2
0
        public Account Login(string userName, string passwrod)
        {
            if (userName == "")
            {
                throw new AppException("用户名为空");
            }
            if (passwrod == "")
            {
                throw new AppException("密码为空");
            }
            int userId = 0;

            int.TryParse(userName, out userId);
            // var model = _db.Accounts.FirstOrDefault(n => n.Id == userId || n.UserName == userName);
            var model = _query.First <Account>("select * from Account where Id=@Id or UserName=@UserName", new { Id = userId, UserName = userName });

            if (model == null || !model.VerifyPassword(passwrod))
            {
                throw new AppException("用户名或密码错误");
            }
            if (model.Status != 1)
            {
                throw new AppException("该账号已被禁用");
            }
            return(model);
        }
Example #3
0
        /// <summary>
        /// 查询当班记录
        /// </summary>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public WorkSchedule GetWorking(int storeId, int posId)
        {
            // return _db.WorkSchedules.Where(n => n.StoreId == storeId && n.EndBy == 0 && n.PosId == posId).FirstOrDefault();
            string sql = "select * from WorkSchedule where StoreId = @StoreId and EndBy = 0 and PosId = @PosId order by Id desc";

            return(_query.First <WorkSchedule>(sql, new { StoreId = storeId, PosId = posId }));
        }
Example #4
0
        public VipCard GetByCode(string code)
        {
            string sql = "select * from VipCard where Code=@Code";

            return(_query.First <VipCard>(sql, new { Code = code }));
            // return  _db.VipCards.FirstOrDefault<VipCard>(n => n.Code == code);
        }
Example #5
0
        public VipProduct GetByProductId(int id)
        {
            string sql = "select * from VipProduct where ProductId= @ProductId";

            return(_query.First <VipProduct>(sql, new { ProductId = id }));
        }