fix: 修复汇付插件启用状态、支付钩子注册与部署脚本平滑重载
这个提交包含在:
@@ -154,7 +154,7 @@ class PayService
|
||||
}
|
||||
|
||||
if ((new \addons\shopro\library\split\Config())->isEnable()) {
|
||||
$order['settle_info'] = ['profit_sharing' => true];
|
||||
$order['profit_sharing'] = 'Y';
|
||||
}
|
||||
|
||||
$order['total_fee'] = $order['total_fee'] * 100;
|
||||
|
||||
@@ -4,7 +4,7 @@ intro = 汇付斗拱小程序微信支付与延时分账插件
|
||||
author = Shopro
|
||||
website = https://paas.huifu.com
|
||||
version = 1.0.0
|
||||
state = 0
|
||||
state = 1
|
||||
url = /addons/shopro_huifu
|
||||
first_menu = shopro_huifu/config
|
||||
license = regular
|
||||
|
||||
@@ -29,10 +29,33 @@ return [
|
||||
],
|
||||
'app_init' => [
|
||||
'shopro',
|
||||
'shopro_huifu',
|
||||
'shopro_wechat_trade',
|
||||
],
|
||||
'config_init' => [
|
||||
'summernote',
|
||||
],
|
||||
'shopro_pay_create' => [
|
||||
'addons\\shopro_huifu\\listener\\PayCreateHook',
|
||||
],
|
||||
'shopro_pay_refund' => [
|
||||
'addons\\shopro_huifu\\listener\\RefundHook',
|
||||
],
|
||||
'shopro_split_execute' => [
|
||||
'addons\\shopro_huifu\\listener\\SplitHook',
|
||||
],
|
||||
'shopro_commission_apply_after' => [
|
||||
'addons\\shopro_huifu\\listener\\CommissionApplyHook',
|
||||
],
|
||||
'shopro_regional_agent_apply_after' => [
|
||||
'addons\\shopro_huifu\\listener\\RegionalAgentApplyHook',
|
||||
],
|
||||
'order_send_after' => [
|
||||
'addons\\shopro_wechat_trade\\listener\\ShippingHook',
|
||||
],
|
||||
'order_confirm_after' => [
|
||||
'addons\\shopro_wechat_trade\\listener\\ConfirmHook',
|
||||
],
|
||||
],
|
||||
'route' => [],
|
||||
'priority' => [],
|
||||
|
||||
@@ -41,6 +41,12 @@ fi
|
||||
chmod -R 777 runtime 2>/dev/null || true
|
||||
chmod -R 775 public/uploads 2>/dev/null || true
|
||||
|
||||
# 平滑重载 PHP-FPM 刷新 OPcache 字节码缓存
|
||||
if [ -x "/etc/init.d/php-fpm-73" ]; then
|
||||
echo "[${DATE}] 平滑重载 PHP-FPM 7.3..." >> "${LOG_FILE}"
|
||||
/etc/init.d/php-fpm-73 reload >> "${LOG_FILE}" 2>&1 || true
|
||||
fi
|
||||
|
||||
COMMIT_INFO=$(git log -1 --pretty=format:"%h - %s (%an, %cd)")
|
||||
echo "[${DATE}] 当前最新版本: ${COMMIT_INFO}" >> "${LOG_FILE}"
|
||||
echo "[${DATE}] >>> 部署成功完成" >> "${LOG_FILE}"
|
||||
|
||||
93
tests/HuifuBridgeTest.php
普通文件
93
tests/HuifuBridgeTest.php
普通文件
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* 汇付支付与分账桥接状态单元测试 (TDD)
|
||||
*/
|
||||
|
||||
class HuifuBridgeTest
|
||||
{
|
||||
private $passed = 0;
|
||||
private $failed = 0;
|
||||
|
||||
public function run()
|
||||
{
|
||||
echo "=== 开始执行 汇付支付与桥接单元测试 (TDD) ===\n";
|
||||
$this->testInfoIniStateEnabled();
|
||||
$this->testPayServiceProfitSharingParameter();
|
||||
$this->testDeployScriptContainsPhpFpmReload();
|
||||
$this->testAddonsHooksRegistered();
|
||||
|
||||
echo "\n测试结果: {$this->passed} 通过, {$this->failed} 失败\n";
|
||||
if ($this->failed > 0) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private function assert($condition, $message)
|
||||
{
|
||||
if ($condition) {
|
||||
echo " [PASS] {$message}\n";
|
||||
$this->passed++;
|
||||
} else {
|
||||
echo " [FAIL] {$message}\n";
|
||||
$this->failed++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 addons/shopro_huifu/info.ini 中 state 必须为 1
|
||||
*/
|
||||
public function testInfoIniStateEnabled()
|
||||
{
|
||||
$iniPath = __DIR__ . '/../addons/shopro_huifu/info.ini';
|
||||
$this->assert(is_file($iniPath), "info.ini 必须存在: {$iniPath}");
|
||||
|
||||
$info = parse_ini_file($iniPath);
|
||||
$state = $info['state'] ?? null;
|
||||
$this->assert($state === '1' || $state === 1, "shopro_huifu 插件 state 必须为 1 (启用),当前为: " . var_export($state, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 PayService.php 中不能向 Yansongda v2 传递 settle_info 数组,避免 Array to string conversion 报错
|
||||
*/
|
||||
public function testPayServiceProfitSharingParameter()
|
||||
{
|
||||
$payServicePath = __DIR__ . '/../addons/shopro/library/PayService.php';
|
||||
$this->assert(is_file($payServicePath), "PayService.php 必须存在");
|
||||
|
||||
$content = file_get_contents($payServicePath);
|
||||
$hasSettleInfoArray = strpos($content, "\$order['settle_info'] = ['profit_sharing' => true]") !== false;
|
||||
$this->assert(!$hasSettleInfoArray, "PayService 中不能包含 settle_info 数组赋值 (会导致 Yansongda v2 XML 序列化报 Array to string conversion)");
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 deploy.sh 部署脚本中必须包含 php-fpm reload 命令刷新 OPcache
|
||||
*/
|
||||
public function testDeployScriptContainsPhpFpmReload()
|
||||
{
|
||||
$deployScriptPath = __DIR__ . '/../deploy.sh';
|
||||
$this->assert(is_file($deployScriptPath), "deploy.sh 脚本必须存在");
|
||||
|
||||
$content = file_get_contents($deployScriptPath);
|
||||
$hasReload = strpos($content, 'php-fpm-73 reload') !== false || strpos($content, 'php-fpm reload') !== false;
|
||||
$this->assert($hasReload, "deploy.sh 部署脚本必须包含 php-fpm reload 刷新 OPcache");
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 application/extra/addons.php 中必须注册 shopro_huifu 及 shopro_pay_create 钩子
|
||||
*/
|
||||
public function testAddonsHooksRegistered()
|
||||
{
|
||||
$addonsPath = __DIR__ . '/../application/extra/addons.php';
|
||||
$this->assert(is_file($addonsPath), "addons.php 必须存在");
|
||||
|
||||
$addons = require $addonsPath;
|
||||
$appInit = $addons['hooks']['app_init'] ?? [];
|
||||
$this->assert(in_array('shopro_huifu', $appInit), "addons.php app_init 必须包含 shopro_huifu");
|
||||
|
||||
$payCreate = $addons['hooks']['shopro_pay_create'] ?? [];
|
||||
$this->assert(!empty($payCreate), "addons.php 必须注册 shopro_pay_create 钩子");
|
||||
}
|
||||
}
|
||||
|
||||
$test = new HuifuBridgeTest();
|
||||
$test->run();
|
||||
在新工单中引用
屏蔽一个用户