ProductBatchService.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace app\service;
  3. use app\model\Product;
  4. use app\model\ProductBatch;
  5. use app\model\Enterprises;
  6. use app\model\Base;
  7. use think\Model;
  8. class ProductBatchService
  9. {
  10. public static function getProductBatchList($page, $qydm): array
  11. {
  12. $map[]=["t_product_batch.qydm","=",$qydm];
  13. $res["row"] = (new ProductBatch)
  14. ->where($map)
  15. ->field("t_product_batch.*,t_product.product_name, t_product.product_class_id, t_enterprises.enterprises_name,
  16. t_enterprises.fzr_phone, t_enterprises.enterprises_address")
  17. ->page($page["page"],$page["size"])
  18. ->leftJoin("t_product","t_product_batch.product_id=t_product.id")
  19. ->leftJoin("t_enterprises","t_enterprises.qydm=t_product_batch.qydm")
  20. ->select();
  21. $res["count"] = (new ProductBatch)->where($map)->count();
  22. return $res;
  23. }
  24. public static function getProductBatchAll($qydm)
  25. {
  26. $map[]=["t_product_batch.qydm","=",$qydm];
  27. $res = (new ProductBatch)
  28. ->where($map)
  29. ->field("t_product_batch.batch_id,t_product.product_name")
  30. ->leftJoin("t_product","t_product_batch.product_id=t_product.id")
  31. ->select();
  32. return $res;
  33. }
  34. public static function getProductBatchInfoById($id)
  35. {
  36. return ProductBatch::find($id);
  37. }
  38. public static function addProductBatch($info):bool
  39. {
  40. return (new ProductBatch)->save($info);
  41. }
  42. public static function editProductBatch($info,$id): ProductBatch
  43. {
  44. return ProductBatch::update($info,["id"=>$id]);
  45. }
  46. public static function delProductBatch($id): bool
  47. {
  48. return ProductBatch::destroy($id);
  49. }
  50. public static function findEnterprisesBaseInfo($qydm)
  51. {
  52. $map[] = ["qydm","=",$qydm];
  53. return Enterprises::field('qydm, enterprises_name, fzr_phone')
  54. ->where($map)
  55. ->find();
  56. }
  57. public static function selectProductBaseInfo($qydm)
  58. {
  59. $map[] = ["qydm","=",$qydm];
  60. return Product::field('id, product_name, product_class_id')
  61. ->where($map)
  62. ->select();
  63. }
  64. public static function selectChandiBaseInfo($qydm)
  65. {
  66. $map[] = ["qydm","=",$qydm];
  67. return Base::field('id, city, county, towns, village')
  68. ->where($map)
  69. ->select();
  70. }
  71. public static function getPchByProId($id){
  72. return ProductBatch::where("product_id",$id)->select();
  73. }
  74. }