<?php
namespace app\models\user;

use crmeb\traits\ModelTrait;
use crmeb\basic\BaseModel;

class UserCoin extends BaseModel {

    use ModelTrait;

    public static function upsertAddr($uid, $symbol, $addr) {
        $cond = ['uid'=>$uid, 'symbol'=>$symbol];
        $row = self::where($cond)->find();
        if ($row) {
            return self::where($cond)->update(['addr'=>$addr]);
        }else{
            return self::create([
                'uid'=>$uid,
                'symbol'=>$symbol,
                'addr'=>$addr,
            ]);
        }
    }
}