1
This commit is contained in:
parent
46dbe88ed9
commit
c8aaa5d878
@ -178,4 +178,24 @@ class BaseController {
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function _addLogEx($accountId, $type, $subtype, $params)
|
||||
{
|
||||
$fieldsKv = array(
|
||||
'account_id' => $accountId,
|
||||
'type' => $type,
|
||||
'subtype' => $subtype,
|
||||
'param1' => getXVal($params, 'param1', ''),
|
||||
'param2' => getXVal($params, 'param2', ''),
|
||||
'param3' => getXVal($params, 'param3', ''),
|
||||
'param4' => getXVal($params, 'param4', ''),
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
SqlHelper::insert(
|
||||
myself()->_getMysql($accountId),
|
||||
't_game_log',
|
||||
$fieldsKv
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,10 @@ namespace services;
|
||||
|
||||
require_once("mt/ShopGoods.php");
|
||||
require_once("mt/Item.php");
|
||||
|
||||
require_once("models/ShopBuyRecord.php");
|
||||
require_once("models/InAppOrder.php");
|
||||
|
||||
require_once("services/LogService.php");
|
||||
require_once("ShopAddItemService.php");
|
||||
|
||||
@ -12,7 +15,9 @@ use phpcommon\SqlHelper;
|
||||
|
||||
use mt\ShopGoods;
|
||||
use mt\Item;
|
||||
|
||||
use models\ShopBuyRecord;
|
||||
use models\InAppOrder;
|
||||
|
||||
use services\LogService;
|
||||
|
||||
@ -37,7 +42,7 @@ class InAppPurchase {
|
||||
|
||||
public function process()
|
||||
{
|
||||
error_log('ShopInappPurchaseDiamonds:' . json_encode($_REQUEST));
|
||||
error_log('InappPurchase:' . json_encode($_REQUEST));
|
||||
error_log('----- inappPurchaseDiamonds -----');
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
@ -53,13 +58,44 @@ class InAppPurchase {
|
||||
|
||||
$records = $data['records'];
|
||||
for ($i = 0; $i < count($records); $i++) {
|
||||
$record = $records[$i];
|
||||
$this->processOneOrder($records[i]);
|
||||
}
|
||||
|
||||
$product_id = $record['productId'];
|
||||
$order_id = $record['gameOrderId'];
|
||||
$out_order_id = $record['orderId'];
|
||||
$this->_rspOk();
|
||||
}
|
||||
|
||||
private function verifySign($data)
|
||||
{
|
||||
$channel = $data['channel'];
|
||||
$records = $data['records'];
|
||||
$sign = $data['sign'];
|
||||
|
||||
$strings = array();
|
||||
foreach ($records as $record) {
|
||||
ksort($record);
|
||||
foreach($record as $key => $val){
|
||||
array_push($strings, $key . '=' . $val);
|
||||
}
|
||||
}
|
||||
$signStr = 'channel=' . $channel . '&' . implode("&", $strings);
|
||||
error_log('InAppPurchase verify ' . $signStr);
|
||||
|
||||
$signature = hash_hmac('sha256', $singStr, BUY_SERVER_PKEY);
|
||||
return $sign == $signature;
|
||||
}
|
||||
|
||||
private function processOneOrder($record)
|
||||
{
|
||||
$productId = $record['productId'];
|
||||
$orderId = $record['gameOrderId'];
|
||||
$spOrderId = $record['orderId'];
|
||||
$status = $record['status'];
|
||||
|
||||
$orderDb = InAppOrder::find($orderId);
|
||||
if (!$orderDb) {
|
||||
error_log('InAppPurchase: not found order ' . json_encode($_REQUEST));
|
||||
return;
|
||||
}
|
||||
switch ($status) {
|
||||
case 9: {
|
||||
$status = 1;
|
||||
@ -168,34 +204,15 @@ class InAppPurchase {
|
||||
));
|
||||
break;
|
||||
default:
|
||||
$status = 0;
|
||||
$this->_rspErr(1, "status is not 9 or 96");
|
||||
return;
|
||||
{
|
||||
myself()->_addLogEx($orderDb['account_id'], 'InAppPurchase', 'error_order_status',
|
||||
array(
|
||||
$ordreDb['order_id'],
|
||||
json_encode($orderDb)
|
||||
));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_rspOk();
|
||||
}
|
||||
|
||||
private function verifySign($data)
|
||||
{
|
||||
$channel = $data['channel'];
|
||||
$records = $data['records'];
|
||||
$sign = $data['sign'];
|
||||
|
||||
$strings = array();
|
||||
foreach ($records as $record) {
|
||||
ksort($record);
|
||||
foreach($record as $key => $val){
|
||||
array_push($strings, $key . '=' . $val);
|
||||
}
|
||||
}
|
||||
$signStr = 'channel=' . $channel . '&' . implode("&", $strings);
|
||||
error_log('InAppPurchase verify ' . $signStr);
|
||||
|
||||
$signature = hash_hmac('sha256', $singStr, BUY_SERVER_PKEY);
|
||||
return $sign == $signature;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user