|
|
@@ -237,5 +237,79 @@ class UserController extends BaseController
|
|
|
UserService::updateById($userId, ['payPassword' => password_hash($password, PASSWORD_BCRYPT)]);
|
|
|
util::complete();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ //小程序用户完整信息 shish 2019.12.12
|
|
|
+ public function actionMiniFullInfo()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $iv = isset($post['iv']) ? $post['iv'] : '';
|
|
|
+ $encryptedData = isset($post['encryptedData']) ? $post['encryptedData'] : '';
|
|
|
+ print_r($this->merchant);
|
|
|
+ print_r($this->admin);
|
|
|
+ die;
|
|
|
+ $appId = $this->merchant['miniAppId'];
|
|
|
+ $merchantId = $this->merchantId;
|
|
|
+ $miniOpenId = $this->user['miniOpenId'];
|
|
|
+ if (empty($miniOpenId)) {
|
|
|
+ util::fail('mini_open_id empty');
|
|
|
+ }
|
|
|
+ $cacheKey = 'MALL_MINI_SESSION_KEY_' . $miniOpenId;
|
|
|
+ $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
|
|
|
+ $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
|
|
|
+ require_once($wxMiniSecret . '/wxBizDataCrypt.php');
|
|
|
+ $pc = new \WXBizDataCrypt($appId, $sessionKey);
|
|
|
+ $errCode = $pc->decryptData($encryptedData, $iv, $result);
|
|
|
+ if ($errCode != 0) {
|
|
|
+ Yii::info($result . ' ' . $errCode);
|
|
|
+ util::fail('获取用户信息失败');
|
|
|
+ }
|
|
|
+ Yii::info('小程序获取用户信息:' . $result);
|
|
|
+ $originalInfo = Json::decode($result);
|
|
|
+ $source = UserClass::$userSourceId['mini']['name'];
|
|
|
+ $user = UserService::replaceUser($originalInfo, $source, $merchantId);
|
|
|
+ $userId = $user['id'];
|
|
|
+ $userInfo = UserService::getUserInfo($userId);
|
|
|
+ util::success($userInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ //小程序用户手机号
|
|
|
+ public function actionMiniMobile()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $iv = $post['iv'];
|
|
|
+ $encryptedData = $post['encryptedData'];
|
|
|
+ print_r($this->merchant);
|
|
|
+ print_r($this->admin);
|
|
|
+ die;
|
|
|
+ $merchantId = $this->merchantId;
|
|
|
+ $merchant = $this->merchant;
|
|
|
+ $appId = $merchant['miniAppId'];
|
|
|
+ $miniOpenId = $this->user['miniOpenId'];
|
|
|
+ $user = $this->user;
|
|
|
+ if (!empty($user) && !empty($user['mobile'])) {
|
|
|
+ $userId = $user['id'];
|
|
|
+ UserAssetService::updateByUserId($userId, ['member' => 0]);
|
|
|
+ util::success(['mobile' => $user['mobile']]);
|
|
|
+ }
|
|
|
+ $cacheKey = 'MALL_MINI_SESSION_KEY_' . $miniOpenId;
|
|
|
+ $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
|
|
|
+ if (empty($sessionKey)) {
|
|
|
+ util::fail('sesstion key empty');
|
|
|
+ }
|
|
|
+ $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
|
|
|
+ require_once($wxMiniSecret . '/wxBizDataCrypt.php');
|
|
|
+
|
|
|
+ $pc = new \WXBizDataCrypt($appId, $sessionKey);
|
|
|
+ $errCode = $pc->decryptData($encryptedData, $iv, $result);
|
|
|
+ if ($errCode != 0) {
|
|
|
+ util::fail('解密失败');
|
|
|
+ }
|
|
|
+ $arr = Json::decode($result);
|
|
|
+ $mobile = isset($arr['purePhoneNumber']) ? $arr['purePhoneNumber'] : '';
|
|
|
+ $userId = $user['id'];
|
|
|
+
|
|
|
+ UserService::upgradeToMember($userId, $merchantId, ['mobile' => $mobile]);
|
|
|
+ util::success(['mobile' => $mobile]);
|
|
|
+ }
|
|
|
+
|
|
|
}
|