4 changed files with 76 additions and 1 deletions
@ -0,0 +1,37 @@ |
|||
<?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; |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue