diff --git a/.project b/.project new file mode 100644 index 0000000000..08dada5ea5 --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + ss-panel-v3-mod_UIChanges + + + + + + com.aptana.ide.core.unifiedBuilder + + + + + + com.aptana.projects.webnature + + + + 1522297588605 + + 26 + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-node_modules + + + + diff --git a/app/Controllers/HomeController.php b/app/Controllers/HomeController.php index 0bed4ee52b..5b2b9197f7 100644 --- a/app/Controllers/HomeController.php +++ b/app/Controllers/HomeController.php @@ -105,6 +105,16 @@ public function page500($request, $response, $args) return $newResponse; } + public function codepay_callback($request, $response, $args) + { + echo ' + + '; + return; + } + public function pay_callback($request, $response, $args) { Pay::callback($request); diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index c7fd983f23..a8f76e49a6 100644 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -280,6 +280,62 @@ function ($query) { return $this->view()->assign('codes', $codes)->assign('total_in', Code::where('isused', 1)->where('type', -1)->sum('number'))->assign('total_out', Code::where('isused', 1)->where('type', -2)->sum('number'))->display('user/donate.tpl'); } + function isHTTPS() + { + define('HTTPS', false); + if (defined('HTTPS') && HTTPS) return true; + if (!isset($_SERVER)) return FALSE; + if (!isset($_SERVER['HTTPS'])) return FALSE; + if ($_SERVER['HTTPS'] === 1) { //Apache + return TRUE; + } elseif ($_SERVER['HTTPS'] === 'on') { //IIS + return TRUE; + } elseif ($_SERVER['SERVER_PORT'] == 443) { //其他 + return TRUE; + } + return FALSE; + } + + public function codepay($request, $response, $args) + { + $codepay_id=Config::get('codepay_id');//这里改成码支付ID + $codepay_key=Config::get('codepay_key'); //这是您的通讯密钥 + $uid = $this->user->id; + $price = $request->getParam('price'); + $type = $request->getParam('type'); + $url = (UserController::isHTTPS() ? 'https://' : 'http://').$_SERVER['HTTP_HOST']; + $data = array( + "id" => $codepay_id,//你的码支付ID + "pay_id" => $uid, //唯一标识 可以是用户ID,用户名,session_id(),订单ID,ip 付款后返回 + "type" => $type,//1支付宝支付 2QQ钱包 3微信支付 + "price" => $price,//金额100元 + "param" => "",//自定义参数 + "notify_url"=> $url.'/codepay_callback',//通知地址 + "return_url"=> $url.'/codepay_callback',//跳转地址 + ); //构造需要传递的参数 + + ksort($data); //重新排序$data数组 + reset($data); //内部指针指向数组中的第一个元素 + + $sign = ''; //初始化需要签名的字符为空 + $urls = ''; //初始化URL参数为空 + + foreach ($data AS $key => $val) { //遍历需要传递的参数 + if ($val == ''||$key == 'sign') continue; //跳过这些不参数签名 + if ($sign != '') { //后面追加&拼接URL + $sign .= "&"; + $urls .= "&"; + } + $sign .= "$key=$val"; //拼接为url参数形式 + $urls .= "$key=" . urlencode($val); //拼接为url参数形式并URL编码参数值 + + } + $query = $urls . '&sign=' . md5($sign .$codepay_key); //创建订单所需的参数 + $url = "http://api2.fateqq.com:52888/creat_order/?".$query; //支付页面 + + header("Location:".$url); + } + public function code_check($request, $response, $args) diff --git a/app/Utils/Pay.php b/app/Utils/Pay.php index dc172d4519..6eaa7657bf 100644 --- a/app/Utils/Pay.php +++ b/app/Utils/Pay.php @@ -23,6 +23,8 @@ public static function getHTML($user) return Pay::f2fpay_html($user); case 'yftpay': return Pay::yftpay_html($user); + case 'codepay': + return Pay::codepay_html($user); default: return ""; } @@ -95,6 +97,22 @@ private static function yftpay_html($user) '; } + + private static function codepay_html($user) + { + return ' +

请输入充值金额

+
+ +
+ + + + +
+'; + } + private static function pmw_html($user) { \Paymentwall_Config::getInstance()->set(array( @@ -658,6 +676,116 @@ private static function f2fpay_callback() echo "fail"; //请不要修改或删除 } } + + private static function codepay_callback(){ + //以下五行无需更改 + ksort($_POST); //排序post参数 + reset($_POST); //内部指针指向数组中的第一个元素 + $codepay_key=Config::get('codepay_key'); //这是您的密钥 + $sign = '';//初始化 + foreach ($_POST AS $key => $val) { //遍历POST参数 + if ($val == '' || $key == 'sign') continue; //跳过这些不签名 + if ($sign) $sign .= '&'; //第一个字符串签名不加& 其他加&连接起来参数 + $sign .= "$key=$val"; //拼接为url参数形式 + } + if (!$_POST['pay_no'] || md5($sign . $codepay_key) != $_POST['sign']) { //不合法的数据 + exit('fail'); //返回成功 不要删除哦 + } else { //合法的数据 + //业务处理 + $pay_id = $_POST['pay_id']; //需要充值的ID 或订单号 或用户名 + $money = (float)$_POST['money']; //实际付款金额 + $price = (float)$_POST['price']; //订单的原价 + //$param = $_POST['param']; //自定义参数 + $pay_no = $_POST['pay_no']; //流水号 + $codeq=Code::where("code", "=", $pay_no)->first(); + if ($codeq==null){ + $user=User::find($pay_id); + $codeq=new Code(); + $codeq->code=$pay_no; + $codeq->isused=1; + $codeq->type=-1; + $codeq->number=$price; + $codeq->usedatetime=date("Y-m-d H:i:s"); + $codeq->userid=$user->id; + $codeq->save(); + $user->money=$user->money+$price; + $user->save(); + + //更新返利 + if ($user->ref_by!=""&&$user->ref_by!=0&&$user->ref_by!=null) { + $gift_user=User::where("id", "=", $user->ref_by)->first(); + $gift_user->money=($gift_user->money+($codeq->number*(Config::get('code_payback')/100))); + $gift_user->save(); + + $Payback=new Payback(); + $Payback->total=$total; + $Payback->userid=$user->id; + $Payback->ref_by=$user->ref_by; + $Payback->ref_get=$codeq->number*(Config::get('code_payback')/100); + $Payback->datetime=time(); + $Payback->save(); + } + exit('success'); //返回成功 不要删除哦 + } + } + if ($codeq!=null){ + echo ' + + '; + return; + } + } + + private static function notify(){ + //系统订单号 + $trade_no = $_POST['pay_no']; + //交易用户 + $trade_id = strtok($_POST['pay_id'], "@"); + //金额 + $trade_num = $_POST['price']; + $param = urldecode($_POST['param']); + $codeq=Code::where("code", "=", $trade_no)->first(); + if($codeq!=null){ + exit('success'); //说明数据已经处理完毕 + return; + } + if($param!=Config::get('alipay')||$trade_no==''){ //鉴权失败 + exit('fail'); + return; + } + + //更新用户账户 + $user=User::find($trade_id); + $codeq=new Code(); + $codeq->code=$trade_no; + $codeq->isused=1; + $codeq->type=-1; + $codeq->number=$_POST['price']; + $codeq->usedatetime=date("Y-m-d H:i:s"); + $codeq->userid=$user->id; + $codeq->save(); + $user->money=$user->money+$trade_num; + $user->save(); + //更新返利 + if ($user->ref_by!=""&&$user->ref_by!=0&&$user->ref_by!=null) { + $gift_user=User::where("id", "=", $user->ref_by)->first(); + $gift_user->money=($gift_user->money+($codeq->number*(Config::get('code_payback')/100))); + $gift_user->save(); + + $Payback=new Payback(); + $Payback->total=$trade_num; + $Payback->userid=$user->id; + $Payback->ref_by=$user->ref_by; + $Payback->ref_get=$codeq->number*(Config::get('code_payback')/100); + $Payback->datetime=time(); + $Payback->save(); + } + exit('success'); //返回成功 不要删除哦 + } + public static function callback($request) { $driver = Config::get("payment_system"); @@ -670,6 +798,8 @@ public static function callback($request) return Pay::zfbjk_callback($request); case 'f2fpay': return Pay::f2fpay_callback(); + case 'codepay': + return Pay::codepay_callback(); default: return ""; } diff --git a/config/.config.php.example b/config/.config.php.example index 8faa251c09..ab46f5e15f 100644 --- a/config/.config.php.example +++ b/config/.config.php.example @@ -296,9 +296,14 @@ $System_Config['sendgrid_sender'] = ''; #支付系统 -#取值 doiampay,paymentwall,zfbjk,spay,f2fpay,yftpay,none +#取值 codepay,doiampay,paymentwall,zfbjk,spay,f2fpay,yftpay,none $System_Config['payment_system']='none'; +#codepay码支付 +#wiki地址:https://github.com/NimaQu/ss-panel-v3-mod_UIChanges/wiki/%E7%A0%81%E6%94%AF%E4%BB%98%E5%AF%B9%E6%8E%A5%E6%95%99%E7%A8%8B/ +$System_Config['codepay_id']='';//码支付ID +$System_Config['codepay_key']='';//码支付通信密钥 + #doiampay,https://www.daimiyun.cn/v3/ $System_Config['doiampay']=[ 'enabled' => [ diff --git a/config/routes.php b/config/routes.php index a382e29c1a..50e275f94c 100644 --- a/config/routes.php +++ b/config/routes.php @@ -72,6 +72,7 @@ $app->get('/405', 'App\Controllers\HomeController:page405'); $app->get('/500', 'App\Controllers\HomeController:page500'); $app->get('/pwm_pingback', 'App\Controllers\HomeController:pay_callback'); +$app->post('/notify', 'App\Controllers\HomeController:notify'); $app->post('/alipay_callback', 'App\Controllers\HomeController:pay_callback'); $app->post('/pay_callback', 'App\Controllers\HomeController:pay_callback'); $app->get('/pay_callback', 'App\Controllers\HomeController:pay_callback'); @@ -81,7 +82,8 @@ $app->get('/gfwlistjs', 'App\Controllers\LinkController:GetGfwlistJs'); $app->post('/telegram_callback', 'App\Controllers\HomeController:telegram'); $app->get('/yft/notify','App\Controllers\YFTPayCallBackController:yft_notify'); - +$app->get('/codepay_callback', 'App\Controllers\HomeController:codepay_callback'); +$app->post('/codepay_callback', 'App\Controllers\HomeController:pay_callback'); // User Center @@ -147,6 +149,7 @@ $this->get('/alipay', 'App\Controllers\UserController:alipay'); $this->post('/code/f2fpay', 'App\Controllers\UserController:f2fpay'); $this->get('/code/f2fpay', 'App\Controllers\UserController:f2fpayget'); + $this->get('/code/codepay', 'App\Controllers\UserController:codepay'); $this->get('/code_check', 'App\Controllers\UserController:code_check'); $this->post('/code', 'App\Controllers\UserController:codepost'); $this->post('/gacheck', 'App\Controllers\UserController:GaCheck'); diff --git a/public/images/alipay.jpg b/public/images/alipay.jpg new file mode 100644 index 0000000000..f45a64537e Binary files /dev/null and b/public/images/alipay.jpg differ diff --git a/public/images/qqpay.jpg b/public/images/qqpay.jpg new file mode 100644 index 0000000000..ec8330dc06 Binary files /dev/null and b/public/images/qqpay.jpg differ diff --git a/public/images/weixin.jpg b/public/images/weixin.jpg new file mode 100644 index 0000000000..e31f803079 Binary files /dev/null and b/public/images/weixin.jpg differ