82 lines
2.4 KiB
PHP
82 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace models;
|
|
|
|
use mt;
|
|
use phpcommon\SqlHelper;
|
|
|
|
class InAppRecord extends BaseModel {
|
|
|
|
public static function get()
|
|
{
|
|
$row = SqlHelper::ormSelectOne(
|
|
myself()->_getSelfMysql(),
|
|
't_inapp_record',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'daytime' => myself()->_getNowDaySeconds()
|
|
)
|
|
);
|
|
return $row;
|
|
}
|
|
|
|
public static function addAmount($amount)
|
|
{
|
|
SqlHelper::upsert(
|
|
myself()->_getSelfMysql(),
|
|
't_inapp_record',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'daytime' => myself()->_getNowDaySeconds()
|
|
),
|
|
array(
|
|
'amount' => function () use($amount) {
|
|
return 'amount + ' + $amount;
|
|
},
|
|
'buy_times' => function () {
|
|
return 'buy_times + 1';
|
|
},
|
|
'modifytime' => myself()->_getNowTime(),
|
|
),
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'amount' => $amount,
|
|
'buy_times' => 1,
|
|
'daytime' => myself()->_getNowDaySeconds(),
|
|
'createtime' => myself()->_getNowTime(),
|
|
'modifytime' => myself()->_getNowTime(),
|
|
)
|
|
);
|
|
}
|
|
|
|
public static function addAmountOk($accountId, $amount)
|
|
{
|
|
SqlHelper::upsert(
|
|
myself()->_getMysql($accountId),
|
|
't_inapp_record',
|
|
array(
|
|
'account_id' => $accountId,
|
|
'daytime' => myself()->_getNowDaySeconds()
|
|
),
|
|
array(
|
|
'amount_ok' => function () use($amount) {
|
|
return 'amount_ok + ' + $amount;
|
|
},
|
|
'buy_ok_times' => function () use($amount) {
|
|
return 'buy_ok_times + 1';
|
|
},
|
|
'modifytime' => myself()->_getNowTime(),
|
|
),
|
|
array(
|
|
'account_id' => $accountId,
|
|
'amount_ok' => $amount,
|
|
'buy_ok_times' => 1,
|
|
'daytime' => myself()->_getNowDaySeconds(),
|
|
'createtime' => myself()->_getNowTime(),
|
|
'modifytime' => myself()->_getNowTime(),
|
|
)
|
|
);
|
|
}
|
|
|
|
}
|