game2006api/webapp/models/InGameMall.php
hujiabin 1b8db59b6b 1
2024-05-21 17:28:07 +08:00

130 lines
3.3 KiB
PHP

<?php
namespace models;
use phpcommon\SqlHelper;
class InGameMall extends BaseModel {
const PENDING_STATE = 0;
const BUY_OK_STATE = 1;
const CANCEL_STATE = 2;
const HERO_TYPE = 1;
const CHIP_TYPE = 2;
const HERO_FRAGMENT_TYPE = 3;
const CHIP_FRAGMENT_TYPE = 4;
const BOX_TYPE = 5;
const GOLD_TYPE = 6;
const SYSTEM_MALL_ACCOUNT = "kingsome";
public static function findByOrderId($orderId)
{
$row = SqlHelper::ormSelectOne(
myself()->_getMysql(''),
't_ingame_mall',
array(
'order_id' => $orderId
)
);
return $row;
}
public static function add($orderId, $orderType, $goodsUniid,$itemId, $itemNum, $price, $orderField)
{
SqlHelper::insert
(myself()->_getMysql(''),
't_ingame_mall',
array(
'order_id' => $orderId,
'order_type' => $orderType,
'seller' => myself()->_getAccountId(),
'seller_address' => myself()->_getAddress(),
'goods_uniid' => $goodsUniid,
'item_id' => $itemId,
'item_num' => $itemNum,
'price' => $price,
'order1' => $orderField,
'last_modify_price_time' => myself()->_getNowTime(),
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
));
}
public static function modifyPrice($orderId, $price)
{
SqlHelper::update
(myself()->_getMysql(''),
't_ingame_mall',
array(
'order_id' => $orderId
),
array(
'price' => $price,
'last_modify_price_time' => myself()->_getNowTime(),
)
);
}
public static function cancel($orderId)
{
SqlHelper::update
(myself()->_getMysql(''),
't_ingame_mall',
array(
'order_id' => $orderId
),
array(
'status' => self::CANCEL_STATE,
'modifytime' => myself()->_getNowTime(),
)
);
}
public static function buyOk($orderId, $buyer)
{
SqlHelper::update
(myself()->_getMysql(''),
't_ingame_mall',
array(
'order_id' => $orderId
),
array(
'status' => self::BUY_OK_STATE,
'buyer' => $buyer,
'buy_ok_time' => myself()->_getNowTime()
)
);
}
public static function getMySell($cb){
SqlHelper::ormSelect(
myself()->_getMysql(''),
't_ingame_mall',
array(
'seller' => myself()->_getAccountId()
),
function ($row) use($cb) {
$cb($row);
}
);
}
public static function getMyBuy($cb){
SqlHelper::ormSelect(
myself()->_getMysql(''),
't_ingame_mall',
array(
'buyer' => myself()->_getAccountId()
),
function ($row) use($cb) {
$cb($row);
}
);
}
}