53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace models;
|
|
|
|
require_once('phpcommon/bchelper.php');
|
|
|
|
use mt;
|
|
use phpcommon;
|
|
use phpcommon\SqlHelper;
|
|
|
|
class BuyRecord extends BaseModel {
|
|
|
|
public static function genOrderId($gameId, $funcId, $time, $buyerAddress)
|
|
{
|
|
SqlHelper::insert
|
|
(myself()->_getMarketMysql(),
|
|
't_buy_record',
|
|
array(
|
|
'blobdata' => json_encode($_REQUEST),
|
|
'buyer_address' => $buyerAddress,
|
|
'createtime' => myself()->_getNowTime(),
|
|
'modifytime' => myself()->_getNowTime()
|
|
)
|
|
);
|
|
$lastIdx = SqlHelper::getLastInsertId(myself()->_getMarketMysql());
|
|
if (empty($lastIdx)) {
|
|
die(json_encode(array(
|
|
'errcode' => 500,
|
|
'errmsg' => 'server internal error'
|
|
)));
|
|
}
|
|
$orderId = phpcommon\genOrderId($gameId, $funcId, $time, 0, $lastIdx);
|
|
if (!phpcommon\isValidOrderId($orderId)) {
|
|
die(json_encode(array(
|
|
'errcode' => 500,
|
|
'errmsg' => 'server internal error'
|
|
)));
|
|
}
|
|
SqlHelper::update
|
|
(myself()->_getMarketMysql(),
|
|
't_buy_record',
|
|
array(
|
|
'idx' => $lastIdx
|
|
),
|
|
array(
|
|
'order_id' => $orderId
|
|
)
|
|
);
|
|
return $orderId;
|
|
}
|
|
|
|
}
|