<?php
namespace app\api\lists\recharge;

use app\api\lists\BaseApiDataLists;
use app\common\enum\PayEnum;
use app\common\model\recharge\RechargeOrder;

/**
 * 充值记录列表
 * Class RechargeLists
 * @package app\api\lists\recharge
 */
class RechargeLists extends BaseApiDataLists
{
    /**
     * @notes 获取列表
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function lists(): array
    {
        $lists = RechargeOrder::field('order_amount,create_time')
            ->where([
                'order_type' => 1,
                'user_id' => $this->userId,
            ])
            ->order('id', 'desc')
            ->select()
            ->toArray();
        return $lists;
    }


    /**
     * @notes  获取数量
     * @return int
     */
    public function count(): int
    {
        return RechargeOrder::where([
                'order_type' => 1,
                'user_id' => $this->userId,
            ])
            ->count();
    }

}