1
This commit is contained in:
parent
7698894aac
commit
777ba0c3df
@ -2,15 +2,10 @@
|
||||
|
||||
namespace services;
|
||||
|
||||
require_once('phpcommon/bchelper.php');
|
||||
require_once('services/callback/BuyPassCbService.php');
|
||||
require_once('services/callback/BuyShopGoodsCbService.php');
|
||||
require_once('services/callback/common/SignatureService.php');
|
||||
require_once('ShopAddItemService.php');
|
||||
require_once('services/LogService.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\ShopBuyRecord;
|
||||
|
||||
class GameItemMarketBuyOk {
|
||||
|
||||
@ -85,115 +80,4 @@ class GameItemMarketBuyOk {
|
||||
));
|
||||
}
|
||||
|
||||
private function _isVirtualItem($itemId)
|
||||
{
|
||||
return in_array(
|
||||
$itemId,
|
||||
array(
|
||||
V_ITEM_EXP,
|
||||
V_ITEM_PASS,
|
||||
V_ITEM_RESET_CARD,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function _updateOrderState($address, $transId)
|
||||
{
|
||||
SqlHelper::update(
|
||||
myself()->_getMysql($address),
|
||||
't_bc_order',
|
||||
array(
|
||||
'order_id' => $transId
|
||||
),
|
||||
array(
|
||||
'status' => 1,
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function buyFromMarket($order, $idx)
|
||||
{
|
||||
$address = $order['address'];
|
||||
$account_id = $this->getAccountId($address);
|
||||
$goods = $this->getMarketGoods($address, $idx);
|
||||
$this->markMarketGoodsSold($address, $idx);
|
||||
|
||||
$this->_addGoods($address, $goods);
|
||||
{
|
||||
//埋点
|
||||
$event = [
|
||||
'name' => LogService::MARKET_BUY_GOLD,
|
||||
'val' => $goods['amount']
|
||||
];
|
||||
LogService::productGoldCallback(['account_id' => $account_id], $event );
|
||||
}
|
||||
}
|
||||
|
||||
private function getMarketGoods($address, $idx)
|
||||
{
|
||||
$row = SqlHelper::selectOne(
|
||||
myself()->_getMysql($address),
|
||||
't_market_store',
|
||||
array('order_id', 'item_id', 'amount', 's_price', 'owner_address'),
|
||||
array(
|
||||
'idx' => $idx
|
||||
)
|
||||
);
|
||||
if (!$row) {
|
||||
return null;
|
||||
}
|
||||
if (!$row['item_id']) {
|
||||
return null;
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
private function markMarketGoodsSold($address, $idx)
|
||||
{
|
||||
SqlHelper::update(
|
||||
myself()->_getMysql($address),
|
||||
't_market_store',
|
||||
array(
|
||||
'idx' => $idx
|
||||
),
|
||||
array(
|
||||
'status' => 2,
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function _addGoods($address, $goods)
|
||||
{
|
||||
$itemService = new ShopAddItemService();
|
||||
$item_id = $goods['item_id'];
|
||||
$goods_num = $goods['amount'];
|
||||
|
||||
$id = null;
|
||||
if (!empty($goods['id'])) {
|
||||
$id = $goods['id'];
|
||||
}
|
||||
|
||||
error_log(json_encode($goods));
|
||||
error_log('_addGoods ' . $address . ' item_id ' . $item_id . ' goods_num ' . $goods_num . ' id ' . $id);
|
||||
$itemService->addItem($address, $item_id, $goods_num);
|
||||
if ($id) {
|
||||
ShopBuyRecord::addWithAddress($address, $id, $goods_num);
|
||||
}
|
||||
}
|
||||
|
||||
private function getAccountId($address){
|
||||
|
||||
$row = SqlHelper::ormSelectOne
|
||||
(myself()->_getMysql($address),
|
||||
't_user',
|
||||
array(
|
||||
'address' => $address
|
||||
)
|
||||
);
|
||||
|
||||
return $row['account_id'];
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user