diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 736a6b14..c8967763 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -1387,7 +1387,7 @@ CREATE TABLE `t_mall` ( `idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id', `order_id` varchar(255) NOT NULL DEFAULT '' COMMENT '订单id', `goods_uuid` varchar(255) NOT NULL DEFAULT '' COMMENT '商品uuid', - `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', + `seller` varchar(60) NOT NULL DEFAULT '' COMMENT 'seller', `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '物品id', `item_num` bigint NOT NULL DEFAULT '0' COMMENT '物品数量', `currency` varchar(60) NOT NULL COMMENT 'currency', @@ -1396,7 +1396,7 @@ CREATE TABLE `t_mall` ( `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), - KEY `account_id` (`account_id`), + KEY `seller` (`seller`), UNIQUE KEY `order_id` (`order_id`), UNIQUE KEY `goods_uuid` (`goods_uuid`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; diff --git a/webapp/controller/MallController.class.php b/webapp/controller/MallController.class.php index 821c03c1..f311e4cc 100644 --- a/webapp/controller/MallController.class.php +++ b/webapp/controller/MallController.class.php @@ -5,6 +5,7 @@ require_once('mt/Parameter.php'); require_once('models/BcOrder.php'); require_once('models/Mall.php'); +require_once('models/OrderId.php'); require_once('services/BlockChainService.php'); require_once('services/LogService.php'); @@ -13,6 +14,7 @@ use phpcommon\SqlHelper; use models\BcOrder; use models\Mall; +use models\OrderId; use services\LogService; use services\BlockChainService; @@ -21,7 +23,7 @@ class MallController extends BaseAuthedController { public function productList() { - $page = getReqVal('page', 1); + $page = getReqVal('page', 0); $queryData = array(); $out = array( @@ -43,7 +45,7 @@ class MallController extends BaseAuthedController { ) ), //'orderBy' => $orderBy, - 'handle' => function ($row) { + 'handle' => function ($row) use(&$out) { array_push($out['rows'], array( 'goods_uuid' => $row['goods_uuid'], @@ -62,10 +64,12 @@ class MallController extends BaseAuthedController { public function sell() { - $address = $this->_getAddress(); - if (!$address) { - $this->_rspErr(1, 'address not found'); - return; + if (SERVER_ENV == _ONLINE) { + $address = myself()->_getAddress(); + if (!$address) { + $this->_rspErr(1, 'address not found'); + return; + } } $itemId = getReqVal('item_id', ''); $amount = getReqVal('amount', ''); @@ -143,11 +147,11 @@ class MallController extends BaseAuthedController { $goodsUuid = getReqVal('goods_uuid', ''); $goodsDb = Mall::findByGoodsUuid($goodsUuid); if (!$goodsDb) { - myself()->_resErr(1, 'goods not found'); + myself()->_rspErr(1, 'goods not found'); return; } - if ($goodDb['seller'] != myself()->_getAccountId()) { - myself()->_resErr(1, 'goods not found'); + if ($goodsDb['seller'] != myself()->_getAccountId()) { + myself()->_rspErr(1, 'goods not found'); return; } Mall::cancel($goodsDb['goods_uuid']); @@ -160,11 +164,11 @@ class MallController extends BaseAuthedController { $price = getReqVal('price', ''); $goodsDb = Mall::findByGoodsUuid($goodsUuid); if (!$goodsDb) { - myself()->_resErr(1, 'goods not found'); + myself()->_rspErr(1, 'goods not found'); return; } - if ($goodDb['seller'] != myself()->_getAccountId()) { - myself()->_resErr(1, 'goods not found'); + if ($goodsDb['seller'] != myself()->_getAccountId()) { + myself()->_rspErr(1, 'goods not found'); return; } Mall::modifyPrice($goodsDb['goods_uuid'], $price); diff --git a/webapp/models/Mall.php b/webapp/models/Mall.php index fcc9e7a0..6ed0c272 100644 --- a/webapp/models/Mall.php +++ b/webapp/models/Mall.php @@ -33,20 +33,21 @@ class Mall extends BaseModel { } public static function add($orderId, $goodsUuid, $itemId, $itemNum, - $currency, $pirce) { - self::internalUpdate( - $orderId, - array( - 'order_id' => $orderId, - 'goods_uuid' => $goodsUuid, - 'seller' => myself()->_getAccountId(), - 'item_id' => $itemId, - 'item_num' => $amount, - 'currency' => $currency, - 'price' => $price, - 'createtime' => myself()->_getNowTime(), - 'modifytime' => myself()->_getNowTime(), - )); + $currency, $price) { + SqlHelper::insert + (myself()->_getMysql(''), + 't_mall', + array( + 'order_id' => $orderId, + 'goods_uuid' => $goodsUuid, + 'seller' => myself()->_getAccountId(), + 'item_id' => $itemId, + 'item_num' => $itemNum, + 'currency' => $currency, + 'price' => $price, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + )); } public static function modifyPrice($goodsUuid, $price) {