pay/webapp/controller/PayController.class.php
aozhiwei dc7029a2dc 1
2020-11-10 11:27:38 +08:00

96 lines
3.0 KiB
PHP

<?php
class PayController {
public function preOrder()
{
error_log(json_encode($_REQUEST));
/*
if (!phpcommon\isValidSessionId($_REQUEST['account_id'], $_REQUEST['session_id'])) {
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
return;
}*/
$channel = phpcommon\extractChannel($_REQUEST['account_id']);
if (!empty($_REQUEST['poly_sdk_channel'])) {
$channel = $_REQUEST['poly_sdk_channel'];
}
if (!empty($_REQUEST['unified_channel'])) {
$channel = $_REQUEST['unified_channel'];
}
$sdk = sdkwarpper\createSdkByChannel($channel);
if (!$sdk) {
echo 'is null';
} else {
$sdk->setChannel($channel);
$sdk->preOrder();
}
}
public function payNotify()
{
error_log(json_encode($_REQUEST));
$channel = '';
if (isset($_REQUEST['_poly_sdk_channel'])) {
$channel = $_REQUEST['_poly_sdk_channel'];
} else {
$channel = $_REQUEST['_channel'];
}
if (!empty($_REQUEST['_unified_channel'])) {
$channel = $_REQUEST['_unified_channel'];
}
$sdk = sdkwarpper\createSdkByChannel($channel);
if (!$sdk) {
echo 'is null';
} else {
$sdk->setChannel($channel);
$sdk->payNotify();
}
}
public function getPendingOrderList()
{
if (!phpcommon\isValidSessionId($_REQUEST['account_id'], $_REQUEST['session_id'])) {
phpcommon\sendError(1, 'session无效');
return;
}
require 'classes/OrderCtrl.php';
$order_ctrl = new classes\OrderCtrl();
$order_ctrl->getPendingOrderList($_REQUEST['account_id']);
}
public function deliver()
{
if (!phpcommon\isValidSessionId($_REQUEST['account_id'], $_REQUEST['session_id'])) {
phpcommon\sendError(1, 'session无效');
return;
}
require 'classes/OrderCtrl.php';
$order_ctrl = new classes\OrderCtrl();
$order_ctrl->deliver($_REQUEST['account_id'], $_REQUEST['cp_orderid']);
}
public function queryOrderInfo()
{
if (!phpcommon\isValidSessionId($_REQUEST['account_id'], $_REQUEST['session_id'])) {
phpcommon\sendError(1, 'session无效');
return;
}
require 'classes/OrderCtrl.php';
$order_ctrl = new classes\OrderCtrl();
$order_info = $order_ctrl->getOrder($_REQUEST['cp_orderid']);
if (!$order_info || $order_info['account_id'] != $_REQUEST['account_id']) {
phpcommon\sendError(1, '订单不存在');
return;
}
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'cp_orderid' => $order_info['orderid'],
'sp_orderid' => $order_info['sp_orderid'],
'status' => $order_info['status'],
'itemid' => $order_info['itemid'],
));
}
}