feat: 新增会员浏览/拨打额度并优化无图展示逻辑
新增会员每日浏览完整信息和拨打电话的额度配置,调整付费查看接口描述为解锁完整信息,优化帖子无图时的兜底展示逻辑,修复图片加载路径问题,删除废弃工具脚本。
这个提交包含在:
@@ -215,6 +215,24 @@ class FcInstall extends Command
|
||||
$output->writeln(' - ' . $planTable . ' 新增列 post_discount');
|
||||
$changed++;
|
||||
}
|
||||
if (!$this->hasColumn($planTable, 'view_quota')) {
|
||||
Db::execute("ALTER TABLE `{$planTable}` ADD COLUMN `view_quota` int(10) NOT NULL DEFAULT 20"
|
||||
. " COMMENT '会员每日免费浏览完整信息条数(0=不限)' AFTER `free_view_quota`");
|
||||
Db::execute("UPDATE `{$planTable}` SET `view_quota` = 20 WHERE `plan_code` = 'M1'");
|
||||
Db::execute("UPDATE `{$planTable}` SET `view_quota` = 50 WHERE `plan_code` = 'M3'");
|
||||
Db::execute("UPDATE `{$planTable}` SET `view_quota` = 0 WHERE `plan_code` = 'M12'");
|
||||
$output->writeln(' - ' . $planTable . ' 新增列 view_quota(0=不限次浏览)');
|
||||
$changed++;
|
||||
}
|
||||
if (!$this->hasColumn($planTable, 'call_quota')) {
|
||||
Db::execute("ALTER TABLE `{$planTable}` ADD COLUMN `call_quota` int(10) NOT NULL DEFAULT 30"
|
||||
. " COMMENT '会员每日拨打电话次数(0=不限)' AFTER `view_quota`");
|
||||
Db::execute("UPDATE `{$planTable}` SET `call_quota` = 30 WHERE `plan_code` = 'M1'");
|
||||
Db::execute("UPDATE `{$planTable}` SET `call_quota` = 40 WHERE `plan_code` = 'M3'");
|
||||
Db::execute("UPDATE `{$planTable}` SET `call_quota` = 0 WHERE `plan_code` = 'M12'");
|
||||
$output->writeln(' - ' . $planTable . ' 新增列 call_quota(0=不限次拨打)');
|
||||
$changed++;
|
||||
}
|
||||
if (!$this->hasColumn($extTable, 'free_view_quota')) {
|
||||
Db::execute("ALTER TABLE `{$extTable}` ADD COLUMN `free_view_quota` int(10) NOT NULL DEFAULT 20"
|
||||
. " COMMENT '当前会员每日免费查看条数(0=无限)' AFTER `free_view_used`");
|
||||
@@ -256,6 +274,7 @@ class FcInstall extends Command
|
||||
$deprecated = [
|
||||
'post.monthPrice', 'post.monthQuota', 'post.yearPrice', 'post.yearQuota',
|
||||
'fee.singlePost', 'fee.freePostPerDay', 'fee.memberMonth', 'fee.memberQuarter', 'fee.memberYear',
|
||||
'call.vipDailyQuota',
|
||||
];
|
||||
$removedKeys = Db::name('fc_config')->where('key', 'in', $deprecated)->delete();
|
||||
if ($removedKeys) {
|
||||
@@ -943,6 +962,17 @@ class FcInstall extends Command
|
||||
KEY `target` (`target_type`, `target_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='同城-电话拨打次数记录';",
|
||||
|
||||
'view_log' => "CREATE TABLE IF NOT EXISTS `#P#view_log` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '浏览用户ID',
|
||||
`post_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '信息ID',
|
||||
`view_date` date NOT NULL COMMENT '浏览日期',
|
||||
`createtime` int(10) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uniq_user_post_date` (`user_id`, `post_id`, `view_date`),
|
||||
KEY `idx_user_date` (`user_id`, `view_date`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='同城-完整信息每日浏览记录';",
|
||||
|
||||
'category' => "CREATE TABLE IF NOT EXISTS `#P#category` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(32) NOT NULL DEFAULT '' COMMENT '分类名',
|
||||
|
||||
@@ -1,477 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\command;
|
||||
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 信息测试数据重建命令
|
||||
*
|
||||
* 用法:
|
||||
* php think fc:seed-posts 清空接口验证/残缺信息,按 8 个分类重建规范化演示数据
|
||||
*
|
||||
* 说明:
|
||||
* - 只处理内容类业务表:fc_post / fc_comment / fc_favorite / fc_pay_view / fc_draft / fc_report
|
||||
* 以及重复的「接口验证区」区域,不动用户、订单、佣金、配置等数据。
|
||||
* - 命令可重复执行,每次都会重建同一套 ID 段的数据。
|
||||
*/
|
||||
class FcSeedPosts extends Command
|
||||
{
|
||||
/** 演示账号:user_id => [昵称, 手机号] */
|
||||
const USERS = [
|
||||
1001 => ['同城小助手', '13800001111'],
|
||||
1002 => ['小王同学', '15033443344'],
|
||||
1003 => ['洁净到家·陈姐', '13156785678'],
|
||||
2001 => ['顺捷物流·杨经理', '13988888888'],
|
||||
2002 => ['安家房产·周主管', '13566666666'],
|
||||
2003 => ['骑行爱好者·小周', '13712341234'],
|
||||
2004 => ['车行天下·张总', '13800000000'],
|
||||
2005 => ['洁净到家·王师傅', '13156785678'],
|
||||
2006 => ['数码达人·阿豪', '15033443344'],
|
||||
2007 => ['优选二手车·赵经理', '13700000000'],
|
||||
];
|
||||
|
||||
/** 区域中心坐标(gcj02 近似值,用于首页「附近」排序演示) */
|
||||
const AREA_COORD = [
|
||||
'云岩区' => [26.605, 106.710],
|
||||
'南明区' => [26.568, 106.716],
|
||||
'观山湖区' => [26.625, 106.625],
|
||||
'花溪区' => [26.430, 106.670],
|
||||
];
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('fc:seed-posts')
|
||||
->setDescription('清理不规范测试数据,按分类重建信息演示数据');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
$now = time();
|
||||
$prefix = \think\Config::get('database.prefix');
|
||||
$output->writeln('==> 清理不规范测试数据');
|
||||
$this->clean();
|
||||
|
||||
$data = $this->posts();
|
||||
$owners = $this->owners();
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$id = 101;
|
||||
$seq = 0;
|
||||
$stat = [];
|
||||
foreach ($data as $categoryId => $rows) {
|
||||
$stat[$categoryId] = 0;
|
||||
foreach ($rows as $i => $row) {
|
||||
$uid = $owners[$categoryId][$i];
|
||||
$user = self::USERS[$uid];
|
||||
$audit = $this->auditStatus($categoryId, $i);
|
||||
$paid = $audit === 1 && $categoryId !== 8 && $i % 4 === 1;
|
||||
$views = 160 + (($categoryId * 977 + $i * 613) % 3200);
|
||||
$likes = max(2, (int)($views / 48));
|
||||
$areas = $this->coord($row[4], $i);
|
||||
$created = $now - (int)((0.15 + $i * 0.41 + $categoryId * 0.13) * 86400);
|
||||
$media = $this->mediaPaths($categoryId, $i);
|
||||
|
||||
$areaId = $this->areaId($row[5]);
|
||||
|
||||
Db::name('fc_post')->insert([
|
||||
'id' => $id,
|
||||
'user_id' => $uid,
|
||||
'category_id' => $categoryId,
|
||||
'identity_type' => in_array($uid, [1003, 2001, 2002, 2004, 2005, 2007, 2011], true) ? 2 : 1,
|
||||
'title' => $row[1],
|
||||
'content' => $row[2],
|
||||
'cover' => $media[0],
|
||||
'media' => json_encode($media, JSON_UNESCAPED_UNICODE),
|
||||
'price' => $row[3],
|
||||
'price_unit' => $row[4],
|
||||
'area' => $row[5],
|
||||
'district_id' => $areaId,
|
||||
'address' => $row[6],
|
||||
'lat' => $areas[0],
|
||||
'lng' => $areas[1],
|
||||
'contact' => $row[0],
|
||||
'phone' => $user[1],
|
||||
'wechat' => 'gyfc' . $id,
|
||||
'tags' => $row[7],
|
||||
'is_paid' => $paid ? 1 : 0,
|
||||
'amount' => $paid ? 5 : 0,
|
||||
'pay_type' => $paid ? ($i % 2 === 1 ? 'wxpay' : 'balance') : '',
|
||||
'audit_status' => $audit,
|
||||
'audit_reason' => $audit === 2 ? '信息涉嫌重复发布' : '',
|
||||
'views' => $audit === 1 ? $views : 0,
|
||||
'likes' => $audit === 1 ? $likes : 0,
|
||||
'comment_count' => 0,
|
||||
'status' => 1,
|
||||
'is_top' => $this->isTop($categoryId, $i) ? 1 : 0,
|
||||
'distance' => 0,
|
||||
'createtime' => $created,
|
||||
'updatetime' => $created,
|
||||
]);
|
||||
|
||||
$id++;
|
||||
$seq++;
|
||||
if ($audit === 1) {
|
||||
$stat[$categoryId]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$output->writeln(' - 信息 ' . $seq . ' 条(已更新 ID 101-' . ($id - 1) . ')');
|
||||
|
||||
$this->seedComments($now);
|
||||
$this->seedDrafts($now);
|
||||
$this->seedReports($now);
|
||||
$this->syncCounts();
|
||||
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
$output->writeln(' [x] 重建失败:' . $e->getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
Db::execute('ALTER TABLE `' . $prefix . 'fc_post` AUTO_INCREMENT = 165');
|
||||
|
||||
foreach ($stat as $categoryId => $count) {
|
||||
$name = Db::name('fc_category')->where('id', $categoryId)->value('name');
|
||||
$output->writeln(' - ' . $name . ':' . $count . ' 条已发布');
|
||||
}
|
||||
$output->writeln('==> 完成');
|
||||
}
|
||||
|
||||
/** 清理内容类测试数据(保留用户、订单、佣金、配置) */
|
||||
protected function clean()
|
||||
{
|
||||
Db::name('fc_comment')->where('id', '>', 0)->delete();
|
||||
Db::name('fc_favorite')->where('id', '>', 0)->delete();
|
||||
Db::name('fc_pay_view')->where('id', '>', 0)->delete();
|
||||
Db::name('fc_draft')->where('id', '>', 0)->delete();
|
||||
Db::name('fc_report')->where('id', '>', 0)->delete();
|
||||
Db::name('fc_post')->where('id', '>', 0)->delete();
|
||||
Db::name('fc_area')->where('district', '接口验证区')->delete();
|
||||
Db::name('fc_message')->where('title', 'like', '%接口验证%')->whereOr('content', 'like', '%接口验证%')->delete();
|
||||
$this->cleanMockUsers();
|
||||
}
|
||||
|
||||
/** 清理历史自动化脚本遗留的临时用户及其关联数据 */
|
||||
protected function cleanMockUsers()
|
||||
{
|
||||
$ids = Db::name('user')
|
||||
->where('username', 'like', 'test\\_dist\\_%')
|
||||
->whereOr('username', 'like', 'mock\\_test\\_dist\\_%')
|
||||
->column('id');
|
||||
if (!$ids) {
|
||||
return;
|
||||
}
|
||||
Db::name('fc_user_ext')->where('user_id', 'in', $ids)->delete();
|
||||
Db::name('fc_dist_relation')->where('user_id', 'in', $ids)->whereOr('parent_id', 'in', $ids)->delete();
|
||||
Db::name('fc_order')->where('user_id', 'in', $ids)->delete();
|
||||
Db::name('fc_commission')->where('user_id', 'in', $ids)->whereOr('from_user_id', 'in', $ids)->delete();
|
||||
Db::name('fc_withdraw')->where('user_id', 'in', $ids)->delete();
|
||||
Db::name('fc_message')->where('user_id', 'in', $ids)->delete();
|
||||
Db::name('user')->where('id', 'in', $ids)->delete();
|
||||
}
|
||||
|
||||
/** 每个分类下的发布账号,按信息顺序一一对应 */
|
||||
protected function owners()
|
||||
{
|
||||
return [
|
||||
1 => [2001, 1002, 2002, 2005, 1002, 2001, 1003, 2004],
|
||||
2 => [2002, 2002, 2002, 2002, 1001, 2002, 2002, 1001],
|
||||
3 => [2003, 2006, 1002, 2005, 1003, 1001, 2003, 2006],
|
||||
4 => [2004, 2007, 2004, 2007, 2004, 2007, 2003, 2007],
|
||||
5 => [2005, 1003, 1001, 1003, 2005, 1003, 1002, 1001],
|
||||
6 => [1002, 1003, 1001, 1002, 1003, 1001, 1002, 1003],
|
||||
7 => [1003, 2005, 1003, 2005, 1003, 2005, 1003, 2005],
|
||||
8 => [1002, 2003, 1001, 1002, 2003, 1001, 1002, 2003],
|
||||
];
|
||||
}
|
||||
|
||||
/** 审核状态:默认通过;少量待审/驳回用于验证后台流程 */
|
||||
protected function auditStatus($categoryId, $index)
|
||||
{
|
||||
$pending = [[4, 6], [8, 7]];
|
||||
$rejected = [[3, 5]];
|
||||
if (in_array([$categoryId, $index], $pending, true)) {
|
||||
return 0;
|
||||
}
|
||||
if (in_array([$categoryId, $index], $rejected, true)) {
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** 置顶:每个分类最多一条,制造首页头部内容 */
|
||||
protected function isTop($categoryId, $index)
|
||||
{
|
||||
$tops = [[1, 0], [3, 1], [5, 0], [7, 1]];
|
||||
return in_array([$categoryId, $index], $tops, true);
|
||||
}
|
||||
|
||||
/** 区县名称 → 服务区域ID(fc_area.id) */
|
||||
protected function areaId($area)
|
||||
{
|
||||
static $cache = [];
|
||||
if (isset($cache[$area])) {
|
||||
return $cache[$area];
|
||||
}
|
||||
$row = Db::name('fc_area')->where('district', $area)->find();
|
||||
return $cache[$area] = $row ? (int)$row['id'] : 0;
|
||||
}
|
||||
|
||||
/** 区域中心 + 稳定偏移,避免所有信息坐标完全重合 */
|
||||
protected function coord($area, $index)
|
||||
{
|
||||
$base = isset(self::AREA_COORD[$area]) ? self::AREA_COORD[$area] : self::AREA_COORD['云岩区'];
|
||||
$lat = $base[0] + (($index % 5) - 2) * 0.0055;
|
||||
$lng = $base[1] + ((int)($index / 2) - 2) * 0.0065;
|
||||
return [round($lat, 6), round($lng, 6)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息配图:每条信息使用 1 张与内容匹配的真实照片作为封面和详情图。
|
||||
* 图片存放在 public/static/posts/,随代码仓库部署,不依赖第三方外链。
|
||||
*/
|
||||
protected function mediaPaths($categoryId, $index)
|
||||
{
|
||||
$primary = $this->primaries()[$categoryId][$index];
|
||||
return ['/static/posts/' . $primary . '.jpg'];
|
||||
}
|
||||
|
||||
/** 每条信息的首图(与 posts() 的顺序一一对应) */
|
||||
protected function primaries()
|
||||
{
|
||||
return [
|
||||
1 => ['job-warehouse', 'job-cafe', 'job-office', 'job-cleaning', 'job-warehouse', 'job-delivery', 'job-classroom', 'job-handshake'],
|
||||
2 => ['house-living1', 'house-living3', 'house-office', 'house-model', 'house-living2', 'house-living4', 'house-exterior', 'job-cafe'],
|
||||
3 => ['goods-bike', 'goods-ipad', 'goods-dining', 'goods-fridge', 'goods-stroller', 'goods-laptop', 'goods-treadmill', 'goods-desk'],
|
||||
4 => ['car-sedan-white', 'car-compact-blue', 'car-moto', 'car-hatch-red', 'car-coupe-blue', 'car-suv-white', 'goods-bike', 'car-sedan-dark'],
|
||||
5 => ['svc-spray', 'svc-keys', 'svc-code', 'svc-wrench', 'svc-moving', 'svc-drill', 'svc-camera', 'svc-night'],
|
||||
6 => ['edu-art', 'edu-books', 'edu-shelf', 'edu-guitar', 'edu-laptop', 'edu-class', 'car-sedan-white', 'edu-shelf'],
|
||||
7 => ['clean-window', 'clean-bath', 'clean-baby', 'clean-kitchen', 'clean-kitchen', 'clean-window', 'clean-elder', 'clean-vacuum'],
|
||||
8 => ['friend-hike', 'friend-badminton', 'friend-books', 'friend-run', 'friend-camera', 'friend-bike', 'friend-board', 'friend-group'],
|
||||
];
|
||||
}
|
||||
|
||||
/** 信息数据集:联系人 / 标题 / 内容 / 价格 / 单位 / 区域 / 地址 / 标签 */
|
||||
protected function posts()
|
||||
{
|
||||
return [
|
||||
// 招聘求职
|
||||
1 => [
|
||||
['杨经理', '急招快递分拣员(日结)', '站点直招,日结 180-220 元,包工作餐,当天结算。能吃苦、手脚麻利即可,年龄 18-50 岁。', 0, '面议', '云岩区', '贵阳北站物流园', '日结,包吃'],
|
||||
['李店长', '奶茶店店员(包住)', '花果园商圈奶茶店招店员,负责点单和出杯。早班 10 点到 18 点,月休 4 天,包住,有提成。', 3800, '元/月', '南明区', '花果园购物中心', '包住,有提成'],
|
||||
['周主管', '行政文员(双休)', '负责合同整理、客户接待和日常表格。会基本办公软件,做事细心,转正后买五险。', 4200, '元/月', '观山湖区', '金融城', '双休,五险'],
|
||||
['王师傅', '招保洁员 5 名', '承接小区和写字楼保洁,公司派单,不用自己找客户。多劳多得,工资月结。', 3000, '元/月', '云岩区', '喷水池', '多劳多得,月结'],
|
||||
['张店长', '超市理货员(兼职)', '每天下午 4 点到 9 点,负责补货和整理货架。适合学生和宝妈,工资周结。', 18, '元/小时', '南明区', '花果园', '兼职,周结'],
|
||||
['刘站长', '外卖骑手(可日结)', '自带电动车优先,站点提供充电和休息区。跑单时间自由,多跑多得。', 6000, '元/月', '观山湖区', '世纪城', '日结,时间自由'],
|
||||
['陈老师', '幼儿园保育员', '负责班级卫生和孩子日常照料,有保育员证优先。周末双休,包午餐。', 3200, '元/月', '花溪区', '贵州大学附近', '双休,包午餐'],
|
||||
['吴经理', '汽车销售顾问', '负责到店客户接待和车型介绍,有销售经验优先。底薪加提成,上不封顶。', 5000, '元/月', '观山湖区', '金阳客车站旁', '底薪加提成,五险'],
|
||||
],
|
||||
// 房产租售
|
||||
2 => [
|
||||
['刘经理', '整租·未来方舟精装一室一厅', '家电齐全,拎包入住,近地铁 2 号线,押一付一,可短租。', 1800, '元/月', '南明区', '未来方舟 B 区', '精装,近地铁'],
|
||||
['王女士', '花果园两室一厅 南北通透', '中间楼层,采光好,家具家电全带,随时看房。', 2200, '元/月', '南明区', '花果园', '采光好,随时看房'],
|
||||
['周先生', '观山湖金融城写字楼出租', '80 平,独立办公室,带中央空调和前台,适合小团队。', 45, '元/㎡/月', '观山湖区', '金融城', '写字楼,带空调'],
|
||||
['李女士', '云岩区学区房出售 满五唯一', '两室一厅 78 平,划片实验小学,业主置换急售。', 98, '万元', '云岩区', '喷水池', '学区房,满五唯一'],
|
||||
['小杨', '花溪大学城单间合租', '独立卫生间,室友都是上班族,环境安静,押一付三。', 650, '元/月', '花溪区', '贵州大学北门', '合租,独卫'],
|
||||
['刘经理', '世纪城三室两厅 拎包入住', '130 平,电梯房,家电齐全,适合一家人住。', 2600, '元/月', '观山湖区', '世纪城', '电梯房,家电齐全'],
|
||||
['陈先生', '甲秀楼旁两室出售', '65 平,位置方便,出门就是菜场和公交站,价格可谈。', 62, '万元', '南明区', '甲秀楼', '位置好,可议价'],
|
||||
['小杨', '观山湖门面转让(可空转)', '临街 40 平,带基础装修,适合小吃和便利店,接手就能营业。', 3500, '元/月', '观山湖区', '奥体中心', '临街,可空转'],
|
||||
],
|
||||
// 二手闲置
|
||||
3 => [
|
||||
['小周', '九成新山地自行车 转让', '骑行不到 300 公里,27 速,原价 1599,现 680 出,可小刀,同城自提。', 680, '元', '观山湖区', '世纪城', '自提,9成新'],
|
||||
['小王', 'iPad 2021 64G 深空灰', '学生自用,无磕碰,配件齐全,支持当面验机。', 1450, '元', '观山湖区', '贵阳奥体中心', '验机,无磕碰'],
|
||||
['小林', '实木餐桌椅 四人位', '搬家带不走,桌面无划痕,椅子结实,自提价。', 420, '元', '南明区', '花果园', '自提,实木'],
|
||||
['王姐', '美的双门冰箱 260L', '用了两年,制冷正常,因为换大冰箱所以出,可上门看货。', 550, '元', '云岩区', '喷水池', '可看货,制冷正常'],
|
||||
['小陈', '好孩子婴儿推车', '宝宝大了用不上,可坐可躺,折叠方便,清洗干净。', 180, '元', '花溪区', '花溪公园', '可折叠,已清洗'],
|
||||
['小杨', '联想拯救者游戏本', '16G 内存,512G 固态,打游戏不卡,电池健康,带原装充电器。', 3200, '元', '南明区', '花果园', '游戏本,带充电器'],
|
||||
['小周', '家用跑步机 九成新', '买来跑了不到十次,可折叠收纳,同城自提。', 800, '元', '观山湖区', '观山湖公园', '自提,可折叠'],
|
||||
['小王', '书架加办公桌一套', '租房换地方,便宜出,书桌 1.2 米,书架五层。', 200, '元', '观山湖区', '世纪城', '一套,便宜出'],
|
||||
],
|
||||
// 车辆买卖
|
||||
4 => [
|
||||
['吴经理', '2019 款奥迪 A4L 一手车', '白色车身,车况好,无事故无泡水,4S 店保养记录齐全,支持第三方检测。', 12.8, '万元', '云岩区', '金阳客车站旁', '无事故,可检测'],
|
||||
['优选二手车', '城市代步小车 2022 款', '车身小巧好停车,续航够日常通勤,跑了 1.2 万公里,手续齐全。', 2.6, '万元', '观山湖区', '世纪城', '代步,手续齐全'],
|
||||
['吴经理', '雅马哈踏板摩托车', '125 排量,车况好,油耗低,带牌照一起出,可试车。', 4500, '元', '南明区', '花果园', '可试车,带牌'],
|
||||
['老李', '二手代步小车 省油好开', '个人一手车,1.5 排量,市区代步省油,保养刚做,可试车。', 1.8, '万元', '云岩区', '贵阳北站', '省油,可试车'],
|
||||
['吴经理', '宝马 4 系 2018 款', '蓝色车身,车况好,无事故,支持第三方检测,可分期。', 15.8, '万元', '观山湖区', '金融城', '无事故,可分期'],
|
||||
['优选二手车', '家用七座 SUV 车况好', '七座大空间,适合一家人出行,无事故,保养记录齐全,可检测。', 8.8, '万元', '南明区', '龙洞堡', '7座,可检测'],
|
||||
['小周', '电助力山地车', '36V 电池,助力续航 50 公里,上下班代步很省力。', 1600, '元', '观山湖区', '奥体中心', '助力,省力'],
|
||||
['老李', '宝马 3 系 2019 款', '车况好,内饰干净,无事故,支持第三方检测,可分期。', 12.8, '万元', '花溪区', '石板物流园', '无事故,可分期'],
|
||||
],
|
||||
// 本地服务
|
||||
5 => [
|
||||
['王师傅', '专业空调清洗加氟上门', '10 年老师傅,清洗 60 元一台,加氟 80 元起,不满意不收费。', 60, '元/台', '南明区', '花果园', '上门,不满意不收费'],
|
||||
['陈师傅', '开锁换锁 24 小时上门', '防盗门、汽车锁都能开,换锁芯明码标价,半夜也能来。', 80, '元起', '云岩区', '喷水池', '24小时,明码标价'],
|
||||
['小杨', '电脑维修 重装系统', '蓝屏、开不了机、清灰换硅脂都能修,先检测后报价。', 50, '元起', '南明区', '花果园', '先检测,上门'],
|
||||
['陈师傅', '管道疏通 高压清洗', '厨房下水、马桶、地漏疏通,不通不收费,节假日不休。', 100, '元起', '云岩区', '黔灵山公园', '不通不收费,节假日不休'],
|
||||
['王师傅', '搬家拉货 小面包车', '市区内 120 元起,可帮忙搬下楼,费用提前说清楚。', 120, '元起', '观山湖区', '世纪城', '搬家,价格透明'],
|
||||
['陈师傅', '防水补漏 免费上门检测', '屋顶、卫生间、外墙漏水都能做,先看现场再报价,质保两年。', 0, '面议', '花溪区', '花溪公园', '免费检测,质保两年'],
|
||||
['小林', '摄影跟拍 婚礼活动', '婚礼、生日、毕业照都能拍,当天出精修图,可约周末。', 800, '元/场', '观山湖区', '观山湖公园', '跟拍,当天出图'],
|
||||
['小杨', '酒后代驾 市区内', '晚上 8 点到凌晨 2 点接单,市区 39 元起,安全送到家。', 39, '元起', '南明区', '甲秀楼', '夜间,安全送达'],
|
||||
],
|
||||
// 教育培训
|
||||
6 => [
|
||||
['李老师', '少儿美术体验课 9.9 元', '4 到 12 岁都能来,画材全包,先体验再决定,周末可约。', 9.9, '元', '观山湖区', '世纪城', '体验课,画材全包'],
|
||||
['张老师', '初三数学一对一辅导', '在职老师,带过三届毕业班,先测水平再定计划,可上门。', 150, '元/课时', '南明区', '花果园', '一对一,可上门'],
|
||||
['招生办', '成人高考报名咨询', '大专本科都能报,流程有人指导,考前有资料,不收中介费。', 0, '面议', '云岩区', '喷水池', '学历提升,免费咨询'],
|
||||
['阿杰老师', '吉他尤克里里 零基础班', '小班教学,一人一把琴,学会三首歌再续课,晚上和周末上课。', 80, '元/课时', '观山湖区', '奥体中心', '零基础,小班'],
|
||||
['李老师', '少儿编程体验课', '图形化编程入门,边玩边学,适合 7 到 12 岁,电脑教室上课。', 19.9, '元', '花溪区', '花溪公园', '体验课,边玩边学'],
|
||||
['招生办', '普通话考级培训', '针对二乙二甲考试,小班纠音,考前模拟测试,不过可重听。', 680, '元', '云岩区', '黔灵山公园', '考级,可重听'],
|
||||
['王教练', '驾校 C1 报名', '本地练车,随到随学,科目一到科目四全程带,费用一次交清。', 2680, '元', '南明区', '龙洞堡', '一费制,随到随学'],
|
||||
['张老师', '英语四六级冲刺班', '每周三次晚课,讲真题和作文模板,适合基础一般的大学生。', 499, '元', '花溪区', '贵州大学', '冲刺班,真题讲解'],
|
||||
],
|
||||
// 家政保洁
|
||||
7 => [
|
||||
['陈姐', '日常保洁 3 小时', '扫地拖地、擦灰、厨房卫生间清洁,自带工具,满意再付款。', 120, '元/次', '南明区', '花果园', '自带工具,满意付款'],
|
||||
['王师傅', '新房开荒保洁', '装修后除尘除胶,玻璃和柜子里外都擦,按面积算,量大优惠。', 5, '元/㎡', '观山湖区', '世纪城', '开荒,按面积'],
|
||||
['陈姐', '月嫂育儿嫂 可预约', '带过 30 多个宝宝,会做月子餐,有健康证,可先面试。', 8000, '元/月', '云岩区', '喷水池', '有健康证,可面试'],
|
||||
['王师傅', '油烟机洗衣机深度清洗', '拆洗不伤机器,清洗完当场试机,两台一起更划算。', 199, '元', '南明区', '花果园', '拆洗,当场试机'],
|
||||
['陈姐', '钟点工 做饭打扫', '每天两小时,做饭加简单收拾,口味可以按家里习惯来。', 35, '元/小时', '观山湖区', '金融城', '做饭,按小时'],
|
||||
['王师傅', '高层玻璃清洗', '内外都能擦,带安全绳,雨天不接单,提前一天预约。', 150, '元起', '观山湖区', '奥体中心', '高层,带安全绳'],
|
||||
['陈姐', '老人陪护 住家', '照顾能自理的老人,做饭陪着说话,有护理经验,可长期。', 4500, '元/月', '花溪区', '花溪公园', '住家,有护理经验'],
|
||||
['王师傅', '地毯清洗 上门', '公司办公室和家庭地毯都能洗,洗完当天能干,按平方计价。', 8, '元/㎡', '云岩区', '贵阳北站', '上门,当天干'],
|
||||
],
|
||||
// 同城交友
|
||||
8 => [
|
||||
['小林', '周末爬山搭子 黔灵山', '周六早上 8 点黔灵山门口集合,走慢线,新手也能来,自带水。', 0, '面议', '云岩区', '黔灵山公园', '爬山,新手友好'],
|
||||
['小周', '羽毛球约球 每周三晚', '观山湖体育馆,水平一般,主要活动身体,场地费 AA。', 0, '面议', '观山湖区', '奥体中心', '羽毛球,AA'],
|
||||
['小杨', '贵阳本地读书会 招募', '每月一本书,线下聊两小时,不限年龄职业,安静参与就好。', 0, '面议', '南明区', '甲秀楼', '读书会,每月一次'],
|
||||
['小林', '90 后女生 找运动搭子', '平时跑步、骑车都可以,周末有空,希望住得近一点,互相监督。', 0, '面议', '观山湖区', '观山湖公园', '运动,住得近'],
|
||||
['小周', '摄影爱好者 周末扫街', '喜欢拍老街和人文,器材不限,手机也能一起玩,拍完一起吃饭。', 0, '面议', '云岩区', '喷水池', '摄影,手机也行'],
|
||||
['小杨', '骑行群招募 周末环湖', '休闲骑,速度不快,观山湖集合,骑完喝茶,安全第一。', 0, '面议', '观山湖区', '观山湖公园', '骑行,休闲'],
|
||||
['小林', '桌游局 缺 2 人', '周六下午玩狼人杀和剧本,新手有人带,场地在花果园,费用 AA。', 0, '面议', '南明区', '花果园', '桌游,新手可来'],
|
||||
['小周', '单身青年联谊活动 报名', '25 到 35 岁,工作稳定,活动有游戏和自由聊天,提前报名。', 0, '面议', '南明区', '花果园', '联谊,提前报名'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/** 评价:post_id => [用户ID, 评分, 内容, 商家回复] */
|
||||
protected function seedComments($now)
|
||||
{
|
||||
$comments = [
|
||||
101 => [[1002, 5, '联系很及时,当天就上岗了。', ''], [2003, 5, '工资日结是真的,站长人也不错。', '']],
|
||||
102 => [[1003, 5, '店里氛围挺好,排班也合理。', '']],
|
||||
109 => [[1003, 4, '房子不错,房东好说话。', '感谢支持,欢迎续租~']],
|
||||
110 => [[1002, 5, '采光确实好,看房很方便。', '']],
|
||||
117 => [[2006, 5, '车况和描述一致,交易很顺利。', ''], [1001, 4, '卖家很爽快,还送了车锁。', '']],
|
||||
118 => [[2003, 5, '当面验过机,没有问题。', '']],
|
||||
125 => [[2003, 5, '检测报告齐全,买得放心。', '']],
|
||||
126 => [[1002, 4, '代步够用,充电也方便。', '']],
|
||||
133 => [[1001, 5, '师傅上门很准时,清洗得很干净。', '感谢认可,有需要随时联系。']],
|
||||
134 => [[2006, 5, '半夜叫的开锁,十分钟就到了。', '']],
|
||||
141 => [[1003, 5, '孩子很喜欢,老师也有耐心。', '']],
|
||||
142 => [[2003, 4, '讲得清楚,孩子愿意学。', '']],
|
||||
149 => [[1001, 5, '打扫得仔细,下次还约。', '']],
|
||||
150 => [[1003, 5, '开荒做得很干净,柜子里面都擦了。', '']],
|
||||
157 => [[1003, 5, '上周去过,路线轻松,人也很好。', '']],
|
||||
158 => [[1001, 5, '水平差不多,打得很尽兴。', '']],
|
||||
];
|
||||
|
||||
$id = 5001;
|
||||
$i = 0;
|
||||
foreach ($comments as $postId => $rows) {
|
||||
foreach ($rows as $row) {
|
||||
$t = $now - (int)((0.4 + $i * 0.23) * 86400);
|
||||
Db::name('fc_comment')->insert([
|
||||
'id' => $id,
|
||||
'post_id' => $postId,
|
||||
'user_id' => $row[0],
|
||||
'score' => $row[1],
|
||||
'content' => $row[2],
|
||||
'images' => json_encode([], JSON_UNESCAPED_UNICODE),
|
||||
'reply' => $row[3],
|
||||
'replytime' => $row[3] !== '' ? $t + 3600 : null,
|
||||
'top' => 0,
|
||||
'status' => 1,
|
||||
'createtime' => $t,
|
||||
'updatetime' => $t,
|
||||
]);
|
||||
$id++;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 草稿:保留两条未完成信息,用于验证草稿箱 */
|
||||
protected function seedDrafts($now)
|
||||
{
|
||||
$rows = [
|
||||
[1001, 2, '转租单间(草稿)', '房子还在收拾,晚点补照片。'],
|
||||
[1003, 7, '保洁套餐(草稿)', '想做一个三次卡的套餐,价格还没定。'],
|
||||
];
|
||||
$t = $now - 7200;
|
||||
foreach ($rows as $row) {
|
||||
Db::name('fc_draft')->insert([
|
||||
'user_id' => $row[0],
|
||||
'category_id' => $row[1],
|
||||
'title' => $row[2],
|
||||
'content' => $row[3],
|
||||
'media' => json_encode([], JSON_UNESCAPED_UNICODE),
|
||||
'contact' => '',
|
||||
'phone' => '',
|
||||
'address' => '',
|
||||
'savedat' => $t,
|
||||
'createtime' => $t,
|
||||
'updatetime' => $t,
|
||||
]);
|
||||
$t -= 1800;
|
||||
}
|
||||
}
|
||||
|
||||
/** 举报:两条不同状态,便于后台处理演示 */
|
||||
protected function seedReports($now)
|
||||
{
|
||||
$rows = [
|
||||
['post', 117, '价格与描述不一致', 1002, 'pending', '', 0.6],
|
||||
['comment', 5002, '评论里留了外部联系方式', 2006, 'handled', '已删除违规评论', 3],
|
||||
];
|
||||
foreach ($rows as $row) {
|
||||
$t = $now - (int)($row[6] * 86400);
|
||||
Db::name('fc_report')->insert([
|
||||
'target_type' => $row[0],
|
||||
'target_id' => $row[1],
|
||||
'reason' => $row[2],
|
||||
'reporter_id' => $row[3],
|
||||
'status' => $row[4],
|
||||
'remark' => $row[5],
|
||||
'createtime' => $t,
|
||||
'updatetime' => $t,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/** 回写分类信息量 / 评价数,保证列表计数与真实数据一致 */
|
||||
protected function syncCounts()
|
||||
{
|
||||
Db::execute('UPDATE `' . \think\Config::get('database.prefix') . 'fc_post` p SET p.`comment_count` = (SELECT COUNT(*) FROM `' . \think\Config::get('database.prefix') . 'fc_comment` c WHERE c.`post_id` = p.`id` AND c.`status` = 1)');
|
||||
|
||||
foreach ([1, 2, 3, 4, 5, 6, 7, 8] as $categoryId) {
|
||||
$count = Db::name('fc_post')
|
||||
->where('category_id', $categoryId)
|
||||
->where('audit_status', 1)
|
||||
->where('status', 1)
|
||||
->whereNull('deletetime')
|
||||
->count();
|
||||
Db::name('fc_category')->where('id', $categoryId)->update(['post_count' => $count]);
|
||||
}
|
||||
|
||||
// 同步商家有效发帖数
|
||||
$merchants = Db::name('fc_merchant')->field('id,user_id')->select();
|
||||
foreach ($merchants as $m) {
|
||||
$mCount = Db::name('fc_post')
|
||||
->where('user_id', $m['user_id'])
|
||||
->where('audit_status', 1)
|
||||
->where('status', 1)
|
||||
->whereNull('deletetime')
|
||||
->count();
|
||||
Db::name('fc_merchant')->where('id', $m['id'])->update(['post_count' => $mCount]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,9 @@ return [
|
||||
'Origin_price' => '原价',
|
||||
'Days' => '有效天数',
|
||||
'Post_quota' => '赠送发布条数',
|
||||
'Free_view_quota' => '每日免费看',
|
||||
'Free_view_quota' => '每日免费看(废弃)',
|
||||
'View_quota' => '每日浏览条数',
|
||||
'Call_quota' => '每日拨打次数',
|
||||
'Post_discount' => '超额发帖折扣',
|
||||
'Tag' => '标签',
|
||||
'Sort' => '排序',
|
||||
|
||||
@@ -372,12 +372,12 @@
|
||||
<button type="button" class="btn btn-success fc-btn-main" id="btn-open-icon-picker">
|
||||
<i class="fa fa-th-large"></i> 挑选果蔬实拍图
|
||||
</button>
|
||||
<button type="button" id="faupload-icon_key" class="btn btn-default faupload" data-input-id="c-icon_key" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/svg+xml" data-multiple="false">
|
||||
<button type="button" id="faupload-icon_key" class="btn btn-default faupload" data-input-id="c-icon_key" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/svg+xml" data-maxsize="500KB" data-multiple="false">
|
||||
<i class="fa fa-upload text-primary"></i> 上传实拍图
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<span class="help-block text-muted" style="margin-top:4px;margin-bottom:0;font-size:11px;">优先上传真实农产品照片,农民用户靠「看图识物」选择品类。</span>
|
||||
<span class="help-block text-muted" style="margin-top:4px;margin-bottom:0;font-size:11px;">优先上传真实农产品照片,农民用户靠「看图识物」选择品类;建议 500×500 以上方形图,单张不超过 <b class="text-danger">500KB</b>,过大的图片会拖慢小程序加载。</span>
|
||||
<input type="hidden" name="row[icon_key]" id="c-icon_key" value="cat-veg">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -372,12 +372,12 @@
|
||||
<button type="button" class="btn btn-success fc-btn-main" id="btn-open-icon-picker">
|
||||
<i class="fa fa-th-large"></i> 挑选果蔬实拍图
|
||||
</button>
|
||||
<button type="button" id="faupload-icon_key" class="btn btn-default faupload" data-input-id="c-icon_key" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/svg+xml" data-multiple="false">
|
||||
<button type="button" id="faupload-icon_key" class="btn btn-default faupload" data-input-id="c-icon_key" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/svg+xml" data-maxsize="500KB" data-multiple="false">
|
||||
<i class="fa fa-upload text-primary"></i> 上传实拍图
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<span class="help-block text-muted" style="margin-top:4px;margin-bottom:0;font-size:11px;">优先上传真实农产品照片,农民用户靠「看图识物」选择品类。</span>
|
||||
<span class="help-block text-muted" style="margin-top:4px;margin-bottom:0;font-size:11px;">优先上传真实农产品照片,农民用户靠「看图识物」选择品类;建议 500×500 以上方形图,单张不超过 <b class="text-danger">500KB</b>,过大的图片会拖慢小程序加载。</span>
|
||||
<input type="hidden" name="row[icon_key]" id="c-icon_key" value="{$row.icon_key|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -50,13 +50,23 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Free_view_quota')}:</label>
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('View_quota')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="input-group">
|
||||
<input id="c-free_view_quota" data-rule="required;integer;range(0~)" class="form-control" name="row[free_view_quota]" type="number" value="20">
|
||||
<input id="c-view_quota" data-rule="required;integer;range(0~)" class="form-control" name="row[view_quota]" type="number" value="20">
|
||||
<span class="input-group-addon">条 / 日</span>
|
||||
</div>
|
||||
<span class="help-block">会员每日免费查看联系方式条数(填 <code>0</code> 表示<strong>无限次免费查看</strong>)</span>
|
||||
<span class="help-block">会员每日免费浏览<strong>完整信息</strong>条数(填 <code>0</code> 表示<strong>不限次浏览</strong>)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Call_quota')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="input-group">
|
||||
<input id="c-call_quota" data-rule="required;integer;range(0~)" class="form-control" name="row[call_quota]" type="number" value="30">
|
||||
<span class="input-group-addon">次 / 日</span>
|
||||
</div>
|
||||
<span class="help-block">会员每日拨打电话次数(填 <code>0</code> 表示<strong>不限次拨打</strong>;普通用户次数在「付费设置」中配置)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
@@ -50,13 +50,23 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Free_view_quota')}:</label>
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('View_quota')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="input-group">
|
||||
<input id="c-free_view_quota" data-rule="required;integer;range(0~)" class="form-control" name="row[free_view_quota]" type="number" value="{$row.free_view_quota|default='20'|htmlentities}">
|
||||
<input id="c-view_quota" data-rule="required;integer;range(0~)" class="form-control" name="row[view_quota]" type="number" value="{$row.view_quota|default='20'|htmlentities}">
|
||||
<span class="input-group-addon">条 / 日</span>
|
||||
</div>
|
||||
<span class="help-block">会员每日免费查看联系方式条数(填 <code>0</code> 表示<strong>无限次免费查看</strong>)</span>
|
||||
<span class="help-block">会员每日免费浏览<strong>完整信息</strong>条数(填 <code>0</code> 表示<strong>不限次浏览</strong>)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Call_quota')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="input-group">
|
||||
<input id="c-call_quota" data-rule="required;integer;range(0~)" class="form-control" name="row[call_quota]" type="number" value="{$row.call_quota|default='30'|htmlentities}">
|
||||
<span class="input-group-addon">次 / 日</span>
|
||||
</div>
|
||||
<span class="help-block">会员每日拨打电话次数(填 <code>0</code> 表示<strong>不限次拨打</strong>;普通用户次数在「付费设置」中配置)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tab 2:联系方式浏览配置 -->
|
||||
<!-- Tab 2:完整信息浏览与拨打配置 -->
|
||||
<div class="tab-pane fade" id="tab-view">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">浏览模式:</label>
|
||||
@@ -103,30 +103,30 @@
|
||||
<div class="radio">
|
||||
<label style="margin-right: 24px;">
|
||||
<input type="radio" name="row[fc_fee_viewMode]" value="free" {if $row.viewMode=='free'}checked{/if}>
|
||||
<strong>完全免费公开</strong>(详情页直接明文展示手机号与微信,支持一键拨打)
|
||||
<strong>完全免费公开</strong>(完整信息对所有人直接展示,浏览不限次)
|
||||
</label>
|
||||
<label>
|
||||
<input type="radio" name="row[fc_fee_viewMode]" value="paid" {if $row.viewMode=='paid'}checked{/if}>
|
||||
<strong>付费或会员解锁</strong>(默认打码保护隐私,需单次付费或使用 VIP 免费看额度解锁)
|
||||
<strong>付费或会员解锁</strong>(非会员仅展示摘要,单条付费解锁;会员按套餐每日免费浏览)
|
||||
</label>
|
||||
</div>
|
||||
<div id="view-mode-free-tip" class="fc-mode-tip fc-mode-tip--free" style="{if $row.viewMode!='free'}display:none;{/if}">
|
||||
<i class="fa fa-check-circle"></i> 当前为「完全免费公开」:所有帖子电话与微信号零门槛直显,无需解锁。
|
||||
<i class="fa fa-check-circle"></i> 当前为「完全免费公开」:完整信息零门槛直显,会员浏览额度自动休眠不计数。
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="view-paid-fields" style="{if $row.viewMode=='free'}display:none;{/if}">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">非会员单次查看价:</label>
|
||||
<label class="control-label col-xs-12 col-sm-2">非会员单条解锁价:</label>
|
||||
<div class="col-xs-12 col-sm-4">
|
||||
<div class="input-group">
|
||||
<input type="number" min="0" step="0.01" class="form-control" name="row[fc_fee_payView]" value="{$row.payViewPrice|htmlentities}" data-rule="required;range(0~)"/>
|
||||
<span class="input-group-addon">元 / 次</span>
|
||||
<span class="input-group-addon">元 / 条</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<span class="help-block">普通用户超额后解锁单条帖子拨打权限的价格(同一条信息一次解锁永久有效)</span>
|
||||
<span class="help-block">非会员解锁单条完整信息的价格(一次解锁永久有效;填 <code>0</code> 等同免费公开模式)</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -142,20 +142,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<span class="help-block">详情页与商家详情页统一隐藏明文手机号,仅保留拨打按钮;填 <code>0</code> 表示不限次数</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">VIP会员每日拨打上限:</label>
|
||||
<div class="col-xs-12 col-sm-4">
|
||||
<div class="input-group">
|
||||
<input type="number" min="0" step="1" class="form-control" name="row[fc_call_vipDailyQuota]" value="{$row.callVipDailyQuota|default=30|htmlentities}" data-rule="required;integer;range(0~)"/>
|
||||
<span class="input-group-addon">次 / 日</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<span class="help-block">VIP 会员每日可拨打电话次数上限(填 <code>0</code> 表示 VIP 会员不限拨打次数)</span>
|
||||
<span class="help-block">仅对非会员生效;手机号任何模式都不展示,只保留拨打按钮;填 <code>0</code> 表示不限次数。会员拨打次数请在「会员套餐」中按套餐配置</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -57,10 +57,10 @@ class AdminMember extends V1
|
||||
}
|
||||
|
||||
/**
|
||||
* AMB2 会员权益配置
|
||||
* POST /api/v1/admin/member/benefit 入参 {freeView,postDiscount,distRate,benefits[]}
|
||||
* → {freeView,postDiscount,distRate,benefits[]}
|
||||
* 未被传入的字段保持原值;freeView <0 报错
|
||||
* AMB2 会员权益配置(兜底默认值;各套餐的浏览/拨打次数以 fc_plan 为准)
|
||||
* POST /api/v1/admin/member/benefit 入参 {viewQuota,callQuota,postDiscount,distRate,benefits[]}
|
||||
* → {viewQuota,callQuota,postDiscount,distRate,benefits[]}
|
||||
* 未被传入的字段保持原值;次数 <0 报错
|
||||
*/
|
||||
public function saveBenefit()
|
||||
{
|
||||
@@ -69,12 +69,23 @@ class AdminMember extends V1
|
||||
$current = [];
|
||||
}
|
||||
|
||||
$freeView = $this->input('freeView', null);
|
||||
if ($freeView !== null && $freeView !== '') {
|
||||
if ((int)$freeView < 0) {
|
||||
$this->fail('免费查看条数不能为负');
|
||||
$viewQuota = $this->input('viewQuota', null);
|
||||
if ($viewQuota === null) {
|
||||
$viewQuota = $this->input('freeView', null); // 兼容旧字段
|
||||
}
|
||||
if ($viewQuota !== null && $viewQuota !== '') {
|
||||
if ((int)$viewQuota < 0) {
|
||||
$this->fail('每日浏览条数不能为负');
|
||||
}
|
||||
$current['freeView'] = (int)$freeView;
|
||||
$current['viewQuota'] = (int)$viewQuota;
|
||||
}
|
||||
|
||||
$callQuota = $this->input('callQuota', null);
|
||||
if ($callQuota !== null && $callQuota !== '') {
|
||||
if ((int)$callQuota < 0) {
|
||||
$this->fail('每日拨打次数不能为负');
|
||||
}
|
||||
$current['callQuota'] = (int)$callQuota;
|
||||
}
|
||||
|
||||
$postDiscount = $this->input('postDiscount', null);
|
||||
@@ -101,7 +112,8 @@ class AdminMember extends V1
|
||||
}
|
||||
|
||||
$defaults = [
|
||||
'freeView' => 20,
|
||||
'viewQuota' => 20,
|
||||
'callQuota' => 30,
|
||||
'postDiscount' => '8 折',
|
||||
'distRate' => '一级 20% / 二级 10%',
|
||||
'benefits' => [],
|
||||
@@ -112,7 +124,8 @@ class AdminMember extends V1
|
||||
$this->adminLog('修改会员权益配置');
|
||||
|
||||
$this->ok([
|
||||
'freeView' => (int)$current['freeView'],
|
||||
'viewQuota' => (int)$current['viewQuota'],
|
||||
'callQuota' => (int)$current['callQuota'],
|
||||
'postDiscount' => (string)$current['postDiscount'],
|
||||
'distRate' => (string)$current['distRate'],
|
||||
'benefits' => array_values((array)$current['benefits']),
|
||||
|
||||
@@ -17,7 +17,7 @@ use app\common\library\DistributionService;
|
||||
class Member extends V1
|
||||
{
|
||||
/**
|
||||
* M1 会员套餐(套餐价格 + 赠送发帖数 + 每日免费看次数 + 超额发帖折扣 一体化返回)
|
||||
* M1 会员套餐(套餐价格 + 赠送发帖数 + 每日浏览/拨打次数 + 超额发帖折扣 一体化返回)
|
||||
* GET /api/v1/member/plans
|
||||
* 规则:仅 enabled=1,按 sort asc
|
||||
*/
|
||||
@@ -30,7 +30,8 @@ class Member extends V1
|
||||
|
||||
$list = [];
|
||||
foreach ($rows as $row) {
|
||||
$freeViewQuota = isset($row['free_view_quota']) ? max(0, (int)$row['free_view_quota']) : 20;
|
||||
$viewQuota = isset($row['view_quota']) ? max(0, (int)$row['view_quota']) : 20;
|
||||
$callQuota = isset($row['call_quota']) ? max(0, (int)$row['call_quota']) : 30;
|
||||
$discountNum = isset($row['post_discount']) ? \app\common\library\FcConfig::parseDiscountNum($row['post_discount']) : 8.0;
|
||||
$list[] = [
|
||||
'planId' => (string)$row['plan_code'],
|
||||
@@ -40,8 +41,10 @@ class Member extends V1
|
||||
'days' => (int)$row['days'],
|
||||
'tag' => (string)$row['tag'],
|
||||
'postQuota' => isset($row['post_quota']) ? (int)$row['post_quota'] : 0,
|
||||
'freeViewQuota' => $freeViewQuota,
|
||||
'freeViewUnlimited' => ($freeViewQuota === 0),
|
||||
'viewQuota' => $viewQuota,
|
||||
'viewUnlimited' => ($viewQuota === 0),
|
||||
'callQuota' => $callQuota,
|
||||
'callUnlimited' => ($callQuota === 0),
|
||||
'postDiscountNum' => $discountNum,
|
||||
'postDiscount' => \app\common\library\FcConfig::formatDiscountText($discountNum),
|
||||
'benefits' => \app\common\library\FcConfig::buildPlanBenefits($row),
|
||||
@@ -61,8 +64,10 @@ class Member extends V1
|
||||
$ext = $me ? $this->ext($me['id']) : null;
|
||||
|
||||
$benefitCfg = \app\common\library\FcConfig::resolveMemberBenefit($ext);
|
||||
$freeViewQuota = (int)$benefitCfg['freeView'];
|
||||
$freeViewUnlimited = ($freeViewQuota === 0);
|
||||
$viewQuota = (int)$benefitCfg['viewQuota'];
|
||||
$viewUnlimited = ($viewQuota === 0);
|
||||
$callQuota = (int)$benefitCfg['callQuota'];
|
||||
$callUnlimited = ($callQuota === 0);
|
||||
$postDiscountNum = (float)$benefitCfg['postDiscountNum'];
|
||||
$postDiscount = (string)$benefitCfg['postDiscount'];
|
||||
$benefits = (array)$benefitCfg['benefits'];
|
||||
@@ -79,8 +84,10 @@ class Member extends V1
|
||||
$viewMode = ($viewModeRaw === 'free' || $payViewPrice <= 0) ? 'free' : 'paid';
|
||||
|
||||
$isMember = false;
|
||||
$freeViewUsed = 0;
|
||||
$freeViewLeft = 0;
|
||||
$viewUsed = 0;
|
||||
$viewLeft = 0;
|
||||
$callUsed = 0;
|
||||
$callLeft = 0;
|
||||
$postQuotaLeft = 0;
|
||||
$memberExpireAt = null;
|
||||
|
||||
@@ -89,15 +96,27 @@ class Member extends V1
|
||||
$isMember = (int)$ext['is_member'] === 1
|
||||
&& !empty($ext['member_expiretime']) && (int)$ext['member_expiretime'] > $now;
|
||||
$today = date('Y-m-d');
|
||||
$freeViewUsed = ((string)$ext['free_view_date'] === $today) ? (int)$ext['free_view_used'] : 0;
|
||||
$freeViewLeft = $isMember ? ($freeViewUnlimited ? -1 : max(0, $freeViewQuota - $freeViewUsed)) : 0;
|
||||
if ($isMember) {
|
||||
$viewUsed = (int)Db::name('fc_view_log')
|
||||
->where('user_id', (int)$me['id'])
|
||||
->where('view_date', $today)
|
||||
->count();
|
||||
$viewLeft = $viewUnlimited ? -1 : max(0, $viewQuota - $viewUsed);
|
||||
$callUsed = (int)Db::name('fc_call_log')
|
||||
->where('user_id', (int)$me['id'])
|
||||
->where('call_date', $today)
|
||||
->count();
|
||||
$callLeft = $callUnlimited ? -1 : max(0, $callQuota - $callUsed);
|
||||
}
|
||||
$postQuotaLeft = $this->quotaLeft($ext);
|
||||
$memberExpireAt = !empty($ext['member_expiretime']) ? $this->iso($ext['member_expiretime']) : null;
|
||||
}
|
||||
|
||||
$this->ok([
|
||||
'freeView' => $freeViewQuota,
|
||||
'freeViewUnlimited' => $freeViewUnlimited,
|
||||
'viewQuota' => $viewQuota,
|
||||
'viewUnlimited' => $viewUnlimited,
|
||||
'callQuota' => $callQuota,
|
||||
'callUnlimited' => $callUnlimited,
|
||||
'postDiscountNum' => $postDiscountNum,
|
||||
'postDiscount' => $postDiscount,
|
||||
'maxPlanQuota' => $maxPlanQuota,
|
||||
@@ -105,9 +124,10 @@ class Member extends V1
|
||||
'viewMode' => $viewMode,
|
||||
'benefits' => $benefits,
|
||||
'isMember' => $isMember,
|
||||
'freeViewQuota' => $freeViewQuota,
|
||||
'freeViewUsed' => $freeViewUsed,
|
||||
'freeViewLeft' => $freeViewLeft,
|
||||
'viewUsed' => $viewUsed,
|
||||
'viewLeft' => $viewLeft,
|
||||
'callUsed' => $callUsed,
|
||||
'callLeft' => $callLeft,
|
||||
'postQuotaLeft' => $postQuotaLeft,
|
||||
'memberExpireAt' => $memberExpireAt,
|
||||
]);
|
||||
@@ -276,7 +296,6 @@ class Member extends V1
|
||||
}
|
||||
$days = $plan ? max(0, (int)$plan['days']) : 30;
|
||||
$quota = $plan && isset($plan['post_quota']) ? max(0, (int)$plan['post_quota']) : 0;
|
||||
$freeViewQuota = $plan && isset($plan['free_view_quota']) ? max(0, (int)$plan['free_view_quota']) : 20;
|
||||
$postDiscount = $plan && isset($plan['post_discount']) ? round((float)$plan['post_discount'], 1) : 8.0;
|
||||
$level = $plan ? (string)$plan['name'] : '会员';
|
||||
|
||||
@@ -299,7 +318,6 @@ class Member extends V1
|
||||
'is_member' => 1,
|
||||
'member_level' => $level,
|
||||
'member_expiretime' => $expire,
|
||||
'free_view_quota' => $freeViewQuota,
|
||||
'post_quota_left' => $left,
|
||||
'post_quota_expire' => $expire,
|
||||
'post_discount' => $postDiscount,
|
||||
@@ -415,13 +433,18 @@ class Member extends V1
|
||||
];
|
||||
}
|
||||
|
||||
$ext = $this->ext($user['id']);
|
||||
$isMember = (int)$ext['is_member'] === 1
|
||||
&& !empty($ext['member_expiretime']) && (int)$ext['member_expiretime'] > $now;
|
||||
|
||||
$this->ok([
|
||||
'balance' => (float)$user['money'],
|
||||
'isMember' => $isMember,
|
||||
'coupons' => $coupons,
|
||||
'couponCount' => count($coupons),
|
||||
'points' => (int)$user['score'],
|
||||
'payPasswordEnabled' => (int)$this->cfg('pay.payPasswordEnabled', 0) === 1,
|
||||
'hasPayPassword' => (string)$this->ext($user['id'])['pay_password'] !== '',
|
||||
'hasPayPassword' => (string)$ext['pay_password'] !== '',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -922,23 +922,7 @@ class Post extends V1
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情页联系方式可见性(避免「已开通会员仍显示已受保护」)
|
||||
*
|
||||
* 可见规则(与 payView 计费口径一致):
|
||||
* ① 会员有效期内 → 免费看
|
||||
* ② 已付费解锁 fc_pay_view → 看(余额 / 微信回调写入)
|
||||
* ③ 本人发布的信息 → 看
|
||||
* 其它(游客 / 非会员未付费)→ 仍返回脱敏串
|
||||
*
|
||||
* 出参新增:unlocked(bool)、wechat(明文,未解锁为空串)。
|
||||
* 注意:只加在详情接口,列表(首页/收藏等)仍保持脱敏,避免手机号被批量抓取。
|
||||
*
|
||||
* @param array $data buildPost() 结果
|
||||
* @param array $post fc_post 行
|
||||
* @return array
|
||||
*/
|
||||
/**
|
||||
* 判断当前全站是否处于「联系方式完全免费公开」模式
|
||||
* 判断当前全站是否处于「完整信息免费公开」模式
|
||||
* 规则:fee.viewMode === 'free' 或 fee.payView <= 0 时均为免费公开
|
||||
*
|
||||
* @return bool
|
||||
@@ -951,13 +935,17 @@ class Post extends V1
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情页联系方式与内容访问控制(支持完全免费公开模式与商业付费/会员解锁模式自由切换)
|
||||
* 详情页完整信息访问控制(免费公开 / 付费解锁 / 会员每日额度 三态自由切换)
|
||||
*
|
||||
* 可见规则:
|
||||
* ① 全站处于「完全免费公开」模式(fee.viewMode=free 或 fee.payView<=0)→ unlocked=true,直接明文返回
|
||||
* ② 本人发布的信息或已付费解锁记录(fc_pay_view)→ unlocked=true,返回真实联系方式明文
|
||||
* ③ 会员享有每日免费查看额度(freeView=0 代表会员不限次数免费看),未点击解锁时不泄露真实号码
|
||||
* ④ 未解锁状态下,对标题与详细正文中的手机号执行掩码遮蔽,封堵正文直接贴电话的白嫖漏洞
|
||||
* 联系方式规则:任何模式下界面都不展示手机号(明文与脱敏串均不返回),仅保留拨打按钮,
|
||||
* 由 POST /post/:id/dial 校验拨打额度后调起系统拨号。
|
||||
*
|
||||
* 完整信息(正文/农产品规格)规则:
|
||||
* ① 免费公开模式(fee.viewMode=free 或 fee.payView<=0)→ 直接放行
|
||||
* ② 本人发布 或 已付费解锁(fc_pay_view,永久)→ 放行
|
||||
* ③ 会员:每日免费浏览额度(fc_plan.view_quota,0=不限),同一条当日只计 1 次
|
||||
* ④ 额度用尽 / 非会员未解锁 → content 仅返回摘要,contentLocked=true
|
||||
* 防白嫖:标题与正文中出现的手机号始终动态遮蔽。
|
||||
*
|
||||
* @param array $data buildPost() 结果
|
||||
* @param array $post fc_post 行
|
||||
@@ -965,70 +953,57 @@ class Post extends V1
|
||||
*/
|
||||
protected function contactAccess($data, $post)
|
||||
{
|
||||
$data['unlocked'] = false;
|
||||
$data['wechat'] = '';
|
||||
|
||||
$me = $this->user();
|
||||
$ext = $me ? $this->ext($me['id']) : null;
|
||||
$now = time();
|
||||
$userId = $me ? (int)$me['id'] : 0;
|
||||
|
||||
$isMember = false;
|
||||
$quota = $this->memberFreeViewQuota($ext);
|
||||
$freeViewUnlimited = ($quota === 0);
|
||||
$used = 0;
|
||||
$freeViewLeft = 0;
|
||||
$payViewPrice = max(0, round((float)$this->cfg('fee.payView', 2), 2));
|
||||
$isFreeView = $this->isFreeViewMode();
|
||||
|
||||
$isOwner = false;
|
||||
$paid = false;
|
||||
|
||||
if ($me && $ext) {
|
||||
$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;
|
||||
if ($isMember) {
|
||||
$freeViewLeft = $freeViewUnlimited ? 999 : max(0, $quota - $used);
|
||||
} else {
|
||||
$freeViewLeft = 0;
|
||||
$isFreeView = $this->isFreeViewMode();
|
||||
$payViewPrice = max(0, round((float)$this->cfg('fee.payView', 2), 2));
|
||||
$isOwner = $userId > 0 && (int)$post['user_id'] === $userId;
|
||||
|
||||
// ---- 已付费解锁记录(永久解锁,任何模式不占每日额度) ----
|
||||
$paid = false;
|
||||
if ($userId > 0) {
|
||||
$paid = (bool)Db::name('fc_pay_view')
|
||||
->where('user_id', $userId)
|
||||
->where('post_id', (int)$post['id'])
|
||||
->find();
|
||||
}
|
||||
|
||||
// ---- 完整信息解锁判定 ----
|
||||
$unlocked = false;
|
||||
$viewState = null; // 会员付费模式下的浏览额度状态(含本次消耗后的最新值)
|
||||
if ($isFreeView || $isOwner || $paid) {
|
||||
$unlocked = true;
|
||||
} elseif ($isMember) {
|
||||
// 会员每日浏览额度(view_quota=0 代表不限),同一条当日只计 1 次
|
||||
$viewState = $this->viewQuotaState($userId, $ext);
|
||||
if ($this->hasViewedToday($userId, (int)$post['id'])) {
|
||||
$unlocked = true; // 今日已浏览过该条,不重复扣额度
|
||||
} elseif ($viewState['unlimited'] || $viewState['left'] > 0) {
|
||||
$this->recordViewLog($userId, (int)$post['id']);
|
||||
$viewState['used'] += 1;
|
||||
$viewState['left'] = $viewState['unlimited'] ? 999 : max(0, $viewState['total'] - $viewState['used']);
|
||||
$unlocked = true;
|
||||
}
|
||||
}
|
||||
|
||||
$data['viewMode'] = $isFreeView ? 'free' : 'paid';
|
||||
$data['isMember'] = $isMember;
|
||||
$data['freeViewQuota'] = $quota;
|
||||
$data['freeViewUnlimited'] = $freeViewUnlimited;
|
||||
$data['freeViewUsed'] = $used;
|
||||
$data['freeViewLeft'] = $freeViewLeft;
|
||||
$data['payViewPrice'] = $isFreeView ? 0 : $payViewPrice;
|
||||
$contentLocked = !$unlocked;
|
||||
|
||||
// 每日电话拨打次数上限与剩余额度(详情预览页隐藏明文手机号,仅保留免责声明弹窗拨打)
|
||||
$callState = $this->callQuotaState($me ? (int)$me['id'] : 0, $isMember);
|
||||
$rawPhone = (string)$post['phone'];
|
||||
$contactName = (string)(isset($post['contact']) ? $post['contact'] : '');
|
||||
$maskedPhone = $this->maskPhone($rawPhone);
|
||||
// ---- 正文与农产品规格锁定 ----
|
||||
if ($contentLocked) {
|
||||
$data['content'] = $this->contentPreview((string)$data['content'], 100);
|
||||
unset($data['plantArea'], $data['harvestTime'], $data['outputRange']);
|
||||
}
|
||||
|
||||
$data['hasPhone'] = $rawPhone !== '';
|
||||
$data['dialDisplay'] = $this->buildDialDisplay($contactName, $rawPhone);
|
||||
$data['callQuotaTotal'] = $callState['total'];
|
||||
$data['callQuotaUsed'] = $callState['used'];
|
||||
$data['callQuotaLeft'] = $callState['left'];
|
||||
$data['canDial'] = $isOwner || $paid || $callState['unlimited'] || $callState['left'] > 0;
|
||||
|
||||
// 界面上始终隐藏明文手机号(仅返回脱敏号码),通过 POST /post/:id/dial 校验额度并调起系统拨号
|
||||
$data['unlocked'] = ($isFreeView || $isOwner || $paid);
|
||||
$data['phone'] = $maskedPhone;
|
||||
$data['contact'] = $maskedPhone;
|
||||
$data['contactName'] = $contactName;
|
||||
$data['wechat'] = '';
|
||||
|
||||
// 标题与详细描述中的任何手机号执行动态安全遮蔽,防止正文直接贴电话
|
||||
// 标题与正文中出现的手机号始终遮蔽,防止正文贴电话绕过限制
|
||||
if (!empty($data['content'])) {
|
||||
$data['content'] = $this->maskTextPhones($data['content']);
|
||||
}
|
||||
@@ -1036,39 +1011,138 @@ class Post extends V1
|
||||
$data['title'] = $this->maskTextPhones($data['title']);
|
||||
}
|
||||
|
||||
// ---- 拨打额度状态 ----
|
||||
$callState = $this->callQuotaState($userId, $isMember);
|
||||
|
||||
$data['unlocked'] = $unlocked;
|
||||
$data['contentLocked'] = $contentLocked;
|
||||
$data['viewMode'] = $isFreeView ? 'free' : 'paid';
|
||||
$data['payViewPrice'] = $isFreeView ? 0 : $payViewPrice;
|
||||
$data['isMember'] = $isMember;
|
||||
|
||||
// 会员每日浏览额度(免费公开模式不展示、不计数)
|
||||
$data['viewQuotaTotal'] = $viewState ? $viewState['total'] : 0;
|
||||
$data['viewQuotaUsed'] = $viewState ? $viewState['used'] : 0;
|
||||
$data['viewQuotaLeft'] = $viewState ? $viewState['left'] : 0;
|
||||
$data['viewQuotaUnlimited'] = $viewState ? $viewState['unlimited'] : false;
|
||||
|
||||
$data['hasPhone'] = (string)$post['phone'] !== '';
|
||||
// 任何模式均不返回手机号(明文与脱敏串都不给),界面只保留拨打按钮,
|
||||
// 由 POST /post/:id/dial 校验拨打额度后调起系统拨号
|
||||
$data['phone'] = '';
|
||||
$data['contact'] = (string)(isset($post['contact']) ? $post['contact'] : '');
|
||||
$data['contactName'] = (string)(isset($post['contact']) ? $post['contact'] : '');
|
||||
$data['callQuotaTotal'] = $callState['total'];
|
||||
$data['callQuotaUsed'] = $callState['used'];
|
||||
$data['callQuotaLeft'] = $callState['left'];
|
||||
$data['canDial'] = $isOwner || $paid || $callState['unlimited'] || $callState['left'] > 0;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造免责声明拨打弹窗展示文案(如:夏178****8426)
|
||||
* 计算会员今日的完整信息浏览额度状态(真源:fc_plan.view_quota;0 代表不限)
|
||||
* 是否今日已浏览过某条 → hasViewedToday 单独判断
|
||||
*
|
||||
* @param string $contactName 联系人姓名
|
||||
* @param string $phone 手机号
|
||||
* @param int $userId 用户ID
|
||||
* @param array $ext fc_user_ext 行
|
||||
* @return array{total:int,used:int,left:int,unlimited:bool}
|
||||
*/
|
||||
protected function viewQuotaState($userId, $ext = null)
|
||||
{
|
||||
$benefit = \app\common\library\FcConfig::resolveMemberBenefit($ext);
|
||||
$total = isset($benefit['viewQuota']) ? max(0, (int)$benefit['viewQuota']) : 20;
|
||||
$unlimited = ($total === 0);
|
||||
|
||||
$today = date('Y-m-d');
|
||||
$used = (int)Db::name('fc_view_log')
|
||||
->where('user_id', (int)$userId)
|
||||
->where('view_date', $today)
|
||||
->count();
|
||||
|
||||
return [
|
||||
'total' => $total,
|
||||
'used' => $used,
|
||||
'left' => $unlimited ? 999 : max(0, $total - $used),
|
||||
'unlimited' => $unlimited,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录一条完整信息浏览日志(同一条当日幂等,重复浏览不产生新记录)
|
||||
*
|
||||
* @param int $userId 用户ID
|
||||
* @param int $postId 信息ID
|
||||
* @return bool 是否成功写入新记录
|
||||
*/
|
||||
protected function recordViewLog($userId, $postId)
|
||||
{
|
||||
$today = date('Y-m-d');
|
||||
$exist = Db::name('fc_view_log')
|
||||
->where('user_id', (int)$userId)
|
||||
->where('post_id', (int)$postId)
|
||||
->where('view_date', $today)
|
||||
->find();
|
||||
if ($exist) {
|
||||
return false;
|
||||
}
|
||||
Db::name('fc_view_log')->insert([
|
||||
'user_id' => (int)$userId,
|
||||
'post_id' => (int)$postId,
|
||||
'view_date' => $today,
|
||||
'createtime' => time(),
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断用户今日是否已浏览过指定信息
|
||||
*
|
||||
* @param int $userId 用户ID
|
||||
* @param int $postId 信息ID
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasViewedToday($userId, $postId)
|
||||
{
|
||||
return (bool)Db::name('fc_view_log')
|
||||
->where('user_id', (int)$userId)
|
||||
->where('post_id', (int)$postId)
|
||||
->where('view_date', date('Y-m-d'))
|
||||
->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 截取正文摘要(锁定态展示,保留首行主信息)
|
||||
*
|
||||
* @param string $content 正文
|
||||
* @param int $length 摘要长度(字符)
|
||||
* @return string
|
||||
*/
|
||||
protected function buildDialDisplay($contactName, $phone)
|
||||
protected function contentPreview($content, $length = 100)
|
||||
{
|
||||
$masked = $this->maskPhone($phone);
|
||||
$name = trim((string)$contactName);
|
||||
if ($name === '') {
|
||||
return $masked;
|
||||
$text = trim((string)$content);
|
||||
if ($text === '' || mb_strlen($text, 'UTF-8') <= $length) {
|
||||
return $text;
|
||||
}
|
||||
$surname = mb_substr($name, 0, 1, 'UTF-8');
|
||||
return $surname . $masked;
|
||||
return mb_substr($text, 0, $length, 'UTF-8') . '…';
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算指定用户今日的电话拨打额度状态
|
||||
*
|
||||
* 会员:每日拨打次数真源 = 所属 fc_plan 套餐 call_quota(0 代表不限)
|
||||
* 非会员:全局配置 call.normalDailyQuota(0 代表不限)
|
||||
* @param int $userId 用户ID(0表示游客)
|
||||
* @param bool $isMember 是否为有效期内VIP会员
|
||||
* @return array{total:int,used:int,left:int,unlimited:bool}
|
||||
*/
|
||||
protected function callQuotaState($userId, $isMember)
|
||||
{
|
||||
$normalQuota = max(0, (int)$this->cfg('call.normalDailyQuota', 5));
|
||||
$vipQuota = max(0, (int)$this->cfg('call.vipDailyQuota', 30));
|
||||
$total = $isMember ? $vipQuota : $normalQuota;
|
||||
if ($isMember) {
|
||||
$benefit = \app\common\library\FcConfig::resolveMemberBenefit();
|
||||
$total = isset($benefit['callQuota']) ? max(0, (int)$benefit['callQuota']) : 30;
|
||||
} else {
|
||||
$total = max(0, (int)$this->cfg('call.normalDailyQuota', 5));
|
||||
}
|
||||
$unlimited = ($total === 0);
|
||||
|
||||
$used = 0;
|
||||
@@ -1091,7 +1165,7 @@ class Post extends V1
|
||||
/**
|
||||
* P6-B 信息详情页申请拨打电话(校验每日拨打次数上限并记录拨打日志)
|
||||
* POST /api/v1/post/:id/dial
|
||||
* → {phoneNumber, dialDisplay, callQuotaTotal, callQuotaUsed, callQuotaLeft}
|
||||
* → {phoneNumber, callQuotaTotal, callQuotaUsed, callQuotaLeft}
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -1125,8 +1199,8 @@ class Post extends V1
|
||||
// 非本人且未单条付费解锁时,校验每日拨打次数上限
|
||||
if (!$isOwner && !$paid && !$state['unlimited'] && $state['left'] <= 0) {
|
||||
$msg = $isMember
|
||||
? ('您今日的 VIP 拨打次数已达上限(' . $state['total'] . '次/日)')
|
||||
: ('您今日的免费拨打次数已达上限(' . $state['total'] . '次/日),开通 VIP 会员可享每日更多拨打次数');
|
||||
? ('您今日的拨打次数已达上限(' . $state['total'] . '次/日),明日再来或升级更高套餐')
|
||||
: ('您今日的免费拨打次数已达上限(' . $state['total'] . '次/日),开通会员可享更多拨打次数');
|
||||
$this->fail($msg, 403);
|
||||
}
|
||||
|
||||
@@ -1145,7 +1219,6 @@ class Post extends V1
|
||||
|
||||
$this->ok([
|
||||
'phoneNumber' => $phone,
|
||||
'dialDisplay' => $this->buildDialDisplay(isset($post['contact']) ? $post['contact'] : '', $phone),
|
||||
'callQuotaTotal' => $state['total'],
|
||||
'callQuotaUsed' => $newUsed,
|
||||
'callQuotaLeft' => $newLeft,
|
||||
@@ -1153,56 +1226,11 @@ class Post extends V1
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员每日免费查看条数(从用户所属 fc_plan 套餐或默认套餐读取;0 代表会员无限次免费看)
|
||||
*
|
||||
* @param array|null $ext fc_user_ext 行
|
||||
* @return int
|
||||
*/
|
||||
protected function memberFreeViewQuota($ext = null)
|
||||
{
|
||||
$benefit = \app\common\library\FcConfig::resolveMemberBenefit($ext);
|
||||
return isset($benefit['freeView']) ? max(0, (int)$benefit['freeView']) : 20;
|
||||
}
|
||||
|
||||
/**
|
||||
* 消耗一次会员免费查看额度(跨天自动重置;quota=0 代表会员不限次数无限看;需在事务内调用)
|
||||
*
|
||||
* @param int $userId
|
||||
* @param int $quota
|
||||
* @return bool 是否成功占用
|
||||
*/
|
||||
protected function consumeFreeView($userId, $quota)
|
||||
{
|
||||
$today = date('Y-m-d');
|
||||
$ext = Db::name('fc_user_ext')->where('user_id', (int)$userId)->lock(true)->find();
|
||||
if (!$ext) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((string)$ext['free_view_date'] !== $today) {
|
||||
Db::name('fc_user_ext')->where('user_id', (int)$userId)->update([
|
||||
'free_view_date' => $today,
|
||||
'free_view_used' => 1,
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($quota > 0 && (int)$ext['free_view_used'] >= $quota) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Db::name('fc_user_ext')->where('user_id', (int)$userId)->setInc('free_view_used', 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* P6 付费查看联系方式
|
||||
* P6 付费解锁完整信息(单条永久解锁)
|
||||
* POST /api/v1/post/:id/pay-view {payType}
|
||||
* → {unlocked:true,contact:{phone,wechat}}(免费公开/余额/会员免费:立即解锁)
|
||||
* → {order:{orderNo,amount,payType,status:'pending'}}(微信支付:前端再调 POST /pay/prepay 调起收银台)
|
||||
* 规则 BR-05;金额取 fee.payView;全站免费模式、会员额度内或已解锁免费
|
||||
* → {unlocked:true}(余额:立即解锁)
|
||||
* → {order:{orderNo,amount,payType,status:'pending'}}(微信支付:前端再调 POST /pay/prepay 调起收银台,回调写解锁记录)
|
||||
* 适用:付费模式下非会员,或会员每日浏览额度用尽后的单条解锁;免费公开模式无需解锁
|
||||
*/
|
||||
public function payView()
|
||||
{
|
||||
@@ -1210,10 +1238,7 @@ class Post extends V1
|
||||
$id = $this->routeId();
|
||||
|
||||
$payType = (string)$this->input('payType', '');
|
||||
if ($payType === '') {
|
||||
$payType = 'free';
|
||||
}
|
||||
if (!in_array($payType, ['wxpay', 'balance', 'free'], true)) {
|
||||
if (!in_array($payType, ['wxpay', 'balance'], true)) {
|
||||
$this->fail('支付方式不支持');
|
||||
}
|
||||
|
||||
@@ -1222,128 +1247,94 @@ class Post extends V1
|
||||
$this->fail('信息不存在', 404);
|
||||
}
|
||||
|
||||
$phone = (string)$post['phone'];
|
||||
$wechat = $post['wechat'] !== '' ? (string)$post['wechat'] : ('tongcheng_' . $id);
|
||||
$contactName = (string)(isset($post['contact']) ? $post['contact'] : '');
|
||||
|
||||
$contact = [
|
||||
'name' => $contactName,
|
||||
'phone' => $phone,
|
||||
'wechat' => $wechat,
|
||||
];
|
||||
|
||||
$amount = max(0, round((float)$this->cfg('fee.payView', 2), 2));
|
||||
$isFreeView = $this->isFreeViewMode();
|
||||
$now = time();
|
||||
if ($isFreeView) {
|
||||
$this->ok(['unlocked' => true, 'freeMode' => true]);
|
||||
}
|
||||
|
||||
$ext = $this->ext($user['id']);
|
||||
$isMember = (int)$ext['is_member'] === 1
|
||||
&& !empty($ext['member_expiretime']) && (int)$ext['member_expiretime'] > $now;
|
||||
$quota = $this->memberFreeViewQuota($ext);
|
||||
$freeViewUnlimited = ($quota === 0);
|
||||
$isOwner = (int)$post['user_id'] === (int)$user['id'];
|
||||
if ($isOwner) {
|
||||
$this->ok(['unlocked' => true, 'freeMode' => true]);
|
||||
}
|
||||
|
||||
// 已解锁直接返回(严格返回纯净扁平字段,杜绝 JSON 嵌套导致前端格式错乱)
|
||||
// 已解锁直接返回
|
||||
$exist = Db::name('fc_pay_view')
|
||||
->where('user_id', $user['id'])
|
||||
->where('post_id', $id)
|
||||
->find();
|
||||
if ($exist) {
|
||||
$today = date('Y-m-d');
|
||||
$usedToday = ((string)$ext['free_view_date'] === $today) ? (int)$ext['free_view_used'] : 0;
|
||||
$this->ok([
|
||||
'unlocked' => true,
|
||||
'phone' => $phone,
|
||||
'contact' => $contact,
|
||||
'contactName' => $contactName,
|
||||
'wechat' => $wechat,
|
||||
'contactInfo' => $contact,
|
||||
'freeViewUnlimited' => $freeViewUnlimited,
|
||||
'freeViewLeft' => $isMember ? ($freeViewUnlimited ? 999 : max(0, $quota - $usedToday)) : 0,
|
||||
]);
|
||||
$this->ok(['unlocked' => true]);
|
||||
}
|
||||
|
||||
$amount = max(0, round((float)$this->cfg('fee.payView', 2), 2));
|
||||
$now = time();
|
||||
$orderId = 0;
|
||||
$pending = null;
|
||||
|
||||
// 后台开启支付密码时,余额支付需校验(全站免费或会员免费额度未用完时走免费,不要求密码)
|
||||
if (!$isFreeView && $payType === 'balance' && !$isMember) {
|
||||
// 后台开启支付密码时,余额支付需校验
|
||||
if ($payType === 'balance') {
|
||||
$this->verifyPayPassword($user);
|
||||
}
|
||||
|
||||
try {
|
||||
Db::transaction(function () use (&$orderId, &$pending, $isFreeView, $isMember, $quota, $payType, $amount, $user, $id, $now) {
|
||||
if ($isFreeView) {
|
||||
// 全站免费浏览模式(或解锁单价设为 0 元):直接免单解锁,避免走 0 元支付死锁
|
||||
$amount = 0;
|
||||
$payType = 'free';
|
||||
} else {
|
||||
// 会员每日免费查看额度(quota=0 代表会员不限次数;当天用完后按正常付费)
|
||||
$usedFree = $isMember ? $this->consumeFreeView((int)$user['id'], $quota) : false;
|
||||
|
||||
if ($usedFree) {
|
||||
$amount = 0;
|
||||
$payType = 'free';
|
||||
} elseif ($payType === 'free') {
|
||||
// 用户希望使用会员免费特权,但额度已耗尽或非会员
|
||||
throw new \RuntimeException($isMember ? '今日会员免费查看额度已用完,请选择支付方式付费查看' : '该内容需付费查看,请选择支付方式');
|
||||
} elseif ($payType === 'balance') {
|
||||
// 条件扣款:并发下不会扣成负数
|
||||
$affected = Db::name('user')
|
||||
->where('id', (int)$user['id'])
|
||||
->where('money', '>=', $amount)
|
||||
->setDec('money', $amount);
|
||||
if (!$affected) {
|
||||
throw new \RuntimeException('余额不足,请充值或使用微信支付');
|
||||
}
|
||||
$balance = (float)Db::name('user')->where('id', (int)$user['id'])->value('money');
|
||||
// 余额支付为「即时支付」:同步落一笔已支付订单,保证「我的订单」与微信支付口径一致
|
||||
$orderNo = $this->orderNo('VO');
|
||||
$orderId = Db::name('fc_order')->insertGetId([
|
||||
'order_no' => $orderNo,
|
||||
'user_id' => $user['id'],
|
||||
'type' => 'payview',
|
||||
'title' => '付费查看 #' . $id,
|
||||
'amount' => $amount,
|
||||
'pay_type' => 'balance',
|
||||
'status' => 'paid',
|
||||
'paytime' => $now,
|
||||
'related_id' => $id,
|
||||
'createtime' => $now,
|
||||
'updatetime' => $now,
|
||||
]);
|
||||
$this->flow('expense', '付费查看', $amount, $balance, $id, '', (int)$user['id']);
|
||||
// 钱包流水(fa_user.money 减)→ 余额中心「余额明细」
|
||||
$this->walletFlow($user['id'], 'expense', '付费查看', $amount, $balance, $id, '解锁信息 #' . $id);
|
||||
// 余额支付同样触发分销结算(与微信回调 OrderFulfill::handle 口径一致)
|
||||
$orderRow = Db::name('fc_order')->where('id', $orderId)->find();
|
||||
if ($orderRow) {
|
||||
DistributionService::settleOrder($orderRow);
|
||||
}
|
||||
} else {
|
||||
// 微信支付:只落 pending 订单(不预写解锁记录),
|
||||
// 支付成功后由 /pay/notify 按 type=payview + related_id 解锁(回调可独立完成)
|
||||
$orderNo = $this->orderNo('VO');
|
||||
Db::name('fc_order')->insert([
|
||||
'order_no' => $orderNo,
|
||||
'user_id' => $user['id'],
|
||||
'type' => 'payview',
|
||||
'title' => '付费查看 #' . $id,
|
||||
'amount' => $amount,
|
||||
'pay_type' => 'wxpay',
|
||||
'status' => 'pending',
|
||||
'paytime' => null,
|
||||
'related_id' => $id,
|
||||
'createtime' => $now,
|
||||
'updatetime' => $now,
|
||||
]);
|
||||
$pending = [
|
||||
'orderNo' => $orderNo,
|
||||
'amount' => $amount,
|
||||
'payType' => 'wxpay',
|
||||
'status' => 'pending',
|
||||
];
|
||||
return;
|
||||
Db::transaction(function () use (&$orderId, &$pending, $payType, $amount, $user, $id, $now) {
|
||||
if ($payType === 'balance') {
|
||||
// 条件扣款:并发下不会扣成负数
|
||||
$affected = Db::name('user')
|
||||
->where('id', (int)$user['id'])
|
||||
->where('money', '>=', $amount)
|
||||
->setDec('money', $amount);
|
||||
if (!$affected) {
|
||||
throw new \RuntimeException('余额不足,请充值或使用微信支付');
|
||||
}
|
||||
$balance = (float)Db::name('user')->where('id', (int)$user['id'])->value('money');
|
||||
// 余额支付为「即时支付」:同步落一笔已支付订单,保证「我的订单」与微信支付口径一致
|
||||
$orderNo = $this->orderNo('VO');
|
||||
$orderId = Db::name('fc_order')->insertGetId([
|
||||
'order_no' => $orderNo,
|
||||
'user_id' => $user['id'],
|
||||
'type' => 'payview',
|
||||
'title' => '解锁信息 #' . $id,
|
||||
'amount' => $amount,
|
||||
'pay_type' => 'balance',
|
||||
'status' => 'paid',
|
||||
'paytime' => $now,
|
||||
'related_id' => $id,
|
||||
'createtime' => $now,
|
||||
'updatetime' => $now,
|
||||
]);
|
||||
$this->flow('expense', '解锁信息', $amount, $balance, $id, '', (int)$user['id']);
|
||||
// 钱包流水(fa_user.money 减)→ 余额中心「余额明细」
|
||||
$this->walletFlow($user['id'], 'expense', '解锁信息', $amount, $balance, $id, '解锁信息 #' . $id);
|
||||
// 余额支付同样触发分销结算(与微信回调 OrderFulfill::handle 口径一致)
|
||||
$orderRow = Db::name('fc_order')->where('id', $orderId)->find();
|
||||
if ($orderRow) {
|
||||
DistributionService::settleOrder($orderRow);
|
||||
}
|
||||
} else {
|
||||
// 微信支付:只落 pending 订单(不预写解锁记录),
|
||||
// 支付成功后由 /pay/notify 按 type=payview + related_id 解锁(回调可独立完成)
|
||||
$orderNo = $this->orderNo('VO');
|
||||
Db::name('fc_order')->insert([
|
||||
'order_no' => $orderNo,
|
||||
'user_id' => $user['id'],
|
||||
'type' => 'payview',
|
||||
'title' => '解锁信息 #' . $id,
|
||||
'amount' => $amount,
|
||||
'pay_type' => 'wxpay',
|
||||
'status' => 'pending',
|
||||
'paytime' => null,
|
||||
'related_id' => $id,
|
||||
'createtime' => $now,
|
||||
'updatetime' => $now,
|
||||
]);
|
||||
$pending = [
|
||||
'orderNo' => $orderNo,
|
||||
'amount' => $amount,
|
||||
'payType' => 'wxpay',
|
||||
'status' => 'pending',
|
||||
];
|
||||
return;
|
||||
}
|
||||
|
||||
Db::name('fc_pay_view')->insert([
|
||||
@@ -1375,20 +1366,8 @@ class Post extends V1
|
||||
}
|
||||
}
|
||||
|
||||
$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,
|
||||
'phone' => $phone,
|
||||
'contact' => $contact,
|
||||
'contactName' => $contactName,
|
||||
'wechat' => $wechat,
|
||||
'contactInfo' => $contact,
|
||||
'freeViewUnlimited' => $freeViewUnlimited,
|
||||
'freeViewLeft' => $isMember ? ($freeViewUnlimited ? 999 : max(0, $quota - $usedNow)) : 0,
|
||||
'usedFree' => isset($usedFree) ? $usedFree : false,
|
||||
'unlocked' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,5 +22,4 @@ return [
|
||||
'app\admin\command\FcSettle',
|
||||
'app\admin\command\FcVerifyDist',
|
||||
'app\admin\command\FcVerifyMember',
|
||||
'app\admin\command\FcSeedPosts',
|
||||
];
|
||||
|
||||
@@ -85,7 +85,6 @@ class FcConfig
|
||||
'viewMode' => $viewMode,
|
||||
'payViewPrice' => max(0, $payViewPrice),
|
||||
'callNormalDailyQuota' => max(0, (int)$pick('call.normalDailyQuota', 5)),
|
||||
'callVipDailyQuota' => max(0, (int)$pick('call.vipDailyQuota', 30)),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -136,22 +135,30 @@ class FcConfig
|
||||
/**
|
||||
* 根据后台实时配置与启用套餐,自动生成 100% 准确的会员权益文案列表(无需手写)
|
||||
*
|
||||
* @param int $freeView 每日免费查看条数(0 = 无限次)
|
||||
* @param int $viewQuota 每日免费浏览完整信息条数(0 = 不限)
|
||||
* @param int $callQuota 每日拨打电话次数(0 = 不限)
|
||||
* @param float $discountNum 超额单条发布折扣值(1~10)
|
||||
* @return array<int,string>
|
||||
*/
|
||||
public static function buildAutoBenefits($freeView, $discountNum)
|
||||
public static function buildAutoBenefits($viewQuota, $callQuota, $discountNum)
|
||||
{
|
||||
$list = [];
|
||||
|
||||
// 1. 联系方式查看特权
|
||||
if ((int)$freeView > 0) {
|
||||
$list[] = '每日免费查看 ' . (int)$freeView . ' 条同城信息联系方式';
|
||||
// 1. 完整信息浏览特权
|
||||
if ((int)$viewQuota > 0) {
|
||||
$list[] = '每日免费浏览 ' . (int)$viewQuota . ' 条完整信息';
|
||||
} else {
|
||||
$list[] = '全站同城信息联系方式无限次免费查看';
|
||||
$list[] = '完整信息无限次免费浏览';
|
||||
}
|
||||
|
||||
// 2. 套餐赠送免费发布额度特权(实时读取 fc_plan 启用套餐)
|
||||
// 2. 拨打电话特权
|
||||
if ((int)$callQuota > 0) {
|
||||
$list[] = '每日可拨打 ' . (int)$callQuota . ' 次电话联系发布者';
|
||||
} else {
|
||||
$list[] = '拨打电话不限次数';
|
||||
}
|
||||
|
||||
// 3. 套餐赠送免费发布额度特权(实时读取 fc_plan 启用套餐)
|
||||
try {
|
||||
$plans = Db::name('fc_plan')->where('enabled', 1)->order('sort asc')->select();
|
||||
$quotaParts = [];
|
||||
@@ -170,21 +177,21 @@ class FcConfig
|
||||
$list[] = '开通套餐立赠海量免费发布额度';
|
||||
}
|
||||
|
||||
// 3. 超额单条发布折扣特权
|
||||
// 4. 超额单条发布折扣特权
|
||||
$num = round((float)$discountNum, 1);
|
||||
if ($num > 0 && $num < 10) {
|
||||
$clean = rtrim(rtrim(number_format($num, 1, '.', ''), '0'), '.');
|
||||
$list[] = '赠送额度用尽后,单条付费发布专享 ' . $clean . ' 折优惠';
|
||||
}
|
||||
|
||||
// 4. 尊贵身份标识
|
||||
// 5. 尊贵身份标识
|
||||
$list[] = '全站帖子详情与个人主页点亮 VIP 专属金标';
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为单个会员套餐生成专属权益文案列表(直接读取套餐行的 post_quota / free_view_quota / post_discount)
|
||||
* 为单个会员套餐生成专属权益文案列表(直接读取套餐行权益字段)
|
||||
*
|
||||
* @param array $plan fc_plan 表行数据
|
||||
* @return array<int,string>
|
||||
@@ -192,14 +199,22 @@ class FcConfig
|
||||
public static function buildPlanBenefits(array $plan)
|
||||
{
|
||||
$postQuota = isset($plan['post_quota']) ? max(0, (int)$plan['post_quota']) : 0;
|
||||
$freeView = isset($plan['free_view_quota']) ? max(0, (int)$plan['free_view_quota']) : 20;
|
||||
$viewQuota = isset($plan['view_quota']) ? max(0, (int)$plan['view_quota']) : 20;
|
||||
$callQuota = isset($plan['call_quota']) ? max(0, (int)$plan['call_quota']) : 30;
|
||||
$discount = isset($plan['post_discount']) ? self::parseDiscountNum($plan['post_discount']) : 8.0;
|
||||
|
||||
$list = [];
|
||||
if ($freeView > 0) {
|
||||
$list[] = '每日免费查看 ' . $freeView . ' 条同城信息联系方式';
|
||||
|
||||
if ($viewQuota > 0) {
|
||||
$list[] = '每日免费浏览 ' . $viewQuota . ' 条完整信息';
|
||||
} else {
|
||||
$list[] = '全站同城信息联系方式无限次免费查看';
|
||||
$list[] = '完整信息无限次免费浏览';
|
||||
}
|
||||
|
||||
if ($callQuota > 0) {
|
||||
$list[] = '每日可拨打 ' . $callQuota . ' 次电话联系发布者';
|
||||
} else {
|
||||
$list[] = '拨打电话不限次数';
|
||||
}
|
||||
|
||||
if ($postQuota > 0) {
|
||||
@@ -221,7 +236,7 @@ class FcConfig
|
||||
* 解析指定用户(或默认推荐套餐)对应的会员权益数据(真源:fc_plan 套餐表)
|
||||
*
|
||||
* @param array|null $ext fc_user_ext 行(可为空)
|
||||
* @return array{freeView:int,postDiscountNum:float,postDiscount:string,benefits:array}
|
||||
* @return array{viewQuota:int,callQuota:int,postDiscountNum:float,postDiscount:string,benefits:array}
|
||||
*/
|
||||
public static function resolveMemberBenefit($ext = null)
|
||||
{
|
||||
@@ -243,12 +258,14 @@ class FcConfig
|
||||
}
|
||||
|
||||
if ($plan) {
|
||||
$freeView = isset($plan['free_view_quota']) ? max(0, (int)$plan['free_view_quota']) : 20;
|
||||
$viewQuota = isset($plan['view_quota']) ? max(0, (int)$plan['view_quota']) : 20;
|
||||
$callQuota = isset($plan['call_quota']) ? max(0, (int)$plan['call_quota']) : 30;
|
||||
$discountNum = isset($plan['post_discount']) ? self::parseDiscountNum($plan['post_discount']) : 8.0;
|
||||
$postDiscount = self::formatDiscountText($discountNum);
|
||||
$benefitsArr = self::buildPlanBenefits($plan);
|
||||
return [
|
||||
'freeView' => $freeView,
|
||||
'viewQuota' => $viewQuota,
|
||||
'callQuota' => $callQuota,
|
||||
'postDiscountNum' => $discountNum,
|
||||
'postDiscount' => $postDiscount,
|
||||
'benefits' => $benefitsArr,
|
||||
@@ -274,16 +291,18 @@ class FcConfig
|
||||
}
|
||||
}
|
||||
|
||||
$freeView = isset($benefitCfg['freeView']) ? max(0, (int)$benefitCfg['freeView']) : 20;
|
||||
$viewQuota = isset($benefitCfg['viewQuota']) ? max(0, (int)$benefitCfg['viewQuota']) : 20;
|
||||
$callQuota = isset($benefitCfg['callQuota']) ? max(0, (int)$benefitCfg['callQuota']) : 30;
|
||||
$rawDiscount = isset($benefitCfg['postDiscountNum'])
|
||||
? $benefitCfg['postDiscountNum']
|
||||
: (isset($benefitCfg['postDiscount']) ? $benefitCfg['postDiscount'] : 8);
|
||||
$discountNum = self::parseDiscountNum($rawDiscount);
|
||||
$postDiscount = self::formatDiscountText($discountNum);
|
||||
$benefitsArr = self::buildAutoBenefits($freeView, $discountNum);
|
||||
$benefitsArr = self::buildAutoBenefits($viewQuota, $callQuota, $discountNum);
|
||||
|
||||
return [
|
||||
'freeView' => $freeView,
|
||||
'viewQuota' => $viewQuota,
|
||||
'callQuota' => $callQuota,
|
||||
'postDiscountNum' => $discountNum,
|
||||
'postDiscount' => $postDiscount,
|
||||
'benefits' => $benefitsArr,
|
||||
@@ -468,7 +487,7 @@ class FcConfig
|
||||
self::put($key, $value, 'post', '发布配置');
|
||||
}
|
||||
|
||||
// 联系方式浏览规则(若表单同时传入则一并保存)
|
||||
// 完整信息浏览规则(若表单同时传入则一并保存)
|
||||
if (isset($row['fc_fee_viewMode']) || isset($row['fc_fee_payView'])) {
|
||||
$viewMode = isset($row['fc_fee_viewMode']) ? trim((string)$row['fc_fee_viewMode']) : 'paid';
|
||||
if (!in_array($viewMode, ['free', 'paid'], true)) {
|
||||
@@ -476,22 +495,18 @@ class FcConfig
|
||||
}
|
||||
$payView = $num('fc_fee_payView', 2);
|
||||
if ($payView < 0) {
|
||||
throw new \Exception('非会员查看价格不能为负');
|
||||
throw new \Exception('非会员单条解锁价格不能为负');
|
||||
}
|
||||
// 若选了完全免费公开,或单次价格设为 0,统一保障免费可看
|
||||
self::put('fee.viewMode', $viewMode, 'fee', '联系方式浏览模式:free免费公开 / paid付费或会员解锁');
|
||||
self::put('fee.payView', $viewMode === 'free' ? 0 : $payView, 'fee', '非会员单条查看联系方式价格');
|
||||
self::put('fee.viewMode', $viewMode, 'fee', '完整信息浏览模式:free免费公开 / paid付费或会员额度解锁');
|
||||
self::put('fee.payView', $viewMode === 'free' ? 0 : $payView, 'fee', '非会员单条解锁完整信息价格');
|
||||
}
|
||||
|
||||
// 每日电话拨打次数限制(详情页与商家主页共用额度池)
|
||||
// 普通用户(非会员)每日拨打次数限制(会员拨打次数由各套餐 call_quota 控制)
|
||||
if (isset($row['fc_call_normalDailyQuota'])) {
|
||||
$normalQuota = max(0, $int('fc_call_normalDailyQuota', 5));
|
||||
self::put('call.normalDailyQuota', $normalQuota, 'call', '普通用户每日免费拨打次数上限(0表示不限制)');
|
||||
}
|
||||
if (isset($row['fc_call_vipDailyQuota'])) {
|
||||
$vipQuota = max(0, $int('fc_call_vipDailyQuota', 30));
|
||||
self::put('call.vipDailyQuota', $vipQuota, 'call', 'VIP会员每日拨打次数上限(0表示不限制)');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -503,7 +518,8 @@ class FcConfig
|
||||
*/
|
||||
public static function saveMember(array $row)
|
||||
{
|
||||
$freeView = isset($row['fc_member_freeView']) ? max(0, (int)$row['fc_member_freeView']) : 20;
|
||||
$viewQuota = isset($row['fc_member_viewQuota']) ? max(0, (int)$row['fc_member_viewQuota']) : 20;
|
||||
$callQuota = isset($row['fc_member_callQuota']) ? max(0, (int)$row['fc_member_callQuota']) : 30;
|
||||
$rawDiscount = isset($row['fc_member_postDiscountNum'])
|
||||
? $row['fc_member_postDiscountNum']
|
||||
: (isset($row['fc_member_postDiscount']) ? $row['fc_member_postDiscount'] : 8);
|
||||
@@ -512,7 +528,7 @@ class FcConfig
|
||||
throw new \Exception('发布折扣需在 0.1 ~ 10 之间(10 表示不打折)');
|
||||
}
|
||||
$postDiscount = self::formatDiscountText($discountNum);
|
||||
$benefits = self::buildAutoBenefits($freeView, $discountNum);
|
||||
$benefits = self::buildAutoBenefits($viewQuota, $callQuota, $discountNum);
|
||||
|
||||
$current = [];
|
||||
$raw = Db::name('fc_config')->where('key', 'member.benefit')->value('value');
|
||||
@@ -522,7 +538,8 @@ class FcConfig
|
||||
$current = $decoded;
|
||||
}
|
||||
}
|
||||
$current['freeView'] = $freeView;
|
||||
$current['viewQuota'] = $viewQuota;
|
||||
$current['callQuota'] = $callQuota;
|
||||
$current['postDiscountNum'] = $discountNum;
|
||||
$current['postDiscount'] = $postDiscount;
|
||||
$current['benefits'] = $benefits;
|
||||
|
||||
在新工单中引用
屏蔽一个用户