102 lines
2.8 KiB
PHP
102 lines
2.8 KiB
PHP
<?php
|
|
|
|
require_once('mt/Item.php');
|
|
require_once('mt/Parameter.php');
|
|
|
|
require_once('models/BcOrder.php');
|
|
require_once('models/Mall.php');
|
|
|
|
require_once('services/BlockChainService.php');
|
|
require_once('services/LogService.php');
|
|
|
|
use phpcommon\SqlHelper;
|
|
|
|
use models\BcOrder;
|
|
use models\Mall;
|
|
|
|
use services\LogService;
|
|
use services\BlockChainService;
|
|
|
|
class MallController extends BaseAuthedController {
|
|
|
|
public function productList()
|
|
{
|
|
$page = getReqVal('page', 1);
|
|
$queryData = array();
|
|
|
|
$out = array(
|
|
'pagination' => array(),
|
|
'rows' => array()
|
|
);
|
|
SqlHelper::rawQueryPage(
|
|
myself()->_getMySql(''),
|
|
'SELECT * FROM t_mall WHERE status=:status',
|
|
array(
|
|
':status' => Mall::PENDING_STATE
|
|
),
|
|
array(
|
|
'page' => $page,
|
|
'perPage' => 10,
|
|
'filter' => array(
|
|
'data' => $queryData,
|
|
'fields' => array(
|
|
)
|
|
),
|
|
//'orderBy' => $orderBy,
|
|
'handle' => function ($row) {
|
|
array_push($out['rows'],
|
|
array(
|
|
'goods_uuid' => $row['goods_uuid'],
|
|
'seller' => $row['seller'],
|
|
'item_id' => $row['item_id'],
|
|
'item_num' => $row['item_num'],
|
|
'currency' => $row['currency'],
|
|
'price' => $row['price'],
|
|
));
|
|
}
|
|
),
|
|
$out['pagination']
|
|
);
|
|
myself()->_rspData($out);
|
|
}
|
|
|
|
public function sell()
|
|
{
|
|
|
|
}
|
|
|
|
public function cancel()
|
|
{
|
|
$goodsUuid = getReqVal('goods_uuid', '');
|
|
$goodsDb = Mall::findByGoodsUuid($goodsUuid);
|
|
if (!$goodsDb) {
|
|
myself()->_resErr(1, 'goods not found');
|
|
return;
|
|
}
|
|
if ($goodDb['seller'] != myself()->_getAccountId()) {
|
|
myself()->_resErr(1, 'goods not found');
|
|
return;
|
|
}
|
|
Mall::cancel($goodsDb['goods_uuid']);
|
|
myself()->_rspOk();
|
|
}
|
|
|
|
public function modifyPrice()
|
|
{
|
|
$goodsUuid = getReqVal('goods_uuid', '');
|
|
$price = getReqVal('price', '');
|
|
$goodsDb = Mall::findByGoodsUuid($goodsUuid);
|
|
if (!$goodsDb) {
|
|
myself()->_resErr(1, 'goods not found');
|
|
return;
|
|
}
|
|
if ($goodDb['seller'] != myself()->_getAccountId()) {
|
|
myself()->_resErr(1, 'goods not found');
|
|
return;
|
|
}
|
|
Mall::modifyPrice($goodsDb['goods_uuid'], $price);
|
|
$this->_rspOk();
|
|
}
|
|
|
|
}
|