This commit is contained in:
songliang 2023-06-28 17:34:22 +08:00
parent ab4bcf3ad2
commit 0b5a86dd32

View File

@ -997,19 +997,19 @@ class ShopController extends BaseAuthedController
$this->internalAddItem($propertyChgService, $itemMeta, $goods_count, 1); $this->internalAddItem($propertyChgService, $itemMeta, $goods_count, 1);
$this->_rspOk(); $this->_rspOk();
} else { } else {
error_log("buy normal 1, need_price = ". $need_price . " goods_num = " . $goods_num); error_log("buy normal 1, need_price = " . $need_price . " goods_num = " . $goods_num);
$price = $this->normalizeWeb3Price($goods_num * $need_price); $price = $this->normalizeWeb3Price($goods_num * $need_price);
error_log("buy normal 2, price = " . $price); error_log("buy normal 2, price = " . $price);
$item_id = $row['goods_id']; $item_id = $row['goods_id'];
$item_count = $goods_num; $item_count = $goods_num;
$response = services\BlockChainService::gameItemMallBuy( $response = services\BlockChainService::gameItemMallBuy(
Transaction::BUY_GOODS_ACTION_TYPE, Transaction::BUY_GOODS_ACTION_TYPE,
$price, $price,
$item_id, $item_id,
$item_count $item_count
); );
BcOrder::upsert($response['trans_id'], array( BcOrder::upsert($response['trans_id'], array(
'item_id' => $item_id, 'item_id' => $item_id,
'item_num' => $item_count, 'item_num' => $item_count,
@ -1020,11 +1020,11 @@ class ShopController extends BaseAuthedController
'id' => $id, 'id' => $id,
)), )),
)); ));
$response['item_id'] = $item_id; $response['item_id'] = $item_id;
$response['item_num'] = $item_count; $response['item_num'] = $item_count;
$this->_rspData( $this->_rspData(
array( array(
"block_chain" => $response "block_chain" => $response
) )
); );
@ -1098,15 +1098,16 @@ class ShopController extends BaseAuthedController
$price = $this->normalizeWeb3Price($goods['price'] * $count); $price = $this->normalizeWeb3Price($goods['price'] * $count);
$item_id = $goods['goods_id']; $item_id = $goods['goods_id'];
$item_count = $goods['goods_num'] * $count; $item_count = $goods['goods_num'] * $count;
error_log("buyGoodsDS start " . json_encode(array( error_log("buyGoodsDS start " . json_encode(
'idx' => $idx, array(
'grid' => $grid, 'idx' => $idx,
'count' => $count, 'grid' => $grid,
'goodPrice' => $goods['price'], 'count' => $count,
'price' => $price, 'goodPrice' => $goods['price'],
'item_id' => $item_id, 'price' => $price,
'item_count' => $item_count, 'item_id' => $item_id,
) 'item_count' => $item_count,
)
)); ));
$response = services\BlockChainService::gameItemMallBuy( $response = services\BlockChainService::gameItemMallBuy(
Transaction::BUY_GOODS_ACTION_TYPE, Transaction::BUY_GOODS_ACTION_TYPE,
@ -1127,12 +1128,13 @@ class ShopController extends BaseAuthedController
)), )),
)); ));
error_log("buyGoodsDS start " . json_encode(array( error_log("buyGoodsDS start " . json_encode(
'idx' => $idx, array(
'grid' => $grid, 'idx' => $idx,
'count' => $count, 'grid' => $grid,
'block_chain' => $response, 'count' => $count,
) 'block_chain' => $response,
)
)); ));
$this->_rspData( $this->_rspData(
@ -1168,7 +1170,7 @@ class ShopController extends BaseAuthedController
$itemStore = mt\ShopChest::getRandomItemListByChestType($recommend); $itemStore = mt\ShopChest::getRandomItemListByChestType($recommend);
$result = array(); $result = array();
for ($i=0; $i<$num; $i++) { for ($i = 0; $i < $num; $i++) {
$record = array(); $record = array();
foreach ($itemStore as $key => $value) { foreach ($itemStore as $key => $value) {
$item = $this->weighted_random($value); $item = $this->weighted_random($value);
@ -1181,16 +1183,16 @@ class ShopController extends BaseAuthedController
$this->internalAddItem($propertyChgService, $itemMeta, 1, 1); $this->internalAddItem($propertyChgService, $itemMeta, 1, 1);
} }
} }
$record[$key] = array("item_id" => $item['item_id'], "item_num" => $item['num']);
$record[$key] = array( "item_id" => $item['item_id'], "item_num" => $item['num'] ); array_push($result, $record[$key]);
} }
array_push($result, $record);
} }
error_log("buyBlindBox start " . json_encode(array( error_log("buyBlindBox start " . json_encode(
'account' => $account, array(
'itemListStore' => $result, 'account' => $account,
) 'itemListStore' => $result,
)
)); ));
$this->_rspData( $this->_rspData(
@ -1544,7 +1546,7 @@ class ShopController extends BaseAuthedController
$this->_addVirtualItem($itemMeta['id'], $count, null, $propertyChgService); $this->_addVirtualItem($itemMeta['id'], $count, null, $propertyChgService);
$propertyChgService->addUserChg(); $propertyChgService->addUserChg();
// 充值就尝试开启首充活动 // 充值就尝试开启首充活动
if ($sysAdd!=1) { if ($sysAdd != 1) {
if ($itemMeta['id'] == 10001) { if ($itemMeta['id'] == 10001) {
$this->beginFirstTupop(); $this->beginFirstTupop();
} }
@ -1645,50 +1647,48 @@ class ShopController extends BaseAuthedController
return phpcommon\bnToStr($ret_price); return phpcommon\bnToStr($ret_price);
} }
private function countFreeBuyTimes($goods) { private function countFreeBuyTimes($goods)
{
$conn = myself()->_getMysql(''); $conn = myself()->_getMysql('');
$account = myself()->_getAccountId(); $account = myself()->_getAccountId();
switch($goods['free_type']) switch ($goods['free_type']) {
{ case 1: {
case 1: $dayTime = myself()->_getNowDaySeconds();
{ $sql = 'SELECT COUNT(*) as cnt FROM t_shop_free_record WHERE account_id = ? AND `id` = ? AND goods_id = ? AND createtime >= ?';
$dayTime = myself()->_getNowDaySeconds(); $row = $conn->execQueryOne($sql, array($account, $goods['id'], $goods['goods_id'], $dayTime));
$sql = 'SELECT COUNT(*) as cnt FROM t_shop_free_record WHERE account_id = ? AND `id` = ? AND goods_id = ? AND createtime >= ?'; return $row['cnt'];
$row = $conn->execQueryOne($sql, array($account, $goods['id'], $goods['goods_id'], $dayTime)); }
return $row['cnt']; break;
}
break;
} }
return 0; return 0;
} }
private function addFreeBuyRecord($goods) { private function addFreeBuyRecord($goods)
{
$conn = myself()->_getMysql(''); $conn = myself()->_getMysql('');
$account = myself()->_getAccountId(); $account = myself()->_getAccountId();
switch($goods['free_type']) switch ($goods['free_type']) {
{ case 1: {
case 1: $dayTime = myself()->_getNowTime();
{ SqlHelper::insert(
$dayTime = myself()->_getNowTime(); $conn,
SqlHelper::insert( 't_shop_free_record',
$conn, array(
't_shop_free_record', 'account_id' => $account,
array( 'shop_id' => $goods['shop_id'],
'account_id' => $account, 'id' => $goods['id'],
'shop_id' => $goods['shop_id'], 'goods_id' => $goods['goods_id'],
'id' => $goods['id'], 'goods_num' => $goods['goods_num'],
'goods_id' => $goods['goods_id'], 'free_type' => $goods['free_type'],
'goods_num' => $goods['goods_num'], 'free_num' => $goods['free_num'],
'free_type' => $goods['free_type'], 'createtime' => $dayTime,
'free_num' => $goods['free_num'], )
'createtime' => $dayTime, );
) }
); break;
}
break;
} }
} }
} }