Procházet zdrojové kódy

fix():修改配置

geek před 4 roky
rodič
revize
7388050a50

+ 1 - 0
application/api/controller/Order.php

@@ -270,6 +270,7 @@ class Order extends BaseController {
             $rs = $model::where(['mobile' => $input['mobile']])->find();
             if (empty($rs)) {
                 $id = $model->insertGetId([
+                    'name' => '',
                     'real_name' => $input['name'],
                     'avatar'    => '',
                     'mobile'    => $input['mobile'],

+ 19 - 3
application/api/controller/Staff.php

@@ -8,6 +8,7 @@ namespace app\api\controller;
 
 
 use app\api\BaseController;
+use app\api\exception\ApiException;
 use app\api\model\BrandModel;
 use app\api\model\GroupModel;
 use app\api\model\StaffModel;
@@ -37,14 +38,17 @@ class Staff extends BaseController {
         $model = new StaffModel();
         $model->setPage($input['page'] ?? 1);
         $model->setPageSize($input['pageSize'] ?? 10);
+        $where = [];
         if ($this->isAdmin()) {
-            $where = [];
+            if (!empty($input['status'])) {
+                $where[] = ['s.status', '=', $input['status']];
+            }
         } else {
             $where[] = ['s.status', '=', $model::NORMAL];
         }
 
         if (!empty($input['name'])) {
-            $where[] = ['s.staff_name', 'like', "%{$input['name']}%"];
+            $where[] = ['s.staff_name|s.staff_code', 'like', "%{$input['name']}%"];
         }
 
         if (!empty($input['mobile'])) {
@@ -58,7 +62,11 @@ class Staff extends BaseController {
 
         if (!empty($input['groupId'])) {
             $arr =  explode(',',$input['groupId']);
-            $where[] = ['s.group_id', 'in', $arr];
+            $where[] = ['sto.group_id', 'in', $arr];
+        }
+
+        if ($this->isAdmin()) {
+            $where[] = ['gr.admin_id','=',$this->adminId];
         }
         $model->setWhere($where);
         $data = $model->getStaffList();
@@ -100,6 +108,10 @@ class Staff extends BaseController {
         Until::check($rule, $input);
         $model = new StaffModel();
         if (!empty($input['id'])) {
+            $rs = $model::where([['code','=',$input['code'],['id','<>',$input['id']]]])->find();
+            if (!empty($rs)) {
+                throw new ApiException('工号不可重复');
+            }
             $id = (int)$input['id'];
             $model::where(['id' => $id])->update([
                 'staff_name'     => $input['name'],
@@ -111,6 +123,10 @@ class Staff extends BaseController {
                 'status'         => $input['status'] ?? $model::NORMAL
             ]);
         } else {
+            $rs = $model::where([['code','=',$input['code']]])->find();
+            if (!empty($rs)) {
+                throw new ApiException('工号不可重复');
+            }
             $id = $model->insertGetId([
                 'staff_name'     => $input['name'],
                 'staff_code'     => $input['code'],

+ 1 - 1
application/api/exception/ExceptionHandel.php

@@ -37,7 +37,7 @@ class ExceptionHandel extends Handle {
 
         if ($e instanceof Exception || $e instanceof Error) {
             Until::output([],
-                $e->getMessage(),
+                $e->getMessage().' file:' . $e->getFile() . ' line:' . $e->getLine() ,
                 Enum::THROW_ERR_CODE,
                 $e->getTraceAsString()
             );

+ 3 - 1
application/api/model/CompanyModel.php

@@ -18,7 +18,9 @@ class CompanyModel  extends BaseModel {
             $joinType = 'INNER';
         }
         $countModel = $this->alias('c')
-            ->join('group g', 'g.id = c.group_id');
+            ->join('group g', 'g.id = c.group_id')
+            ->join('group_role gr','g.id = gr.group_id and gr.admin_id = '.Until::$adminId,$joinType)
+        ;
 
         $selectModel = $this->alias('c')
             ->field('c.*,g.group_name,p.pay_code')

+ 12 - 3
application/api/model/StaffModel.php

@@ -13,15 +13,24 @@ class StaffModel  extends BaseModel {
     protected $table = 'staff';
 
     public function getStaffList() {
+
+        $joinType = 'left';
+        if (!empty(Until::$adminId)) {
+            $joinType = 'INNER';
+        }
         $countModel = $this->alias('s')
             ->join('store sto','sto.id = s.store_id')
-            ->join('staff_title st','st.id = s.staff_title_id','left');
+            ->join('group g','g.id = sto.group_id')
+            ->join('staff_title st','st.id = s.staff_title_id','left')
+            ->join('group_role gr','g.id = gr.group_id and gr.admin_id = '.Until::$adminId,$joinType);
+
 
         $selectModel = $this->alias('s')
-            ->field('s.*,sto.store_name,st.staff_title,sto.groupId,g.group_name')
+            ->field('s.*,sto.store_name,st.staff_title,sto.group_id,g.group_name')
             ->join('store sto','sto.id = s.store_id')
+            ->join('group g','g.id = sto.group_id')
+            ->join('group_role gr','g.id = gr.group_id and gr.admin_id = '.Until::$adminId,$joinType)
             ->join('staff_title st','st.id = s.staff_title_id','left')
-            ->join('group g','g.id = sto.group_id','left')
             ->order(['s.id' => 'desc']);
         return $this->joinModelPageList($countModel, $selectModel);
     }

+ 2 - 3
application/common/service/OrderService.php

@@ -43,10 +43,9 @@ class OrderService {
         }
         $model = new OrderModel();
         try {
-            $userId = Until::$userId ?: $input['userId'];
+            $userId = empty($input['userId']) ? Until::$userId : $input['userId'];
             $orderType = 1;
             if (Until::$isAdmin) {
-                $userId = 0;
                 $orderType = 2;
             }
             $model->startTrans();
@@ -64,7 +63,7 @@ class OrderService {
                 'status'           => 1,
                 'order_type'       => $orderType,
                 'user_id'          => $userId,
-                'admin_id'         => Until::$isAdmin
+                'admin_id'         => Until::$adminId
             ]);
             $opModel = new OrderProductModel();
             $opModel->insert([

+ 1 - 1
application/common/until/Token.php

@@ -28,7 +28,7 @@ class Token {
         $payload = [
             "iat"     => time(),
             "exp"     => time() + (3600 * 24 * 7),
-            "userId"  => $isAdmin ? 1 : $userId,
+            "userId"  => $isAdmin ? 0 : $userId,
             "visitor" => $visitor,
             'isAdmin' => $isAdmin ? 1 : 0,
             'adminId' => $isAdmin ? $userId : 0,