Browse Source

奖池即时产出

lizhen_gitee 1 year ago
parent
commit
c9653f85b0

+ 41 - 1
application/admin/controller/Eggjackpotchanchu.php

@@ -3,7 +3,7 @@
 namespace app\admin\controller;
 
 use app\common\controller\Backend;
-
+use think\Db;
 /**
  * 奖池产出日志
  *
@@ -71,4 +71,44 @@ class Eggjackpotchanchu extends Backend
         return $this->view->fetch();
     }
 
+    //奖池产出
+    public function chanchu(){
+        if ($this->request->isAjax()) {
+            $list = Db::name('egg_jackpot')->where('status',1)->order('type asc')->select();
+
+            $typea_arr = [
+                1 => '普通',
+                2 => '高级',
+                3 => '大转盘',
+            ];
+
+            foreach($list as $key => &$jackpot){
+                $jackpot_id = $jackpot['id'];
+
+                $jackpot_chanchu = [
+                    'type' => $typea_arr[$jackpot['type']],
+
+                    //奖池的
+                    'jp_giftnum'   => Db::name('egg_gift')->where('Jackpot_id',$jackpot_id)->count(), //总礼物数量
+                    'jp_giftprice' => Db::name('egg_gift')->where('Jackpot_id',$jackpot_id)->sum('price'), //总礼物价值
+                    //抽奖的
+                    'do_payfee'    => Db::name('egg_do')->where('Jackpot_id',$jackpot_id)->where('starttime',$jackpot['starttime'])->sum('pay_fee'), //物抽总礼奖费用
+                    'do_usercount' => Db::name('egg_do')->where('Jackpot_id',$jackpot_id)->where('starttime',$jackpot['starttime'])->group('user_id')->count('id'),//抽奖总人数
+                    'do_usertimes' => Db::name('egg_do')->where('Jackpot_id',$jackpot_id)->where('starttime',$jackpot['starttime'])->group('do_no')->count('id'),//抽奖总次数
+                    'do_giftnum'   => Db::name('egg_do')->where('Jackpot_id',$jackpot_id)->where('starttime',$jackpot['starttime'])->count('id'),//抽奖总礼物数量
+                    'do_giftprice' => Db::name('egg_do')->where('Jackpot_id',$jackpot_id)->where('starttime',$jackpot['starttime'])->sum('price'),//抽奖总礼物价值
+                ];
+                //产出比
+                $jackpot_chanchu['chanchubi'] = bcdiv($jackpot_chanchu['do_giftprice'],$jackpot_chanchu['jp_giftprice'],2);
+
+                $jackpot = array_merge($jackpot,$jackpot_chanchu);
+            }
+
+            $result = array("total" => 3, "rows" => $list);
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+
 }

+ 3 - 1
application/admin/lang/zh-cn/eggjackpotchanchu.php

@@ -13,5 +13,7 @@ return [
     'Do_giftnum'      => '抽奖总礼物数量',
     'Do_giftprice'    => '抽奖总礼物价值',
     'Chanchubi'       => '产出比',
-    'Eggjackpot.name' => '奖池名称'
+    'Eggjackpot.name' => '奖池名称',
+    'Eggjackpot.type' => '奖池类型',
+    'Eggjackpot.starttime' => '奖池启用时间',
 ];

+ 22 - 0
application/admin/view/eggjackpotchanchu/chanchu.html

@@ -0,0 +1,22 @@
+<div class="panel panel-default panel-intro">
+    {:build_heading()}
+
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="one">
+                <div class="widget-body no-padding">
+                    <div id="toolbar" class="toolbar">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
+
+
+                        
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 44 - 0
public/assets/js/backend/eggjackpotchanchu.js

@@ -46,6 +46,50 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             // 为表格绑定事件
             Table.api.bindevent(table);
         },
+        chanchu: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'eggjackpotchanchu/chanchu' + location.search,
+                    table: 'egg_jackpot_chanchu',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                searchFormVisible: false,
+                search: false,  //搜索id
+                showToggle: false,//修改列表方式
+                commonSearch:false,
+                exportTypes: ['excel'], //只导出excel
+                columns: [
+                    [
+                        {field: 'id', title: __('Jackpot_id')},
+                        {field: 'name', title: __('Eggjackpot.name'), operate: false},
+                        {field: 'type', title: __('Eggjackpot.type'), operate: false},
+                        {field: 'starttime', title: __('Eggjackpot.starttime'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+
+                        {field: 'jp_giftnum', title: __('Jp_giftnum')},
+                        {field: 'jp_giftprice', title: __('Jp_giftprice')},
+                        {field: 'do_payfee', title: __('Do_payfee')},
+                        {field: 'do_usercount', title: __('Do_usercount')},
+                        {field: 'do_usertimes', title: __('Do_usertimes')},
+                        {field: 'do_giftnum', title: __('Do_giftnum')},
+                        {field: 'do_giftprice', title: __('Do_giftprice')},
+                        {field: 'chanchubi', title: __('Chanchubi'), operate:'BETWEEN'},
+//                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
         add: function () {
             Controller.api.bindevent();
         },