From a9815ee7ab7d12ff1958dc7d7bf418e1b5f26d1b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 9 Nov 2020 14:13:18 +0800 Subject: [PATCH] 1 --- webapp/classes/OrderCtrl.php | 52 ++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/webapp/classes/OrderCtrl.php b/webapp/classes/OrderCtrl.php index 6b7add1..1a197bf 100644 --- a/webapp/classes/OrderCtrl.php +++ b/webapp/classes/OrderCtrl.php @@ -206,7 +206,7 @@ class OrderCtrl { ) ); $data = array(); - foreach ($rows as $row ) { + foreach ($rows as $row) { array_push($data, array( 'cp_orderid' => $row['orderid'], 'sp_orderid' => $row['sp_orderid'], @@ -221,16 +221,64 @@ class OrderCtrl { )); } + public function getInternetGamesConf($gameid) + { + $json_str = $json_string = file_get_contents('../config/internet_games.json'); + $jsonobj = json_decode($json_str, true); + foreach ($jsonobj as $conf) { + if ($conf['gameid'] == $gameid) { + return $conf; + } + } + return null; + } + public function deliver($account_id, $cp_orderid) { $conn = $this->getMysql($this->getStrDNA($account_id)); - $row = $conn->execQueryOne('SELECT orderid, sp_orderid, itemid, status FROM orderinfo ' . + $row = $conn->execQueryOne('SELECT orderid, sp_orderid, itemid, status, sp_pay_result ' . + 'FROM orderinfo ' . 'WHERE account_id=:account_id AND orderid=:orderid;', array( ':account_id' => $account_id, ':orderid' => $cp_orderid ) ); + if (empty($row)) { + phpcommon\sendError(3, '不支持发货功能'); + return; + } + $gameid = phpcommon\extractGameId($receipt_info['account_id']); + $game_conf = $this->getInternetGamesConf($gameid); + if ($game_conf) { + phpcommon\sendError(3, '不支持发货功能'); + return; + } + if ($row['status'] == 1) { + phpcommon\sendError(1, '已经发货不能重复发货'); + return; + } + if ($row['sp_pay_result'] != 1) { + phpcommon\sendError(2, '平台未确认'); + return; + } + $ret = $conn->execScript('UPDATE orderinfo SET ' . + ' status=1, ' . + ' confirmtime=:confirmtime ' . + 'WHERE orderid=:orderid;', + array( + ':confirmtime' => time(), + ':orderid' => $cp_orderid + )); + if (!$ret) { + phpcommon\sendError(100, '服务器内部错误'); + return; + } + echo json_encode(array( + 'errcode' => 0, + 'errmsg' => '', + 'itemid' => $row['itemid'] + )); } }