添加支付费率扣除
This commit is contained in:
@@ -18,6 +18,7 @@ class VirtualPayService
|
||||
const SESSION_PREFIX = 'wx_session_key:';
|
||||
const TRADE_PREFIX = 'vp_trade:';
|
||||
const LATEST_PREFIX = 'vp_order_latest:';
|
||||
const PLATFORM_PREFIX = 'vp_pay_platform:';
|
||||
const CACHE_TTL = 1296000; // 15天
|
||||
|
||||
/**
|
||||
@@ -33,6 +34,50 @@ class VirtualPayService
|
||||
Cache::set(self::SESSION_PREFIX . $userId, $sessionKey, self::CACHE_TTL);
|
||||
}
|
||||
|
||||
/**
|
||||
* 记下客户拉起支付时的终端。iOS 单独记,鸿蒙、Windows 等按安卓费率
|
||||
* @param string $orderNo
|
||||
* @param string $platform
|
||||
* @return string
|
||||
*/
|
||||
public static function rememberPayPlatform($orderNo, $platform)
|
||||
{
|
||||
$normalized = self::normalizePayPlatform($platform);
|
||||
if ($orderNo !== '' && $normalized !== '') {
|
||||
Cache::set(self::PLATFORM_PREFIX . $orderNo, $normalized, self::CACHE_TTL);
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $orderNo
|
||||
* @return string
|
||||
*/
|
||||
public static function payPlatformOf($orderNo)
|
||||
{
|
||||
$cached = $orderNo ? Cache::get(self::PLATFORM_PREFIX . $orderNo) : '';
|
||||
|
||||
return self::normalizePayPlatform($cached);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $platform
|
||||
* @return string android|ios|空
|
||||
*/
|
||||
public static function normalizePayPlatform($platform)
|
||||
{
|
||||
$platform = strtolower(trim((string)$platform));
|
||||
if ($platform === 'ios' || $platform === 'iphone') {
|
||||
return 'ios';
|
||||
}
|
||||
if ($platform === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
return 'android';
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 wx.requestVirtualPayment 参数。signData 必须原样传给客户端,不能再 JSON.stringify
|
||||
* @param string $orderNo
|
||||
@@ -239,7 +284,8 @@ class VirtualPayService
|
||||
$transactionId,
|
||||
'XPAY',
|
||||
$paidTime > 0 ? $paidTime : time(),
|
||||
'settle'
|
||||
'settle',
|
||||
self::payPlatformOf($order->order_no)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -266,7 +312,8 @@ class VirtualPayService
|
||||
(string)($payInfo['TransactionId'] ?? ''),
|
||||
'XPAY',
|
||||
$paidTime > 0 ? $paidTime : time(),
|
||||
'coin_notify'
|
||||
'coin_notify',
|
||||
self::payPlatformOf($orderNo)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user