瀏覽代碼

fix:代理商身份

super-yimizi 15 小時之前
父節點
當前提交
28f03a249d

+ 3 - 3
application/admin/controller/commission/Apply.php

@@ -51,12 +51,12 @@ class Apply extends Backend
      */
     public function detail($ids = null)
     {
-        $row = $this->model->get($ids);
+        $row = $this->model::with(['user', 'identity', 'province', 'city', 'district', 'admin'])
+          ->where('id', $ids)
+          ->find();
         if (!$row) {
             $this->error(__('No Results were found'));
         }
-        
-        $row->load(['user', 'identity', 'province', 'city', 'district', 'admin']);
         $this->view->assign('row', $row);
         return $this->view->fetch();
     }

+ 17 - 0
application/common/model/User.php

@@ -39,6 +39,23 @@ class User extends Model
         return "/u/" . $data['id'];
     }
 
+    /**
+     * 关联上级用户
+     */
+    public function parent_user()
+    {
+        return $this->belongsTo('app\common\model\User', 'parent_user_id', 'id')
+                    ->field('id,nickname,avatar,mobile');
+    }
+
+    /**
+     * 别名关联上级用户(支持驼峰命名)
+     */
+    public function parentUser()
+    {
+        return $this->parent_user();
+    }
+
     // /**
     //  * 获取头像
     //  * @param string $value

+ 20 - 0
application/common/model/commission/Agent.php

@@ -5,6 +5,8 @@ namespace app\common\model\commission;
 use app\common\model\User;
 use app\common\Enum\AgentType;
 use app\common\library\BcMath;
+use app\common\model\commission\Level;
+use app\common\model\commission\Reward;
 use think\Model;
 class Agent  extends Model
 {
@@ -85,6 +87,12 @@ class Agent  extends Model
     {
         return $this->belongsTo(Level::class, 'level', 'level')->field(['level', 'name', 'image', 'commission_rules']);
     }
+    
+    // 添加蛇形命名的关联方法别名
+    public function level_info()
+    {
+        return $this->levelInfo();
+    }
 
     public function getPendingRewardAttr($value, $data)
     {
@@ -110,9 +118,21 @@ class Agent  extends Model
     {
         return $this->belongsTo(Level::class, 'level_status', 'level');
     }
+    
+    // 添加蛇形命名的关联方法别名
+    public function level_status_info()
+    {
+        return $this->levelStatusInfo();
+    }
 
     public function upgradeLevel()
     {
         return $this->belongsTo(Level::class, 'level_status', 'level');
     }
+    
+    // 添加蛇形命名的关联方法别名
+    public function upgrade_level()
+    {
+        return $this->upgradeLevel();
+    }
 }

+ 0 - 1
public/assets/js/backend/commission/agent.js

@@ -28,7 +28,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'user_id', title: __('ID'), width: 60},
                         {field: 'user.nickname', title: __('用户昵称'), operate: 'LIKE'},
                         {field: 'user.mobile', title: __('手机号'), operate: 'LIKE'},
-                        {field: 'level_info.name', title: __('分销等级')},
                         {field: 'status', title: __('状态'), searchList: {
                             "normal": __('正常'),
                             "pending": __('审核中'),