| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?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.
- }
- //for ($i = 2; $i< 10; $i++) {
- //$this->saveAll([
- //[
- //'name' => '佩佩'.$i,
- //'mobile' => '1557692025'.$i,
- //'sex'=> 1,
- //'sun_calendar' => '2020-'.$i.'-11',
- //'lunar_calendar' => '2020-'.($i-1).'-19',
- //'user_id' => 100000,
- //'username' => 'Caviar.',
- //'relation' => '朋友'.$i,
- //'address' => '巴西'.$i,
- //'email' => $i.'@163.com',
- //'store_id' => 1,
- //'linkman' => 'A_Caviar'
- //]
- //]);
- //}
- /**
- * @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]);
- }
- }
|