From 82b7b279030c62c21b4d8fb4a8d69bc13c486e04 Mon Sep 17 00:00:00 2001 From: yangduo Date: Sat, 21 Jun 2025 21:17:41 +0800 Subject: [PATCH] hwpay --- .../controller/RechargeController.class.php | 104 +++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-) diff --git a/webapp/controller/RechargeController.class.php b/webapp/controller/RechargeController.class.php index 75bc780..6dfc439 100644 --- a/webapp/controller/RechargeController.class.php +++ b/webapp/controller/RechargeController.class.php @@ -257,6 +257,108 @@ class RechargeController )); } + public function hwprePay() + { + $this->prePay(); + } + + public function hwpayDone() + { + $this->purchaseDone(); + } + + protected function hwpayDoneQuery() + { + $account_id = $_REQUEST['account_id']; + //登录校验 + $login = loginVerify($account_id, $_REQUEST['session_id']); + if (!$login) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); + return; + } + + $goodsid = $_REQUEST['goods_id']; + $orderid = $_REQUEST['order_id']; + $purchasetoken = $_REQUEST['token']; + + if ($orderid == '') { + die(); + } + + $key = 'game2004api-purchase:' . $account_id . '-' . $orderid; + $r = $this->getRedis($key); + if (!$r) { + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'order_id' => $orderid, + 'status' => 0, + )); + return; + } + + $user_purchase_str = $r->get($key); + if (!empty($user_purchase_str)) { + echo $user_purchase_str; + return; + } + + $conn = $this->getMysql($account_id); + if (!$conn) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + return; + } + + $orderRow = $conn->execQueryOne( + 'SELECT * FROM orderinfo WHERE orderid=:orderid', + array( + ':orderid' => $orderid + ) + ); + + if ($orderRow) { + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'order_id' => $orderid, + 'status' => 1, + )); + die(); + } else { + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'order_id' => $orderid, + 'status' => 0, + )); + } + + $url = ''; + if (SERVER_ENV == _ONLINE) { + $url = 'https://payservice.kingsome.cn/api/ingame/hwpaid'; + } else { + $url = 'https://payservice-test.kingsome.cn/api/ingame/hwpaid'; + } + $sign = md5($account_id . $goodsid . 'f3a6a9a5-217a-4079-ab99-b5d69b8212be' . $_REQUEST['session_id'] . $orderid . $purchasetoken); + $params = array( + 'account_id' => $account_id, + 'goods_id' => $goodsid, + 'session_id' => $_REQUEST['session_id'], + 'order_id' => $orderid, + 'token' => $purchasetoken, + 'user_ip' => phpcommon\getIPv4(), + 'sign' => $sign + ); + + if (!phpcommon\HttpClient::get($url, $params, $rsp)) { + return; + } + + if (is_null($rsp) || empty($rsp)) { + return; + } + } + public function preparePay() { $this->prePay(); @@ -313,7 +415,7 @@ class RechargeController return; } - $response = json_decode($rsp, true); + $response = json_decode($rsp, true); echo json_encode(array( 'errcode' => $response['errcode'], 'errmsg' => $response['errmsg'],