42 行
1.0 KiB
PHP
42 行
1.0 KiB
PHP
<?php
|
|
|
|
namespace addons\shopro_wechat_trade\library;
|
|
|
|
use think\Db;
|
|
|
|
class Bridge
|
|
{
|
|
public static function isEnabled()
|
|
{
|
|
if (!function_exists('get_addon_info')) {
|
|
return false;
|
|
}
|
|
$info = get_addon_info('shopro_wechat_trade');
|
|
if (!$info || intval($info['state'] ?? 0) !== 1) {
|
|
return false;
|
|
}
|
|
return WxTradeConfig::getInstance()->get('wechat_trade_enable', '1') === '1';
|
|
}
|
|
|
|
public static function shouldHandleOrder($order)
|
|
{
|
|
if (!self::isEnabled()) {
|
|
return false;
|
|
}
|
|
if (!$order) {
|
|
return false;
|
|
}
|
|
if (($order['platform'] ?? '') !== 'wxMiniProgram') {
|
|
return false;
|
|
}
|
|
$payType = $order['pay_type'] ?? '';
|
|
if (!in_array($payType, ['wechat', 'huifu_wechat'], true)) {
|
|
return false;
|
|
}
|
|
if (intval($order['status'] ?? 0) <= 0) {
|
|
return false;
|
|
}
|
|
return WxOrderContext::resolveTransactionId($order) !== '';
|
|
}
|
|
}
|