first commit
This commit is contained in:
58
app/Http/Controllers/TestController.php
Normal file
58
app/Http/Controllers/TestController.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Api\Controllers\ApiResponse;
|
||||
use App\Models\User;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
// use Wo;
|
||||
|
||||
class TestController
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->user = User::find(3);
|
||||
$ret = [
|
||||
'redemptionCode' => '951117396307',
|
||||
'total' => 5,
|
||||
'outletId' => '2004011649602',
|
||||
];
|
||||
|
||||
return $this->success($ret);
|
||||
|
||||
dd();
|
||||
|
||||
$jsonData = json_encode($ret); //数据JSON化
|
||||
$ascdata = $this->keyasc($jsonData); //加密
|
||||
$addcode = sprintf("%08d", mt_rand(0, 99999999)); //随机code 验证签名用
|
||||
$sign = $this->keysign($ascdata, $addcode);
|
||||
|
||||
$data = [
|
||||
'server_id' => $this->user->server_id,
|
||||
'key' => $this->user->server_key,
|
||||
'addcode' => $addcode,
|
||||
'sign' => $sign,
|
||||
'data' => $ascdata,
|
||||
];
|
||||
|
||||
$res = self::http($data);
|
||||
dd($res);
|
||||
}
|
||||
|
||||
public function http($data)
|
||||
{
|
||||
$client = new Client();
|
||||
$response = $client->request('POST', 'http://pa.ysd-bs.com/api/V1/user/freezecoupon', ['form_params' => $data, 'http_errors' => false]);
|
||||
|
||||
$body = $response->getBody();
|
||||
$content = $body->getContents();
|
||||
dump($content);
|
||||
$result = json_decode($content, true);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user