92 lines
2.7 KiB
PHP
92 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace services;
|
|
|
|
require_once('ShopAddItemService.php');
|
|
|
|
require_once('models/Mall.php');
|
|
require_once('services/EventService.php');
|
|
|
|
require_once('services/LogService.php');
|
|
require_once ('services/callback/common/SignatureService.php');
|
|
|
|
use phpcommon\SqlHelper;
|
|
|
|
use models\Mall;
|
|
|
|
use services\EventService;
|
|
|
|
/*
|
|
order_id
|
|
*/
|
|
|
|
class GameItemMarketBuyOk {
|
|
|
|
public function process()
|
|
{
|
|
SignatureService::web3ServiceCheck();
|
|
$buyer = strtolower(getReqVal('buyer', ''));
|
|
$orderId = getReqVal('order_id', '');
|
|
$currency = getReqVal('currency', '');
|
|
$price = getReqVal('price', '');
|
|
|
|
$orderDb = Mall::findByOrderId($orderId);
|
|
if (!$orderDb) {
|
|
myself()->_rspErr(2, 'Order does not exist');
|
|
return;
|
|
}
|
|
if ($orderDb['status'] == Mall::BUY_OK_STATE) {
|
|
myself()->_rspOk();
|
|
return;
|
|
}
|
|
Mall::buyOk($orderId, $buyer);
|
|
|
|
$accountId = myself()->_getAccountIdByAddress($buyer);
|
|
if (empty($accountId)) {
|
|
myself()->_addLogEx('', "mallBuyOk", "error_not_found_buyer", array(
|
|
'param1' => $orderDb['order_id'],
|
|
'param2' => json_encode(array(
|
|
'item_id' => $orderDb['item_id'],
|
|
'item_num' => $orderDb['item_num'],
|
|
)),
|
|
'param3' => json_encode($orderDb),
|
|
));
|
|
myself()->_rspOk();
|
|
return;
|
|
}
|
|
$itemId = $orderDb['item_id'];
|
|
$itemNum = $orderDb['item_num'];
|
|
myself()->_addLogEx($accountId, "mallBuyOk", "begin", array(
|
|
'param1' => $orderDb['order_id'],
|
|
'param2' => json_encode(array(
|
|
'item_id' => $orderDb['item_id'],
|
|
'item_num' => $orderDb['item_num'],
|
|
)),
|
|
'param3' => json_encode($orderDb),
|
|
));
|
|
if ($itemId == V_ITEM_GOLD) {
|
|
$event = [
|
|
'name' => LogService::MARKET_BUY_GOLD,
|
|
'val' => $itemNum
|
|
];
|
|
LogService::productGoldCallback(
|
|
array('account_id' => $accountId),
|
|
$event);
|
|
}
|
|
$itemService = new ShopAddItemService();
|
|
$itemService->addItemByAccountId($accountId, $itemId, $itemNum);
|
|
myself()->_addLogEx($accountId, "mallBuyOk", "end", array(
|
|
'param1' => $orderDb['order_id'],
|
|
'param2' => json_encode(array(
|
|
'item_id' => $orderDb['item_id'],
|
|
'item_num' => $orderDb['item_num'],
|
|
)),
|
|
'param3' => json_encode($orderDb),
|
|
));
|
|
$currencyName = $orderDb['currency'];
|
|
EventService::mallConsume($accountId, $currencyName, $price);
|
|
myself()->_rspOk();
|
|
}
|
|
|
|
}
|