64 lines
1.5 KiB
PHP
64 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace models;
|
|
|
|
use mt;
|
|
use phpcommon\SqlHelper;
|
|
|
|
class InAppOrder extends BaseModel {
|
|
|
|
const PENDING_STATE = 0;
|
|
const FINISHED_STATE = 1;
|
|
const FAILED_STATE = 2;
|
|
|
|
const ANDROID_PLATFORM = 1;
|
|
const IOS_PLATFORM = 2;
|
|
|
|
public static function find($orderId)
|
|
{
|
|
$row = SqlHelper::ormSelectOne(
|
|
myself()->_getMysql(''),
|
|
't_inapp_order',
|
|
array(
|
|
'order_id' => $orderId,
|
|
)
|
|
);
|
|
return $row;
|
|
}
|
|
|
|
public static function add($orderId, $platform, $goodsId, $price)
|
|
{
|
|
SqlHelper::insert(
|
|
myself()->_getMysql(''),
|
|
't_inapp_order',
|
|
array(
|
|
'order_id' => $orderId,
|
|
'account_id' => myself()->_getAccountId(),
|
|
'platform' => $platform,
|
|
'goods_id' => $goodsId,
|
|
'price' => $price,
|
|
'createtime' => myself()->_getNowTime(),
|
|
'modifytime' => myself()->_getNowTime(),
|
|
)
|
|
);
|
|
}
|
|
|
|
public static function update($orderId, $fieldsKv)
|
|
{
|
|
SqlHelper::update(
|
|
myself()->_getMysql(''),
|
|
't_inapp_order',
|
|
array(
|
|
'order_id' => $orderId
|
|
),
|
|
$fieldsKv
|
|
);
|
|
}
|
|
|
|
public static function isValidPlatform($platform)
|
|
{
|
|
return in_array($platform, array(self::ANDROID_PLATFORM, self::IOS_PLATFORM));
|
|
}
|
|
|
|
}
|