|
|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace ghs\controllers;
|
|
|
|
|
|
+use biz\admin\classes\AdminRoleClass;
|
|
|
use biz\ghs\classes\GhsClass;
|
|
|
use biz\shop\classes\ShopAdminClass;
|
|
|
use biz\sj\classes\SjClass;
|
|
|
@@ -11,6 +12,7 @@ use bizHd\saas\classes\ApplyClass;
|
|
|
use bizHd\saas\services\ApplyService;
|
|
|
use bizHd\shop\classes\ShopClass;
|
|
|
use bizHd\stat\classes\StatVisitClass;
|
|
|
+use common\components\dict;
|
|
|
use common\components\imgUtil;
|
|
|
use common\components\stringUtil;
|
|
|
use common\components\util;
|
|
|
@@ -19,6 +21,57 @@ use Yii;
|
|
|
class CustomController extends BaseController
|
|
|
{
|
|
|
|
|
|
+ //帮客户添加员工 ssh 20220613
|
|
|
+ public function actionAddStaff()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $customId = $post['id'] ?? 0;
|
|
|
+ $mobile = $post['mobile'] ?? 0;
|
|
|
+ if (stringUtil::isMobile($mobile) == false) {
|
|
|
+ util::fail('手机号填写错误');
|
|
|
+ }
|
|
|
+ $info = CustomService::getById($customId, true);
|
|
|
+ CustomClass::valid($info, $this->shopId);
|
|
|
+
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ $shopId = $info->shopId ?? 0;
|
|
|
+ $customShop = ShopClass::getById($shopId, true);
|
|
|
+ if (empty($customShop)) {
|
|
|
+ util::fail('没有找到客户的门店');
|
|
|
+ }
|
|
|
+ $mainId = $customShop->mainId ?? 0;
|
|
|
+ $ptStyle = dict::getDict('ptStyle', 'hd');
|
|
|
+ $adminInfo = ['name' => $mobile, 'mobile' => $mobile, 'style' => $ptStyle, 'currentShopId' => $shopId];
|
|
|
+ $fromApp = dict::getDict('userSourceGetId', 'app', 'id');
|
|
|
+ $admin = \bizGhs\admin\classes\AdminClass::replaceAdmin($adminInfo, $fromApp);
|
|
|
+ $roleList = AdminRoleClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
|
|
|
+ if (empty($roleList)) {
|
|
|
+ util::fail('客户门店没有员工角色');
|
|
|
+ }
|
|
|
+ $currentRoleId = 0;
|
|
|
+ foreach ($roleList as $role) {
|
|
|
+ $roleId = $role->id ?? 0;
|
|
|
+ $currentRoleId = $roleId;
|
|
|
+ if ($role->roleName == '员工') {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $params = [
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'mobile' => $mobile,
|
|
|
+ 'roleId' => $currentRoleId,
|
|
|
+ ];
|
|
|
+ \bizHd\staff\classes\StaffClass::appGenerateStaff($params, $admin);
|
|
|
+ $transaction->commit();
|
|
|
+ util::complete('添加成功');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ util::fail('添加失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//添加新花店 ssh 2021.1.8
|
|
|
public function actionAdd()
|
|
|
{
|