From 877fcd0513223ef410855586071935bd5699152b Mon Sep 17 00:00:00 2001 From: songliang Date: Wed, 19 Jul 2023 14:50:58 +0800 Subject: [PATCH 1/9] ... --- webapp/services/LogService.php | 28 ++++++++++++------- .../callback/BuyShopGoodsCbService.php | 2 +- .../services/callback/GameItemMarketBuyOk.php | 18 ++++++++++-- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/webapp/services/LogService.php b/webapp/services/LogService.php index dc0a6854..14d3d120 100644 --- a/webapp/services/LogService.php +++ b/webapp/services/LogService.php @@ -44,7 +44,7 @@ class LogService extends BaseService public static function consumeGold($event,$param = []) { - $logInfo = self::goldRecord($param); + $logInfo = self::goldRecord(myself()->_getAccountId()); $data = self::userInfo(); $data['type'] = self::CONSUME_TYPE; $data['event_name'] = $event['name']; @@ -74,7 +74,7 @@ class LogService extends BaseService public static function productGold($event,$param = []) { - $logInfo = self::goldRecord($param); + $logInfo = self::goldRecord(myself()->_getAccountId()); $data = self::userInfo(); $data['type'] = self::PRODUCT_TYPE; $data['event_name'] = $event['name']; @@ -85,8 +85,22 @@ class LogService extends BaseService $logInfo['properties'] = array_merge($data,$param); TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo); } + public static function productGoldCallback($base, $event,$param = []) + { + $logInfo = self::goldRecord($base['account_id']); + $data = self::userInfoByAccountId($base['account_id']); + $data['type'] = self::PRODUCT_TYPE; + $data['event_name'] = $event['name']; + $data['event_type'] = self::GOLD_TYPE; + $data['event_product'] = 'gold'; + $data['event_product_val'] = $event['val']; - public static function productDiamond($base, $event,$param = []) + $logInfo['properties'] = array_merge($data,$param); + TGLog::writeToLog(self::PRONAME,self::GAMEID,$logInfo); + } + + + public static function productDiamondCallback($base, $event,$param = []) { $logInfo = self::diamondRecord($base['account_id']); $data = self::userInfoByAccountId($base['account_id']); @@ -139,14 +153,8 @@ class LogService extends BaseService ); return $info; } - private static function goldRecord($params = []) + private static function goldRecord($account_id) { - if (isset($params['account_id']) && !empty($params['account_id'])) { - $account_id = $params['account_id']; - } else { - $account_id = myself()->_getAccountId(); - } - // $logInfo['log_class'] = $logInfo['log_class']; // unset($logInfo['log_class']); $data = array( diff --git a/webapp/services/callback/BuyShopGoodsCbService.php b/webapp/services/callback/BuyShopGoodsCbService.php index 12c4965f..963be70b 100644 --- a/webapp/services/callback/BuyShopGoodsCbService.php +++ b/webapp/services/callback/BuyShopGoodsCbService.php @@ -90,7 +90,7 @@ class BuyShopGoodsCbService 'name' => LogService::CEBG_TO_DIAMOND, 'val' => $item_num ]; - LogService::productDiamond(['account_id' => $account_id], $event); + LogService::productDiamondCallback(['account_id' => $account_id], $event); } $this->_addGoods($address, array( diff --git a/webapp/services/callback/GameItemMarketBuyOk.php b/webapp/services/callback/GameItemMarketBuyOk.php index 18ac0951..c06693b3 100644 --- a/webapp/services/callback/GameItemMarketBuyOk.php +++ b/webapp/services/callback/GameItemMarketBuyOk.php @@ -17,7 +17,7 @@ class GameItemMarketBuyOk public function process() { - SignatureService::web3ServiceCheck(); + // SignatureService::web3ServiceCheck(); $itemService = new ShopAddItemService(); $address = getReqVal('address', ''); $orderId = getReqVal('order_id', ''); @@ -116,6 +116,7 @@ class GameItemMarketBuyOk private function buyFromMarket($order, $idx) { $address = $order['address']; + $account_id = $this->getAccountId($address); $goods = $this->getMarketGoods($address, $idx); $this->markMarketGoodsSold($address, $idx); @@ -126,7 +127,7 @@ class GameItemMarketBuyOk 'name' => LogService::MARKET_BUY_GOLD, 'val' => $goods['amount'] ]; - LogService::productGold($event, ['account_id' => $address]); + LogService::productGoldCallback(['account_id' => $account_id], $event ); } } @@ -182,4 +183,17 @@ class GameItemMarketBuyOk 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']; +} } From a03cfa7cfd44289689113b6c1a1abfdebb603b0d Mon Sep 17 00:00:00 2001 From: songliang Date: Wed, 19 Jul 2023 14:54:56 +0800 Subject: [PATCH 2/9] ... --- webapp/services/callback/GameItemMarketBuyOk.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/services/callback/GameItemMarketBuyOk.php b/webapp/services/callback/GameItemMarketBuyOk.php index c06693b3..6427d790 100644 --- a/webapp/services/callback/GameItemMarketBuyOk.php +++ b/webapp/services/callback/GameItemMarketBuyOk.php @@ -17,7 +17,7 @@ class GameItemMarketBuyOk public function process() { - // SignatureService::web3ServiceCheck(); + SignatureService::web3ServiceCheck(); $itemService = new ShopAddItemService(); $address = getReqVal('address', ''); $orderId = getReqVal('order_id', ''); From 3d1c737fbf045c6e40131ca6d57c5686de3c67e9 Mon Sep 17 00:00:00 2001 From: songliang Date: Wed, 19 Jul 2023 16:02:12 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BF=94=E8=BF=98?= =?UTF-8?q?=E4=BA=A4=E6=98=93=E5=B8=82=E5=9C=BA=E8=A2=AB=E9=94=81=E9=87=91?= =?UTF-8?q?=E5=B8=81(=E8=87=AA=E5=8A=A8=E4=B8=8B=E6=9E=B6)sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/giveback_market_gold.sql | 5 +++++ webapp/services/BlockChainService.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 sql/giveback_market_gold.sql diff --git a/sql/giveback_market_gold.sql b/sql/giveback_market_gold.sql new file mode 100644 index 00000000..da1b6c28 --- /dev/null +++ b/sql/giveback_market_gold.sql @@ -0,0 +1,5 @@ +UPDATE t_user o JOIN ( +SELECT owner_address, item_id, SUM(amount) as t FROM t_market_store WHERE `status`=3 AND item_id=10001 GROUP BY owner_address +) t ON o.address = t.owner_address +SET o.gold = o.gold + t.t; +UPDATE t_market_store SET `status`=1 WHERE `status`=3; diff --git a/webapp/services/BlockChainService.php b/webapp/services/BlockChainService.php index a2c16252..6ee9154a 100644 --- a/webapp/services/BlockChainService.php +++ b/webapp/services/BlockChainService.php @@ -173,7 +173,7 @@ class BlockChainService { private static function getWeb3ServiceUrl() { if (SERVER_ENV == _DEBUG) { - return 'https://login-test.kingsome.cn/webapp/index.php'; + return 'https://192.144.140.87/webapp/index.php'; } if (SERVER_ENV == _TEST) { return 'http://127.0.0.1:7672/webapp/index.php'; From 2674dcc27ab3b939a972ea0ccfa2b8dfbed079da Mon Sep 17 00:00:00 2001 From: songliang Date: Wed, 19 Jul 2023 17:02:20 +0800 Subject: [PATCH 4/9] =?UTF-8?q?...=20=E6=AF=8F=E6=97=A5=E7=B2=BE=E9=80=89?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=87=91=E5=B8=81=E8=B4=AD=E4=B9=B0=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/controller/ShopController.class.php | 45 +++++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index fb8da15e..667c0050 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -1201,6 +1201,16 @@ class ShopController extends BaseAuthedController return; } + $token_type = getReqVal('token_type', ''); + switch ($token_type) { + case ShopController::TOKEN_TYPE_GOLD: + case ShopController::TOKEN_TYPE_DIAMOND: + break; + default: + $this->_rspErr(1, "token_type is unsupport, {$token_type}"); + return; + } + $conn = $this->_getMysql(''); $row = SqlHelper::selectOne( @@ -1234,17 +1244,29 @@ class ShopController extends BaseAuthedController $goods = mt\Dailyselection::get($sel_id); - $token_type = $goods['token_type']; + $desired_token_type = $goods['token_type']; + $check_token_type = splitStr1($desired_token_type); + if (!in_array($token_type, $check_token_type)) { + $this->_rspErr(1, "token_type parameter error, desired_token_type: {$desired_token_type}"); + return; + } + $token_pos = array_search($token_type, $check_token_type, true); + + $price_array = splitStr1($goods['price']); + $discount_array = splitStr1($goods['discount']); + + $need_price = $price_array[$token_pos]; + $discount = $discount_array[$token_pos]; + $costItemId = $this->getCostItemIdByTokenType($token_type); - $costItems = $this->makeCostItems($costItemId, $count * $goods['price']); + $costItems = $this->makeCostItems($costItemId, $count * $need_price); $lackItem = null; if (!$this->_hasEnoughItems($costItems, $lackItem)) { $this->_rspErr(2, $this->_getLackItemErrMsg($lackItem)); return; } - $item_id = $goods['goods_id']; $item_num = $goods['goods_num']; @@ -1264,7 +1286,18 @@ class ShopController extends BaseAuthedController 'name' => LogService::SHOP_BUY_ITEM_DAILY, 'val' => $costItems[0]['item_num'] ]; - LogService::consumeDiamond($event); + switch ($token_type) { + case ShopController::TOKEN_TYPE_GOLD: + LogService::consumeGold($event); + break; + case ShopController::TOKEN_TYPE_DIAMOND: + LogService::consumeDiamond($event); + break; + default: + // 这里不应该出现,出现了说明配置表新增了一种货币,但是这里没有处理 + error_log("buyGoodsDS token_type is invalid, token_type: {$token_type}"); + return; + } $goodsDto = array( 'goods_id' => $sel_id, @@ -1275,12 +1308,14 @@ class ShopController extends BaseAuthedController ), 'bought_times' => 0, 'total_buy_times' => 0, - ); { + ); + { $priceInfo = mt\Item::getPriceInfo($itemMeta); if (!empty($priceInfo)) { $goodsDto['price_info'] = $priceInfo['price_info']; } } + $propertyChgService->addUserChg(); $this->_rspData( From 6a5a344f9c5161a57ac56184b2c08c1504d2f9eb Mon Sep 17 00:00:00 2001 From: songliang Date: Wed, 19 Jul 2023 17:07:06 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=AF=8F=E6=97=A5?= =?UTF-8?q?=E7=B2=BE=E9=80=89=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/Shop.py | 1 + doc/_common.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/Shop.py b/doc/Shop.py index 6fa119e5..1161a161 100644 --- a/doc/Shop.py +++ b/doc/Shop.py @@ -279,6 +279,7 @@ class Shop(object): ['idx', 0, '每日精选的索引'], ['grid', 0, '商品在每日精选中的位置索引'], ['count', 0, '购买数量,始终是1'], + ['token_type', '', "选用币种,只能选择一种"], ], 'response': [ _common.RspHead(), diff --git a/doc/_common.py b/doc/_common.py index ebb62205..0c1538f8 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -450,8 +450,9 @@ class DailySelectionGoods(object): ['goods_num', 0, '商品堆叠数量'], ['shop_icon', "", '商品图标'], ['weight', 0, '权重'], - ['discount', 0, '折扣'], - ['price', 0, '价格'], + ['token_type', '', '代币类型(4|0)'], + ['discount', '', '折扣(95|80)'], + ['price', '', '价格(100|100000)'], ['pending', 0, '购买中...'], ] From 111f1840b36d281ca89e90b19fdc5b7690d91f3c Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 25 Jul 2023 15:04:53 +0800 Subject: [PATCH 6/9] ... --- webapp/controller/ShopController.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 667c0050..50136932 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -388,10 +388,15 @@ class ShopController extends BaseAuthedController default: error_log("buyGoodsDirect--- " . $order_id . " --- " . $status); $this->_rspErr(1, "status error, status: {$status}"); - break; + return; } - 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)); + + if ($buyStatus == 2) { + $this->_rspErr(2, "buyStatus error, buyStatus: {$buyStatus}"); + return; + } // 以下是看商品表中是否配置了充值额外奖励 $goods = mt\ShopGoods::get($id); From a1de844a76dd4521c9b8dfcac508dc13b676594c Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 25 Jul 2023 15:11:23 +0800 Subject: [PATCH 7/9] ... --- webapp/controller/ShopController.class.php | 2 +- webapp/services/callback/ShopBuyGoodsDirect.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 50136932..f571c694 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -416,7 +416,7 @@ class ShopController extends BaseAuthedController 'name' => LogService::RECHARGE_CEBG_BONUS, 'val' => $item_num ]; - LogService::productDiamond(['account_id' => $account_id], $event); + LogService::productDiamondCallback(['account_id' => $account_id], $event); } error_log("buyGoodsDirect---" . $address . "---" . $item_id . "---" . $item_num); diff --git a/webapp/services/callback/ShopBuyGoodsDirect.php b/webapp/services/callback/ShopBuyGoodsDirect.php index e4a3ea89..673ded55 100644 --- a/webapp/services/callback/ShopBuyGoodsDirect.php +++ b/webapp/services/callback/ShopBuyGoodsDirect.php @@ -101,7 +101,12 @@ class ShopBuyGoodsDirect 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)); + + if ($buyStatus == 2) { + $this->_rspErr(2, "buyStatus error, buyStatus: {$buyStatus}"); + return; + } // 以下是看商品表中是否配置了充值额外奖励 $goods = ShopGoods::get($id); @@ -121,7 +126,7 @@ class ShopBuyGoodsDirect 'name' => LogService::RECHARGE_CEBG_BONUS, 'val' => $item_num ]; - LogService::productDiamond(['account_id' => $account_id], $event); + LogService::productDiamondCallback(['account_id' => $account_id], $event); } error_log("buyGoodsDirect---" . $address . "---" . $item_id . "---" . $item_num); From 947d21b308b413326349ffc0d37f5c9162631c40 Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 25 Jul 2023 15:13:57 +0800 Subject: [PATCH 8/9] ... --- webapp/controller/ShopController.class.php | 4 ++-- webapp/services/callback/ShopInappPurchaseDiamonds.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index f571c694..f227cdcf 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -627,7 +627,7 @@ class ShopController extends BaseAuthedController 'name' => LogService::RECHARGE_DIAMOND, 'val' => $item_num ]; - LogService::productDiamond(['account_id' => $account_id], $event); + LogService::productDiamondCallback(['account_id' => $account_id], $event); } $this->_addGoods($address, array( @@ -679,7 +679,7 @@ class ShopController extends BaseAuthedController 'name' => LogService::RECHARGE_DIAMOND, 'val' => -$item_num ]; - LogService::productDiamond(['account_id' => $account_id], $event); + LogService::productDiamondCallback(['account_id' => $account_id], $event); } $this->_decGoods($address, array( diff --git a/webapp/services/callback/ShopInappPurchaseDiamonds.php b/webapp/services/callback/ShopInappPurchaseDiamonds.php index ef744ed1..42f575f2 100644 --- a/webapp/services/callback/ShopInappPurchaseDiamonds.php +++ b/webapp/services/callback/ShopInappPurchaseDiamonds.php @@ -130,7 +130,7 @@ class ShopInappPurchaseDiamonds 'name' => LogService::RECHARGE_DIAMOND, 'val' => $item_num ]; - LogService::productDiamond(['account_id' => $account_id], $event); + LogService::productDiamondCallback(['account_id' => $account_id], $event); } $this->_addGoods($address, array( @@ -182,7 +182,7 @@ class ShopInappPurchaseDiamonds 'name' => LogService::RECHARGE_DIAMOND, 'val' => -$item_num ]; - LogService::productDiamond(['account_id' => $account_id], $event); + LogService::productDiamondCallback(['account_id' => $account_id], $event); } $this->_decGoods($address, array( From 332d8d6e09f2ec9d55df2d9f587b65fc39256b56 Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 25 Jul 2023 15:43:13 +0800 Subject: [PATCH 9/9] ... --- webapp/controller/ShopController.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index f227cdcf..ad84e0df 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -1266,6 +1266,9 @@ class ShopController extends BaseAuthedController $costItemId = $this->getCostItemIdByTokenType($token_type); $costItems = $this->makeCostItems($costItemId, $count * $need_price); + + error_log("buyGoodsDS costItems " . json_encode($costItems)); + $lackItem = null; if (!$this->_hasEnoughItems($costItems, $lackItem)) { $this->_rspErr(2, $this->_getLackItemErrMsg($lackItem));