Browse Source

秋念修改

dev
李可松 4 years ago
parent
commit
e6ef17358f
  1. 6
      app/Request/v3/UserUpdateRequest.php
  2. 31
      app/Service/v3/Implementations/UserInfoService.php

6
app/Request/v3/UserUpdateRequest.php

@ -15,9 +15,9 @@ class UserUpdateRequest extends BaseFormRequest
public function rules(): array public function rules(): array
{ {
return [ return [
'user_id' => 'required|nonempty',
'userId' => 'required|nonempty',
'iv' => 'required|nonempty', 'iv' => 'required|nonempty',
'encrypted_data' => 'required|nonempty'
'encryptedData' => 'required|nonempty'
]; ];
} }
@ -35,4 +35,4 @@ class UserUpdateRequest extends BaseFormRequest
{ {
return parent::attributes(); return parent::attributes();
} }
}
}

31
app/Service/v3/Implementations/UserInfoService.php

@ -16,24 +16,30 @@ use EasyWeChat\Kernel\Exceptions\DecryptException;
use Hyperf\Guzzle\CoroutineHandler; use Hyperf\Guzzle\CoroutineHandler;
use Hyperf\Utils\ApplicationContext; use Hyperf\Utils\ApplicationContext;
class UserInfoService implements UserInfoServiceInterface
class UserInfoService
{ {
/** /**
* 更新 * 更新
* @param $userId
* @param $iv
* @param $encryptedData
* @param $data
* @return array * @return array
* @throws DecryptException * @throws DecryptException
*/ */
public function do($userId, $iv, $encryptedData)
public function do($data)
{ {
try { try {
$userId = $data['userId'];
$iv = $data['iv'];
$encryptedData = $data['encryptedData'];
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
$user = $ssdb->exec('hgetall', SsdbKeys::USER_INFO.$userId); $user = $ssdb->exec('hgetall', SsdbKeys::USER_INFO.$userId);
if(empty($user)) {
return ['找不到缓存的用户信息'];
}
// 微信登录 // 微信登录
$config = config('applet'); $config = config('applet');
$app = Factory::miniProgram($config); $app = Factory::miniProgram($config);
@ -43,8 +49,8 @@ class UserInfoService implements UserInfoServiceInterface
$data = [ $data = [
'nick_name' => $decryptedData['nickName'], 'nick_name' => $decryptedData['nickName'],
'avatar' => $decryptedData['avatarUrl'], 'avatar' => $decryptedData['avatarUrl'],
'openid' => $decryptedData['openId'],
'unionid' => $decryptedData['unionId'],
// 'openid' => $decryptedData['openId'],
// 'unionid' => $decryptedData['unionId'],
'country' => $decryptedData['country'], 'country' => $decryptedData['country'],
'province' => $decryptedData['province'], 'province' => $decryptedData['province'],
'city' => $decryptedData['city'], 'city' => $decryptedData['city'],
@ -83,10 +89,15 @@ class UserInfoService implements UserInfoServiceInterface
public function detail($userId) public function detail($userId)
{ {
return User::query()
$result = User::query()
->select(['id', 'nick_name', 'avatar', 'openid', 'unionid', 'total_score', 'real_name']) ->select(['id', 'nick_name', 'avatar', 'openid', 'unionid', 'total_score', 'real_name'])
->where(['status' => 1, 'id' => $userId]) ->where(['status' => 1, 'id' => $userId])
->first()->toArray();
->first();
if(!$result) {
return [];
}else{
return $result;
}
} }
public function getStoreByUID($userId) public function getStoreByUID($userId)

Loading…
Cancel
Save