Files
oil/server-tp6/app/api/controller/SybNotify.php
T
2026-09-01 22:15:50 +08:00

162 lines
7.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | 管理系统
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.zizai.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 自在科技
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\api\controller;
use app\api\model\Company as CompanyModel;
use app\store\model\User as UserModel;
use app\common\crypto\Crypto;
use app\common\service\SybOil;
use app\store\model\card\CardLog as CardLogModel;
use think\facade\Db;
use think\facade\Request;
use app\common\service\QueueService;
/**
* 加油e卡通通知接口
* Class SybNotify
* @package app\api\controller
*/
class SybNotify extends Controller
{
public function yanzheng()
{
// 拿到队列数据处理
$data = json_decode('{"header":{"content-length":"428","connection":"keep-alive","host":"139.129.21.253","pragma":"no-cache","cache-control":"no-cache","content-type":"application/json;charset=UTF-8","version":"1.0.0","accept-language":"zh-CN,zh;q=0.8","accept-encoding":"gzip, deflate","appkey":"qlv4l3law1","sign":"R9A4Zw5/52bq2gsmaxGMt7QcSPr9RWuxSp40D36VKSeS8uZfifTD/Yknzt6uVZn5G5rhEgDumFiLo7A/eAgo5u/tA+AMizZ3sHHv7mu0dLPO8b9LUdf01I7nxYqyqPatnNJGIgq6dTZyyNdE4YaTEShemnlEC/XI9O1T29obpt8=","user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36 Hutool","requestid":"8232721b-ef72-40a7-aa24-bdbb536fd602","method":"syb.notify.oilCard.share","accept":"text/html,application/json,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"},"res":{"shareNo":"CDV2408082020420001","amount":"200.00","saleOrderNo":"2024080897521014","oilCardType":"zsy_ticket","oilCardNo":"CDV2408082020420001","status":"success"}}', true);
$headers = $data['header'];
$res = $data['res'];
// 存入队列处理
$queueService = new QueueService();
$queueService->push('callback_queue', json_encode(['header'=>$headers,'res'=>$res],320));
}
/** 通知接口
* @return array|mixed|string[]
*/
public function notifyOld()
{
// 获取所有 HTTP 请求头
$headers = Request::header();
// 获取 JSON 格式的请求体
$jsonData = Request::instance()->getContent();
$data = json_decode($jsonData, true);
$this->saveLog('callback_queue回调加密参数原文;header:'.json_encode($headers).',body:'.$jsonData);
$appKey = $headers['appKey'] ?? $headers['appkey'];
$company = CompanyModel::detail(['appKey' => $appKey]);
$crypto = new Crypto($company);
$res = $crypto->processResponse(['header'=>$headers,'encryptData'=>$data]);
// 记录日志等
$this->saveLog('callback_queue回调参数解密,'.$headers['method'].":".json_encode($res,320));
// 检查 JSON 解码是否成功
if (!$res) {
return json(['code' => '03', 'message' => '报文解密异常']);
}
// 存入队列处理
$queueService = new QueueService();
$queueService->push('callback_queue', json_encode(['header'=>$headers,'res'=>$res],320));
// 返回成功的 JSON 响应
return json(['code' => '00', 'message' => '请求成功']);
}
/** 分油下单回到
* @return string
*/
public function notify()
{
// 获取所有 HTTP 请求头
$headers = Request::header();
// 获取 GET 参数
$data = Request::param();
$this->saveLog('callback_queue回调参数原文;header:'.json_encode($headers).',body:'.json_encode($data));
/*$appKey = $headers['appKey'] ?? $headers['appkey'];
$company = CompanyModel::detail(['appKey' => $appKey]);
$crypto = new Crypto($company);
$res = $crypto->processResponse(['header'=>$headers,'encryptData'=>$data]);
// 记录日志等
$this->saveLog('callback_queue回调参数解密,'.$headers['method'].":".json_encode($res,320));
// 检查 JSON 解码是否成功
if (!$res) {
return json(['code' => '03', 'message' => '报文解密异常']);
}*/
$headers['method'] = 'oil';
// 存入队列处理
$queueService = new QueueService();
$queueService->push('callback_queue', json_encode(['header'=>$headers,'res'=>$data],320));
// 返回成功的 JSON 响应
return 'OK';
}
/** 使用结果回调
* @return string
*/
public function use()
{
// 获取所有 HTTP 请求头
$headers = Request::header();
// 获取 GET 参数
$data = Request::param();
$this->saveLog('callback_queue回调参数原文;header:'.json_encode($headers).',body:'.json_encode($data));
/*$appKey = $headers['appKey'] ?? $headers['appkey'];
$company = CompanyModel::detail(['appKey' => $appKey]);
$crypto = new Crypto($company);
$res = $crypto->processResponse(['header'=>$headers,'encryptData'=>$data]);
// 记录日志等
$this->saveLog('callback_queue回调参数解密,'.$headers['method'].":".json_encode($res,320));
// 检查 JSON 解码是否成功
if (!$res) {
return json(['code' => '03', 'message' => '报文解密异常']);
}*/
$headers['method'] = 'use';
// 存入队列处理
$queueService = new QueueService();
$queueService->push('callback_queue', json_encode(['header'=>$headers,'res'=>$data],320));
// 返回成功的 JSON 响应
return 'OK';
}
/** 分油下单回到
* @return string
*/
public function partnersNotify()
{
// 获取所有 HTTP 请求头
$headers = Request::header();
// 获取 GET 参数
$data = Request::param();
$this->saveLog('callback_queue回调参数原文;header:'.json_encode($headers).',body:'.json_encode($data));
$headers['method'] = 'oil_partners';
// 存入队列处理
$queueService = new QueueService();
$queueService->push('callback_queue', json_encode(['header'=>$headers,'res'=>$data],320));
// 返回成功的 JSON 响应
return 'OK';
}
/** 使用结果回调
* @return string
*/
public function partnersUse()
{
// 获取所有 HTTP 请求头
$headers = Request::header();
// 获取 GET 参数
$data = Request::param();
$this->saveLog('callback_queue回调参数原文;header:'.json_encode($headers).',body:'.json_encode($data));
$headers['method'] = 'use_partners';
// 存入队列处理
$queueService = new QueueService();
$queueService->push('callback_queue', json_encode(['header'=>$headers,'res'=>$data],320));
// 返回成功的 JSON 响应
return 'OK';
}
}