p2 project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB

3 months ago
<?php
namespace app\model;
class UserStockIndexInrModel extends BaseModel
{
protected $name = 'user_stock_index_inr';
public static function getUserStockIndexInrLock(int $user_id,string $contract_id ='INR'):array
{
$info = self::where([
'user_id'=>$user_id,
'contract_id'=>$contract_id
])->lock(true)->find();
if(empty($info)){
// 如果没有则创建
$info = new self;
$info->user_id = $user_id;
$info->contract_id = $contract_id;
$info->usable_num = 0;
$info->frozen_num = 0;
$info->create_time = date('Y-m-d H:i:s');
$info->update_time = date('Y-m-d H:i:s');
$info->save();
}
return $info->toArray();
}
public static function updateUserStockIndexInr(array $update_data,array $where)
{
$update_data['update_time']=date('Y-m-d H:i:s');
$res=self::where($where)->save($update_data);
//echo self::where($where)->getLastSql();
return $res;
}
}