public ApiMessage <List <StoreGood> > GetGoods(BaseParm parm) { var page = new ApiMessage <List <StoreGood> >(); var strSql = new StringBuilder(); strSql.Append(@"SELECT DISTINCT p.ID,p.Name,p.TypeID,p1.Url,p2.Price,p2.MemberPrice,p2.LimitNum,p2.UnitName,p2.UnitID,s.Amount ,s.OutAmount FROM product p LEFT JOIN(SELECT * FROM productimg n WHERE n.RowNO = 0) p1 ON p.ID = p1.ProductID LEFT JOIN productprice p2 ON p.ID = p2.ProductID INNER JOIN store s ON p.ID = s.ProductID AND p2.UnitID = s.UnitID LEFT JOIN producttype p3 ON p.TypeID = p3.ID WHERE p.IsActive = 1 AND s.Amount>0 "); if (!string.IsNullOrEmpty(parm.Name)) { strSql.Append(" And p.name like CONCAT('%',@name,'%')"); } if (parm.Type == "2") { if (parm.Code == "1") { strSql.Append(" ORDER BY p2.Price Desc"); } else { strSql.Append(" ORDER BY p2.Price "); } } else if (parm.Type == "1") { strSql.Append(" ORDER BY s.OutAmount desc"); } else { strSql.Append(" ORDER BY p3.OrderByNo, p3.CreateDate, p.OrderByNo "); } strSql.Append(" LIMIT @m,@n"); var list = _db.Fetch <StoreGood>(strSql.ToString(), new { name = parm.Name, m = (parm.page - 1) * parm.rows, n = parm.rows }); page.Data = list; return(page); }
public ApiMessage <userinfo> LoginOn(userinfo user) { var strSql = PetaPoco.Sql.Builder; strSql.Append("select * from userinfo f "); strSql.Where("f.UserCode=@0 and f.IsActive=1", user.UserCode); strSql.Where("f.PassWord=@0 ", user.PassWord); var loginUser = _db.Fetch <userinfo>(strSql).FirstOrDefault(); if (string.IsNullOrEmpty(loginUser?.ID)) { return(new ApiMessage <userinfo> { MsgCode = "400", Msg = "用户不存在或密码有误", Success = false }); } return(new ApiMessage <userinfo> { Data = loginUser }); }
public ApiMessage <staff> LoginOn(staff user) { var strSql = PetaPoco.Sql.Builder; strSql.Append("select f.* from staff f left join station s on s.ID=f.StationID "); strSql.Where("f.UserCode=@0 and f.IsActive=1", user.UserCode); strSql.Where("f.PassWord=@0 and s.IsActive=1", user.PassWord); var loginUser = _db.Fetch <staff>(strSql).FirstOrDefault(); if (string.IsNullOrEmpty(loginUser?.ID)) { return(new ApiMessage <staff> { MsgCode = "400", Msg = "用户不存在或密码有误", Success = false }); } return(new ApiMessage <staff> { Data = loginUser }); }