shish 5 år sedan
förälder
incheckning
442849b0e2

+ 1 - 2
app-ghs/controllers/OrderSendController.php

@@ -40,10 +40,9 @@ class OrderSendController extends BaseController
     {
         $post = Yii::$app->request->post();
         $id = isset($post['id']) ? $post['id'] : 0;
-        $option = isset($post['option']) ? $post['option'] : 0;
         $order = OrderService::getById($id);
         OrderService::valid($order, $this->shopId);
-        OrderSendService::reach($order, ['option' => $option]);
+        OrderSendService::reach($order);
     }
 
 }

+ 1 - 2
app-hd/controllers/OrderSendController.php

@@ -49,10 +49,9 @@ class OrderSendController extends BaseController
     {
         $post = Yii::$app->request->post();
         $id = isset($post['id']) ? $post['id'] : 0;
-        $option = isset($post['option']) ? $post['option'] : 0;
         $order = OrderService::getById($id);
         OrderService::valid($order, $this->shopId);
-        OrderSendService::reach($order, ['option' => $option]);
+        OrderSendService::reach($order);
     }
 
     //向快递公司发起配送需求

+ 109 - 62
app-hd/controllers/ShopAdminController.php

@@ -2,6 +2,8 @@
 
 namespace hd\controllers;
 
+use biz\admin\classes\AdminClass;
+use biz\shop\classes\ShopAdminClass;
 use bizHd\admin\services\AdminRoleService;
 use bizHd\admin\services\ShopAdminService;
 use bizHd\wx\services\WxOpenService;
@@ -16,67 +18,112 @@ class ShopAdminController extends BaseController
 
     public $guestAccess = ['generate-admin'];
 
-	//创建管理员数据准备 ssh 2020.4.17
-	public function actionPrepareBind()
-	{
-		$post = Yii::$app->request->post();
-		$roleId = isset($post['roleId']) ? $post['roleId'] : 0;
-		$role = AdminRoleService::getById($roleId);
-		if (empty($role) || isset($role['merchantId']) != $this->sjId) {
-			util::fail('请选择角色!');
-		}
-		unset($post['userId']);
-		unset($post['status']);
-		$post['shopId'] = $this->shopId;
-		$post['adminId'] = $this->adminId;
-		$merchant = WxOpenService::getWxInfo();
-		$post['merchant'] = $merchant;
-		$respond = ShopAdminService::prepareBindAdmin($post);
-		$miniCode = isset($respond['miniCode']) ? imgUtil::getPrefix() . $respond['miniCode'] : '';
-		util::success(['miniCode' => $miniCode]);
-	}
-	
-	//创建管理员 ssh 2020.4.20
-	public function actionGenerateAdmin()
-	{
-		$post = Yii::$app->request->post();
-		$respond = ShopAdminService::generateAdmin($post);
-		util::success($respond);
-	}
-	
-	//收款通知 ssh 2020.1.4
-	public function actionUpdateRemind()
-	{
-		$get = Yii::$app->request->get();
-		$id = isset($get['id']) ? $get['id'] : 0;
-		$remind = isset($get['remind']) && is_numeric($get['remind']) ? $get['remind'] : 0;
-		$shopAdmin = ShopAdminService::getById($id);
-		ShopAdminService::valid($shopAdmin, $this->shopId);
-		ShopAdminService::updateById($id, ['remind' => $remind]);
-		util::complete();
-	}
-	
-	//启用与停用 ssh 2020.1.4
-	public function actionUpdateStatus()
-	{
-		$get = Yii::$app->request->get();
-		$id = isset($get['id']) && is_numeric($get['id']) ? $get['id'] : 0;
-		$status = isset($get['status']) ? $get['status'] : 0;
-		$shopAdmin = ShopAdminService::getById($id);
-		ShopAdminService::valid($shopAdmin, $this->shopId);
-		ShopAdminService::updateById($id, ['status' => $status]);
-		util::complete();
-	}
+    //创建管理员数据准备 ssh 2020.4.17
+    public function actionPrepareBind()
+    {
+        $post = Yii::$app->request->post();
+        $roleId = isset($post['roleId']) ? $post['roleId'] : 0;
+        $role = AdminRoleService::getById($roleId);
+        if (empty($role) || isset($role['merchantId']) != $this->sjId) {
+            util::fail('请选择角色!');
+        }
+        unset($post['userId']);
+        unset($post['status']);
+        $post['shopId'] = $this->shopId;
+        $post['adminId'] = $this->adminId;
+        $merchant = WxOpenService::getWxInfo();
+        $post['merchant'] = $merchant;
+        $respond = ShopAdminService::prepareBindAdmin($post);
+        $miniCode = isset($respond['miniCode']) ? imgUtil::getPrefix() . $respond['miniCode'] : '';
+        util::success(['miniCode' => $miniCode]);
+    }
+
+    //创建管理员 ssh 2020.4.20
+    public function actionGenerateAdmin()
+    {
+        $post = Yii::$app->request->post();
+        $respond = ShopAdminService::generateAdmin($post);
+        util::success($respond);
+    }
+
+    //收款通知 ssh 2020.1.4
+    public function actionUpdateRemind()
+    {
+        $get = Yii::$app->request->get();
+        $id = isset($get['id']) ? $get['id'] : 0;
+        $remind = isset($get['remind']) && is_numeric($get['remind']) ? $get['remind'] : 0;
+        $shopAdmin = ShopAdminService::getById($id);
+        ShopAdminService::valid($shopAdmin, $this->shopId);
+        ShopAdminService::updateById($id, ['remind' => $remind]);
+        util::complete();
+    }
+
+    //启用与停用 ssh 2020.1.4
+    public function actionUpdateStatus()
+    {
+        $get = Yii::$app->request->get();
+        $id = isset($get['id']) && is_numeric($get['id']) ? $get['id'] : 0;
+        $status = isset($get['status']) ? $get['status'] : 0;
+        $shopAdmin = ShopAdminService::getById($id);
+        ShopAdminService::valid($shopAdmin, $this->shopId);
+        ShopAdminService::updateById($id, ['status' => $status]);
+        util::complete();
+    }
+
+    //员工列表 ssh 2019.12.8
+    public function actionList()
+    {
+        $where = [];
+        $where['shopId'] = $this->shopId;
+        $where['delStatus'] = 0;
+        $list = ShopAdminService::getAdminList($where);
+        util::success($list);
+    }
+
+    //获取员工信息 ssh 2021.1.13
+    public function actionDetail()
+    {
+        $get = Yii::$app->request->get();
+        $id = isset($get['id']) ? $get['id'] : 0;
+        $respond = ShopAdminClass::getAdminInfo($id);
+        ShopAdminClass::valid($respond, $this->shopId);
+        util::success($respond);
+    }
+
+    //修改员工信息
+    public function actionUpdate()
+    {
+        $post = Yii::$app->request->post();
+        $id = $post['id'] ?? 0;
+        if (empty($id)) {
+            util::fail('请选择员工');
+        }
+        $relation = ShopAdminClass::getById($id, true);
+        if (empty($relation)) {
+            util::fail('没有找到员工');
+        }
+        ShopAdminClass::valid($relation, $this->shopId);
+        unset($post['id']);
+        $roleId = $post['roleId'] ?? 0;
+        $remind = $post['remind'] ?? 0;
+        $status = $post['status'] ?? 1;
+        $relation->roleId = $roleId;
+        $relation->remind = $remind;
+        $relation->status = $status;
+        if (isset($post['name']) && !empty($post['name'])) {
+            $relation->name = $post['name'];
+        }
+        $relation->save();
+
+        //若有传密码,则修改密码
+        $password = $post['password'] ?? '';
+        if (!empty($password)) {
+            $adminId = $relation->adminId;
+            $password = password_hash($password, PASSWORD_BCRYPT);
+            AdminClass::updateById($adminId, ['password' => $password]);
+        }
+
+        util::complete('修改成功');
+    }
 
-	//员工列表 ssh 2019.12.8
-	public function actionList()
-	{
-		$get = Yii::$app->request->get();
-		$where = [];
-		$where['shopId'] = $this->shopId;
-		$where['delStatus'] = 0;
-		$list = ShopAdminService::getAdminList($where);
-		util::success($list);
-	}
-	
 }

+ 2 - 3
biz-ghs/order/services/OrderSendService.php

@@ -114,10 +114,9 @@ class OrderSendService extends BaseService
     }
 
     //送达 ssh 2019.12.17
-    public static function reach($order, $data)
+    public static function reach($order)
     {
-        $id = $order['id'];
-        $orderSn = $data['orderSn'];
+        $orderSn = $order['orderSn'];
         $actionRelation = OrderSendClass::ACTION_RELATION;
         $reachId = $actionRelation['reach'];
         $currentId = OrderSendClass::toDoActionId($orderSn);

+ 2 - 16
biz-hd/admin/services/ShopAdminService.php

@@ -11,6 +11,7 @@ use bizHd\merchant\classes\ShopClass;
 use biz\sj\services\MerchantService;
 use bizHd\user\services\UserService;
 use common\components\error;
+use common\components\imgUtil;
 use common\components\miniUtil;
 use common\components\stringUtil;
 use common\components\util;
@@ -97,23 +98,8 @@ class ShopAdminService extends BaseService
         if (empty($list)) {
             return $data;
         }
-
-        //管理员基础信息
-        $ids = array_column($list, 'adminId');
-        $adminInfo = AdminClass::getByIds($ids, null, 'id');
-        $adminBaseInfo = AdminClass::groupAdminBaseInfo($adminInfo, $sensitive);
-
-        $roleIds = array_column($list, 'roleId');
-        $roleIds = array_filter(array_unique($roleIds));
-        $roleList = AdminRoleClass::getByIds($roleIds, null, 'id');
-
         foreach ($list as $key => $val) {
-            $adminId = $val['adminId'];
-            $current = isset($adminBaseInfo[$adminId]) ? $adminBaseInfo[$adminId] : [];
-            $list[$key]['adminBaseInfo'] = $current;
-            $roleId = $val['roleId'];
-            $roleName = isset($roleList[$roleId]['roleName']) ? $roleList[$roleId]['roleName'] : '';
-            $list[$key]['roleName'] = $roleName;
+            $list[$key]['avatar'] = imgUtil::groupImg($val['avatar']);
         }
         $data['list'] = $list;
         return $data;

+ 8 - 7
biz-hd/order/classes/OrderSendClass.php

@@ -89,14 +89,15 @@ class OrderSendClass extends BaseClass
         $reachId = $actionIdList['reach'];
         OrderSendClass::updateByCondition(['orderId' => $id, 'actionId' => $reachId], ['option' => $option, 'finishTime' => $time]);
 
-        $userId = $order['userId'];
-        $user = UserClass::getById($userId);
-        $merchantId = $order['merchantId'];
-        $merchant = MerchantClass::getById($merchantId);
-        //完成通知客户
-        InformUserClass::sendComplete($user, $order, $merchant);
+//        $customId = $order['customId'];
+//        $customInfo = [];
+//        $merchantId = $order['merchantId'];
+//        $merchant = MerchantClass::getById($merchantId);
+//        //完成通知客户
+//        InformUserClass::sendComplete($customInfo, $order, $merchant);
+
         //完成通知管理员
-        InformAdminClass::sendComplete($order);
+        //InformAdminClass::sendComplete($order);
     }
 
 }

+ 2 - 2
biz-hd/order/services/OrderSendService.php

@@ -118,9 +118,9 @@ class OrderSendService extends BaseService
     }
 
     //送达 ssh 2019.12.17
-    public static function reach($order, $data)
+    public static function reach($order)
     {
-        $orderSn = $data['orderSn'];
+        $orderSn = $order['orderSn'] ?? '';
         $actionIdList = OrderSendClass::$actionId;
         $reachId = $actionIdList['reach'];
         $currentId = OrderSendClass::toDoActionId($orderSn);

+ 12 - 2
biz/shop/classes/ShopAdminClass.php

@@ -93,9 +93,9 @@ class ShopAdminClass extends BaseClass
         return $info;
     }
 
-    public static function valid($adminInfo, $merchantId)
+    public static function valid($adminInfo, $shopId)
     {
-        if (isset($adminInfo['merchantId']) && $adminInfo['merchantId'] == $merchantId) {
+        if (isset($adminInfo['shopId']) && $adminInfo['shopId'] == $shopId) {
             return true;
         }
         util::fail('此员工您没有权限操作');
@@ -138,4 +138,14 @@ class ShopAdminClass extends BaseClass
         }
     }
 
+    //获取基本信息 shish 2021.4.23
+    public static function getAdminInfo($id)
+    {
+        $relation = self::getById($id);
+        if (empty($relation)) {
+            util::fail('没有找到员工信息');
+        }
+        return $relation;
+    }
+
 }