setSalt(); $savePassword = $this->setPassword($password, $salt); $data = [ 'password' => $savePassword, 'salt' => $salt ]; $User = new WechatUser(); return $User->where('id', $id)->save($data); } public static function addUser( int $phone, string $email, string $pucode, string $tax_number, int $type ) { $query = WechatUser::where('phone', $phone)->find(); if (!$query) { $save = [ 'nickname' => '导入用户', 'phone' => $phone, 'email' => $email ]; $id = (new WechatUser())->insertGetId($save); if ($id) { $codeSave = [ 'wechat_user_id' => $id, 'pucode' => $pucode, 'create_time' => time() ]; (new WechatPucode())->save($codeSave); if ($codeSave) { $headSave = [ 'tax_number' => $tax_number, ]; $headQuery = InvoiceHead::where($headSave)->find(); if (!$headQuery) { $headSave['type'] = $type; $headSave['phone'] = $phone; $headSave['wechat_user_id'] = $id; $headSave['create_time'] = time(); (new InvoiceHead())->save($headSave); } } } return 1; } return 0; } public static function getTaxUser($tax_id) { $where = [ 'tax_number' => $tax_id ]; $user_ids = InvoiceHead::where($where)->column('wechat_user_id'); if ($user_ids) { return WechatPucode::whereIn('wechat_user_id', $user_ids)->column('pucode'); } } }