Commit 3785d15bccb9f3f3f279b17579de4a05989bca26
1 parent
f3e7b9fa
revert: restore wx_unionid (database schema fix required)
Showing
1 changed file
with
6 additions
and
5 deletions
| ... | ... | @@ -274,24 +274,25 @@ class AuthService |
| 274 | 274 | if ($user) { |
| 275 | 275 | // 更新 openid |
| 276 | 276 | if ($openid && $user['wx_openid'] !== $openid) { |
| 277 | - $stmt = $this->pdo->prepare("UPDATE users SET wx_openid = ? WHERE id = ?"); | |
| 278 | - $stmt->execute([$openid, $user['id']]); | |
| 277 | + $stmt = $this->pdo->prepare("UPDATE users SET wx_openid = ?, wx_unionid = ? WHERE id = ?"); | |
| 278 | + $stmt->execute([$openid, $unionid, $user['id']]); | |
| 279 | 279 | } |
| 280 | 280 | return $user; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | // 创建新用户 |
| 284 | 284 | $stmt = $this->pdo->prepare(" |
| 285 | - INSERT INTO users (phone, wx_openid, nickname) | |
| 286 | - VALUES (?, ?, ?) | |
| 285 | + INSERT INTO users (phone, wx_openid, wx_unionid, nickname) | |
| 286 | + VALUES (?, ?, ?, ?) | |
| 287 | 287 | "); |
| 288 | 288 | $nickname = '用户' . substr($phone, -4); |
| 289 | - $stmt->execute([$phone, $openid, $nickname]); | |
| 289 | + $stmt->execute([$phone, $openid, $unionid, $nickname]); | |
| 290 | 290 | |
| 291 | 291 | return [ |
| 292 | 292 | 'id' => $this->pdo->lastInsertId(), |
| 293 | 293 | 'phone' => $phone, |
| 294 | 294 | 'wx_openid' => $openid, |
| 295 | + 'wx_unionid' => $unionid, | |
| 295 | 296 | 'nickname' => $nickname, |
| 296 | 297 | 'avatar_url' => null, |
| 297 | 298 | ]; | ... | ... |
Please
register
or
login
to post a comment