ProductService.php 1014 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\service;
  3. use app\model\Product;
  4. use think\Model;
  5. class ProductService
  6. {
  7. public static function getProductList($page, $qydm): array
  8. {
  9. $map[]=["qydm","=",$qydm];
  10. $res["row"] = (new Product)->where($map)->page($page["page"],$page["size"])->select();
  11. $res["count"] = (new Product)->where($map)->count();
  12. return $res;
  13. }
  14. public static function getProductInfoById($id)
  15. {
  16. return Product::find($id);
  17. }
  18. public static function addProduct($info):bool
  19. {
  20. return (new Product)->save($info);
  21. }
  22. public static function editProduct($info,$id): Product
  23. {
  24. return Product::update($info,["id"=>$id]);
  25. }
  26. public static function delProduct($id): bool
  27. {
  28. return Product::destroy($id);
  29. }
  30. public static function getProductListIsPch($qydm){
  31. return Product::where("t_product.qydm",$qydm)->field("t_product.*")->join("t_product_batch p","t_product.id=p.product_id")->select();
  32. }
  33. }