game2006api/webapp/models/InGameMall.php
hujiabin 1958761e7a 1
2024-08-16 17:48:12 +08:00

134 lines
3.4 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_SKIN_TYPE = 1;
const CHIP_TYPE = 2;
const HERO_FRAGMENT_TYPE = 3;
const SKIN_FRAGMENT_TYPE = 4;
const GOLD_TYPE = 5;
const OTHER_TYPE = 11;
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, $payType,$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,
'pay_type' => $payType,
'price' => $price,
'order1' => $orderField,
'unit_price' => $price/$itemNum,
'last_modify_price_time' => myself()->_getNowTime(),
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
));
}
public static function modifyPrice($orderId, $price,$unitPrice)
{
SqlHelper::update
(myself()->_getMysql(''),
't_ingame_mall',
array(
'order_id' => $orderId
),
array(
'price' => $price,
'unit_price' => $unitPrice,
'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);
}
);
}
}