CustomerModel.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\common\model;
  3. class CustomerModel extends BaseModel
  4. {
  5. protected $table = 'erp_customer';
  6. // public function getSexAttr($value) {
  7. // return ['', '男', '女', '未知'][$value];
  8. // }
  9. public function doesItExist($mobile) {
  10. $customer = $this->where([
  11. ["mobile", '=',$mobile],
  12. ["is_delete", '=', 0],
  13. ])->find();
  14. return $customer ? true : false;
  15. }
  16. protected function genSchema(array $schema)
  17. {
  18. // TODO: Implement genSchema() method.
  19. }
  20. /**
  21. * @param array $params
  22. * @return \think\Paginator
  23. * @throws \think\db\exception\DbException
  24. */
  25. public function findByPaginate(array $params) {
  26. $where = [
  27. ['is_delete', '=', 0]
  28. ];
  29. if(isset($params['name_zh']))
  30. array_push($where,['name_zh', 'like', "%".$params['name_zh']."%"]);
  31. if(isset($params['name_en']))
  32. array_push($where,['name_en', 'like', "%".$params['name_en']."%"]);
  33. if(isset($params['mobile']))
  34. array_push($where,['mobile', 'like', "%".$params['mobile']."%"]);
  35. return $this->where($where)->order('create_time','desc')->paginate(['list_rows'=>10, "query" => $params]);
  36. }
  37. }