<?php

namespace app\admin\model;

use think\Model;

class Recharge extends Model
{

    /**
     * 充值列表
     * @access public
     * @author csdeshang
     * @param array $condition 条件
     * @param string $field 字段
     * @param number $page 分页
     * @param string $order 排序
     * @return array
     */
    public function getRechargeList($condition = array(), $field = '*', $page = 0, $order = 'recharge_id desc')
    {
        $user_list = $this
            ->alias('a')
            ->join('user b','b.user_id = a.user_id')
            ->where($condition)
            ->order($order)
            ->paginate($page, false, ['query' => request()->param()]);
        $this->page_info = $user_list;
        return $user_list->items();
    }
    public function rechargeList($condition)
    {
        $user_list = $this
            ->alias('a')
            ->join('user b','b.user_id = a.user_id')
            ->where($condition)
            ->order('recharge_time desc')
            ->paginate(10);
        return $user_list;
    }
    public function findRecharge($condition)
    {
        $result = $this
            ->alias('a')
            ->join('userinfo b','b.user_id = a.user_id')
            ->where($condition)
            ->find();

        return $result;
    }
    public function updateRecharge($condition, $data)
    {
        $result = $this
            ->where($condition)
            ->update($data);

        return $result;
    }


}
