feat: 优化消息互动中心与首页Banner呈现,同步全量业务数据与高清图标
这个提交包含在:
@@ -308,7 +308,7 @@ class Post extends V1
|
||||
// LBS 坐标(gcj02;未定位/为 0 时存 NULL,首页「附近」不参与距离排序)
|
||||
'lat' => $this->coord('lat', 90),
|
||||
'lng' => $this->coord('lng', 180),
|
||||
'is_paid' => $paid ? 1 : 0,
|
||||
'is_paid' => ($paid && $paidNow) ? 1 : 0, // 微信支付发帖未付款前为 0,防止未支付信息外泄
|
||||
'amount' => $paid ? $amount : 0,
|
||||
'pay_type' => $paid ? $payType : '',
|
||||
'audit_status' => 0,
|
||||
@@ -823,38 +823,77 @@ class Post extends V1
|
||||
* @param array $post fc_post 行
|
||||
* @return array
|
||||
*/
|
||||
/**
|
||||
* 详情页联系方式与内容访问控制(严格执行会员权益与付费拦截)
|
||||
*
|
||||
* 可见规则:
|
||||
* ① 本人发布的信息或已付费解锁记录(fc_pay_view)→ unlocked=true,返回真实联系方式明文
|
||||
* ② 会员享有每日免费查看额度,未点击解锁时不泄露真实号码,下发真实剩余额度与会员标识
|
||||
* ③ 未解锁状态下,对标题与详细正文中的手机号执行掩码遮蔽,封堵正文直接贴电话的白嫖漏洞
|
||||
*
|
||||
* @param array $data buildPost() 结果
|
||||
* @param array $post fc_post 行
|
||||
* @return array 增强后的 Post 详情结构
|
||||
*/
|
||||
protected function contactAccess($data, $post)
|
||||
{
|
||||
$data['unlocked'] = false;
|
||||
$data['wechat'] = '';
|
||||
|
||||
$me = $this->user();
|
||||
if (!$me) {
|
||||
return $data;
|
||||
$now = time();
|
||||
$isMember = false;
|
||||
$quota = $this->memberFreeViewQuota();
|
||||
$used = 0;
|
||||
$freeViewLeft = 0;
|
||||
$payViewPrice = round((float)$this->cfg('fee.payView', 2), 2);
|
||||
|
||||
$isOwner = false;
|
||||
$paid = false;
|
||||
|
||||
if ($me) {
|
||||
$ext = $this->ext($me['id']);
|
||||
$isMember = (int)$ext['is_member'] === 1
|
||||
&& (empty($ext['member_expiretime']) || (int)$ext['member_expiretime'] > $now);
|
||||
$isOwner = (int)$post['user_id'] === (int)$me['id'];
|
||||
$paid = (bool)Db::name('fc_pay_view')
|
||||
->where('user_id', $me['id'])
|
||||
->where('post_id', $post['id'])
|
||||
->find();
|
||||
|
||||
$today = date('Y-m-d');
|
||||
$used = ((string)$ext['free_view_date'] === $today) ? (int)$ext['free_view_used'] : 0;
|
||||
$freeViewLeft = $isMember ? max(0, $quota - $used) : 0;
|
||||
}
|
||||
|
||||
$now = time();
|
||||
$ext = $this->ext($me['id']);
|
||||
$isMember = (int)$ext['is_member'] === 1
|
||||
&& (empty($ext['member_expiretime']) || (int)$ext['member_expiretime'] > $now);
|
||||
$isOwner = (int)$post['user_id'] === (int)$me['id'];
|
||||
$paid = (bool)Db::name('fc_pay_view')
|
||||
->where('user_id', $me['id'])
|
||||
->where('post_id', $post['id'])
|
||||
->find();
|
||||
$data['isMember'] = $isMember;
|
||||
$data['freeViewQuota'] = $quota;
|
||||
$data['freeViewUsed'] = $used;
|
||||
$data['freeViewLeft'] = $freeViewLeft;
|
||||
$data['payViewPrice'] = $payViewPrice;
|
||||
|
||||
// 会员每日免费查看剩余次数(只做展示;解锁统一走 payView,按额度/付费计费)
|
||||
$quota = $this->memberFreeViewQuota();
|
||||
$today = date('Y-m-d');
|
||||
$used = ((string)$ext['free_view_date'] === $today) ? (int)$ext['free_view_used'] : 0;
|
||||
$data['freeViewLeft'] = $isMember ? max(0, $quota - $used) : 0;
|
||||
|
||||
if ($isOwner || $paid || $isMember) {
|
||||
$data['unlocked'] = true;
|
||||
$data['phone'] = (string)$post['phone'];
|
||||
$data['contact'] = (string)$post['phone'];
|
||||
// 真实解锁态判定:仅本人发布或已生成有效解锁记录
|
||||
if ($isOwner || $paid) {
|
||||
$data['unlocked'] = true;
|
||||
$data['phone'] = (string)$post['phone'];
|
||||
$data['contact'] = (string)$post['phone'];
|
||||
$data['contactName'] = (string)(isset($post['contact']) ? $post['contact'] : '');
|
||||
$data['wechat'] = $post['wechat'] !== '' ? (string)$post['wechat'] : ('tongcheng_' . $post['id']);
|
||||
$data['wechat'] = $post['wechat'] !== '' ? (string)$post['wechat'] : ('tongcheng_' . $post['id']);
|
||||
// 若发帖人有关联商家门店,在解锁态下一并展现真实门店电话
|
||||
if (!empty($data['merchant']) && is_array($data['merchant']) && !empty($data['merchant']['id'])) {
|
||||
$rawShopContact = Db::name('fc_merchant')->where('id', $data['merchant']['id'])->value('contact');
|
||||
if ($rawShopContact) {
|
||||
$data['merchant']['contact'] = (string)$rawShopContact;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 未解锁态:标题与详细描述中的任何手机号执行动态安全遮蔽,杜绝正文绕过
|
||||
if (!empty($data['content'])) {
|
||||
$data['content'] = $this->maskTextPhones($data['content']);
|
||||
}
|
||||
if (!empty($data['title'])) {
|
||||
$data['title'] = $this->maskTextPhones($data['title']);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
@@ -923,7 +962,10 @@ class Post extends V1
|
||||
$id = $this->routeId();
|
||||
|
||||
$payType = (string)$this->input('payType', '');
|
||||
if (!in_array($payType, ['wxpay', 'balance'], true)) {
|
||||
if ($payType === '') {
|
||||
$payType = 'free';
|
||||
}
|
||||
if (!in_array($payType, ['wxpay', 'balance', 'free'], true)) {
|
||||
$this->fail('支付方式不支持');
|
||||
}
|
||||
|
||||
@@ -965,6 +1007,9 @@ class Post extends V1
|
||||
if ($usedFree) {
|
||||
$amount = 0;
|
||||
$payType = 'free';
|
||||
} elseif ($payType === 'free') {
|
||||
// 用户希望使用会员免费特权,但额度已耗尽或非会员
|
||||
throw new \RuntimeException($isMember ? '今日会员免费查看额度已用完,请选择支付方式付费查看' : '该内容需付费查看,请选择支付方式');
|
||||
} elseif ($payType === 'balance') {
|
||||
// 条件扣款:并发下不会扣成负数
|
||||
$affected = Db::name('user')
|
||||
@@ -972,7 +1017,7 @@ class Post extends V1
|
||||
->where('money', '>=', $amount)
|
||||
->setDec('money', $amount);
|
||||
if (!$affected) {
|
||||
throw new \RuntimeException('余额不足');
|
||||
throw new \RuntimeException('余额不足,请充值或使用微信支付');
|
||||
}
|
||||
$balance = (float)Db::name('user')->where('id', (int)$user['id'])->value('money');
|
||||
$this->flow('expense', '付费查看', $amount, $balance, $id);
|
||||
@@ -1019,7 +1064,16 @@ class Post extends V1
|
||||
$this->ok(['order' => $pending]);
|
||||
}
|
||||
|
||||
$this->ok(['unlocked' => true, 'contact' => $contact]);
|
||||
$today = date('Y-m-d');
|
||||
$extNow = $this->ext($user['id']);
|
||||
$usedNow = ((string)$extNow['free_view_date'] === $today) ? (int)$extNow['free_view_used'] : 0;
|
||||
|
||||
$this->ok([
|
||||
'unlocked' => true,
|
||||
'contact' => $contact,
|
||||
'freeViewLeft' => $isMember ? max(0, $quota - $usedNow) : 0,
|
||||
'usedFree' => isset($usedFree) ? $usedFree : false,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1442,7 +1496,7 @@ class Post extends V1
|
||||
'address' => (string)(isset($m['address']) ? $m['address'] : ''),
|
||||
'lat' => (isset($m['lat']) && $m['lat'] !== null && $m['lat'] !== '') ? (float)$m['lat'] : null,
|
||||
'lng' => (isset($m['lng']) && $m['lng'] !== null && $m['lng'] !== '') ? (float)$m['lng'] : null,
|
||||
'contact' => (string)(isset($m['contact']) ? $m['contact'] : ''),
|
||||
'contact' => $this->maskPhone(isset($m['contact']) ? $m['contact'] : ''), // 默认脱敏,未解锁绝不泄露
|
||||
'category' => (string)(isset($m['category']) ? $m['category'] : ''),
|
||||
'notice' => (string)(isset($m['notice']) ? $m['notice'] : ''),
|
||||
'auditStatus' => (int)$m['audit_status'],
|
||||
|
||||
在新工单中引用
屏蔽一个用户