public function record() { $user = Yii::$app->session->get('user'); $invoice = Invoice::findApplyingByUser($user['userId']); if ($invoice) { return false; } $invoice = new Invoice(); $user = Yii::$app->session->get('user'); $invoice->userId = $user['userId']; $invoice->money = $this->money; $invoice->address = $user['address']; $invoice->createDate = DateFunctions::getCurrentDate(); $invoice->state = Invoice::STATE_ING; $invoice->address = $this->address; if (!$invoice->save()) { throw new Exception("Invoice save error"); } return true; }
public function record() { $user = Yii::$app->session->get('user'); $invoice = Invoice::findApplyingByUser($user['userId']); if ($invoice) { CommonFunctions::createAlertMessage("发票申请失败,您已经有正在申请中的发票了,一次只能申请一张", "error"); return false; } else { $invoice = new Invoice(); $invoice->userId = $user['userId']; $invoice->address = $this->address; $invoice->money = $this->money; $invoice->description = $this->description; $invoice->createDate = DateFunctions::getCurrentDate(); $invoice->state = Invoice::STATE_ING; if (!$invoice->save()) { throw new Exception("Apply Invoice save error"); } return true; } }