This commit is contained in:
aozhiwei 2023-08-07 17:14:17 +08:00
parent 0b0042d423
commit 8b8824d193
2 changed files with 39 additions and 30 deletions

View File

@ -46,31 +46,7 @@ class MallController extends BaseAuthedController {
), ),
//'orderBy' => $orderBy, //'orderBy' => $orderBy,
'handle' => function ($row) use(&$out) { 'handle' => function ($row) use(&$out) {
$cancelCd = -1; array_push($out['rows'], Mall::toDto($row));
$modifyCd = -1;
if ($row['seller'] == myself()->_getAccountId() &&
$row['seller_address'] == myself()->_getAddress()) {
$cancelCd = myself()->_getNowTime() - $row['last_buy_time'];
if ($cancelCd > 3600 * 24) {
$cancelCd = 0;
}
$modifyCd = myself()->_getNowTime() - $row['last_modify_price_time'];
if ($modifyCd > 60 * 10) {
$modifyCd = 0;
}
}
array_push($out['rows'],
array(
'goods_uuid' => $row['goods_uuid'],
'seller' => $row['seller'],
'seller_address' => $row['seller_address'],
'item_id' => $row['item_id'],
'item_num' => $row['item_num'],
'currency' => $row['currency'],
'price' => $row['price'],
'cancel_countdown' => $cancelCd,
'modify_countdown' => $modifyCd
));
} }
), ),
$out['pagination'] $out['pagination']

View File

@ -10,7 +10,8 @@ class Mall extends BaseModel {
const BUY_OK_STATE = 1; const BUY_OK_STATE = 1;
const CANCEL_STATE = 2; const CANCEL_STATE = 2;
public static function findByGoodsUuid($goodsUuid){ public static function findByGoodsUuid($goodsUuid)
{
$row = SqlHelper::ormSelectOne( $row = SqlHelper::ormSelectOne(
myself()->_getMysql(''), myself()->_getMysql(''),
't_mall', 't_mall',
@ -21,7 +22,8 @@ class Mall extends BaseModel {
return $row; return $row;
} }
public static function findByOrderId($orderId){ public static function findByOrderId($orderId)
{
$row = SqlHelper::ormSelectOne( $row = SqlHelper::ormSelectOne(
myself()->_getMysql(''), myself()->_getMysql(''),
't_mall', 't_mall',
@ -33,7 +35,8 @@ class Mall extends BaseModel {
} }
public static function add($orderId, $goodsUuid, $itemId, $itemNum, public static function add($orderId, $goodsUuid, $itemId, $itemNum,
$currency, $price) { $currency, $price)
{
SqlHelper::insert SqlHelper::insert
(myself()->_getMysql(''), (myself()->_getMysql(''),
't_mall', 't_mall',
@ -51,7 +54,8 @@ class Mall extends BaseModel {
)); ));
} }
public static function modifyPrice($goodsUuid, $price) { public static function modifyPrice($goodsUuid, $price)
{
SqlHelper::update SqlHelper::update
(myself()->_getMysql(''), (myself()->_getMysql(''),
't_mall', 't_mall',
@ -64,7 +68,8 @@ class Mall extends BaseModel {
); );
} }
public static function cancel($goodsUuid) { public static function cancel($goodsUuid)
{
SqlHelper::update SqlHelper::update
(myself()->_getMysql(''), (myself()->_getMysql(''),
't_mall', 't_mall',
@ -77,4 +82,32 @@ class Mall extends BaseModel {
); );
} }
public static function toDto($row)
{
$cancelCd = -1;
$modifyCd = -1;
if ($row['seller'] == myself()->_getAccountId() &&
$row['seller_address'] == myself()->_getAddress()) {
$cancelCd = myself()->_getNowTime() - $row['last_buy_time'];
if ($cancelCd > 3600 * 24) {
$cancelCd = 0;
}
$modifyCd = myself()->_getNowTime() - $row['last_modify_price_time'];
if ($modifyCd > 60 * 10) {
$modifyCd = 0;
}
}
return array(
'goods_uuid' => $row['goods_uuid'],
'seller' => $row['seller'],
'seller_address' => $row['seller_address'],
'item_id' => $row['item_id'],
'item_num' => $row['item_num'],
'currency' => $row['currency'],
'price' => $row['price'],
'cancel_countdown' => $cancelCd,
'modify_countdown' => $modifyCd
);
}
} }