From 6d904e58aaa92c770ac8eace4977ce8ca46eb8d1 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Mon, 20 May 2024 15:39:48 +0800 Subject: [PATCH] 1 --- doc/InGameMall.py | 42 ++++++++++- doc/_common.py | 1 + .../controller/InGameMallController.class.php | 75 +++++++++++++++++-- webapp/models/InGameMall.php | 33 +++++++- 4 files changed, 141 insertions(+), 10 deletions(-) diff --git a/doc/InGameMall.py b/doc/InGameMall.py index 406472b5..997cecfc 100644 --- a/doc/InGameMall.py +++ b/doc/InGameMall.py @@ -18,7 +18,7 @@ class InGameMall(object): ['order_method', 0, '排序方式 0:默认排序(当前指向1) 1:上架时间 2:价格'], ['order_asc', 0, '排序方向, 0:从小到大 1:从大到小'], ['price_filter', '', '价格过滤(用|分割)'], - ['type_filter', '', '类型过滤 1:英雄 2:芯片 3:碎片 4:其它'], + ['type_filter', '', '类型过滤 1:英雄 2:芯片 3:英雄碎片 4:芯片碎片 5:其它'], ['item_filter', '', 'itemId过滤'], ], 'response': [ @@ -83,4 +83,44 @@ class InGameMall(object): _common.RspHead() ] }, + { + 'name': 'sellList', + 'desc': '出售记录', + 'group': 'InGameMall', + 'url': 'webapp/index.php?c=InGameMall&a=sellList', + 'params':[ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ['!list', [_common.InGameMallGoods()], '商品列表'] + ] + }, + { + 'name': 'buyList', + 'desc': '购买记录', + 'group': 'InGameMall', + 'url': 'webapp/index.php?c=InGameMall&a=buyList', + 'params':[ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ['!list', [_common.InGameMallGoods()], '商品列表'] + ] + }, + { + 'name': 'shoppingCartList', + 'desc': '购物车列表', + 'group': 'InGameMall', + 'url': 'webapp/index.php?c=InGameMall&a=shoppingCartList', + 'params':[ + _common.ReqHead(), + ['order_ids', '', '订单id(多个订单用 | 隔开)'], + ], + 'response': [ + _common.RspHead(), + ['!list', [_common.InGameMallGoods()], '商品列表'] + ] + }, ] diff --git a/doc/_common.py b/doc/_common.py index f4c05254..65b7d9a2 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1371,6 +1371,7 @@ class InGameMallGoods(object): ['item_id', '', '商品道具id'], ['item_num', '', '道具数量'], ['price', '', '出售价格'], + ['status', '', '0:出售中 1:已购买 2:已取消'], ['createtime', 0, '上架时间'], ['last_modify_price_time', 0, '修改时间(更新价格等)'], ] diff --git a/webapp/controller/InGameMallController.class.php b/webapp/controller/InGameMallController.class.php index 8099103d..6e46c8cf 100644 --- a/webapp/controller/InGameMallController.class.php +++ b/webapp/controller/InGameMallController.class.php @@ -133,8 +133,8 @@ class InGameMallController extends BaseAuthedController { 'ignore_empty' => true, 'custom_func' => function () use ($queryData) { $typeFilter = $queryData['type_filter']; - if ($typeFilter >= 4){ - return "AND (order_type >= 4)"; + if ($typeFilter >= 5){ + return "AND (order_type >= 5)"; }else{ return "AND (order_type = '${typeFilter}')"; } @@ -144,6 +144,19 @@ class InGameMallController extends BaseAuthedController { ), 'orderBy' => $orderBy, 'handle' => function ($row) use(&$out) { + switch ($row['order_type']){ + case InGameMall::HERO_TYPE :{ + $row['item_info'] = Hero::mallInfo(Hero::findEx($row['goods_uniid'])); + } + break; + case InGameMall::CHIP_TYPE :{ + $row['item_info'] = Chip::toDto(Chip::findEx($row['goods_uniid'])); + } + break; + default:{ + $row['item_info'] = array(); + } + } array_push($out['rows'], $row); } ), @@ -174,6 +187,10 @@ class InGameMallController extends BaseAuthedController { $this->_rspErr(1, 'param goods_unnid error'); return; } + if ($heroDb['seal_type'] != 1){ + $this->_rspErr(1, 'Shelf heroes need to be packaged first'); + return; + } } break; case \mt\Item::CHIP_TYPE : { @@ -258,7 +275,7 @@ class InGameMallController extends BaseAuthedController { } $orderId = OrderId::gen(); - $orderType = $this->_getGoodsType($itemMeta['type']); + $orderType = $this->_getGoodsType($itemMeta); InGameMall::add( $orderId, $orderType, @@ -459,6 +476,45 @@ class InGameMallController extends BaseAuthedController { myself()->_rspOk(); } + public function sellList(){ + $list = array(); + InGameMall::getMySell(function ($row) use (&$list) { + array_push($list,$row); + }); + $this->_rspData(array( + 'list' => $list + )); + } + + public function buyList(){ + $list = array(); + InGameMall::getMyBuy(function ($row) use (&$list) { + array_push($list,$row); + }); + $this->_rspData(array( + 'list' => $list + )); + } + + public function shoppingCartList(){ + $orderIds = getReqVal('order_ids', ''); + if (!$orderIds){ + $this->_rspErr(1, 'param is not null'); + return; + } + $orderIdArr = explode("|",$orderIds); + $list = array(); + foreach ($orderIdArr as $orderId){ + $orderDb = InGameMall::findByOrderId($orderId); + if ($orderDb){ + array_push($list,$orderDb); + } + } + $this->_rspData(array( + 'list' => $list + )); + } + private function _isNumber($number){ if (is_int($number) && $number > 0){ return true; @@ -481,8 +537,11 @@ class InGameMallController extends BaseAuthedController { } } - private function _getGoodsType($type){ - switch ($type){ + private function _getGoodsType($itemMeta){ + if (!$itemMeta){ + return ; + } + switch ($itemMeta['type']){ case \mt\Item::HERO_TYPE : { return InGameMall::HERO_TYPE; } @@ -490,7 +549,11 @@ class InGameMallController extends BaseAuthedController { return InGameMall::CHIP_TYPE; } case \mt\Item::FRAGMENT_TYPE : { - return InGameMall::FRAGMENT_TYPE; + if ($itemMeta['sub_type'] == \mt\Item::HERO_FRAGMENT_SUBTYPE){ + return InGameMall::HERO_FRAGMENT_TYPE; + }else if ($itemMeta['sub_type'] == \mt\Item::CHIP_FRAGMENT_SUBTYPE){ + return InGameMall::CHIP_FRAGMENT_TYPE; + } } case \mt\Item::BATTLE_REWARD_BOX : { return InGameMall::BOX_TYPE; diff --git a/webapp/models/InGameMall.php b/webapp/models/InGameMall.php index cf6568cb..9ffb8ec9 100644 --- a/webapp/models/InGameMall.php +++ b/webapp/models/InGameMall.php @@ -12,9 +12,10 @@ class InGameMall extends BaseModel { const HERO_TYPE = 1; const CHIP_TYPE = 2; - const FRAGMENT_TYPE = 3; - const BOX_TYPE = 4; - const GOLD_TYPE = 5; + const HERO_FRAGMENT_TYPE = 3; + const CHIP_FRAGMENT_TYPE = 4; + const BOX_TYPE = 5; + const GOLD_TYPE = 6; const SYSTEM_MALL_ACCOUNT = "kingsome"; @@ -96,6 +97,32 @@ class InGameMall extends BaseModel { ); } + public static function getMySell($cb){ + SqlHelper::ormSelect( + myself()->_getMysql(''), + 't_ingame_mall', + array( + 'seller' => myself()->_getAccountId() + ), + function ($row) use($cb) { + $cb($row); + } + ); + } + + public static function getMyBuy($cb){ + SqlHelper::ormSelect( + myself()->_getMysql(''), + 't_ingame_mall', + array( + 'buyer' => myself()->_getAccountId() + ), + function ($row) use($cb) { + $cb($row); + } + ); + } + }