一、open_basedir 不能再写 /tmp(7.4 池子把白名单收紧,Monolog/EasyWeChat 会抛异常)
- addons/shopro/library/Wechat.php:easywechat 日志改到 runtime/easywechat/
- addons/epay/library/Yansongda/Supports/Logger.php:epay 日志默认路径改到 runtime/epay/
- application/admin/library/traits/Backend.php:CSV 导入临时文件改到 runtime/temp/
二、implode 参数反序(7.4 起 E_DEPRECATED,TP5 会抛异常)
- application/api/controller/Datas.php
- application/index/controller/wms/Pda.php
- 另修正 Wms.php 中 1 处(拆分面单提示)
三、null 取下标(7.4 起 "Trying to access array offset on value of type null")
- 覆盖 71 个文件 135 行:find()/value()/json_decode()/redis get 等结果未判空即取下标处,
统一 (\['k'] ?? null) 兜底;foreach 目标用 ?? [];in_array/count 等数组参数用 ?? []
- 涉及 api/*、admin/shopro/*、addons/shopro/*、addons/epay/*、index/wms/* 等
四、嵌套三元未加括号(7.4 弃用)
- application/index/controller/wms/Wms.php getPackingprice 2 处,补括号后与旧版本解析顺序一致
验证:74 个文件、148 行改动,逐行括号/引号配平与 HEAD 一致,未改动 vendor/ 与 thinkphp/;
剩余扫描命中均为写目标、unset、或已被 if(!\){error()} 拦截的假阳性。
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
219 lines
6.7 KiB
PHP
219 lines
6.7 KiB
PHP
<?php
|
||
|
||
namespace addons\epay\controller;
|
||
|
||
use addons\epay\library\Service;
|
||
use addons\epay\library\Wechat;
|
||
use addons\third\model\Third;
|
||
use app\common\library\Auth;
|
||
use think\addons\Controller;
|
||
use think\Response;
|
||
use think\Session;
|
||
use Yansongda\Pay\Exceptions\GatewayException;
|
||
use Yansongda\Pay\Pay;
|
||
|
||
/**
|
||
* API接口控制器
|
||
*
|
||
* @package addons\epay\controller
|
||
*/
|
||
class Api extends Controller
|
||
{
|
||
|
||
protected $layout = 'default';
|
||
protected $config = [];
|
||
|
||
/**
|
||
* 默认方法
|
||
*/
|
||
public function index()
|
||
{
|
||
return;
|
||
}
|
||
|
||
/**
|
||
* 外部提交
|
||
*/
|
||
public function submit()
|
||
{
|
||
$this->request->filter('trim');
|
||
$out_trade_no = $this->request->request("out_trade_no");
|
||
$title = $this->request->request("title");
|
||
$amount = $this->request->request('amount');
|
||
$type = $this->request->request('type');
|
||
$method = $this->request->request('method', 'web');
|
||
$openid = $this->request->request('openid', '');
|
||
$auth_code = $this->request->request('auth_code', '');
|
||
$notifyurl = $this->request->request('notifyurl', '');
|
||
$returnurl = $this->request->request('returnurl', '');
|
||
|
||
if (!$amount || $amount < 0) {
|
||
$this->error("支付金额必须大于0");
|
||
}
|
||
|
||
if (!$type || !in_array($type, ['alipay', 'wechat'])) {
|
||
$this->error("支付类型错误");
|
||
}
|
||
|
||
$params = [
|
||
'type' => $type,
|
||
'out_trade_no' => $out_trade_no,
|
||
'title' => $title,
|
||
'amount' => $amount,
|
||
'method' => $method,
|
||
'openid' => $openid,
|
||
'auth_code' => $auth_code,
|
||
'notifyurl' => $notifyurl,
|
||
'returnurl' => $returnurl,
|
||
];
|
||
return Service::submitOrder($params);
|
||
}
|
||
|
||
/**
|
||
* 微信支付(公众号支付&PC扫码支付)
|
||
* @return string
|
||
*/
|
||
public function wechat()
|
||
{
|
||
$config = Service::getConfig('wechat');
|
||
|
||
$isWechat = stripos($this->request->server('HTTP_USER_AGENT'), 'MicroMessenger') !== false;
|
||
$isMobile = $this->request->isMobile();
|
||
$this->view->assign("isWechat", $isWechat);
|
||
$this->view->assign("isMobile", $isMobile);
|
||
|
||
//发起PC支付(Scan支付)(PC扫码模式)
|
||
if ($this->request->isAjax()) {
|
||
$pay = Pay::wechat($config);
|
||
$orderid = $this->request->post("orderid");
|
||
try {
|
||
$result = $pay->find($orderid, 'scan');
|
||
if (($result['return_code'] ?? null)== 'SUCCESS' && ($result['result_code'] ?? null)== 'SUCCESS') {
|
||
$this->success("", "", ['status' => $result['trade_state']]);
|
||
} else {
|
||
$this->error("查询失败");
|
||
}
|
||
} catch (GatewayException $e) {
|
||
$this->error("查询失败");
|
||
}
|
||
}
|
||
|
||
$orderData = Session::get("wechatorderdata");
|
||
if (!$orderData) {
|
||
$this->error("请求参数错误");
|
||
}
|
||
if ($isWechat && $isMobile) {
|
||
//发起公众号(jsapi支付),openid必须
|
||
|
||
//如果没有openid,则自动去获取openid
|
||
if (!isset($orderData['openid']) || !$orderData['openid']) {
|
||
$orderData['openid'] = Service::getOpenid();
|
||
}
|
||
|
||
$orderData['method'] = 'mp';
|
||
$type = 'jsapi';
|
||
$payData = Service::submitOrder($orderData);
|
||
if (!isset($payData['paySign'])) {
|
||
$this->error("创建订单失败,请返回重试", "");
|
||
}
|
||
} else {
|
||
$orderData['method'] = 'scan';
|
||
$type = 'pc';
|
||
$payData = Service::submitOrder($orderData);
|
||
if (!isset($payData['code_url'])) {
|
||
$this->error("创建订单失败,请返回重试", "");
|
||
}
|
||
}
|
||
$this->view->assign("orderData", $orderData);
|
||
$this->view->assign("payData", $payData);
|
||
$this->view->assign("type", $type);
|
||
|
||
$this->view->assign("title", "微信支付");
|
||
return $this->view->fetch();
|
||
}
|
||
|
||
/**
|
||
* 支付宝支付(PC扫码支付)
|
||
* @return string
|
||
*/
|
||
public function alipay()
|
||
{
|
||
$config = Service::getConfig('alipay');
|
||
|
||
$isWechat = stripos($this->request->server('HTTP_USER_AGENT'), 'MicroMessenger') !== false;
|
||
$isMobile = $this->request->isMobile();
|
||
$this->view->assign("isWechat", $isWechat);
|
||
$this->view->assign("isMobile", $isMobile);
|
||
|
||
if ($this->request->isAjax()) {
|
||
$orderid = $this->request->post("orderid");
|
||
$pay = Pay::alipay($config);
|
||
try {
|
||
$result = $pay->find($orderid, 'scan');
|
||
if (($result['code'] ?? null)== '10000' && ($result['trade_status'] ?? null)== 'TRADE_SUCCESS') {
|
||
$this->success("", "", ['status' => $result['trade_status']]);
|
||
} else {
|
||
$this->error("查询失败");
|
||
}
|
||
} catch (GatewayException $e) {
|
||
$this->error("查询失败");
|
||
}
|
||
}
|
||
|
||
//发起PC支付(Scan支付)(PC扫码模式)
|
||
$orderData = Session::get("alipayorderdata");
|
||
if (!$orderData) {
|
||
$this->error("请求参数错误");
|
||
}
|
||
|
||
$orderData['method'] = 'scan';
|
||
$payData = Service::submitOrder($orderData);
|
||
if (!isset($payData['qr_code'])) {
|
||
$this->error("创建订单失败,请返回重试");
|
||
}
|
||
|
||
$type = 'pc';
|
||
$this->view->assign("orderData", $orderData);
|
||
$this->view->assign("payData", $payData);
|
||
$this->view->assign("type", $type);
|
||
$this->view->assign("title", "支付宝支付");
|
||
return $this->view->fetch();
|
||
}
|
||
|
||
/**
|
||
* 支付成功回调
|
||
*/
|
||
public function notifyx()
|
||
{
|
||
$type = $this->request->param('type');
|
||
$pay = \addons\epay\library\Service::checkNotify($type);
|
||
if (!$pay) {
|
||
echo '签名错误';
|
||
return;
|
||
}
|
||
$data = $pay->verify();
|
||
|
||
//你可以在这里你的业务处理逻辑,比如处理你的订单状态、给会员加余额等等功能
|
||
//下面这句必须要执行,且在此之前不能有任何输出
|
||
return $pay->success()->send();
|
||
}
|
||
|
||
/**
|
||
* 支付成功返回
|
||
*/
|
||
public function returnx()
|
||
{
|
||
$type = $this->request->param('type');
|
||
if (Service::checkReturn($type)) {
|
||
echo '签名错误';
|
||
return;
|
||
}
|
||
|
||
//你可以在这里定义你的提示信息,但切记不可在此编写逻辑
|
||
$this->success("恭喜你!支付成功!", addon_url("epay/index/index"));
|
||
|
||
return;
|
||
}
|
||
|
||
}
|