<?php

namespace app\controller;


use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Db;

class Refund
{
    /**
     * @throws ModelNotFoundException
     * @throws DataNotFoundException
     * @throws DbException
     */
    public function FindRechargeOrder($start_time = '', $end_time = '', $out_trade_no = '')
    {

      
        $where = [];
        if ($start_time) {
            $where[] = ['success_time','>=',$start_time];
        }
        if ($end_time) {
            $where[] = ['success_time','<=',$end_time];
        }

        if ($out_trade_no) {
            $where[] = ['out_trade_no','like','%'.$end_time.'%'];
        }


        $list = Db::table('zxc_recharge')->where($where)->order('id desc')->select();  // 获取全部数据
        
        
        
        
        foreach ($list as $key => &$value) {

            $value['total'] = round($value['total'] / 100, 2);
            $value['payer_total'] = round($value['payer_total'] / 100, 2);
            
            
            $table = 'zxc_user';
            $phone = Db::table($table)->where('openid', $value['openid'])->value('phone');
            $value['phone'] = $phone;

        }

        return json($list);

    }
}