This commit is contained in:
aozhiwei 2020-10-19 19:55:39 +08:00
parent 6cb9a7ec6d
commit 997ca9606c
3 changed files with 51 additions and 4 deletions

View File

@ -35,6 +35,9 @@ class PayController {
} else { } else {
$channel = $_REQUEST['_channel']; $channel = $_REQUEST['_channel'];
} }
if (!empty($_REQUEST['_unified_channel'])) {
$channel = $_REQUEST['_unified_channel'];
}
$sdk = sdkwarpper\createSdkByChannel($channel); $sdk = sdkwarpper\createSdkByChannel($channel);
if (!$sdk) { if (!$sdk) {
echo 'is null'; echo 'is null';
@ -46,6 +49,14 @@ class PayController {
public function queryOrderInfo() public function queryOrderInfo()
{ {
$channel = phpcommon\extractChannel($_REQUEST['account_id']);
$sdk = sdkwarpper\createSdkByChannel($channel);
if (!$sdk) {
echo 'is null';
} else {
$sdk->setChannel($channel);
$sdk->queryOrderInfo();
}
} }
} }

View File

@ -11,6 +11,8 @@ class BaseSdk
{ {
protected $real_channel = '0'; protected $real_channel = '0';
protected $channel = '0'; protected $channel = '0';
protected $unified_channel = '0';
protected $poly_sdk_channel = '0';
protected $gameid = 0; protected $gameid = 0;
protected $order_ctrl = null; protected $order_ctrl = null;

View File

@ -12,6 +12,7 @@ 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 = '';
@ -30,15 +31,31 @@ 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\extractGameId($_REQUEST['account_id']); $this->real_channel = phpcommon\extractChannelId($_REQUEST['account_id']);
$this->loadConfig(); $this->loadConfig();
$cp_orderid = $this->order_ctrl->genOrderId();
{
$this->order_ctrl->addPreOrder(
array(
'orderid' => $cp_orderid,
'account_id' => $_REQUEST['account_id'],
'roleid' => '',
'server_id' => 0,
'poly_sdk_channel' => $this->poly_sdk_channel,
'unified_channel' => $this->unified_channel,
'itemid' => $itemid,
'ipv4' => phpcommon\getIPv4(),
)
);
}
$params = array( $params = array(
'appid' => $this->conf_appid, 'appid' => $this->conf_appid,
'mch_id' => $this->conf_mch_id, 'mch_id' => $this->conf_mch_id,
'nonce_str' => uniqid('201019'), 'nonce_str' => md5($cp_orderid . time()),
'body' => '测试产品', 'body' => '测试产品',
'out_trade_no' => uniqid('201019'), 'out_trade_no' => $cp_orderid,
'total_fee' => '101', 'total_fee' => '101',
'spbill_create_ip' => phpcommon\getIPv4(), 'spbill_create_ip' => phpcommon\getIPv4(),
'notify_url' => 'https://gamepay.kingsome.cn/webapp/paynotify/unified_weixin.php', 'notify_url' => 'https://gamepay.kingsome.cn/webapp/paynotify/unified_weixin.php',
@ -60,9 +77,26 @@ class UnifiedWeiXin extends BaseSdk {
phpcommon\objectToXml($params), phpcommon\objectToXml($params),
$response $response
)) { )) {
phpcommon\sendError(1, '服务器内部错误');
return;
} }
echo $response; echo $response;
$xml = new \SimpleXMLElement($response);
if ($xml->return_code != 'SUCCESS') {
phpcommon\sendError(2, $xml->return_msg);
return;
}
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'cp_orderid' => $cp_orderid,
'prepayid' => $xml->prepay_id
));
}
public function payNotify()
{
} }
} }