public function traffic_guide() { $hospital_info = $this->get_hospital_info(); if ($hospital_info) { // For html response $this->set_template('hospital.traffic_guide'); $this->set_data(array('phone' => $hospital_info->phone, 'latitude' => $hospital_info->latitude, 'longtitude' => $hospital_info->longtitude, 'traffic_guide' => $hospital_info->traffic_guide, 'traffic_intro' => $hospital_info->traffic_intro)); // Post process function: // Remove html tags in value of keys 'traffic_intro' and 'traffic_guide' $this->set_postprocess_function('json', function ($result, $status) { if ($status) { $result['traffic_intro'] = strip_tags($result['traffic_intro']); $result['traffic_guide'] = strip_tags($result['traffic_guide']); } return $result; }); // Post function: // Get weixin access token and javascript api ticket $this->set_postprocess_function('html', function ($result, $status) use($hospital_info) { if ($status) { $app_id = Config::get('weixin.app_id'); $app_secret = Config::get('weixin.app_secret'); $wx = new WeixinSDK($app_id, $app_secret, new DataStorageWrapper()); $sign_package = $wx->getSignPackage(); $result['hospital'] = array('name' => $hospital_info->name, 'latitude' => $hospital_info->latitude, 'longtitude' => $hospital_info->longtitude); $result['app_id'] = $app_id; $result['sign_package'] = $sign_package; $result['baidu_map_app_key'] = Config::get('platform.baidu.map.app_key'); } return $result; }); } else { $this->set_error_code(1); } return $this->response(); }
public function modify_return() { $record = RegisterRecord::find(Input::get('record_id')); // 是否存在该记录 if (!isset($record)) { return Response::json(array('error_code' => 2, 'message' => '不存在该挂号记录')); } // 检查该就诊记录是否该医生的 if ($record->doctor_id != Session::get('doctor.id')) { return Response::json(array('error_code' => 3, 'message' => '无法修改该挂号')); } // 检查就诊状态 if (!(int) $record->status) { return Response::json(array('error_code' => 4, 'message' => '尚未就诊')); } $record->return_date = Input::get('date'); $record->status = 2; // 修改状态 --> 2 - 需复诊 if (!$record->save()) { return Response::json(array('error_code' => 1, 'message' => '设置失败')); } // 通过微信公众号向永华发送模板消息 if (isset($weixin_pay_order) && $weixin_pay_order->status == 'FINISHED') { $doctor = $record->doctor; WeixinSDK::send_template_message(['touser' => $weixin_pay_order->open_id, 'template_id' => Config::get('weixin.template.return'), 'topcolor' => '#FF00000', 'data' => array('first' => ['value' => '您好,您的复诊时间已到,请及时进行复诊。'], 'keyword1' => ['value' => $record->account->name], 'keyword2' => ['value' => $doctor->department->hospital->name], 'keyword3' => ['value' => $doctor->name], 'keyword4' => ['value' => $record->return_date], 'remark' => ['value' => '祝您身体健康!'])]); } return Response::json(array('error_code' => 0, 'message' => '设置成功', 'return_date' => $record->return_date)); }