public function record() { $user = Yii::$app->session->get('user'); $model = Withdraw::find()->where(['userId' => $user['userId'], 'state' => Withdraw::STATE_APPLYING])->one(); if ($model) { return false; } $withdraw = new Withdraw(); $withdraw->userId = $user['userId']; $withdraw->money = $this->money; $withdraw->bitcoin = ceil(Scheme::calculateWithdrawBitcoin($user, $this->money)); //扣除云豆数为向上取整,有小数就整数部分加1 $withdraw->invoiceMoney = $this->invoiceMoney; $withdraw->invoiceNo = $this->invoiceNo; $withdraw->createDate = DateFunctions::getCurrentDate(); $withdraw->state = Withdraw::STATE_APPLYING; if (!$withdraw->save()) { throw new Exception("Withdraw save error"); } return true; }