1
This commit is contained in:
parent
d26d140678
commit
230be5d2ad
@ -18,6 +18,8 @@ class InGameMall(object):
|
|||||||
['order_method', 0, '排序方式 0:默认排序(当前指向1) 1:上架时间 2:价格'],
|
['order_method', 0, '排序方式 0:默认排序(当前指向1) 1:上架时间 2:价格'],
|
||||||
['order_asc', 0, '排序方向, 0:从小到大 1:从大到小'],
|
['order_asc', 0, '排序方向, 0:从小到大 1:从大到小'],
|
||||||
['price_filter', '', '价格过滤(用|分割)'],
|
['price_filter', '', '价格过滤(用|分割)'],
|
||||||
|
['type_filter', '', '类型过滤 1:英雄 2:芯片 3:碎片 4:宝箱'],
|
||||||
|
['item_filter', '', 'itemId过滤'],
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
@ -32,7 +34,8 @@ class InGameMall(object):
|
|||||||
'url': 'webapp/index.php?c=InGameMall&a=sell',
|
'url': 'webapp/index.php?c=InGameMall&a=sell',
|
||||||
'params': [
|
'params': [
|
||||||
_common.ReqHead(),
|
_common.ReqHead(),
|
||||||
['item_id', '', '道具id'],
|
['goods_uniid', '', '道具id'],
|
||||||
|
['item_id', '', '道具itemId'],
|
||||||
['amount', '', '出售数量'],
|
['amount', '', '出售数量'],
|
||||||
['price', '', '出售价格'],
|
['price', '', '出售价格'],
|
||||||
],
|
],
|
||||||
|
@ -1362,14 +1362,12 @@ class InGameMallGoods(object):
|
|||||||
self.fields = [
|
self.fields = [
|
||||||
['seller', '', '出售方账号'],
|
['seller', '', '出售方账号'],
|
||||||
['seller_address', '', '出售方钱包地址'],
|
['seller_address', '', '出售方钱包地址'],
|
||||||
|
['goods_uniid', '', '商品唯一id'],
|
||||||
['item_id', '', '商品道具id'],
|
['item_id', '', '商品道具id'],
|
||||||
['item_num', '', '道具数量'],
|
['item_num', '', '道具数量'],
|
||||||
['currency', '', "选用币种 目前只支持CEG USDC USDT"],
|
|
||||||
['price', '', '出售价格'],
|
['price', '', '出售价格'],
|
||||||
['selltime', 0, '上架时间'],
|
['createtime', 0, '上架时间'],
|
||||||
['updatetime', 0, '修改时间(更新价格等)'],
|
['last_modify_price_time', 0, '修改时间(更新价格等)'],
|
||||||
['cancel_countdown', 0, '可下架时间倒计时:-1不可下架'],
|
|
||||||
['modify_countdown', 0, '可修改价格倒计时:-1不可修改价格'],
|
|
||||||
]
|
]
|
||||||
|
|
||||||
class ComputingPowerCurr(object):
|
class ComputingPowerCurr(object):
|
||||||
|
@ -1419,7 +1419,7 @@ CREATE TABLE `t_mall` (
|
|||||||
UNIQUE KEY `goods_uuid` (`goods_uuid`)
|
UNIQUE KEY `goods_uuid` (`goods_uuid`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `t_ingame_mall`
|
-- Table structure for table `t_ingame_mall`
|
||||||
--
|
--
|
||||||
@ -1430,17 +1430,17 @@ DROP TABLE IF EXISTS `t_ingame_mall`;
|
|||||||
CREATE TABLE `t_ingame_mall` (
|
CREATE TABLE `t_ingame_mall` (
|
||||||
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
`order_id` varchar(255) NOT NULL DEFAULT '' COMMENT '订单id',
|
`order_id` varchar(255) NOT NULL DEFAULT '' COMMENT '订单id',
|
||||||
|
`order_type` int(11) NOT NULL DEFAULT '0' COMMENT '1:英雄 2:芯片 3:碎片 4:宝箱',
|
||||||
`seller` varchar(60) NOT NULL DEFAULT '' COMMENT 'seller',
|
`seller` varchar(60) NOT NULL DEFAULT '' COMMENT 'seller',
|
||||||
`seller_address` varchar(60) NOT NULL DEFAULT '' COMMENT 'seller_address',
|
`seller_address` varchar(60) NOT NULL DEFAULT '' COMMENT 'seller_address',
|
||||||
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT '物品id',
|
`goods_uniid` varchar(50) NOT NULL DEFAULT '0' COMMENT '物品id',
|
||||||
|
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT '物品itemId',
|
||||||
`item_num` bigint NOT NULL DEFAULT '0' COMMENT '物品数量',
|
`item_num` bigint NOT NULL DEFAULT '0' COMMENT '物品数量',
|
||||||
`price` bigint NOT NULL DEFAULT '0' COMMENT '价格',
|
`price` bigint NOT NULL DEFAULT '0' COMMENT '价格',
|
||||||
`status` int(11) NOT NULL DEFAULT '0' COMMENT 'status',
|
`status` int(11) NOT NULL DEFAULT '0' COMMENT 'status',
|
||||||
`last_buy_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后一次购买时间',
|
|
||||||
`last_buyer` varchar(60) NOT NULL DEFAULT '' COMMENT '最后一次购买者',
|
|
||||||
`last_modify_price_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后一次修改价格事件',
|
|
||||||
`buyer` varchar(60) NOT NULL DEFAULT '' COMMENT '购买成功者',
|
`buyer` varchar(60) NOT NULL DEFAULT '' COMMENT '购买成功者',
|
||||||
`buy_ok_time` int(11) NOT NULL DEFAULT '0' COMMENT '购买成功时间',
|
`buy_ok_time` int(11) NOT NULL DEFAULT '0' COMMENT '购买成功时间',
|
||||||
|
`last_modify_price_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后一次修改价格事件',
|
||||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
PRIMARY KEY (`idx`),
|
PRIMARY KEY (`idx`),
|
||||||
@ -1450,7 +1450,7 @@ CREATE TABLE `t_ingame_mall` (
|
|||||||
UNIQUE KEY `order_id` (`order_id`)
|
UNIQUE KEY `order_id` (`order_id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `t_market`
|
-- Table structure for table `t_market`
|
||||||
@ -1801,4 +1801,4 @@ CREATE TABLE `t_global_data` (
|
|||||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
PRIMARY KEY (`idx`),
|
PRIMARY KEY (`idx`),
|
||||||
UNIQUE KEY `name` (`name`)
|
UNIQUE KEY `name` (`name`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
@ -11,6 +11,30 @@ alter table t_hero drop column base_attr;
|
|||||||
alter table t_chip add column `wealth_attr` mediumblob COMMENT '财富值属性';
|
alter table t_chip add column `wealth_attr` mediumblob COMMENT '财富值属性';
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE `t_ingame_mall` (
|
||||||
|
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
|
`order_id` varchar(255) NOT NULL DEFAULT '' COMMENT '订单id',
|
||||||
|
`order_type` int(11) NOT NULL DEFAULT '0' COMMENT '1:英雄 2:芯片 3:碎片 4:宝箱',
|
||||||
|
`seller` varchar(60) NOT NULL DEFAULT '' COMMENT 'seller',
|
||||||
|
`seller_address` varchar(60) NOT NULL DEFAULT '' COMMENT 'seller_address',
|
||||||
|
`goods_uniid` varchar(50) NOT NULL DEFAULT '0' COMMENT '物品id',
|
||||||
|
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT '物品itemId',
|
||||||
|
`item_num` bigint NOT NULL DEFAULT '0' COMMENT '物品数量',
|
||||||
|
`price` bigint NOT NULL DEFAULT '0' COMMENT '价格',
|
||||||
|
`status` int(11) NOT NULL DEFAULT '0' COMMENT 'status',
|
||||||
|
`buyer` varchar(60) NOT NULL DEFAULT '' COMMENT '购买成功者',
|
||||||
|
`buy_ok_time` int(11) NOT NULL DEFAULT '0' COMMENT '购买成功时间',
|
||||||
|
`last_modify_price_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后一次修改价格事件',
|
||||||
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`idx`),
|
||||||
|
KEY `seller` (`seller`),
|
||||||
|
KEY `seller_address` (`seller_address`),
|
||||||
|
KEY `price` (`price`),
|
||||||
|
UNIQUE KEY `order_id` (`order_id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
|
||||||
|
|
||||||
insert into version (version) values(2024030501);
|
insert into version (version) values(2024030501);
|
||||||
|
|
||||||
commit;
|
commit;
|
||||||
|
@ -620,7 +620,7 @@ class BaseAuthedController extends BaseController {
|
|||||||
{
|
{
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
//道具消耗埋点
|
//道具消耗埋点
|
||||||
LogService::consumeItem($item);
|
// LogService::consumeItem($item);
|
||||||
if ($this->_isVirtualItem($item['item_id'])) {
|
if ($this->_isVirtualItem($item['item_id'])) {
|
||||||
$this->_decVirtualItem($item['item_id'], $item['item_num']);
|
$this->_decVirtualItem($item['item_id'], $item['item_num']);
|
||||||
} else {
|
} else {
|
||||||
|
@ -7,7 +7,11 @@ require_once('mt/Parameter.php');
|
|||||||
|
|
||||||
require_once('models/BcOrder.php');
|
require_once('models/BcOrder.php');
|
||||||
require_once('models/Mall.php');
|
require_once('models/Mall.php');
|
||||||
|
require_once('models/InGameMall.php');
|
||||||
require_once('models/OrderId.php');
|
require_once('models/OrderId.php');
|
||||||
|
require_once('models/Hero.php');
|
||||||
|
require_once('models/Chip.php');
|
||||||
|
require_once('models/Bag.php');
|
||||||
|
|
||||||
require_once('services/BlockChainService.php');
|
require_once('services/BlockChainService.php');
|
||||||
require_once('services/LogService.php');
|
require_once('services/LogService.php');
|
||||||
@ -18,7 +22,11 @@ use phpcommon\SqlHelper;
|
|||||||
|
|
||||||
use models\BcOrder;
|
use models\BcOrder;
|
||||||
use models\Mall;
|
use models\Mall;
|
||||||
|
use models\InGameMall;
|
||||||
use models\OrderId;
|
use models\OrderId;
|
||||||
|
use models\Hero;
|
||||||
|
use models\Chip;
|
||||||
|
use models\Bag;
|
||||||
|
|
||||||
use services\LogService;
|
use services\LogService;
|
||||||
use services\BlockChainService;
|
use services\BlockChainService;
|
||||||
@ -43,6 +51,14 @@ class InGameMallController extends BaseAuthedController {
|
|||||||
if (!empty($seller)) {
|
if (!empty($seller)) {
|
||||||
$queryData['seller'] = $seller;
|
$queryData['seller'] = $seller;
|
||||||
}
|
}
|
||||||
|
$type_filter = getReqVal('type_filter', '');
|
||||||
|
if (!empty($type_filter)) {
|
||||||
|
$queryData['type_filter'] = $type_filter;
|
||||||
|
}
|
||||||
|
$item_filter = getReqVal('item_filter', '');
|
||||||
|
if (!empty($item_filter)) {
|
||||||
|
$queryData['item_filter'] = $item_filter;
|
||||||
|
}
|
||||||
$queryData['price_filter'] = getReqVal('price_filter', '');
|
$queryData['price_filter'] = getReqVal('price_filter', '');
|
||||||
$orderBy = '';
|
$orderBy = '';
|
||||||
$orderAsc = 'ASC';
|
$orderAsc = 'ASC';
|
||||||
@ -68,7 +84,7 @@ class InGameMallController extends BaseAuthedController {
|
|||||||
);
|
);
|
||||||
SqlHelper::rawQueryPage(
|
SqlHelper::rawQueryPage(
|
||||||
myself()->_getMySql(''),
|
myself()->_getMySql(''),
|
||||||
'SELECT * FROM t_mall WHERE status=:status',
|
'SELECT * FROM t_ingame_mall WHERE status=:status',
|
||||||
array(
|
array(
|
||||||
':status' => Mall::PENDING_STATE
|
':status' => Mall::PENDING_STATE
|
||||||
),
|
),
|
||||||
@ -80,7 +96,7 @@ class InGameMallController extends BaseAuthedController {
|
|||||||
'fields' => array(
|
'fields' => array(
|
||||||
array(
|
array(
|
||||||
'name' => 'seller',
|
'name' => 'seller',
|
||||||
'field_name' => 'seller_address',
|
'field_name' => 'seller',
|
||||||
'cond' => '=',
|
'cond' => '=',
|
||||||
'ignore_empty' => true,
|
'ignore_empty' => true,
|
||||||
),
|
),
|
||||||
@ -98,11 +114,23 @@ class InGameMallController extends BaseAuthedController {
|
|||||||
. " AND (price >= '${priceLow}' AND price <= '${priceHigh}') ";
|
. " AND (price >= '${priceLow}' AND price <= '${priceHigh}') ";
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'item_filter',
|
||||||
|
'field_name' => 'item_id',
|
||||||
|
'cond' => '=',
|
||||||
|
'ignore_empty' => true,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'type_filter',
|
||||||
|
'field_name' => 'order_type',
|
||||||
|
'cond' => '=',
|
||||||
|
'ignore_empty' => true,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'orderBy' => $orderBy,
|
'orderBy' => $orderBy,
|
||||||
'handle' => function ($row) use(&$out) {
|
'handle' => function ($row) use(&$out) {
|
||||||
array_push($out['rows'], Mall::toDto($row));
|
array_push($out['rows'], $row);
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
$out['pagination']
|
$out['pagination']
|
||||||
@ -112,41 +140,116 @@ class InGameMallController extends BaseAuthedController {
|
|||||||
|
|
||||||
public function sell()
|
public function sell()
|
||||||
{
|
{
|
||||||
$address = myself()->_getAddress();
|
$goodsUniid = getReqVal('goods_uniid', '');
|
||||||
if (!$address) {
|
|
||||||
$this->_rspErr(1, 'address not found');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$itemId = getReqVal('item_id', '');
|
$itemId = getReqVal('item_id', '');
|
||||||
$amount = intval(getReqVal('amount', ''), 10);
|
$amount = intval(getReqVal('amount', ''), 10);
|
||||||
$currency = getReqVal('currency', '');
|
$priceBn = intval(getReqVal('price', ''));
|
||||||
$priceBn = phpcommon\bnInit(getReqVal('price', ''));
|
$itemMeta = \mt\Item::get($itemId);
|
||||||
if ($itemId != V_ITEM_GOLD) {
|
if (!$itemMeta){
|
||||||
$this->_rspErr(1, 'only support gold');
|
$this->_rspErr(1, 'param item_id error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (! $this->_isGoodsType($itemMeta['type'])){
|
||||||
|
$this->_rspErr(1, 'param item_id error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch ($itemMeta['type']){
|
||||||
|
case \mt\Item::HERO_TYPE : {
|
||||||
|
$heroDb = Hero::find($goodsUniid);
|
||||||
|
if (!$heroDb || !empty($heroDb['token_id']) || $heroDb['hero_id']!= $itemId){
|
||||||
|
$this->_rspErr(1, 'param goods_unnid error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case \mt\Item::CHIP_TYPE : {
|
||||||
|
$chipDb = Chip::find($goodsUniid);
|
||||||
|
if (!$chipDb || !empty($chipDb['token_id']) || $chipDb['item_id']!= $itemId){
|
||||||
|
$this->_rspErr(1, 'param goods_unnid error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if ($amount <= 0) {
|
if ($amount <= 0) {
|
||||||
$this->_rspErr(1, 'amount must > 0');
|
$this->_rspErr(1, 'amount must > 0');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$this->checkPrice($priceBn)) {
|
if (!$this->_isNumber($priceBn) || $priceBn < 0) {
|
||||||
|
$this->_rspErr(1, 'param price error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!in_array(
|
$propertyChgService = new PropertyChgService();
|
||||||
$currency,
|
if (\mt\Item::isBagItem($itemMeta['type'],$itemMeta['sub_type'])){
|
||||||
array(
|
$costItems = array(
|
||||||
BlockChainService::CURRENCY_CEG,
|
array(
|
||||||
BlockChainService::CURRENCY_USDC,
|
'item_id' => $itemId,
|
||||||
BlockChainService::CURRENCY_USDT,
|
'item_num' => $amount
|
||||||
)
|
)
|
||||||
)) {
|
);
|
||||||
$this->_rspErr(1, 'paramater error currency');
|
$lackItem = null;
|
||||||
|
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||||
|
$this->_rspErr(2, $this->_getLackItemErrMsg($lackItem));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->_decItems($costItems);
|
||||||
|
$propertyChgService->addBagChg();
|
||||||
|
}elseif ($itemMeta['type'] == \mt\Item::HERO_TYPE){
|
||||||
|
SqlHelper::update
|
||||||
|
(myself()->_getSelfMysql(),
|
||||||
|
't_hero',
|
||||||
|
array(
|
||||||
|
'idx' => $goodsUniid,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => InGameMall::SYSTEM_MALL_ACCOUNT
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$propertyChgService->addHeroChg();
|
||||||
|
}elseif ($itemMeta['type'] == \mt\Item::CHIP_TYPE){
|
||||||
|
SqlHelper::update
|
||||||
|
(myself()->_getSelfMysql(),
|
||||||
|
't_chip',
|
||||||
|
array(
|
||||||
|
'idx' => $goodsUniid,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => InGameMall::SYSTEM_MALL_ACCOUNT
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$propertyChgService->addChip();
|
||||||
|
}
|
||||||
|
|
||||||
|
$orderId = OrderId::gen();
|
||||||
|
$orderType = $this->_getGoodsType($itemMeta['type']);
|
||||||
|
InGameMall::add(
|
||||||
|
$orderId,
|
||||||
|
$orderType,
|
||||||
|
$goodsUniid,
|
||||||
|
$itemId,
|
||||||
|
$amount,
|
||||||
|
$priceBn
|
||||||
|
);
|
||||||
|
myself()->_rspData(array(
|
||||||
|
'property_chg' => $propertyChgService->toDto(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buy(){
|
||||||
|
$orderId = getReqVal('order_id', '');
|
||||||
|
$goodsDb = InGameMall::findByOrderId($orderId);
|
||||||
|
if (!$goodsDb) {
|
||||||
|
myself()->_rspErr(1, 'goods not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ($goodsDb['status'] != InGameMall::PENDING_STATE){
|
||||||
|
myself()->_rspErr(1, 'cannot cancel the goods');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$price = $goodsDb['price'];
|
||||||
$costItems = array(
|
$costItems = array(
|
||||||
array(
|
array(
|
||||||
'item_id' => $itemId,
|
'item_id' => V_ITEM_GOLD,
|
||||||
'item_num' => $amount
|
'item_num' => $price
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$lackItem = null;
|
$lackItem = null;
|
||||||
@ -155,111 +258,183 @@ class InGameMallController extends BaseAuthedController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->_decItems($costItems);
|
$this->_decItems($costItems);
|
||||||
if ($itemId == V_ITEM_GOLD) {
|
SqlHelper::update
|
||||||
//埋点
|
($this->_getSelfMysql(),
|
||||||
$event = [
|
't_user',
|
||||||
'name' => LogService::MARKET_SELL_GOLD,
|
array(
|
||||||
'val' => $amount
|
'account_id' => $goodsDb['seller']
|
||||||
];
|
),
|
||||||
LogService::consumeGold($event);
|
array(
|
||||||
}
|
'gold' => function () use($price) {
|
||||||
$orderId = OrderId::gen();
|
return "gold + ${price}";
|
||||||
Mall::Add(
|
}
|
||||||
$orderId,
|
)
|
||||||
$orderId,
|
|
||||||
$itemId,
|
|
||||||
$amount,
|
|
||||||
$currency,
|
|
||||||
phpcommon\bnToStr($priceBn)
|
|
||||||
);
|
);
|
||||||
myself()->_rspOk();
|
$propertyChgService = new PropertyChgService();
|
||||||
|
switch ($goodsDb['order_type']){
|
||||||
|
case InGameMall::HERO_TYPE :{
|
||||||
|
SqlHelper::update
|
||||||
|
(myself()->_getSelfMysql(),
|
||||||
|
't_hero',
|
||||||
|
array(
|
||||||
|
'idx' => $goodsDb['goods_uniid'],
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$propertyChgService->addHeroChg();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case InGameMall::CHIP_TYPE:{
|
||||||
|
SqlHelper::update
|
||||||
|
(myself()->_getSelfMysql(),
|
||||||
|
't_chip',
|
||||||
|
array(
|
||||||
|
'idx' => $goodsDb['goods_uniid'],
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$propertyChgService->addChip();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default : {
|
||||||
|
Bag::addItem($goodsDb['item_id'],$goodsDb['item_num']);
|
||||||
|
$propertyChgService->addBagChg();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
InGameMall::buyOk($orderId,myself()->_getAccountId());
|
||||||
|
myself()->_rspData(array(
|
||||||
|
'property_chg' => $propertyChgService->toDto(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cancel()
|
public function cancel()
|
||||||
{
|
{
|
||||||
$goodsUuid = getReqVal('goods_uuid', '');
|
$orderId = getReqVal('order_id', '');
|
||||||
$goodsDb = Mall::findByGoodsUuid($goodsUuid);
|
$goodsDb = InGameMall::findByOrderId($orderId);
|
||||||
if (!$goodsDb) {
|
if (!$goodsDb) {
|
||||||
myself()->_rspErr(1, 'goods not found');
|
myself()->_rspErr(1, 'goods not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$goodsDto = Mall::toDto($goodsDb);
|
if ($goodsDb['status'] != InGameMall::PENDING_STATE){
|
||||||
if ($goodsDto['cancel_countdown'] != 0) {
|
myself()->_rspErr(1, 'cannot cancel the goods');
|
||||||
myself()->_rspErr(1, 'cant cancel');
|
return;
|
||||||
|
}
|
||||||
|
if ($goodsDb['seller'] != myself()->_getAccountId()){
|
||||||
|
myself()->_rspErr(1, 'Not the seller');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$awardService = new AwardService();
|
|
||||||
$propertyChgService = new PropertyChgService();
|
$propertyChgService = new PropertyChgService();
|
||||||
switch ($goodsDb['item_id']) {
|
switch ($goodsDb['order_type']){
|
||||||
case V_ITEM_GOLD:
|
case InGameMall::HERO_TYPE :{
|
||||||
{
|
SqlHelper::update
|
||||||
$items = array(
|
(myself()->_getSelfMysql(),
|
||||||
array(
|
't_hero',
|
||||||
'item_id' => $goodsDb['item_id'],
|
array(
|
||||||
'item_num' => $goodsDb['item_num'],
|
'idx' => $goodsDb['goods_uniid'],
|
||||||
)
|
),
|
||||||
);
|
array(
|
||||||
Mall::cancel($goodsDto['goods_uuid']);
|
'account_id' => myself()->_getAccountId()
|
||||||
myself()->_addItems($items, $awardService, $propertyChgService);
|
)
|
||||||
{
|
);
|
||||||
//埋点
|
$propertyChgService->addHeroChg();
|
||||||
$event = [
|
}
|
||||||
'name' => LogService::MARKET_CANCEL_SELL_GOLD,
|
break;
|
||||||
'val' => $goods['amount']
|
case InGameMall::CHIP_TYPE:{
|
||||||
];
|
SqlHelper::update
|
||||||
LogService::productGold($event);
|
(myself()->_getSelfMysql(),
|
||||||
|
't_chip',
|
||||||
|
array(
|
||||||
|
'idx' => $goodsDb['goods_uniid'],
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$propertyChgService->addChip();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default : {
|
||||||
|
Bag::addItem($goodsDb['item_id'],$goodsDb['item_num']);
|
||||||
|
$propertyChgService->addBagChg();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
InGameMall::cancel($orderId);
|
||||||
default:
|
|
||||||
{
|
|
||||||
myself()->_rspErr(1, 'cant cancel');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
myself()->_rspData(array(
|
myself()->_rspData(array(
|
||||||
'award' => $awardService->toDto(),
|
|
||||||
'property_chg' => $propertyChgService->toDto(),
|
'property_chg' => $propertyChgService->toDto(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function modifyPrice()
|
public function modifyPrice()
|
||||||
{
|
{
|
||||||
$goodsUuid = getReqVal('goods_uuid', '');
|
$orderId = getReqVal('order_id', '');
|
||||||
$priceBn = phpcommon\bnInit(getReqVal('price', ''));
|
$priceBn =intval(getReqVal('price', ''));
|
||||||
if (!$this->checkPrice($priceBn)) {
|
if (!$this->_isNumber($priceBn)) {
|
||||||
|
$this->_rspErr(1, 'param price error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$goodsDb = Mall::findByGoodsUuid($goodsUuid);
|
$goodsDb = InGameMall::findByOrderId($orderId);
|
||||||
if (!$goodsDb) {
|
if (!$goodsDb) {
|
||||||
myself()->_rspErr(1, 'goods not found');
|
myself()->_rspErr(1, 'goods not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$goodsDto = Mall::toDto($goodsDb);
|
if ($goodsDb['status'] != InGameMall::PENDING_STATE){
|
||||||
if ($goodsDto['modify_countdown'] != 0) {
|
myself()->_rspErr(1, 'cannot cancel the goods');
|
||||||
myself()->_rspErr(1, 'cant modify price');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Mall::modifyPrice($goodsDto['goods_uuid'], phpcommon\bnToStr($priceBn));
|
if ($goodsDb['seller'] != myself()->_getAccountId()){
|
||||||
|
myself()->_rspErr(1, 'Not the seller');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
InGameMall::modifyPrice($orderId, $priceBn);
|
||||||
myself()->_rspOk();
|
myself()->_rspOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkPrice($priceBn)
|
private function _isNumber($number){
|
||||||
{
|
if (is_int($number) && $number > 0){
|
||||||
if ($priceBn === false) {
|
return true;
|
||||||
myself()->_rspErr(1, 'price format error1');
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (phpcommon\bnCmp($this->priceLowBn, $priceBn) > 0) {
|
|
||||||
myself()->_rspErr(1, 'price format error2');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (phpcommon\bnCmp($this->priceHighBn, $priceBn) < 0) {
|
|
||||||
myself()->_rspErr(1, 'price format error3');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function _isGoodsType($type){
|
||||||
|
if (in_array($type,array(
|
||||||
|
\mt\Item::HERO_TYPE,
|
||||||
|
\mt\Item::CHIP_TYPE,
|
||||||
|
\mt\Item::FRAGMENT_TYPE,
|
||||||
|
\mt\Item::TREASURE_BOX,
|
||||||
|
))){
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _getGoodsType($type){
|
||||||
|
switch ($type){
|
||||||
|
case \mt\Item::HERO_TYPE : {
|
||||||
|
return InGameMall::HERO_TYPE;
|
||||||
|
}
|
||||||
|
case \mt\Item::CHIP_TYPE : {
|
||||||
|
return InGameMall::CHIP_TYPE;
|
||||||
|
}
|
||||||
|
case \mt\Item::FRAGMENT_TYPE : {
|
||||||
|
return InGameMall::FRAGMENT_TYPE;
|
||||||
|
}
|
||||||
|
case \mt\Item::TREASURE_BOX : {
|
||||||
|
return InGameMall::BOX_TYPE;
|
||||||
|
}
|
||||||
|
default : {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,11 +60,6 @@ class Hero extends BaseModel {
|
|||||||
'idx' => $heroUniId,
|
'idx' => $heroUniId,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if ($row) {
|
|
||||||
if ($row['account_id'] != myself()->_getAccountId()) {
|
|
||||||
$row = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
100
webapp/models/InGameMall.php
Normal file
100
webapp/models/InGameMall.php
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace models;
|
||||||
|
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
|
class InGameMall extends BaseModel {
|
||||||
|
|
||||||
|
const PENDING_STATE = 0;
|
||||||
|
const BUY_OK_STATE = 1;
|
||||||
|
const CANCEL_STATE = 2;
|
||||||
|
|
||||||
|
const HERO_TYPE = 1;
|
||||||
|
const CHIP_TYPE = 2;
|
||||||
|
const FRAGMENT_TYPE = 3;
|
||||||
|
const BOX_TYPE = 4;
|
||||||
|
|
||||||
|
const SYSTEM_MALL_ACCOUNT = "kingsome";
|
||||||
|
|
||||||
|
public static function findByOrderId($orderId)
|
||||||
|
{
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getMysql(''),
|
||||||
|
't_ingame_mall',
|
||||||
|
array(
|
||||||
|
'order_id' => $orderId
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function add($orderId, $orderType, $goodsUniid,$itemId, $itemNum, $price)
|
||||||
|
{
|
||||||
|
SqlHelper::insert
|
||||||
|
(myself()->_getMysql(''),
|
||||||
|
't_ingame_mall',
|
||||||
|
array(
|
||||||
|
'order_id' => $orderId,
|
||||||
|
'order_type' => $orderType,
|
||||||
|
'seller' => myself()->_getAccountId(),
|
||||||
|
'seller_address' => myself()->_getAddress(),
|
||||||
|
'goods_uniid' => $goodsUniid,
|
||||||
|
'item_id' => $itemId,
|
||||||
|
'item_num' => $itemNum,
|
||||||
|
'price' => $price,
|
||||||
|
'last_modify_price_time' => myself()->_getNowTime(),
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function modifyPrice($orderId, $price)
|
||||||
|
{
|
||||||
|
SqlHelper::update
|
||||||
|
(myself()->_getMysql(''),
|
||||||
|
't_ingame_mall',
|
||||||
|
array(
|
||||||
|
'order_id' => $orderId
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'price' => $price,
|
||||||
|
'last_modify_price_time' => myself()->_getNowTime(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function cancel($orderId)
|
||||||
|
{
|
||||||
|
SqlHelper::update
|
||||||
|
(myself()->_getMysql(''),
|
||||||
|
't_ingame_mall',
|
||||||
|
array(
|
||||||
|
'order_id' => $orderId
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'status' => self::CANCEL_STATE,
|
||||||
|
'modifytime' => myself()->_getNowTime(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function buyOk($orderId, $buyer)
|
||||||
|
{
|
||||||
|
SqlHelper::update
|
||||||
|
(myself()->_getMysql(''),
|
||||||
|
't_ingame_mall',
|
||||||
|
array(
|
||||||
|
'order_id' => $orderId
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'status' => self::BUY_OK_STATE,
|
||||||
|
'buyer' => $buyer,
|
||||||
|
'buy_ok_time' => myself()->_getNowTime()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user