http($api, [ 'address' => $address ]); if ($response['errcode'] != 0) { exception('errorinfo'); } $lessen = pow(10, $this->currency->decimal_scale); return $response['data']['balance'] / $lessen; } /** * 更新钱包余额 * * @return mixed */ public function updateBalance($wallet) { // TODO: Implement updateBalance() method. $this->canUpdateBalance($wallet); $balance = $this->balance($wallet->address); if ($balance > $wallet->old_balance) { $wallet->old_balance = $balance; $number = $balance - $wallet->old_balance; $wallet->save(); UsersWallet::changeBalance($wallet->user_id, $wallet->currency_id, $number, AccountLog::UPDATED_BALACNE); } } }