浏览代码

奖池礼物增加搜索

lizhen_gitee 1 年之前
父节点
当前提交
a6810cfb26

+ 2 - 2
application/admin/controller/egg/Gift.php

@@ -59,10 +59,10 @@ class Gift extends Backend
                     ->order($sort, $order)
                     ->paginate($limit);
 
-            $totalMoney = $this->model->where($where)->sum('price');
+            $totalMoney = $this->model->with(['eggjackpot'])->where($where)->sum('price');
             foreach ($list as $row) {
                 
-                $row->getRelation('eggjackpot')->visible(['name']);
+                $row->getRelation('eggjackpot')->visible(['name','type']);
             }
 
             $result = array("total" => $list->total(), "rows" => $list->items(), "extend" => ['total_price' => $totalMoney]);

+ 17 - 12
application/admin/lang/zh-cn/egg/gift.php

@@ -1,16 +1,21 @@
 <?php
 
 return [
-    'Gift_id'         => '礼物ID',
-    'Image'           => '图片',
-    'Special'         => '特效',
-    'Gift_name'       => '礼物名称',
-    'Jackpot_id'      => '奖池ID',
-    'Prize_no'        => '中奖编号',
-    'Price'           => '价值',
-    'Is_use'          => '是否被抽走',
-    'Is_use 1'        => '是',
-    'Is_use 0'        => '否',
-    'Updatetime'      => '更新时间',
-    'Eggjackpot.name' => '奖池名称'
+    'Gift_id'           => '礼物ID',
+    'Image'             => '图片',
+    'Special'           => '特效',
+    'Gift_name'         => '礼物名称',
+    'Jackpot_id'        => '奖池ID',
+    'Prize_no'          => '中奖编号',
+    'Price'             => '价值',
+    'Is_use'            => '是否被抽走',
+    'Is_use 1'          => '是',
+    'Is_use 0'          => '否',
+    'Updatetime'        => '更新时间',
+    'Starttime'         => '启用时间',
+    'Eggjackpot.name'   => '奖池名称',
+    'Eggjackpot.type'   => '奖池分类',
+    'Eggjackpot.type 1' => '普通',
+    'Eggjackpot.type 2' => '高级',
+    'Eggjackpot.type 3' => '大转盘'
 ];

+ 11 - 1
application/admin/model/egg/Gift.php

@@ -25,7 +25,8 @@ class Gift extends Model
 
     // 追加属性
     protected $append = [
-        'is_use_text'
+        'is_use_text',
+        'starttime_text'
     ];
     
 
@@ -44,7 +45,16 @@ class Gift extends Model
     }
 
 
+    public function getStarttimeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['starttime']) ? $data['starttime'] : '');
+        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+    }
 
+    protected function setStarttimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
 
     public function eggjackpot()
     {

+ 3 - 1
public/assets/js/backend/egg/gift.js

@@ -36,15 +36,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'id', title: __('Id')},
                         {field: 'Jackpot_id', title: __('Jackpot_id')},
                         {field: 'eggjackpot.name', title: __('Eggjackpot.name'), operate: 'LIKE'},
+                        {field: 'eggjackpot.type', title: __('Eggjackpot.type'), searchList: {"1":__('Eggjackpot.type 1'),"2":__('Eggjackpot.type 2'),"3":__('Eggjackpot.type 3')}, formatter: Table.api.formatter.normal},
                         {field: 'gift_id', title: __('Gift_id')},
-                        {field: 'gift_name', title: __('Gift_name'), operate: 'LIKE'},
                         {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
 //                        {field: 'special', title: __('Special'), operate: 'LIKE'},
+                        {field: 'gift_name', title: __('Gift_name'), operate: 'LIKE'},
 
 //                        {field: 'prize_no', title: __('Prize_no')},
                         {field: 'price', title: __('Price')},
                         {field: 'is_use', title: __('Is_use'), searchList: {"1":__('Is_use 1'),"0":__('Is_use 0')}, formatter: Table.api.formatter.normal},
                         {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+//                        {field: 'starttime', title: __('Starttime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]