<?php

namespace app\index\controller;

use app\common\controller\IndexCommon;
use hehe\Verify;
use think\Db;


class Scan extends IndexCommon {


    protected $noNeedRight = ['*'];
    protected $noNeedLogin = ['*'];

    protected $layout = '';


    public function _initialize() {
        parent::_initialize(); // TODO: Change the autogenerated stub


    }




    public function index() {

        $params = json_decode(base64_decode($this->request->param('data')), true);
        if($params['hm_type'] == 'goods'){
//            echo $params['out_trade_no'];die;
            $order = db::name('goods_order')->where(['out_trade_no' => $params['out_trade_no']])->find();
        }
        if($params['hm_type'] == 'recharge'){
            $order = db::name('recharge_order')->where(['out_trade_no' => $params['out_trade_no']])->find();
        }

//        echo $this->scan_template;die;
        $plugin_path = ROOT_PATH . "content/" . $this->scan_template;
        $info = include_once "{$plugin_path}/setting.php";

//        var_dump($order);die;

//        echo '<pre>'; print_r($params);die;

        $this->assign([
            'order' => $order,
            'pay_code' => urlencode($params['qr_code']),
            'plugin_info' => $info,
            'params' => $params,
            'user' => $this->user
        ]);
        return view($this->scan_template . '/index');
    }







}
