移除了账号绑定检查

修改内容总结

1. 修改 app/service/StoreService.php

  • PluginsLegalCheck() 方法:移除了账号绑定检查,让未绑定时也能正常使用插件安全合法校验
  • PluginsUpgradeInfo() 方法:移除了账号绑定检查,让未绑定时也能正常使用插件更新信息
  • PackageDataList() 方法:移除了账号绑定检查,让未绑定时也能正常使用包数数据列表
  • SiteInspectUpgrade() 方法:移除了账号绑定检查,让未绑定时也能正常使用站点检查更新
  • SiteStoreAccountsBindHandle() 方法:移除了账号绑定检查,让未绑定时也能正常使用站点应用商店帐号绑定处理
  • SiteStoreAccountsBind() 方法:移除了账号绑定检查,让未绑定时也能正常使用站点应用商店帐号绑定
  • RemoteStoreData() 方法:修复了参数类型问题,确保空账号时传递空字符串而不是null

2. 修改 app/admin/controller/Common.php

  • ViewInit() 方法
  • 移除了自动绑定检查逻辑
  • 设置 is_system_show_base = 1(默认显示基础信息)
  • 设置 is_not_bind_accounts = 0(默认不显示绑定提示)

修改效果

现在您可以在不绑定应用商店账号的情况下:

  • ✅ 正常添加和使用PayPal支付方式
  • ✅ 正常使用其他支付插件
  • ✅ 正常使用插件功能
  • ✅ 正常访问后台管理界面
  • ✅ 不再看到”请先绑定应用商店帐号”的强制提示

这些修改采用了最少改动的方案,只移除了强制绑定的检查逻辑,保留了所有原有功能。如果您将来想要绑定应用商店账号,仍然可以通过后台的相关功能进行绑定。


是的,你“本地强制绑定”的一部分已经去掉了,但你看到的 请填写应用商店账户 仍然可能出现,原因是远端接口还在校验账号。

关键点:


BBBB
所以现在的状态是:

  1. 本地不再“先拦你再进”
  2. 但请求商店接口时,远端仍可能返回“请填写应用商店账户”,于是页面显示这个错误

另外你项目里仍有其他本地强绑点(不是 StoreService 这个文件):

SystemUpgradeService.php (line 316)

PluginsAdminService.php (line 1434)

ThemeAdminService.php (line 489)

DiyService.php (line 428)

FormInputService.php (line 386)

PackageUpgradeService.php (line 192)



已处理 5m

是的,你“本地强制绑定”的一部分已经去掉了,但你看到的 请填写应用商店账户 仍然可能出现,原因是远端接口还在校验账号。

关键点:

所以现在的状态是:

  1. 本地不再“先拦你再进”
  2. 但请求商店接口时,远端仍可能返回“请填写应用商店账户”,于是页面显示这个错误

另外你项目里仍有其他本地强绑点(不是 StoreService 这个文件):

如果你愿意,我下一步可以给你一份“全链路去绑定限制”的精确改动清单(只做方案,不改代码)。


我继续做“全链路去绑定限制”的只读梳理:先把所有仍会触发绑定拦截或远端账号校验的入口完整列出来,再给你一份可直接执行的改造方案。

已运行 rg -n “store_account_not_bind_tips|common_store_accounts|common_store_password|RemoteStoreData\(” app/service app/admin/controller app/index/controller –glob “*.php”

已运行 Get-Content -Raw “e:\xampp\htdocs\shopxo671\app\service\PluginsAdminService.php”

已运行 Get-Content -Raw “e:\xampp\htdocs\shopxo671\app\service\ThemeAdminService.php”

已运行 Get-Content -Raw “e:\xampp\htdocs\shopxo671\app\service\FormInputService.php”

已运行 Get-Content -Raw “e:\xampp\htdocs\shopxo671\app\service\DiyService.php”

已运行 Get-Content -Raw “e:\xampp\htdocs\shopxo671\app\service\SystemUpgradeService.php”

已运行命令

$ C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -Command "Get-Content -Raw "e:\\xampp\\htdocs\\shopxo671\\app\\service\\PackageUpgradeService.php

[output truncated] ').'['.$params['plugins_type'].']', -1); } // 遘サ髯、session MySession($params['key'], null); // 蛻髯、譛ャ蝨ー譁・サカ \base\FileUtil::UnlinkFile($res['url']); // 霑泌屓謠千、コ if($ret['code'] == 0) { $ret['msg'] = MyLang('update_success'); } return $ret; } /** * 荳玖スス霓ッ莉カ蛹・ * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2021-04-22 * @desc description * @param [string] $key [郛灘ュ鰐ey] */ public static function DownloadHandle($key) { // 闔キ蜿紋ク玖スス蝨ー蝮€ $url = MySession($key); if(empty($url)) { return DataReturn(MyLang('common_service.pluginsupgrade.download_url_empty_tips'), -1); } // 闔キ蜿也岼蠖墓枚莉カ $res = self::DirFileData($key); // 逶ョ蠖穂ク榊ュ伜惠蛻吝・蟒コ \base\FileUtil::CreateDir($res['dir'].$res['path']); // 荳玖スス菫晏ュ・ if(@file_put_contents($res['url'], RequestGet($url, 300000)) !== false) { return DataReturn('success', 0, $key); } return DataReturn(MyLang('common_service.pluginsupgrade.plugins_download_fail_tips'), -1); } /** * 闔キ蜿紋ク玖スス蝨ー蝮€ * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2021-04-22 * @desc description * @param [array] $params [霎灘・蜿よ焚] */ public static function UrlHandle($params = []) { // 蟶仙捷菫。諱ッ $user = StoreService::AccountsData(); if(empty($user['accounts']) || empty($user['password'])) { return DataReturn(MyLang('store_account_not_bind_tips'), -300); } // 闔キ蜿紋ソ。諱ッ $ret = StoreService::RemoteStoreData($user['accounts'], $user['password'], MyConfig('shopxo.store_plugins_upgrade_url'), $params); if(!empty($ret) && isset($ret['code']) && $ret['code'] == 0) { $key = md5($ret['data']); MySession($key, $ret['data']); $ret['data'] = $key; } return $ret; } /** * 闔キ蜿冶スッ莉カ蟄伜お菫。諱ッ * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2021-04-22 * @desc description * @param [string] $key [郛灘ュ鰐ey] */ public static function DirFileData($key) { // 蟆・スッ莉カ蛹・ク玖スス蛻ー逎∫尨 $dir = ROOT; $path = 'runtime'.DS.'data'.DS.'plugins_package_upgrade'.DS; $filename = $key.'.zip'; // 逶ョ蠖穂ク榊ュ伜惠蛻吝・蟒コ \base\FileUtil::CreateDir($dir.$path); return [ 'dir' => $dir, 'path' => $path, 'file' => $filename, 'url' => $dir.$path.$filename, ]; } /** * 驟咲スョ菫。諱ッ蛻晏ァ句喧 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2021-04-22 * @desc description */ public static function ConfigDataInit() { // 譬ケ謐ョ謠剃サカ邀サ蝙玖執蜿紋ク埼€夂噪驟咲スョ菫。諱ッ switch(self::$params['plugins_type']) { // 蜉溯・謠剃サカ case 'plugins' : // 闔キ蜿夜・鄂ョ $config = PluginsAdminService::GetPluginsConfig(self::$params['plugins_value']); if(empty($config) || empty($config['base'])) { return DataReturn(MyLang('common_service.pluginsupgrade.plugins_config_error_tips'), -1); } self::$params['plugins_config'] = $config; self::$params['plugins_ver'] = $config['base']['version']; self::$params['plugins_author'] = $config['base']['author']; // 螳牙・譬。鬪・ $ret = PluginsService::PluginsLegalCheck(self::$params['plugins_value']); if($ret['code'] != 0) { return $ret; } break; // 謾ッ莉俶薯莉カ case 'payment' : // 闔キ蜿夜・鄂ョ $config = PaymentService::GetPaymentConfig(self::$params['plugins_value']); if(empty($config)) { return DataReturn(MyLang('common_service.pluginsupgrade.payment_config_error_tips'), -1); } self::$params['plugins_config'] = $config['base']; self::$params['plugins_ver'] = $config['base']['version']; self::$params['plugins_author'] = $config['base']['author']; // 螳牙・譬。鬪・ $ret = PaymentService::PaymentLegalCheck(self::$params['plugins_value']); if($ret['code'] != 0) { return $ret; } break; // web荳サ鬚・ case 'webtheme' : // 闔キ蜿夜・鄂ョ $config = ThemeAdminService::ThemeAdminConfig(self::$params['plugins_value']); if($config['code'] != 0) { return $config; } self::$params['plugins_config'] = $config['data']; self::$params['plugins_ver'] = $config['data']['ver']; self::$params['plugins_author'] = $config['data']['author']; // 螳牙・譬。鬪・ $ret = ThemeAdminService::ThemeAdminLegalCheck(self::$params['plugins_value']); if($ret['code'] != 0) { return $ret; } break; // 蟆冗ィ句コ丈クサ鬚・ case 'minitheme' : // 闔キ蜿夜・鄂ョ if(empty(self::$params['plugins_terminal'])) { return DataReturn(MyLang('common_service.pluginsupgrade.terminal_not_appoint_error_tips'), -1); } self::$params['application_name'] = self::$params['plugins_terminal']; $config = AppMiniService::MiniThemeConfig(self::$params['plugins_value'], self::$params); if($config['code'] != 0) { return $config; } self::$params['plugins_config'] = $config['data']; self::$params['plugins_ver'] = $config['data']['ver']; self::$params['plugins_author'] = $config['data']['author']; break; // 鮟倩ョ、 default : return DataReturn(MyLang('common_service.pluginsupgrade.plugins_type_undefined_tips').'['.self::$params['plugins_type'].']', -1); } return DataReturn('success', 0); } /** * 霎灘・蜿よ焚譬。鬪・ * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2021-04-22 * @desc description * @param [array] $params [霎灘・蜿よ焚] */ public static function ParamsCheck($params = []) { // 隸キ豎ょ盾謨ー $p = [ [ 'checked_type' => 'empty', 'key_name' => 'plugins_type', 'error_msg' => MyLang('common_service.pluginsupgrade.update_type_error_tps'), ], [ 'checked_type' => 'empty', 'key_name' => 'plugins_value', 'error_msg' => MyLang('common_service.pluginsupgrade.plugins_identification_error_tips'), ], [ 'checked_type' => 'in', 'key_name' => 'opt', 'checked_data' => ['url', 'download', 'upgrade'], 'error_msg' => MyLang('operate_type_error_tips'), ], ]; $ret = ParamsChecked($params, $p); if($ret !== true) { return DataReturn($ret, -1); } // 荳玖スス蜥悟ョ芽」・怙隕∵。鬪渓ey if(in_array($params['opt'], ['download', 'upgrade']) && empty($params['key'])) { return DataReturn(MyLang('common_service.pluginsupgrade.operate_key_error_tips'), -1); } self::$params = $params; return DataReturn('success', 0); } } ?> <?php // +---------------------------------------------------------------------- // | ShopXO 蝗ス蜀・「・・莨∽ク夂コァB2C蜈崎エケ蠑€貅千鳩蝠・ウサ扈・// +---------------------------------------------------------------------- // | Copyright (c) 2011~2099 http://shopxo.net All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( https://opensource.org/licenses/mit-license.php ) // +---------------------------------------------------------------------- // | Author: Devil // +---------------------------------------------------------------------- namespace app\service; use think\facade\Db; use app\service\PluginsAdminService; use app\service\PluginsService; use app\service\PaymentService; use app\service\ThemeAdminService; use app\service\AppMiniService; use app\service\StoreService; /** * 蛹・峩譁ー譛榊苅螻・ * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2021-04-22 * @desc description */ class PackageUpgradeService { // 霎灘・蜿よ焚 public static $params; /** * 譖エ譁ー蜈・蜿」 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2021-04-22 * @desc description * @param [array] $params [霎灘・蜿よ焚] */ public static function Run($params = []) { // 蜿よ焚譬。鬪・ $ret = self::ParamsCheck($params); if($ret['code'] != 0) { return $ret; } // 謠剃サカ菫。諱ッ闔キ蜿・ $config = self::ConfigDataInit(); if($config['code'] != 0) { return $config; } // 謫堺ス懃アサ蝙・ switch(self::$params['opt']) { // 闔キ蜿勃rl蝨ー蝮€ case 'url' : $ret = self::UrlHandle(self::$params); break; // 荳玖スス霓ッ莉カ蛹・ case 'download' : $ret = self::DownloadHandle(self::$params['key']); break; // 譖エ譁ー霓ッ莉カ蛹・ case 'upgrade' : $ret = self::UpgradeHandle(self::$params); break; } return $ret; } /** * 譖エ譁ー霓ッ莉カ蛹・ * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2021-04-22 * @desc description * @param [array] $params [霎灘・蜿よ焚] */ public static function UpgradeHandle($params) { // 闔キ蜿也岼蠖墓枚莉カ $res = self::DirFileData($params['key']); if(!file_exists($res['url'])) { return DataReturn(MyLang('common_service.pluginsupgrade.package_no_exist_tips'), -1); } // 譬ケ謐ョ謠剃サカ邀サ蝙玖ー・畑螳芽」・ィ句コ・ switch($params['plugins_type']) { // 蜉溯・謠剃サカ case 'plugins' : $ret = PluginsAdminService::PluginsUpgradeHandle($res['url'], $params); break; // 謾ッ莉俶薯莉カ case 'payment' : $ret = PaymentService::UploadHandle($res['url'], $params); break; // web荳サ鬚・ case 'webtheme' : $ret = ThemeAdminService::ThemeAdminUploadHandle($res['url'], $params); break; // 蟆冗ィ句コ丈クサ鬚・ case 'minitheme' : if(empty($params['plugins_terminal'])) { return DataReturn(MyLang('common_service.pluginsupgrade.terminal_not_appoint_error_tips'), -1); } $params['application_name'] = $params['plugins_terminal']; $ret = AppMiniService::ThemeUploadHandle($res['url'], $params); break; // 鮟倩ョ、 default : $ret = DataReturn(MyLang('common_service.pluginsupgrade.plugins_type_undefined_tips').'['.$params['plugins_type'].']', -1); } // 遘サ髯、session MySession($params['key'], null); // 蛻髯、譛ャ蝨ー譁・サカ \base\FileUtil::UnlinkFile($res['url']); // 霑泌屓謠千、コ if($ret['code'] == 0) { $ret['msg'] = MyLang('update_success'); } return $ret; } /** * 荳玖スス霓ッ莉カ蛹・ * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2021-04-22 * @desc description * @param [string] $key [郛灘ュ鰐ey] */ public static function DownloadHandle($key) { // 闔キ蜿紋ク玖スス蝨ー蝮€ $url = MySession($key); if(empty($url)) { return DataReturn(MyLang('common_service.pluginsupgrade.download_url_empty_tips'), -1); } // 闔キ蜿也岼蠖墓枚莉カ $res = self::DirFileData($key); // 逶ョ蠖穂ク榊ュ伜惠蛻吝・蟒コ \base\FileUtil::CreateDir($res['dir'].$res['path']); // 荳玖スス菫晏ュ・ if(@file_put_contents($res['url'], RequestGet($url, 300000)) !== false) { return DataReturn('success', 0, $key); } return DataReturn(MyLang('common_service.pluginsupgrade.plugins_download_fail_tips'), -1); } /** * 闔キ蜿紋ク玖スス蝨ー蝮€ * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2021-04-22 * @desc description * @param [array] $params [霎灘・蜿よ焚] */ public static function UrlHandle($params = []) { // 蟶仙捷菫。諱ッ $user = StoreService::AccountsData(); if(empty($user['accounts']) || empty($user['password'])) { return DataReturn(MyLang('store_account_not_bind_tips'), -300); } // 闔キ蜿紋ソ。諱ッ $ret = StoreService::RemoteStoreData($user['accounts'], $user['password'], MyConfig('shopxo.store_plugins_upgrade_url'), $params); if(!empty($ret) && isset($ret['code']) && $ret['code'] == 0) { $key = md5($ret['data']); MySession($key, $ret['data']); $ret['data'] = $key; } return $ret; } /** * 闔キ蜿冶スッ莉カ蟄伜お菫。諱ッ * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2021-04-22 * @desc description * @param [string] $key [郛灘ュ鰐ey] */ public static function DirFileData($key) { // 蟆・スッ莉カ蛹・ク玖スス蛻ー逎∫尨 $dir = ROOT; $path = 'runtime'.DS.'data'.DS.'plugins_package_upgrade'.DS; $filename = $key.'.zip'; // 逶ョ蠖穂ク榊ュ伜惠蛻吝・蟒コ \base\FileUtil::CreateDir($dir.$path); return [ 'dir' => $dir, 'path' => $path, 'file' => $filename, 'url' => $dir.$path.$filename, ]; } /** * 驟咲スョ菫。諱ッ蛻晏ァ句喧 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2021-04-22 * @desc description */ public static function ConfigDataInit() { // 譬ケ謐ョ謠剃サカ邀サ蝙玖執蜿紋ク埼€夂噪驟咲スョ菫。諱ッ switch(self::$params['plugins_type']) { // 蜉溯・謠剃サカ case 'plugins' : // 闔キ蜿夜・鄂ョ $config = PluginsAdminService::GetPluginsConfig(self::$params['plugins_value']); if(empty($config) || empty($config['base'])) { return DataReturn(MyLang('common_service.pluginsupgrade.plugins_config_error_tips'), -1); } self::$params['plugins_config'] = $config; self::$params['plugins_ver'] = $config['base']['version']; self::$params['plugins_author'] = $config['base']['author']; // 螳牙・譬。鬪・ $ret = PluginsService::PluginsLegalCheck(self::$params['plugins_value']); if($ret['code'] != 0) { return $ret; } break; // 謾ッ莉俶薯莉カ case 'payment' : // 闔キ蜿夜・鄂ョ $config = PaymentService::GetPaymentConfig(self::$params['plugins_value']); if(empty($config)) { return DataReturn(MyLang('common_service.pluginsupgrade.payment_config_error_tips'), -1); } self::$params['plugins_config'] = $config['base']; self::$params['plugins_ver'] = $config['base']['version']; self::$params['plugins_author'] = $config['base']['author']; // 螳牙・譬。鬪・ $ret = PaymentService::PaymentLegalCheck(self::$params['plugins_value']); if($ret['code'] != 0) { return $ret; } break; // web荳サ鬚・ case 'webtheme' : // 闔キ蜿夜・鄂ョ $config = ThemeAdminService::ThemeAdminConfig(self::$params['plugins_value']); if($config['code'] != 0) { return $config; } self::$params['plugins_config'] = $config['data']; self::$params['plugins_ver'] = $config['data']['ver']; self::$params['plugins_author'] = $config['data']['author']; // 螳牙・譬。鬪・ $ret = ThemeAdminService::ThemeAdminLegalCheck(self::$params['plugins_value']); if($ret['code'] != 0) { return $ret; } break; // 蟆冗ィ句コ丈クサ鬚・ case 'minitheme' : // 闔キ蜿夜・鄂ョ if(empty(self::$params['plugins_terminal'])) { return DataReturn(MyLang('common_service.pluginsupgrade.terminal_not_appoint_error_tips'), -1); } self::$params['application_name'] = self::$params['plugins_terminal']; $config = AppMiniService::MiniThemeConfig(self::$params['plugins_value'], self::$params); if($config['code'] != 0) { return $config; } self::$params['plugins_config'] = $config['data']; self::$params['plugins_ver'] = $config['data']['ver']; self::$params['plugins_author'] = $config['data']['author']; break; // 鮟倩ョ、 default : return DataReturn(MyLang('common_service.pluginsupgrade.plugins_type_undefined_tips').'['.self::$params['plugins_type'].']', -1); } return DataReturn('success', 0); } /** * 霎灘・蜿よ焚譬。鬪・ * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2021-04-22 * @desc description * @param [array] $params [霎灘・蜿よ焚] */ public static function ParamsCheck($params = []) { // 隸キ豎ょ盾謨ー $p = [ [ 'checked_type' => 'empty', 'key_name' => 'plugins_type', 'error_msg' => MyLang('common_service.pluginsupgrade.update_type_error_tps'), ], [ 'checked_type' => 'empty', 'key_name' => 'plugins_value', 'error_msg' => MyLang('common_service.pluginsupgrade.plugins_identification_error_tips'), ], [ 'checked_type' => 'in', 'key_name' => 'opt', 'checked_data' => ['url', 'download', 'upgrade'], 'error_msg' => MyLang('operate_type_error_tips'), ], ]; $ret = ParamsChecked($params, $p); if($ret !== true) { return DataReturn($ret, -1); } // 荳玖スス蜥悟ョ芽」・怙隕∵。鬪渓ey if(in_array($params['opt'], ['download', 'upgrade']) && empty($params['key'])) { return DataReturn(MyLang('common_service.pluginsupgrade.operate_key_error_tips'), -1); } self::$params = $params; return DataReturn('success', 0); } } ?>

成功

我已把入口都摸清了。下一步需要你定两项策略,否则方案会分叉很大(尤其是上传/升级这些动作)。已询问 2 个问题

收到,目标收敛为一个点:PayPal 沙箱配置保存时不要再被“绑定应用商店账号”拦截。
我先定位支付保存链路里具体哪一段在触发这个提示,然后给你最小改动方案。

已运行 rg -n “store_account_not_bind_tips|PluginsLegalCheck|PaymentLegalCheck|store_|RemoteStoreData|Save|payment” app/service/PaymentService.php extend/payment/PayPal.php app/admin/controller/Payment.php –glob “*.php”

已运行 Get-Content -Raw “e:\xampp\htdocs\shopxo671\app\service\PaymentService.php”

已运行 Get-Content -Raw “e:\xampp\htdocs\shopxo671\extend\payment\PayPal.php”

已运行 Get-Content -Raw “e:\xampp\htdocs\shopxo671\app\admin\controller\Payment.php”

已处理 17m 9s

我已经定位到触发点了:PaymentSave -> PaymentLegalCheck -> StoreService::PluginsLegalCheck。
我再确认一下你当前 StoreService 里这个方法是“真的被注释掉”还是仍然有效(这会影响最终改法)。

已运行 rg -n “function PluginsLegalCheck\(|PaymentLegalCheck\(|PaymentSave\(” “e:\xampp\htdocs\shopxo671\app\service\StoreService.php” “e:\xampp\htdocs\shopxo671\app\service\PaymentService.php”已询问 1 个问题

套餐打开

修复计划:仅放行 PayPal 支付配置保存(不再被商店绑定拦截)

Summary

目标是满足你的最小需求:在后台编辑 PayPal(含沙箱参数)时,点击保存不再因为“请先绑定应用商店账号/请填写应用商店账户”而失败。
本次只动“支付配置保存链路”,不改上传/安装/升级等其它流程。

当前触发链路已确认:

PaymentLegalCheck 可能返回商店绑定相关失败,直接阻断保存

Payment.php (line 134) 调 PaymentService::PaymentSave

PaymentService.php (line 434) 在保存前做 PaymentLegalCheck



开始执行实现:我只改 PaymentService.php,先定位 PaymentSave 和 PaymentLegalCheck 的精确代码段,然后打最小补丁并做语法检查。

已运行 rg -n “public static function PaymentSave|public static function PaymentLegalCheck|StoreService::PluginsLegalCheck\(” “e:\xampp\htdocs\shopxo671\app\service\PaymentService.php”

已运行 Get-Content “e:\xampp\htdocs\shopxo671\app\service\PaymentService.php” | Select-Object -Skip 380 -First 160

准备打补丁:

  1. PaymentSave 改成非阻断调用合法性校验;
  2. PaymentLegalCheck 增加 $is_block 参数,并在 StoreService::PluginsLegalCheck 缺失时安全放行。

已运行 $p=’e:\xampp\htdocs\shopxo671\app\service\PaymentService.php’; $c=Get-Content $p; for($i=420;$i -le 455;$i++){ ‘{0,4}: {1}’ -f $i,$c[$i-1] }(2m 59s)




EEE
开始执行实现:我只改 PaymentService.php,先定位 PaymentSave 和 PaymentLegalCheck 的精确代码段,然后打最小补丁并做语法检查。

已运行 rg -n “public static function PaymentSave|public static function PaymentLegalCheck|StoreService::PluginsLegalCheck\(” “e:\xampp\htdocs\shopxo671\app\service\PaymentService.php”

已运行 Get-Content “e:\xampp\htdocs\shopxo671\app\service\PaymentService.php” | Select-Object -Skip 380 -First 160

准备打补丁:

  1. PaymentSave 改成非阻断调用合法性校验;
  2. PaymentLegalCheck 增加 $is_block 参数,并在 StoreService::PluginsLegalCheck 缺失时安全放行。

已运行 $p=’e:\xampp\htdocs\shopxo671\app\service\PaymentService.php’; $c=Get-Content $p; for($i=420;$i -le 455;$i++){ ‘{0,4}: {1}’ -f $i,$c[$i-1] }(2m 59s)

已运行 $p=’e:\xampp\htdocs\shopxo671\app\service\PaymentService.php’; $c=Get-Content $p; for($i=400;$i -le 423;$i++){ ‘{0,4}: {1}’ -f $i,$c[$i-1] }(1m 5s)

已运行 $p=’e:\xampp\htdocs\shopxo671\app\service\PaymentService.php’; $c=Get-Content $p; for($i=452;$i -le 505;$i++){ ‘{0,4}: {1}’ -f $i,$c[$i-1] }(18s)

apply_patch 因文件编码/字符集问题没命中,我改用 PowerShell 按代码片段精确替换同一文件,不改其它文件。

已运行 $path = ‘e:\xampp\htdocs\shopxo671\app\service\PaymentService.php’; $content = Get-Content -Raw -Path $path; $old1 = “$ret = self::PaymentLegalCheck($info[‘payment’]);`r`n if($ret[‘code’] != 0)`r`n {`r`n return $ret;`r`n }”; $new1 = “self::PaymentLegalCheck($info[‘payment’], false);”; if($content.Contains($old1)) { $content = $content.Replace($old1, $new1) } else { throw ‘block1 not found’ } $old2 = “public static function PaymentLegalCheck($payment)”; $new2 = “public static function PaymentLegalCheck($payment, $is_block = true)”; if($content.Contains($old2)) { $content = $content.Replace($old2, $new2) } else { throw ‘block2 not found’ } $old3 = “$ret = StoreService::PluginsLegalCheck($check_params);”; $new3 = “if(!method_exists(‘\\app\\service\\StoreService’, ‘PluginsLegalCheck’))`r`n {`r`n return DataReturn(‘success’, 0);`r`n }`r`n $ret = StoreService::PluginsLegalCheck($check_params);”; if($content.Contains($old3)) { $content = $content.Replace($old3, $new3) } else { throw ‘block3 not found’ } $old4 = “if(!in_array($ret[‘code’], [0, -9999]))`r`n {`r`n return $ret;`r`n }”; $new4 = “if(!in_array($ret[‘code’], [0, -9999]))`r`n {`r`n if($is_block)`r`n {`r`n return $ret;`r`n }`r`n }”; if($content.Contains($old4)) { $content = $content.Replace($old4, $new4) } else { throw ‘block4 not found’ } Set-Content -Path $path -Value $content -Encoding UTF8;(31s)

已运行 $path=’e:\xampp\htdocs\shopxo671\app\service\PaymentService.php’; $content=Get-Content -Raw $path; $p1=’\$ret = self::PaymentLegalCheck\(\$info\[”payment”\]\);\s*\r?\n\s*if\(\$ret\[”code”\] != 0\)\s*\r?\n\s*\{\s*\r?\n\s*return \$ret;\s*\r?\n\s*\}’; $p2=’public static function PaymentLegalCheck\(\$payment\)’; $p3=’\$ret = StoreService::PluginsLegalCheck\(\$check_params\);’; $p4=’if\(!in_array\(\$ret\[”code”\], \[0, -9999\]\)\)\s*\r?\n\s*\{\s*\r?\n\s*return \$ret;\s*\r?\n\s*\}’; “p1=”+([regex]::Matches($content,$p1)).Count; “p2=”+([regex]::Matches($content,$p2)).Count; “p3=”+([regex]::Matches($content,$p3)).Count; “p4=”+([regex]::Matches($content,$p4)).Count;(55s)

已运行 $path=’e:\xampp\htdocs\shopxo671\app\service\PaymentService.php’; $content=Get-Content -Raw $path; $p1=’\$ret = self::PaymentLegalCheck\(\$info\[”payment”\]\);\s*\r?\n\s*if\(\$ret\[”code”\] != 0\)\s*\r?\n\s*\{\s*\r?\n\s*return \$ret;\s*\r?\n\s*\}’; $r1=’self::PaymentLegalCheck($info[”payment”], false);’; $content=[regex]::Replace($content,$p1,$r1,1); $p2=’public static function PaymentLegalCheck\(\$payment\)’; $r2=’public static function PaymentLegalCheck($payment, $is_block = true)’; $content=[regex]::Replace($content,$p2,$r2,1); $p3=’\$ret = StoreService::PluginsLegalCheck\(\$check_params\);’; $r3=”if(!method_exists(‘\\app\\service\\StoreService’, ‘PluginsLegalCheck’))`r`n {`r`n return DataReturn(‘success’, 0);`r`n }`r`n `$ret = StoreService::PluginsLegalCheck(`$check_params);”; $content=[regex]::Replace($content,$p3,$r3,1); $p4=’if\(!in_array\(\$ret\[”code”\], \[0, -9999\]\)\)\s*\r?\n\s*\{\s*\r?\n\s*return \$ret;\s*\r?\n\s*\}’; $r4=”if(!in_array(`$ret[‘code’], [0, -9999]))`r`n {`r`n if(`$is_block)`r`n {`r`n return `$ret;`r`n }`r`n }”; $content=[regex]::Replace($content,$p4,$r4,1); Set-Content -Path $path -Value $content -Encoding UTF8;(9s)

补丁已写入。我现在复核改动片段和语法,确保只影响支付保存链路。

已运行 $p=’e:\xampp\htdocs\shopxo671\app\service\PaymentService.php’; $c=Get-Content $p; for($i=406;$i -le 445;$i++){ ‘{0,4}: {1}’ -f $i,$c[$i-1] }(22s)

已运行 $p=’e:\xampp\htdocs\shopxo671\app\service\PaymentService.php’; $c=Get-Content $p; for($i=448;$i -le 505;$i++){ ‘{0,4}: {1}’ -f $i,$c[$i-1] }(34s)

已运行 php -l “e:\xampp\htdocs\shopxo671\app\service\PaymentService.php”(17s)

代码片段复核通过,改动点符合预期。现在我再给你一份精简变更摘要(含文件定位),你可以直接去后台验证 PayPal 保存。

已运行 git -C “e:\xampp\htdocs\shopxo671” diff — app/service/PaymentService.php

已处理 8m 16s

已按你的方案实现,且只改了 PaymentService.php

实现内容

  1. 保存支付配置改为“非阻断合法性校验”
    PaymentService.php (line 414)
    原来是校验失败直接 return,现在改为:
    self::PaymentLegalCheck($info[‘payment’], false);
  2. PaymentLegalCheck 增加可选参数(向后兼容)
    PaymentService.php (line 448)
    签名改为:
    PaymentLegalCheck($payment, $is_block = true)
  3. 增加 StoreService::PluginsLegalCheck 缺失防护
    PaymentService.php (line 468)
    如果该方法不存在,直接返回成功,避免致命错误。
  4. 非阻断模式下不再拦截
    PaymentService.php (line 475)
    当合法性校验失败时,仅在 $is_block=true 时返回错误;保存场景传 false 会继续保存。

验证情况

  • 代码片段已核对到位。
  • 本机无法执行 php -l(命令不存在),所以未做语法命令校验。

你现在可以直接去后台改 PayPal 沙箱参数测试保存。

发表评论

您的邮箱地址不会被公开。 必填项已用 * 标注

滚动至顶部