From 373a69415e0e81f474e9a7add6c3a9c162f4b806 Mon Sep 17 00:00:00 2001 From: songliang Date: Mon, 10 Jul 2023 20:32:36 +0800 Subject: [PATCH 01/22] ... --- webapp/controller/ShopController.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 24b49c9b..a75945ea 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -447,8 +447,9 @@ class ShopController extends BaseAuthedController public function inappPurchaseDiamonds() { - error_log(json_encode($_REQUEST)); - + error_log('request:' . json_encode($_REQUEST)); + error_log('post:' . json_encode($_POST)); + $order_id = getReqVal('order_id', ''); // { // channel: 'google', From d73c76cc1e3feb2f00001cbfe3ea7a45803ff85d Mon Sep 17 00:00:00 2001 From: songliang Date: Mon, 10 Jul 2023 20:56:02 +0800 Subject: [PATCH 02/22] ... --- webapp/controller/ShopController.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index a75945ea..658a1722 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -446,9 +446,12 @@ class ShopController extends BaseAuthedController public function inappPurchaseDiamonds() { - error_log('request:' . json_encode($_REQUEST)); - error_log('post:' . json_encode($_POST)); + $channel = getReqVal('channel', ''); + $records = getReqVal('records', ''); + $records_json = json_decode($records); + + error_log('records:' . json_encode($records_json)); $order_id = getReqVal('order_id', ''); // { From 41fd3a27152e81a81a0ef082d491837ba00f9690 Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 10:21:40 +0800 Subject: [PATCH 03/22] ... --- webapp/controller/ShopController.class.php | 124 +++++++++++++-------- 1 file changed, 80 insertions(+), 44 deletions(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 658a1722..2dc47a68 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -420,7 +420,7 @@ class ShopController extends BaseAuthedController // gen order id $order_id_base = date('YmdHis') . "10000000"; $divIdx = ($lastId) % 9999999; - + $order_id = bnAdd_s($order_id_base, $divIdx); $test = SqlHelper::update($conn, 't_web2_order', array('idx' => $lastId), array('order_id' => $order_id)); if (!$test) { @@ -446,14 +446,15 @@ class ShopController extends BaseAuthedController public function inappPurchaseDiamonds() { + error_log('----- inappPurchaseDiamonds -----'); error_log('request:' . json_encode($_REQUEST)); $channel = getReqVal('channel', ''); $records = getReqVal('records', ''); - $records_json = json_decode($records); + $records_json = json_decode($records, true); + $sign = getReqVal('sign', ''); error_log('records:' . json_encode($records_json)); - $order_id = getReqVal('order_id', ''); // { // channel: 'google', // sign: '123456677' // 签名字段 @@ -473,63 +474,98 @@ class ShopController extends BaseAuthedController // const sign = hmacsha256(signStr, hashSort) + // 定义一个空数组,用来存放每个记录的键值对字符串 + $record_strings = array(); + + // 遍历 records 数组,对每个记录进行排序和拼接 + foreach ($records_json as $record) { + // 对记录的键进行升序排序 + ksort($record); + // 把记录的键值对用等号连接,然后用 & 连接成一个字符串 + $record_string = http_build_query($record); + // 把字符串加入到 record_strings 数组中 + $record_strings[] = $record_string; + } + + // 把 record_strings 数组用 & 连接成一个字符串 + $records_string = implode("&", $record_strings); + + $hash_data = 'channel=' . $channel . '&' . $records_string; + + $signature = hash_hmac('sha256', $hash_data, 'iG4Rpsa)6U31$H#^T85$^^3'); + + if ($signature != $sign) { + $this->_rspErr(1, "signature error, signature: {$signature}, sign: {$sign}"); + return; + } + // 有三种情况: // 1. 从商城购买钻石,有订单号 // 2. 站外充值钻石,没有订单号 // 3. appstore 退款,没有订单号 - $order_id = getReqVal('order_id', ''); + for ($i = 0; $i < count($records_json); $i++) { + $record = $records_json[$i]; - error_log('----- inappPurchaseDiamonds -----'); + $product_id = $record['productId']; + $order_id = $record['gameOrderId']; + $out_order_id = $record['orderId']; + $status = $record['status']; - $data = [ - 'channel' => 'google', - 'sign' => '123456677', - 'records' => [[ - 'productId' => '2999', // 从google play console获取的product id - 'gameOrderId' => '299', // 开始支付时, 从游戏相关服务那获得的订单id - 'orderId' => 'GPA.3355-1172-9416-16839', // 从google develope API 获取的订单id - 'status' => 9, // 订单状态, 上报的订单状态一般只有2种情况, 9: 支付成功, 96: 用户退款 - ]] - ]; + switch ($status) { + case 9: { + $status = 1; + if (empty($order_id)) { + if (empty($product_id)) { + $this->_rspErr(2, "product_id is empty"); + return; + } + // $goods = mt\ShopGoods::getByProductId($product_id); - $order_id = $data['records'][0]['gameOrderId']; - $data_str = json_encode($data); - $data_json = json_decode($data_str, true); - error_log('----- inappPurchaseDiamonds -----' . json_encode($data)); + return; + } - $conn = myself()->_getMysql(''); + $conn = myself()->_getMysql(''); - $order = SqlHelper::selectOne($conn, 't_shop_buy_order', array('address', 'id', 'item_id', 'goods_num', 'status'), array('idx' => $order_id)); + $order = SqlHelper::selectOne($conn, 't_web2_order', array('address', 'id', 'item_id', 'goods_num', 'status'), array('idx' => $order_id)); - $buyStatus = 1; + SqlHelper::update($conn, 't_web2_order', array('idx' => $order_id), array('status' => $status, 'channel' => $channel, 'out_order_id' => $out_order_id)); - SqlHelper::update($conn, 't_shop_buy_order', array('idx' => $order_id), array('status' => $buyStatus)); + $id = $order['id']; + $goods = mt\ShopGoods::get($id); + // 这里命名混乱了, 购买个数,一捆个数命名冲突 + $goods_num = $order['goods_num']; + $bundle_size = $goods['goods_num']; + $item_num = $goods_num * $bundle_size; + $item_id = $goods['goods_id']; + $address = $order['address']; + $account_id = $this->getAccountId($address); - $id = $order['id']; - $goods = mt\ShopGoods::get($id); - // 这里命名混乱了, 购买个数,一捆个数命名冲突 - $goods_num = $order['goods_num']; - $bundle_size = $goods['goods_num']; - $item_num = $goods_num * $bundle_size; - $item_id = $goods['goods_id']; - $address = $order['address']; - $account_id = $this->getAccountId($address); + if ($item_id == V_ITEM_DIAMOND) { + $event = [ + 'name' => LogService::RECHARGE_DIAMOND, + 'val' => $item_num + ]; + LogService::productDiamond(['account_id' => $account_id], $event); + } - if ($item_id == V_ITEM_DIAMOND) { - $event = [ - 'name' => LogService::RECHARGE_DIAMOND, - 'val' => $item_num - ]; - LogService::productDiamond(['account_id' => $account_id], $event); + $this->_addGoods($address, array( + 'goods_id' => $item_id, + 'goods_num' => $item_num, + 'id' => $id, + )); + } + break; + case 96: + // 退款 + $status = 2; + break; + default: + $status = 0; + break; + } } - $this->_addGoods($address, array( - 'goods_id' => $item_id, - 'goods_num' => $item_num, - 'id' => $id, - )); - $this->_rspOk(); } From 703d40c9eb4bc76dda7173ce3f8eefef2d953b92 Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 10:32:57 +0800 Subject: [PATCH 04/22] ... --- sql/gamedb.sql | 21 +++++++++++++++++++++ sql/gamedb2006_migrate_230710_01.sql | 20 ++++++++++++++++++++ webapp/controller/ShopController.class.php | 5 ++--- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 4acc6b22..b363e703 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -1267,3 +1267,24 @@ CREATE TABLE `t_user_honor` ( UNIQUE KEY `address` (`address`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; + +DROP TABLE IF EXISTS `t_web2_order`; +CREATE TABLE `t_web2_order` ( + `idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id', + `status` int(11) NOT NULL COMMENT '订单状态 0-客户端申请了订单 1-订单完成 2-订单失败', + `order_id` varchar(64) DEFAULT NULL COMMENT '订单id', + `createtime` datetime NOT NULL COMMENT '创建时间', + `account_Id` varchar(64) NOT NULL COMMENT '申请账号id', + `address` varchar(64) DEFAULT NULL COMMENT '申请时账号绑定的钱包', + `item_id` int(11) NOT NULL COMMENT '物品id', + `item_num` int(11) NOT NULL COMMENT '物品数量', + `id` int(11) NOT NULL COMMENT '商店中的配置id,', + `goods_num` int(11) NOT NULL COMMENT '购买商品个数', + `price` varchar(64) DEFAULT NULL COMMENT '价格', + `ext_data` mediumblob COMMENT '扩展自定义数据', + `channel` varchar(64) DEFAULT NULL COMMENT 'google or apple', + `out_order_id` varchar(64) DEFAULT NULL COMMENT 'app store order_id', + PRIMARY KEY (`idx`), + UNIQUE KEY `order_id` (`order_id`) USING HASH, + KEY `out_order_id` (`out_order_id`) +) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8; \ No newline at end of file diff --git a/sql/gamedb2006_migrate_230710_01.sql b/sql/gamedb2006_migrate_230710_01.sql index 5b4f2db2..fa532b73 100644 --- a/sql/gamedb2006_migrate_230710_01.sql +++ b/sql/gamedb2006_migrate_230710_01.sql @@ -14,6 +14,26 @@ CREATE TABLE `t_user_honor` ( UNIQUE KEY `address` (`address`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +CREATE TABLE `t_web2_order` ( + `idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id', + `status` int(11) NOT NULL COMMENT '订单状态 0-客户端申请了订单 1-订单完成 2-订单失败', + `order_id` varchar(64) DEFAULT NULL COMMENT '订单id', + `createtime` datetime NOT NULL COMMENT '创建时间', + `account_Id` varchar(64) NOT NULL COMMENT '申请账号id', + `address` varchar(64) DEFAULT NULL COMMENT '申请时账号绑定的钱包', + `item_id` int(11) NOT NULL COMMENT '物品id', + `item_num` int(11) NOT NULL COMMENT '物品数量', + `id` int(11) NOT NULL COMMENT '商店中的配置id,', + `goods_num` int(11) NOT NULL COMMENT '购买商品个数', + `price` varchar(64) DEFAULT NULL COMMENT '价格', + `ext_data` mediumblob COMMENT '扩展自定义数据', + `channel` varchar(64) DEFAULT NULL COMMENT 'google or apple', + `out_order_id` varchar(64) DEFAULT NULL COMMENT 'app store order_id', + PRIMARY KEY (`idx`), + UNIQUE KEY `order_id` (`order_id`) USING HASH, + KEY `out_order_id` (`out_order_id`) +) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8; + insert into version (version) values(2023071001); commit; \ No newline at end of file diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 2dc47a68..28adcaab 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -499,6 +499,7 @@ class ShopController extends BaseAuthedController return; } + $conn = myself()->_getMysql(''); // 有三种情况: // 1. 从商城购买钻石,有订单号 // 2. 站外充值钻石,没有订单号 @@ -525,10 +526,8 @@ class ShopController extends BaseAuthedController return; } - $conn = myself()->_getMysql(''); - $order = SqlHelper::selectOne($conn, 't_web2_order', array('address', 'id', 'item_id', 'goods_num', 'status'), array('idx' => $order_id)); - + error_log('process order '. json_encode($order)); SqlHelper::update($conn, 't_web2_order', array('idx' => $order_id), array('status' => $status, 'channel' => $channel, 'out_order_id' => $out_order_id)); $id = $order['id']; From 31fff493af6544e2d2d14fbbfa55296d29d89cff Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 10:47:40 +0800 Subject: [PATCH 05/22] ... --- doc/Shop.py | 13 +++++++++++++ doc/_common.py | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/doc/Shop.py b/doc/Shop.py index ec019caf..cac3fa32 100644 --- a/doc/Shop.py +++ b/doc/Shop.py @@ -208,6 +208,19 @@ class Shop(object): ['status', 0, '订单状态 0:未支付 1:已支付 2:支付失败'], ] }, + { + 'name':'inappPurchaseDiamonds', + 'desc': '内购回调', + 'group': 'Shop', + 'url': 'webapp/index.php?c=Shop&a=inappPurchaseDiamonds', + 'params': [ + ['channel', '', '渠道 goole or apple'], + ['!records' [_common.InappPurchaseRecord()], '购买记录'], + ], + 'response': [ + _common.RspHead(), + ] + }, { 'name': 'getPayMethods', 'desc': '获取支付方式', diff --git a/doc/_common.py b/doc/_common.py index b82060f4..ebb62205 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1236,4 +1236,13 @@ class BlindBoxResult(object): self.fields = [ ['item_id', 0, 'item_id'], ['item_num', 0, 'item_num'], + ] + +class InappPurchaseRecord(object): + def __init__(self): + self.fields = [ + ['productId', '', '商品id'], + ['gameOrderId', '', '游戏订单id'], + ['orderId', '', 'google订单id'], + ['status', 0, '订单状态'], ] \ No newline at end of file From 56a746970b72a61ddd789918d210c29013743897 Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 10:51:27 +0800 Subject: [PATCH 06/22] ... --- doc/_common.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/_common.py b/doc/_common.py index ebb62205..c1054cdf 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1241,8 +1241,8 @@ class BlindBoxResult(object): class InappPurchaseRecord(object): def __init__(self): self.fields = [ - ['productId', '', '商品id'], - ['gameOrderId', '', '游戏订单id'], - ['orderId', '', 'google订单id'], - ['status', 0, '订单状态'], + # ['productId', '', '商品id'], + # ['gameOrderId', '', '游戏订单id'], + # ['orderId', '', 'google订单id'], + # ['status', 0, '订单状态'], ] \ No newline at end of file From fa1d4e3324f5fa991cc90197ebdaabb18dc828b3 Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 10:52:12 +0800 Subject: [PATCH 07/22] ... --- doc/Shop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Shop.py b/doc/Shop.py index cac3fa32..36a3fe9d 100644 --- a/doc/Shop.py +++ b/doc/Shop.py @@ -215,7 +215,7 @@ class Shop(object): 'url': 'webapp/index.php?c=Shop&a=inappPurchaseDiamonds', 'params': [ ['channel', '', '渠道 goole or apple'], - ['!records' [_common.InappPurchaseRecord()], '购买记录'], + ['records' [_common.InappPurchaseRecord()], '购买记录'], ], 'response': [ _common.RspHead(), From 7a35a162e66f9e0e23c461bfbaa3860d22ef027d Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 10:59:21 +0800 Subject: [PATCH 08/22] ... --- doc/Shop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Shop.py b/doc/Shop.py index 36a3fe9d..857633c6 100644 --- a/doc/Shop.py +++ b/doc/Shop.py @@ -215,7 +215,7 @@ class Shop(object): 'url': 'webapp/index.php?c=Shop&a=inappPurchaseDiamonds', 'params': [ ['channel', '', '渠道 goole or apple'], - ['records' [_common.InappPurchaseRecord()], '购买记录'], + ['records' '', '购买记录 [{productId:2999,gameOrderId:14,orderId:GPA.3300-1417-5598-53875,status:9}]'], ], 'response': [ _common.RspHead(), From 931cb9f2e1b9aba2d3c01e484b7f8a470167430b Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 11:00:37 +0800 Subject: [PATCH 09/22] ... --- doc/Shop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Shop.py b/doc/Shop.py index 857633c6..6d1d7e07 100644 --- a/doc/Shop.py +++ b/doc/Shop.py @@ -215,7 +215,7 @@ class Shop(object): 'url': 'webapp/index.php?c=Shop&a=inappPurchaseDiamonds', 'params': [ ['channel', '', '渠道 goole or apple'], - ['records' '', '购买记录 [{productId:2999,gameOrderId:14,orderId:GPA.3300-1417-5598-53875,status:9}]'], + ['records' '', '购买记录 [{\"productId\":\"2999\",\"gameOrderId\":\"14\",\"orderId\":\"GPA.3300-1417-5598-53875\",\"status\":9}]'], ], 'response': [ _common.RspHead(), From 266d6fbc706667a8f473c11468073cd0ed73e465 Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 11:02:03 +0800 Subject: [PATCH 10/22] ... --- doc/Shop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Shop.py b/doc/Shop.py index 6d1d7e07..db6d20eb 100644 --- a/doc/Shop.py +++ b/doc/Shop.py @@ -215,7 +215,7 @@ class Shop(object): 'url': 'webapp/index.php?c=Shop&a=inappPurchaseDiamonds', 'params': [ ['channel', '', '渠道 goole or apple'], - ['records' '', '购买记录 [{\"productId\":\"2999\",\"gameOrderId\":\"14\",\"orderId\":\"GPA.3300-1417-5598-53875\",\"status\":9}]'], + ['records' '', '购买记录 \[{\"productId\":\"2999\",\"gameOrderId\":\"14\",\"orderId\":\"GPA.3300-1417-5598-53875\",\"status\":9}\]'], ], 'response': [ _common.RspHead(), From 48dff4700175480613ac066399b697e816590524 Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 11:04:28 +0800 Subject: [PATCH 11/22] ... --- doc/Shop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Shop.py b/doc/Shop.py index db6d20eb..e9f020dd 100644 --- a/doc/Shop.py +++ b/doc/Shop.py @@ -215,7 +215,7 @@ class Shop(object): 'url': 'webapp/index.php?c=Shop&a=inappPurchaseDiamonds', 'params': [ ['channel', '', '渠道 goole or apple'], - ['records' '', '购买记录 \[{\"productId\":\"2999\",\"gameOrderId\":\"14\",\"orderId\":\"GPA.3300-1417-5598-53875\",\"status\":9}\]'], + ['records' '', '购买记录 \[{"productId":"2999","gameOrderId":"14","orderId":"GPA.3300-1417-5598-53875","status":9}\]'], ], 'response': [ _common.RspHead(), From 6385147133e6ecef914f1351a5847ca45881bbc7 Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 11:06:58 +0800 Subject: [PATCH 12/22] ... --- doc/Shop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Shop.py b/doc/Shop.py index e9f020dd..e54bcdce 100644 --- a/doc/Shop.py +++ b/doc/Shop.py @@ -215,7 +215,7 @@ class Shop(object): 'url': 'webapp/index.php?c=Shop&a=inappPurchaseDiamonds', 'params': [ ['channel', '', '渠道 goole or apple'], - ['records' '', '购买记录 \[{"productId":"2999","gameOrderId":"14","orderId":"GPA.3300-1417-5598-53875","status":9}\]'], + ['records' '', '购买记录 [{"productId":"2999","gameOrderId":"14","orderId":"GPA.3300-1417-5598-53875","status":9}]'], ], 'response': [ _common.RspHead(), From b2563fd540b5000cceac9019b5cd4054f9d721f7 Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 11:07:29 +0800 Subject: [PATCH 13/22] ... --- doc/Shop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Shop.py b/doc/Shop.py index e54bcdce..ac7a24bf 100644 --- a/doc/Shop.py +++ b/doc/Shop.py @@ -215,7 +215,7 @@ class Shop(object): 'url': 'webapp/index.php?c=Shop&a=inappPurchaseDiamonds', 'params': [ ['channel', '', '渠道 goole or apple'], - ['records' '', '购买记录 [{"productId":"2999","gameOrderId":"14","orderId":"GPA.3300-1417-5598-53875","status":9}]'], + ['records' '', '购买记录 [\{"productId":"2999","gameOrderId":"14","orderId":"GPA.3300-1417-5598-53875","status":9\}]'], ], 'response': [ _common.RspHead(), From a31a551deb7defd0aa3fa27fa419b4774aa92a37 Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 11:09:21 +0800 Subject: [PATCH 14/22] ... --- webapp/controller/ShopController.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 28adcaab..0b94d1ed 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -526,9 +526,9 @@ class ShopController extends BaseAuthedController return; } - $order = SqlHelper::selectOne($conn, 't_web2_order', array('address', 'id', 'item_id', 'goods_num', 'status'), array('idx' => $order_id)); + $order = SqlHelper::selectOne($conn, 't_web2_order', array('address', 'id', 'item_id', 'goods_num', 'status'), array('order_id' => $order_id)); error_log('process order '. json_encode($order)); - SqlHelper::update($conn, 't_web2_order', array('idx' => $order_id), array('status' => $status, 'channel' => $channel, 'out_order_id' => $out_order_id)); + SqlHelper::update($conn, 't_web2_order', array('order_id' => $order_id), array('status' => $status, 'channel' => $channel, 'out_order_id' => $out_order_id)); $id = $order['id']; $goods = mt\ShopGoods::get($id); From 57b3ec4193567d3b7770012f3663bd495fe979ae Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 11:15:02 +0800 Subject: [PATCH 15/22] ... --- webapp/controller/ShopController.class.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 0b94d1ed..653e0c89 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -50,10 +50,6 @@ use models\BcOrder; use services\LogService; use services\ShopAddItemService; -use function phpcommon\bnAdd_s; -use function phpcommon\bnDiv_s; -use function phpcommon\bnInit; - if (!function_exists('array_column')) { function array_column($arr2, $column_key) { @@ -421,7 +417,7 @@ class ShopController extends BaseAuthedController $order_id_base = date('YmdHis') . "10000000"; $divIdx = ($lastId) % 9999999; - $order_id = bnAdd_s($order_id_base, $divIdx); + $order_id = phpcommon\bnAdd_s($order_id_base, $divIdx); $test = SqlHelper::update($conn, 't_web2_order', array('idx' => $lastId), array('order_id' => $order_id)); if (!$test) { $this->_rspErr(5, "start purchase failed"); From e4417d05842bcebe2ae5a6775380b213865fa1fe Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 11:17:38 +0800 Subject: [PATCH 16/22] ... --- webapp/controller/ShopController.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 653e0c89..df12d60a 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -444,6 +444,7 @@ class ShopController extends BaseAuthedController { error_log('----- inappPurchaseDiamonds -----'); error_log('request:' . json_encode($_REQUEST)); + error_log('post:' . json_encode($_POST)); $channel = getReqVal('channel', ''); $records = getReqVal('records', ''); $records_json = json_decode($records, true); From 5d59f457e720aa09c2ea4c342902c09e12dedb7a Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 11:31:00 +0800 Subject: [PATCH 17/22] ... --- webapp/controller/ShopController.class.php | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index df12d60a..52c3d739 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -445,12 +445,13 @@ class ShopController extends BaseAuthedController error_log('----- inappPurchaseDiamonds -----'); error_log('request:' . json_encode($_REQUEST)); error_log('post:' . json_encode($_POST)); - $channel = getReqVal('channel', ''); - $records = getReqVal('records', ''); - $records_json = json_decode($records, true); - $sign = getReqVal('sign', ''); + $body = json_decode(file_get_contents('php://input'), true); + error_log('body:' . json_encode($body)); + $channel = $body['channel']; + $records = $body['records']; + $sign = $body['sign']; - error_log('records:' . json_encode($records_json)); + error_log('records:' . json_encode($records)); // { // channel: 'google', @@ -475,7 +476,7 @@ class ShopController extends BaseAuthedController $record_strings = array(); // 遍历 records 数组,对每个记录进行排序和拼接 - foreach ($records_json as $record) { + foreach ($records as $record) { // 对记录的键进行升序排序 ksort($record); // 把记录的键值对用等号连接,然后用 & 连接成一个字符串 @@ -502,8 +503,8 @@ class ShopController extends BaseAuthedController // 2. 站外充值钻石,没有订单号 // 3. appstore 退款,没有订单号 - for ($i = 0; $i < count($records_json); $i++) { - $record = $records_json[$i]; + for ($i = 0; $i < count($records); $i++) { + $record = $records[$i]; $product_id = $record['productId']; $order_id = $record['gameOrderId']; @@ -523,8 +524,13 @@ class ShopController extends BaseAuthedController return; } - $order = SqlHelper::selectOne($conn, 't_web2_order', array('address', 'id', 'item_id', 'goods_num', 'status'), array('order_id' => $order_id)); + $order = SqlHelper::selectOne($conn, 't_web2_order', array('address', 'id', 'item_id', 'goods_num', 'status'), array('order_id' => $order_id, 'status' => 0)); error_log('process order '. json_encode($order)); + if (!$order) { + $this->_rspErr(3, "order not found, order_id: {$order_id}"); + return; + } + SqlHelper::update($conn, 't_web2_order', array('order_id' => $order_id), array('status' => $status, 'channel' => $channel, 'out_order_id' => $out_order_id)); $id = $order['id']; From 631d4cd1e3a0d69b73c33c0233996de6ea8bb00b Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 11:53:04 +0800 Subject: [PATCH 18/22] ... --- doc/Shop.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/Shop.py b/doc/Shop.py index ac7a24bf..65ca1b3a 100644 --- a/doc/Shop.py +++ b/doc/Shop.py @@ -215,7 +215,8 @@ class Shop(object): 'url': 'webapp/index.php?c=Shop&a=inappPurchaseDiamonds', 'params': [ ['channel', '', '渠道 goole or apple'], - ['records' '', '购买记录 [\{"productId":"2999","gameOrderId":"14","orderId":"GPA.3300-1417-5598-53875","status":9\}]'], + ['records' '', '购买记录 {"productId":"2999","gameOrderId":"14","orderId":"GPA.3300-1417-5598-53875","status":9}'], + ['sign', '', '签名'] ], 'response': [ _common.RspHead(), From 0c96cb8039df4cbb1e72a302dbcd71b199fb751e Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 11:55:20 +0800 Subject: [PATCH 19/22] ... --- doc/Shop.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/Shop.py b/doc/Shop.py index 65ca1b3a..39b6eaf9 100644 --- a/doc/Shop.py +++ b/doc/Shop.py @@ -215,7 +215,8 @@ class Shop(object): 'url': 'webapp/index.php?c=Shop&a=inappPurchaseDiamonds', 'params': [ ['channel', '', '渠道 goole or apple'], - ['records' '', '购买记录 {"productId":"2999","gameOrderId":"14","orderId":"GPA.3300-1417-5598-53875","status":9}'], + ['!records', [_common.InappPurchaseRecord()], '购买记录'] + # ['productId':"2999","gameOrderId":"14","orderId":"GPA.3300-1417-5598-53875","status":9}'], ['sign', '', '签名'] ], 'response': [ From e527e9e3042bb752bc4d09faee797aceaf1c1819 Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 11:55:46 +0800 Subject: [PATCH 20/22] ... --- doc/Shop.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/Shop.py b/doc/Shop.py index 39b6eaf9..fe63a773 100644 --- a/doc/Shop.py +++ b/doc/Shop.py @@ -215,9 +215,8 @@ class Shop(object): 'url': 'webapp/index.php?c=Shop&a=inappPurchaseDiamonds', 'params': [ ['channel', '', '渠道 goole or apple'], - ['!records', [_common.InappPurchaseRecord()], '购买记录'] - # ['productId':"2999","gameOrderId":"14","orderId":"GPA.3300-1417-5598-53875","status":9}'], - ['sign', '', '签名'] + ['!records', [_common.InappPurchaseRecord()], '购买记录'], + ['sign', '', '签名'], ], 'response': [ _common.RspHead(), From 09b28c5325f9fc9b333ae4518acaef0d220ed487 Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 11:56:57 +0800 Subject: [PATCH 21/22] ... --- doc/_common.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/_common.py b/doc/_common.py index c1054cdf..ebb62205 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1241,8 +1241,8 @@ class BlindBoxResult(object): class InappPurchaseRecord(object): def __init__(self): self.fields = [ - # ['productId', '', '商品id'], - # ['gameOrderId', '', '游戏订单id'], - # ['orderId', '', 'google订单id'], - # ['status', 0, '订单状态'], + ['productId', '', '商品id'], + ['gameOrderId', '', '游戏订单id'], + ['orderId', '', 'google订单id'], + ['status', 0, '订单状态'], ] \ No newline at end of file From f3e609d9106ad3c3d60effdeb944499401aaef05 Mon Sep 17 00:00:00 2001 From: songliang Date: Tue, 11 Jul 2023 11:59:10 +0800 Subject: [PATCH 22/22] ... --- doc/Shop.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/Shop.py b/doc/Shop.py index fe63a773..6fa119e5 100644 --- a/doc/Shop.py +++ b/doc/Shop.py @@ -215,8 +215,12 @@ class Shop(object): 'url': 'webapp/index.php?c=Shop&a=inappPurchaseDiamonds', 'params': [ ['channel', '', '渠道 goole or apple'], - ['!records', [_common.InappPurchaseRecord()], '购买记录'], ['sign', '', '签名'], + ['records', '', '购买记录,以下字段是一个record的表示'], + ['productId', '', '商品id'], + ['gameOrderId', '', '游戏订单id'], + ['orderId', '', 'google订单id'], + ['status', 0, '订单状态'], ], 'response': [ _common.RspHead(),