...
This commit is contained in:
parent
a07b6c09ea
commit
b2b1d6b765
@ -4,6 +4,12 @@ class CallbackController extends BaseController {
|
|||||||
|
|
||||||
private $handlers = array(
|
private $handlers = array(
|
||||||
'gameItemMallBuyOk' => 'GameItemMallBuyOk',
|
'gameItemMallBuyOk' => 'GameItemMallBuyOk',
|
||||||
|
'eventSellOrder' => 'eventSellOrder',
|
||||||
|
'eventBuyOrder' => 'eventBuyOrder',
|
||||||
|
'eventCancelOrder' => 'eventCancelOrder',
|
||||||
|
'eventPriceUpdateOrder' => 'eventPriceUpdateOrder',
|
||||||
|
'buyGoodsDirect' => 'buyGoodsDirect',
|
||||||
|
'inappPurchaseDiamonds' => 'inappPurchaseDiamonds',
|
||||||
);
|
);
|
||||||
|
|
||||||
public function dispatch()
|
public function dispatch()
|
||||||
|
@ -10,7 +10,7 @@ use phpcommon\SqlHelper;
|
|||||||
|
|
||||||
class BuyRecord extends BaseModel {
|
class BuyRecord extends BaseModel {
|
||||||
|
|
||||||
public static function genOrderId($gameId, $funcId, $time, $®)
|
public static function genOrderId($gameId, $funcId, $time, $buyerAddress)
|
||||||
{
|
{
|
||||||
SqlHelper::insert
|
SqlHelper::insert
|
||||||
(myself()->_getMarketMysql(),
|
(myself()->_getMarketMysql(),
|
||||||
|
11
webapp/services/callback/buyGoodsDirect.php
Normal file
11
webapp/services/callback/buyGoodsDirect.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace services;
|
||||||
|
|
||||||
|
class buyGoodsDirect
|
||||||
|
{
|
||||||
|
public function process()
|
||||||
|
{
|
||||||
|
error_log('buyGoodsDirect:' . json_encode($_REQUEST, JSON_PRETTY_PRINT));
|
||||||
|
}
|
||||||
|
}
|
75
webapp/services/callback/eventBuyOrder.php
Normal file
75
webapp/services/callback/eventBuyOrder.php
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace services;
|
||||||
|
|
||||||
|
class eventBuyOrder
|
||||||
|
{
|
||||||
|
public function process()
|
||||||
|
{
|
||||||
|
error_log('eventBuyOrder:' . json_encode($_REQUEST, JSON_PRETTY_PRINT));
|
||||||
|
|
||||||
|
$tokenId = getReqVal('tokenId', '');
|
||||||
|
$orderId = getReqVal('orderId', '');
|
||||||
|
$nftToken = getReqVal('nftToken', '');
|
||||||
|
$amount = getReqVal('amount', 0);
|
||||||
|
$seller = strtolower(getReqVal('seller', ''));
|
||||||
|
$buyer = strtolower(getReqVal('buyer', ''));
|
||||||
|
$erc20 = getReqVal('erc20', '');
|
||||||
|
$price = getReqVal('price', '');
|
||||||
|
|
||||||
|
error_log(
|
||||||
|
"eventBuyOrder:" . json_encode(
|
||||||
|
array(
|
||||||
|
'tokenId' => $tokenId,
|
||||||
|
'orderId' => $orderId,
|
||||||
|
'nftToken' => $nftToken,
|
||||||
|
'amount' => $amount,
|
||||||
|
'seller' => $seller,
|
||||||
|
'buyer' => $buyer,
|
||||||
|
'erc20' => $erc20,
|
||||||
|
'price' => $price,
|
||||||
|
),
|
||||||
|
JSON_PRETTY_PRINT
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$conn = myself()->_getSelfMysql();
|
||||||
|
|
||||||
|
// 1. check order status
|
||||||
|
$chk = SqlHelper::selectOne($conn, 't_market_store', array('status', 'idx', 'c_name', 'token_type'), array('o_link' => $orderId));
|
||||||
|
if (empty($chk)) {
|
||||||
|
$this->_rspErr(1, 'not found order, orderId=' . $orderId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($chk['status'] == '0') {
|
||||||
|
$r = SqlHelper::update(
|
||||||
|
$conn,
|
||||||
|
't_market_store',
|
||||||
|
array(
|
||||||
|
'o_link' => $orderId,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'status' => 2,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if ($r) {
|
||||||
|
// 增加交易记录
|
||||||
|
$record = array(
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'orderid' => $chk['idx'],
|
||||||
|
'o_link' => $orderId,
|
||||||
|
'seller' => $seller,
|
||||||
|
'buyer' => $buyer,
|
||||||
|
'tokenid' => $tokenId,
|
||||||
|
'amount' => $amount,
|
||||||
|
'name' => $chk['c_name'],
|
||||||
|
'type' => $chk['token_type'],
|
||||||
|
);
|
||||||
|
$this->addTransactionRecord($record);
|
||||||
|
$this->_rspOk();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->_rspErr(1, 'order status error, order=' . $orderId);
|
||||||
|
}
|
||||||
|
}
|
51
webapp/services/callback/eventCancelOrder.php
Normal file
51
webapp/services/callback/eventCancelOrder.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace services;
|
||||||
|
|
||||||
|
class eventCancelOrder
|
||||||
|
{
|
||||||
|
public function process()
|
||||||
|
{
|
||||||
|
error_log('eventCancelOrder:' . json_encode($_REQUEST, JSON_PRETTY_PRINT));
|
||||||
|
|
||||||
|
$orderId = getReqVal('orderId', '');
|
||||||
|
$nftToken = getReqVal('nftToken', '');
|
||||||
|
$tokenId = getReqVal('tokenId', '');
|
||||||
|
error_log(
|
||||||
|
"eventCancelOrder:" . json_encode(
|
||||||
|
array(
|
||||||
|
'orderId' => $orderId,
|
||||||
|
'nftToken' => $nftToken,
|
||||||
|
'tokenId' => $tokenId,
|
||||||
|
),
|
||||||
|
JSON_PRETTY_PRINT
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$conn = myself()->_getSelfMysql();
|
||||||
|
|
||||||
|
// 1. check order status
|
||||||
|
$chk = SqlHelper::selectOne($conn, 't_market_store', array('status'), array('o_link' => $orderId));
|
||||||
|
if (empty($chk)) {
|
||||||
|
$this->_rspErr(1, 'not found order, orderId=' . $orderId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($chk['status'] == '0') {
|
||||||
|
$r = SqlHelper::update(
|
||||||
|
$conn,
|
||||||
|
't_market_store',
|
||||||
|
array(
|
||||||
|
'o_link' => $orderId,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'status' => 1,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if ($r) {
|
||||||
|
$this->_rspOk();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->_rspErr(1, 'order status error, order=' . $orderId);
|
||||||
|
}
|
||||||
|
}
|
57
webapp/services/callback/eventPriceUpdateOrder.php
Normal file
57
webapp/services/callback/eventPriceUpdateOrder.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace services;
|
||||||
|
|
||||||
|
class eventPriceUpdateOrder
|
||||||
|
{
|
||||||
|
public function process()
|
||||||
|
{
|
||||||
|
error_log('eventPriceUpdateOrder:' . json_encode($_REQUEST, JSON_PRETTY_PRINT));
|
||||||
|
|
||||||
|
$orderId = getReqVal('orderId', '');;
|
||||||
|
$nftToken = getReqVal('nftToken', '');
|
||||||
|
$tokenId = getReqVal('tokenId', '');
|
||||||
|
$priceOld = getReqVal('priceOld', '');
|
||||||
|
$price = getReqVal('price', '');
|
||||||
|
error_log(
|
||||||
|
"eventPriceUpdateOrder:" . json_encode(
|
||||||
|
array(
|
||||||
|
'orderId' => $orderId,
|
||||||
|
'nftToken' => $nftToken,
|
||||||
|
'tokenId' => $tokenId,
|
||||||
|
'priceOld' => $priceOld,
|
||||||
|
'price' => $price,
|
||||||
|
),
|
||||||
|
JSON_PRETTY_PRINT
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$conn = myself()->_getSelfMysql();
|
||||||
|
|
||||||
|
// 1. check order status
|
||||||
|
$chk = SqlHelper::selectOne($conn, 't_market_store', array('status'), array('o_link' => $orderId));
|
||||||
|
if (empty($chk)) {
|
||||||
|
$this->_rspErr(1, 'not found order, orderId=' . $orderId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($chk['status'] == '0') {
|
||||||
|
$r = SqlHelper::update(
|
||||||
|
$conn,
|
||||||
|
't_market_store',
|
||||||
|
array(
|
||||||
|
'o_link' => $orderId,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
's_price' => $price,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if ($r) {
|
||||||
|
$this->_rspOk();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_rspErr(1, 'price update failed, orderId=' . $orderId);
|
||||||
|
}
|
||||||
|
}
|
83
webapp/services/callback/eventSellOrder.php
Normal file
83
webapp/services/callback/eventSellOrder.php
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace services;
|
||||||
|
|
||||||
|
class eventSellOrder
|
||||||
|
{
|
||||||
|
public function process()
|
||||||
|
{
|
||||||
|
error_log('eventBuyOrder:' . json_encode($_REQUEST, JSON_PRETTY_PRINT));
|
||||||
|
|
||||||
|
$tokenId = getReqVal('tokenId', '');
|
||||||
|
$owner = strtolower(getReqVal('owner', ''));
|
||||||
|
$nftToken = getReqVal('nftToken', '');
|
||||||
|
$amount = getReqVal('amount', 0);
|
||||||
|
$orderId = getReqVal('orderId', '');
|
||||||
|
$currency = getReqVal('currency', '');
|
||||||
|
$price = getReqVal('price', '');
|
||||||
|
|
||||||
|
error_log(
|
||||||
|
"eventSellOrder:" . json_encode(
|
||||||
|
array(
|
||||||
|
'tokenId' => $tokenId,
|
||||||
|
'owner' => $owner,
|
||||||
|
'nftToken' => $nftToken,
|
||||||
|
'amount' => $amount,
|
||||||
|
'orderId' => $orderId,
|
||||||
|
'currency' => $currency,
|
||||||
|
'price' => $price,
|
||||||
|
),
|
||||||
|
JSON_PRETTY_PRINT
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$conn = myself()->_getSelfMysql();
|
||||||
|
|
||||||
|
// 1. check order status
|
||||||
|
$chk = SqlHelper::selectOne($conn, 't_market_store', array('status'), array('o_link' => $orderId));
|
||||||
|
if (!empty($chk)) {
|
||||||
|
$this->_rspErr(1, 'repeat sell order, orderId=' . $orderId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. insert sell order to t_market_store
|
||||||
|
$nftDb = Nft::findNftByOwner($owner, $tokenId);
|
||||||
|
if (empty($nftDb)) {
|
||||||
|
$nftDb = Nft::getNft($tokenId);
|
||||||
|
}
|
||||||
|
$nftDetail = Nft::toDto($nftDb);
|
||||||
|
$detail = $this->getNftGameData($nftDb);
|
||||||
|
$r = SqlHelper::insert(
|
||||||
|
$conn,
|
||||||
|
't_market_store',
|
||||||
|
array(
|
||||||
|
'token_id' => $tokenId,
|
||||||
|
'o_link' => $orderId,
|
||||||
|
'nft_token' => $nftToken,
|
||||||
|
'status' => 0,
|
||||||
|
'owner_address' => $owner,
|
||||||
|
'token_type' => $nftDetail['type'],
|
||||||
|
'amount' => $amount,
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime(),
|
||||||
|
's_currency' => $currency,
|
||||||
|
's_price' => $price,
|
||||||
|
'c_name' => $nftDetail['info']['name'],
|
||||||
|
'c_job' => isset($nftDetail['info']['job']) ? $nftDetail['info']['job']
|
||||||
|
: (isset($detail['chip_type']) ? $detail['chip_type']
|
||||||
|
: (isset($detail['type']) ? $detail['type']
|
||||||
|
: 0)),
|
||||||
|
'c_lv' => @$detail['gun_lv'] | @$detail['hero_lv'] | @$detail['chip_grade'],
|
||||||
|
'c_quality' => isset($nftDetail['info']['quality']) ? $nftDetail['info']['quality'] : 0,
|
||||||
|
'c_durability' => isset($nftDetail['info']['durability']) ? $nftDetail['info']['durability'] : (isset($detail['hero_tili']) ? $detail['hero_tili'] : 0),
|
||||||
|
'c_type' => isset($detail['type']) ? $detail['type'] : 0,
|
||||||
|
'c_id' => $nftDetail['item_id'],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (!$r) {
|
||||||
|
$this->_rspErr(2, 'unknown error, orderId=' . $orderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_rspOk();
|
||||||
|
}
|
||||||
|
}
|
12
webapp/services/callback/inappPurchaseDiamonds.php
Normal file
12
webapp/services/callback/inappPurchaseDiamonds.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace services;
|
||||||
|
|
||||||
|
class inappPurchaseDiamonds
|
||||||
|
{
|
||||||
|
|
||||||
|
public function process()
|
||||||
|
{
|
||||||
|
error_log('inappPurchaseDiamonds:' . json_encode($_REQUEST, JSON_PRETTY_PRINT));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user