|
|
@@ -4,11 +4,10 @@ namespace shop\controllers;
|
|
|
|
|
|
use biz\admin\services\AdminService;
|
|
|
use biz\merchant\services\MerchantAssetService;
|
|
|
-use biz\merchant\services\MerchantExtendService;
|
|
|
use biz\merchant\services\MerchantRemarkService;
|
|
|
+use biz\user\classes\UserClass;
|
|
|
use biz\user\services\UserAssetService;
|
|
|
use biz\user\services\UserGrowthService;
|
|
|
-use biz\user\services\UserIntegralService;
|
|
|
use biz\user\services\UserService;
|
|
|
use biz\user\services\UserUpgradeService;
|
|
|
use common\components\wxUtil;
|
|
|
@@ -19,224 +18,225 @@ use common\services\xhUserIntegralService;
|
|
|
use Yii;
|
|
|
use common\components\stringUtil;
|
|
|
use common\components\util;
|
|
|
+use yii\helpers\Json;
|
|
|
|
|
|
class UserController extends BaseController
|
|
|
{
|
|
|
-
|
|
|
- //客户列表 shish 2019.11.30
|
|
|
- public function actionList()
|
|
|
- {
|
|
|
- $get = Yii::$app->request->get();
|
|
|
- //组建where
|
|
|
- $type = isset($get['type']) ? $get['type'] : -1;
|
|
|
- $search = isset($get['search']) ? $get['search'] : '';
|
|
|
- $where = ['merchantId' => $this->merchantId];
|
|
|
- switch ($type) {
|
|
|
- case 1:
|
|
|
- //粉丝
|
|
|
- $where['subscribe'] = 1;
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- //会员
|
|
|
- $where['member>'] = -1;
|
|
|
- break;
|
|
|
- default:
|
|
|
- }
|
|
|
- if (!empty($search)) {
|
|
|
- if (stringUtil::isMobile($search)) {
|
|
|
- $where['mobile'] = $search;
|
|
|
- } else {
|
|
|
- $where['userName'] = ['like', $search];
|
|
|
- }
|
|
|
- }
|
|
|
- $list = UserService::getUserList($where);
|
|
|
- $list['asset'] = MerchantAssetService::getByMerchantId($this->merchantId);
|
|
|
- util::success($list);
|
|
|
- }
|
|
|
-
|
|
|
- //获取客户基本和资产信息 shish 2019.11.30
|
|
|
- public function actionDetail()
|
|
|
- {
|
|
|
- $userId = Yii::$app->request->get('userId');
|
|
|
- $info = UserService::getUserInfo($userId);
|
|
|
- if (isset($info['merchantId']) == false || $this->merchantId != $info['merchantId']) {
|
|
|
- util::fail('没有权限');
|
|
|
- }
|
|
|
- util::success($info);
|
|
|
- }
|
|
|
-
|
|
|
- //获取客户详情,包括基本信息、资产、订单和备注 2019.11.30
|
|
|
- public function actionUserDetail()
|
|
|
- {
|
|
|
- $userId = Yii::$app->request->get('userId');
|
|
|
- $info = UserService::getFullUserInfo($userId);
|
|
|
- UserService::valid($info, $this->merchantId);
|
|
|
-
|
|
|
- $list = MerchantRemarkService::getRemarkList($userId);
|
|
|
- $info['remarkList'] = $list;
|
|
|
- util::success($info);
|
|
|
- }
|
|
|
-
|
|
|
- //添加客户,申请会员时会自动同步资产 shish 2019.11.30
|
|
|
- public function actionAdd()
|
|
|
- {
|
|
|
- $post = Yii::$app->request->post();
|
|
|
- if (isset($post['mobile']) == false || stringUtil::isMobile($post['mobile']) == false) {
|
|
|
- util::fail('请输入手机号');
|
|
|
- }
|
|
|
- if ($post['mobile'] != $post['confirmMobile']) {
|
|
|
- util::fail('二次输入手机号不一样');
|
|
|
- }
|
|
|
-
|
|
|
- $confirmPassword = isset($post['confirmPassword']) ? $post['confirmPassword'] : '';
|
|
|
- AdminService::verifyConfirmPassword($this->adminId, $confirmPassword);
|
|
|
-
|
|
|
- $mobile = $post['mobile'];
|
|
|
- $user = UserService::getByMobile($mobile, $this->merchantId);
|
|
|
- if (!empty($user)) {
|
|
|
- util::fail('手机号已使用,客户已存在');
|
|
|
- }
|
|
|
-
|
|
|
- $post['merchantId'] = $this->merchantId;
|
|
|
- $post['member'] = $post['memberLevel'];
|
|
|
- UserService::addUser($post);
|
|
|
-
|
|
|
- util::complete();
|
|
|
- }
|
|
|
-
|
|
|
- //充值 shish 2019.12.1
|
|
|
- public function actionRecharge()
|
|
|
- {
|
|
|
- $post = Yii::$app->request->post();
|
|
|
- $confirmPassword = isset($post['confirmPassword']) ? $post['confirmPassword'] : '';
|
|
|
- AdminService::verifyConfirmPassword($this->adminId, $confirmPassword);
|
|
|
-
|
|
|
- $userId = isset($post['userId']) ? $post['userId'] : 0;
|
|
|
- $rechargeAmount = isset($post['rechargeAmount']) ? $post['rechargeAmount'] : 1;
|
|
|
- $user = UserService::getById($userId);
|
|
|
- if (empty($user)) {
|
|
|
- util::fail('找不到客户');
|
|
|
- }
|
|
|
- if ($user['merchantId'] != $this->merchantId) {
|
|
|
- util::fail('您没有权限操作');
|
|
|
- }
|
|
|
- $userAsset = UserAssetService::getByUserId($userId);
|
|
|
- $totalBalance = $userAsset['balance'] + $rechargeAmount;
|
|
|
- $totalRecharge = $userAsset['totalRecharge'] + $rechargeAmount;
|
|
|
- $upData['balance'] = $totalBalance;
|
|
|
- $upData['totalRecharge'] = $totalRecharge;
|
|
|
- $merchantAsset = MerchantAssetService::getByMerchantId($this->merchantId);
|
|
|
- $return = xhRechargeService::recharge($rechargeAmount, $user, $this->adminId, $this->merchant, $this->merchantExtend, $merchantAsset);
|
|
|
- if ($return['code'] == 'A0001') {
|
|
|
- util::complete();
|
|
|
- }
|
|
|
- util::fail();
|
|
|
- }
|
|
|
-
|
|
|
- //升级 shish 2019.12.1
|
|
|
- public function actionUpgrade()
|
|
|
- {
|
|
|
- $post = Yii::$app->request->post();
|
|
|
- $userId = isset($post['userId']) ? $post['userId'] : 0;
|
|
|
- $member = isset($post['member']) ? $post['member'] : 0;
|
|
|
- $user = UserService::getById($userId);
|
|
|
- if (empty($user)) {
|
|
|
- util::fail('客户不存在');
|
|
|
- }
|
|
|
- //验证是否商家客户
|
|
|
- UserService::valid($user, $this->merchantId);
|
|
|
- //验证确认密码
|
|
|
- $confirmPassword = $post['confirmPassword'];
|
|
|
- AdminService::verifyConfirmPassword($this->adminId, $confirmPassword);
|
|
|
-
|
|
|
- $grade = xhMerchantExtendService::getGradeList($this->merchantExtend, 'desc');
|
|
|
- //升级后的成长值
|
|
|
- $newLevelGrowth = $grade[$member]['growth'];
|
|
|
- $newDiscount = $grade[$member]['discount'];
|
|
|
- $userAsset = UserAssetService::getByUserId($userId);
|
|
|
- if ($userAsset['member'] >= $member) {
|
|
|
- util::fail('客户已经达到此级别了');
|
|
|
- }
|
|
|
-
|
|
|
- $now = time();
|
|
|
- $date = date("Y-m-d H:i", $now);
|
|
|
-
|
|
|
- $connection = Yii::$app->db;//事务处理
|
|
|
- $transaction = $connection->beginTransaction();
|
|
|
- try {
|
|
|
-
|
|
|
- $addGrowth = $newLevelGrowth - $userAsset['growth'];
|
|
|
- $upData['growth'] = $newLevelGrowth;
|
|
|
- $upData['member'] = $member;
|
|
|
- $upData['discount'] = $newDiscount;
|
|
|
- UserAssetService::updateByUserId($userId, $upData);
|
|
|
- UserService::updateById($userId, ['member' => $member]);
|
|
|
-
|
|
|
- $upgradeData = [
|
|
|
- 'member' => $member,
|
|
|
- 'prevMember' => $userAsset['member'],
|
|
|
- 'merchantId' => $this->merchantId,
|
|
|
- 'gainType' => 0,
|
|
|
- 'addTime' => $now,
|
|
|
- 'userId' => $userId,
|
|
|
- ];
|
|
|
- $upgradeRespond = UserUpgradeService::add($upgradeData);
|
|
|
-
|
|
|
- $growthData = [
|
|
|
- 'userId' => $userId,
|
|
|
- 'userName' => $user['userName'],
|
|
|
- 'merchantId' => $this->merchantId,
|
|
|
- 'relateId' => $upgradeRespond['id'],
|
|
|
- 'growth' => $newLevelGrowth,
|
|
|
- 'num' => $addGrowth,
|
|
|
- 'io' => 1,
|
|
|
- 'payWay' => 4,
|
|
|
- 'alipayId' => '',
|
|
|
- 'event' => '管理员操作升到' . $member . '级增加成长值',
|
|
|
- 'operatorId' => $userId,
|
|
|
- 'createTime' => $date,
|
|
|
- 'gainType' => 0,
|
|
|
- 'addTime' => $now,
|
|
|
- ];
|
|
|
- UserGrowthService::add($growthData);
|
|
|
- $transaction->commit();
|
|
|
- } catch (Exception $e) {
|
|
|
- $transaction->rollBack();
|
|
|
- util::fail();
|
|
|
- }
|
|
|
- $allTM = xhTMessageService::getList($this->merchantId);
|
|
|
- $openId = isset($user['openId']) ? $user['openId'] : '';
|
|
|
- if (empty($openId)) {
|
|
|
- util::complete();
|
|
|
- }
|
|
|
- $shortTempId = 'OPENTM205211943';//升级通知
|
|
|
- if (isset($allTM[$shortTempId]) == false) {
|
|
|
- util::complete();
|
|
|
- }
|
|
|
- $tempId = $allTM[$shortTempId];
|
|
|
- $data = [
|
|
|
- "touser" => $openId, "template_id" => $tempId, "url" => '',
|
|
|
- "data" => [
|
|
|
- "first" => ["value" => "恭喜,您已经升为{$member}级会员。", "color" => "#173177"],
|
|
|
- "keyword1" => ["value" => $user['userName'], "color" => "#173177"],
|
|
|
- "keyword2" => ["value" => $date, "color" => "#173177"],
|
|
|
- "remark" => ["value" => "点击查看会员权益", "color" => "#173177"],
|
|
|
- ]];
|
|
|
- wxUtil::sendTaskInform($data, $this->merchant);
|
|
|
- util::complete();
|
|
|
- }
|
|
|
-
|
|
|
- //重置客户密码
|
|
|
- public function actionResetPayPassword()
|
|
|
- {
|
|
|
- $post = Yii::$app->request->post();
|
|
|
- $userId = isset($post['userId']) ? $post['userId'] : 0;
|
|
|
- $password = isset($post['password']) ? $post['password'] : 0;
|
|
|
- $info = UserService::getById($userId);
|
|
|
- UserService::valid($info, $this->merchantId);
|
|
|
- UserService::updateById($userId, ['payPassword' => password_hash($password, PASSWORD_BCRYPT)]);
|
|
|
- util::complete();
|
|
|
- }
|
|
|
+
|
|
|
+ //客户列表 shish 2019.11.30
|
|
|
+ public function actionList()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ //组建where
|
|
|
+ $type = isset($get['type']) ? $get['type'] : -1;
|
|
|
+ $search = isset($get['search']) ? $get['search'] : '';
|
|
|
+ $where = ['merchantId' => $this->merchantId];
|
|
|
+ switch ($type) {
|
|
|
+ case 1:
|
|
|
+ //粉丝
|
|
|
+ $where['subscribe'] = 1;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ //会员
|
|
|
+ $where['member>'] = -1;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ }
|
|
|
+ if (!empty($search)) {
|
|
|
+ if (stringUtil::isMobile($search)) {
|
|
|
+ $where['mobile'] = $search;
|
|
|
+ } else {
|
|
|
+ $where['userName'] = ['like', $search];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $list = UserService::getUserList($where);
|
|
|
+ $list['asset'] = MerchantAssetService::getByMerchantId($this->merchantId);
|
|
|
+ util::success($list);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取客户基本和资产信息 shish 2019.11.30
|
|
|
+ public function actionDetail()
|
|
|
+ {
|
|
|
+ $userId = Yii::$app->request->get('userId');
|
|
|
+ $info = UserService::getUserInfo($userId);
|
|
|
+ if (isset($info['merchantId']) == false || $this->merchantId != $info['merchantId']) {
|
|
|
+ util::fail('没有权限');
|
|
|
+ }
|
|
|
+ util::success($info);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取客户详情,包括基本信息、资产、订单和备注 2019.11.30
|
|
|
+ public function actionUserDetail()
|
|
|
+ {
|
|
|
+ $userId = Yii::$app->request->get('userId');
|
|
|
+ $info = UserService::getFullUserInfo($userId);
|
|
|
+ UserService::valid($info, $this->merchantId);
|
|
|
+
|
|
|
+ $list = MerchantRemarkService::getRemarkList($userId);
|
|
|
+ $info['remarkList'] = $list;
|
|
|
+ util::success($info);
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加客户,申请会员时会自动同步资产 shish 2019.11.30
|
|
|
+ public function actionAdd()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ if (isset($post['mobile']) == false || stringUtil::isMobile($post['mobile']) == false) {
|
|
|
+ util::fail('请输入手机号');
|
|
|
+ }
|
|
|
+ if ($post['mobile'] != $post['confirmMobile']) {
|
|
|
+ util::fail('二次输入手机号不一样');
|
|
|
+ }
|
|
|
+
|
|
|
+ $confirmPassword = isset($post['confirmPassword']) ? $post['confirmPassword'] : '';
|
|
|
+ AdminService::verifyConfirmPassword($this->adminId, $confirmPassword);
|
|
|
+
|
|
|
+ $mobile = $post['mobile'];
|
|
|
+ $user = UserService::getByMobile($mobile, $this->merchantId);
|
|
|
+ if (!empty($user)) {
|
|
|
+ util::fail('手机号已使用,客户已存在');
|
|
|
+ }
|
|
|
+
|
|
|
+ $post['merchantId'] = $this->merchantId;
|
|
|
+ $post['member'] = $post['memberLevel'];
|
|
|
+ UserService::addUser($post);
|
|
|
+
|
|
|
+ util::complete();
|
|
|
+ }
|
|
|
+
|
|
|
+ //充值 shish 2019.12.1
|
|
|
+ public function actionRecharge()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $confirmPassword = isset($post['confirmPassword']) ? $post['confirmPassword'] : '';
|
|
|
+ AdminService::verifyConfirmPassword($this->adminId, $confirmPassword);
|
|
|
+
|
|
|
+ $userId = isset($post['userId']) ? $post['userId'] : 0;
|
|
|
+ $rechargeAmount = isset($post['rechargeAmount']) ? $post['rechargeAmount'] : 1;
|
|
|
+ $user = UserService::getById($userId);
|
|
|
+ if (empty($user)) {
|
|
|
+ util::fail('找不到客户');
|
|
|
+ }
|
|
|
+ if ($user['merchantId'] != $this->merchantId) {
|
|
|
+ util::fail('您没有权限操作');
|
|
|
+ }
|
|
|
+ $userAsset = UserAssetService::getByUserId($userId);
|
|
|
+ $totalBalance = $userAsset['balance'] + $rechargeAmount;
|
|
|
+ $totalRecharge = $userAsset['totalRecharge'] + $rechargeAmount;
|
|
|
+ $upData['balance'] = $totalBalance;
|
|
|
+ $upData['totalRecharge'] = $totalRecharge;
|
|
|
+ $merchantAsset = MerchantAssetService::getByMerchantId($this->merchantId);
|
|
|
+ $return = xhRechargeService::recharge($rechargeAmount, $user, $this->adminId, $this->merchant, $this->merchantExtend, $merchantAsset);
|
|
|
+ if ($return['code'] == 'A0001') {
|
|
|
+ util::complete();
|
|
|
+ }
|
|
|
+ util::fail();
|
|
|
+ }
|
|
|
+
|
|
|
+ //升级 shish 2019.12.1
|
|
|
+ public function actionUpgrade()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $userId = isset($post['userId']) ? $post['userId'] : 0;
|
|
|
+ $member = isset($post['member']) ? $post['member'] : 0;
|
|
|
+ $user = UserService::getById($userId);
|
|
|
+ if (empty($user)) {
|
|
|
+ util::fail('客户不存在');
|
|
|
+ }
|
|
|
+ //验证是否商家客户
|
|
|
+ UserService::valid($user, $this->merchantId);
|
|
|
+ //验证确认密码
|
|
|
+ $confirmPassword = $post['confirmPassword'];
|
|
|
+ AdminService::verifyConfirmPassword($this->adminId, $confirmPassword);
|
|
|
+
|
|
|
+ $grade = xhMerchantExtendService::getGradeList($this->merchantExtend, 'desc');
|
|
|
+ //升级后的成长值
|
|
|
+ $newLevelGrowth = $grade[$member]['growth'];
|
|
|
+ $newDiscount = $grade[$member]['discount'];
|
|
|
+ $userAsset = UserAssetService::getByUserId($userId);
|
|
|
+ if ($userAsset['member'] >= $member) {
|
|
|
+ util::fail('客户已经达到此级别了');
|
|
|
+ }
|
|
|
+
|
|
|
+ $now = time();
|
|
|
+ $date = date("Y-m-d H:i", $now);
|
|
|
+
|
|
|
+ $connection = Yii::$app->db;//事务处理
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+
|
|
|
+ $addGrowth = $newLevelGrowth - $userAsset['growth'];
|
|
|
+ $upData['growth'] = $newLevelGrowth;
|
|
|
+ $upData['member'] = $member;
|
|
|
+ $upData['discount'] = $newDiscount;
|
|
|
+ UserAssetService::updateByUserId($userId, $upData);
|
|
|
+ UserService::updateById($userId, ['member' => $member]);
|
|
|
+
|
|
|
+ $upgradeData = [
|
|
|
+ 'member' => $member,
|
|
|
+ 'prevMember' => $userAsset['member'],
|
|
|
+ 'merchantId' => $this->merchantId,
|
|
|
+ 'gainType' => 0,
|
|
|
+ 'addTime' => $now,
|
|
|
+ 'userId' => $userId,
|
|
|
+ ];
|
|
|
+ $upgradeRespond = UserUpgradeService::add($upgradeData);
|
|
|
+
|
|
|
+ $growthData = [
|
|
|
+ 'userId' => $userId,
|
|
|
+ 'userName' => $user['userName'],
|
|
|
+ 'merchantId' => $this->merchantId,
|
|
|
+ 'relateId' => $upgradeRespond['id'],
|
|
|
+ 'growth' => $newLevelGrowth,
|
|
|
+ 'num' => $addGrowth,
|
|
|
+ 'io' => 1,
|
|
|
+ 'payWay' => 4,
|
|
|
+ 'alipayId' => '',
|
|
|
+ 'event' => '管理员操作升到' . $member . '级增加成长值',
|
|
|
+ 'operatorId' => $userId,
|
|
|
+ 'createTime' => $date,
|
|
|
+ 'gainType' => 0,
|
|
|
+ 'addTime' => $now,
|
|
|
+ ];
|
|
|
+ UserGrowthService::add($growthData);
|
|
|
+ $transaction->commit();
|
|
|
+ } catch (Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ util::fail();
|
|
|
+ }
|
|
|
+ $allTM = xhTMessageService::getList($this->merchantId);
|
|
|
+ $openId = isset($user['openId']) ? $user['openId'] : '';
|
|
|
+ if (empty($openId)) {
|
|
|
+ util::complete();
|
|
|
+ }
|
|
|
+ $shortTempId = 'OPENTM205211943';//升级通知
|
|
|
+ if (isset($allTM[$shortTempId]) == false) {
|
|
|
+ util::complete();
|
|
|
+ }
|
|
|
+ $tempId = $allTM[$shortTempId];
|
|
|
+ $data = [
|
|
|
+ "touser" => $openId, "template_id" => $tempId, "url" => '',
|
|
|
+ "data" => [
|
|
|
+ "first" => ["value" => "恭喜,您已经升为{$member}级会员。", "color" => "#173177"],
|
|
|
+ "keyword1" => ["value" => $user['userName'], "color" => "#173177"],
|
|
|
+ "keyword2" => ["value" => $date, "color" => "#173177"],
|
|
|
+ "remark" => ["value" => "点击查看会员权益", "color" => "#173177"],
|
|
|
+ ]];
|
|
|
+ wxUtil::sendTaskInform($data, $this->merchant);
|
|
|
+ util::complete();
|
|
|
+ }
|
|
|
+
|
|
|
+ //重置客户密码
|
|
|
+ public function actionResetPayPassword()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $userId = isset($post['userId']) ? $post['userId'] : 0;
|
|
|
+ $password = isset($post['password']) ? $post['password'] : 0;
|
|
|
+ $info = UserService::getById($userId);
|
|
|
+ UserService::valid($info, $this->merchantId);
|
|
|
+ UserService::updateById($userId, ['payPassword' => password_hash($password, PASSWORD_BCRYPT)]);
|
|
|
+ util::complete();
|
|
|
+ }
|
|
|
|
|
|
//小程序用户完整信息 shish 2019.12.12
|
|
|
public function actionMiniFullInfo()
|
|
|
@@ -244,16 +244,14 @@ class UserController extends BaseController
|
|
|
$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'];
|
|
|
+ $merchant = $this->openMerchant;
|
|
|
+ $appId = $merchant['miniAppId'];
|
|
|
+ $admin = $this->admin;
|
|
|
+ $miniOpenId = $admin['miniOpenId'];
|
|
|
if (empty($miniOpenId)) {
|
|
|
util::fail('mini_open_id empty');
|
|
|
}
|
|
|
- $cacheKey = 'MALL_MINI_SESSION_KEY_' . $miniOpenId;
|
|
|
+ $cacheKey = 'SHOP_MINI_SESSION_KEY_' . $miniOpenId;
|
|
|
$sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
|
|
|
$wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
|
|
|
require_once($wxMiniSecret . '/wxBizDataCrypt.php');
|
|
|
@@ -266,10 +264,10 @@ class UserController extends BaseController
|
|
|
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);
|
|
|
+ $admin = AdminService::replaceAdmin($originalInfo, $source);
|
|
|
+ $adminId = $admin['id'];
|
|
|
+ $admin = AdminService::getAdminById($adminId);
|
|
|
+ util::success($admin);
|
|
|
}
|
|
|
|
|
|
//小程序用户手机号
|
|
|
@@ -278,20 +276,12 @@ class UserController extends BaseController
|
|
|
$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;
|
|
|
+ $merchant = $this->openMerchant;
|
|
|
$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;
|
|
|
+ $admin = $this->admin;
|
|
|
+ $miniOpenId = $admin['miniOpenId'];
|
|
|
+
|
|
|
+ $cacheKey = 'SHOP_MINI_SESSION_KEY_' . $miniOpenId;
|
|
|
$sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
|
|
|
if (empty($sessionKey)) {
|
|
|
util::fail('sesstion key empty');
|
|
|
@@ -306,9 +296,6 @@ class UserController extends BaseController
|
|
|
}
|
|
|
$arr = Json::decode($result);
|
|
|
$mobile = isset($arr['purePhoneNumber']) ? $arr['purePhoneNumber'] : '';
|
|
|
- $userId = $user['id'];
|
|
|
-
|
|
|
- UserService::upgradeToMember($userId, $merchantId, ['mobile' => $mobile]);
|
|
|
util::success(['mobile' => $mobile]);
|
|
|
}
|
|
|
|