afa 1 tháng trước cách đây
mục cha
commit
44a79a4760

+ 27 - 7
application/admin/controller/user/Codeuserlog.php

@@ -21,17 +21,37 @@ class Codeuserlog extends Backend
     public function _initialize()
     {
         parent::_initialize();
-        $this->model = new \app\admin\model\user\Codeuserlog;
-        $this->view->assign("statusList", $this->model->getStatusList());
+        $this->model = new \app\common\model\CodeUserLogModel();
     }
 
-
-
     /**
-     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
-     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
-     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     * 查看
+     * @return string|Json
+     * @throws \think\Exception
+     * @throws DbException
      */
+    public function index()
+    {
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if (false === $this->request->isAjax()) {
+            return $this->view->fetch();
+        }
+        //如果发送的来源是 Selectpage,则转发到 Selectpage
+        if ($this->request->request('keyField')) {
+            return $this->selectpage();
+        }
+        [$where, $sort, $order, $offset, $limit] = $this->buildparams();
+        $list = $this->model
+            ->with(['users','product1','product2'])
+            ->where($where)
+            ->order($sort, $order)
+            ->paginate($limit);
+        $result = ['total' => $list->total(), 'rows' => $list->items()];
+        return json($result);
+    }
+
+
 
 
 }

+ 1 - 1
application/admin/lang/zh-cn/user/codeuserlog.php

@@ -2,7 +2,7 @@
 
 return [
     'Id'          => 'ID',
-    'User_id'     => '激活用户Id',
+    'User_id'     => '激活用户',
     'Gift1'       => '激活礼品1',
     'Gift2'       => '激活礼品2',
     'Frozen'      => '茶宝手续费',

+ 0 - 73
application/admin/model/user/Codeuserlog.php

@@ -1,73 +0,0 @@
-<?php
-
-namespace app\admin\model\user;
-
-use think\Model;
-
-
-class Codeuserlog extends Model
-{
-
-    
-
-    
-
-    // 表名
-    protected $table = 'code_user_log';
-    
-    // 自动写入时间戳字段
-    protected $autoWriteTimestamp = false;
-
-    // 定义时间戳字段名
-    protected $createTime = false;
-    protected $updateTime = false;
-    protected $deleteTime = false;
-
-    // 追加属性
-    protected $append = [
-        'status_text',
-        'create_time_text',
-        'update_time_text'
-    ];
-    
-
-    
-    public function getStatusList()
-    {
-        return ['30' => __('Status 30')];
-    }
-
-
-    public function getStatusTextAttr($value, $data)
-    {
-        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
-        $list = $this->getStatusList();
-        return isset($list[$value]) ? $list[$value] : '';
-    }
-
-
-    public function getCreateTimeTextAttr($value, $data)
-    {
-        $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
-        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
-    }
-
-
-    public function getUpdateTimeTextAttr($value, $data)
-    {
-        $value = $value ? $value : (isset($data['update_time']) ? $data['update_time'] : '');
-        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
-    }
-
-    protected function setCreateTimeAttr($value)
-    {
-        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
-    }
-
-    protected function setUpdateTimeAttr($value)
-    {
-        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
-    }
-
-
-}

+ 19 - 0
application/common/model/CodeUserLogModel.php

@@ -40,6 +40,25 @@ class CodeUserLogModel extends Model
             $codeUserLogModel->code_no   = $code_no;
             $codeUserLogModel->save();
       }
+
+
+      public function users()
+      {
+            return $this->hasOne('UserModel', 'id', 'user_id', [], 'LEFT')->setEagerlyType(0);
+      }
+
+
+      //产品
+      public function product1()
+      {
+            return $this->hasOne('ProductLists', 'id', 'gift1', [], 'LEFT')->setEagerlyType(0);
+      }
+
+      public function product2()
+      {
+            return $this->hasOne('ProductLists', 'id', 'gift2', [], 'LEFT')->setEagerlyType(0);
+      }
+
     
       public function getCreateTimeTextAttr($value, $data)
       {

+ 12 - 4
application/config.php

@@ -412,12 +412,20 @@ return [
     //激活码配置
     'code_config' => [
         //【财神送喜】礼包:1.RWA 茶 2025 财神节*1,2.RWA 茶 喜糖*3,3.茶宝(手续费账户)2 枚
-        0 => ['gift1'=>['product_id'=> 167, 'num' => 1], 'gift2'=>['product_id'=> 165, 'num' => 3], 'num' => 2],
+        // 0 => ['gift1'=>['product_id'=> 167, 'num' => 1], 'gift2'=>['product_id'=> 165, 'num' => 3], 'num' => 2],
+        // //【社区主理人】礼包:1.社区主理人 RWA 权益卡*1, 2.RWA 茶 雄鹰 6 号*1,3.V1激活码*200
+        // 1 => ['gift1'=>['product_id'=> 166, 'num' => 1], 'gift2'=>['product_id'=> 159, 'num' => 1], 'num' => 200],
+        // //【生态主理人】礼包:1.生态主理人 RWA 权益卡*1,2.RWA 茶 雄鹰 8 号*1,3.V2礼包激活码*99
+        // 2 => ['gift1'=>['product_id'=> 181, 'num' => 1], 'gift2'=>['product_id'=> 180, 'num' => 1], 'num' => 99],
+        // //【超级主理人】礼包:1.超级主理人 RWA 权益卡*1,2.RWA 茶 雄鹰 9 号*1,3.V3礼包激活码*19
+        // 3 => ['gift1'=>['product_id'=> 182, 'num' => 1], 'gift2'=>['product_id'=> 183, 'num' => 1], 'num' => 19]
+
+        0 => ['gift1'=>['product_id'=> 11, 'num' => 1], 'gift2'=>['product_id'=> 12, 'num' => 3], 'num' => 2],
         //【社区主理人】礼包:1.社区主理人 RWA 权益卡*1, 2.RWA 茶 雄鹰 6 号*1,3.V1激活码*200
-        1 => ['gift1'=>['product_id'=> 166, 'num' => 1], 'gift2'=>['product_id'=> 159, 'num' => 1], 'num' => 200],
+        1 => ['gift1'=>['product_id'=> 13, 'num' => 1], 'gift2'=>['product_id'=> 14, 'num' => 1], 'num' => 200],
         //【生态主理人】礼包:1.生态主理人 RWA 权益卡*1,2.RWA 茶 雄鹰 8 号*1,3.V2礼包激活码*99
-        2 => ['gift1'=>['product_id'=> 181, 'num' => 1], 'gift2'=>['product_id'=> 180, 'num' => 1], 'num' => 99],
+        2 => ['gift1'=>['product_id'=> 15, 'num' => 1], 'gift2'=>['product_id'=> 16, 'num' => 1], 'num' => 99],
         //【超级主理人】礼包:1.超级主理人 RWA 权益卡*1,2.RWA 茶 雄鹰 9 号*1,3.V3礼包激活码*19
-        3 => ['gift1'=>['product_id'=> 182, 'num' => 1], 'gift2'=>['product_id'=> 183, 'num' => 1], 'num' => 19]
+        3 => ['gift1'=>['product_id'=> 17, 'num' => 1], 'gift2'=>['product_id'=> 18, 'num' => 1], 'num' => 19]
     ],
 ];

+ 11 - 6
public/assets/js/backend/user/codeuserlog.js

@@ -26,16 +26,21 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     [
                         {checkbox: true},
                         {field: 'id', title: __('Id')},
-                        {field: 'user_id', title: __('User_id')},
-                        {field: 'gift1', title: __('Gift1')},
-                        {field: 'gift2', title: __('Gift2')},
-                        {field: 'frozen', title: __('Frozen'), operate:false},
-                        {field: 'frozen', title: __('激活码数量'), operate: false, formatter: function (value, row, index, field) {
+                        {field: 'users.address', title: __('User_id'), operate: "LIKE"},
+                        {field: 'product1.zh_name', title: __('Gift1'), operate: "LIKE"},
+                        {field: 'product2.zh_name', title: __('Gift2'), operate: "LIKE"},
+                        {field: 'frozen', title: __('Frozen'), operate: false, formatter: function (value, row, index, field) {
+                            if(row.level > 0){
+                                return 0;
+                            }
+                            return Number(row.frozen);
+                        }},
+                        {field: 'frozen', title: __('赠送激活码'), operate: false, formatter: function (value, row, index, field) {
                             if(row.level == 0){
                                 return 0;
                             }
                             return Number(row.frozen);
-                        } },
+                        }},
                         {field: 'code_no', title: __('Code_no'), operate: false},
                         {field: 'level', title: __('Level'), searchList: {0:__('V1'), 1:__('V2'), 2:__('V3'), 3:__('V4')}, formatter: Table.api.formatter.status},
                         {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},