diff --git a/doc/InGameMall.py b/doc/InGameMall.py index 997cecfc..fb10f583 100644 --- a/doc/InGameMall.py +++ b/doc/InGameMall.py @@ -90,10 +90,14 @@ class InGameMall(object): 'url': 'webapp/index.php?c=InGameMall&a=sellList', 'params':[ _common.ReqHead(), + ['page', 0, '第几页数据'], + ['order_method', 0, '排序方式 0:默认排序(当前指向1) 1:购买时间 2:价格'], + ['order_asc', 0, '排序方向, 0:从小到大 1:从大到小'], ], 'response': [ _common.RspHead(), - ['!list', [_common.InGameMallGoods()], '商品列表'] + ['pagination', _common.Pagination(), '分页信息'], + ['!rows', [_common.InGameMallGoods()], '商品列表'] ] }, { @@ -103,10 +107,14 @@ class InGameMall(object): 'url': 'webapp/index.php?c=InGameMall&a=buyList', 'params':[ _common.ReqHead(), + ['page', 0, '第几页数据'], + ['order_method', 0, '排序方式 0:默认排序(当前指向1) 1:购买时间 2:价格'], + ['order_asc', 0, '排序方向, 0:从小到大 1:从大到小'], ], 'response': [ _common.RspHead(), - ['!list', [_common.InGameMallGoods()], '商品列表'] + ['pagination', _common.Pagination(), '分页信息'], + ['!rows', [_common.InGameMallGoods()], '商品列表'] ] }, { diff --git a/webapp/controller/InGameMallController.class.php b/webapp/controller/InGameMallController.class.php index 6e46c8cf..2d3b6fd3 100644 --- a/webapp/controller/InGameMallController.class.php +++ b/webapp/controller/InGameMallController.class.php @@ -477,23 +477,93 @@ class InGameMallController extends BaseAuthedController { } public function sellList(){ - $list = array(); - InGameMall::getMySell(function ($row) use (&$list) { - array_push($list,$row); - }); - $this->_rspData(array( - 'list' => $list - )); + $page = getReqVal('page', 0); + $orderBy = ''; + $orderAsc = 'ASC'; + if (getReqVal('order_asc', '') == 1) { + $orderAsc = 'DESC'; + } + switch (getReqVal('order_method', '')) { + case 1: + { + $orderBy = 'ORDER BY buy_ok_time ' . $orderAsc; + } + break; + case 2: + { + $orderBy = 'ORDER BY length(price) ' . $orderAsc . ', price ' . $orderAsc; + } + break; + } + + $out = array( + 'pagination' => array(), + 'rows' => array() + ); + SqlHelper::rawQueryPage( + myself()->_getMySql(''), + 'SELECT * FROM t_ingame_mall WHERE seller=:seller AND status=:status', + array( + ':seller' => myself()->_getAccountId(), + ':status' => Mall::BUY_OK_STATE, + ), + array( + 'page' => $page, + 'perPage' => 10, + 'orderBy' => $orderBy, + 'handle' => function ($row) use(&$out) { + array_push($out['rows'], $row); + } + ), + $out['pagination'] + ); + myself()->_rspData($out); } + + public function buyList(){ - $list = array(); - InGameMall::getMyBuy(function ($row) use (&$list) { - array_push($list,$row); - }); - $this->_rspData(array( - 'list' => $list - )); + $page = getReqVal('page', 0); + $orderBy = ''; + $orderAsc = 'ASC'; + if (getReqVal('order_asc', '') == 1) { + $orderAsc = 'DESC'; + } + switch (getReqVal('order_method', '')) { + case 1: + { + $orderBy = 'ORDER BY buy_ok_time ' . $orderAsc; + } + break; + case 2: + { + $orderBy = 'ORDER BY length(price) ' . $orderAsc . ', price ' . $orderAsc; + } + break; + } + + $out = array( + 'pagination' => array(), + 'rows' => array() + ); + SqlHelper::rawQueryPage( + myself()->_getMySql(''), + 'SELECT * FROM t_ingame_mall WHERE buyer=:buyer AND status=:status', + array( + ':buyer' => myself()->_getAccountId(), + ':status' => Mall::BUY_OK_STATE, + ), + array( + 'page' => $page, + 'perPage' => 10, + 'orderBy' => $orderBy, + 'handle' => function ($row) use(&$out) { + array_push($out['rows'], $row); + } + ), + $out['pagination'] + ); + myself()->_rspData($out); } public function shoppingCartList(){