1
This commit is contained in:
parent
a7ca1bdc47
commit
de58d063ed
@ -62,7 +62,80 @@ class MallController extends BaseAuthedController {
|
|||||||
|
|
||||||
public function sell()
|
public function sell()
|
||||||
{
|
{
|
||||||
|
$address = $this->_getAddress();
|
||||||
|
if (!$address) {
|
||||||
|
$this->_rspErr(1, 'address not found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$itemId = getReqVal('item_id', '');
|
||||||
|
$amount = getReqVal('amount', '');
|
||||||
|
$currency = getReqVal('currency', '');
|
||||||
|
$price = getReqVal('price', '');
|
||||||
|
if ($itemId != V_ITEM_GOLD) {
|
||||||
|
$this->_rspErr(1, 'only support gold');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (empty($price)) {
|
||||||
|
$this->_rspErr(1, 'price not found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($price <= 0) {
|
||||||
|
$this->_rspErr(1, 'price must > 0');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (empty($amount)) {
|
||||||
|
$this->_rspErr(1, 'amount not found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!is_numeric($amount)) {
|
||||||
|
$this->_rspErr(1, 'amount must be number');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($amount <= 0) {
|
||||||
|
$this->_rspErr(1, 'amount must > 0');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!in_array(
|
||||||
|
$currency,
|
||||||
|
array(
|
||||||
|
'CEG',
|
||||||
|
'USDC',
|
||||||
|
'USDT'
|
||||||
|
)
|
||||||
|
)) {
|
||||||
|
$this->_rspErr(1, 'paramater error currency');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$costItems = array(
|
||||||
|
array(
|
||||||
|
'item_id' => $itemId,
|
||||||
|
'item_num' => $amount
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$lackItem = null;
|
||||||
|
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||||
|
$this->_rspErr(2, $this->_getLackItemErrMsg($lackItem));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->_decItems($costItems);
|
||||||
|
if ($itemId == V_ITEM_GOLD) {
|
||||||
|
//埋点
|
||||||
|
$event = [
|
||||||
|
'name' => LogService::MARKET_SELL_GOLD,
|
||||||
|
'val' => $amount
|
||||||
|
];
|
||||||
|
LogService::consumeGold($event);
|
||||||
|
}
|
||||||
|
$orderId = OrderId::gen();
|
||||||
|
Mall::Add(
|
||||||
|
$orderId,
|
||||||
|
$orderId,
|
||||||
|
$itemId,
|
||||||
|
$amount,
|
||||||
|
$currency,
|
||||||
|
$price
|
||||||
|
);
|
||||||
|
myself()->_rspOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cancel()
|
public function cancel()
|
||||||
|
@ -32,19 +32,18 @@ class Mall extends BaseModel {
|
|||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function add($orderId, $tokenId, $seller, $nftToken,
|
public static function add($orderId, $goodsUuid, $itemId, $itemNum,
|
||||||
$amount, $currency, $pirce) {
|
$currency, $pirce) {
|
||||||
self::internalUpdate(
|
self::internalUpdate(
|
||||||
$orderId,
|
$orderId,
|
||||||
array(
|
array(
|
||||||
'token_id' => $tokenId,
|
'order_id' => $orderId,
|
||||||
'seller' => $seller,
|
'goods_uuid' => $goodsUuid,
|
||||||
'nft_token' => $nftToken,
|
'seller' => myself()->_getAccountId(),
|
||||||
'amount' => $amount,
|
'item_id' => $itemId,
|
||||||
|
'item_num' => $amount,
|
||||||
'currency' => $currency,
|
'currency' => $currency,
|
||||||
'price' => $price,
|
'price' => $price,
|
||||||
'activated' => 1,
|
|
||||||
'selltime' => myself()->_getNowTime(),
|
|
||||||
'createtime' => myself()->_getNowTime(),
|
'createtime' => myself()->_getNowTime(),
|
||||||
'modifytime' => myself()->_getNowTime(),
|
'modifytime' => myself()->_getNowTime(),
|
||||||
));
|
));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user