| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace app\common\model;
- class CustomerModel extends BaseModel
- {
- protected $table = 'erp_customer';
- // public function getSexAttr($value) {
- // return ['', '男', '女', '未知'][$value];
- // }
- public function doesItExist($mobile) {
- $customer = $this->where([
- ["mobile", '=',$mobile],
- ["is_delete", '=', 0],
- ])->find();
- return $customer ? true : false;
- }
- protected function genSchema(array $schema)
- {
- // TODO: Implement genSchema() method.
- }
- /**
- * @param array $params
- * @return \think\Paginator
- * @throws \think\db\exception\DbException
- */
- public function findByPaginate(array $params) {
- $where = [
- ['is_delete', '=', 0]
- ];
- if(isset($params['name_zh']))
- array_push($where,['name_zh', 'like', "%".$params['name_zh']."%"]);
- if(isset($params['name_en']))
- array_push($where,['name_en', 'like', "%".$params['name_en']."%"]);
- if(isset($params['mobile']))
- array_push($where,['mobile', 'like', "%".$params['mobile']."%"]);
- return $this->where($where)->order('create_time','desc')->paginate(['list_rows'=>10, "query" => $params]);
- }
- public function findByName($name) {
- return $this->where([
- ['is_delete','=', 0],
- ['name_zh|name_en', '=', $name]
- ])->find();
- }
- public function findByMobile($mobile) {
- return $this->where([
- ['is_delete','=', 0],
- ['mobile', '=', $mobile]
- ])->find();
- }
- }
|