WithdrawController.php 4.2 KB
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/4/17
 * Time: 2:21
 */

namespace app\user\controller;

use cmf\controller\AdminBaseController;
use think\Db;

class WithdrawController extends AdminBaseController
{
    /*
     * 获取提现列表
     */
    public function getList() {
        $where   = ['w.state' => 1];
        $request = input('request.');

        $keywordComplex = [];
        if (!empty($request['keyword'])) {
            $keyword = $request['keyword'];

            $keywordComplex['u.user_nickname']    = ['like', "%$keyword%"];
        }
        if (!empty($request['start_time']) && !empty($request['end_time'])) {
            $keywordComplex['w.create_time'] = ['>=', $request['start_time']];
            $keywordComplex['w.create_time'] = ['<=', $request['end_time']];
        }
        $list = Db::name('withdraw_log')
            ->alias('w')
            ->join('user u','w.user_id = u.id','left')
            ->whereOr($keywordComplex)
            ->where($where)
            ->field('w.id,w.money,w.blance,w.pay_time,w.charge,u.user_nickname,u.user_type')
            ->order("w.pay_time DESC")
            ->paginate(10);
        // 获取分页显示
        $page = $list->render();
        $this->assign('list', $list);
        $this->assign('page', $page);
        // 渲染模板输出
        return $this->fetch('list');
    }

    /*
     * 获取领取列表
     */
    public function getPullList() {
        $where   = ['s.state' => 1];
        $request = input('request.');

        $keywordComplex = [];
        if (!empty($request['keyword'])) {
            $keyword = $request['keyword'];

            $keywordComplex['u.user_nickname|c.name']    = ['like', "%$keyword%"];
        }
        if (!empty($request['start_time']) && !empty($request['end_time'])) {
            $keywordComplex['s.create_time'] = ['>=', $request['start_time']];
            $keywordComplex['s.create_time'] = ['<=', $request['end_time']];
        }
        $list = Db::name('share_log')
            ->alias('s')
            ->join('user u','s.user_id = u.id','left')
            ->join('card c','s.card_id = c.id','left')
            ->whereOr($keywordComplex)
            ->where($where)
            ->field('s.id,s.money,s.create_time,u.user_nickname,c.name')
            ->order("s.create_time DESC")
            ->paginate(10);
        $count = Db::name('share_log')
            ->alias('s')
            ->join('user u','s.user_id = u.id','left')
            ->join('card c','s.card_id = c.id','left')
            ->whereOr($keywordComplex)
            ->where($where)
            ->sum('s.money');
        // 获取分页显示
        $page = $list->render();
        $this->assign('count', $count);
        $this->assign('list', $list);
        $this->assign('page', $page);
        // 渲染模板输出
        return $this->fetch('log');
    }
    /*
     * 充值列表
     */
    public function getRechargeList() {

        $where   = ['r.state' => 1];
        $request = input('request.');
        $keywordComplex = [];
        if (!empty($request['keyword'])) {
            $keyword = $request['keyword'];

            $keywordComplex['c.name']    = ['like', "%$keyword%"];
        }
        if (!empty($request['start_time']) && !empty($request['end_time'])) {
            $keywordComplex['r.create_time'] = ['>=', $request['start_time']];
            $keywordComplex['r.create_time'] = ['<=', $request['end_time']];
        }
        $list = Db::name('recharge_log')
            ->alias('r')
            ->join('user u','r.user_id = u.id','left')
            ->join('card c','u.id = c.user_id','left')
            ->whereOr($keywordComplex)
            ->where($where)
            ->field('r.id,r.order_sn,r.num,r.money,r.create_time,r.pay_time,u.user_nickname,u.avatar,c.name,u.id user_id')
            ->order("r.create_time DESC")
            ->paginate(10);
        // 获取分页显示
        $page = $list->render();
        $this->assign('start_time', isset($request['start_time']) ? $request['start_time'] : '');
        $this->assign('end_time', isset($request['end_time']) ? $request['end_time'] : '');
        $this->assign('list', $list);
        $this->assign('page', $page);
        // 渲染模板输出
        return $this->fetch('rechargeList');
    }
}