This commit is contained in:
songliang 2023-07-07 14:57:31 +08:00
parent 95bb04db25
commit 12ac97878c
2 changed files with 46 additions and 11 deletions

View File

@ -700,6 +700,41 @@ class ShopController extends BaseAuthedController
}
}
public function buyDiamond()
{
$num = getReqVal('num', 0);
$price = $this->normalizeWeb3Price($num);
$item_id = V_ITEM_DIAMOND;
$item_count = $num;
$response = services\BlockChainService::gameItemMallBuy(
Transaction::BUY_GOODS_ACTION_TYPE,
$price,
$item_id,
$item_count
);
BcOrder::upsert($response['trans_id'], array(
'item_id' => $item_id,
'item_num' => $item_count,
'order_type' => 1,
'ext_data' => json_encode(array(
'mode' => SHOP_BUY_MODE_NORMAL,
)),
));
$response['item_id'] = $item_id;
$response['item_num'] = $item_count;
error_log("buy diamond, item_id = " . $item_id . " item_count = " . $item_count . " num = " . $num . " price = " . $price . " response = " . json_encode($response));
$this->_rspData(
array(
"block_chain" => $response
)
);
}
public function buyGoodsDS()
{
$idx = getReqVal('idx', 0);
@ -760,7 +795,7 @@ class ShopController extends BaseAuthedController
$sql = "UPDATE t_shop_dailyselection SET count_$grid = count_$grid - $count WHERE idx = $idx";
$chk = $conn->execScript($sql);
$itemMeta = mt\Item::get($item_id);
$propertyChgService = new services\PropertyChgService();
for ($i = 0; $i < $count; $i++) {

View File

@ -132,12 +132,12 @@ class BuyShopGoodsCbService
$itemService = new ShopAddItemService();
$item_id = $goods['goods_id'];
$goods_num = $goods['goods_num'];
$id = null;
if ($goods['id']) {
$id = $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);
@ -146,17 +146,17 @@ class BuyShopGoodsCbService
}
}
private function getAccountId($address){
private function getAccountId($address)
{
$row = SqlHelper::ormSelectOne
(myself()->_getMysql($address),
$row = SqlHelper::ormSelectOne(
myself()->_getMysql($address),
't_user',
array(
'address' => $address
'address' => $address
)
);
);
return $row['account_id'];
}
}
}