1
This commit is contained in:
parent
a12be7649a
commit
b5c0c9dd6b
@ -53,13 +53,13 @@ class OrderCtrl {
|
|||||||
return uniqid('201020') . $hex_str;
|
return uniqid('201020') . $hex_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOrderByCpOrderId($cp_orderid)
|
public function getOrder($cp_orderid)
|
||||||
{
|
{
|
||||||
$conn = $this->getMysql($this->getCpOrderIdDNA($cp_orderid));
|
$conn = $this->getMysql($this->getCpOrderIdDNA($cp_orderid));
|
||||||
$row = $conn->execQueryOne('SELECT * FROM orderinfo ' .
|
$row = $conn->execQueryOne('SELECT * FROM orderinfo ' .
|
||||||
'WHERE orderid=:orderid;',
|
'WHERE orderid=:orderid;',
|
||||||
array(
|
array(
|
||||||
':orderid' => $orderid
|
':orderid' => $cp_orderid
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return $row;
|
return $row;
|
||||||
@ -78,6 +78,7 @@ class OrderCtrl {
|
|||||||
{
|
{
|
||||||
$gameid = phpcommon\extractGameId($order_info['account_id']);
|
$gameid = phpcommon\extractGameId($order_info['account_id']);
|
||||||
$openid = phpcommon\extractOpenId($order_info['account_id']);
|
$openid = phpcommon\extractOpenId($order_info['account_id']);
|
||||||
|
$channel = phpcommon\extractChannel($order_info['account_id']);
|
||||||
$conn = $this->getMysql($this->getStrDNA($order_info['account_id']));
|
$conn = $this->getMysql($this->getStrDNA($order_info['account_id']));
|
||||||
$ret = $conn->execScript('INSERT INTO orderinfo(' .
|
$ret = $conn->execScript('INSERT INTO orderinfo(' .
|
||||||
' orderid, account_id, roleid, server_id, channel, ' .
|
' orderid, account_id, roleid, server_id, channel, ' .
|
||||||
@ -97,7 +98,7 @@ class OrderCtrl {
|
|||||||
':account_id' => $order_info['account_id'],
|
':account_id' => $order_info['account_id'],
|
||||||
':roleid' => $order_info['roleid'],
|
':roleid' => $order_info['roleid'],
|
||||||
':server_id' => $order_info['server_id'],
|
':server_id' => $order_info['server_id'],
|
||||||
':channel' => $order_info['channel'],
|
':channel' => $channel,
|
||||||
':poly_sdk_channel' => $order_info['poly_sdk_channel'],
|
':poly_sdk_channel' => $order_info['poly_sdk_channel'],
|
||||||
':unified_channel' => $order_info['unified_channel'],
|
':unified_channel' => $order_info['unified_channel'],
|
||||||
':gameid' => $gameid,
|
':gameid' => $gameid,
|
||||||
|
@ -49,14 +49,19 @@ class PayController {
|
|||||||
|
|
||||||
public function queryOrderInfo()
|
public function queryOrderInfo()
|
||||||
{
|
{
|
||||||
$channel = phpcommon\extractChannel($_REQUEST['account_id']);
|
require 'classes/OrderCtrl.php';
|
||||||
$sdk = sdkwarpper\createSdkByChannel($channel);
|
$order_ctrl = new classes\OrderCtrl();
|
||||||
if (!$sdk) {
|
$order_info = $order_ctrl->getOrder($_REQUEST['cp_orderid']);
|
||||||
echo 'is null';
|
if (!$order_info || $order_info['account_id'] != $_REQUEST['account_id']) {
|
||||||
} else {
|
phpcommon\sendError(1, '订单不存在');
|
||||||
$sdk->setChannel($channel);
|
return;
|
||||||
$sdk->queryOrderInfo();
|
|
||||||
}
|
}
|
||||||
|
echo json_encode(array(
|
||||||
|
'errcode' => 0,
|
||||||
|
'errmsg' => '',
|
||||||
|
'cp_orderid' => $order_info['orderid'],
|
||||||
|
'status' => $order_info['status'],
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ class BaseSdk
|
|||||||
error_log('basesdk new');
|
error_log('basesdk new');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setChannel($channel)
|
public function setChannel($channel)
|
||||||
{
|
{
|
||||||
$this->channel = $channel;
|
$this->channel = $channel;
|
||||||
}
|
}
|
||||||
@ -39,9 +39,10 @@ class BaseSdk
|
|||||||
|
|
||||||
public function queryOrderInfo()
|
public function queryOrderInfo()
|
||||||
{
|
{
|
||||||
$order_info = $this->order_ctrl->getOrderByCpOrderId($_REQUEST['cp_orderid']);
|
$order_info = $this->order_ctrl->getOrder($_REQUEST['cp_orderid']);
|
||||||
if (!$order_info) {
|
if (!$order_info) {
|
||||||
phpcommon\sendError(1, '订单不存在');
|
phpcommon\sendError(1, '订单不存在');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
'errcode' => 0,
|
'errcode' => 0,
|
||||||
|
@ -12,12 +12,17 @@ class UnifiedWeiXin extends BaseSdk {
|
|||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->unified_channel = $this->channel;
|
|
||||||
$this->conf_appid = '';
|
$this->conf_appid = '';
|
||||||
$this->conf_mch_id = '';
|
$this->conf_mch_id = '';
|
||||||
$this->conf_pay_secret_key = '';
|
$this->conf_pay_secret_key = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setChannel($channel)
|
||||||
|
{
|
||||||
|
parent::setChannel($channel);
|
||||||
|
$this->unified_channel = $this->channel;
|
||||||
|
}
|
||||||
|
|
||||||
private function loadConfig()
|
private function loadConfig()
|
||||||
{
|
{
|
||||||
$config_name = "../config/game{$this->gameid}/{$this->channel}/config.php";
|
$config_name = "../config/game{$this->gameid}/{$this->channel}/config.php";
|
||||||
@ -31,7 +36,7 @@ class UnifiedWeiXin extends BaseSdk {
|
|||||||
public function preOrder()
|
public function preOrder()
|
||||||
{
|
{
|
||||||
$this->gameid = phpcommon\extractGameId($_REQUEST['account_id']);
|
$this->gameid = phpcommon\extractGameId($_REQUEST['account_id']);
|
||||||
$this->real_channel = phpcommon\extractChannelId($_REQUEST['account_id']);
|
$this->real_channel = phpcommon\extractChannel($_REQUEST['account_id']);
|
||||||
$this->loadConfig();
|
$this->loadConfig();
|
||||||
|
|
||||||
$cp_orderid = $this->order_ctrl->genOrderId($_REQUEST['account_id']);
|
$cp_orderid = $this->order_ctrl->genOrderId($_REQUEST['account_id']);
|
||||||
@ -42,10 +47,10 @@ class UnifiedWeiXin extends BaseSdk {
|
|||||||
'account_id' => $_REQUEST['account_id'],
|
'account_id' => $_REQUEST['account_id'],
|
||||||
'roleid' => '',
|
'roleid' => '',
|
||||||
'server_id' => 0,
|
'server_id' => 0,
|
||||||
|
'itemid' => 1,
|
||||||
'price' => 101,
|
'price' => 101,
|
||||||
'poly_sdk_channel' => $this->poly_sdk_channel,
|
'poly_sdk_channel' => $this->poly_sdk_channel,
|
||||||
'unified_channel' => $this->unified_channel,
|
'unified_channel' => $this->unified_channel,
|
||||||
'itemid' => $itemid,
|
|
||||||
'ipv4' => phpcommon\getIPv4(),
|
'ipv4' => phpcommon\getIPv4(),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -73,7 +78,7 @@ class UnifiedWeiXin extends BaseSdk {
|
|||||||
error_log(json_encode($params));
|
error_log(json_encode($params));
|
||||||
error_log(phpcommon\objectToXml($params));
|
error_log(phpcommon\objectToXml($params));
|
||||||
$response = '';
|
$response = '';
|
||||||
if (phpcommon\HttpClient::postContent(
|
if (!phpcommon\HttpClient::postContent(
|
||||||
'https://api.mch.weixin.qq.com/pay/unifiedorder',
|
'https://api.mch.weixin.qq.com/pay/unifiedorder',
|
||||||
phpcommon\objectToXml($params),
|
phpcommon\objectToXml($params),
|
||||||
$response
|
$response
|
||||||
|
Loading…
x
Reference in New Issue
Block a user