diff --git a/.project b/.project
new file mode 100644
index 0000000000..08dada5ea5
--- /dev/null
+++ b/.project
@@ -0,0 +1,28 @@
+
+
请输入充值金额
+ +'; + } + 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