|
|
@@ -2,8 +2,10 @@
|
|
|
|
|
|
namespace pt\controllers;
|
|
|
|
|
|
+use biz\admin\classes\AdminRoleClass;
|
|
|
use biz\shop\classes\ShopClass;
|
|
|
use bizHd\merchant\services\ShopService;
|
|
|
+use common\components\dict;
|
|
|
use common\components\stringUtil;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
@@ -11,6 +13,51 @@ use Yii;
|
|
|
class ShopController extends BaseController
|
|
|
{
|
|
|
|
|
|
+ //添加员工 ssh 2023429
|
|
|
+ public function actionAddStaff()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $mobile = $post['mobile'] ?? '';
|
|
|
+ $shopId = $post['shopId'] ?? 0;
|
|
|
+ $super = $post['super'] ?? 0;
|
|
|
+ $nickName = $post['nickName'] ?? '';
|
|
|
+ $nickName = empty($nickName) ? substr($mobile, 7, 4) : $nickName;
|
|
|
+ $shop = ShopClass::getById($shopId, true);
|
|
|
+ if (empty($shop)) {
|
|
|
+ util::fail('没有找到门店');
|
|
|
+ }
|
|
|
+ $ptStyle = $shop->ptStyle ?? 1;
|
|
|
+ if ($ptStyle != 2) {
|
|
|
+ util::fail('请在择批发店添加员工');
|
|
|
+ }
|
|
|
+
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+
|
|
|
+ $mainId = $shop->mainId ?? 0;
|
|
|
+ $adminInfo = ['name' => $nickName, 'mobile' => $mobile, 'style' => $ptStyle, 'currentGhsShopId' => $shopId];
|
|
|
+ $fromApp = dict::getDict('userSourceGetId', 'app', 'id');
|
|
|
+ $admin = \bizGhs\admin\classes\AdminClass::replaceAdmin($adminInfo, $fromApp);
|
|
|
+
|
|
|
+ $role = AdminRoleClass::getByCondition(['mainId' => $mainId], true);
|
|
|
+ if (empty($role)) {
|
|
|
+ util::fail('没有找到角色');
|
|
|
+ }
|
|
|
+ $roleId = $role->id ?? 0;
|
|
|
+
|
|
|
+ $addData = ['shopId' => $shopId, 'mobile' => $mobile, 'super' => $super, 'remind' => 1, 'roleId' => $roleId];
|
|
|
+ $respond = \bizGhs\shop\classes\ShopAdminClass::appGenerateStaff($addData, $admin);
|
|
|
+
|
|
|
+ $transaction->commit();
|
|
|
+ util::success($respond);
|
|
|
+ } catch (\Exception $exception) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::info("失败原因:" . $exception->getMessage());
|
|
|
+ util::fail('添加失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//调整仅采购功能,允许零售使用所有功能 ssh 20220919
|
|
|
public function actionChangeOnlyCg()
|
|
|
{
|