This commit is contained in:
aozhiwei 2023-08-05 16:40:20 +08:00
parent 91aeddeb70
commit 265338b9f0

View File

@ -7,8 +7,8 @@ use phpcommon\SqlHelper;
class Market extends BaseModel {
const PENDING_STATE = 0;
const BUY_OK_STATUS = 1;
const CANCEL_STATUS = 2;
const BUY_OK_STATE = 1;
const CANCEL_STATE = 2;
public static function find($orderId){
$row = SqlHelper::ormSelectOne(
@ -21,19 +21,47 @@ class Market extends BaseModel {
return $row;
}
public static function add($orderId, $fieldsKv) {
public static function add($orderId, $tokenId, $owner, $nftToken,
$amount, $currency, $pirce) {
self::internalUpdate(
$orderId,
array(
'token_id' => $tokenId,
'owner' => $owner,
'nft_token' => $nftToken,
'amount' => $amount,
'currency' => $currency,
'price' => $price,
'activated' => 1,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
));
}
public static function updatePrice($orderId, $currency, $price) {
self::internalUpdate(
$orderId,
array(
'update_currency' => $currency,
'update_price' => $price,
'update_time' => myself()->_getNowTime(),
));
}
public static function buyOk($orderId) {
self::internalUpdate(
$orderId,
array(
'status' => self::BUY_OK_STATE,
));
}
public static function cancel($orderId) {
self::internalUpdate(
$orderId,
array(
'status' => self::CANCEL_STATE,
));
}
private static function internalUpdate($orderId, $fieldsKv){
@ -47,6 +75,8 @@ class Market extends BaseModel {
),
array(
'order_id' => $orderId,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
)
);
SqlHelper::update