public function bookBuyAction() { if (!$this->thisController->id) { return $this->thisController->displayAjax(false, '参数有误'); } $book_info = self::$service->getBook($this->thisController->id); if (!$book_info) { return $this->thisController->displayAjax(false, '参数有误'); } if (IS_POST) { $form = BaseForm::getForm('BookOrderForm'); if (!$form->isValid($this->thisController->request->getPost())) { foreach ($form->getMessages() as $message) { return $this->thisController->displayAjax(false, $message->getMessage()); } } //写入数据 $data = $this->thisController->request->getPost(); $data['number'] = st_order_number(); $data['book_id'] = $this->thisController->id; if ($book_info->getPrice() <= 0) { $data['pay_status'] = 2; $data['status'] = 3; //已支付 } else { $data['pay_status'] = 1; $data['status'] = 4; //未支付 } $data['price'] = $book_info->getPrice(); $data['good_id'] = 0; $data['credit'] = 0; $data['uid'] = $this->thisController->user->id; $result = self::$service->insertCommon($data, 'Order'); return $this->thisController->ajax($result); } }