|
|
@ -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) |
|
|
|