|
|
@@ -1280,21 +1280,52 @@ class User extends BaseController
|
|
1280
|
1280
|
* 修改个人信息*/
|
|
1281
|
1281
|
public function updateUser()
|
|
1282
|
1282
|
{
|
|
|
1283
|
+ $uid = $this->request->uid();
|
|
1283
|
1284
|
$data['nickname'] = $this->request->param('nickname', null);
|
|
1284
|
1285
|
$data['avatar'] = $this->request->param('avatar', null);
|
|
1285
|
1286
|
$data['sex'] = $this->request->param('sex', null);
|
|
1286
|
1287
|
$data['birthday'] = $this->request->param('birthday', null);
|
|
1287
|
1288
|
$data['addres'] = $this->request->param('addres', null);
|
|
1288
|
1289
|
$data['mark'] = $this->request->param('mark', null);
|
|
|
1290
|
+ // 新加更换用户手机号逻辑,更换手机号时需验证 当前使用手机号收到的验证码,以确认本人操作
|
|
|
1291
|
+ // 需求描述说:更换用户手机号时,同步更新 商户申请表、商户表、商户管理员表
|
|
1289
|
1292
|
$data['phone'] = $this->request->param('phone', null);
|
|
1290
|
|
- // $data['phone'] = $this->request->param('phone', null);
|
|
|
1293
|
+ $sms_code = $this->request->param('sms_code', null);
|
|
|
1294
|
+ if (!empty($data['phone'])) {
|
|
|
1295
|
+ $changeUserData = $this->repository->getOne(['phone' => $data['phone']]);
|
|
|
1296
|
+ if (!empty($changeUserData)) {
|
|
|
1297
|
+ return app("json")->fail("该手机号已被用户绑定");
|
|
|
1298
|
+ }
|
|
|
1299
|
+ if (empty($sms_code)) {
|
|
|
1300
|
+ return app("json")->fail("请输入验证码");
|
|
|
1301
|
+ }
|
|
|
1302
|
+ $userData = $this->repository->get($uid)->toArray();
|
|
|
1303
|
+ if (!$this->checkSmsCode($userData['phone'], $sms_code)) {
|
|
|
1304
|
+ return app('json')->fail('验证码不正确');
|
|
|
1305
|
+ }
|
|
|
1306
|
+ // 商户申请表
|
|
|
1307
|
+ Db::name("merchant_intention")
|
|
|
1308
|
+ ->where('uid', $uid)
|
|
|
1309
|
+ ->where('phone', $userData['phone'])
|
|
|
1310
|
+ ->update(['phone' => $data['phone']]);
|
|
|
1311
|
+ // 商户表
|
|
|
1312
|
+ Db::name("merchant")
|
|
|
1313
|
+ ->where('uid', $uid)
|
|
|
1314
|
+ ->where('mer_phone', $userData['phone'])
|
|
|
1315
|
+ ->update(['mer_phone' => $data['phone']]);
|
|
|
1316
|
+
|
|
|
1317
|
+ // 商户管理员表
|
|
|
1318
|
+ Db::name("merchant_admin")
|
|
|
1319
|
+ ->where('uid', $uid)
|
|
|
1320
|
+ ->where('account', $userData['phone'])
|
|
|
1321
|
+ ->update(['account' => $data['phone']]);
|
|
|
1322
|
+ }
|
|
1291
|
1323
|
if (!empty($data['phone'])) {
|
|
1292
|
1324
|
$data['account'] = $data['phone'];
|
|
1293
|
1325
|
}
|
|
1294
|
1326
|
$data = array_filter($data, function($value) {
|
|
1295
|
1327
|
return $value !== null;
|
|
1296
|
1328
|
});
|
|
1297
|
|
- $uid = $this->request->uid();
|
|
1298
|
1329
|
$res = '';
|
|
1299
|
1330
|
if ($this->source == 'yhc') {
|
|
1300
|
1331
|
$res = Db::name('enterprise_user')->where('mer_id', $this->merId)->where('uid', $uid)->update(['avatar' => $data['avatar']]);
|