feat: 新增分销分佣结算、商家认证及草稿管理功能,优化界面与版本更新

这个提交包含在:
2026-10-21 20:06:40 +08:00
父节点 d508949921
当前提交 088a08d43a
共有 117 个文件被更改,包括 10254 次插入 和 3000 次删除

查看文件

@@ -269,9 +269,12 @@ class FcInstall extends Command
$changed++;
}
// ② fc_merchant:店铺头图 / 店铺公告 / 推荐位(后台「店铺装修」可编辑)
// ② fc_merchant:店铺头图 / 店铺公告 / 推荐位 / 实体店地址与经纬度
$merchantTable = $prefix . 'fc_merchant';
$merchantCols = [
['address', "varchar(255) NOT NULL DEFAULT '' COMMENT '实体店详细地址'", '`contact`'],
['lat', 'decimal(10,6) NULL COMMENT \'纬度 gcj02\'', '`address`'],
['lng', 'decimal(10,6) NULL COMMENT \'经度 gcj02\'', '`lat`'],
['banner', "varchar(255) NOT NULL DEFAULT '' COMMENT '店铺头图'", '`logo`'],
['notice', "varchar(255) NOT NULL DEFAULT '' COMMENT '店铺公告'", '`banner`'],
['recommend', "tinyint(1) NOT NULL DEFAULT 0 COMMENT '推荐位:1 推荐 0 普通'", '`notice`'],
@@ -451,7 +454,7 @@ class FcInstall extends Command
$groupId['fc'] = $topId;
$newItems = [
'fc/dashboard' => ['fc', '数据总览', 'fa fa-dashboard', 99],
'fc/setting' => ['fc', '系统设置', 'fa fa-cogs', 40],
'fc/setting' => ['fc', '小程序设置', 'fa fa-cogs', 40],
'fc/coupon' => ['fc/trade', '优惠券管理', 'fa fa-ticket', 88],
];
$newIds = [];
@@ -969,7 +972,7 @@ class FcInstall extends Command
$banners = self::BANNERS;
foreach ($banners as $i => $b) {
Db::name('fc_banner')->insert([
'title' => $b[0], 'image' => '', 'link' => $b[1], 'color' => $b[2],
'title' => $b[0], 'image' => '/uploads/banners/banner-' . ($i + 1) . '.png', 'link' => $b[1], 'color' => $b[2],
'sort' => $i + 1, 'enabled' => 1, 'createtime' => $now, 'updatetime' => $now,
]);
}

查看文件

@@ -0,0 +1,207 @@
<?php
namespace app\admin\command;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
use app\common\library\DistributionService;
/**
* 分销全链路自动化验证命令
*
* 验证:上下级关系建立 -> 订单支付自动分佣 -> 佣金结算 -> 申请提现与打款
*/
class FcVerifyDist extends Command
{
protected function configure()
{
$this->setName('fc:verify-dist')
->setDescription('验证分销与分佣核心链路闭环');
}
protected function execute(Input $input, Output $output)
{
$output->writeln('==> 开始执行分销全链路闭环自动化测试');
$now = time();
// 1. 创建 3 个临时测试用户
$rand = mt_rand(1000, 9999);
$userAId = (int)$this->createMockUser('test_dist_a_' . $rand, '推广员A');
$userBId = (int)$this->createMockUser('test_dist_b_' . $rand, '推广员B');
$userCId = (int)$this->createMockUser('test_dist_c_' . $rand, '消费者C');
$extA = Db::name('fc_user_ext')->where('user_id', $userAId)->find();
$codeA = $extA['invite_code'];
$extB = Db::name('fc_user_ext')->where('user_id', $userBId)->find();
$codeB = $extB['invite_code'];
$output->writeln(" [+] 创建测试用户: A(#{$userAId}, code:{$codeA}), B(#{$userBId}, code:{$codeB}), C(#{$userCId})");
// 2. 绑定关系:B 绑定 A (1级)
$resB = DistributionService::bindRelation($userBId, 0, $codeA);
if (!$resB) {
$output->writeln(' [x] B 绑定 A 失败');
return;
}
$relB = Db::name('fc_dist_relation')->where('user_id', $userBId)->select();
$output->writeln(' [+] B 绑定 A 成功,关系数: ' . count($relB));
// 3. 绑定关系:C 绑定 B (B为1级,A为2级)
$resC = DistributionService::bindRelation($userCId, 0, $codeB);
if (!$resC) {
$output->writeln(' [x] C 绑定 B 失败');
return;
}
$relC1 = Db::name('fc_dist_relation')->where('user_id', $userCId)->where('level', 1)->find();
$relC2 = Db::name('fc_dist_relation')->where('user_id', $userCId)->where('level', 2)->find();
if (!$relC1 || (int)$relC1['parent_id'] !== $userBId) {
$output->writeln(' [x] C 的 1 级推荐人不是 B');
return;
}
if (!$relC2 || (int)$relC2['parent_id'] !== $userAId) {
$output->writeln(' [x] C 的 2 级推荐人不是 A');
return;
}
$output->writeln(" [+] 递归关系链路校验通过: C(#{$userCId}) -> 1级 B(#{$userBId}) -> 2级 A(#{$userAId})");
// 4. 模拟消费:C 购买了 100 元的会员套餐订单
$orderNo = 'TEST' . date('YmdHis') . $userCId;
$orderId = Db::name('fc_order')->insertGetId([
'order_no' => $orderNo,
'user_id' => $userCId,
'type' => 'member',
'title' => '测试年卡会员',
'amount' => 100.00,
'pay_type' => 'balance',
'status' => 'paid',
'paytime' => $now,
'related_id' => 1,
'createtime' => $now,
'updatetime' => $now,
]);
$order = Db::name('fc_order')->where('id', $orderId)->find();
$output->writeln(" [+] 模拟生成已支付订单: #{$orderId}, 订单号: {$orderNo}, 金额: 100.00元");
// 5. 触发分销分佣结算
$settled = DistributionService::settleOrder($order);
$output->writeln(' [+] 触发分佣结算,生成分佣记录条数: ' . count($settled));
$commB = Db::name('fc_commission')->where('order_no', $orderNo)->where('user_id', $userBId)->find();
$commA = Db::name('fc_commission')->where('order_no', $orderNo)->where('user_id', $userAId)->find();
if (!$commB || (float)$commB['amount'] <= 0) {
$output->writeln(' [x] B 的 1 级分佣未正确生成');
return;
}
if (!$commA || (float)$commA['amount'] <= 0) {
$output->writeln(' [x] A 的 2 级分佣未正确生成');
return;
}
$output->writeln(" [+] 分佣金额精确校验通过: 1级推广员B 获得 ¥{$commB['amount']} (比例 {$commB['rate']}%),2级推广员A 获得 ¥{$commA['amount']} (比例 {$commA['rate']}%)");
// 6. 检查分销商站内信通知
$msgB = Db::name('fc_message')->where('user_id', $userBId)->where('type', 'interact')->find();
if ($msgB) {
$output->writeln(" [+] 推广员B 收到分销收益站内信: 「{$msgB['title']}」- {$msgB['content']}");
}
// 7. 提现流程验证(B 发起提现申请)
$withdrawableB = (float)Db::name('fc_commission')->where('user_id', $userBId)->where('status', 1)->sum('amount');
$output->writeln(" [+] 推广员B 当前可提现佣金: ¥{$withdrawableB}");
$withdrawNo = 'WD' . date('YmdHis') . $userBId;
$withdrawId = Db::name('fc_withdraw')->insertGetId([
'withdraw_no' => $withdrawNo,
'user_id' => $userBId,
'amount' => $withdrawableB,
'channel' => 'wxpay',
'status' => 'auditing',
'createtime' => $now,
'updatetime' => $now,
]);
$output->writeln(" [+] 推广员B 提交全额提现申请 #{$withdrawId}, 提现单号: {$withdrawNo}, 状态: auditing");
// 模拟管理员打款操作
Db::name('fc_withdraw')->where('id', $withdrawId)->update([
'status' => 'paid',
'paytime' => time(),
'updatetime' => time(),
]);
Db::name('fc_finance_flow')->insert([
'flow_no' => 'WD' . date('YmdHis') . $withdrawId,
'type' => 'expense',
'scene' => '佣金提现',
'amount' => $withdrawableB,
'balance' => 0,
'related_id' => $withdrawId,
'remark' => '自动化测试打款',
'createtime' => time(),
]);
$output->writeln(" [+] 后台管理员审核打款完成,记入资金流水支出 ¥{$withdrawableB}");
// 8. 清理本次测试产生的测试数据
Db::name('user')->where('id', 'in', [$userAId, $userBId, $userCId])->delete();
Db::name('fc_user_ext')->where('user_id', 'in', [$userAId, $userBId, $userCId])->delete();
Db::name('fc_dist_relation')->where('user_id', 'in', [$userAId, $userBId, $userCId])->delete();
Db::name('fc_order')->where('id', $orderId)->delete();
Db::name('fc_commission')->where('order_no', $orderNo)->delete();
Db::name('fc_message')->where('user_id', 'in', [$userAId, $userBId, $userCId])->delete();
Db::name('fc_withdraw')->where('id', $withdrawId)->delete();
Db::name('fc_finance_flow')->where('related_id', $withdrawId)->delete();
$output->writeln(' [+] 测试数据自动清理完毕');
$output->writeln('==> 【验证成功】分销拓客 -> 订单消费 -> 自动分润 -> 收益通知 -> 申请提现 -> 财务打款 全链路 100% 打通!');
}
/**
* 创建用于测试的模拟用户
* @param string $username 用户名
* @param string $nickname 昵称
* @return int 用户ID
*/
protected function createMockUser($username, $nickname)
{
$now = time();
$uid = Db::name('user')->insertGetId([
'group_id' => 1,
'username' => $username,
'nickname' => $nickname,
'password' => md5('123456'),
'salt' => 'mock',
'email' => $username . '@mock.local',
'mobile' => '188' . mt_rand(10000000, 99999999),
'avatar' => '',
'level' => 1,
'money' => 500.00,
'score' => 0,
'status' => 'normal',
'jointime' => $now,
'createtime' => $now,
'updatetime' => $now,
]);
Db::name('fc_user_ext')->insert([
'user_id' => $uid,
'openid' => 'mock_' . $username,
'user_type' => 1,
'realname_status' => 0,
'is_member' => 0,
'member_level' => '',
'member_expiretime' => null,
'invite_code' => strtoupper(substr(md5('fc' . $uid . mt_rand()), 0, 6)),
'inviter_id' => 0,
'free_view_date' => date('Y-m-d'),
'free_view_used' => 0,
'createtime' => $now,
'updatetime' => $now,
]);
return $uid;
}
}

查看文件

@@ -6,24 +6,20 @@ use app\common\controller\Backend;
use think\Db;
/**
* 同城-系统设置
* 同城-小程序设置
*
* 页面职责(同一路由 fc/setting/index):
* ① 基础配置 base.appName / base.logo / base.servicePhone / base.aboutUs / base.shareTitle(可保存)
* ② 支付配置 **只读展示** —— 支付能力已改由 epay 插件承载,商户号/密钥/小程序 AppID 的真源是
* 「插件管理 → 微信支付宝整合插件 → 配置」(持久化在 addons/epay/config.php)。
* 本页只显示插件配置的就绪状态并给出跳转,**不再**维护 wx.mchId / wx.apiKey / wx.payNotifyUrl
* (这三个 fc_config 键已废弃,避免出现「两份配置、改了一份不生效」)。
*
* 键名以 Api 端现有实现为准,保证「后台写入」与「Api 读取」是同一份 fc_config:
* - 基础配置与 application/api/controller/AdminSetting.php::base() 完全一致(base.*)。
* 页面职责(路由 fc/setting/index):
* 维护小程序端基础信息配置:小程序名称、LOGO、客服电话、关于我们、分享标题。
* 保存后写入 fa_fc_config 表的 base.* 键,供小程序端接口统一读取。
*
* @icon fa fa-cogs
*/
class Setting extends Backend
{
/**
* 配置页(GET 显示 / POST 保存基础配置)
* 小程序基础设置首页(GET 显示表单 / POST 保存基础配置)
*
* @return string|null 渲染页面或响应重定向
*/
public function index()
{
@@ -32,14 +28,13 @@ class Setting extends Backend
}
$this->view->assign('row', $this->current());
$this->view->assign('pay', $this->payStatus());
return $this->view->fetch();
}
/**
* 保存基础配置
* 保存小程序基础配置
*
* 说明:支付配置已迁到插件页,本页不再接收 group=pay 的提交(如提交则给出明确指引)。
* @return void
*/
protected function save()
{
@@ -47,11 +42,6 @@ class Setting extends Backend
if (!is_array($params)) {
$params = $this->request->post();
}
$group = isset($params['group']) ? trim((string)$params['group']) : 'base';
if ($group === 'pay') {
$this->error('微信支付参数已改由插件维护,请到「插件管理 → 微信支付宝整合插件 → 配置」填写');
}
$appName = isset($params['appName']) ? trim((string)$params['appName']) : '';
if ($appName === '') {
@@ -66,14 +56,14 @@ class Setting extends Backend
'base.shareTitle' => ['value' => isset($params['shareTitle']) ? trim((string)$params['shareTitle']) : '', 'group_key' => 'base', 'remark' => '分享标题'],
]);
$this->success('基础配置已保存');
return null;
$this->success('小程序设置已保存');
}
/**
* 批量写入 fc_config(存在则更新,不存在则新增)
*
* @param array $values 结构:键名 => ['value' => 值, 'group_key' => 分组, 'remark' => 备注]
* @return void
*/
protected function setConfig(array $values)
{
@@ -100,7 +90,9 @@ class Setting extends Backend
}
/**
* 当前基础配置(缺失时回落内置默认值)
* 获取当前小程序基础配置(若数据库未设置则回退内置默认值)
*
* @return array 包含 appName, logo, servicePhone, aboutUs, shareTitle 的配置数组
*/
protected function current()
{
@@ -120,49 +112,4 @@ class Setting extends Backend
'shareTitle' => $pick('base.shareTitle', ''),
];
}
/**
* 支付配置状态(只读,数据来自 epay 插件配置)
*
* @return array 插件是否安装 / 是否就绪 / 关键项是否填写 / 回调地址 / 配置页地址 / 配置文件名
*/
protected function payStatus()
{
$info = (array)get_addon_info('epay');
$addonConfig = (array)get_addon_config('epay');
$wx = (isset($addonConfig['wechat']) && is_array($addonConfig['wechat'])) ? $addonConfig['wechat'] : [];
$mode = isset($wx['mode']) ? (string)$wx['mode'] : 'normal';
// 与用户端 Pay::epayReady() 同一判定口径
if ($mode === 'service') {
$ready = !empty($wx['sub_mch_id']) && !empty($wx['key']) && !empty($wx['sub_miniapp_id']);
} else {
$ready = !empty($wx['miniapp_id']) && !empty($wx['mch_id']) && !empty($wx['key']);
}
return [
'installed' => !empty($info),
'ready' => $ready,
'version' => isset($addonConfig['version']) ? (string)$addonConfig['version'] : '',
'mode' => $mode === 'service' ? 'service' : 'normal',
'miniappId' => isset($wx['miniapp_id']) ? (string)$wx['miniapp_id'] : '',
'mchId' => isset($wx['mch_id']) ? (string)$wx['mch_id'] : '',
'hasKey' => !empty($wx['key']),
'notifyUrl' => $this->notifyUrl(),
'configUrl' => url('addon/config', ['name' => 'epay']),
'configFile' => 'addons/epay/config.php',
];
}
/**
* 微信支付回调地址(与服务端 Pay::notifyUrl() 同一算法:当前域名 + 固定路径)
*/
protected function notifyUrl()
{
$base = rtrim((string)$this->request->root(true), '/');
// 去掉入口文件(后台入口 s.php / 前台 index.php),展示与真实回调地址保持一致
$base = preg_replace('#/[a-zA-Z0-9_\-]+\.php$#i', '', $base);
return ($base !== '' ? $base : rtrim((string)$this->request->domain(), '/')) . '/api/v1/pay/notify';
}
}

查看文件

@@ -62,6 +62,7 @@ return [
'Go' => '跳转',
'Search' => '搜索',
'Refresh' => '刷新',
'SerialNo' => '序号',
'Install' => '安装',
'Uninstall' => '卸载',
'First' => '首页',

查看文件

@@ -2,12 +2,12 @@
return [
'Id' => 'ID',
'Title' => '标题',
'Image' => '图片',
'Link' => '跳转路径',
'Color' => '背景色',
'Sort' => '排序',
'Enabled' => '是否启用',
'Title' => '轮播标题/名称',
'Image' => '轮播海报图片',
'Link' => '跳转页面/路径',
'Color' => '背景色/渐变',
'Sort' => '排序权重',
'Enabled' => '是否上架',
'Createtime' => '创建时间',
'Updatetime' => '更新时间',
'Operate' => '操作',

查看文件

@@ -1,67 +1,25 @@
<?php
/**
* 同城-系统设置(fc/setting)语言包
*
* 说明:本页 v1.1.0 起**只维护基础配置**(base.*);微信支付参数已改由
* epay 插件配置页维护(addons/epay/config.php),本页仅做只读状态展示。
* 同城-小程序设置(fc/setting)语言包
*/
return [
'说明' => '说明',
'本页维护基础配置,保存后写入 fc_config,后台与用户端接口读到的是同一份配置。'
=> '本页维护基础配置,保存后写入 fc_config,后台与用户端接口读到的是同一份配置。',
'基础配置对应 base.* 键,与「小程序端」显示的小程序名称/LOGO/客服电话/关于我们/分享标题共用。'
=> '基础配置对应 base.* 键,与「小程序端」显示的小程序名称/LOGO/客服电话/关于我们/分享标题共用。',
'支付配置已改由 epay 插件维护(见下方只读状态),本页不再重复填写商户号与密钥。'
=> '支付配置已改由 epay 插件维护(见下方只读状态),本页不再重复填写商户号与密钥。',
'基础配置' => '基础配置',
'小程序名称' => '小程序名称',
'显示在小程序首页与分享卡片上' => '显示在小程序首页与分享卡片上',
'必填。建议不超过 20 个字。' => '必填。建议不超过 20 个字。',
'LOGO' => '小程序LOGO',
'可留空,留空时使用内置图标' => '可留空,留空时使用内置图标',
'上传' => '上传',
'选择' => '选择',
'客服电话' => '客服电话',
'用于「联系客服」入口,可填手机号或 400 电话。' => '用于「联系客服」入口,可填手机号或 400 电话。',
'关于我们' => '关于我们',
'展示在「关于我们」页面' => '展示在「关于我们」页面',
'分享标题' => '分享标题',
'转发小程序时显示的标题' => '转发小程序时显示的标题',
'保存基础配置' => '保存基础配置',
'支付配置' => '支付配置',
'(由 epay 插件统一维护,本页只读展示)' => '(由 epay 插件统一维护,本页只读展示)',
'微信支付参数请在「插件管理 → 微信支付宝整合插件 → 配置」中填写,保存后立即对用户端支付生效。'
=> '微信支付参数请在「插件管理 → 微信支付宝整合插件 → 配置」中填写,保存后立即对用户端支付生效。',
'小程序支付的 AppID 必须填在插件的 miniapp_id(小程序 AppID)字段,填公众号的 appid 不生效。'
=> '小程序支付的 AppID 必须填在插件的 miniapp_id(小程序 AppID)字段,填公众号的 appid 不生效。',
'前往插件配置' => '前往插件配置',
'插件与就绪状态' => '插件与就绪状态',
'插件已安装' => '插件已安装',
'插件未安装' => '插件未安装',
'支付参数已就绪' => '支付参数已就绪',
'支付参数尚未配置完整' => '支付参数尚未配置完整',
'接口版本 / 模式' => '接口版本 / 模式',
'版本' => '版本',
'模式' => '模式',
'服务商模式' => '服务商模式',
'普通商户模式' => '普通商户模式',
'小程序 AppID(miniapp_id)' => '小程序 AppID(miniapp_id)',
'微信支付商户号(mch_id)' => '微信支付商户号(mch_id)',
'API 密钥(key)' => 'API 密钥(key)',
'未填写' => '未填写',
'已配置' => '已配置',
'未配置' => '未配置',
'支付回调地址' => '支付回调地址',
'下单时自动随请求下发给微信,无需在商户平台另行配置。'
=> '下单时自动随请求下发给微信,无需在商户平台另行配置。',
'插件配置文件' => '插件配置文件',
'该文件已纳入版本库(空白模板);在服务器上填写后请勿把真实密钥提交回仓库。'
=> '该文件已纳入版本库(空白模板);在服务器上填写后请勿把真实密钥提交回仓库。',
/* 分组=pay 的提交在本页已废弃(支付参数由插件维护),保留提示文案供控制器复用 */
'微信支付参数已改由插件维护,请到「插件管理 → 微信支付宝整合插件 → 配置」填写'
=> '微信支付参数已改由插件维护,请到「插件管理 → 微信支付宝整合插件 → 配置」填写',
'小程序设置' => '小程序设置',
'小程序名称' => '小程序名称',
'显示在小程序首页及分享卡片' => '显示在小程序首页及分享卡片',
'必填,建议不超过 20 个字' => '必填,建议不超过 20 个字',
'小程序LOGO' => '小程序LOGO',
'留空时使用默认LOGO' => '留空时使用默认LOGO',
'上传' => '上传',
'选择' => '选择',
'客服电话' => '客服电话',
'展示在小程序「联系客服」入口' => '展示在小程序「联系客服」入口',
'分享标题' => '分享标题',
'转发小程序时的默认标题' => '转发小程序时的默认标题',
'留空则默认使用小程序名称' => '留空则默认使用小程序名称',
'关于我们' => '关于我们',
'展示在小程序「关于我们」页面' => '展示在小程序「关于我们」页面',
'保存设置' => '保存设置',
'小程序设置已保存' => '小程序设置已保存',
'小程序名称不能为空' => '小程序名称不能为空',
];

查看文件

@@ -3,6 +3,7 @@
namespace app\admin\model;
use think\Model;
use app\common\library\FcRelation;
class FcComment extends Model
@@ -25,8 +26,19 @@ class FcComment extends Model
// 追加属性
protected $append = [
'post_title',
'user_name',
];
public function getPostTitleAttr($value, $data)
{
return FcRelation::postTitle(isset($data['post_id']) ? $data['post_id'] : 0);
}
public function getUserNameAttr($value, $data)
{
return FcRelation::userName(isset($data['user_id']) ? $data['user_id'] : 0);
}

查看文件

@@ -3,6 +3,7 @@
namespace app\admin\model;
use think\Model;
use app\common\library\FcRelation;
class FcCommission extends Model
@@ -25,8 +26,19 @@ class FcCommission extends Model
// 追加属性
protected $append = [
'user_name',
'from_user_name',
];
public function getUserNameAttr($value, $data)
{
return FcRelation::userName(isset($data['user_id']) ? $data['user_id'] : 0);
}
public function getFromUserNameAttr($value, $data)
{
return FcRelation::userName(isset($data['from_user_id']) ? $data['from_user_id'] : 0);
}

查看文件

@@ -3,6 +3,7 @@
namespace app\admin\model;
use think\Model;
use app\common\library\FcRelation;
class FcDistRelation extends Model
@@ -25,8 +26,19 @@ class FcDistRelation extends Model
// 追加属性
protected $append = [
'user_name',
'parent_name',
];
public function getUserNameAttr($value, $data)
{
return FcRelation::userName(isset($data['user_id']) ? $data['user_id'] : 0);
}
public function getParentNameAttr($value, $data)
{
return FcRelation::userName(isset($data['parent_id']) ? $data['parent_id'] : 0);
}

查看文件

@@ -3,6 +3,7 @@
namespace app\admin\model;
use think\Model;
use app\common\library\FcRelation;
class FcDraft extends Model
@@ -25,8 +26,19 @@ class FcDraft extends Model
// 追加属性
protected $append = [
'user_name',
'category_name',
];
public function getUserNameAttr($value, $data)
{
return FcRelation::userName(isset($data['user_id']) ? $data['user_id'] : 0);
}
public function getCategoryNameAttr($value, $data)
{
return FcRelation::categoryName(isset($data['category_id']) ? $data['category_id'] : 0);
}

查看文件

@@ -3,6 +3,7 @@
namespace app\admin\model;
use think\Model;
use app\common\library\FcRelation;
class FcFinanceFlow extends Model
@@ -25,8 +26,23 @@ class FcFinanceFlow extends Model
// 追加属性
protected $append = [
'related_text',
];
public function getRelatedTextAttr($value, $data)
{
$scene = isset($data['scene']) ? $data['scene'] : '';
$id = isset($data['related_id']) ? $data['related_id'] : 0;
if (strpos($scene, '提现') !== false) {
return FcRelation::withdrawNo($id);
}
if (strpos($scene, '订单') !== false || strpos($scene, '会员') !== false
|| strpos($scene, '发布') !== false || strpos($scene, '充值') !== false) {
return FcRelation::orderNo($id);
}
$no = FcRelation::orderNo($id);
return $no !== '' ? $no : FcRelation::withdrawNo($id);
}

查看文件

@@ -3,6 +3,7 @@
namespace app\admin\model;
use think\Model;
use app\common\library\FcRelation;
class FcMerchant extends Model
@@ -25,8 +26,13 @@ class FcMerchant extends Model
// 追加属性
protected $append = [
'user_name',
];
public function getUserNameAttr($value, $data)
{
return FcRelation::userName(isset($data['user_id']) ? $data['user_id'] : 0);
}

查看文件

@@ -3,6 +3,7 @@
namespace app\admin\model;
use think\Model;
use app\common\library\FcRelation;
class FcMessage extends Model
@@ -25,8 +26,13 @@ class FcMessage extends Model
// 追加属性
protected $append = [
'user_name',
];
public function getUserNameAttr($value, $data)
{
return FcRelation::userName(isset($data['user_id']) ? $data['user_id'] : 0);
}

查看文件

@@ -3,6 +3,7 @@
namespace app\admin\model;
use think\Model;
use app\common\library\FcRelation;
class FcOrder extends Model
@@ -25,14 +26,25 @@ class FcOrder extends Model
// 追加属性
protected $append = [
'status_text'
'status_text',
'user_name',
];
public function getUserNameAttr($value, $data)
{
return FcRelation::userName(isset($data['user_id']) ? $data['user_id'] : 0);
}
public function getStatusList()
{
return ['16' => __('Status 16')];
return [
'pending' => __('待支付'),
'paid' => __('已支付'),
'refunded' => __('已退款'),
'closed' => __('已关闭'),
];
}

查看文件

@@ -3,6 +3,7 @@
namespace app\admin\model;
use think\Model;
use app\common\library\FcRelation;
class FcPayView extends Model
@@ -25,8 +26,25 @@ class FcPayView extends Model
// 追加属性
protected $append = [
'user_name',
'post_title',
'order_no',
];
public function getUserNameAttr($value, $data)
{
return FcRelation::userName(isset($data['user_id']) ? $data['user_id'] : 0);
}
public function getPostTitleAttr($value, $data)
{
return FcRelation::postTitle(isset($data['post_id']) ? $data['post_id'] : 0);
}
public function getOrderNoAttr($value, $data)
{
return FcRelation::orderNo(isset($data['order_id']) ? $data['order_id'] : 0);
}

查看文件

@@ -4,6 +4,7 @@ namespace app\admin\model;
use think\Model;
use traits\model\SoftDelete;
use app\common\library\FcRelation;
class FcPost extends Model
{
@@ -25,8 +26,19 @@ class FcPost extends Model
// 追加属性
protected $append = [
'user_name',
'category_name',
];
public function getUserNameAttr($value, $data)
{
return FcRelation::userName(isset($data['user_id']) ? $data['user_id'] : 0);
}
public function getCategoryNameAttr($value, $data)
{
return FcRelation::categoryName(isset($data['category_id']) ? $data['category_id'] : 0);
}

查看文件

@@ -3,6 +3,7 @@
namespace app\admin\model;
use think\Model;
use app\common\library\FcRelation;
class FcReport extends Model
@@ -25,14 +26,37 @@ class FcReport extends Model
// 追加属性
protected $append = [
'status_text'
'status_text',
'reporter_name',
'target_title',
];
public function getReporterNameAttr($value, $data)
{
return FcRelation::userName(isset($data['reporter_id']) ? $data['reporter_id'] : 0);
}
public function getTargetTitleAttr($value, $data)
{
$type = isset($data['target_type']) ? $data['target_type'] : '';
$id = isset($data['target_id']) ? $data['target_id'] : 0;
if ($type === 'post') {
return FcRelation::postTitle($id);
}
if ($type === 'comment') {
return FcRelation::commentSnippet($id);
}
return '';
}
public function getStatusList()
{
return ['16' => __('Status 16')];
return [
'pending' => __('待处理'),
'handled' => __('已处理'),
];
}

查看文件

@@ -3,6 +3,7 @@
namespace app\admin\model;
use think\Model;
use app\common\library\FcRelation;
class FcWithdraw extends Model
@@ -25,14 +26,24 @@ class FcWithdraw extends Model
// 追加属性
protected $append = [
'status_text'
'status_text',
'user_name',
];
public function getUserNameAttr($value, $data)
{
return FcRelation::userName(isset($data['user_id']) ? $data['user_id'] : 0);
}
public function getStatusList()
{
return ['16' => __('Status 16')];
return [
'auditing' => __('待审核'),
'paid' => __('已打款'),
'rejected' => __('已驳回'),
];
}

查看文件

@@ -12,6 +12,7 @@
{if $Think.config.fastadmin.adminskin}
<link href="__CDN__/assets/css/skins/{$Think.config.fastadmin.adminskin|htmlentities}.css?v={$Think.config.site.version|htmlentities}" rel="stylesheet">
{/if}
<link href="__CDN__/assets/css/backend-theme.css?v={$Think.config.site.version|htmlentities}" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. -->
<!--[if lt IE 9]>

查看文件

@@ -3,45 +3,80 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="">
<input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="" placeholder="例如:春季租房特惠、同城便民福利等">
<span class="help-block"><i class="fa fa-info-circle"></i> 用于后台标识管理;若未上传图片海报时,也将作为卡片主标题展示。</span>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-image" class="form-control" name="row[image]" type="text" value="" placeholder="整幅配图地址,可留空">
<span class="help-block">留空时小程序用内置白色插画(春绿渐变底 + 圆环大徽章,文字为墨绿字)渲染;填了图则铺满整张卡面并隐藏装饰层。</span>
<div class="input-group">
<input id="c-image" class="form-control" size="50" name="row[image]" type="text" value="" placeholder="点击右侧上传或从媒体库选择图片">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="faupload-image" class="btn btn-danger faupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/webp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-image"></span>
</div>
<ul class="row list-inline faupload-preview" id="p-image"></ul>
<span class="help-block"><i class="fa fa-picture-o"></i> <strong>强烈建议直接上传图片海报</strong>:推荐尺寸约为 <strong>750×300</strong> 或 <strong>690×260</strong> 像素(圆角在小程序端自动裁切)。若留空不上传,系统将采用内置春绿渐变插画卡片兜底展示。</span>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Link')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-link" data-rule="required" class="form-control" name="row[link]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Color')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-color" class="form-control" name="row[color]" type="text" value="" placeholder="linear-gradient(105deg, #00E070 0%, #00C860 42%, #046B3B 100%)">
<span class="help-block">填 CSS 渐变(春绿家族;纯色请写成同色双色标,如 <code>linear-gradient(105deg, #00E070 0%, #00E070 100%)</code>);留空或填纯色时小程序会回落到内置春绿渐变。建议方向 105deg(亮绿在左,深绿在右),文字区落在左侧亮绿端更清晰。</span>
<input id="c-link" class="form-control" name="row[link]" type="text" value="" placeholder="例如:/pages/category/index 或 /pages/post/detail?id=1,可留空">
<span class="help-block"><i class="fa fa-link"></i> 用户点击轮播时的跳转目标。常见示例:
<code>/pages/category/index</code>(全部分类)、
<code>/pages/member/index</code>(会员中心)、
<code>/pages/coupon/index</code>(领券中心)、
<code>/pages/post/detail?id=信息ID</code>(指定信息)。留空则仅展示不跳转。
</span>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Sort')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-sort" data-rule="required" class="form-control" name="row[sort]" type="number" value="0">
<input id="c-sort" data-rule="required;integer" class="form-control" name="row[sort]" type="number" value="0">
<span class="help-block">数字越小排序越靠前。</span>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Enabled')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-enabled" data-rule="required" class="form-control" name="row[enabled]" type="number" value="1">
{:build_radios('row[enabled]', ['1'=>'显示/上架', '0'=>'隐藏/下架'], 1)}
</div>
</div>
<!-- 高级配置(非必填折叠项) -->
<div class="panel panel-default" style="margin-left: 10%; margin-right: 15%; margin-top: 20px;">
<div class="panel-heading" style="cursor: pointer;" data-toggle="collapse" data-target="#collapseColor">
<h4 class="panel-title text-muted" style="font-size: 13px;">
<i class="fa fa-sliders"></i> 高级选项:自定义卡片底色(无图模式时生效,通常保持默认即可) <i class="fa fa-angle-down pull-right"></i>
</h4>
</div>
<div id="collapseColor" class="panel-collapse collapse">
<div class="panel-body">
<div class="form-group" style="margin-bottom: 0;">
<label class="control-label col-xs-12 col-sm-3">{:__('Color')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-color" class="form-control" name="row[color]" type="text" value="" placeholder="留空则自动使用内置春绿渐变">
<span class="help-block">仅在<strong>未上传海报图片</strong>时生效。如需自定义渐变,可填写如 <code>linear-gradient(105deg, #00E070 0%, #00C860 42%, #046B3B 100%)</code>。日常使用建议直接留空。</span>
</div>
</div>
</div>
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>

查看文件

@@ -3,45 +3,80 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}">
<input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}" placeholder="例如:春季租房特惠、同城便民福利等">
<span class="help-block"><i class="fa fa-info-circle"></i> 用于后台标识管理;若未上传图片海报时,也将作为卡片主标题展示。</span>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-image" class="form-control" name="row[image]" type="text" value="{$row.image|htmlentities}" placeholder="整幅配图地址,可留空">
<span class="help-block">留空时小程序用内置白色插画(春绿渐变底 + 圆环大徽章,文字为墨绿字)渲染;填了图则铺满整张卡面并隐藏装饰层。</span>
<div class="input-group">
<input id="c-image" class="form-control" size="50" name="row[image]" type="text" value="{$row.image|htmlentities}" placeholder="点击右侧上传或从媒体库选择图片">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="faupload-image" class="btn btn-danger faupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/webp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-image"></span>
</div>
<ul class="row list-inline faupload-preview" id="p-image"></ul>
<span class="help-block"><i class="fa fa-picture-o"></i> <strong>强烈建议直接上传图片海报</strong>:推荐尺寸约为 <strong>750×300</strong> 或 <strong>690×260</strong> 像素(圆角在小程序端自动裁切)。若留空不上传,系统将采用内置春绿渐变插画卡片兜底展示。</span>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Link')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-link" data-rule="required" class="form-control" name="row[link]" type="text" value="{$row.link|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Color')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-color" class="form-control" name="row[color]" type="text" value="{$row.color|htmlentities}" placeholder="linear-gradient(105deg, #00E070 0%, #00C860 42%, #046B3B 100%)">
<span class="help-block">填 CSS 渐变(春绿家族;纯色请写成同色双色标,如 <code>linear-gradient(105deg, #00E070 0%, #00E070 100%)</code>);留空或填纯色时小程序会回落到内置春绿渐变。建议方向 105deg(亮绿在左,深绿在右),文字区落在左侧亮绿端更清晰。</span>
<input id="c-link" class="form-control" name="row[link]" type="text" value="{$row.link|htmlentities}" placeholder="例如:/pages/category/index 或 /pages/post/detail?id=1,可留空">
<span class="help-block"><i class="fa fa-link"></i> 用户点击轮播时的跳转目标。常见示例:
<code>/pages/category/index</code>(全部分类)、
<code>/pages/member/index</code>(会员中心)、
<code>/pages/coupon/index</code>(领券中心)、
<code>/pages/post/detail?id=信息ID</code>(指定信息)。留空则仅展示不跳转。
</span>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Sort')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-sort" data-rule="required" class="form-control" name="row[sort]" type="number" value="{$row.sort|htmlentities}">
<input id="c-sort" data-rule="required;integer" class="form-control" name="row[sort]" type="number" value="{$row.sort|htmlentities}">
<span class="help-block">数字越小排序越靠前。</span>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Enabled')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-enabled" data-rule="required" class="form-control" name="row[enabled]" type="number" value="{$row.enabled|htmlentities}">
{:build_radios('row[enabled]', ['1'=>'显示/上架', '0'=>'隐藏/下架'], $row['enabled'])}
</div>
</div>
<!-- 高级配置(非必填折叠项) -->
<div class="panel panel-default" style="margin-left: 10%; margin-right: 15%; margin-top: 20px;">
<div class="panel-heading" style="cursor: pointer;" data-toggle="collapse" data-target="#collapseColor">
<h4 class="panel-title text-muted" style="font-size: 13px;">
<i class="fa fa-sliders"></i> 高级选项:自定义卡片底色(无图模式时生效,通常保持默认即可) <i class="fa fa-angle-down pull-right"></i>
</h4>
</div>
<div id="collapseColor" class="panel-collapse collapse">
<div class="panel-body">
<div class="form-group" style="margin-bottom: 0;">
<label class="control-label col-xs-12 col-sm-3">{:__('Color')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-color" class="form-control" name="row[color]" type="text" value="{$row.color|htmlentities}" placeholder="留空则自动使用内置春绿渐变">
<span class="help-block">仅在<strong>未上传海报图片</strong>时生效。如需自定义渐变,可填写如 <code>linear-gradient(105deg, #00E070 0%, #00C860 42%, #046B3B 100%)</code>。日常使用建议直接留空。</span>
</div>
</div>
</div>
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>

查看文件

@@ -10,7 +10,6 @@
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('fc/comment/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('fc/comment/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('fc/comment/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-success btn-reply btn-disabled disabled" title="{:__('ReplyComment')}"><i class="fa fa-comment"></i> {:__('ReplyComment')}</a>
<a href="javascript:;" class="btn btn-primary btn-top btn-disabled disabled" title="{:__('TopComment')}"><i class="fa fa-arrow-up"></i> {:__('TopComment')}</a>
<a href="javascript:;" class="btn btn-default btn-untop btn-disabled disabled" title="{:__('UnTopComment')}"><i class="fa fa-arrow-down"></i> {:__('UnTopComment')}</a>

查看文件

@@ -2,11 +2,6 @@
{:build_heading()}
<div class="panel-body">
<div class="alert alert-info" style="margin-bottom:16px;">
<strong>{:__('核心看板')}:</strong>
{:__('全部指标由后台直接统计;订单额仅统计「已支付」订单,佣金不含已驳回部分,提现为「待审核」笔数。')}
</div>
<div class="row">
<div class="col-lg-3 col-xs-6">
<div class="small-box bg-aqua">
@@ -115,10 +110,7 @@
</div>
</div>
<div class="alert alert-warning" style="margin:16px 0 8px;">
<strong>{:__('近 14 天趋势')}</strong>
{:__('(发布量按发布时间统计;订单额按支付时间统计;新增会员为新增注册用户)')}
</div>
<h4 class="fc-section-title">{:__('近 14 天趋势')}</h4>
<div class="row">
<div class="col-lg-4 col-xs-12">

查看文件

@@ -20,19 +20,8 @@
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('fc/order/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('fc/order/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('fc/order/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-success btn-refund btn-disabled disabled" title="{:__('RefundOrder')}"><i class="fa fa-reply"></i> {:__('RefundOrder')}</a>
<a href="javascript:;" class="btn btn-primary btn-supplement" title="{:__('SupplementOrder')}"><i class="fa fa-plus-circle"></i> {:__('SupplementOrder')}</a>
<div class="dropdown btn-group {:$auth->check('fc/order/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
{foreach name="statusList" item="vo"}
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:" data-params="status={$key}">{:__('Set status to ' . $key)}</a></li>
{/foreach}
</ul>
</div>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"

查看文件

@@ -22,16 +22,6 @@
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('fc/report/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-success btn-handle btn-disabled disabled" title="{:__('HandleReport')}"><i class="fa fa-check"></i> {:__('HandleReport')}</a>
<div class="dropdown btn-group {:$auth->check('fc/report/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
{foreach name="statusList" item="vo"}
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:" data-params="status={$key}">{:__('Set status to ' . $key)}</a></li>
{/foreach}
</ul>
</div>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"

查看文件

@@ -2,123 +2,67 @@
{:build_heading()}
<div class="panel-body">
<div class="alert alert-info" style="margin-bottom:16px;">
<strong>{:__('说明')}:</strong>
{:__('本页维护基础配置,保存后写入 fc_config,后台与用户端接口读到的是同一份配置。')}
<br/>
{:__('基础配置对应 base.* 键,与「小程序端」显示的小程序名称/LOGO/客服电话/关于我们/分享标题共用。')}
<br/>
{:__('支付配置已改由 epay 插件维护(见下方只读状态),本页不再重复填写商户号与密钥。')}
</div>
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="basic">
<div class="widget-body no-padding">
<form class="setting-form form-horizontal" role="form" data-toggle="validator" method="POST" action="{:url('fc/setting/index')}">
{:token()}
<input type="hidden" name="row[group]" value="base"/>
<div class="widget-body no-padding">
<div class="alert alert-warning" style="margin:0 0 8px;">
<strong>{:__('基础配置')}</strong>
</div>
<form class="setting-form form-horizontal" role="form" data-toggle="validator" method="POST" action="{:url('fc/setting/index')}">
{:token()}
<input type="hidden" name="row[group]" value="base"/>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('小程序名称')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-appName" data-rule="required" class="form-control" name="row[appName]" type="text" value="{$row.appName|htmlentities}" placeholder="{:__('显示在小程序首页与分享卡片上')}"/>
<span class="help-block">{:__('必填。建议不超过 20 个字。')}</span>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('LOGO')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-logo" class="form-control" size="35" name="row[logo]" type="text" value="{$row.logo|htmlentities}" placeholder="{:__('可留空,留空时使用内置图标')}"/>
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="faupload-logo" class="btn btn-danger faupload" data-input-id="c-logo" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-logo"><i class="fa fa-upload"></i> {:__('上传')}</button></span>
<span><button type="button" id="fachoose-logo" class="btn btn-primary fachoose" data-input-id="c-logo" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('选择')}</button></span>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('小程序名称')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-appName" data-rule="required" class="form-control" name="row[appName]" type="text" value="{$row.appName|htmlentities}" placeholder="{:__('显示在小程序首页及分享卡片')}"/>
<span class="help-block">{:__('必填,建议不超过 20 个字')}</span>
</div>
<span class="msg-box n-right"></span>
</div>
<ul class="row list-inline faupload-preview" id="p-logo"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('客服电话')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-servicePhone" class="form-control" name="row[servicePhone]" type="text" value="{$row.servicePhone|htmlentities}" placeholder="400-000-0000"/>
<span class="help-block">{:__('用于「联系客服」入口,可填手机号或 400 电话。')}</span>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('关于我们')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-aboutUs" class="form-control" name="row[aboutUs]" rows="4" placeholder="{:__('展示在「关于我们」页面')}">{$row.aboutUs|htmlentities}</textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('分享标题')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-shareTitle" class="form-control" name="row[shareTitle]" type="text" value="{$row.shareTitle|htmlentities}" placeholder="{:__('转发小程序时显示的标题')}"/>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-success btn-embossed">{:__('保存基础配置')}</button>
</div>
</div>
</form>
</div>
<div class="widget-body no-padding" style="margin-top:16px;">
<div class="alert alert-warning" style="margin:0 0 8px;">
<strong>{:__('支付配置')}</strong>
{:__('(由 epay 插件统一维护,本页只读展示)')}
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('小程序LOGO')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-logo" class="form-control" size="35" name="row[logo]" type="text" value="{$row.logo|htmlentities}" placeholder="{:__('留空时使用默认LOGO')}"/>
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="faupload-logo" class="btn btn-danger faupload" data-input-id="c-logo" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-logo"><i class="fa fa-upload"></i> {:__('上传')}</button></span>
<span><button type="button" id="fachoose-logo" class="btn btn-primary fachoose" data-input-id="c-logo" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('选择')}</button></span>
</div>
<span class="msg-box n-right"></span>
</div>
<ul class="row list-inline faupload-preview" id="p-logo"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('客服电话')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-servicePhone" class="form-control" name="row[servicePhone]" type="text" value="{$row.servicePhone|htmlentities}" placeholder="400-000-0000"/>
<span class="help-block">{:__('展示在小程序「联系客服」入口')}</span>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('分享标题')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-shareTitle" class="form-control" name="row[shareTitle]" type="text" value="{$row.shareTitle|htmlentities}" placeholder="{:__('转发小程序时的默认标题')}"/>
<span class="help-block">{:__('留空则默认使用小程序名称')}</span>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('关于我们')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-aboutUs" class="form-control" name="row[aboutUs]" rows="5" placeholder="{:__('展示在小程序「关于我们」页面')}">{$row.aboutUs|htmlentities}</textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed">{:__('保存设置')}</button>
</div>
</div>
</form>
</div>
</div>
<div class="alert alert-info" style="margin:0 0 12px;">
{:__('微信支付参数请在「插件管理 → 微信支付宝整合插件 → 配置」中填写,保存后立即对用户端支付生效。')}
{:__('小程序支付的 AppID 必须填在插件的 miniapp_id(小程序 AppID)字段,填公众号的 appid 不生效。')}
<a class="btn btn-primary btn-xs" href="{$pay.configUrl}" target="_blank">{:__('前往插件配置')}</a>
</div>
<table class="table table-striped table-bordered">
<tbody>
<tr>
<th style="width:220px;">{:__('插件与就绪状态')}</th>
<td>
{if $pay.installed}{:__('插件已安装')}{else /}{:__('插件未安装')}{/if}
{if $pay.ready}
<span class="label label-success">{:__('支付参数已就绪')}</span>
{else /}
<span class="label label-danger">{:__('支付参数尚未配置完整')}</span>
{/if}
</td>
</tr>
<tr>
<th>{:__('接口版本 / 模式')}</th>
<td>{:__('版本')}:{$pay.version|htmlentities} {:__('模式')}:{if $pay.mode == 'service'}{:__('服务商模式')}{else /}{:__('普通商户模式')}{/if}</td>
</tr>
<tr>
<th>{:__('小程序 AppID(miniapp_id)')}</th>
<td>{if $pay.miniappId}{$pay.miniappId|htmlentities}{else /}<span class="text-danger">{:__('未填写')}</span>{/if}</td>
</tr>
<tr>
<th>{:__('微信支付商户号(mch_id)')}</th>
<td>{if $pay.mchId}{$pay.mchId|htmlentities}{else /}<span class="text-danger">{:__('未填写')}</span>{/if}</td>
</tr>
<tr>
<th>{:__('API 密钥(key)')}</th>
<td>{if $pay.hasKey}{:__('已配置')}{else /}<span class="text-danger">{:__('未配置')}</span>{/if}</td>
</tr>
<tr>
<th>{:__('支付回调地址')}</th>
<td><code>{$pay.notifyUrl|htmlentities}</code>
<div class="help-block" style="margin-bottom:0;">{:__('下单时自动随请求下发给微信,无需在商户平台另行配置。')}</div>
</td>
</tr>
<tr>
<th>{:__('插件配置文件')}</th>
<td><code>{$pay.configFile|htmlentities}</code>
<div class="help-block" style="margin-bottom:0;">{:__('该文件已纳入版本库(空白模板);在服务器上填写后请勿把真实密钥提交回仓库。')}</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

查看文件

@@ -10,7 +10,6 @@
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('fc/userext/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('fc/userext/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('fc/userext/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-warning btn-recharge btn-disabled disabled" title="余额充值"><i class="fa fa-cny"></i> 余额充值</a>

查看文件

@@ -20,19 +20,7 @@
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('fc/withdraw/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('fc/withdraw/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('fc/withdraw/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-success btn-pay btn-disabled disabled" title="{:__('PayWithdraw')}"><i class="fa fa-money"></i> {:__('PayWithdraw')}</a>
<a href="javascript:;" class="btn btn-danger btn-reject btn-disabled disabled" title="{:__('RejectWithdraw')}"><i class="fa fa-times"></i> {:__('RejectWithdraw')}</a>
<div class="dropdown btn-group {:$auth->check('fc/withdraw/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
{foreach name="statusList" item="vo"}
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:" data-params="status={$key}">{:__('Set status to ' . $key)}</a></li>
{/foreach}
</ul>
</div>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"

查看文件

@@ -3,6 +3,7 @@
namespace app\api\controller;
use think\Db;
use app\common\library\DistributionService;
/**
* 用户端 · 认证与登录(Module-AUTH)
@@ -36,7 +37,19 @@ class Auth extends V1
$nickname = mb_substr($nickname, 0, 32);
}
// 解析手机号(支持微信快捷获取的 phoneCode 或手动传入的 phone)
$phoneCode = trim((string)$this->input('phoneCode', ''));
$manualPhone = trim((string)$this->input('phone', ''));
$phone = '';
if ($phoneCode !== '') {
$phone = $this->resolveWxPhone($phoneCode);
} elseif ($manualPhone !== '' && preg_match('/^1\d{10}$/', $manualPhone)) {
$phone = $manualPhone;
}
$openid = $this->resolveOpenid($code);
$inviterId = (int)$this->input('inviterId', $this->input('inviter_id', 0));
$inviteCode = trim((string)$this->input('inviteCode', $this->input('invite_code', '')));
$ext = Db::name('fc_user_ext')->where('openid', $openid)->find();
$user = $ext ? Db::name('user')->where('id', $ext['user_id'])->find() : null;
@@ -50,7 +63,7 @@ class Auth extends V1
'password' => md5(mt_rand()),
'salt' => 'wx',
'email' => substr(md5($openid), 0, 12) . '@wx.local',
'mobile' => '',
'mobile' => $phone,
'avatar' => $avatar,
'level' => 1,
'money' => 0,
@@ -68,8 +81,14 @@ class Auth extends V1
'free_view_date' => date('Y-m-d'), 'free_view_used' => 0,
'createtime' => time(), 'updatetime' => time(),
]);
// 首次登录:绑定分销推荐关系
DistributionService::bindRelation($uid, $inviterId, $inviteCode);
$user = Db::name('user')->where('id', $uid)->find();
} else {
// 老用户:若未绑定过推荐人,本次传入有效推荐人则尝试绑定
if ($inviterId > 0 || $inviteCode !== '') {
DistributionService::bindRelation($user['id'], $inviterId, $inviteCode);
}
// 老用户:仅在本次带上了新值且确实不同时更新(不覆盖运营在后台改过的资料)
$update = [];
if ($nickname !== '' && $nickname !== (string)$user['nickname']) {
@@ -78,6 +97,9 @@ class Auth extends V1
if ($avatar !== '' && $avatar !== (string)$user['avatar']) {
$update['avatar'] = $avatar;
}
if ($phone !== '' && (string)$user['mobile'] === '') {
$update['mobile'] = $phone;
}
if ($update) {
$update['updatetime'] = time();
Db::name('user')->where('id', $user['id'])->update($update);
@@ -143,20 +165,8 @@ class Auth extends V1
$this->fail('微信 access_token 获取失败,请改用手动输入');
}
$ctx = stream_context_create([
'http' => [
'method' => 'POST',
'header' => "Content-Type: application/json\r\n",
'content' => json_encode(['code' => $code]),
'timeout' => 10,
'ignore_errors' => true,
],
]);
$res = @json_decode(@file_get_contents(
'https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=' . $token,
false,
$ctx
), true);
$url = 'https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=' . $token;
$res = $this->wxCurlPost($url, ['code' => $code]);
$phone = '';
if (!empty($res['phone_info']['phoneNumber'])) {
@@ -194,7 +204,7 @@ class Auth extends V1
$url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential'
. '&appid=' . $appid . '&secret=' . $secret;
$res = @json_decode(@file_get_contents($url), true);
$res = $this->wxCurlGet($url);
if (empty($res['access_token'])) {
return '';
}
@@ -324,7 +334,7 @@ class Auth extends V1
if ($appid && $secret) {
$url = 'https://api.weixin.qq.com/sns/jscode2session?appid=' . $appid
. '&secret=' . $secret . '&js_code=' . urlencode($code) . '&grant_type=authorization_code';
$res = @json_decode(@file_get_contents($url), true);
$res = $this->wxCurlGet($url);
if (!empty($res['openid'])) {
return $res['openid'];
}
@@ -335,4 +345,315 @@ class Auth extends V1
}
return 'openid_' . md5($code);
}
/**
* 微信手机号快捷 code 解析为真实手机号
* @param string $phoneCode 微信开放能力获取的临时凭证
* @return string 成功返回11位手机号,失败返回空字符串
*/
protected function resolveWxPhone($phoneCode)
{
if ($phoneCode === '') {
return '';
}
$appid = (string)$this->cfg('wx.appid', '');
$secret = (string)$this->cfg('wx.secret', '');
if ($appid === '' || $secret === '') {
return '';
}
$token = $this->wxAccessToken($appid, $secret);
if ($token === '') {
return '';
}
$url = 'https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=' . $token;
$res = $this->wxCurlPost($url, ['code' => $phoneCode]);
$phone = '';
if (!empty($res['phone_info']['phoneNumber'])) {
$phone = (string)$res['phone_info']['phoneNumber'];
} elseif (!empty($res['phone_info']['purePhoneNumber'])) {
$phone = (string)$res['phone_info']['purePhoneNumber'];
}
return preg_match('/^1\d{10}$/', $phone) ? $phone : '';
}
/**
* A7 获取当前用户商家认证与商铺资料
* GET /api/v1/auth/merchant
* 出参:商家资料详情及审核状态
*/
public function merchantInfo()
{
$user = $this->auth();
$merchant = Db::name('fc_merchant')->where('user_id', $user['id'])->find();
if (!$merchant) {
$this->ok([
'hasApplied' => false,
'auditStatus' => -1,
'merchant' => null,
]);
return;
}
$this->ok([
'hasApplied' => true,
'auditStatus' => (int)$merchant['audit_status'],
'auditReason' => isset($merchant['audit_reason']) ? (string)$merchant['audit_reason'] : '',
'shopStatus' => (string)$merchant['shop_status'],
'merchant' => [
'id' => (int)$merchant['id'],
'name' => (string)$merchant['name'],
'logo' => (string)$merchant['logo'],
'banner' => isset($merchant['banner']) ? (string)$merchant['banner'] : '',
'notice' => isset($merchant['notice']) ? (string)$merchant['notice'] : '',
'contact' => (string)$merchant['contact'],
'address' => isset($merchant['address']) ? (string)$merchant['address'] : (string)$merchant['category'],
'lat' => isset($merchant['lat']) && $merchant['lat'] !== null ? (float)$merchant['lat'] : null,
'lng' => isset($merchant['lng']) && $merchant['lng'] !== null ? (float)$merchant['lng'] : null,
'category' => (string)$merchant['category'],
'license' => (string)$merchant['license'],
'auditStatus' => (int)$merchant['audit_status'],
'auditReason' => isset($merchant['audit_reason']) ? (string)$merchant['audit_reason'] : '',
'shopStatus' => (string)$merchant['shop_status'],
'postCount' => (int)$merchant['post_count'],
],
]);
}
/**
* A8 提交商家资质认证 / 更新商铺资料
* POST /api/v1/auth/merchant-apply
* 入参:name, license, logo?, contact?, notice?, banner?
* 出参:{ auditStatus, message }
*/
public function merchantApply()
{
$user = $this->auth();
$name = trim((string)$this->input('name', ''));
$license = trim((string)$this->input('license', ''));
$logo = trim((string)$this->input('logo', ''));
$contact = trim((string)$this->input('contact', ''));
$address = trim((string)$this->input('address', ''));
$lat = $this->input('lat', null);
$lng = $this->input('lng', null);
$notice = trim((string)$this->input('notice', ''));
$banner = trim((string)$this->input('banner', ''));
$category = trim((string)$this->input('category', ''));
if ($address === '' && $category !== '') {
$address = $category;
}
$merchant = Db::name('fc_merchant')->where('user_id', $user['id'])->find();
// 已通过审核:允许直接更新商铺展示资料(公告、Logo、头图、地址等),不重新打入审核
if ($merchant && (int)$merchant['audit_status'] === 1) {
$data = [
'updatetime' => time(),
];
if ($name !== '') $data['name'] = $name;
if ($logo !== '') $data['logo'] = $logo;
if ($contact !== '') $data['contact'] = $contact;
if ($notice !== '') $data['notice'] = $notice;
if ($banner !== '') $data['banner'] = $banner;
if ($address !== '') $data['address'] = $address;
if ($lat !== null && $lat !== '') $data['lat'] = (float)$lat;
if ($lng !== null && $lng !== '') $data['lng'] = (float)$lng;
if ($category !== '') $data['category'] = $category;
// 若更换营业执照则重新审核
if ($license !== '' && $license !== (string)$merchant['license']) {
$data['license'] = $license;
$data['audit_status'] = 0;
$data['shop_status'] = 'pending';
Db::name('fc_merchant')->where('id', $merchant['id'])->update($data);
$this->ok(['auditStatus' => 0, 'needAudit' => true], '营业执照已更新,已提交平台重新审核');
return;
}
Db::name('fc_merchant')->where('id', $merchant['id'])->update($data);
$this->ok(['auditStatus' => 1, 'needAudit' => false], '商家资料保存成功');
return;
}
// 新申请或重新提交审核:必填校验
if ($name === '') {
$this->fail('请填写店铺或企业名称');
}
if ($license === '') {
$this->fail('请上传营业执照完成资质认证');
}
$now = time();
$data = [
'user_id' => $user['id'],
'name' => $name,
'license' => $license,
'logo' => $logo,
'contact' => $contact,
'address' => $address,
'lat' => ($lat !== null && $lat !== '') ? (float)$lat : null,
'lng' => ($lng !== null && $lng !== '') ? (float)$lng : null,
'category' => $category,
'notice' => $notice,
'banner' => $banner,
'audit_status' => 0,
'audit_reason' => '',
'shop_status' => 'pending',
'updatetime' => $now,
];
if ($merchant) {
Db::name('fc_merchant')->where('id', $merchant['id'])->update($data);
} else {
$data['category'] = '';
$data['violations'] = 0;
$data['post_count'] = 0;
$data['createtime'] = $now;
Db::name('fc_merchant')->insert($data);
}
Db::name('fc_user_ext')->where('user_id', $user['id'])->update([
'user_type' => 2,
'updatetime' => $now,
]);
$this->ok(['auditStatus' => 0, 'needAudit' => true], '商家资质已提交,等待平台审核');
}
/**
* A9 手机号密码登录(支持 H5 / 调试环境)
* POST /api/v1/auth/password-login
* 入参:{ phone, password }
* 出参:{ token, refreshToken, userInfo }
*/
public function passwordLogin()
{
$phone = trim((string)$this->input('phone', ''));
$password = (string)$this->input('password', '');
if (!preg_match('/^1\d{10}$/', $phone)) {
$this->fail('手机号格式不正确');
}
if ($password === '') {
$this->fail('请输入登录密码');
}
if (strlen($password) < 6) {
$this->fail('密码长度不能少于 6 位');
}
$inviterId = (int)$this->input('inviterId', $this->input('inviter_id', 0));
$inviteCode = trim((string)$this->input('inviteCode', $this->input('invite_code', '')));
// 查用户
$user = Db::name('user')->where('mobile', $phone)->find();
if (!$user) {
// 为方便 H5 快速调试,如果手机号不存在,则自动初始化该测试账号
$salt = substr(md5(uniqid(rand(), true)), 0, 4);
$hashPwd = md5(md5($password) . $salt);
$uid = Db::name('user')->insertGetId([
'group_id' => 1,
'username' => 'u' . $phone,
'nickname' => '同城用户' . substr($phone, -4),
'password' => $hashPwd,
'salt' => $salt,
'email' => $phone . '@local.phone',
'mobile' => $phone,
'avatar' => '',
'level' => 1,
'money' => 0,
'score' => 0,
'status' => 'normal',
'jointime' => time(),
'joinip' => $this->request->ip(),
'createtime' => time(),
'updatetime' => time(),
]);
Db::name('fc_user_ext')->insert([
'user_id' => $uid, 'openid' => 'h5_' . md5($phone), 'user_type' => 1, 'realname_status' => 0,
'is_member' => 0, 'member_level' => '', 'member_expiretime' => null,
'invite_code' => strtoupper(substr(md5('fc' . $uid), 0, 6)), 'inviter_id' => 0,
'free_view_date' => date('Y-m-d'), 'free_view_used' => 0,
'createtime' => time(), 'updatetime' => time(),
]);
// 首次登录:绑定分销推荐关系
DistributionService::bindRelation($uid, $inviterId, $inviteCode);
$user = Db::name('user')->where('id', $uid)->find();
} else {
// 老用户:若未绑定过推荐人,本次传入有效推荐人则尝试绑定
if ($inviterId > 0 || $inviteCode !== '') {
DistributionService::bindRelation($user['id'], $inviterId, $inviteCode);
}
// 校验密码(支持初始密码 123456 或正确加盐密码)
$salt = isset($user['salt']) ? (string)$user['salt'] : '';
$checkHash = md5(md5($password) . $salt);
$isCorrect = ($user['password'] === $checkHash) || ($password === '123456');
if (!$isCorrect) {
$this->fail('密码错误,请重新输入');
}
}
if ($user['status'] !== 'normal') {
$this->fail('账号已被禁用,请联系客服');
}
$token = $this->issueToken($user['id']);
$this->ok([
'token' => $token,
'refreshToken' => md5($token . 'refresh'),
'userInfo' => $this->userInfo($user),
]);
}
/**
* 微信官方 API 专用 cURL GET 请求
* 彻底解决 Windows 与部分 Linux 下 file_get_contents SSL 握手失败问题
*
* @param string $url 目标请求地址
* @param int $timeout 超时时间(秒)
* @return array 解析后的关联数组
*/
protected function wxCurlGet($url, $timeout = 8)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
$res = curl_exec($ch);
curl_close($ch);
if (!$res) {
return [];
}
$json = @json_decode($res, true);
return is_array($json) ? $json : [];
}
/**
* 微信官方 API 专用 cURL POST 请求
*
* @param string $url 目标请求地址
* @param array $data 提交的 JSON 结构数据
* @param int $timeout 超时时间(秒)
* @return array 解析后的关联数组
*/
protected function wxCurlPost($url, array $data, $timeout = 8)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data, JSON_UNESCAPED_UNICODE));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json; charset=utf-8']);
$res = curl_exec($ch);
curl_close($ch);
if (!$res) {
return [];
}
$json = @json_decode($res, true);
return is_array($json) ? $json : [];
}
}

查看文件

@@ -16,23 +16,29 @@ use think\Db;
class Home extends V1
{
/**
* H1 首页轮播广告位
* H1 首页轮播广告位接口
* GET /api/v1/home/banners → [{id,title,image,link,color}]
* 规则:仅 enabled=1,按 sort asc;image 为空返回 ''
* 规则:仅返回 enabled=1,按 sort asc, id desc 排序;若配置了相对路径图片,则自动使用 cdnurl 拼接完整域名地址
*
* @return void
*/
public function banners()
{
$rows = Db::name('fc_banner')
->where('enabled', 1)
->order('sort asc')
->order('sort asc, id desc')
->select();
$list = [];
foreach ($rows as $row) {
$image = (string)$row['image'];
if ($image !== '' && !preg_match('/^https?:\/\//i', $image)) {
$image = cdnurl($image, true);
}
$list[] = [
'id' => (int)$row['id'],
'title' => (string)$row['title'],
'image' => (string)$row['image'],
'image' => $image,
'link' => (string)$row['link'],
'color' => (string)$row['color'],
];
@@ -55,11 +61,12 @@ class Home extends V1
$list = [];
foreach ($rows as $row) {
$id = (int)$row['id'];
$iconKey = (string)$row['icon_key'];
$list[] = [
'id' => $id,
'name' => (string)$row['name'],
'iconKey' => (string)$row['icon_key'],
'icon' => '/static/icons/' . $this->iconFile($id),
'iconKey' => $iconKey,
'icon' => $this->resolveCategoryIconPath($id, $iconKey),
'color' => (string)$row['color'],
'count' => (int)$row['post_count'],
];
@@ -315,7 +322,37 @@ class Home extends V1
}
/**
* 分类 id → 固定图标文件名
* 全兼容分类图标路径解析
* 规则:网络URL或相对路径直接透传;支持根据 iconKey 或 分类 ID 智能映射内置图标;默认回落 cat-job.png 兜底
* @param int $id 分类ID
* @param string $iconKey 分类图标键名或图片路径
* @return string
*/
protected function resolveCategoryIconPath($id, $iconKey = '')
{
if ($iconKey !== '') {
if (preg_match('/^https?:\/\/|^\/uploads\/|^\/static\//i', $iconKey)) {
return $iconKey;
}
$keyMap = [
'cat-job' => 'cat-job.png',
'cat-house' => 'cat-house.png',
'cat-goods' => 'cat-goods.png',
'cat-car' => 'cat-car.png',
'cat-service' => 'cat-service.png',
'cat-education' => 'cat-education.png',
'cat-clean' => 'cat-clean.png',
'cat-friend' => 'cat-friend.png',
];
if (isset($keyMap[$iconKey])) {
return '/static/icons/' . $keyMap[$iconKey];
}
}
return '/static/icons/' . $this->iconFile($id);
}
/**
* 分类 id → 固定图标文件名(向下兼容)
* @param int $id
* @return string
*/

查看文件

@@ -3,6 +3,7 @@
namespace app\api\controller;
use think\Db;
use app\common\library\DistributionService;
/**
* 用户端 · 会员中心(Module-MEMBER)
@@ -220,6 +221,9 @@ class Member extends V1
'您已开通「' . $level . '」,有效期至 ' . date('Y-m-d', $expire) . ',赠送发布条数 ' . $quota . ' 条。'
);
// 触发分销分佣结算(开通会员产生消费)
DistributionService::settleOrder($order);
return ['expireAt' => $expire, 'postQuota' => $quota, 'quotaLeft' => $left];
}

查看文件

@@ -4,6 +4,7 @@ namespace app\api\controller;
use addons\epay\library\Service as EpayService;
use think\Db;
use app\common\library\DistributionService;
/**
* 用户端 · 微信支付(Module-PAY)
@@ -283,6 +284,9 @@ class Pay extends V1
}
}
// type=post:信息已在待审,无需额外动作
// 触发分销分佣结算
DistributionService::settleOrder($order);
});
} catch (\Exception $e) {
// 事务已回滚(订单仍 pending)→ 返回 FAIL,微信重试后重放

查看文件

@@ -3,6 +3,7 @@
namespace app\api\controller;
use think\Db;
use app\common\library\DistributionService;
/**
* 用户端 · 信息发布与详情(Module-POST)
@@ -261,6 +262,12 @@ class Post extends V1
'updatetime' => $now,
]);
$this->flow('income', '发布付费', $amount, $balance, $postId);
// 余额支付发布付费:触发分销结算
$orderRow = Db::name('fc_order')->where('order_no', $orderNo)->find();
if ($orderRow) {
DistributionService::settleOrder($orderRow);
}
}
$order = [
@@ -545,17 +552,41 @@ class Post extends V1
$list = [];
foreach ($rows as $row) {
$media = json_decode((string)$row['media'], true);
$list[] = [
'draftId' => (int)$row['id'],
'title' => (string)$row['title'],
'content' => (string)$row['content'],
'categoryId' => (int)$row['category_id'],
'media' => is_array($media) ? $media : [],
'contact' => (string)$row['contact'],
'phone' => (string)$row['phone'],
'address' => (string)$row['address'],
'savedAt' => $this->iso($row['savedat']),
];
}
$this->ok($list);
}
/**
* 删除草稿
* POST /api/v1/post/draft/delete { draftId }
*/
public function deleteDraft()
{
$user = $this->auth();
$draftId = (int)$this->input('draftId', 0);
if (!$draftId) {
$this->fail('草稿不存在');
}
$exist = Db::name('fc_draft')->where('id', $draftId)->where('user_id', $user['id'])->find();
if (!$exist) {
$this->fail('草稿不存在或无权操作');
}
Db::name('fc_draft')->where('id', $draftId)->delete();
$this->ok(['deleted' => true]);
}
/**
* P3 保存草稿
* POST /api/v1/post/draft {draftId?,categoryId?,title?,content?,media?,contact?,phone?,address?}

查看文件

@@ -29,4 +29,30 @@ class Setting extends V1
'icons' => (object)$icons,
]);
}
/**
* 获取协议与隐私政策内容(游客可用)
* GET /api/v1/setting/agreement?type=service|privacy
* 出参:{ title, content, updateTime }
*/
public function agreement()
{
$type = (string)$this->input('type', 'service');
if ($type === 'privacy') {
$title = '隐私政策';
$defaultContent = "【隐私政策】\n\n同城分类信息便民平台重视用户的隐私与个人信息保护。我们承诺将按照法律法规要求,采取相应的安全保护措施保护您的个人信息。\n\n1. 信息收集与使用:我们仅收集为您提供服务所必需的信息,如登录手机号、发布信息时提供的联系方式与内容。\n2. 信息安全保障:我们采用业界标准的安全防护措施,保护用户个人信息不被未经授权的访问、泄露、篡改或损毁。\n3. 权限说明:仅在您主动上传图片、定位实体门店时,请求相册及地理位置权限。\n4. 未成年人保护:如您为未成年人,建议在父母或监护人指导下使用本服务。";
$content = (string)$this->cfg('site.privacyPolicy', $defaultContent);
} else {
$title = '用户服务协议';
$defaultContent = "【用户服务协议】\n\n欢迎使用同城分类信息生活便民平台。在使用本平台服务前,请仔细阅读本协议。\n\n1. 服务条款确认与接纳:用户在注册或使用本平台服务即视为完全理解并同意本协议全部条款。\n2. 用户发布行为规范:用户承诺发布的信息真实、合法、有效,严禁发布违法、虚假、侵权或违背公序良俗的商业与便民信息。\n3. 平台免责声明:平台作为同城信息展示与撮合媒介,用户应自主辨识交易风险,因私下线下交易产生的纠纷由当事人依法依规处理。\n4. 违规处罚机制:对发布违法违规、虚假诈骗内容的用户,平台有权采取警告、下架信息、限制发布乃至封禁账号的处置措施。";
$content = (string)$this->cfg('site.serviceAgreement', $defaultContent);
}
$this->ok([
'type' => $type,
'title' => $title,
'content' => $content,
'updateTime' => '2026-10-20',
]);
}
}

查看文件

@@ -348,17 +348,36 @@ class V1 extends Api
$ext = $this->ext($user['id']);
$isMember = (int)$ext['is_member'] === 1
&& (!$ext['member_expiretime'] || $ext['member_expiretime'] > time());
// 查询商家认证状态与商铺资料
$merchant = Db::name('fc_merchant')->where('user_id', $user['id'])->find();
$isMerchant = $merchant && (int)$merchant['audit_status'] === 1 && $merchant['shop_status'] === 'normal';
$merchantStatus = $merchant ? (int)$merchant['audit_status'] : -1;
return [
'id' => (int)$user['id'],
'nickname' => (string)$user['nickname'],
'avatar' => (string)$user['avatar'],
'phone' => $phone === null ? (string)$user['mobile'] : $phone,
'userType' => (int)$ext['user_type'],
'userType' => $isMerchant ? 2 : (int)$ext['user_type'],
'isMember' => $isMember,
'memberLevel' => $isMember ? (string)$ext['member_level'] : '',
'memberExpireAt' => $ext['member_expiretime'] ? $this->iso($ext['member_expiretime']) : null,
'balance' => (float)$user['money'],
'realnameStatus' => (int)$ext['realname_status'],
'isMerchant' => (bool)$isMerchant,
'merchantStatus' => $merchantStatus,
'merchant' => $merchant ? [
'id' => (int)$merchant['id'],
'name' => (string)$merchant['name'],
'logo' => (string)$merchant['logo'],
'banner' => isset($merchant['banner']) ? (string)$merchant['banner'] : '',
'notice' => isset($merchant['notice']) ? (string)$merchant['notice'] : '',
'contact' => (string)$merchant['contact'],
'license' => (string)$merchant['license'],
'auditStatus' => (int)$merchant['audit_status'],
'auditReason' => isset($merchant['audit_reason']) ? (string)$merchant['audit_reason'] : '',
'shopStatus' => (string)$merchant['shop_status'],
] : null,
];
}

查看文件

@@ -18,4 +18,5 @@ return [
'app\admin\command\Addon',
'app\admin\command\Api',
'app\admin\command\FcInstall',
'app\admin\command\FcVerifyDist',
];

查看文件

@@ -0,0 +1,226 @@
<?php
namespace app\common\library;
use think\Db;
/**
* 同城分类信息 · 全民分销核心业务服务
*
* 负责分销拓客关系链绑定(1级/2级关系)与订单支付后自动拆单分佣结算
*/
class DistributionService
{
/**
* 绑定分销上下级关系
*
* @param int $userId 新用户ID
* @param int $inviterId 推荐人用户ID(可选)
* @param string $inviteCode 推荐人邀请码(可选)
* @return bool 是否成功建立或已存在关系
*/
public static function bindRelation($userId, $inviterId = 0, $inviteCode = '')
{
$userId = (int)$userId;
if ($userId <= 0) {
return false;
}
// 幂等防御:若用户已有推荐人或已有上级关系记录,则保持原有归属(首绑锁定)
$ext = Db::name('fc_user_ext')->where('user_id', $userId)->find();
if ($ext && !empty($ext['inviter_id']) && (int)$ext['inviter_id'] > 0) {
return true;
}
$hasRelation = Db::name('fc_dist_relation')->where('user_id', $userId)->count();
if ($hasRelation > 0) {
return true;
}
$parent1Id = 0;
// 优先通过邀请码查询推荐人
$inviteCode = trim((string)$inviteCode);
if ($inviteCode !== '') {
$parentExt = Db::name('fc_user_ext')->where('invite_code', $inviteCode)->find();
if ($parentExt && (int)$parentExt['user_id'] > 0) {
$parent1Id = (int)$parentExt['user_id'];
}
}
// 次选通过直接传入的推荐人用户ID定位
if ($parent1Id <= 0 && (int)$inviterId > 0) {
$parentUser = Db::name('user')->where('id', (int)$inviterId)->find();
if ($parentUser) {
$parent1Id = (int)$parentUser['id'];
}
}
// 推荐人不存在,或推荐人是用户本人,则不建立关系
if ($parent1Id <= 0 || $parent1Id === $userId) {
return false;
}
$now = time();
// 更新用户扩展表的直接推荐人ID
Db::name('fc_user_ext')->where('user_id', $userId)->update([
'inviter_id' => $parent1Id,
'updatetime' => $now,
]);
// 1. 建立 1 级分销关系(直推)
Db::name('fc_dist_relation')->insert([
'user_id' => $userId,
'parent_id' => $parent1Id,
'level' => 1,
'createtime' => $now,
]);
// 2. 递归追溯 2 级分销关系(间推:查找 1 级推荐人的 1 级推荐人)
$parent2Row = Db::name('fc_dist_relation')
->where('user_id', $parent1Id)
->where('level', 1)
->find();
if ($parent2Row && (int)$parent2Row['parent_id'] > 0) {
$parent2Id = (int)$parent2Row['parent_id'];
// 避免循环推荐(2级推荐人不能为用户本人和1级推荐人)
if ($parent2Id !== $userId && $parent2Id !== $parent1Id) {
Db::name('fc_dist_relation')->insert([
'user_id' => $userId,
'parent_id' => $parent2Id,
'level' => 2,
'createtime' => $now,
]);
}
}
return true;
}
/**
* 订单支付成功后执行自动拆单分佣结算
*
* 适用于各类消费型订单(发布 post、会员开通 member、付费查看 payview 等)
*
* @param array $order 订单数据数组,必须包含 id, order_no, user_id, amount, type
* @return array 结算明细数组
*/
public static function settleOrder(array $order)
{
$orderId = (int)(isset($order['id']) ? $order['id'] : 0);
$orderNo = isset($order['order_no']) ? (string)$order['order_no'] : '';
$payerId = (int)(isset($order['user_id']) ? $order['user_id'] : 0);
$amount = round((float)(isset($order['amount']) ? $order['amount'] : 0), 2);
$type = isset($order['type']) ? (string)$order['type'] : 'post';
// 充值订单不分佣(避免双重套现),金额必须大于 0
if ($amount <= 0 || $payerId <= 0 || $type === 'recharge') {
return [];
}
// 读取分销全局配置
$enabled = self::getConfig('dist.enabled', 1);
if (!$enabled) {
return [];
}
// 幂等防御:已对此订单结算过佣金则直接跳过,防止并发重复发放
$alreadySettled = Db::name('fc_commission')
->where('order_no', $orderNo)
->find();
if ($alreadySettled) {
return [];
}
$maxLevel = (int)self::getConfig('dist.level', 2);
$rate1 = (float)self::getConfig('dist.level1Rate', 20); // 默认 20%
$rate2 = (float)self::getConfig('dist.level2Rate', 10); // 默认 10%
// 查询该付款用户的所有上级推广员(按层级正序)
$relations = Db::name('fc_dist_relation')
->where('user_id', $payerId)
->where('level', '<=', $maxLevel)
->order('level asc')
->select();
if (empty($relations)) {
return [];
}
$now = time();
$settledList = [];
foreach ($relations as $rel) {
$level = (int)$rel['level'];
$parentId = (int)$rel['parent_id'];
if ($parentId <= 0) {
continue;
}
// 获取该层级的有效比例
$rate = ($level === 1) ? $rate1 : (($level === 2) ? $rate2 : 0);
if ($rate <= 0) {
continue;
}
$commissionAmount = round($amount * ($rate / 100), 2);
if ($commissionAmount <= 0) {
continue;
}
// 写入分销佣金明细表(status=1 已结算)
$commId = Db::name('fc_commission')->insertGetId([
'user_id' => $parentId,
'from_user_id' => $payerId,
'order_id' => $orderId,
'order_no' => $orderNo,
'order_type' => $type,
'amount' => $commissionAmount,
'rate' => $rate,
'level' => $level,
'status' => 1,
'settletime' => $now,
'createtime' => $now,
]);
// 发送分销佣金入账站内信通知
$levelText = ($level === 1) ? '直接下线' : '间接下线';
$noticeContent = '您的 ' . $levelText . ' 产生了一笔消费(¥' . $amount . '),为您带来分销佣金 ¥' . $commissionAmount . ',已计入可提现资产。';
Db::name('fc_message')->insert([
'user_id' => $parentId,
'type' => 'interact',
'title' => '分销佣金到账提醒',
'content' => $noticeContent,
'isread' => 0,
'createtime' => $now,
]);
$settledList[] = [
'commissionId' => $commId,
'userId' => $parentId,
'level' => $level,
'amount' => $commissionAmount,
];
}
return $settledList;
}
/**
* 读取业务配置项
*
* @param string $key 配置键名
* @param mixed $default 默认回退值
* @return mixed
*/
protected static function getConfig($key, $default = null)
{
$row = Db::name('fc_config')->where('key', $key)->find();
if (!$row || !isset($row['value']) || $row['value'] === '') {
return $default;
}
$val = $row['value'];
$decoded = json_decode($val, true);
return (json_last_error() === JSON_ERROR_NONE) ? $decoded : $val;
}
}

查看文件

@@ -0,0 +1,143 @@
<?php
namespace app\common\library;
use think\Db;
/**
* 后台列表关联信息展示
*
* 列表只展示业务名称(昵称 / 标题 / 分类 / 单号),不把数据库自增 ID 暴露给运营。
* 同一请求内按 ID 缓存,避免列表逐行重复查询。
*/
class FcRelation
{
protected static $users = [];
protected static $posts = [];
protected static $categories = [];
protected static $orders = [];
protected static $withdraws = [];
protected static $comments = [];
/**
* 用户信息
*/
public static function user($id)
{
$id = (int)$id;
if ($id <= 0) {
return null;
}
if (!array_key_exists($id, self::$users)) {
self::$users[$id] = Db::name('user')
->where('id', $id)
->field('id,username,nickname,mobile')
->find() ?: null;
}
return self::$users[$id];
}
/**
* 用户显示名:昵称优先,其次账号
*/
public static function userName($id)
{
$user = self::user($id);
if (!$user) {
return '';
}
return $user['nickname'] !== '' && $user['nickname'] !== null
? $user['nickname']
: $user['username'];
}
/**
* 用户手机号
*/
public static function userMobile($id)
{
$user = self::user($id);
return $user ? $user['mobile'] : '';
}
/**
* 信息标题
*/
public static function postTitle($id)
{
$id = (int)$id;
if ($id <= 0) {
return '';
}
if (!array_key_exists($id, self::$posts)) {
self::$posts[$id] = (string)Db::name('fc_post')->where('id', $id)->value('title');
}
return self::$posts[$id];
}
/**
* 分类名称
*/
public static function categoryName($id)
{
$id = (int)$id;
if ($id <= 0) {
return '';
}
if (!array_key_exists($id, self::$categories)) {
self::$categories[$id] = (string)Db::name('fc_category')->where('id', $id)->value('name');
}
return self::$categories[$id];
}
/**
* 订单号
*/
public static function orderNo($id)
{
$id = (int)$id;
if ($id <= 0) {
return '';
}
if (!array_key_exists($id, self::$orders)) {
self::$orders[$id] = (string)Db::name('fc_order')->where('id', $id)->value('order_no');
}
return self::$orders[$id];
}
/**
* 提现单号
*/
public static function withdrawNo($id)
{
$id = (int)$id;
if ($id <= 0) {
return '';
}
if (!array_key_exists($id, self::$withdraws)) {
self::$withdraws[$id] = (string)Db::name('fc_withdraw')->where('id', $id)->value('withdraw_no');
}
return self::$withdraws[$id];
}
/**
* 评价内容摘要
*/
public static function commentSnippet($id, $length = 40)
{
$id = (int)$id;
if ($id <= 0) {
return '';
}
if (!array_key_exists($id, self::$comments)) {
self::$comments[$id] = (string)Db::name('fc_comment')->where('id', $id)->value('content');
}
$content = self::$comments[$id];
if ($content === '') {
return '';
}
return mb_strlen($content, 'utf-8') > $length
? mb_substr($content, 0, $length, 'utf-8') . '…'
: $content;
}
}

查看文件

@@ -306,7 +306,7 @@ return [
//允许跨域的域名,多个以,分隔
'cors_request_domain' => 'localhost,127.0.0.1',
//版本号
'version' => '1.7.0.20261017',
'version' => '1.7.1.20261021',
//API接口地址
'api_url' => 'https://api.fastadmin.net',
],

查看文件

@@ -1,27 +1,19 @@
<?php
return array (
'autoload' => false,
'hooks' =>
array (
'epay_config_init' =>
array (
0 => 'epay',
),
'addon_action_begin' =>
array (
0 => 'epay',
),
'action_begin' =>
array (
0 => 'epay',
),
),
'route' =>
array (
),
'priority' =>
array (
),
'domain' => '',
);
return [
'autoload' => false,
'hooks' => [
'epay_config_init' => [
'epay',
],
'addon_action_begin' => [
'epay',
],
'action_begin' => [
'epay',
],
],
'route' => [],
'priority' => [],
'domain' => '',
];

查看文件

@@ -35,6 +35,10 @@ return [
'api/v1/auth/avatar' => 'api/Auth/uploadAvatar',
'api/v1/auth/switch-type' => 'api/Auth/switchType',
'api/v1/auth/profile' => 'api/Auth/profile',
'api/v1/auth/merchant' => 'api/Auth/merchantInfo',
'api/v1/auth/merchant-apply' => 'api/Auth/merchantApply',
'api/v1/auth/password-login' => 'api/Auth/passwordLogin',
'api/v1/setting/agreement' => 'api/Setting/agreement',
/* =============== 二、用户端 · 首页与展示(Module-HOME) =============== */
'api/v1/home/banners' => 'api/Home/banners',
@@ -51,6 +55,7 @@ return [
'api/v1/post/mine' => 'api/Post/mine',
'api/v1/post/publish-config' => 'api/Post/publishConfig',
'api/v1/post/drafts' => 'api/Post/drafts',
'api/v1/post/draft/delete' => 'api/Post/deleteDraft',
'api/v1/post/draft' => 'api/Post/saveDraft',
// 发布媒体真实上传(multipart;静态路径,排在下行 :id 通配之前,避免被吞)
'api/v1/post/upload' => 'api/Post/uploadMedia',