添加虚拟支付日志

This commit is contained in:
Dev
2026-10-27 16:47:23 +08:00
parent ed5c1e8c48
commit f1d03be571
5 changed files with 47 additions and 8 deletions
@@ -45,6 +45,7 @@ class VirtualPayService
{
$offerId = (string)config('common.virtual_pay.offer_id');
if ($offerId === '') {
self::logMissingOfferId();
throw new \Exception('未配置虚拟支付 OfferID');
}
$buyQuantity = self::coinQuantity($amountYuan);
@@ -377,6 +378,48 @@ class VirtualPayService
return (string)$sessionKey;
}
/**
* OfferID 为空时记下 .env 有没有被读到,不记录密钥内容
*/
private static function logMissingOfferId()
{
$envFile = (defined('ROOT_PATH') ? ROOT_PATH : '') . '.env';
$exists = $envFile !== '.env' && is_file($envFile);
$section = '';
$found = null;
if ($exists) {
$lines = file($envFile, FILE_IGNORE_NEW_LINES);
if (is_array($lines)) {
foreach ($lines as $line) {
$trim = trim($line);
if ($trim === '' || $trim[0] === ';' || $trim[0] === '#') {
continue;
}
if (preg_match('/^\[(.+)\]$/', $trim, $sectionMatch)) {
$section = $sectionMatch[1];
continue;
}
if (preg_match('/^vp_offer_id\s*=\s*(.*)$/', $trim, $valueMatch)) {
$value = trim($valueMatch[1], " \t\"'");
$found = [
'section' => $section,
'len' => strlen($value),
];
}
}
}
}
$fromEnv = getenv('PHP_WECHAT_VP_OFFER_ID');
$virtualPay = config('common.virtual_pay');
Log::error('虚拟支付 OfferID 为空 ' . json_encode([
'env_file' => $envFile,
'env_exists' => $exists,
'file_item' => $found ?: 'missing',
'getenv' => $fromEnv === false ? 'false' : ('len:' . strlen(trim((string)$fromEnv))),
'config_keys' => is_array($virtualPay) ? array_keys($virtualPay) : gettype($virtualPay),
], JSON_UNESCAPED_UNICODE));
}
/**
* @param float|string $amountYuan
* @return int
@@ -1,4 +1,4 @@
<view class="goods-detail-page {{caseView ? 'goods-detail-page--case' : ''}}">
<view class="goods-detail-page">
<view class="goods-head">
<view class="goods-gallery">
<t-swiper wx:if="{{details.images.length > 0}}" height="750rpx" current="{{current}}" autoplay="{{autoplay}}" duration="{{duration}}" interval="{{interval}}" navigation="{{navigation}}" list="{{details.images}}"></t-swiper>
@@ -97,7 +97,7 @@
</view>
</view>
<view class="goods-bottom-operation" wx:if="{{!caseView}}">
<view class="goods-bottom-operation">
<buy-bar soldout="{{soldout}}" isStock="{{isStock}}" buttonType="{{buttonType}}" bind:toBuyNow="buyItNow" />
</view>
@@ -11,10 +11,6 @@ page {
background-color: var(--bg-page);
}
.goods-detail-page--case {
padding-bottom: calc(env(safe-area-inset-bottom) + 32rpx);
}
.goods-head {
--td-swiper-radius: 0;
}
+1 -1
View File
@@ -28,7 +28,7 @@ Page({
loadMoreStatus: 0,
loading: true,
tabList: [],
caseView: wx.getStorageSync('goodsCaseView') === true, // 案例展示:标题改为软件案例,不显示价格和购物车
caseView: wx.getStorageSync('goodsCaseView') === true, // 案例展示:标题改为软件案例,不显示购物车
},
handleFilterChange(e) {
+1 -1
View File
@@ -29,7 +29,7 @@
</view>
</view>
<view class="category-goods-list" wx:if="{{goodsList.length}}">
<goods-list wr-class="wr-goods-list" goodsList="{{goodsList}}" show-buy="{{!caseView}}" show-price="{{!caseView}}" bind:click="gotoGoodsDetail" />
<goods-list wr-class="wr-goods-list" goodsList="{{goodsList}}" show-buy="{{!caseView}}" show-price="{{true}}" bind:click="gotoGoodsDetail" />
</view>
<view class="empty-wrap" wx:if="{{goodsList.length === 0 && hasLoaded}}">
<t-empty t-class="empty-tips" size="240rpx" description="暂无相关产品" />