<?php

namespace app\api\controller;

use app\admin\validate\tools\GenerateTableValidate;
use app\admin\logic\tools\GeneratorLogic;
use app\common\service\pay\PayService;
use app\common\service\wechat\WeChatMnpService;
use app\common\service\wechat\WeChatOaService;
use DateTime;
use Webman\Config;
use Webman\RedisQueue\Redis;
use Yansongda\Pay\Pay;
use Webman\Push\Api;

class IndexController extends BaseApiController
{
    public $notNeedLogin = ['index'];

    public function index()
    {
        $app=new WeChatMnpService();
       $a= $app->delivery('PF171564998868869065');
       d($a);
        $queue = 'send-mail';
        // 数据,可以直接传数组,无需序列化
        $data = ['to' => 'tom@gmail.com', 'content' => 'hello'];
        // 投递消息
        Redis::send($queue, $data);
        // 投递延迟消息,消息会在60秒后处理
        // Redis::send($queue, $data, 5);

        return json(['msg' =>create_password(123456, '11d3')]);
    }

    /**
     * @notes 下载文件
     */
    public function download()
    {
        $params = (new GenerateTableValidate())->goCheck('download');
        $result = GeneratorLogic::download($params['file']);
        if (false === $result) {
            return $this->fail(GeneratorLogic::getError() ?: '下载失败');
        }
        return response()->download($result, 'webman-curd.zip');
    }
}