aozhiwei 20165d5e3b 1
2023-08-07 13:18:24 +08:00

80 lines
2.0 KiB
PHP

<?php
namespace models;
use phpcommon\SqlHelper;
class Mall extends BaseModel {
const PENDING_STATE = 0;
const BUY_OK_STATE = 1;
const CANCEL_STATE = 2;
public static function findByGoodsUuid($goodsUuid){
$row = SqlHelper::ormSelectOne(
myself()->_getMysql(''),
't_mall',
array(
'goods_uuid' => $goodsUuid
)
);
return $row;
}
public static function findByOrderId($orderId){
$row = SqlHelper::ormSelectOne(
myself()->_getMysql(''),
't_mall',
array(
'order_id' => $orderId
)
);
return $row;
}
public static function add($orderId, $goodsUuid, $itemId, $itemNum,
$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) {
SqlHelper::update
(myself()->_getMysql(''),
't_mall',
array(
'goods_uuid' => $goodsUuid
),
array(
'price' => $price
)
);
}
public static function cancel($goodsUuid) {
SqlHelper::update
(myself()->_getMysql(''),
't_mall',
array(
'goods_uuid' => $goodsUuid
),
array(
'status' => self::CANCEL_STATE
)
);
}
}