Merge branch 'star' of git.kingsome.cn:server/game2006api into star
This commit is contained in:
commit
cd89285e1e
74
sql/bcnftdb.sql
Normal file
74
sql/bcnftdb.sql
Normal file
@ -0,0 +1,74 @@
|
||||
-- MySQL dump 10.14 Distrib 5.5.41-MariaDB, for Linux (x86_64)
|
||||
--
|
||||
-- Host: localhost Database: bcnft
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 5.5.41-MariaDB
|
||||
|
||||
--
|
||||
-- Table structure for table `version`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `version`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `version` (
|
||||
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`version` int(11) NOT NULL DEFAULT '0' COMMENT '版本号',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `version` (`version`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_nft`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_nft`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_nft` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`owner_address` varchar(60) NOT NULL DEFAULT '' COMMENT 'owner_address',
|
||||
`creator_address` varchar(60) NOT NULL DEFAULT '' COMMENT 'creator_address',
|
||||
`token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id',
|
||||
`token_type` int(11) NOT NULL DEFAULT '0' COMMENT 'nft类型 1:英雄 2:枪支 3:芯片 6:荣誉',
|
||||
`token_state` int(11) NOT NULL DEFAULT '0' COMMENT '0:正常状态 1:出售中 2:出租中',
|
||||
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id',
|
||||
`deleted` int(11) NOT NULL DEFAULT '0' COMMENT 'deleted',
|
||||
`confirm_count` int(11) NOT NULL DEFAULT '0' COMMENT 'confirm_count',
|
||||
`confirm_block_number` bigint NOT NULL DEFAULT '0' COMMENT 'confirm_block_number',
|
||||
`tags` varchar(60) NOT NULL DEFAULT '' COMMENT 'tags',
|
||||
`net_id` bigint NOT NULL DEFAULT '0' COMMENT 'net_id',
|
||||
`contract_address` varchar(60) NOT NULL DEFAULT '' COMMENT 'contract_address',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `unikey` (`net_id`, `contract_address`, `token_id`),
|
||||
KEY `owner_address_token_type` (`owner_address`, `token_type`),
|
||||
KEY `owner_address_contract_address` (`owner_address`, `contract_address`),
|
||||
KEY `owner_address` (`owner_address`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_log`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_log`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_log` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`type` varchar(255) NOT NULL DEFAULT '' COMMENT '日志类型',
|
||||
`subtype` varchar(255) NOT NULL DEFAULT '' COMMENT '日志子类型',
|
||||
`param1` mediumblob COMMENT 'param1',
|
||||
`param2` mediumblob COMMENT 'param2',
|
||||
`param3` mediumblob COMMENT 'param3',
|
||||
`param4` mediumblob COMMENT 'param4',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
-- Dump completed on 2015-08-19 18:51:22
|
@ -443,16 +443,12 @@ class ShopController extends BaseAuthedController
|
||||
public function inappPurchaseDiamonds()
|
||||
{
|
||||
error_log('----- inappPurchaseDiamonds -----');
|
||||
error_log('request:' . json_encode($_REQUEST));
|
||||
error_log('post:' . json_encode($_POST));
|
||||
$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));
|
||||
|
||||
// {
|
||||
// channel: 'google',
|
||||
// sign: '123456677' // 签名字段
|
||||
@ -519,6 +515,7 @@ class ShopController extends BaseAuthedController
|
||||
$this->_rspErr(2, "product_id is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
// $goods = mt\ShopGoods::getByProductId($product_id);
|
||||
|
||||
return;
|
||||
@ -530,7 +527,7 @@ class ShopController extends BaseAuthedController
|
||||
$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'];
|
||||
@ -559,8 +556,47 @@ class ShopController extends BaseAuthedController
|
||||
}
|
||||
break;
|
||||
case 96:
|
||||
$status = 3;
|
||||
if (empty($order_id)) {
|
||||
if (empty($product_id)) {
|
||||
$this->_rspErr(2, "product_id is empty");
|
||||
return;
|
||||
}
|
||||
// $goods = mt\ShopGoods::getByProductId($product_id);
|
||||
|
||||
return;
|
||||
}
|
||||
// 退款
|
||||
$status = 2;
|
||||
$order = SqlHelper::selectOne($conn, 't_web2_order', array('address', 'id', 'item_id', 'goods_num', 'status'), array('order_id' => $order_id, 'status' => 1));
|
||||
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));
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
$this->_decGoods($address, array(
|
||||
'goods_id' => $item_id,
|
||||
'goods_num' => $item_num,
|
||||
'id' => $id,
|
||||
));
|
||||
break;
|
||||
default:
|
||||
$status = 0;
|
||||
@ -594,7 +630,6 @@ class ShopController extends BaseAuthedController
|
||||
$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);
|
||||
if ($id) {
|
||||
@ -602,6 +637,16 @@ class ShopController extends BaseAuthedController
|
||||
}
|
||||
}
|
||||
|
||||
private function _decGoods($address, $goods)
|
||||
{
|
||||
$itemService = new ShopAddItemService();
|
||||
$item_id = $goods['goods_id'];
|
||||
$goods_num = $goods['goods_num'];
|
||||
|
||||
error_log('_decGoods ' . $address . ' item_id ' . $item_id . ' goods_num ' . $goods_num);
|
||||
$itemService->decItem($address, $item_id, $goods_num);
|
||||
}
|
||||
|
||||
public function getPayMethods()
|
||||
{
|
||||
$token_type = getReqVal('token_type', 99);
|
||||
|
@ -72,6 +72,25 @@ class ShopAddItemService
|
||||
|
||||
}
|
||||
|
||||
public function decItem($address, $itemId, $itemNum)
|
||||
{
|
||||
if ($itemNum < 1) {
|
||||
return;
|
||||
}
|
||||
$itemMeta = \mt\Item::get($itemId);
|
||||
if (!$itemMeta) {
|
||||
return;
|
||||
}
|
||||
$accountId = $this->getAccountId($address);
|
||||
$conn = myself()->_getMysql($address);
|
||||
if ($this->_isVirtualItem($itemId)) {
|
||||
$this->_decVirtualItem($conn, $accountId, $itemId, $itemNum);
|
||||
} else {
|
||||
error_log("decItem itemId:$itemId not support");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private function getAccountId($address){
|
||||
|
||||
$row = SqlHelper::ormSelectOne
|
||||
@ -254,6 +273,35 @@ class ShopAddItemService
|
||||
}
|
||||
}
|
||||
|
||||
private function _decVirtualItem($conn, $accountId, $itemId, $itemNum) {
|
||||
if ($itemNum <= 0) {
|
||||
return;
|
||||
}
|
||||
switch ($itemId) {
|
||||
case V_ITEM_GOLD:
|
||||
{
|
||||
$this->_updateUserInfo($conn,$accountId,array(
|
||||
'gold' => function () use($itemNum) {
|
||||
return "gold - ${itemNum}";
|
||||
}
|
||||
));
|
||||
}
|
||||
break;
|
||||
case V_ITEM_DIAMOND:
|
||||
{
|
||||
$this->_updateUserInfo($conn,$accountId,array(
|
||||
'diamond' => function () use($itemNum) {
|
||||
return "diamond - ${itemNum}";
|
||||
}
|
||||
));
|
||||
}
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function _updateUserInfo($conn,$accountId,$fieldsKv)
|
||||
{
|
||||
SqlHelper::update
|
||||
|
Loading…
x
Reference in New Issue
Block a user