发卡网源码三合一解决方案:企业版+个人版+易支付对接教程
在数字经济蓬勃发展的今天,虚拟商品交易已成为电子商务的重要组成部分,传统的电子商务平台往往无法满足虚拟商品特有的即时交付、自动化管理和灵活定价等需求,这为专业化的发卡系统创造了巨大的市场空间。本发卡网三合一解决方案正是在这样的背景下应运而生。它不仅仅是一个简单的商品销售系统,而是一个集成了企业级管理、个人卖家友好和多元化支付对接的综合性平台。
源码及演示:fakaysw.top
系统采用模块化架构设计,支持企业版与个人版的无缝切换,让您可以根据业务发展阶段灵活调整系统功能。企业版提供了完整的权限管理、多店铺支持、发票系统和API接口,满足规模化运营的需求;个人版则以简洁易用为核心,降低技术门槛,让个人卖家能够快速上手。同时,我们深度集成了易支付等多种支付接口,解决了虚拟交易中最核心的资金流转问题。
一、系统架构设计
1.1 核心架构设计
本发卡网三合一解决方案采用模块化设计,支持企业版和个人版功能切换,同时集成易支付接口。以下是系统基础架构:
<?php // 系统配置文件 config.php define('SYSTEM_VERSION', '3.0.0'); define('SYSTEM_MODE', 'enterprise'); // enterprise 或 personal // 数据库配置 class DatabaseConfig { const HOST = 'localhost'; const USERNAME = 'root'; const PASSWORD = ''; const DB_NAME = 'faka_system'; const CHARSET = 'utf8mb4'; } // 支付接口配置 class PaymentConfig { const EASY_PAY_URL = 'https://api.easypay.com/v3/'; const TIMEOUT = 30; const VERSION = '1.0'; } // 系统模式检测 class SystemMode { public static function isEnterprise() { return SYSTEM_MODE === 'enterprise'; } public static function isPersonal() { return SYSTEM_MODE === 'personal'; } public static function switchMode($mode) { if (in_array($mode, ['enterprise', 'personal'])) { define('SYSTEM_MODE', $mode); return true; } return false; } } ?>
1.2 数据库设计
-- 商品表结构 CREATE TABLE `products` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `description` text, `price` decimal(10,2) NOT NULL, `stock` int(11) DEFAULT 0, `category_id` int(11) DEFAULT NULL, `type` enum('virtual','entity') DEFAULT 'virtual', `auto_delivery` tinyint(1) DEFAULT 1, `delivery_content` text, `status` tinyint(1) DEFAULT 1, `created_at` timestamp DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `category_id` (`category_id`), KEY `status` (`status`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- 订单表 CREATE TABLE `orders` ( `id` varchar(32) NOT NULL, `trade_no` varchar(64) DEFAULT NULL, `product_id` int(11) NOT NULL, `quantity` int(11) DEFAULT 1, `total_price` decimal(10,2) NOT NULL, `email` varchar(255) DEFAULT NULL, `contact` varchar(255) DEFAULT NULL, `status` enum('pending','paid','delivered','completed','cancelled') DEFAULT 'pending', `pay_type` varchar(50) DEFAULT NULL, `ip_address` varchar(45) DEFAULT NULL, `user_agent` text, `payment_info` text, `delivery_info` text, `created_at` timestamp DEFAULT CURRENT_TIMESTAMP, `paid_at` timestamp NULL DEFAULT NULL, `delivered_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `trade_no` (`trade_no`), KEY `product_id` (`product_id`), KEY `status` (`status`), KEY `email` (`email`(191)) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- 支付配置表 CREATE TABLE `payment_configs` ( `id` int(11) NOT NULL AUTO_INCREMENT, `payment_code` varchar(50) NOT NULL, `config` text NOT NULL, `status` tinyint(1) DEFAULT 1, `sort` int(11) DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `payment_code` (`payment_code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- 企业版特有表 CREATE TABLE IF NOT EXISTS `enterprise_settings` ( `id` int(11) NOT NULL AUTO_INCREMENT, `company_name` varchar(255) DEFAULT NULL, `tax_number` varchar(100) DEFAULT NULL, `invoice_enabled` tinyint(1) DEFAULT 0, `multi_branch` tinyint(1) DEFAULT 0, `department_limit` int(11) DEFAULT 1, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- 个人版设置表 CREATE TABLE IF NOT EXISTS `personal_settings` ( `id` int(11) NOT NULL AUTO_INCREMENT, `seller_name` varchar(100) DEFAULT NULL, `contact_qq` varchar(20) DEFAULT NULL, `contact_wx` varchar(100) DEFAULT NULL, `custom_style` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
二、核心功能实现
2.1 支付接口基类
<?php // 支付接口抽象类 PayInterface.php abstract class PayInterface { protected $config = []; protected $notifyUrl = ''; protected $returnUrl = ''; public function __construct($config = []) { $this->config = array_merge($this->getDefaultConfig(), $config); } abstract protected function getDefaultConfig(); abstract public function pay($orderData); abstract public function verify($data); abstract public function refund($orderNo, $amount, $reason = ''); // 设置通知URL public function setNotifyUrl($url) { $this->notifyUrl = $url; return $this; } // 设置返回URL public function setReturnUrl($url) { $this->returnUrl = $url; return $this; } // 生成签名 protected function generateSign($data, $signType = 'MD5') { ksort($data); $string = urldecode(http_build_query($data)); $string .= '&key=' . $this->config['key']; switch(strtoupper($signType)) { case 'MD5': return strtoupper(md5($string)); case 'SHA256': return strtoupper(hash('sha256', $string)); default: return strtoupper(md5($string)); } } } ?>
2.2 易支付接口实现
<?php // 易支付实现 EasyPay.php require_once 'PayInterface.php'; class EasyPay extends PayInterface { protected function getDefaultConfig() { return [ 'pid' => '', 'key' => '', 'api_url' => 'https://api.easypay.com/', 'sign_type' => 'MD5', 'version' => '1.0' ]; } /** * 发起支付 * @param array $orderData 订单数据 * @return array */ public function pay($orderData) { $params = [ 'pid' => $this->config['pid'], 'type' => $orderData['pay_type'] ?? 'alipay', 'out_trade_no' => $orderData['trade_no'], 'notify_url' => $this->notifyUrl, 'return_url' => $this->returnUrl, 'name' => $orderData['product_name'], 'money' => number_format($orderData['amount'], 2, '.', ''), 'clientip' => $_SERVER['REMOTE_ADDR'], 'device' => $this->getDeviceType(), 'param' => isset($orderData['param']) ? json_encode($orderData['param']) : '', 'sign_type' => $this->config['sign_type'], 'version' => $this->config['version'], 'timestamp' => time() ]; // 移除空值 $params = array_filter($params, function($value) { return $value !== '' && $value !== null; }); // 生成签名 $params['sign'] = $this->generateSign($params, $params['sign_type']); // 构建支付URL $payUrl = $this->config['api_url'] . 'create?' . http_build_query($params); return [ 'code' => 0, 'message' => 'success', 'data' => [ 'pay_url' => $payUrl, 'trade_no' => $orderData['trade_no'], 'params' => $params ] ]; } /** * 验证支付结果 * @param array $data 回调数据 * @return bool */ public function verify($data) { if (!isset($data['sign']) || empty($data['sign'])) { return false; } $sign = $data['sign']; unset($data['sign']); unset($data['sign_type']); $localSign = $this->generateSign($data, $data['sign_type'] ?? 'MD5'); return $sign === $localSign; } /** * 退款处理 * @param string $orderNo 订单号 * @param float $amount 退款金额 * @param string $reason 退款原因 * @return array */ public function refund($orderNo, $amount, $reason = '') { $params = [ 'pid' => $this->config['pid'], 'trade_no' => $orderNo, 'money' => number_format($amount, 2, '.', ''), 'refund_reason' => $reason, 'sign_type' => $this->config['sign_type'], 'timestamp' => time(), 'nonce_str' => $this->generateNonceStr() ]; $params['sign'] = $this->generateSign($params, $params['sign_type']); $result = $this->httpPost($this->config['api_url'] . 'refund', $params); return json_decode($result, true); } /** * 查询订单状态 * @param string $tradeNo 商户订单号 * @return array */ public function query($tradeNo) { $params = [ 'pid' => $this->config['pid'], 'out_trade_no' => $tradeNo, 'sign_type' => $this->config['sign_type'], 'timestamp' => time() ]; $params['sign'] = $this->generateSign($params, $params['sign_type']); $result = $this->httpPost($this->config['api_url'] . 'query', $params); return json_decode($result, true); } /** * HTTP POST请求 */ private function httpPost($url, $data) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); 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, 30); $response = curl_exec($ch); if (curl_errno($ch)) { curl_close($ch); return json_encode(['code' => 500, 'message' => curl_error($ch)]); } curl_close($ch); return $response; } /** * 生成随机字符串 */ private function generateNonceStr($length = 32) { $chars = "abcdefghijklmnopqrstuvwxyz0123456789"; $str = ""; for ($i = 0; $i < $length; $i++) { $str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1); } return $str; } /** * 获取设备类型 */ private function getDeviceType() { $userAgent = $_SERVER['HTTP_USER_AGENT'] ?? ''; if (strpos($userAgent, 'Mobile') !== false || strpos($userAgent, 'Android') !== false || strpos($userAgent, 'iPhone') !== false) { return 'mobile'; } return 'pc'; } } ?>

三、订单处理系统
3.1 订单核心类
<?php // 订单处理类 OrderProcessor.php class OrderProcessor { private $db; private $payment; public function __construct($dbConnection) { $this->db = $dbConnection; } /** * 创建订单 */ public function createOrder($productId, $quantity, $contact, $payType) { try { // 开始事务 $this->db->beginTransaction(); // 获取商品信息 $product = $this->getProduct($productId); if (!$product || $product['status'] != 1) { throw new Exception('商品不存在或已下架'); } // 检查库存 if ($product['stock'] >= 0 && $product['stock'] < $quantity) { throw new Exception('商品库存不足'); } // 生成订单号 $orderNo = $this->generateOrderNo(); $tradeNo = 'T' . date('YmdHis') . mt_rand(1000, 9999); // 计算总价 $totalPrice = bcmul($product['price'], $quantity, 2); // 创建订单记录 $stmt = $this->db->prepare(" INSERT INTO orders (id, trade_no, product_id, quantity, total_price, contact, pay_type, status, ip_address, user_agent) VALUES (?, ?, ?, ?, ?, ?, ?, 'pending', ?, ?) "); $stmt->execute([ $orderNo, $tradeNo, $productId, $quantity, $totalPrice, $contact, $payType, $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'] ?? '' ]); // 更新库存 if ($product['stock'] > 0) { $this->updateProductStock($productId, $quantity); } $this->db->commit(); return [ 'success' => true, 'order_no' => $orderNo, 'trade_no' => $tradeNo, 'total_price' => $totalPrice, 'product_name' => $product['name'] ]; } catch (Exception $e) { $this->db->rollBack(); return [ 'success' => false, 'message' => $e->getMessage() ]; } } /** * 处理支付回调 */ public function handlePaymentNotify($data, $paymentType) { // 验证签名 $payment = $this->getPaymentInstance($paymentType); if (!$payment->verify($data)) { return ['success' => false, 'message' => '签名验证失败']; } $tradeNo = $data['out_trade_no'] ?? ''; $payAmount = $data['money'] ?? 0; // 查询订单 $order = $this->getOrderByTradeNo($tradeNo); if (!$order) { return ['success' => false, 'message' => '订单不存在']; } if ($order['status'] != 'pending') { return ['success' => true, 'message' => '订单已处理']; } // 验证金额 if (bccomp($payAmount, $order['total_price'], 2) != 0) { return ['success' => false, 'message' => '支付金额不匹配']; } // 更新订单状态 $this->updateOrderStatus($tradeNo, 'paid', [ 'payment_info' => json_encode($data, JSON_UNESCAPED_UNICODE), 'paid_at' => date('Y-m-d H:i:s') ]); // 自动发货 if ($this->shouldAutoDeliver($order['product_id'])) { $this->autoDeliver($order['id']); } return ['success' => true, 'message' => '支付成功']; } /** * 自动发货 */ private function autoDeliver($orderId) { $order = $this->getOrderById($orderId); $product = $this->getProduct($order['product_id']); if ($product['type'] == 'virtual' && $product['auto_delivery'] == 1) { $deliveryContent = $this->generateDeliveryContent($product); $stmt = $this->db->prepare(" UPDATE orders SET status = 'delivered', delivery_info = ?, delivered_at = NOW() WHERE id = ? "); $stmt->execute([$deliveryContent, $orderId]); // 发送邮件或站内通知 $this->sendDeliveryNotification($order, $deliveryContent); } } /** * 生成发货内容 */ private function generateDeliveryContent($product) { $content = $product['delivery_content']; // 如果是卡密商品,从卡密库中提取 if ($product['type'] == 'virtual' && strpos($content, '{card}') !== false) { $card = $this->getAvailableCard($product['id']); if ($card) { $content = str_replace('{card}', $card['card_number'], $content); if (strpos($content, '{password}') !== false) { $content = str_replace('{password}', $card['card_password'], $content); } $this->markCardUsed($card['id'], $orderId); } } return $content; } /** * 获取可用的卡密 */ private function getAvailableCard($productId) { $stmt = $this->db->prepare(" SELECT * FROM product_cards WHERE product_id = ? AND status = 'available' LIMIT 1 FOR UPDATE "); $stmt->execute([$productId]); return $stmt->fetch(PDO::FETCH_ASSOC); } private function getProduct($productId) { $stmt = $this->db->prepare("SELECT * FROM products WHERE id = ?"); $stmt->execute([$productId]); return $stmt->fetch(PDO::FETCH_ASSOC); } private function generateOrderNo() { return date('YmdHis') . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT); } } ?>
四、企业版与个人版切换
4.1 模式切换控制器
<?php // 系统模式控制器 SystemController.php class SystemController { private $mode; private $db; public function __construct($dbConnection) { $this->db = $dbConnection; $this->mode = $this->detectMode(); } /** * 检测当前模式 */ private function detectMode() { // 从数据库读取配置 $stmt = $this->db->prepare("SELECT value FROM system_config WHERE name = 'system_mode'"); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); if ($result && in_array($result['value'], ['enterprise', 'personal'])) { return $result['value']; } // 默认企业版 return 'enterprise'; } /** * 切换系统模式 */ public function switchMode($newMode, $config = []) { if (!in_array($newMode, ['enterprise', 'personal'])) { return ['success' => false, 'message' => '不支持的版本模式']; } try { $this->db->beginTransaction(); // 更新系统模式 $stmt = $this->db->prepare(" INSERT INTO system_config (name, value) VALUES ('system_mode', ?) ON DUPLICATE KEY UPDATE value = ? "); $stmt->execute([$newMode, $newMode]); // 根据模式初始化配置 if ($newMode == 'enterprise') { $this->initEnterpriseConfig($config); } else { $this->initPersonalConfig($config); } $this->db->commit(); $this->mode = $newMode; // 清除缓存 $this->clearCache(); return ['success' => true, 'message' => '系统模式切换成功']; } catch (Exception $e) { $this->db->rollBack(); return ['success' => false, 'message' => '切换失败: ' . $e->getMessage()]; } } /** * 初始化企业版配置 */ private function initEnterpriseConfig($config) { $defaultConfig = [ 'invoice_enabled' => 1, 'multi_branch' => 0, 'department_limit' => 5, 'tax_rate' => 0.06, 'company_name' => '', 'tax_number' => '' ]; $config = array_merge($defaultConfig, $config); $stmt = $this->db->prepare(" INSERT INTO enterprise_settings (company_name, tax_number, invoice_enabled, multi_branch, department_limit) VALUES (?, ?, ?, ?, ?) "); $stmt->execute([ $config['company_name'], $config['tax_number'], $config['invoice_enabled'], $config['multi_branch'], $config['department_limit'] ]); } /** * 初始化个人版配置 */ private function initPersonalConfig($config) { $defaultConfig = [ 'seller_name' => '个人商家', 'contact_qq' => '', 'contact_wx' => '', 'custom_css' => '', 'simple_mode' => 1 ]; $config = array_merge($defaultConfig, $config); $stmt = $this->db->prepare(" INSERT INTO personal_settings (seller_name, contact_qq, contact_wx, custom_style) VALUES (?, ?, ?, ?) "); $stmt->execute([ $config['seller_name'], $config['contact_qq'], $config['contact_wx'], json_encode(['custom_css' => $config['custom_css']]) ]); } /** * 获取当前功能列表 */ public function getAvailableFeatures() { $baseFeatures = [ '商品管理', '订单管理', '支付接口', '自动发货', '数据统计' ]; if ($this->mode == 'enterprise') { $enterpriseFeatures = [ '多店铺管理', '发票系统', '部门权限管理', 'API接口', '批量操作', '定制报表', '客户管理', '员工账号' ]; return array_merge($baseFeatures, $enterpriseFeatures); } else { $personalFeatures = [ '简单管理', '快速设置', '模板切换', '基础统计' ]; return array_merge($baseFeatures, $personalFeatures); } } /** * 获取系统配置 */ public function getSystemConfig() { if ($this->mode == 'enterprise') { $stmt = $this->db->prepare("SELECT * FROM enterprise_settings LIMIT 1"); $stmt->execute(); $config = $stmt->fetch(PDO::FETCH_ASSOC); $config['type'] = 'enterprise'; $config['features'] = $this->getAvailableFeatures(); } else { $stmt = $this->db->prepare("SELECT * FROM personal_settings LIMIT 1"); $stmt->execute(); $config = $stmt->fetch(PDO::FETCH_ASSOC); if ($config && $config['custom_style']) { $config['custom_style'] = json_decode($config['custom_style'], true); } $config['type'] = 'personal'; $config['features'] = $this->getAvailableFeatures(); } return $config; } } ?>
五、安装部署教程
5.1 安装脚本
<?php // install.php 安装脚本 class Installer { private $db; private $requirements = [ 'php_version' => '7.2', 'extensions' => ['pdo_mysql', 'openssl', 'json', 'mbstring'], 'writable_dirs' => ['uploads', 'config', 'cache'] ]; public function checkRequirements() { $errors = []; $success = []; // 检查PHP版本 if (version_compare(PHP_VERSION, $this->requirements['php_version'], '<')) { $errors[] = "PHP版本需要 {$this->requirements['php_version']} 或更高,当前版本:" . PHP_VERSION; } else { $success[] = "PHP版本满足要求:" . PHP_VERSION; } // 检查扩展 foreach ($this->requirements['extensions'] as $ext) { if (!extension_loaded($ext)) { $errors[] = "缺少必要扩展:{$ext}"; } else { $success[] = "扩展已安装:{$ext}"; } } // 检查目录权限 foreach ($this->requirements['writable_dirs'] as $dir) { $path = __DIR__ . '/' . $dir; if (!is_writable($path)) { if (!is_dir($path)) { if (!mkdir($path, 0755, true)) { $errors[] = "无法创建目录:{$dir}"; } } else { if (!chmod($path, 0755)) { $errors[] = "目录不可写:{$dir}"; } } } else { $success[] = "目录可写:{$dir}"; } } return [ 'errors' => $errors, 'success' => $success, 'passed' => empty($errors) ]; } public function installDatabase($dbConfig) { try { // 创建数据库连接 $dsn = "mysql:host={$dbConfig['host']};port={$dbConfig['port']};charset=utf8mb4"; $this->db = new PDO($dsn, $dbConfig['username'], $dbConfig['password']); $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // 创建数据库 $this->db->exec("CREATE DATABASE IF NOT EXISTS `{$dbConfig['database']}` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); $this->db->exec("USE `{$dbConfig['database']}`"); // 读取SQL文件 $sqlFile = __DIR__ . '/install/database.sql'; if (!file_exists($sqlFile)) { throw new Exception("数据库文件不存在"); } $sql = file_get_contents($sqlFile); $queries = array_filter(explode(';', $sql)); // 执行SQL foreach ($queries as $query) { if (trim($query)) { $this->db->exec($query); } } // 创建管理员账户 $passwordHash = password_hash($dbConfig['admin_password'], PASSWORD_DEFAULT); $stmt = $this->db->prepare(" INSERT INTO admins (username, password, email, status, created_at) VALUES (?, ?, ?, 1, NOW()) "); $stmt->execute([$dbConfig['admin_username'], $passwordHash, $dbConfig['admin_email']]); // 保存数据库配置 $configContent = "<?phpn"; $configContent .= "define('DB_HOST', '{$dbConfig['host']}');n"; $configContent .= "define('DB_PORT', {$dbConfig['port']});n"; $configContent .= "define('DB_NAME', '{$dbConfig['database']}');n"; $configContent .= "define('DB_USER', '{$dbConfig['username']}');n"; $configContent .= "define('DB_PASS', '{$dbConfig['password']}');n"; $configContent .= "define('DB_CHARSET', 'utf8mb4');n"; file_put_contents(__DIR__ . '/config/database.php', $configContent); return ['success' => true, 'message' => '数据库安装成功']; } catch (Exception $e) { return ['success' => false, 'message' => '安装失败: ' . $e->getMessage()]; } } public function completeInstallation($siteConfig) { // 生成配置文件 $config = [ 'site_name' => $siteConfig['site_name'], 'site_url' => rtrim($siteConfig['site_url'], '/'), 'admin_path' => $siteConfig['admin_path'], 'timezone' => 'Asia/Shanghai', 'debug' => false, 'version' => '3.0.0', 'installed' => true, 'install_time' => date('Y-m-d H:i:s') ]; $configContent = "<?phpnreturn " . var_export($config, true) . ";n"; file_put_contents(__DIR__ . '/config/site.php', $configContent); // 创建.htaccess文件 $htaccess = << Order allow,deny Deny from all # 压缩传输 AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript application/json HTACCESS; file_put_contents(__DIR__ . '/.htaccess', $htaccess); // 创建安装锁文件 file_put_contents(__DIR__ . '/install.lock', '安装时间: ' . date('Y-m-d H:i:s')); return ['success' => true, 'message' => '系统安装完成']; } } ?>
六、部署与配置
6.1 部署配置文件
# Nginx配置文件 faka.conf server { listen 80; server_name yourdomain.com; root /var/www/faka/public; index index.php index.html; # 安全头 add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options "nosniff"; add_header Referrer-Policy "strict-origin-when-cross-origin"; # 禁止访问敏感文件 location ~* .(sql|log|ini|conf)$ { deny all; } location / { try_files $uri $uri/ /index.php?$query_string; } location ~ .php$ { fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; # 安全设置 fastcgi_param HTTP_PROXY ""; fastcgi_param PHP_VALUE " upload_max_filesize=10M post_max_size=10M max_execution_time=300 session.cookie_httponly=1 session.cookie_secure=1 "; } # 静态文件缓存 location ~* .(jpg|jpeg|png|gif|ico|css|js|woff|woff2|ttf|svg)$ { expires 1y; add_header Cache-Control "public, immutable"; } # 限制上传大小 client_max_body_size 10M; }
6.2 系统配置文件
<?php // config/system.php return [ // 系统配置 'system' => [ 'name' => '发卡网三合一系统', 'version' => '3.0.0', 'debug' => false, 'timezone' => 'Asia/Shanghai', 'url' => 'https://yourdomain.com', ], // 数据库配置 'database' => [ 'host' => 'localhost', 'port' => 3306, 'name' => 'faka_system', 'username' => 'faka_user', 'password' => 'your_secure_password', 'charset' => 'utf8mb4', 'prefix' => 'fk_', ], // 支付配置 'payment' => [ 'default' => 'easypay', 'drivers' => [ 'easypay' => [ 'pid' => 'your_pid', 'key' => 'your_key', 'api_url' => 'https://api.easypay.com/', 'sign_type' => 'MD5', ], 'alipay' => [ 'app_id' => '', 'merchant_private_key' => '', 'alipay_public_key' => '', ], 'wxpay' => [ 'appid' => '', 'mch_id' => '', 'key' => '', ] ] ], // 邮件配置 'mail' => [ 'driver' => 'smtp', 'host' => 'smtp.yourmail.com', 'port' => 465, 'username' => 'noreply@yourdomain.com', 'password' => 'your_password', 'encryption' => 'ssl', 'from' => [ 'address' => 'noreply@yourdomain.com', 'name' => '发卡网系统' ] ], // 缓存配置 'cache' => [ 'driver' => 'file', // file, redis, memcached 'prefix' => 'faka_', 'ttl' => 3600, ], // 安全配置 'security' => [ 'csrf_protection' => true, 'xss_protection' => true, 'rate_limit' => [ 'enabled' => true, 'max_requests' => 100, 'period' => 60, ], 'admin_ip_whitelist' => [], ], // 上传配置 'upload' => [ 'max_size' => 10485760, // 10MB 'allowed_types' => ['jpg', 'jpeg', 'png', 'gif', 'pdf'], 'path' => 'uploads/', ], ]; ?>

总结
本发卡网三合一解决方案提供完整的企业级发卡系统实现,包含企业版和个人版两种模式,并集成易支付接口。系统采用模块化设计,安全性高,扩展性强,适合不同规模的业务需求。代码结构清晰,注释完整,便于二次开发和定制。通过本系统,用户可以快速搭建自己的发卡平台,无论是个人卖家还是企业用户,都能找到合适的运营模式。系统持续更新维护,保证安全稳定运行。
