This commit is contained in:
aozhiwei 2023-08-07 13:18:24 +08:00
parent de58d063ed
commit 20165d5e3b
3 changed files with 33 additions and 28 deletions

View File

@ -1387,7 +1387,7 @@ CREATE TABLE `t_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',
`goods_uuid` varchar(255) NOT NULL DEFAULT '' COMMENT '商品uuid', `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_id` int(11) NOT NULL DEFAULT '0' COMMENT '物品id',
`item_num` bigint NOT NULL DEFAULT '0' COMMENT '物品数量', `item_num` bigint NOT NULL DEFAULT '0' COMMENT '物品数量',
`currency` varchar(60) NOT NULL COMMENT 'currency', `currency` varchar(60) NOT NULL COMMENT 'currency',
@ -1396,7 +1396,7 @@ CREATE TABLE `t_mall` (
`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`),
KEY `account_id` (`account_id`), KEY `seller` (`seller`),
UNIQUE KEY `order_id` (`order_id`), UNIQUE KEY `order_id` (`order_id`),
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;

View File

@ -5,6 +5,7 @@ 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/OrderId.php');
require_once('services/BlockChainService.php'); require_once('services/BlockChainService.php');
require_once('services/LogService.php'); require_once('services/LogService.php');
@ -13,6 +14,7 @@ use phpcommon\SqlHelper;
use models\BcOrder; use models\BcOrder;
use models\Mall; use models\Mall;
use models\OrderId;
use services\LogService; use services\LogService;
use services\BlockChainService; use services\BlockChainService;
@ -21,7 +23,7 @@ class MallController extends BaseAuthedController {
public function productList() public function productList()
{ {
$page = getReqVal('page', 1); $page = getReqVal('page', 0);
$queryData = array(); $queryData = array();
$out = array( $out = array(
@ -43,7 +45,7 @@ class MallController extends BaseAuthedController {
) )
), ),
//'orderBy' => $orderBy, //'orderBy' => $orderBy,
'handle' => function ($row) { 'handle' => function ($row) use(&$out) {
array_push($out['rows'], array_push($out['rows'],
array( array(
'goods_uuid' => $row['goods_uuid'], 'goods_uuid' => $row['goods_uuid'],
@ -62,11 +64,13 @@ class MallController extends BaseAuthedController {
public function sell() public function sell()
{ {
$address = $this->_getAddress(); if (SERVER_ENV == _ONLINE) {
$address = myself()->_getAddress();
if (!$address) { if (!$address) {
$this->_rspErr(1, 'address not found'); $this->_rspErr(1, 'address not found');
return; return;
} }
}
$itemId = getReqVal('item_id', ''); $itemId = getReqVal('item_id', '');
$amount = getReqVal('amount', ''); $amount = getReqVal('amount', '');
$currency = getReqVal('currency', ''); $currency = getReqVal('currency', '');
@ -143,11 +147,11 @@ class MallController extends BaseAuthedController {
$goodsUuid = getReqVal('goods_uuid', ''); $goodsUuid = getReqVal('goods_uuid', '');
$goodsDb = Mall::findByGoodsUuid($goodsUuid); $goodsDb = Mall::findByGoodsUuid($goodsUuid);
if (!$goodsDb) { if (!$goodsDb) {
myself()->_resErr(1, 'goods not found'); myself()->_rspErr(1, 'goods not found');
return; return;
} }
if ($goodDb['seller'] != myself()->_getAccountId()) { if ($goodsDb['seller'] != myself()->_getAccountId()) {
myself()->_resErr(1, 'goods not found'); myself()->_rspErr(1, 'goods not found');
return; return;
} }
Mall::cancel($goodsDb['goods_uuid']); Mall::cancel($goodsDb['goods_uuid']);
@ -160,11 +164,11 @@ class MallController extends BaseAuthedController {
$price = getReqVal('price', ''); $price = getReqVal('price', '');
$goodsDb = Mall::findByGoodsUuid($goodsUuid); $goodsDb = Mall::findByGoodsUuid($goodsUuid);
if (!$goodsDb) { if (!$goodsDb) {
myself()->_resErr(1, 'goods not found'); myself()->_rspErr(1, 'goods not found');
return; return;
} }
if ($goodDb['seller'] != myself()->_getAccountId()) { if ($goodsDb['seller'] != myself()->_getAccountId()) {
myself()->_resErr(1, 'goods not found'); myself()->_rspErr(1, 'goods not found');
return; return;
} }
Mall::modifyPrice($goodsDb['goods_uuid'], $price); Mall::modifyPrice($goodsDb['goods_uuid'], $price);

View File

@ -33,15 +33,16 @@ class Mall extends BaseModel {
} }
public static function add($orderId, $goodsUuid, $itemId, $itemNum, public static function add($orderId, $goodsUuid, $itemId, $itemNum,
$currency, $pirce) { $currency, $price) {
self::internalUpdate( SqlHelper::insert
$orderId, (myself()->_getMysql(''),
't_mall',
array( array(
'order_id' => $orderId, 'order_id' => $orderId,
'goods_uuid' => $goodsUuid, 'goods_uuid' => $goodsUuid,
'seller' => myself()->_getAccountId(), 'seller' => myself()->_getAccountId(),
'item_id' => $itemId, 'item_id' => $itemId,
'item_num' => $amount, 'item_num' => $itemNum,
'currency' => $currency, 'currency' => $currency,
'price' => $price, 'price' => $price,
'createtime' => myself()->_getNowTime(), 'createtime' => myself()->_getNowTime(),