Compare commits
11 Commits
master
...
marketshop
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1bd58003dc | ||
![]() |
457f1ff963 | ||
![]() |
1fb7c3ad87 | ||
![]() |
ec615171d3 | ||
![]() |
05f28d5f65 | ||
![]() |
3afd541cc6 | ||
![]() |
dd8668a471 | ||
![]() |
46a2173c2c | ||
![]() |
145602b391 | ||
![]() |
ed3fb9f8b0 | ||
![]() |
04e450ce6c |
@ -137,6 +137,7 @@ class FirstTopupController extends BaseAuthedController
|
||||
'group' => $group,
|
||||
'status' => $status,
|
||||
'reward' => $reward,
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
)
|
||||
);
|
||||
} else if ($test >= 2) {
|
||||
|
@ -22,6 +22,8 @@ require_once('services/LuckyBoxService.php');
|
||||
require_once('services/ActivateNftService.php');
|
||||
require_once('services/BlockChainService.php');
|
||||
require_once('services/LogService.php');
|
||||
require_once('services/AwardService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
|
||||
require_once('phpcommon/bchelper.php');
|
||||
|
||||
@ -334,10 +336,11 @@ class MarketController extends BaseAuthedController
|
||||
};
|
||||
|
||||
$conn = myself()->_getSelfMysql();
|
||||
$now = myself()->_getNowTime();
|
||||
|
||||
$counts = $conn->execQuery(
|
||||
'SELECT count(idx) as count FROM t_market_store ' .
|
||||
'WHERE token_type=:token_type AND status=0 ' .
|
||||
'WHERE token_type=:token_type AND (status=0 OR status=3) AND buytime<:nowThat ' .
|
||||
$job_filter_fn($job_filter_array) .
|
||||
$lv_filter_fn($lv_filter) .
|
||||
$quality_filter_fn($quality_filter) .
|
||||
@ -348,6 +351,7 @@ class MarketController extends BaseAuthedController
|
||||
$order_fn($order_method, $order_asc),
|
||||
array(
|
||||
':token_type' => $type,
|
||||
':nowThat' => $now - 3600 * 24,
|
||||
)
|
||||
);
|
||||
|
||||
@ -362,7 +366,7 @@ class MarketController extends BaseAuthedController
|
||||
|
||||
$rows = $conn->execQuery(
|
||||
'SELECT * FROM t_market_store ' .
|
||||
'WHERE token_type=:token_type AND status=0 ' .
|
||||
'WHERE token_type=:token_type AND (status=0 OR status=3) AND buytime<:nowThat ' .
|
||||
$job_filter_fn($job_filter_array) .
|
||||
$lv_filter_fn($lv_filter) .
|
||||
$quality_filter_fn($quality_filter) .
|
||||
@ -374,6 +378,7 @@ class MarketController extends BaseAuthedController
|
||||
'LIMIT ' . $start . ',' . $page_size,
|
||||
array(
|
||||
':token_type' => $type,
|
||||
':nowThat' => $now - 3600 * 24,
|
||||
)
|
||||
);
|
||||
|
||||
@ -756,10 +761,11 @@ class MarketController extends BaseAuthedController
|
||||
$goods['amount']
|
||||
);
|
||||
|
||||
if (!$this->markOrderBuyStatus($idx)) {
|
||||
$this->_rspErr(1, 'buy failed, update order status failed, idx:' . $idx);
|
||||
return;
|
||||
}
|
||||
// 不再标记购买状态,改为抢单模式,第一个交易成功者获得商品
|
||||
// if (!$this->markOrderBuying($idx)) {
|
||||
// $this->_rspErr(1, 'buy failed, update order status failed, idx:' . $idx);
|
||||
// return;
|
||||
// }
|
||||
|
||||
$item_id = $goods['item_id'];
|
||||
$item_count = $goods['amount'];
|
||||
@ -863,13 +869,15 @@ class MarketController extends BaseAuthedController
|
||||
// error_log('listMySelledNfts ' . $account . ' ' . $type);
|
||||
|
||||
$conn = myself()->_getSelfMysql();
|
||||
$now = myself()->_getNowTime();
|
||||
|
||||
$rows = $conn->execQuery(
|
||||
'SELECT * FROM t_market_store ' .
|
||||
'WHERE owner_address=:account AND token_type=:token_type AND status=0 ',
|
||||
'WHERE owner_address=:account AND token_type=:token_type AND (status=0 OR status=3) AND buytime<:nowThat ',
|
||||
array(
|
||||
':account' => $account,
|
||||
':token_type' => $type,
|
||||
':nowThat' => $now - 3600 * 24,
|
||||
)
|
||||
);
|
||||
|
||||
@ -891,10 +899,9 @@ class MarketController extends BaseAuthedController
|
||||
$row = SqlHelper::selectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_market_store',
|
||||
array('order_id', 'item_id', 'amount', 's_price', 'owner_address'),
|
||||
array('order_id', 'item_id', 'amount', 's_price', 'owner_address', 'status', 'buytime'),
|
||||
array(
|
||||
'idx' => $idx,
|
||||
'status' => 0,
|
||||
)
|
||||
);
|
||||
if (!$row) {
|
||||
@ -903,10 +910,17 @@ class MarketController extends BaseAuthedController
|
||||
if (!$row['item_id']) {
|
||||
return null;
|
||||
}
|
||||
if (!$row['status']==3 && !$row['status']==0) {
|
||||
return null;
|
||||
}
|
||||
$now = myself()->_getNowTime();
|
||||
if ($row['buytime'] > $now - 3600 * 24) {
|
||||
return null;
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
private function markOrderBuyStatus($idx)
|
||||
private function markOrderBuying($idx)
|
||||
{
|
||||
$r = SqlHelper::update(
|
||||
myself()->_getSelfMysql(),
|
||||
|
@ -187,7 +187,6 @@ class ShopController extends BaseAuthedController
|
||||
|
||||
$address = $this->_getAddress();
|
||||
if ($address) {
|
||||
// $goods['pending'] = $this->checkPendingBuyGoodsNormal($address, $goods['goods_id'], $goods['shop_id'], $goods['id']);
|
||||
$goods['pending'] = 0;
|
||||
}
|
||||
}
|
||||
@ -391,7 +390,7 @@ class ShopController extends BaseAuthedController
|
||||
break;
|
||||
}
|
||||
|
||||
SqlHelper::update($conn, 't_shop_buy_order', array('idx' => $order_id), array('status' => $buyStatus));
|
||||
SqlHelper::update($conn, 't_shop_buy_order', array('order_id' => $order_id), array('status' => $buyStatus));
|
||||
|
||||
// 以下是看商品表中是否配置了充值额外奖励
|
||||
$goods = mt\ShopGoods::get($id);
|
||||
@ -822,7 +821,6 @@ class ShopController extends BaseAuthedController
|
||||
$goodsList[$i] = mt\Dailyselection::get($selection['grid_' . $i]);
|
||||
if ($goodsList[$i]) {
|
||||
$goodsList[$i]['count'] = $selection['count_' . $i];
|
||||
// $goodsList[$i]['pending'] = $this->checkPendingBuyGoodsDS($address, $goodsList[$i]['goods_id'], $selection['idx'], $i);
|
||||
$goodsList[$i]['pending'] = 0;
|
||||
}
|
||||
}
|
||||
@ -870,13 +868,6 @@ class ShopController extends BaseAuthedController
|
||||
}
|
||||
|
||||
$goods_id = $row['goods_id'];
|
||||
if (!empty($address)) {
|
||||
// $pending = $this->checkPendingBuyGoodsNormal($address, $goods_id, $row['shop_id'], $id);
|
||||
// if ($pending) {
|
||||
// $this->_rspErr(1, 'pending');
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
|
||||
$desired_token_type = $row['token_type'];
|
||||
$check_token_type = splitStr1($desired_token_type);
|
||||
@ -1343,15 +1334,6 @@ class ShopController extends BaseAuthedController
|
||||
}
|
||||
|
||||
$free_num = $goods['free_num'];
|
||||
// $pending = $this->checkPendingBuyGoodsNormal($address, $goods_id, $shop_id, $id);
|
||||
// error_log("getChestItems start " . json_encode(
|
||||
// array(
|
||||
// 'goods_id' => $goods_id,
|
||||
// 'items' => array_keys($record),
|
||||
// 'free_num' => $free_num,
|
||||
// 'pending' => 0,
|
||||
// )
|
||||
// ));
|
||||
|
||||
$this->_rspData(
|
||||
array(
|
||||
@ -1540,83 +1522,6 @@ class ShopController extends BaseAuthedController
|
||||
}
|
||||
}
|
||||
|
||||
private function countBuyGoodsRequestTimesByGoodsId($address, $goodsId)
|
||||
{
|
||||
$self = myself();
|
||||
if (!$self) return;
|
||||
|
||||
$conn = $self->_getMysql('');
|
||||
|
||||
$sql = "SELECT COUNT(idx) AS cnt FROM t_bc_order WHERE address = '$address' AND item_id = '$goodsId'";
|
||||
|
||||
$row = $conn->execQuery($sql);
|
||||
|
||||
return $row[0]['cnt'];
|
||||
}
|
||||
|
||||
private function checkPendingBuyGoodsNormal($address, $goodsId, $shop_id, $id)
|
||||
{
|
||||
$self = myself();
|
||||
if (!$self) return;
|
||||
|
||||
$conn = $self->_getMysql('');
|
||||
|
||||
$rows = SqlHelper::select(
|
||||
$conn,
|
||||
't_bc_order',
|
||||
array('ext_data', 'createtime'),
|
||||
array(
|
||||
'address' => $address,
|
||||
'item_id' => $goodsId,
|
||||
'status' => 0,
|
||||
)
|
||||
);
|
||||
foreach ($rows as $row) {
|
||||
if ($row['createtime'] + 15 * 60 < $self->_getNowTime()) continue; // 15分钟内有效
|
||||
$extData = json_decode($row['ext_data'], true);
|
||||
// error_log("checkPendingBuyGoodsNormal: " . json_encode($extData));
|
||||
if ($extData['mode'] == SHOP_BUY_MODE_NORMAL) {
|
||||
if ($extData['shop_id'] == $shop_id) {
|
||||
if ($extData['id'] == $id) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function checkPendingBuyGoodsDS($address, $goodsId, $idx, $grid)
|
||||
{
|
||||
$self = myself();
|
||||
if (!$self) return;
|
||||
|
||||
$conn = $self->_getMysql('');
|
||||
|
||||
$rows = SqlHelper::select(
|
||||
$conn,
|
||||
't_bc_order',
|
||||
array('ext_data', 'createtime'),
|
||||
array(
|
||||
'address' => $address,
|
||||
'item_id' => $goodsId,
|
||||
'status' => 0,
|
||||
)
|
||||
);
|
||||
foreach ($rows as $row) {
|
||||
if ($row['createtime'] + 15 * 60 < $self->_getNowTime()) continue; // 15分钟内有效
|
||||
$extData = json_decode($row['ext_data'], true);
|
||||
if ($extData['mode'] == SHOP_BUY_MODE_DAILY_SELECTION) {
|
||||
if ($extData['idx'] == $idx) {
|
||||
if ($extData['grid'] == $grid) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function internalAddItem($propertyChgService, $itemMeta, $count, $sysAdd, $grade = null)
|
||||
{
|
||||
switch ($itemMeta['type']) {
|
||||
|
@ -116,11 +116,21 @@ class GameItemMarketBuyOk
|
||||
private function buyFromMarket($order, $idx)
|
||||
{
|
||||
$address = $order['address'];
|
||||
$goods = $this->getMarketGoods($address, $idx);
|
||||
$goods = $this->getMarketGoodsOnSale($address, $idx);
|
||||
if (!$goods) { {
|
||||
error_log('buyFromMarket goods not found, address:' . $address . ' idx:' . $idx);
|
||||
//埋点
|
||||
$event = [
|
||||
'name' => LogService::MARKET_BUY_GOLD,
|
||||
'val' => $goods['amount']
|
||||
];
|
||||
LogService::productGold($event, ['account_id' => $address, 'result' => 'fail']);
|
||||
}
|
||||
return;
|
||||
}
|
||||
$this->markMarketGoodsSold($address, $idx);
|
||||
|
||||
$this->_addGoods($address, $goods);
|
||||
{
|
||||
$this->_addGoods($address, $goods); {
|
||||
//埋点
|
||||
$event = [
|
||||
'name' => LogService::MARKET_BUY_GOLD,
|
||||
@ -130,14 +140,15 @@ class GameItemMarketBuyOk
|
||||
}
|
||||
}
|
||||
|
||||
private function getMarketGoods($address, $idx)
|
||||
private function getMarketGoodsOnSale($address, $idx)
|
||||
{
|
||||
$row = SqlHelper::selectOne(
|
||||
myself()->_getMysql($address),
|
||||
't_market_store',
|
||||
array('order_id', 'item_id', 'amount', 's_price', 'owner_address'),
|
||||
array(
|
||||
'idx' => $idx
|
||||
'idx' => $idx,
|
||||
'status' => 0,
|
||||
)
|
||||
);
|
||||
if (!$row) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user