浏览代码

fix():增加分类

geek 4 年之前
父节点
当前提交
d4aa56d80e

+ 11 - 0
application/api/controller/Group.php

@@ -10,6 +10,7 @@ namespace app\api\controller;
 use app\api\BaseController;
 use app\api\exception\ApiException;
 use app\api\model\GroupModel;
+use app\api\model\StoreModel;
 use app\common\until\Until;
 
 class Group extends BaseController {
@@ -35,6 +36,16 @@ class Group extends BaseController {
         $where[] = ['gr.admin_id','=',$this->adminId];
         $model->setWhere($where);
         $data = $model->getGroupList();
+        $ids = array_column($data['list'], 'id');
+        $storeList = (new StoreModel())::where([['group_id', 'in', $ids]])->select();
+        $storeList = Until::modelToArray($storeList);
+        $groupStore = [];
+        foreach ($storeList as $info) {
+            $groupStore[$info['group_id']][] = $info;
+        }
+        foreach ($data['list'] as &$info) {
+            $info['storeList'] = $groupStore[$info['id']];
+        }
         Until::output($data);
     }
 

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

@@ -127,7 +127,7 @@ class Order extends BaseController {
             $product[$v['order_id']][] = $v;
         }
 
-        $statusFilter = [1 => '未支付', 2 => '已支付', 3 => '已关闭'];
+        $statusFilter = [1 => '未支付', 2 => '已支付', 3 => '已关闭', 4 => '已删除'];
 
         foreach ($data['list'] as &$one) {
 

+ 5 - 4
application/api/controller/Pay.php

@@ -70,7 +70,8 @@ class Pay extends BaseController {
      *         @OA\Schema(
      *           @OA\Property(description="支付code", property="code", type="string", default="jj公司"),
      *           @OA\Property(description="状态 1正常  2删除", property="status", type="integer", default="1"),
-     *           @OA\Property(description="备注", property="remark", type="dtring", default="xx支付"),
+     *           @OA\Property(description="备注", property="remark", type="string", default="xx支付"),
+     *           @OA\Property(description="集团id", property="groupId", type="string", default="xx支付"),
      *           required={"code"})
      *       )
      *     ),
@@ -85,7 +86,7 @@ class Pay extends BaseController {
             //'subPayId|子商户号'  => 'require',
 //            'masterAppId|主appId' => 'require',
             //'subAppId|子appId'  => 'require',
-//            'groupId|集团id'       => 'require',
+            'groupId|集团id'       => 'require',
 //            'xcxSecret|秘钥'       => 'require',
         ];
         Until::check($rule, $input);
@@ -99,7 +100,7 @@ class Pay extends BaseController {
 //                'master_app_id' => $input['masterAppId'],
 //                'sub_app_id'    => $input['subAppId'],
 //                'xcx_secret'    => $input['xcxSecret'],
-//                'group_id'      => $input['groupId'],
+                'group_id'      => $input['groupId'],
                 'status'        => $input['status'] ?? 1,
                 'remark'        => $input['remark']
             ]);
@@ -115,7 +116,7 @@ class Pay extends BaseController {
 //                'master_app_id' => $input['masterAppId'],
 //                'sub_app_id'    => $input['subAppId'] ?? "",
 //                'xcx_secret'    => $input['xcxSecret'],
-//                'group_id'      => $input['groupId'],
+                'group_id'      => $input['groupId'],
                 'status'        => $input['status'] ?? 1,
                 'remark'        => $input['remark'] ?? ''
             ]);

+ 6 - 2
application/api/controller/Product.php

@@ -43,8 +43,9 @@ class Product extends BaseController {
         $model = new ProductModel();
         $model->setPage($input['page'] ?? 1);
         $model->setPageSize($input['pageSize'] ?? 10);
-        if ($this->isAdmin()) {
-            $where = [];
+        $where = [];
+        if ($this->isAdmin() &&  !empty($input['status'])) {
+            $where[] = ['p.status', '=', ];
         } else {
             $where[] = ['p.status', '=', $model::NORMAL];
         }
@@ -57,6 +58,9 @@ class Product extends BaseController {
             $where[] = ['p.brand_id', '=', "{$input['brandId']}"];
         }
         if (!empty($input['groupId'])) {
+            $where[] = ['p.group_id', '=', "{$input['groupId']}"];
+        }
+        if (!empty($input['companyId'])) {
             $where[] = ['p.company_id', '=', "{$input['companyId']}"];
         }
         //        if (!empty($input['storeId'])) {

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

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

+ 7 - 7
application/api/controller/User.php

@@ -44,27 +44,27 @@ class User extends BaseController {
         $model->setPageSize($input['pageSize'] ?? 10);
         $where = [];
         if (!empty($input['status'])) {
-            $where[] = ['status', '=', $input['status']];
+            $where[] = ['u.status', '=', $input['status']];
         } else {
-            $where[] = ['status', '=', $model::NORMAL];
+            $where[] = ['u.status', '=', $model::NORMAL];
         }
         if (!empty($input['mobile']) || (isset($input['mobile']) && $input['mobile'] == '0')) {
-            $where[] = ['mobile', 'like', '%' . $input['mobile'] . '%'];
+            $where[] = ['u.mobile', 'like', '%' . $input['mobile'] . '%'];
         }
 
         if (!empty($input['name']) || (isset($input['name']) && $input['name'] == '0')) {
-            $where[] = ['name', 'like', '%' . $input['name'] . '%'];
+            $where[] = ['u.name', 'like', '%' . $input['name'] . '%'];
         }
 
         if (!empty($input['cardLevel'])) {
-            $where[] = ['card_level', '=', $input['cardLevel']];
+            $where[] = ['u.card_level', '=', $input['cardLevel']];
         }
 
         if (!empty($input['joinType'])) {
-            $where[] = ['join_type', '=', $input['joinType']];
+            $where[] = ['u.join_type', '=', $input['joinType']];
         }
         $model->setWhere($where);
-        $data = $model->getPageList($model);
+        $data = $model->getUserList();
         Until::output($data);
     }
 

+ 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().' file:' . str_replace('/ky100/www','ROOT',$e->getFile()) . ' line:' . $e->getLine() ,
+                $e->getMessage(),
                 Enum::THROW_ERR_CODE,
                 $e->getTraceAsString()
             );

+ 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,
+            ->field('a.id,a.account,a.name,a.mobile,a.last_login_time,a.status,a.role_id,
             r.auth_name,
             GROUP_CONCAT(DISTINCT st.id) as storeIds,
             GROUP_CONCAT(DISTINCT g.id) as groupIds,

+ 11 - 0
application/api/model/UserModel.php

@@ -15,6 +15,17 @@ class UserModel  extends BaseModel {
 
     protected $table = 'user';
 
+    public function getUserList() {
+        $countModel = $this->alias('u')
+            ->join('store s', 's.id = u.first_store_id', 'left');
+
+        $selectModel = $this->alias('u')
+            ->field('u.*,s.store_name as storeName')
+            ->join('store s', 's.id = u.first_store_id', 'left')
+            ->order('u.id','desc');
+        return $this->joinModelPageList($countModel, $selectModel);
+    }
+
     public function getUserInfo(int $id) {
         $info = $this->alias('u')
             ->field('u.id as userId,u.*,wx.*')