From 12ac97878c6eab51e5459125770dd3dd5eb1623a Mon Sep 17 00:00:00 2001 From: songliang Date: Fri, 7 Jul 2023 14:57:31 +0800 Subject: [PATCH] ... --- webapp/controller/ShopController.class.php | 37 ++++++++++++++++++- .../callback/BuyShopGoodsCbService.php | 20 +++++----- 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 2c616733..fdea0e17 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -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++) { diff --git a/webapp/services/callback/BuyShopGoodsCbService.php b/webapp/services/callback/BuyShopGoodsCbService.php index c3e82177..ef61194e 100644 --- a/webapp/services/callback/BuyShopGoodsCbService.php +++ b/webapp/services/callback/BuyShopGoodsCbService.php @@ -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']; -} - + } }