123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- namespace app\admin\controller;
- use app\common\controller\Backend;
- use think\Db;
- class Eggjackpotchanchu extends Backend
- {
-
-
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\Eggjackpotchanchu;
- }
- public function import()
- {
- parent::import();
- }
-
-
-
- public function index()
- {
-
- $this->relationSearch = true;
-
- $this->request->filter(['strip_tags', 'trim']);
- if ($this->request->isAjax()) {
-
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $list = $this->model
- ->with(['eggjackpot'])
- ->where($where)
- ->order($sort, $order)
- ->paginate($limit);
- foreach ($list as $row) {
-
- $row->getRelation('eggjackpot')->visible(['name']);
- }
- $result = array("total" => $list->total(), "rows" => $list->items());
- return json($result);
- }
- 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();
- }
- }
|