Browse Source

分类优化,全局获取用户信息优化

wufeng 2 years ago
parent
commit
beb31593cc

+ 15 - 14
app/admin/controller/Cat.php

@@ -194,7 +194,8 @@ class Cat extends Base
 //        $fund_code = isset($this->post['fund_code']) && $this->post['fund_code'] !== '' ? trim($this->post['fund_code']) : '';
 
         $level = 1;
-        if ($param['pid'] !== 0) {
+
+        if ($param['pid'] != 0) {
             $levl = Db::name('cat')
                 ->field('id,level,search')
                 ->where(['id' => $param['pid']])
@@ -318,14 +319,14 @@ class Cat extends Base
         if (empty($specs_id)) {
             return error_show(1002, '参数specs_id不能为空');
         }
-        $token = isset($this->post['token']) && $this->post['token'] != '' ? trim($this->post['token']) : '';
-        if ($token == '') {
-            return error_show(105, '参数token不能为空');
-        }
-        $user = GetUserInfo($token);
-        if (empty($user) || $user['code'] != 0) {
-            return error_show(102, '创建人数据不存在');
-        }
+//        $token = isset($this->post['token']) && $this->post['token'] != '' ? trim($this->post['token']) : '';
+//        if ($token == '') {
+//            return error_show(105, '参数token不能为空');
+//        }
+//        $user = GetUserInfo($token);
+//        if (empty($user) || $user['code'] != 0) {
+//            return error_show(102, '创建人数据不存在');
+//        }
 
         $level = 1;
         if ($pid !== 0) {
@@ -341,8 +342,8 @@ class Cat extends Base
         } else {
             $search = $temp . '_' . $cat_name;
         }
-        $createrid = isset($user['data']['id']) ? $user['data']['id'] : '';
-        $creater = isset($user['data']['nickname']) ? $user['data']['nickname'] : '';
+        $createrid = $this->uid;//isset($user['data']['id']) ? $user['data']['id'] : '';
+        $creater = $this->uname;//isset($user['data']['nickname']) ? $user['data']['nickname'] : '';
         //$level = isset($this->post['level']) && $this->post['level'] !=='' ? intval($this->post['level']) :'';
 
         $weight = isset($this->post['weight']) && $this->post['weight'] !== '' ? intval($this->post['weight']) : '0';
@@ -368,8 +369,8 @@ class Cat extends Base
             $jsp = json_encode($idinfo, JSON_UNESCAPED_UNICODE);
             if ($strinfo) {
                 $order = ['order_code' => $id, 'status' => $status, 'action_remark' => '', 'action_type' => 'edit'];
-                ActionLog::logAdd($this->post['token'], $order, 'sxd', $status, $order);
-                ChangeLog::logAdd(7, $idinfo['id'], $jsp, $json, $this->post['token'], $this->post);
+                ActionLog::logAdd(['id'=>$createrid,'nickname'=>$creater], $order, 'sxd', $status, $order);
+                ChangeLog::logAdd(7, $idinfo['id'], $jsp, $json, ['id'=>$createrid,'nickname'=>$creater], $this->post);
                 $spc = [];
                 $vp = Db::name('cat_spec')->where(['cat_id' => $idinfo['id'], 'is_del' => 0])->find();
                 $str = '';
@@ -518,7 +519,7 @@ class Cat extends Base
                     ->alias('a')
                     ->leftJoin('specs b', 'b.id=a.specs_id')
                     ->where(['a.cat_id' => $da['id'], 'a.is_del' => 0])
-                    ->field('a.specs_id,b.spec_name')
+                    ->field('a.specs_id id,b.spec_name')
                     ->select()
                     ->toArray();
             })

+ 2 - 4
app/admin/controller/CompanyPlatformCatProfit.php

@@ -25,9 +25,7 @@ class CompanyPlatformCatProfit extends Base
         $where = [
             ['a.is_del', '=', 0],
             ['a.pid', '=', $param['pid']],
-            ['b.companyNo', '=', $param['companyNo']],
-            ['b.platform_id', '=', $param['platform_id']
-            ]];
+        ];
         if ($param['cat_name'] != '') $where[] = ['a.cat_name', 'like', '%' . $param['cat_name'] . '%'];
 
         $count = Db::name('cat')
@@ -40,7 +38,7 @@ class CompanyPlatformCatProfit extends Base
         $list = Db::name('cat')
             ->alias('a')
             ->field('a.id cat_id,a.cat_name,a.level,p.platform_name,b.rate,b.order_rate,b.money_rate,b.low_rate,b.sale_rate,b.status')
-            ->leftJoin('company_platform_cat_profit b', 'b.cat_id=a.id AND b.is_del=0')
+            ->leftJoin('company_platform_cat_profit b', 'b.cat_id=a.id AND b.is_del=0 AND b.companyNo=\'' . $param['companyNo'] . '\' AND b.platform_id=\'' . $param['platform_id'] . '\'')
             ->leftJoin('platform p', 'p.id=b.platform_id AND p.is_del=0')
             ->where($where)
             ->order('a.id', 'desc')

+ 1 - 1
app/admin/controller/Newfill.php

@@ -183,7 +183,7 @@ class Newfill extends Base
 //
 //            $t = Db::name("company_item")->insert($data, true);
 //            if ($t > 0) {
-//                $orde = ["order_code" => $repeat_name['name'], "status" => 0, "action_remark" => '', "action_type" => "creat"];
+//                $orde = ["order_code" => $repeat_name['name'], "status" => 0, "action_remark" => '', "action_type" => "create"];
 //                ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], $orde, "company_item", 0, $orde);
 //                $depart_link = $spid['depart_link'] . "{$t}-";
 //                $level = explode('-', $depart_link);

+ 11 - 7
app/common.php

@@ -23,14 +23,18 @@ function error_show($code=0,$message=""){
 }
 
 function GetUserInfo($token){
-    $host = Config::get("app");
-    $url = $host["api_host"]."/Api/userinfo";
-    $data=[
-        "token"=>$token
-    ];
-    $response=curl_request($url,$data);
 
-    return json_decode($response,true);
+    $userCommon = new \app\admin\common\User();
+    return $userCommon->handle('verifyToken',['token'=>$token]);
+
+//    $host = Config::get("app");
+//    $url = $host["api_host"]."/Api/userinfo";
+//    $data=[
+//        "token"=>$token
+//    ];
+//    $response=curl_request($url,$data);
+//
+//    return json_decode($response,true);
 }
 //参数1:访问的URL,参数2:post数据(不填则为GET),参数3:提交的$cookies,参数4:是否返回$cookies
 function curl_request($url,$post=''){