| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- namespace business\controllers;
- use biz\admin\services\AdminService;
- use biz\merchant\services\MerchantExtendService;
- use biz\user\services\UserAssetService;
- use biz\user\services\UserIntegralService;
- use biz\user\services\UserService;
- use common\services\xhMerchantExtendService;
- use Yii;
- use common\components\stringUtil;
- use common\components\util;
- class UserController extends BaseController
- {
-
- public $enableCsrfValidation = false;
-
- //客户列表 shish 2019.11.30
- public function actionGetList()
- {
- $get = Yii::$app->request->get();
- //组建where
- $type = isset($get['type']) ? $get['type'] : 0;
- $search = isset($get['search']) ? $get['search'] : '';
- $where = ['merchantId' => $this->merchantId];
- switch ($type) {
- case 1:
- //粉丝
- $where['subscribe'] = 1;
- break;
- case 2:
- //会员
- $where['isMember'] = 1;
- break;
- default:
- }
- if (!empty($search)) {
- if (stringUtil::isMobieNumber($search)) {
- $where['mobile'] = $search;
- } else {
- $where['userName'] = ['like', $search];
- }
- }
- $list = UserService::getUserList($where);
- util::success($list);
- }
-
- //获取客户基本和资产信息 shish 2019.11.30
- public function actionGetInfo()
- {
- $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 actionGetFullInfo()
- {
- $userId = Yii::$app->request->get('userId');
- $info = UserService::getFullUserInfo($userId);
- if (isset($info['merchantId']) == false || $this->merchantId != $info['merchantId']) {
- util::fail('没有权限');
- }
- util::success($info);
- }
-
- //添加客户,申请会员时会自动同步资产 shish 2019.11.30
- public function actionAdd()
- {
- $post = Yii::$app->request->post();
- if ($post['mobile'] != $post['confirmMobile']) {
- util::fail('二次输入手机号不一样');
- }
- $confirmPassword = isset($post['confirmPassword']) ? $post['confirmPassword'] : '';
- $verify = AdminService::verifyConfirmPassword($this->adminId, $confirmPassword);
- if ($verify == false) {
- util::fail('密码错误');
- }
- $mobile = $post['mobile'];
- $user = UserService::getByMobile($mobile);
- if (!empty($user)) {
- util::fail('手机号已使用,客户已存在');
- }
- $originalInfo = [];
- $merchantId = $this->merchantId;
- $originalInfo['merchantId'] = $merchantId;
- $originalInfo['mobile'] = $mobile;
- $originalInfo['realName'] = $post['realName'];
- $userSource = Yii::$app->dict->getValue('userSourceGetId', 'official');
- $source = $userSource['name'];
- $user = UserService::replaceUser($originalInfo, $source, $merchantId);
-
- //等级
- $memberLevel = isset($post['memberLevel']) ? $post['memberLevel'] : 0;
- $extend = MerchantExtendService::getByMerchantId($this->merchantId);
- $gradeList = xhMerchantExtendService::getGradeList($extend, 'desc');
- $growth = isset($gradeList[$memberLevel]['growth']) ? $gradeList[$memberLevel]['growth'] : 0;
- //余额成长值更新
- $userId = $user['id'];
- $balance = isset($post['balance']) && is_numeric($post['balance']) ? $post['balance'] : 0;
- $data = ['balance' => $balance,'growth'=>$growth];
- UserAssetService::updateByUserId($userId, $data);
- //会员升级
- UserIntegralService::increaseToUpgrade(0, $growth, 0, $userId, $merchantId, $extend);
- util::ok();
- }
-
- }
|