/** * 添加初算结果 */ public function addFirstResultAction() { //直接接受backbone的模型json字符串并解码未关联数组 $json_data = $this->request->getJsonRawBody(true); $result = InsuranceCalculator::calInsuranceResult(new Criteria($json_data)); $new_param_id = Insurance::addInsuranceParam($json_data); if (!$new_param_id) { $this->view->setVars(array('success' => false)); return; } $new_result_id = Insurance::addInsuranceResult($result); if (!$new_result_id) { $this->view->setVars(array('success' => false)); return; } $user = User::getCurrentUser(); $insurance_info = array('user_id' => $user['user_id'], 'car_type_id' => !empty($json_data['car_type_id']) ? $json_data['car_type_id'] : 1, 'insurance_param_id' => $new_param_id, 'insurance_result_id' => $new_result_id, 'state_id' => 1, 'user_name' => isset($user['uname']) ? $user['uname'] : '微博用户'); $new_info_id = Insurance::addInsuranceInfo($insurance_info); if (!$new_info_id) { $this->view->setVars(array('success' => false)); return; } $this->view->setVars(array('success' => true, 'row' => array('info_id' => $new_info_id))); }