ProductModel.php 941 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\common\model;
  3. class ProductModel extends BaseModel
  4. {
  5. protected $table = 'erp_product';
  6. protected function genSchema(array $schema)
  7. {
  8. // TODO: Implement genSchema() method.
  9. }
  10. /**
  11. * @param array $params
  12. * @return \think\Paginator
  13. * @throws \think\db\exception\DbException
  14. */
  15. public function findByPaginate(array $params) {
  16. $where = [
  17. ['is_delete', '=', 0]
  18. ];
  19. if($params['bar_code'] != null)
  20. array_push($where,['bar_code', 'like', "%".$params['bar_code']."%"]);
  21. if($params['category_id'] != null)
  22. array_push($where,['category_id', '=', $params['category_id']]);
  23. if($params['is_serve'] != null)
  24. array_push($where,['is_serve', '=', $params['is_serve']]);
  25. return $this->where($where)->order('create_time','desc')->paginate(['list_rows'=>10, "query" => $params]);
  26. }
  27. }