From 2a02b6595266e029f7662dc2fb0a513de8157c40 Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期三, 04 六月 2025 16:04:24 +0800 Subject: [PATCH] 1111 【后台】 btmdb2 充值回调 --- InterfaceConfig.php | 3 api/quick/paybtmdb2.php | 199 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 202 insertions(+), 0 deletions(-) diff --git a/InterfaceConfig.php b/InterfaceConfig.php index eb72f9d..44d8bc4 100644 --- a/InterfaceConfig.php +++ b/InterfaceConfig.php @@ -137,6 +137,9 @@ Key_btmdb_Md5_Key=raytitr7xjpld7hstukedccekuhq4pgv Key_btmdb_Callback_Key=78010593308784252768778951840518 +Key_btmdb2_Md5_Key=raytitr7xjpld7hstukedccekuhq4pgv +Key_btmdb2_Callback_Key=78010593308784252768778951840518 + Key_tqxbqy_Md5_Key=raytitr7xjpld7hstukedccekuhq4pgv Key_tqxbqy_Callback_Key=78010593308784252768778951840518 diff --git a/api/quick/paybtmdb2.php b/api/quick/paybtmdb2.php new file mode 100644 index 0000000..aa926fe --- /dev/null +++ b/api/quick/paybtmdb2.php @@ -0,0 +1,199 @@ +<?php +include_once '/Common/CommFunc.php'; +include_once '/Common/XMLParse.php'; +include_once '/Common/Logging.php'; +include_once '/Common/PayOrder.php'; +include_once "/ProjComm/CfgReader.php"; +include_once "quicksdkAsy.php"; + +header("Content-type: text/html; charset=utf-8"); +// https://www.quicksdk.com/doc-15.html +// https://sdkconsole.happilygame.com/docs/index/aid/3#catlog7 + +// [nt_data] => @111@113@170@157@159@80@170@154@171@168@158@160@162@116@85@97@97@99@87@87@158@160@154@166@149@154@166@156@109@83@133@136@121@95@106@82@83@163@168@150@167@153@150@157@163@165@152@109@85@161@164@89@120@112@115@168@166@154@155@160@163@149@155@147@160@151@165@163@148@151@153@115@117@162@154@164@167@152@154@149@113@111@158@170@152@166@156@170@165@111@104@113@95@154@163@147@167@151@165@164@113@108@151@157@154@163@163@150@160@117@106@97@99@111@100@154@161@147@165@165@150@157@118@113@147@153@145@162@161@151@158@143@161@145@161@154@119@113@100@148@156@152@161@158@152@159@148@165@154@159@156@117@109@148@160@150@158@159@149@160@146@167@155@148@113@101@102@103@108@103@109@100@102@115@98@147@155@148@163@165@158@158@150@172@154@149@118@113@147@153@145@162@161@151@158@143@162@162@152@154@171@115@102@103@105@111@101@98@99@102@103@108@105@105@105@106@106@101@106@105@105@97@96@100@100@110@97@147@155@145@162@163@158@161@148@160@166@155@152@162@113@111@156@152@166@151@150@166@163@149@157@167@110@99@96@102@101@98@105@97@108@97@106@105@110@103@102@104@104@103@101@102@105@111@100@158@154@159@156@150@160@163@156@154@162@111@108@163@165@150@151@162@146@158@163@115@112@102@101@99@100@105@101@96@106@100@110@104@111@102@108@105@98@103@108@103@101@97@103@108@100@101@110@95@162@162@152@154@171@148@163@160@114@115@163@145@172@146@169@160@166@151@117@105@97@99@106@98@96@104@93@101@108@82@99@102@109@100@105@111@107@106@113@96@164@152@172@143@167@156@162@156@119@110@152@164@160@166@166@169@110@98@98@98@99@98@110@95@148@157@163@170@167@169@115@109@167@171@148@164@168@166@115@103@117@97@170@171@146@165@173@168@110@109@149@172@167@164@147@163@146@160@149@167@154@162@168@111@89@110@117@85@101@101@150@167@169@155@155@92@99@99@93@104@113@86@98@102@164@157@148@164@104@98@89@103@107@90@103@116@89@105@101@147@163@156@163@157@168@87@105@105@86@100@121@90@98@99@147@171@97@166@163@156@97@170@159@102@94@103@103@86@102@122@88@98@101@150@165@166@171@150@156@169@154@149@93@103@98@86@99@117@88@100@100@98@99@98@102@101@112@102@110@98@106@107@104@98@100@106@105@103@107@104@109@92@99@99@93@103@115@86@98@102@166@151@164@166@152@162@157@153@94@103@103@86@103@120@88@98@101@101@90@105@107@87@105@122@86@99@106@152@152@146@158@162@152@158@123@116@88@98@102@90@108@118@90@99@102@110@100@97@88@101@103@92@112@118@115@102@150@169@172@167@145@164@143@164@148@164@147@157@166@110@112@100@166@154@168@164@149@158@152@110@111@98@166@172@162@149@162@170@149@156@151@162@149@164@163@149@154@151@112 +// [sign] => @149@147@101@101@106@145@100@102@154@110@106@146@103@109@105@104@100@104@150@112@159@105@106@107@102@150@153@107@148@100@105@105 +// [md5Sign] => 254d1d0e0640ea03f7dc06b0879fb03c + +// $_SERVER['PHP_SELF'] = /api/quick/payxxxxx.php +// strripos 鏈�鍚庝竴娆″嚭鐜� / 鐨勪綅缃紝鍐�+1寰楀埌 payxxxxx.php +// +3 浠巔ay鍚庨潰寮�濮� +// -4 鍘婚櫎鏈�鍚庣殑.php +$appid = substr($_SERVER['PHP_SELF'], strripos($_SERVER['PHP_SELF'], "/") + 1 + 3, -4); +\Logging\CreateLogging("quick.pay" . $appid . ".php", false, \Log4Me\WRITE_MODE_PERHOUR); +\Logging\LogInfo("CONTENT_TYPE: " . $_SERVER["CONTENT_TYPE"]); +if ($_SERVER["CONTENT_TYPE"] == "application/xml") { + //鎺ユ敹浼犻�佺殑鏁版嵁 + $postInput = file_get_contents("php://input"); + \Logging\LogInfo("postInput: " . $postInput); + $postData = array(); + $postInput = new XMLParse($postInput); + if ($postInput->IsSuccess()) { + $postData['nt_data'] = $postInput->GetValue('nt_data'); + $postData['sign'] = $postInput->GetValue('sign'); + $postData['md5Sign'] = $postInput->GetValue('md5Sign'); + $postData['extras_params'] = $postInput->GetValue('extras_params'); + } +} else { + $postData = $_POST; +} +\Logging\LogInfo("postData: " . print_r($postData, true)); + +$nt_data = $postData['nt_data']; +$sign = $postData['sign']; +$md5Sign = $postData['md5Sign']; +if (!$nt_data || !$sign || !$md5Sign) { + Ret("ParamError"); + exit; +} + +if ( + !\CfgReader\ReadConfig() + || !\CfgReader\GetConfigData("Quick", "Key_" . $appid . "_Md5_Key", $Md5_Key) + || !\CfgReader\GetConfigData("Quick", "Key_" . $appid . "_Callback_Key", $Callback_Key) +) { + Ret("CfgError"); + exit; +} + +$md5SignLocal = quickAsy::getSign($postData, $Md5_Key); +if ($md5SignLocal != $md5Sign) { + Ret("SignError", " md5SignLocal:" . $md5SignLocal . " != md5Sign:" . $md5Sign); + exit; +} + +$xmlStr = quickAsy::decode($postData["nt_data"], $Callback_Key); +$xmlData = new XMLParse($xmlStr); +if (!$xmlData->IsSuccess()) { + Ret("xml_parser_error"); + exit; +} +\Logging\LogInfo("xmlStr:" . $xmlStr); +\Logging\LogInfo("xmlVals:" . print_r($xmlData->GetValues(), true)); +// <!--?xml version="1.0" encoding="UTF-8" standalone="no"?--> +// <quicksdk_message> +// <message> +// <is_test>0</is_test> +// <channel>8888</channel> +// <channel_uid>231845</channel_uid> +// <game_order>123456789</game_order> +// <order_no>12520160612114220441168433</order_no> +// <pay_time>2016-06-12 11:42:20</pay_time> +// <amount>1.00</amount> +// <status>0</status> +// <extras_params>{1}_{2}</extras_params> +// </message> +// </quicksdk_message> +$is_test = intval($xmlData->GetValue("is_test")); //鏄惁涓烘祴璇曡鍗� 1涓烘祴璇� 0涓虹嚎涓婃寮忚鍗曪紝娓告垙搴旀牴鎹儏鍐电‘瀹氫笂绾垮悗鏄惁鍚戞祴璇曡鍗曞彂鏀鹃亾鍏枫�� +$channel = $xmlData->GetValue("channel"); //娓犻亾鏍囩ずID 娉ㄦ剰:娓告垙鍙牴鎹疄鎯�,纭畾鍙戞斁閬撳叿鏃舵槸鍚︽牎楠屽厖鍊兼潵婧愭笭閬撴槸鍚︿笌璇ヨ鑹叉敞鍐屾笭閬撶浉绗� +$channel_uid = $xmlData->GetValue("channel_uid"); //娓犻亾鐢ㄦ埛鍞竴鏍囩ず,璇ュ�间粠瀹㈡埛绔疓etUserId()涓彲鑾峰彇 +$game_order = $xmlData->GetValue("game_order"); //娓告垙鍦ㄨ皟鐢≦uickSDK鍙戣捣鏀粯鏃朵紶閫掔殑娓告垙鏂硅鍗�,杩欓噷浼氬師鏍蜂紶鍥� +$order_no = $xmlData->GetValue("order_no"); //QuickSDK鍞竴璁㈠崟鍙� +$pay_time = $xmlData->GetValue("pay_time"); //鏀粯鏃堕棿 2015-01-01 23:00:00 +$amount = floatval($xmlData->GetValue("amount")); //鎴愪氦閲戦锛屽崟浣嶅厓锛屾父鎴忔渶缁堝彂鏀鹃亾鍏烽噾棰濆簲浠ユ涓哄噯 +$status = intval($xmlData->GetValue("status")); //鍏呭�肩姸鎬�:0鎴愬姛, 1澶辫触(涓�1鏃� 搴旇繑鍥濬AILED澶辫触) +$extras_params = $xmlData->GetValue("extras_params"); //鍙负绌�,鍏呭�肩姸鎬佹父鎴忓鎴风璋冪敤SDK鍙戣捣鏀粯鏃跺~鍐欑殑閫忎紶鍙傛暟.娌℃湁鍒欎负绌� +$extras_params = json_decode(urldecode($extras_params), true); +\Logging\LogInfo("extras_params:" . print_r($extras_params, true)); +//=======================灞卞娴嬭瘯鏁版嵁========================== +// [is_test] => 1 +// [channel] => 0 +// [channel_uid] => e10adc3949ba59abbe56e057f20f883e@_() +// [game_order] => 20220704175336672306 +// [order_no] => 00020220704175339692561983 +// [pay_time] => 2022-07-04 17:53:39 +// [amount] => 1.00 +// [status] => 0 +// [extras_params] => %7B%22appid%22%3A%22qkbt52%22%2C%22cpinfo%22%3A%22cw.czk.1%22%2C%22cporderid%22%3A%2220220704175336672306%22%2C%22serverid%22%3A%229999%22%7D +// extras_params +// [appid] => qkbt52 +// [cpinfo] => cw.czk.1 +// [cporderid] => 20220704175336672306 +// [serverid] => 9999 +// [channelID] => 123 娉ㄦ剰鍖哄埆浜� channel锛屼笉鍚� channel 鍙兘瀵瑰簲鐩稿悓 channelID 锛岃处鍙风殑鍞竴鎬х敱 channelID 鍐冲畾 + +// $is_test = 1; +// $status = 0; +// $channel_uid = "bt9123"; +// $channel = 0; +// $extras_params["appid"] = $appid; +// $extras_params["cpinfo"] = "test_cz_6"; +// $extras_params["serverid"] = "87"; +//============================================================ +if ($status == 1) { + Ret("FAILED"); + exit; +} +// extras_params +// extraData.put("appid", GameAppProxy.appId); +// extraData.put("serverid", GameAppProxy.serverId); +// extraData.put("cpinfo", json.getString("cpInfo")); //鍟嗗搧缂栧彿 +// extraData.put("cporderid", json.getString("orderId")); //鍐呴儴璁㈠崟缂栧彿 +if ( + !isset($extras_params) || !array_key_exists("appid", $extras_params) + || !array_key_exists("serverid", $extras_params) || !array_key_exists("cpinfo", $extras_params) +) { + Ret("extras_params_error", " extras_params:" . print_r($extras_params, true)); + exit; +} + +if ($is_test == 1) { + CfgReader\GetConfigData("Quick", "TestAllow", $TestAllow); + if (intval($TestAllow) != 1) { + Ret("Test orders are not allowed"); + exit; + } +} + +// 鍚屾娓告垙鏈嶅姟鍣� +$serverID = intval($extras_params["serverid"]); +$channelID = array_key_exists("channelID", $extras_params) ? $extras_params["channelID"] : $channel; +if ($appid != $extras_params["appid"]) { + Ret("extras_params appid error", "extras_params appid:" . $extras_params["appid"] . " != " . $appid); + exit; +} + +$AccountID = $channel_uid . "@" . $channelID; +$OrderInfo = $extras_params["cpinfo"]; + +// $multiple = array_key_exists("multiple", $extras_params) ? intval($extras_params["multiple"]) : 1; +// $cporderids = explode("_", $extras_params["cporderid"]); // cporderid_multiple 鎵╁睍鏀寔 +// if (count($cporderids) > 1) { +// $multiple = intval($cporderids[1]); +// \Logging\LogInfo("split cporderid multiple:" . $multiple); +// } else { +// \Logging\LogInfo("extras_params multiple:" . $multiple); +// } +// $extras = json_encode(array("multiple" => $multiple)); + +$result = "FAILED"; +// 娌℃湁鍒涘缓璁㈠崟姝ラ锛岀洿鎺ヤ娇鐢╯dk璁㈠崟鍙� +$returnArr = \PayOrder\DoReceivePayOrder($appid, $order_no, $order_no, $AccountID, $serverID, $OrderInfo, $amount, $pay_time, false); +switch ($returnArr["errorcode"]) { + case 1: + $result = "SUCCESS"; + break; + case 2: + $result = "SUCCESS"; + break; + default: + if ($returnArr["errordesc"]) { + $result = $returnArr["errordesc"]; + } + break; +} +Ret($result); +exit; + +function Ret($ret, $msg = "") +{ + echo $ret; + $logMsg = $ret; + if ($msg) { + $logMsg .= " msg => " . $msg; + } + if ($ret != "SUCCESS") { + \Logging\LogError($logMsg); + } else { + \Logging\LogInfo($logMsg); + } +} -- Gitblit v1.8.0