diff --git a/addons/epay/config.php b/addons/epay/config.php index 92607f2..c650f28 100644 --- a/addons/epay/config.php +++ b/addons/epay/config.php @@ -2,71 +2,71 @@ return [ [ - 'name' => 'version', - 'title' => 'API版本(请勿修改该值)', - 'type' => 'radio', + 'name' => 'version', + 'title' => 'API版本(请勿修改该值)', + 'type' => 'radio', 'content' => [], - 'value' => 'v2', - 'rule' => '', - 'msg' => '', - 'tip' => 'V2版本只支持微信支付V2密钥,V3版本只支持微信支付V3密钥,请勿修改该值!!!', - 'ok' => '', - 'extend' => '', + 'value' => 'v2', + 'rule' => '', + 'msg' => '', + 'tip' => 'V2版本只支持微信支付V2密钥,V3版本只支持微信支付V3密钥,请勿修改该值!!!', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'wechat', - 'title' => '微信', - 'type' => 'array', + 'name' => 'wechat', + 'title' => '微信', + 'type' => 'array', 'content' => [], - 'value' => [ - 'appid' => '', - 'app_id' => '', - 'app_secret' => '', - 'miniapp_id' => '', - 'mch_id' => '', - 'key' => '', - 'key_v3' => '', - 'public_key_id' => '', - 'public_key' => '/addons/epay/certs/public_key.pem', - 'cert_client' => '/addons/epay/certs/apiclient_cert.pem', - 'cert_key' => '/addons/epay/certs/apiclient_key.pem', - 'mode' => 'normal', - 'sub_mch_id' => '', - 'sub_appid' => '', - 'sub_app_id' => '', + 'value' => [ + 'appid' => '', + 'app_id' => '', + 'app_secret' => '', + 'miniapp_id' => 'wxbfcb778f3019cff8', + 'mch_id' => '1118898018', + 'key' => 'cfgherdhjbfshf3356586feejfbvjvhe', + 'key_v3' => '', + 'public_key_id' => '', + 'public_key' => '/addons/epay/certs/public_key.pem', + 'cert_client' => '/addons/epay/certs/apiclient_cert.pem', + 'cert_key' => '/addons/epay/certs/apiclient_key.pem', + 'mode' => 'normal', + 'sub_mch_id' => '', + 'sub_appid' => '', + 'sub_app_id' => '', 'sub_miniapp_id' => '', - 'notify_url' => '', - 'log' => '1', + 'notify_url' => '', + 'log' => '1', ], - 'rule' => 'required', - 'msg' => '', - 'tip' => '微信参数配置', - 'ok' => '', - 'extend' => '', + 'rule' => 'required', + 'msg' => '', + 'tip' => '微信参数配置', + 'ok' => '', + 'extend' => '', ], [ - 'name' => 'alipay', - 'title' => '支付宝', - 'type' => 'array', + 'name' => 'alipay', + 'title' => '支付宝', + 'type' => 'array', 'content' => [], - 'value' => [ - 'app_id' => '', - 'mode' => 'normal', - 'notify_url' => '/addons/epay/api/notifyx/type/alipay', - 'return_url' => '/addons/epay/api/returnx/type/alipay', - 'private_key' => '', - 'signtype' => 'cert', - 'pid' => '', - 'ali_public_key' => '', + 'value' => [ + 'mode' => 'normal', + 'pid' => '', + 'app_id' => '', + 'notify_url' => '/addons/epay/api/notifyx/type/alipay', + 'return_url' => '/addons/epay/api/returnx/type/alipay', + 'signtype' => 'cert', + 'ali_public_key' => '', 'app_cert_public_key' => '', - 'alipay_root_cert' => '', - 'log' => '1', - 'scanpay' => '0', + 'alipay_root_cert' => '', + 'private_key' => '', + 'log' => '1', + 'scanpay' => '0', ], - 'rule' => 'required', - 'msg' => '', - 'tip' => '支付宝参数配置', - 'ok' => '', - 'extend' => '', - ] + 'rule' => 'required', + 'msg' => '', + 'tip' => '支付宝参数配置', + 'ok' => '', + 'extend' => '', + ], ]; diff --git a/application/admin/command/FcInstall.php b/application/admin/command/FcInstall.php index ec81807..0199cf4 100644 --- a/application/admin/command/FcInstall.php +++ b/application/admin/command/FcInstall.php @@ -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, ]); } diff --git a/application/admin/command/FcVerifyDist.php b/application/admin/command/FcVerifyDist.php new file mode 100644 index 0000000..54fbe27 --- /dev/null +++ b/application/admin/command/FcVerifyDist.php @@ -0,0 +1,207 @@ + 订单支付自动分佣 -> 佣金结算 -> 申请提现与打款 + */ +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; + } +} diff --git a/application/admin/controller/fc/Setting.php b/application/admin/controller/fc/Setting.php index 05df6a1..31edb39 100644 --- a/application/admin/controller/fc/Setting.php +++ b/application/admin/controller/fc/Setting.php @@ -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'; - } } diff --git a/application/admin/lang/zh-cn.php b/application/admin/lang/zh-cn.php index f0e1bc4..281784e 100755 --- a/application/admin/lang/zh-cn.php +++ b/application/admin/lang/zh-cn.php @@ -62,6 +62,7 @@ return [ 'Go' => '跳转', 'Search' => '搜索', 'Refresh' => '刷新', + 'SerialNo' => '序号', 'Install' => '安装', 'Uninstall' => '卸载', 'First' => '首页', diff --git a/application/admin/lang/zh-cn/fc/banner.php b/application/admin/lang/zh-cn/fc/banner.php index e64dad7..97a84b2 100644 --- a/application/admin/lang/zh-cn/fc/banner.php +++ b/application/admin/lang/zh-cn/fc/banner.php @@ -2,12 +2,12 @@ return [ 'Id' => 'ID', - 'Title' => '标题', - 'Image' => '图片', - 'Link' => '跳转路径', - 'Color' => '背景色', - 'Sort' => '排序', - 'Enabled' => '是否启用', + 'Title' => '轮播标题/名称', + 'Image' => '轮播海报图片', + 'Link' => '跳转页面/路径', + 'Color' => '背景色/渐变', + 'Sort' => '排序权重', + 'Enabled' => '是否上架', 'Createtime' => '创建时间', 'Updatetime' => '更新时间', 'Operate' => '操作', diff --git a/application/admin/lang/zh-cn/fc/setting.php b/application/admin/lang/zh-cn/fc/setting.php index fdc5720..ca4587a 100644 --- a/application/admin/lang/zh-cn/fc/setting.php +++ b/application/admin/lang/zh-cn/fc/setting.php @@ -1,67 +1,25 @@ '说明', - '本页维护基础配置,保存后写入 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', + '上传' => '上传', + '选择' => '选择', + '客服电话' => '客服电话', + '展示在小程序「联系客服」入口' => '展示在小程序「联系客服」入口', + '分享标题' => '分享标题', + '转发小程序时的默认标题' => '转发小程序时的默认标题', + '留空则默认使用小程序名称' => '留空则默认使用小程序名称', + '关于我们' => '关于我们', + '展示在小程序「关于我们」页面' => '展示在小程序「关于我们」页面', + '保存设置' => '保存设置', + '小程序设置已保存' => '小程序设置已保存', + '小程序名称不能为空' => '小程序名称不能为空', ]; diff --git a/application/admin/model/FcComment.php b/application/admin/model/FcComment.php index 21c8ba3..8455555 100644 --- a/application/admin/model/FcComment.php +++ b/application/admin/model/FcComment.php @@ -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); + } diff --git a/application/admin/model/FcCommission.php b/application/admin/model/FcCommission.php index c838840..6f47fd0 100644 --- a/application/admin/model/FcCommission.php +++ b/application/admin/model/FcCommission.php @@ -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); + } diff --git a/application/admin/model/FcDistRelation.php b/application/admin/model/FcDistRelation.php index 4188e52..8b27a97 100644 --- a/application/admin/model/FcDistRelation.php +++ b/application/admin/model/FcDistRelation.php @@ -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); + } diff --git a/application/admin/model/FcDraft.php b/application/admin/model/FcDraft.php index 768edea..4bbf88f 100644 --- a/application/admin/model/FcDraft.php +++ b/application/admin/model/FcDraft.php @@ -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); + } diff --git a/application/admin/model/FcFinanceFlow.php b/application/admin/model/FcFinanceFlow.php index 169f0fa..4e59836 100644 --- a/application/admin/model/FcFinanceFlow.php +++ b/application/admin/model/FcFinanceFlow.php @@ -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); + } diff --git a/application/admin/model/FcMerchant.php b/application/admin/model/FcMerchant.php index 0a21ae6..d4a2d72 100644 --- a/application/admin/model/FcMerchant.php +++ b/application/admin/model/FcMerchant.php @@ -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); + } diff --git a/application/admin/model/FcMessage.php b/application/admin/model/FcMessage.php index 237d7da..987c86b 100644 --- a/application/admin/model/FcMessage.php +++ b/application/admin/model/FcMessage.php @@ -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); + } diff --git a/application/admin/model/FcOrder.php b/application/admin/model/FcOrder.php index 7059629..5e738e4 100644 --- a/application/admin/model/FcOrder.php +++ b/application/admin/model/FcOrder.php @@ -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' => __('已关闭'), + ]; } diff --git a/application/admin/model/FcPayView.php b/application/admin/model/FcPayView.php index 233d55e..abdf4ab 100644 --- a/application/admin/model/FcPayView.php +++ b/application/admin/model/FcPayView.php @@ -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); + } diff --git a/application/admin/model/FcPost.php b/application/admin/model/FcPost.php index ea1c5ff..f42616a 100644 --- a/application/admin/model/FcPost.php +++ b/application/admin/model/FcPost.php @@ -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); + } diff --git a/application/admin/model/FcReport.php b/application/admin/model/FcReport.php index 2467c87..ed88d40 100644 --- a/application/admin/model/FcReport.php +++ b/application/admin/model/FcReport.php @@ -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' => __('已处理'), + ]; } diff --git a/application/admin/model/FcWithdraw.php b/application/admin/model/FcWithdraw.php index b5b9f61..bd9b2ad 100644 --- a/application/admin/model/FcWithdraw.php +++ b/application/admin/model/FcWithdraw.php @@ -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' => __('已驳回'), + ]; } diff --git a/application/admin/view/common/meta.html b/application/admin/view/common/meta.html index 12b3c0e..165f124 100755 --- a/application/admin/view/common/meta.html +++ b/application/admin/view/common/meta.html @@ -12,6 +12,7 @@ {if $Think.config.fastadmin.adminskin} {/if} + +
+
+

+ 高级选项:自定义卡片底色(无图模式时生效,通常保持默认即可) +

+
+
+
+
+ +
+ + 仅在未上传海报图片时生效。如需自定义渐变,可填写如 linear-gradient(105deg, #00E070 0%, #00C860 42%, #046B3B 100%)。日常使用建议直接留空。 +
+
+
+
+
+ diff --git a/application/admin/view/fc/banner/edit.html b/application/admin/view/fc/banner/edit.html index 5e4b6a3..b84d7f0 100644 --- a/application/admin/view/fc/banner/edit.html +++ b/application/admin/view/fc/banner/edit.html @@ -3,45 +3,80 @@
- + + 用于后台标识管理;若未上传图片海报时,也将作为卡片主标题展示。
+
- - 留空时小程序用内置白色插画(春绿渐变底 + 圆环大徽章,文字为墨绿字)渲染;填了图则铺满整张卡面并隐藏装饰层。 +
+ +
+ + +
+ +
+ + 强烈建议直接上传图片海报:推荐尺寸约为 750×300 或 690×260 像素(圆角在小程序端自动裁切)。若留空不上传,系统将采用内置春绿渐变插画卡片兜底展示。
+
- -
-
-
- -
- - 填 CSS 渐变(春绿家族;纯色请写成同色双色标,如 linear-gradient(105deg, #00E070 0%, #00E070 100%));留空或填纯色时小程序会回落到内置春绿渐变。建议方向 105deg(亮绿在左,深绿在右),文字区落在左侧亮绿端更清晰。 + + 用户点击轮播时的跳转目标。常见示例: + /pages/category/index(全部分类)、 + /pages/member/index(会员中心)、 + /pages/coupon/index(领券中心)、 + /pages/post/detail?id=信息ID(指定信息)。留空则仅展示不跳转。 +
+
- + + 数字越小排序越靠前。
+
- + {:build_radios('row[enabled]', ['1'=>'显示/上架', '0'=>'隐藏/下架'], $row['enabled'])}
+ + +
+
+

+ 高级选项:自定义卡片底色(无图模式时生效,通常保持默认即可) +

+
+
+
+
+ +
+ + 仅在未上传海报图片时生效。如需自定义渐变,可填写如 linear-gradient(105deg, #00E070 0%, #00C860 42%, #046B3B 100%)。日常使用建议直接留空。 +
+
+
+
+
+ diff --git a/application/admin/view/fc/comment/index.html b/application/admin/view/fc/comment/index.html index b6a0c03..3618706 100644 --- a/application/admin/view/fc/comment/index.html +++ b/application/admin/view/fc/comment/index.html @@ -10,7 +10,6 @@ {:__('Add')} {:__('Edit')} {:__('Delete')} - {:__('ReplyComment')} {:__('TopComment')} {:__('UnTopComment')} diff --git a/application/admin/view/fc/dashboard/index.html b/application/admin/view/fc/dashboard/index.html index 2b99db1..723e207 100644 --- a/application/admin/view/fc/dashboard/index.html +++ b/application/admin/view/fc/dashboard/index.html @@ -2,11 +2,6 @@ {:build_heading()}
-
- {:__('核心看板')}: - {:__('全部指标由后台直接统计;订单额仅统计「已支付」订单,佣金不含已驳回部分,提现为「待审核」笔数。')} -
-
@@ -115,10 +110,7 @@
-
- {:__('近 14 天趋势')} - {:__('(发布量按发布时间统计;订单额按支付时间统计;新增会员为新增注册用户)')} -
+

{:__('近 14 天趋势')}

diff --git a/application/admin/view/fc/order/index.html b/application/admin/view/fc/order/index.html index 7bf3270..3ddc249 100644 --- a/application/admin/view/fc/order/index.html +++ b/application/admin/view/fc/order/index.html @@ -20,19 +20,8 @@ {:__('Add')} {:__('Edit')} {:__('Delete')} - {:__('RefundOrder')} {:__('SupplementOrder')} - - -
{:__('Delete')} {:__('HandleReport')} - - -
-
- {:__('说明')}: - {:__('本页维护基础配置,保存后写入 fc_config,后台与用户端接口读到的是同一份配置。')} -
- {:__('基础配置对应 base.* 键,与「小程序端」显示的小程序名称/LOGO/客服电话/关于我们/分享标题共用。')} -
- {:__('支付配置已改由 epay 插件维护(见下方只读状态),本页不再重复填写商户号与密钥。')} -
+
+
+
+
+ {:token()} + -
-
- {:__('基础配置')} -
- - {:token()} - -
- -
- - {:__('必填。建议不超过 20 个字。')} -
-
-
- -
-
- -
- - +
+ +
+ + {:__('必填,建议不超过 20 个字')}
-
- -
-
-
- -
- - {:__('用于「联系客服」入口,可填手机号或 400 电话。')} -
-
-
- -
- -
-
-
- -
- -
-
-
-
- -
-
- -
-
-
- {:__('支付配置')} - {:__('(由 epay 插件统一维护,本页只读展示)')} +
+ +
+
+ +
+ + +
+ +
+ +
+
+ +
+ +
+ + {:__('展示在小程序「联系客服」入口')} +
+
+ +
+ +
+ + {:__('留空则默认使用小程序名称')} +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+ +
-
- {:__('微信支付参数请在「插件管理 → 微信支付宝整合插件 → 配置」中填写,保存后立即对用户端支付生效。')} - {:__('小程序支付的 AppID 必须填在插件的 miniapp_id(小程序 AppID)字段,填公众号的 appid 不生效。')} - {:__('前往插件配置')} -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{:__('插件与就绪状态')} - {if $pay.installed}{:__('插件已安装')}{else /}{:__('插件未安装')}{/if} - {if $pay.ready} - {:__('支付参数已就绪')} - {else /} - {:__('支付参数尚未配置完整')} - {/if} -
{:__('接口版本 / 模式')}{:__('版本')}:{$pay.version|htmlentities} {:__('模式')}:{if $pay.mode == 'service'}{:__('服务商模式')}{else /}{:__('普通商户模式')}{/if}
{:__('小程序 AppID(miniapp_id)')}{if $pay.miniappId}{$pay.miniappId|htmlentities}{else /}{:__('未填写')}{/if}
{:__('微信支付商户号(mch_id)')}{if $pay.mchId}{$pay.mchId|htmlentities}{else /}{:__('未填写')}{/if}
{:__('API 密钥(key)')}{if $pay.hasKey}{:__('已配置')}{else /}{:__('未配置')}{/if}
{:__('支付回调地址')}{$pay.notifyUrl|htmlentities} -
{:__('下单时自动随请求下发给微信,无需在商户平台另行配置。')}
-
{:__('插件配置文件')}{$pay.configFile|htmlentities} -
{:__('该文件已纳入版本库(空白模板);在服务器上填写后请勿把真实密钥提交回仓库。')}
-
diff --git a/application/admin/view/fc/userext/index.html b/application/admin/view/fc/userext/index.html index d0c894b..5963d6e 100644 --- a/application/admin/view/fc/userext/index.html +++ b/application/admin/view/fc/userext/index.html @@ -10,7 +10,6 @@ {:__('Add')} {:__('Edit')} {:__('Delete')} - 余额充值 diff --git a/application/admin/view/fc/withdraw/index.html b/application/admin/view/fc/withdraw/index.html index 26ce435..26dd0ad 100644 --- a/application/admin/view/fc/withdraw/index.html +++ b/application/admin/view/fc/withdraw/index.html @@ -20,19 +20,7 @@ {:__('Add')} {:__('Edit')} {:__('Delete')} - {:__('PayWithdraw')} - {:__('RejectWithdraw')} - - - 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 : []; + } } diff --git a/application/api/controller/Home.php b/application/api/controller/Home.php index 37e29fe..67f9083 100644 --- a/application/api/controller/Home.php +++ b/application/api/controller/Home.php @@ -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 */ diff --git a/application/api/controller/Member.php b/application/api/controller/Member.php index deaa80d..44bc361 100644 --- a/application/api/controller/Member.php +++ b/application/api/controller/Member.php @@ -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]; } diff --git a/application/api/controller/Pay.php b/application/api/controller/Pay.php index 2f9957d..f387be9 100644 --- a/application/api/controller/Pay.php +++ b/application/api/controller/Pay.php @@ -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,微信重试后重放 diff --git a/application/api/controller/Post.php b/application/api/controller/Post.php index c24225d..a4d1167 100644 --- a/application/api/controller/Post.php +++ b/application/api/controller/Post.php @@ -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?} diff --git a/application/api/controller/Setting.php b/application/api/controller/Setting.php index 81bbf53..4b64ce5 100644 --- a/application/api/controller/Setting.php +++ b/application/api/controller/Setting.php @@ -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', + ]); + } } diff --git a/application/api/controller/V1.php b/application/api/controller/V1.php index faddad6..23c4c6c 100644 --- a/application/api/controller/V1.php +++ b/application/api/controller/V1.php @@ -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, ]; } diff --git a/application/command.php b/application/command.php index 6abc686..543aa35 100755 --- a/application/command.php +++ b/application/command.php @@ -18,4 +18,5 @@ return [ 'app\admin\command\Addon', 'app\admin\command\Api', 'app\admin\command\FcInstall', + 'app\admin\command\FcVerifyDist', ]; diff --git a/application/common/library/DistributionService.php b/application/common/library/DistributionService.php new file mode 100644 index 0000000..a1bb198 --- /dev/null +++ b/application/common/library/DistributionService.php @@ -0,0 +1,226 @@ +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; + } +} diff --git a/application/common/library/FcRelation.php b/application/common/library/FcRelation.php new file mode 100644 index 0000000..dedce2d --- /dev/null +++ b/application/common/library/FcRelation.php @@ -0,0 +1,143 @@ +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; + } +} diff --git a/application/config.php b/application/config.php index 75d0c36..b6cca65 100755 --- a/application/config.php +++ b/application/config.php @@ -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', ], diff --git a/application/extra/addons.php b/application/extra/addons.php index 064256e..70dbc8f 100755 --- a/application/extra/addons.php +++ b/application/extra/addons.php @@ -1,27 +1,19 @@ 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' => '', +]; diff --git a/application/route.php b/application/route.php index a755fcd..6dd3008 100755 --- a/application/route.php +++ b/application/route.php @@ -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', diff --git a/public/assets/css/backend-theme.css b/public/assets/css/backend-theme.css new file mode 100644 index 0000000..f4ed594 --- /dev/null +++ b/public/assets/css/backend-theme.css @@ -0,0 +1,163 @@ +/** + * 后台列表页样式 + * 中性后台风格,不继承小程序品牌色,不影响小程序端 + */ + +/* ---------- 内容区 ---------- */ +body.inside-header .content { + padding: 12px 14px; +} + +/* ---------- 面板 ---------- */ +.panel { + border: none; + border-radius: 8px; + box-shadow: 0 1px 2px rgba(23, 35, 61, .05), 0 6px 18px rgba(23, 35, 61, .04); +} + +.panel-intro { + background: #FFFFFF; +} + +.panel-intro > .panel-heading { + background: #FFFFFF; + border-bottom: 1px solid #EDEFF3; + border-radius: 8px 8px 0 0; + padding: 12px 14px; +} + +.panel-intro > .panel-body { + padding: 0 14px 14px; +} + +.panel-intro > .panel-heading .nav-tabs { + border-bottom: none; + margin-bottom: 0; +} + +.panel-intro > .panel-heading .nav-tabs > li > a { + border: 1px solid transparent; + border-radius: 6px; + color: #5A6472; + margin-right: 6px; + padding: 6px 14px; +} + +.panel-intro > .panel-heading .nav-tabs > li > a:hover, +.panel-intro > .panel-heading .nav-tabs > li > a:focus { + background: #F5F7FA; + border-color: #EDEFF3; + color: #262C36; +} + +.panel-intro > .panel-heading .nav-tabs > li.active > a, +.panel-intro > .panel-heading .nav-tabs > li.active > a:hover, +.panel-intro > .panel-heading .nav-tabs > li.active > a:focus { + background: #444C69; + border-color: #444C69; + color: #FFFFFF; +} + +/* ---------- 工具栏 ---------- */ +.toolbar { + margin-top: 10px; + margin-bottom: 10px; +} + +.toolbar .btn { + margin-right: 6px; + margin-bottom: 4px; +} + +/* ---------- 表格 ---------- */ +.bootstrap-table .table > thead > tr > th { + background: #F7F8FA; + border-bottom: 1px solid #E5E8EC !important; + color: #262C36; + font-weight: 600; +} + +.bootstrap-table .table > tbody > tr > td { + border-color: #EDEFF3; + vertical-align: middle; +} + +.table-striped > tbody > tr:nth-of-type(odd) { + background-color: #FBFCFD; +} + +.table-hover > tbody > tr:hover { + background-color: #F5F8FC; +} + +.bootstrap-table .table > tbody > tr:last-child > td { + border-bottom: 1px solid #EDEFF3; +} + +.fc-serial { + color: #8A94A6; + font-variant-numeric: tabular-nums; +} + +.table .btn-xs { + padding: 2px 7px; +} + +.pagination > .active > a, +.pagination > .active > a:hover, +.pagination > .active > a:focus, +.pagination > .active > span { + background-color: #444C69; + border-color: #444C69; + color: #FFFFFF; +} + +/* ---------- 状态徽标 ---------- */ +.fc-status { + display: inline-block; + padding: 1px 9px; + border: 1px solid transparent; + border-radius: 999px; + font-size: 12px; + font-weight: 500; + line-height: 20px; + white-space: nowrap; +} + +.fc-status-success { + background: #EAF7F0; + border-color: #CDEBDA; + color: #1E7B4F; +} + +.fc-status-warning { + background: #FFF6E5; + border-color: #F5E2BC; + color: #8A5A00; +} + +.fc-status-danger { + background: #FDECEC; + border-color: #F7D2D2; + color: #A82A2A; +} + +.fc-status-info { + background: #EDF4FD; + border-color: #D4E5FA; + color: #1D5F9E; +} + +.fc-status-default { + background: #F4F5F7; + border-color: #E3E6EA; + color: #5C6670; +} + +/* ---------- 首页分组标题 ---------- */ +.fc-section-title { + margin: 20px 0 12px; + color: #262C36; + font-size: 15px; + font-weight: 600; +} diff --git a/public/assets/js/backend/auth/admin.js b/public/assets/js/backend/auth/admin.js index 0901410..e2b4c00 100755 --- a/public/assets/js/backend/auth/admin.js +++ b/public/assets/js/backend/auth/admin.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -30,7 +30,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {field: 'state', checkbox: true, }, - {field: 'id', title: 'ID'}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'username', title: __('Username')}, {field: 'nickname', title: __('Nickname')}, {field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label}, diff --git a/public/assets/js/backend/auth/adminlog.js b/public/assets/js/backend/auth/adminlog.js index f8b1998..e80cb9b 100755 --- a/public/assets/js/backend/auth/adminlog.js +++ b/public/assets/js/backend/auth/adminlog.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -23,7 +23,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {field: 'state', checkbox: true,}, - {field: 'id', title: 'ID', operate: false}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'admin_id', title: __('Admin_id'), formatter: Table.api.formatter.search, visible: false}, {field: 'username', title: __('Username'), formatter: Table.api.formatter.search}, {field: 'title', title: __('Title'), operate: 'LIKE %...%', placeholder: '模糊搜索'}, diff --git a/public/assets/js/backend/auth/group.js b/public/assets/js/backend/auth/group.js index 8002fd1..f364bb9 100755 --- a/public/assets/js/backend/auth/group.js +++ b/public/assets/js/backend/auth/group.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ($, undefined, Backend, Table, Form, undefined) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree', 'backend/format'], function ($, undefined, Backend, Table, Form, undefined, Format) { //读取选中的条目 $.jstree.core.prototype.get_all_checked = function (full) { var obj = this.get_selected(), i, j; @@ -45,8 +45,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ( columns: [ [ {field: 'state', checkbox: true,}, - {field: 'id', title: 'ID'}, - {field: 'pid', title: __('Parent')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, + {field: 'pid', title: __('Parent'), formatter: function (value) { + if (!value || parseInt(value) === 0) { + return '顶级'; + } + var data = $('#table').bootstrapTable('getData') || []; + for (var i = 0; i < data.length; i++) { + if (String(data[i].id) === String(value)) { + return String(data[i].name).replace(/( |\s)/g, ''); + } + } + return '-'; + }}, {field: 'name', title: __('Name'), align: 'left', formatter:function (value, row, index) { return value.toString().replace(/(&|&)nbsp;/g, ' '); } diff --git a/public/assets/js/backend/auth/rule.js b/public/assets/js/backend/auth/rule.js index d63c38e..0649314 100755 --- a/public/assets/js/backend/auth/rule.js +++ b/public/assets/js/backend/auth/rule.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function ($, undefined, Backend, Table, Form, Template) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'backend/format'], function ($, undefined, Backend, Table, Form, Template, Format) { var Controller = { index: function () { @@ -24,7 +24,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function columns: [ [ {field: 'state', checkbox: true,}, - {field: 'id', title: 'ID'}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'title', title: __('Title'), align: 'left', formatter: Controller.api.formatter.title, clickToSelect: !false}, {field: 'icon', title: __('Icon'), formatter: Controller.api.formatter.icon}, {field: 'name', title: __('Name'), align: 'left', formatter: Controller.api.formatter.name}, diff --git a/public/assets/js/backend/category.js b/public/assets/js/backend/category.js index 0299bf3..6209a7a 100755 --- a/public/assets/js/backend/category.js +++ b/public/assets/js/backend/category.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -26,7 +26,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'type', title: __('Type'), operate: false, searchList: Config.searchList, formatter: Table.api.formatter.label}, {field: 'name', title: __('Name'), align: 'left', formatter:function (value, row, index) { return value.toString().replace(/(&|&)nbsp;/g, ' '); diff --git a/public/assets/js/backend/fc/area.js b/public/assets/js/backend/fc/area.js index 4e648e2..14553d9 100644 --- a/public/assets/js/backend/fc/area.js +++ b/public/assets/js/backend/fc/area.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -25,15 +25,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'name', title: __('Name'), operate: 'LIKE'}, { field: 'enabled', title: __('Enabled'), searchList: {0: '否', 1: '是'}, - formatter: function (value) { - var m = {0: '否', 1: '是'}; - return m[value] !== undefined ? m[value] : '-'; - } + formatter: Format.statusFormatter({0: '否', 1: '是'}, {0: 'default', 1: 'success'}) }, {field: 'sort', title: __('Sort')}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, diff --git a/public/assets/js/backend/fc/banner.js b/public/assets/js/backend/fc/banner.js index abc86f6..2aaad1c 100644 --- a/public/assets/js/backend/fc/banner.js +++ b/public/assets/js/backend/fc/banner.js @@ -1,6 +1,12 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { + /** + * 同城轮播广告管理控制器 + */ var Controller = { + /** + * 轮播列表页逻辑初始化 + */ index: function () { // 初始化表格参数配置 Table.api.init({ @@ -22,24 +28,36 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'sort', + sortOrder: 'asc', columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'title', title: __('Title'), operate: 'LIKE'}, { - field: 'enabled', title: __('Enabled'), - searchList: {0: '否', 1: '是'}, - formatter: function (value) { - var m = {0: '否', 1: '是'}; - return m[value] !== undefined ? m[value] : '-'; + field: 'image', + title: __('Image'), + operate: false, + events: Table.api.events.image, + formatter: function (value, row, index) { + if (!value) { + return ' 内置插画'; + } + return Table.api.formatter.image.call(this, value, row, index); } }, - {field: 'sort', title: __('Sort')}, - {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, + { + field: 'enabled', + title: __('Enabled'), + align: 'center', + table: table, + searchList: {"1": '显示/上架', "0": '隐藏/下架'}, + formatter: Table.api.formatter.toggle + }, + {field: 'sort', title: __('Sort'), sortable: true}, {field: 'link', title: __('Link'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'color', title: __('Color'), operate: 'LIKE'}, - {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'color', title: __('Color'), operate: 'LIKE', visible: false}, + {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, sortable: true}, {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] @@ -49,13 +67,25 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin // 为表格绑定事件 Table.api.bindevent(table); }, + + /** + * 新增轮播页逻辑初始化 + */ add: function () { Controller.api.bindevent(); }, + + /** + * 编辑轮播页逻辑初始化 + */ edit: function () { Controller.api.bindevent(); }, + api: { + /** + * 绑定表单事件与FastAdmin组件初始化 + */ bindevent: function () { Form.api.bindevent($("form[role=form]")); } diff --git a/public/assets/js/backend/fc/category.js b/public/assets/js/backend/fc/category.js index b44ac81..02ed2f5 100644 --- a/public/assets/js/backend/fc/category.js +++ b/public/assets/js/backend/fc/category.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -25,15 +25,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'name', title: __('Name'), operate: 'LIKE'}, { field: 'enabled', title: __('Enabled'), searchList: {0: '否', 1: '是'}, - formatter: function (value) { - var m = {0: '否', 1: '是'}; - return m[value] !== undefined ? m[value] : '-'; - } + formatter: Format.statusFormatter({0: '否', 1: '是'}, {0: 'default', 1: 'success'}) }, {field: 'post_count', title: __('Post_count')}, {field: 'sort', title: __('Sort')}, diff --git a/public/assets/js/backend/fc/comment.js b/public/assets/js/backend/fc/comment.js index 551b6fa..29bbccb 100644 --- a/public/assets/js/backend/fc/comment.js +++ b/public/assets/js/backend/fc/comment.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -27,9 +27,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, - {field: 'post_id', title: __('Post_id')}, - {field: 'user_id', title: __('User_id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, + {field: 'post_id', title: '信息', addClass: 'selectpage', extend: "data-source='fc/post/index' data-field='title'", formatter: function (value, row) { + return row.post_title || '-'; + }}, + {field: 'user_id', title: '评价人', addClass: 'selectpage', extend: "data-source='user/user/index' data-field='nickname'", formatter: function (value, row) { + return row.user_name || '-'; + }}, {field: 'score', title: __('Score'), searchList: {1: '1', 2: '2', 3: '3', 4: '4', 5: '5'}, formatter: function (value) { @@ -40,23 +44,78 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'reply', title: __('Reply'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'top', title: __('Top'), searchList: {0: __('否'), 1: __('是')}, - formatter: function (value) { - var m = {0: __('否'), 1: __('是')}; - return m[value] !== undefined ? m[value] : '-'; - } + formatter: Format.statusFormatter({0: __('否'), 1: __('已置顶')}, {0: 'default', 1: 'warning'}) }, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'replytime', title: __('Replytime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'status', title: __('Status'), searchList: {1: __('正常'), 0: __('隐藏')}, - formatter: function (value) { - var m = {1: __('正常'), 0: __('隐藏')}; - return m[value] !== undefined ? m[value] : '-'; - } + formatter: Format.statusFormatter({1: __('正常'), 0: __('隐藏')}, {1: 'success', 0: 'default'}) }, {field: 'images', title: __('Images'), visible: false}, {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false}, - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + { + field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, + formatter: Table.api.formatter.operate, + buttons: [ + { + name: 'reply', + text: __('ReplyComment'), + title: __('ReplyComment'), + classname: 'btn btn-xs btn-success btn-click', + click: function (options, row) { + Layer.prompt({title: __('请输入回复内容'), formType: 2, value: row.reply || ''}, function (value, index) { + Fast.api.ajax({ + url: 'fc/comment/reply', + data: {ids: row.id, reply: value} + }, function () { + $('#' + options.tableId).bootstrapTable('refresh'); + return false; + }); + Layer.close(index); + }); + } + }, + { + name: 'top', + text: __('TopComment'), + title: __('TopComment'), + classname: 'btn btn-xs btn-info btn-click', + visible: function (row) { + return Number(row.top) !== 1; + }, + confirm: __('确认置顶该评价?'), + click: function (options, row) { + Fast.api.ajax({ + url: 'fc/comment/top', + data: {ids: row.id, top: 1} + }, function () { + $('#' + options.tableId).bootstrapTable('refresh'); + return false; + }); + } + }, + { + name: 'untop', + text: __('UnTopComment'), + title: __('UnTopComment'), + classname: 'btn btn-xs btn-default btn-click', + visible: function (row) { + return Number(row.top) === 1; + }, + confirm: __('确认取消置顶该评价?'), + click: function (options, row) { + Fast.api.ajax({ + url: 'fc/comment/top', + data: {ids: row.id, top: 0} + }, function () { + $('#' + options.tableId).bootstrapTable('refresh'); + return false; + }); + } + } + ] + } ] ] }); @@ -64,21 +123,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin // 为表格绑定事件 Table.api.bindevent(table); - // 回复 - $(document).on('click', '.btn-reply', function () { - var ids = Table.api.selectedids(table); - Layer.prompt({title: __('请输入回复内容'), formType: 2}, function (value, index) { - Fast.api.ajax({ - url: 'fc/comment/reply', - data: {ids: ids.join(','), reply: value} - }, function (data) { - table.bootstrapTable('refresh'); - return false; - }); - Layer.close(index); - }); - }); - // 置顶 $(document).on('click', '.btn-top', function () { var ids = Table.api.selectedids(table); diff --git a/public/assets/js/backend/fc/commission.js b/public/assets/js/backend/fc/commission.js index b0d47a4..22b0fb2 100644 --- a/public/assets/js/backend/fc/commission.js +++ b/public/assets/js/backend/fc/commission.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -27,9 +27,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id'), visible: false}, - {field: 'user_id', title: __('User_id')}, - {field: 'from_user_id', title: __('From_user_id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, + {field: 'user_id', title: '用户', addClass: 'selectpage', extend: "data-source='user/user/index' data-field='nickname'", formatter: function (value, row) { + return row.user_name || '-'; + }}, + {field: 'from_user_id', title: '来源用户', addClass: 'selectpage', extend: "data-source='user/user/index' data-field='nickname'", formatter: function (value, row) { + return row.from_user_name || '-'; + }}, { field: 'amount', title: __('Amount'), operate: 'BETWEEN', formatter: function (value) { @@ -53,13 +57,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin { field: 'status', title: __('Status'), searchList: {0: __('未结算'), 1: __('已结算')}, - formatter: function (value) { - var m = {0: __('未结算'), 1: __('已结算')}; - return m[value] !== undefined ? m[value] : '-'; - } + formatter: Format.statusFormatter({0: __('未结算'), 1: __('已结算')}, {0: 'warning', 1: 'success'}) }, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, - {field: 'order_id', title: __('Order_id')}, {field: 'order_no', title: __('Order_no'), operate: 'LIKE'}, { field: 'order_type', title: __('Order_type'), diff --git a/public/assets/js/backend/fc/coupon.js b/public/assets/js/backend/fc/coupon.js index 4a85827..61a932c 100644 --- a/public/assets/js/backend/fc/coupon.js +++ b/public/assets/js/backend/fc/coupon.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -24,7 +24,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, { field: 'name', title: __('优惠券名称'), operate: 'LIKE', // 双保险:服务端 add/edit 已 strip_tags,这里再做一次 HTML 转义, @@ -69,10 +69,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin { field: 'enabled', title: __('是否启用'), searchList: {0: '否', 1: '是'}, - formatter: function (value) { - var m = {0: '否', 1: '是'}; - return m[value] !== undefined ? m[value] : '-'; - } + formatter: Format.statusFormatter({0: '否', 1: '是'}, {0: 'default', 1: 'success'}) }, {field: 'sort', title: __('排序')}, {field: 'createtime', title: __('创建时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, diff --git a/public/assets/js/backend/fc/distrelation.js b/public/assets/js/backend/fc/distrelation.js index ba9408a..d73ddba 100644 --- a/public/assets/js/backend/fc/distrelation.js +++ b/public/assets/js/backend/fc/distrelation.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -25,9 +25,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, - {field: 'user_id', title: __('User_id')}, - {field: 'parent_id', title: __('Parent_id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, + {field: 'user_id', title: '用户', addClass: 'selectpage', extend: "data-source='user/user/index' data-field='nickname'", formatter: function (value, row) { + return row.user_name || '-'; + }}, + {field: 'parent_id', title: '上级', addClass: 'selectpage', extend: "data-source='user/user/index' data-field='nickname'", formatter: function (value, row) { + return row.parent_name || '-'; + }}, { field: 'level', title: __('Level'), searchList: {1: __('一级'), 2: __('二级')}, diff --git a/public/assets/js/backend/fc/draft.js b/public/assets/js/backend/fc/draft.js index 9471849..4a4c4fb 100644 --- a/public/assets/js/backend/fc/draft.js +++ b/public/assets/js/backend/fc/draft.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -27,10 +27,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, - {field: 'user_id', title: __('User_id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, + {field: 'user_id', title: '用户', addClass: 'selectpage', extend: "data-source='user/user/index' data-field='nickname'", formatter: function (value, row) { + return row.user_name || '-'; + }}, {field: 'title', title: __('Title'), operate: 'LIKE'}, - {field: 'category_id', title: __('Category_id')}, + {field: 'category_id', title: '分类', addClass: 'selectpage', extend: "data-source='fc/category/index' data-field='name'", formatter: function (value, row) { + return row.category_name || '-'; + }}, {field: 'savedat', title: __('Savedat'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'content', title: __('Content'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'contact', title: __('Contact'), operate: 'LIKE'}, diff --git a/public/assets/js/backend/fc/financeflow.js b/public/assets/js/backend/fc/financeflow.js index 315b0d4..3aed4c1 100644 --- a/public/assets/js/backend/fc/financeflow.js +++ b/public/assets/js/backend/fc/financeflow.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -25,7 +25,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id'), visible: false}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'flow_no', title: __('Flow_no'), operate: 'LIKE'}, { field: 'type', title: __('Type'), @@ -49,7 +49,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin } }, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, - {field: 'related_id', title: __('Related_id')}, + {field: 'related_text', title: '关联单号', operate: false, sortable: false, formatter: function (value) { + return value ? value : '-'; + }}, {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] diff --git a/public/assets/js/backend/fc/merchant.js b/public/assets/js/backend/fc/merchant.js index 7741968..078e346 100644 --- a/public/assets/js/backend/fc/merchant.js +++ b/public/assets/js/backend/fc/merchant.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -27,26 +27,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, - {field: 'user_id', title: __('User_id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, + {field: 'user_id', title: '用户', addClass: 'selectpage', extend: "data-source='user/user/index' data-field='nickname'", formatter: function (value, row) { + return row.user_name || '-'; + }}, {field: 'name', title: __('Name'), operate: 'LIKE'}, {field: 'contact', title: __('Contact'), operate: 'LIKE'}, {field: 'category', title: __('Category'), operate: 'LIKE'}, { field: 'audit_status', title: __('Audit_status'), searchList: {0: __('待审核'), 1: __('已通过'), 2: __('已驳回')}, - formatter: function (value) { - var m = {0: __('待审核'), 1: __('已通过'), 2: __('已驳回')}; - return m[value] !== undefined ? m[value] : '-'; - } + formatter: Format.statusFormatter({0: __('待审核'), 1: __('已通过'), 2: __('已驳回')}, {0: 'warning', 1: 'success', 2: 'danger'}) }, { field: 'shop_status', title: __('Shop_status'), searchList: {normal: __('正常'), pending: __('待审核'), banned: __('已封禁')}, - formatter: function (value) { - var m = {normal: __('正常'), pending: __('待审核'), banned: __('已封禁')}; - return m[value] !== undefined ? m[value] : '-'; - } + formatter: Format.statusFormatter({normal: __('正常'), pending: __('待审核'), banned: __('已封禁')}, {normal: 'success', pending: 'warning', banned: 'danger'}) }, {field: 'license', title: __('License'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'violations', title: __('Violations')}, @@ -55,7 +51,52 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'logo', title: __('Logo'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content, visible: false}, {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false}, - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + { + field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, + formatter: Table.api.formatter.operate, + buttons: [ + { + name: 'auditpass', + text: __('AuditPass'), + title: __('AuditPass'), + classname: 'btn btn-xs btn-success btn-click', + visible: function (row) { + return Number(row.audit_status) !== 1; + }, + confirm: __('确认审核通过该商家?'), + click: function (options, row) { + Fast.api.ajax({ + url: 'fc/merchant/audit', + data: {ids: row.id, auditStatus: 1} + }, function () { + $('#' + options.tableId).bootstrapTable('refresh'); + return false; + }); + } + }, + { + name: 'auditreject', + text: __('AuditReject'), + title: __('AuditReject'), + classname: 'btn btn-xs btn-danger btn-click', + visible: function (row) { + return Number(row.audit_status) !== 2; + }, + click: function (options, row) { + Layer.prompt({title: __('请输入驳回原因'), formType: 2}, function (value, index) { + Fast.api.ajax({ + url: 'fc/merchant/audit', + data: {ids: row.id, auditStatus: 2, reason: value} + }, function () { + $('#' + options.tableId).bootstrapTable('refresh'); + return false; + }); + Layer.close(index); + }); + } + } + ] + } ] ] }); diff --git a/public/assets/js/backend/fc/message.js b/public/assets/js/backend/fc/message.js index 1b290c8..b8d952f 100644 --- a/public/assets/js/backend/fc/message.js +++ b/public/assets/js/backend/fc/message.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -25,8 +25,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, - {field: 'user_id', title: __('User_id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, + {field: 'user_id', title: '接收用户', addClass: 'selectpage', extend: "data-source='user/user/index' data-field='nickname'", formatter: function (value, row) { + return row.user_name || '-'; + }}, { field: 'type', title: __('Type'), searchList: {system: __('系统通知'), interact: __('互动消息')}, @@ -40,10 +42,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin { field: 'isread', title: __('Isread'), searchList: {0: __('否'), 1: __('是')}, - formatter: function (value) { - var m = {0: __('否'), 1: __('是')}; - return m[value] !== undefined ? m[value] : '-'; - } + formatter: Format.statusFormatter({0: __('未读'), 1: __('已读')}, {0: 'warning', 1: 'default'}) }, {field: 'readtime', title: __('Readtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, diff --git a/public/assets/js/backend/fc/order.js b/public/assets/js/backend/fc/order.js index 79f5241..6c5e0cb 100644 --- a/public/assets/js/backend/fc/order.js +++ b/public/assets/js/backend/fc/order.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -27,7 +27,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id'), visible: false}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'order_no', title: __('Order_no'), operate: 'LIKE'}, { field: 'type', title: __('Type'), @@ -55,12 +55,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin { field: 'status', title: __('Status'), searchList: {pending: __('待支付'), paid: __('已支付'), refunded: __('已退款'), closed: __('已关闭')}, - formatter: function (value) { - var m = {pending: __('待支付'), paid: __('已支付'), refunded: __('已退款'), closed: __('已关闭')}; - return m[value] !== undefined ? m[value] : '-'; - } + formatter: Format.statusFormatter({pending: __('待支付'), paid: __('已支付'), refunded: __('已退款'), closed: __('已关闭')}, {pending: 'warning', paid: 'success', refunded: 'info', closed: 'default'}) }, - {field: 'user_id', title: __('User_id')}, + {field: 'user_id', title: '下单用户', addClass: 'selectpage', extend: "data-source='user/user/index' data-field='nickname'", formatter: function (value, row) { + return row.user_name || '-'; + }}, {field: 'paytime', title: __('Paytime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, { @@ -72,7 +71,41 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'refund_reason', title: __('Refund_reason'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'related_id', title: __('Related_id'), visible: false}, {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false}, - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + { + field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, + formatter: Table.api.formatter.operate, + buttons: [ + { + name: 'refund', + text: __('RefundOrder'), + title: __('RefundOrder'), + classname: 'btn btn-xs btn-warning btn-click', + visible: function (row) { + return row.status === 'paid'; + }, + click: function (options, row) { + Layer.prompt({title: __('请输入退款金额'), formType: 0, value: row.amount || ''}, function (value, index) { + var amount = parseFloat(value); + if (!amount || amount <= 0) { + Layer.msg(__('退款金额需大于 0')); + return; + } + Layer.prompt({title: __('请输入退款原因(可选)'), formType: 2}, function (reason, index2) { + Fast.api.ajax({ + url: 'fc/order/refund', + data: {ids: row.id, amount: amount, reason: reason} + }, function () { + $('#' + options.tableId).bootstrapTable('refresh'); + return false; + }); + Layer.close(index2); + }); + Layer.close(index); + }); + } + } + ] + } ] ] }); @@ -80,29 +113,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin // 为表格绑定事件 Table.api.bindevent(table); - // 退款 - $(document).on('click', '.btn-refund', function () { - var ids = Table.api.selectedids(table); - Layer.prompt({title: __('请输入退款金额'), formType: 0}, function (value, index) { - var amount = parseFloat(value); - if (!amount || amount <= 0) { - Layer.msg(__('退款金额需大于 0')); - return; - } - Layer.prompt({title: __('请输入退款原因(可选)'), formType: 2}, function (reason, index2) { - Fast.api.ajax({ - url: 'fc/order/refund', - data: {ids: ids.join(','), amount: amount, reason: reason} - }, function (data) { - table.bootstrapTable('refresh'); - return false; - }); - Layer.close(index2); - }); - Layer.close(index); - }); - }); - // 补单 $(document).on('click', '.btn-supplement', function () { Layer.prompt({title: __('请输入需要补单的订单号'), formType: 0}, function (value, index) { diff --git a/public/assets/js/backend/fc/payview.js b/public/assets/js/backend/fc/payview.js index bb49838..43c239b 100644 --- a/public/assets/js/backend/fc/payview.js +++ b/public/assets/js/backend/fc/payview.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -25,9 +25,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id'), visible: false}, - {field: 'user_id', title: __('User_id')}, - {field: 'post_id', title: __('Post_id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, + {field: 'user_id', title: '用户', addClass: 'selectpage', extend: "data-source='user/user/index' data-field='nickname'", formatter: function (value, row) { + return row.user_name || '-'; + }}, + {field: 'post_id', title: '信息', addClass: 'selectpage', extend: "data-source='fc/post/index' data-field='title'", formatter: function (value, row) { + return row.post_title || '-'; + }}, { field: 'pay_type', title: __('Pay_type'), searchList: {wxpay: __('微信支付'), balance: __('余额支付'), free: __('会员免费')}, @@ -43,7 +47,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin } }, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, - {field: 'order_id', title: __('Order_id')}, + {field: 'order_no', title: '订单号', operate: false, sortable: false, formatter: function (value) { + return value ? value : '-'; + }}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] diff --git a/public/assets/js/backend/fc/plan.js b/public/assets/js/backend/fc/plan.js index c3462ae..3ea91ee 100644 --- a/public/assets/js/backend/fc/plan.js +++ b/public/assets/js/backend/fc/plan.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -27,7 +27,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'plan_code', title: __('Plan_code'), operate: 'LIKE'}, {field: 'name', title: __('Name'), operate: 'LIKE'}, { @@ -47,10 +47,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin { field: 'enabled', title: __('Enabled'), searchList: {0: '否', 1: '是'}, - formatter: function (value) { - var m = {0: '否', 1: '是'}; - return m[value] !== undefined ? m[value] : '-'; - } + formatter: Format.statusFormatter({0: '否', 1: '是'}, {0: 'default', 1: 'success'}) }, {field: 'sort', title: __('Sort')}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, diff --git a/public/assets/js/backend/fc/post.js b/public/assets/js/backend/fc/post.js index 72464d1..d333422 100644 --- a/public/assets/js/backend/fc/post.js +++ b/public/assets/js/backend/fc/post.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -27,9 +27,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'title', title: __('Title'), operate: 'LIKE'}, - {field: 'category_id', title: __('Category_id')}, + {field: 'category_id', title: '分类', addClass: 'selectpage', extend: "data-source='fc/category/index' data-field='name'", formatter: function (value, row) { + return row.category_name || '-'; + }}, {field: 'price', title: __('Price'), operate: 'BETWEEN', formatter: function (value) { return (value === null || value === '' || value === undefined) ? '-' : '¥' + value; @@ -39,24 +41,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'area', title: __('Area'), operate: 'LIKE'}, {field: 'audit_status', title: __('Audit_status'), searchList: {0: __('待审核'), 1: __('已通过'), 2: __('已驳回')}, - formatter: function (value) { - var m = {0: __('待审核'), 1: __('已通过'), 2: __('已驳回')}; - return m[value] !== undefined ? m[value] : '-'; - } + formatter: Format.statusFormatter({0: __('待审核'), 1: __('已通过'), 2: __('已驳回')}, {0: 'warning', 1: 'success', 2: 'danger'}) }, {field: 'views', title: __('Views')}, {field: 'is_paid', title: __('Is_paid'), searchList: {0: __('否'), 1: __('是')}, - formatter: function (value) { - var m = {0: __('否'), 1: __('是')}; - return m[value] !== undefined ? m[value] : '-'; - } + formatter: Format.statusFormatter({0: __('未付费'), 1: __('已付费')}, {0: 'default', 1: 'success'}) }, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'content', title: __('Content'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'cover', title: __('Cover'), operate: 'LIKE'}, {field: 'media', title: __('Media'), visible: false}, - {field: 'user_id', title: __('User_id')}, + {field: 'user_id', title: '发布用户', addClass: 'selectpage', extend: "data-source='user/user/index' data-field='nickname'", formatter: function (value, row) { + return row.user_name || '-'; + }}, {field: 'address', title: __('Address'), operate: 'LIKE'}, {field: 'contact', title: __('Contact'), operate: 'LIKE'}, {field: 'phone', title: __('Phone'), operate: 'LIKE'}, @@ -79,51 +77,113 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'comment_count', title: __('Comment_count')}, {field: 'status', title: __('Status'), searchList: {1: __('正常'), 0: __('已下架')}, - formatter: function (value) { - var m = {1: __('正常'), 0: __('已下架')}; - return m[value] !== undefined ? m[value] : '-'; - } + formatter: Format.statusFormatter({1: __('正常'), 0: __('已下架')}, {1: 'success', 0: 'default'}) }, {field: 'is_top', title: __('Is_top'), searchList: {0: __('否'), 1: __('是')}, - formatter: function (value) { - return Number(value) === 1 - ? '' + __('已置顶') + '' - : '' + __('未置顶') + ''; - } + formatter: Format.statusFormatter({0: __('未置顶'), 1: __('已置顶')}, {0: 'default', 1: 'warning'}) }, {field: 'distance', title: __('Distance')}, {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false}, {field: 'deletetime', title: __('Deletetime'), visible: false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate, buttons: [ + { + name: 'auditpass', + text: __('AuditPass'), + title: __('AuditPass'), + classname: 'btn btn-xs btn-success btn-click', + visible: function (row) { + return Number(row.audit_status) !== 1; + }, + confirm: __('确认审核通过该信息?'), + click: function (options, row) { + Fast.api.ajax({ + url: 'fc/post/audit', + data: {ids: row.id, auditStatus: 1} + }, function () { + $('#' + options.tableId).bootstrapTable('refresh'); + return false; + }); + } + }, + { + name: 'auditreject', + text: __('AuditReject'), + title: __('AuditReject'), + classname: 'btn btn-xs btn-danger btn-click', + visible: function (row) { + return Number(row.audit_status) !== 2; + }, + click: function (options, row) { + Layer.prompt({title: __('请输入驳回原因'), formType: 2}, function (value, index) { + Fast.api.ajax({ + url: 'fc/post/audit', + data: {ids: row.id, auditStatus: 2, reason: value} + }, function () { + $('#' + options.tableId).bootstrapTable('refresh'); + return false; + }); + Layer.close(index); + }); + } + }, + { + name: 'offline', + text: __('OfflinePost'), + title: __('OfflinePost'), + classname: 'btn btn-xs btn-warning btn-click', + visible: function (row) { + return Number(row.status) === 1; + }, + confirm: __('确认下架该信息?'), + click: function (options, row) { + Fast.api.ajax({ + url: 'fc/post/offline', + data: {ids: row.id} + }, function () { + $('#' + options.tableId).bootstrapTable('refresh'); + return false; + }); + } + }, { name: 'top', text: __('TopPost'), title: __('TopPost'), - classname: 'btn btn-xs btn-info btn-ajax', - icon: 'fa fa-arrow-up', - url: 'fc/post/top', - data: {isTop: 1}, + classname: 'btn btn-xs btn-info btn-click', visible: function (row) { return Number(row.is_top) !== 1; }, - confirm: __('确认置顶选中的信息?'), - refresh: true + confirm: __('确认置顶该信息?'), + click: function (options, row) { + Fast.api.ajax({ + url: 'fc/post/top', + data: {ids: row.id, isTop: 1} + }, function () { + $('#' + options.tableId).bootstrapTable('refresh'); + return false; + }); + } }, { name: 'untop', text: __('CancelTopPost'), title: __('CancelTopPost'), - classname: 'btn btn-xs btn-default btn-ajax', - icon: 'fa fa-arrow-down', - url: 'fc/post/top', - data: {isTop: 0}, + classname: 'btn btn-xs btn-default btn-click', visible: function (row) { return Number(row.is_top) === 1; }, - confirm: __('确认取消置顶选中的信息?'), - refresh: true + confirm: __('确认取消置顶该信息?'), + click: function (options, row) { + Fast.api.ajax({ + url: 'fc/post/top', + data: {ids: row.id, isTop: 0} + }, function () { + $('#' + options.tableId).bootstrapTable('refresh'); + return false; + }); + } } ] } @@ -228,7 +288,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'title', title: __('Title'), align: 'left'}, { field: 'deletetime', diff --git a/public/assets/js/backend/fc/report.js b/public/assets/js/backend/fc/report.js index ff1c198..2e7ab73 100644 --- a/public/assets/js/backend/fc/report.js +++ b/public/assets/js/backend/fc/report.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -25,7 +25,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'target_type', title: __('Target_type'), searchList: {post: __('信息'), comment: __('评价')}, formatter: function (value) { @@ -33,20 +33,47 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin return m[value] !== undefined ? m[value] : '-'; } }, - {field: 'target_id', title: __('Target_id')}, + {field: 'target_title', title: '举报对象', operate: false, sortable: false, formatter: function (value) { + return value ? value : '-'; + }}, {field: 'reason', title: __('Reason'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'reporter_id', title: __('Reporter_id')}, + {field: 'reporter_id', title: '举报人', addClass: 'selectpage', extend: "data-source='user/user/index' data-field='nickname'", formatter: function (value, row) { + return row.reporter_name || '-'; + }}, {field: 'status', title: __('Status'), searchList: {pending: __('待处理'), handled: __('已处理')}, - formatter: function (value) { - var m = {pending: __('待处理'), handled: __('已处理')}; - return m[value] !== undefined ? m[value] : '-'; - } + formatter: Format.statusFormatter({pending: __('待处理'), handled: __('已处理')}, {pending: 'warning', handled: 'success'}) }, {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false}, - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + { + field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, + formatter: Table.api.formatter.operate, + buttons: [ + { + name: 'handle', + text: __('HandleReport'), + title: __('HandleReport'), + classname: 'btn btn-xs btn-success btn-click', + visible: function (row) { + return row.status !== 'handled'; + }, + click: function (options, row) { + Layer.prompt({title: __('请输入处理备注(可选)'), formType: 2}, function (value, index) { + Fast.api.ajax({ + url: 'fc/report/handle', + data: {ids: row.id, remark: value} + }, function () { + $('#' + options.tableId).bootstrapTable('refresh'); + return false; + }); + Layer.close(index); + }); + } + } + ] + } ] ] }); diff --git a/public/assets/js/backend/fc/userext.js b/public/assets/js/backend/fc/userext.js index b0780a5..3d7f38e 100644 --- a/public/assets/js/backend/fc/userext.js +++ b/public/assets/js/backend/fc/userext.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -27,10 +27,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, - {field: 'user_id', title: __('User_id')}, - {field: 'nickname', title: __('Nickname'), operate: 'LIKE'}, - {field: 'mobile', title: __('Mobile'), operate: 'LIKE'}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, + {field: 'nickname', title: '用户', operate: 'LIKE'}, + {field: 'mobile', title: '手机号', operate: 'LIKE'}, { field: 'money', title: __('Money'), operate: false, formatter: function (value) { @@ -41,18 +40,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin { field: 'user_type', title: __('User_type'), searchList: {'1': __('个人'), '2': __('商家')}, - formatter: function (value) { - var m = {'1': __('个人'), '2': __('商家')}; - return m[value] !== undefined ? m[value] : '-'; - } + formatter: Format.statusFormatter({'1': __('个人'), '2': __('商家')}, {'1': 'info', '2': 'warning'}) }, { field: 'is_member', title: __('Is_member'), searchList: {'0': __('否'), '1': __('是')}, - formatter: function (value) { - var m = {'0': __('否'), '1': __('是')}; - return m[value] !== undefined ? m[value] : '-'; - } + formatter: Format.statusFormatter({'0': __('非会员'), '1': __('会员')}, {'0': 'default', '1': 'warning'}) }, {field: 'member_level', title: __('Member_level'), operate: 'LIKE'}, {field: 'member_expiretime', title: __('Member_expiretime'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime}, @@ -71,37 +64,41 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'free_view_used', title: __('Free_view_used'), visible: false}, {field: 'createtime', title: __('Createtime'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime}, {field: 'updatetime', title: __('Updatetime'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime, visible: false}, - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + { + field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, + formatter: Table.api.formatter.operate, + buttons: [ + { + name: 'recharge', + text: '余额充值', + title: '余额充值', + classname: 'btn btn-xs btn-warning btn-click', + click: function (options, row) { + Layer.prompt({title: '请输入充值金额(元)', formType: 0}, function (value, index) { + var amount = parseFloat(value); + if (!(amount > 0)) { + Layer.msg('充值金额需大于 0'); + return; + } + Fast.api.ajax({ + url: 'fc/userext/recharge', + data: {ids: row.id, amount: amount} + }, function () { + $('#' + options.tableId).bootstrapTable('refresh'); + return false; + }); + Layer.close(index); + }); + } + } + ] + } ] ] }); // 为表格绑定事件 Table.api.bindevent(table); - - // 余额充值:需先勾选用户,再输入金额 - $(document).on('click', '.btn-recharge', function () { - var ids = Table.api.selectedids(table); - if (!ids.length) { - Layer.msg('请先勾选要充值的用户'); - return; - } - Layer.prompt({title: '请输入充值金额(元)', formType: 0}, function (value, index) { - var amount = parseFloat(value); - if (!(amount > 0)) { - Layer.msg('充值金额需大于 0'); - return; - } - Fast.api.ajax({ - url: 'fc/userext/recharge', - data: {ids: ids.join(','), amount: amount} - }, function (data) { - table.bootstrapTable('refresh'); - return false; - }); - Layer.close(index); - }); - }); }, add: function () { Controller.api.bindevent(); diff --git a/public/assets/js/backend/fc/withdraw.js b/public/assets/js/backend/fc/withdraw.js index cf52187..97799e9 100644 --- a/public/assets/js/backend/fc/withdraw.js +++ b/public/assets/js/backend/fc/withdraw.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -27,9 +27,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id'), visible: false}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'withdraw_no', title: __('Withdraw_no'), operate: 'LIKE'}, - {field: 'user_id', title: __('User_id')}, + {field: 'user_id', title: '用户', addClass: 'selectpage', extend: "data-source='user/user/index' data-field='nickname'", formatter: function (value, row) { + return row.user_name || '-'; + }}, { field: 'amount', title: __('Amount'), operate: 'BETWEEN', formatter: function (value) { @@ -47,53 +49,64 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin { field: 'status', title: __('Status'), searchList: {auditing: __('待审核'), paid: __('已打款'), rejected: __('已驳回')}, - formatter: function (value) { - var m = {auditing: __('待审核'), paid: __('已打款'), rejected: __('已驳回')}; - return m[value] !== undefined ? m[value] : '-'; - } + formatter: Format.statusFormatter({auditing: __('待审核'), paid: __('已打款'), rejected: __('已驳回')}, {auditing: 'warning', paid: 'success', rejected: 'danger'}) }, {field: 'reason', title: __('Reason'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'paytime', title: __('Paytime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false}, - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + { + field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, + formatter: Table.api.formatter.operate, + buttons: [ + { + name: 'pay', + text: __('PayWithdraw'), + title: __('PayWithdraw'), + classname: 'btn btn-xs btn-success btn-click', + visible: function (row) { + return row.status === 'auditing'; + }, + confirm: __('确认对该提现申请打款?'), + click: function (options, row) { + Fast.api.ajax({ + url: 'fc/withdraw/pay', + data: {ids: row.id, op: 'pay'} + }, function () { + $('#' + options.tableId).bootstrapTable('refresh'); + return false; + }); + } + }, + { + name: 'reject', + text: __('RejectWithdraw'), + title: __('RejectWithdraw'), + classname: 'btn btn-xs btn-danger btn-click', + visible: function (row) { + return row.status === 'auditing'; + }, + click: function (options, row) { + Layer.prompt({title: __('请输入驳回原因'), formType: 2}, function (value, index) { + Fast.api.ajax({ + url: 'fc/withdraw/pay', + data: {ids: row.id, op: 'reject', reason: value} + }, function () { + $('#' + options.tableId).bootstrapTable('refresh'); + return false; + }); + Layer.close(index); + }); + } + } + ] + } ] ] }); // 为表格绑定事件 Table.api.bindevent(table); - - // 打款 - $(document).on('click', '.btn-pay', function () { - var ids = Table.api.selectedids(table); - Layer.confirm(__('确认对选中的提现申请打款?'), {icon: 3, title: __('提示')}, function (index) { - Fast.api.ajax({ - url: 'fc/withdraw/pay', - data: {ids: ids.join(','), op: 'pay'} - }, function (data) { - table.bootstrapTable('refresh'); - return false; - }); - Layer.close(index); - }); - }); - - // 驳回 - $(document).on('click', '.btn-reject', function () { - var ids = Table.api.selectedids(table); - Layer.prompt({title: __('请输入驳回原因'), formType: 2}, function (value, index) { - Fast.api.ajax({ - url: 'fc/withdraw/pay', - data: {ids: ids.join(','), op: 'reject', reason: value} - }, function (data) { - table.bootstrapTable('refresh'); - return false; - }); - Layer.close(index); - }); - }); - }, add: function () { Controller.api.bindevent(); diff --git a/public/assets/js/backend/format.js b/public/assets/js/backend/format.js new file mode 100644 index 0000000..a92eec1 --- /dev/null +++ b/public/assets/js/backend/format.js @@ -0,0 +1,42 @@ +define(['jquery'], function ($) { + + var Format = { + /** + * 列表序号(跨分页连续) + */ + serial: function (value, row, index) { + var table = this.table ? $(this.table) : null; + var pageSize = 0; + var pageNumber = 1; + if (table && table.length && table.data('bootstrap.table')) { + var options = table.bootstrapTable('getOptions') || {}; + pageSize = parseInt(options.pageSize, 10) || 0; + pageNumber = parseInt(options.pageNumber, 10) || 1; + } + return pageSize > 0 ? (pageNumber - 1) * pageSize + index + 1 : index + 1; + }, + /** + * 状态徽标 + */ + status: function (text, tone) { + if (text === null || typeof text === 'undefined' || text === '') { + text = '-'; + } + return '' + text + ''; + }, + /** + * 生成状态字段的 formatter + * @param map 值 => 文案 + * @param tones 值 => 颜色(success/warning/danger/info/default) + */ + statusFormatter: function (map, tones) { + tones = tones || {}; + return function (value) { + var text = map[value] !== undefined ? map[value] : '-'; + return Format.status(text, tones[value] || 'default'); + }; + } + }; + + return Format; +}); diff --git a/public/assets/js/backend/general/attachment.js b/public/assets/js/backend/general/attachment.js index cd714e1..a897ec0 100755 --- a/public/assets/js/backend/general/attachment.js +++ b/public/assets/js/backend/general/attachment.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefined, Backend, Form, Table) { +define(['jquery', 'bootstrap', 'backend', 'form', 'table', 'backend/format'], function ($, undefined, Backend, Form, Table, Format) { var Controller = { index: function () { @@ -23,7 +23,7 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefin columns: [ [ {field: 'state', checkbox: true}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'category', title: __('Category'), operate: 'in', formatter: Table.api.formatter.label, searchList: Config.categoryList}, {field: 'admin_id', title: __('Admin_id'), visible: false, addClass: "selectpage", extend: "data-source='auth/admin/index' data-field='nickname'"}, {field: 'user_id', title: __('User_id'), visible: false, addClass: "selectpage", extend: "data-source='user/user/index' data-field='nickname'"}, @@ -148,7 +148,7 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefin columns: [ [ {field: 'state', checkbox: multiple, visible: multiple, operate: false}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'category', title: __('Category'), operate: 'in', formatter: Table.api.formatter.label, searchList: Config.categoryList}, {field: 'admin_id', title: __('Admin_id'), formatter: Table.api.formatter.search, visible: false}, {field: 'user_id', title: __('User_id'), formatter: Table.api.formatter.search, visible: false}, diff --git a/public/assets/js/backend/general/profile.js b/public/assets/js/backend/general/profile.js index adfd61a..2071cce 100755 --- a/public/assets/js/backend/general/profile.js +++ b/public/assets/js/backend/general/profile.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'upload'], function ($, undefined, Backend, Table, Form, Upload) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'upload', 'backend/format'], function ($, undefined, Backend, Table, Form, Upload, Format) { var Controller = { index: function () { @@ -24,7 +24,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'upload'], function ( url: $.fn.bootstrapTable.defaults.extend.index_url, columns: [ [ - {field: 'id', title: 'ID'}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'title', title: __('Title')}, {field: 'url', title: __('Url'), align: 'left', formatter: Table.api.formatter.url}, {field: 'ip', title: __('ip'), formatter:Table.api.formatter.search}, diff --git a/public/assets/js/backend/user/group.js b/public/assets/js/backend/user/group.js index d083433..36a099f 100755 --- a/public/assets/js/backend/user/group.js +++ b/public/assets/js/backend/user/group.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ($, undefined, Backend, Table, Form, undefined) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree', 'backend/format'], function ($, undefined, Backend, Table, Form, undefined, Format) { //读取选中的条目 $.jstree.core.prototype.get_all_checked = function (full) { var obj = this.get_selected(), i, j; @@ -39,7 +39,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ( columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'name', title: __('Name')}, {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, {field: 'updatetime', title: __('Updatetime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, diff --git a/public/assets/js/backend/user/rule.js b/public/assets/js/backend/user/rule.js index 0ba2e80..8dd4c67 100755 --- a/public/assets/js/backend/user/rule.js +++ b/public/assets/js/backend/user/rule.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -25,7 +25,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'pid', title: __('Pid'), visible: false}, {field: 'title', title: __('Title'), align: 'left', formatter: Controller.api.formatter.title}, {field: 'name', title: __('Name'), align: 'left', formatter: Controller.api.formatter.name}, diff --git a/public/assets/js/backend/user/user.js b/public/assets/js/backend/user/user.js index 6c042a1..fc1284b 100755 --- a/public/assets/js/backend/user/user.js +++ b/public/assets/js/backend/user/user.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -26,7 +26,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {checkbox: true}, - {field: 'id', title: __('Id'), sortable: true}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'username', title: __('Username'), operate: 'LIKE'}, {field: 'nickname', title: __('Nickname'), operate: 'LIKE'}, { diff --git a/public/assets/js/backend/wechat/autoreply.js b/public/assets/js/backend/wechat/autoreply.js index fcf4391..45d3bec 100755 --- a/public/assets/js/backend/wechat/autoreply.js +++ b/public/assets/js/backend/wechat/autoreply.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefined, Backend, Form, Table) { +define(['jquery', 'bootstrap', 'backend', 'form', 'table', 'backend/format'], function ($, undefined, Backend, Form, Table, Format) { var Controller = { index: function () { @@ -23,7 +23,7 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefin columns: [ [ {field: 'state', checkbox: true,}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'title', title: __('Title')}, {field: 'text', title: __('Text')}, {field: 'eventkey', title: __('Event key')}, diff --git a/public/assets/js/backend/wechat/config.js b/public/assets/js/backend/wechat/config.js index bb7f8a2..0833f01 100755 --- a/public/assets/js/backend/wechat/config.js +++ b/public/assets/js/backend/wechat/config.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { @@ -24,7 +24,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin columns: [ [ {field: 'state', checkbox: true}, - {field: 'id', title: __('Id')}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'name', title: __('Name')}, {field: 'title', title: __('Title')}, {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, diff --git a/public/assets/js/backend/wechat/response.js b/public/assets/js/backend/wechat/response.js index 62a289f..389a7b7 100755 --- a/public/assets/js/backend/wechat/response.js +++ b/public/assets/js/backend/wechat/response.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'adminlte'], function ($, undefined, Backend, Table, Form, Adminlte) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'adminlte', 'backend/format'], function ($, undefined, Backend, Table, Form, Adminlte, Format) { var Controller = { index: function () { @@ -22,7 +22,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'adminlte'], function columns: [ [ {field: 'state', checkbox: true,}, - {field: 'id', title: 'ID'}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'type', title: __('Type')}, {field: 'title', title: __('Resource title')}, {field: 'eventkey', title: __('Event key')}, @@ -52,7 +52,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'adminlte'], function columns: [ [ {field: 'state', checkbox: true,}, - {field: 'id', title: 'ID'}, + {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'type', title: __('Type')}, {field: 'title', title: __('Title')}, {field: 'eventkey', title: __('Event key')}, diff --git a/uniapp/App.vue b/uniapp/App.vue index 7e18b45..b7b8145 100644 --- a/uniapp/App.vue +++ b/uniapp/App.vue @@ -1,13 +1,28 @@ diff --git a/uniapp/common/api/auth.js b/uniapp/common/api/auth.js index 093fe93..e71f51f 100644 --- a/uniapp/common/api/auth.js +++ b/uniapp/common/api/auth.js @@ -7,6 +7,8 @@ import { get, post, buildUrl, buildHeaders } from '../utils/request.js' export const authApi = { /** 微信一键授权登录:code -> token */ wxLogin: (payload) => post('/auth/wx-login', payload, { silent: true }), + /** 手机号密码登录(支持 H5 调试) */ + passwordLogin: (payload) => post('/auth/password-login', payload, { silent: true }), /** 手机号绑定(手动输入 11 位手机号) */ bindPhone: (payload) => post('/auth/bind-phone', payload, { silent: true }), /** 微信手机号快捷获取(