Quellcode durchsuchen

fix():修改配置

geek vor 4 Jahren
Ursprung
Commit
4abec29d15

+ 4 - 3
application/api/controller/Admin.php

@@ -74,10 +74,10 @@ class Admin extends BaseController {
      *           @OA\Property(description="手机号", property="mobile", type="string", default="12367897654"),
      *           @OA\Property(description="角色id-单选", property="roleId", type="integer", default="1"),
      *           @OA\Property(description="集团id-多选", property="groupIds", type="string", default="1,2"),
-     *           @OA\Property(description="门店id-多选", property="storeIds", type="string", default="1,2"),
      *           @OA\Property(description="mac地址", property="macAdress", type="string", default="1,2"),
+     *           @OA\Property(description="工号", property="adminCode", type="string", default="A2"),
      *           @OA\Property(description="管理员id", property="id", type="string", default="0"),
-     *           required={"name","account","mobile","roleId","groupIds","storeIds"})
+     *           required={"name","account","mobile","roleId","groupIds","adminCode"})
      *       )
      *     ),
      *   @OA\Response(response="200", description="请求成功")
@@ -90,6 +90,7 @@ class Admin extends BaseController {
             'account|登入账号'  => 'require',
             'mobile|手机号'    => 'require',
             'roleId|角色id'   => 'require',
+            'adminCode|工号'   => 'require',
 //            'storeIds|门店id' => 'require',
             'groupIds|集团id' => 'require',
         ];
@@ -100,7 +101,7 @@ class Admin extends BaseController {
             $service->editAdmin($input);
         } else {
             $service = new AdminService();
-            $service->addAdmin($input);
+            $input['id'] = $service->addAdmin($input);
         }
         $where[] = ['a.id', '=', (int)$input['id']];
         $model->setWhere($where);

+ 3 - 3
application/api/controller/Pay.php

@@ -48,9 +48,9 @@ class Pay extends BaseController {
             $where[] = ['pay_code', 'like', "%{$input['code']}%"];
         }
 
-//        if (!empty($input['groupId'])) {
-//            $where[] = ['p.group_id', '=', "{$input['groupId']}"];
-//        }
+        if (!empty($input['groupId'])) {
+            $where[] = ['group_id', '=', "{$input['groupId']}"];
+        }
 //        $where[] = ['gr.admin_id','=',$this->adminId];
 
         $model->setWhere($where);

+ 1 - 1
application/api/controller/Store.php

@@ -53,7 +53,7 @@ class Store extends BaseController {
         }
         if (!empty($input['groupId'])) {
             $ids = explode(',', $input['groupId']);
-            $where[] = ['s.group_id', 'in', "{$ids}"];
+            $where[] = ['s.group_id', 'in', $ids];
         }
 
         if (!empty($input['type']) && $input['type'] == 1) {

+ 1 - 1
application/api/model/AdminModel.php

@@ -72,7 +72,7 @@ class AdminModel  extends BaseModel {
 
     public function getAdminInfo() {
         $selectModel = $this->alias('a')
-            ->field('a.id,a.account,a.name,a.mobile,a.last_login_time,a.status,a.role_id,
+            ->field('a.id,a.account,a.name,a.mobile,a.last_login_time,a.status,a.role_id,a.admin_code,
             r.auth_name,
             GROUP_CONCAT(DISTINCT st.id) as storeIds,
             GROUP_CONCAT(DISTINCT g.id) as groupIds,

+ 2 - 2
application/api/model/CompanyModel.php

@@ -15,12 +15,12 @@ class CompanyModel  extends BaseModel {
     public function getCompanyList() {
         $countModel = $this->alias('c')
             ->join('group g','g.id = c.group_id')
-            ->join('pay_config p','p.id = c.pay_id','left');
+            ->join('pay_config p','p.pay_code = c.pay_code','left');
 
         $selectModel = $this->alias('c')
             ->field('c.*,g.group_name,p.pay_code')
             ->join('group g','g.id = c.group_id')
-            ->join('pay_config p','p.id = c.pay_id','left')
+            ->join('pay_config p','p.pay_code = c.pay_code','left')
             ->order(['c.id' => 'desc']);
         return $this->joinModelPageList($countModel, $selectModel);
     }

+ 11 - 0
application/common/service/AdminService.php

@@ -26,6 +26,10 @@ class AdminService {
         if ($info !== null){
             throw new ApiException('管理员账号不能重复!');
         }
+        $info = $model::where(['admin_code' => $input['adminCode']])->find();
+        if ($info !== null){
+            throw new ApiException('管理员工号不能重复!');
+        }
         try {
             $model->startTrans();
             $id = $model->insertGetId([
@@ -34,6 +38,7 @@ class AdminService {
                 'role_id'     => $input['roleId'],
                 'password'    => $this->encodePasswd($input['password']),
                 'mobile'      => $input['mobile'],
+                'admin_code'  => $input['adminCode'],
                 'status'      => $input['status'] ?? 1,
                 'mac_address' => $input['macAddress'] ?? ''
             ]);
@@ -46,11 +51,16 @@ class AdminService {
             $model->rollback();
             throw new ApiException($e->getMessage());
         }
+        return $id;
     }
 
     public function editAdmin($input) {
         $model = new AdminModel();
         $id = (int)$input['id'];
+        $rs =  $model::where([['id', '<>', $id], ['admin_code', '=', $input['adminCode']]])->find();
+        if (!empty($rs)) {
+            throw new ApiException('工号不为空');
+        }
         try {
             $model->startTrans();
             $data = [
@@ -58,6 +68,7 @@ class AdminService {
                 'account' => $input['account'],
                 'role_id' => $input['roleId'],
                 'mobile'  => $input['mobile'],
+                'admin_code'  => $input['adminCode'],
                 'status'  => $input['status'] ?? 1,
             ];
             if (!empty($input['password'])) {

+ 5 - 0
public/api.yaml

@@ -84,6 +84,7 @@ paths:
                 - roleId
                 - groupIds
                 - storeIds
+                - adminCode
               properties:
                 name:
                   description: 管理员名称
@@ -117,6 +118,10 @@ paths:
                   description: mac地址
                   type: string
                   default: '1,2'
+                adminCode:
+                  description: 工号
+                  type: string
+                  default: A2
                 id:
                   description: 管理员id
                   type: string