|
|
@@ -4,11 +4,15 @@ namespace hd\controllers;
|
|
|
|
|
|
use biz\admin\classes\AdminClass;
|
|
|
use biz\shop\classes\ShopClass;
|
|
|
+use bizGhs\admin\services\AdminService;
|
|
|
use bizGhs\shop\classes\ShopAdminClass;
|
|
|
use bizHd\admin\services\AdminRoleService;
|
|
|
use bizHd\admin\services\ShopAdminService;
|
|
|
use bizHd\wx\services\WxOpenService;
|
|
|
+use common\components\dict;
|
|
|
use common\components\imgUtil;
|
|
|
+use common\components\sms;
|
|
|
+use common\components\stringUtil;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
|
|
|
@@ -17,6 +21,55 @@ class ShopAdminController extends BaseController
|
|
|
|
|
|
public $guestAccess = ['generate-admin'];
|
|
|
|
|
|
+ //获取添加员工的验证码 shish 20210117
|
|
|
+ public function actionGetStaffAuthCode()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $mobile = $get['mobile'] ?? '';
|
|
|
+ if (stringUtil::isMobile($mobile) == false) {
|
|
|
+ util::fail('请输入正确手机号');
|
|
|
+ }
|
|
|
+ $rand = rand(11111, 99999);
|
|
|
+ $minute = 10;
|
|
|
+ sms::send($mobile . ',' . $rand . ',' . $minute, '您的员工验证码:{$var},{$var}分钟内有效');
|
|
|
+ $ptStyle = Yii::$app->params['ptStyle'];
|
|
|
+ $cacheKey = 'add_staff_auth_code_' . $ptStyle . '_' . $mobile;
|
|
|
+ Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 600, $rand]);
|
|
|
+ util::complete();
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加员工
|
|
|
+ public function actionAddStaff()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $authCode = $post['authCode'] ?? '';
|
|
|
+ $mobile = $post['mobile'] ?? '';
|
|
|
+ $name = $post['name'] ?? '';
|
|
|
+
|
|
|
+ //避免重复提交
|
|
|
+ util::checkRepeatCommit($mobile, 10);
|
|
|
+
|
|
|
+ $ptStyle = Yii::$app->params['ptStyle'];
|
|
|
+
|
|
|
+ $cacheKey = 'add_staff_auth_code_' . $ptStyle . '_' . $mobile;
|
|
|
+ $saveAuthCode = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
|
|
|
+ if (empty($saveAuthCode)) {
|
|
|
+ util::fail('请填写验证码哦');
|
|
|
+ }
|
|
|
+ if (empty($authCode)) {
|
|
|
+ util::fail('请填写验证码');
|
|
|
+ }
|
|
|
+ if ($saveAuthCode != $authCode) {
|
|
|
+ util::fail('验证码错误');
|
|
|
+ }
|
|
|
+ $adminInfo = ['name' => $name, 'mobile' => $mobile, 'style' => $ptStyle,];
|
|
|
+ $fromApp = dict::getDict('userSourceGetId', 'app', 'id');
|
|
|
+ $admin = AdminService::replaceAdmin($adminInfo, $fromApp);
|
|
|
+ $post['shopId'] = $this->shopId;
|
|
|
+ $respond = \bizGhs\shop\services\ShopAdminService::appGenerateStaff($post, $admin);
|
|
|
+ util::success($respond);
|
|
|
+ }
|
|
|
+
|
|
|
//创建管理员数据准备 ssh 2020.4.17
|
|
|
public function actionPrepareBind()
|
|
|
{
|