diff --git a/app/Controller/DoctorInquiryConfigController.php b/app/Controller/DoctorInquiryConfigController.php index 3b98f12..41ba786 100644 --- a/app/Controller/DoctorInquiryConfigController.php +++ b/app/Controller/DoctorInquiryConfigController.php @@ -12,6 +12,22 @@ use Psr\Http\Message\ResponseInterface; class DoctorInquiryConfigController extends AbstractController { + /** + * 获取医生问诊服务开启状态 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function getDoctorInquiryConfigOpenStatus(): ResponseInterface + { + $request = $this->container->get(DoctorInquiryConfigRequest::class); + $request->scene('getDoctorInquiryConfigOpenStatus')->validateResolved(); + + $DoctorInquiryService = new DoctorInquiryService(); + $data = $DoctorInquiryService->getDoctorInquiryConfigOpenStatus(); + return $this->response->json($data); + } + /** * 获取医生问诊配置 * @return ResponseInterface @@ -61,50 +77,107 @@ class DoctorInquiryConfigController extends AbstractController } /** - * 获取医生问诊配置-服务设置 + * 获取医生问诊配置-疑难会诊-服务设置 * @return ResponseInterface * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function getInquiryServiceConfig(): ResponseInterface + public function getDoctorInquiryDifficultConfig(): ResponseInterface { $request = $this->container->get(DoctorInquiryConfigRequest::class); - $request->scene('getInquiryServiceConfig')->validateResolved(); + $request->scene('getDoctorInquiryDifficultConfig')->validateResolved(); $DoctorInquiryService = new DoctorInquiryService(); - $data = $DoctorInquiryService->getInquiryServiceConfig(); + $data = $DoctorInquiryService->getDoctorInquiryDifficultConfig(); return $this->response->json($data); } /** - * 新增医生问诊配置-服务设置 + * 新增医生问诊配置-疑难会诊-服务设置 * @return ResponseInterface * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function addInquiryServiceConfig(): ResponseInterface + public function addDoctorInquiryDifficultConfig(): ResponseInterface { $request = $this->container->get(DoctorInquiryConfigRequest::class); - $request->scene('addInquiryServiceConfig')->validateResolved(); + $request->scene('addDoctorInquiryDifficultConfig')->validateResolved(); $DoctorInquiryService = new DoctorInquiryService(); - $data = $DoctorInquiryService->addInquiryServiceConfig(); + $data = $DoctorInquiryService->addDoctorInquiryDifficultConfig(); return $this->response->json($data); } /** - * 修改医生问诊配置-服务设置 + * 修改医生问诊配置-疑难会诊-服务设置 * @return ResponseInterface * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function putInquiryServiceConfig(): ResponseInterface + public function putDoctorInquiryDifficultConfig(): ResponseInterface { $request = $this->container->get(DoctorInquiryConfigRequest::class); - $request->scene('putInquiryServiceConfig')->validateResolved(); + $request->scene('putDoctorInquiryDifficultConfig')->validateResolved(); $DoctorInquiryService = new DoctorInquiryService(); - $data = $DoctorInquiryService->putInquiryServiceConfig(); + $data = $DoctorInquiryService->putDoctorInquiryDifficultConfig(); return $this->response->json($data); } + + /** + * 获取医生问诊配置-随访包 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function getDoctorInquiryFollowConfig(): ResponseInterface + { + $DoctorInquiryService = new DoctorInquiryService(); + $data = $DoctorInquiryService->getDoctorInquiryFollowConfig(); + return $this->response->json($data); + } + + /** + * 获取医生问诊配置-随访包-列表 + * @return ResponseInterface + */ + public function getDoctorInquiryFollowItemConfig(): ResponseInterface + { + $DoctorInquiryService = new DoctorInquiryService(); + $data = $DoctorInquiryService->getDoctorInquiryFollowItemConfig(); + return $this->response->json($data); + } + + /** + * 新增医生问诊配置-随访包 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function addDoctorInquiryFollowConfig(): ResponseInterface + { + $request = $this->container->get(DoctorInquiryConfigRequest::class); + $request->scene('addDoctorInquiryFollowConfig')->validateResolved(); + + $DoctorInquiryService = new DoctorInquiryService(); + $data = $DoctorInquiryService->addDoctorInquiryFollowConfig(); + return $this->response->json($data); + } + + /** + * 修改医生问诊配置-随访包 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function putDoctorInquiryFollowConfig(): ResponseInterface + { + $request = $this->container->get(DoctorInquiryConfigRequest::class); + $request->scene('putDoctorInquiryFollowConfig')->validateResolved(); + + $DoctorInquiryService = new DoctorInquiryService(); + $data = $DoctorInquiryService->putDoctorInquiryFollowConfig(); + return $this->response->json($data); + } + } \ No newline at end of file diff --git a/app/Controller/SystemController.php b/app/Controller/SystemController.php index adad20d..fe1bc48 100644 --- a/app/Controller/SystemController.php +++ b/app/Controller/SystemController.php @@ -29,4 +29,20 @@ class SystemController extends AbstractController $data = $SystemService->getSystemInquiryTime(); return $this->response->json($data); } + + /** + * 获取系统问诊配置 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function getSystemInquiryConfig(): ResponseInterface + { + $request = $this->container->get(SystemRequest::class); + $request->scene('getSystemInquiryConfig')->validateResolved(); + + $SystemService = new SystemService(); + $data = $SystemService->getSystemInquiryConfig(); + return $this->response->json($data); + } } \ No newline at end of file diff --git a/app/Model/DoctorConfigFollowPackage.php b/app/Model/DoctorConfigFollowPackage.php new file mode 100644 index 0000000..1f4c7c3 --- /dev/null +++ b/app/Model/DoctorConfigFollowPackage.php @@ -0,0 +1,78 @@ +first($fields); + } + + /** + * 多条 + * @param array $params + * @param array $fields + * @return Collection|array + */ + public static function getList(array $params, array $fields = ['*']): Collection|array + { + return self::where($params)->get($fields); + } + + /** + * 新增 + * @param array $data + * @return DoctorConfigFollowPackage|\Hyperf\Database\Model\Model + */ + public static function addDoctorConfigFollowPackage(array $data): \Hyperf\Database\Model\Model|DoctorConfigFollowPackage + { + return self::create($data); + } + + /** + * 修改 + * @param array $params + * @param array $data + * @return int + */ + public static function edit(array $params = [], array $data = []): int + { + return self::where($params)->update($data); + } +} diff --git a/app/Model/DoctorConfigFollowPackageItem.php b/app/Model/DoctorConfigFollowPackageItem.php new file mode 100644 index 0000000..78015ef --- /dev/null +++ b/app/Model/DoctorConfigFollowPackageItem.php @@ -0,0 +1,78 @@ +first($fields); + } + + /** + * 多条 + * @param array $params + * @param array $fields + * @return Collection|array + */ + public static function getList(array $params, array $fields = ['*']): Collection|array + { + return self::where($params)->get($fields); + } + + /** + * 新增 + * @param array $data + * @return DoctorConfigFollowPackageItem|\Hyperf\Database\Model\Model + */ + public static function addDoctorConfigFollowPackageItem(array $data): \Hyperf\Database\Model\Model|DoctorConfigFollowPackageItem + { + return self::create($data); + } + + /** + * 删除 + * @param array $params + * @return int|mixed + */ + public static function del(array $params): mixed + { + return self::where($params)->delete(); + } +} diff --git a/app/Model/SystemInquiryConfig.php b/app/Model/SystemInquiryConfig.php index ebb9b01..410bc7e 100644 --- a/app/Model/SystemInquiryConfig.php +++ b/app/Model/SystemInquiryConfig.php @@ -15,6 +15,7 @@ use Hyperf\Snowflake\Concern\Snowflake; * @property int $inquiry_mode 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊 7:附赠 8:健康包 9:随访包) * @property int $default_work_num_day 默认每日接诊数量 * @property int $max_work_num_day 每日最大接诊数量 + * @property int $min_work_num_day 每日最小接诊数量 * @property string $inquiry_price 接诊价格 * @property string $min_inquiry_price 最低接诊价格(专家问诊) * @property string $max_inquiry_price 最高接诊价格(专家问诊) @@ -35,12 +36,12 @@ class SystemInquiryConfig extends Model /** * The attributes that are mass assignable. */ - protected array $fillable = ['system_inquiry_config_id', 'inquiry_type', 'inquiry_mode', 'default_work_num_day', 'max_work_num_day', 'inquiry_price', 'min_inquiry_price', 'max_inquiry_price', 'times_number', 'duration', 'created_at', 'updated_at']; + protected array $fillable = ['system_inquiry_config_id', 'inquiry_type', 'inquiry_mode', 'default_work_num_day', 'max_work_num_day', 'min_work_num_day', 'inquiry_price', 'min_inquiry_price', 'max_inquiry_price', 'times_number', 'duration', 'created_at', 'updated_at']; /** * The attributes that should be cast to native types. */ - protected array $casts = ['system_inquiry_config_id' => 'string', 'inquiry_type' => 'integer', 'inquiry_mode' => 'integer', 'max_work_num_day' => 'integer', 'times_number' => 'integer', 'duration' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'default_work_num_day' => 'integer']; + protected array $casts = ['system_inquiry_config_id' => 'string', 'inquiry_type' => 'integer', 'inquiry_mode' => 'integer', 'max_work_num_day' => 'integer', 'times_number' => 'integer', 'duration' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'default_work_num_day' => 'integer', 'min_work_num_day' => 'integer']; protected string $primaryKey = "system_inquiry_config_id"; diff --git a/app/Request/DoctorInquiryConfigRequest.php b/app/Request/DoctorInquiryConfigRequest.php index b3ed7cb..0e02479 100644 --- a/app/Request/DoctorInquiryConfigRequest.php +++ b/app/Request/DoctorInquiryConfigRequest.php @@ -11,6 +11,10 @@ use Hyperf\Validation\Rule; class DoctorInquiryConfigRequest extends FormRequest { protected array $scenes = [ + 'getDoctorInquiryConfigOpenStatus' => [ // 获取医生问诊服务开启状态 + 'inquiry_type', + 'inquiry_mode', + ], 'getDoctorInquiryConfig' => [ // 获取医生问诊配置 'inquiry_type', 'inquiry_mode', @@ -26,22 +30,32 @@ class DoctorInquiryConfigRequest extends FormRequest 'inquiry_price', 'work_num_day', ], - 'getInquiryServiceConfig' => [ // 获取医生问诊配置-服务设置 + 'getDoctorInquiryDifficultConfig' => [ // 获取医生问诊配置-疑难会诊-服务设置 'inquiry_type', 'inquiry_mode', ], - 'addInquiryServiceConfig' => [ // 新增医生问诊配置-服务设置 + 'addDoctorInquiryDifficultConfig' => [ // 新增医生问诊配置-疑难会诊-服务设置 'service_content', 'service_process', 'service_period', 'service_rounds', ], - 'putInquiryServiceConfig' => [ // 修改医生问诊配置-服务设置 + 'putDoctorInquiryDifficultConfig' => [ // 修改医生问诊配置-疑难会诊-服务设置 'service_content', 'service_process', 'service_period', 'service_rounds', ], + 'addDoctorInquiryFollowConfig' => [ // 新增医生问诊配置-随访包 + 'monthly_frequency', // 每月次数(0表示不限次) + 'service_rounds', // 服务回合数(0表示不限次) + 'items', // 随访包内容列表数据 + ], + 'putDoctorInquiryFollowConfig' => [ // 修改医生问诊配置-随访包 + 'monthly_frequency', // 每月次数(0表示不限次) + 'service_rounds', // 服务回合数(0表示不限次) + 'items', // 随访包内容列表数据 + ], ]; /** @@ -59,7 +73,7 @@ class DoctorInquiryConfigRequest extends FormRequest { return [ 'inquiry_type' => 'required|integer|min:1|max:3', - 'inquiry_mode' => 'required|integer|min:1|max:6', + 'inquiry_mode' => 'required|integer|min:1|max:9', 'is_open' => "required|boolean", 'inquiry_price' => "required|min:0|numeric", 'work_num_day' => "required|min:0|numeric", @@ -67,6 +81,8 @@ class DoctorInquiryConfigRequest extends FormRequest 'service_process' => "required", 'service_period' => "required|min:2|max:30|numeric", 'service_rounds' => "required|min:0|max:300|numeric", + 'monthly_frequency' => "required|min:0|max:10|numeric", + 'items' => "required", ]; } @@ -103,6 +119,11 @@ class DoctorInquiryConfigRequest extends FormRequest 'service_rounds.min' => "服务回合数最小值不可低于0", 'service_rounds.max' => "服务回合数最大值不可超过300", 'service_rounds.numeric' => "服务回合数填写错误", + 'monthly_frequency.required' => "请填写每月次数", + 'monthly_frequency.min' => "每月次数最小值不可低于0", + 'monthly_frequency.max' => "每月次数最大值不可超过10", + 'monthly_frequency.numeric' => "每月次数填写错误", + 'items.required' => "请填写服务内容", ]; } } diff --git a/app/Request/SystemRequest.php b/app/Request/SystemRequest.php index e9a6165..1b8f257 100644 --- a/app/Request/SystemRequest.php +++ b/app/Request/SystemRequest.php @@ -12,7 +12,11 @@ class SystemRequest extends FormRequest protected array $scenes = [ 'getSystemInquiryTime' => [ // 获取系统问诊配置 快速问诊-问诊购药 'inquiry_type', // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药) - 'inquiry_mode', // 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员) + 'inquiry_mode', // 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊 7:附赠 8:健康包 9:随访包) + ], + 'getSystemInquiryConfig' => [ // 获取系统问诊配置 + 'inquiry_type', // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药) + 'inquiry_mode', // 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊 7:附赠 8:健康包 9:随访包) ], ]; @@ -31,7 +35,7 @@ class SystemRequest extends FormRequest { return [ 'inquiry_type' => 'required|integer|min:1|max:4', - 'inquiry_mode' => 'required|integer|min:1|max:5', + 'inquiry_mode' => 'required|integer|min:1|max:9', ]; } diff --git a/app/Services/DoctorInquiryService.php b/app/Services/DoctorInquiryService.php index 2394e6b..4776e58 100644 --- a/app/Services/DoctorInquiryService.php +++ b/app/Services/DoctorInquiryService.php @@ -4,6 +4,8 @@ namespace App\Services; use App\Constants\HttpEnumCode; use App\Exception\BusinessException; +use App\Model\DoctorConfigFollowPackage; +use App\Model\DoctorConfigFollowPackageItem; use App\Model\DoctorInquiryConfig; use App\Model\DoctorInquiryConfigService; use App\Model\DoctorInquiryPriceRecord; @@ -16,6 +18,64 @@ use Hyperf\DbConnection\Db; */ class DoctorInquiryService extends BaseService { + /** + * 获取医生问诊服务开启状态 + * @return array + */ + public function getDoctorInquiryConfigOpenStatus(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $inquiry_type = $this->request->input('inquiry_type');// 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊) + $inquiry_mode = $this->request->input('inquiry_mode');// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊 7:附赠 8:健康包 9:随访包) + + // 获取医生信息 + $params = array(); + $params['doctor_id'] = $user_info['client_user_id']; + $doctor = UserDoctor::getOne($params); + if (empty($doctor)) { + return fail(HttpEnumCode::HTTP_ERROR, "未知医生"); + } + + if ($doctor['idcard_status'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先进行实名认证"); + } + + if ($doctor['iden_auth_status'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先进行身份认证"); + } + + if ($doctor['is_bind_bank'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先进行绑定结算银行卡"); + } + + // 接诊开关 + $is_open = 0; + + // 系统问诊配置表 + $params = array(); + $params['inquiry_type'] = $inquiry_type; + $params['inquiry_mode'] = $inquiry_mode; + $system_inquiry_config = SystemInquiryConfig::getOne($params); + if (empty($system_inquiry_config)) { + return fail(HttpEnumCode::SERVER_ERROR); + } + + // 医生接诊配置表 + $params = array(); + $params['doctor_id'] = $user_info['client_user_id']; + $params['inquiry_type'] = $inquiry_type; + $params['inquiry_mode'] = $inquiry_mode; + $doctor_inquiry_config = DoctorInquiryConfig::getOne($params); + if (!empty($doctor_inquiry_config)) { + if ($doctor_inquiry_config['is_enable'] == 1){ + $is_open = 1; + } + } + + return success($is_open); + } + /** * 获取医生问诊配置 * @return array @@ -25,7 +85,7 @@ class DoctorInquiryService extends BaseService $user_info = $this->request->getAttribute("userInfo") ?? []; $inquiry_type = $this->request->input('inquiry_type');// 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊) - $inquiry_mode = $this->request->input('inquiry_mode');// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊) + $inquiry_mode = $this->request->input('inquiry_mode');// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊 7:附赠 8:健康包 9:随访包) // 获取医生信息 $params = array(); @@ -49,14 +109,10 @@ class DoctorInquiryService extends BaseService // 返回数据 $result = array(); - $info = array(); - $config = array(); - - // 接诊开关 - $is_open = 0; // 接诊价格 - $info['inquiry_price'] = 0; + $result['inquiry_price'] = ""; + $result['work_num_day'] = ""; // 系统问诊配置表 $params = array(); @@ -73,67 +129,138 @@ class DoctorInquiryService extends BaseService $params['inquiry_type'] = $inquiry_type; $params['inquiry_mode'] = $inquiry_mode; $doctor_inquiry_config = DoctorInquiryConfig::getOne($params); - if (empty($doctor_inquiry_config)) { + if (!empty($doctor_inquiry_config)) { // 接诊价格 - $info['inquiry_price'] = $system_inquiry_config['inquiry_price'] ?: 0; - if ($inquiry_type == 3) { - // 公益问诊,存在价格档次,默认第一档 - $inquiry_price = explode(',', $system_inquiry_config['inquiry_price']); - - $info['inquiry_price'] = $inquiry_price[0]; - } - - // 默认接诊人数 - $info['work_num_day'] = $system_inquiry_config['default_work_num_day'] ?: 0; - } else { - // 接诊价格 - $info['inquiry_price'] = $doctor_inquiry_config['inquiry_price'] ?: 0; - if ($inquiry_type == 2) { + $result['inquiry_price'] = $doctor_inquiry_config['inquiry_price'] ?: 0; + if ($inquiry_type == 2 && $inquiry_mode == 1) { // 快速-系统配置 - $info['inquiry_price'] = $system_inquiry_config['inquiry_price']; + $result['inquiry_price'] = $system_inquiry_config['inquiry_price']; } - $info['work_num_day'] = $doctor_inquiry_config['work_num_day'] ?: 0; - - // 接诊开关 - if ($doctor_inquiry_config['is_enable'] == 1){ - $is_open = 1; - } + $result['work_num_day'] = $doctor_inquiry_config['work_num_day'] ?: 0; } - // 接诊开关 - $info['is_open'] = $is_open; - - // 每日最大接诊数量 - $config['max_work_num_day'] = $system_inquiry_config['max_work_num_day']; - - // 最低接诊价格(专家问诊) - $config['min_inquiry_price'] = $system_inquiry_config['min_inquiry_price'] ?: 0; - - // 最高接诊价格(专家问诊) - $config['max_inquiry_price'] = $system_inquiry_config['max_inquiry_price'] ?: 0; - - // 默认价格 - $config['default_inquiry_price'] = $system_inquiry_config['max_inquiry_price'] ?: 0; - - // 沟通次数(0为不限制次数) - $config['times_number'] = $system_inquiry_config['times_number']; - - // 沟通时长(分钟,0为不限制时长) - $config['duration'] = $system_inquiry_config['duration']; - - // 系统价格(公益问诊) - $config['system_inquiry_price'] = []; - if ($inquiry_type == 3) { - $config['system_inquiry_price'] = explode(',', $system_inquiry_config['inquiry_price']); - } - - $result['info'] = $info; - $result['config'] = $config; - return success($result); } + /** + * 获取医生问诊配置 + * @return array + */ +// public function getDoctorInquiryConfig(): array +// { +// $user_info = $this->request->getAttribute("userInfo") ?? []; +// +// $inquiry_type = $this->request->input('inquiry_type');// 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊) +// $inquiry_mode = $this->request->input('inquiry_mode');// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊 7:附赠 8:健康包 9:随访包) +// +// // 获取医生信息 +// $params = array(); +// $params['doctor_id'] = $user_info['client_user_id']; +// $doctor = UserDoctor::getOne($params); +// if (empty($doctor)) { +// return fail(HttpEnumCode::HTTP_ERROR, "未知医生"); +// } +// +// if ($doctor['idcard_status'] != 1) { +// return fail(HttpEnumCode::HTTP_ERROR, "请先进行实名认证"); +// } +// +// if ($doctor['iden_auth_status'] != 1) { +// return fail(HttpEnumCode::HTTP_ERROR, "请先进行身份认证"); +// } +// +// if ($doctor['is_bind_bank'] != 1) { +// return fail(HttpEnumCode::HTTP_ERROR, "请先进行绑定结算银行卡"); +// } +// +// // 返回数据 +// $result = array(); +// $info = array(); +// $config = array(); +// +// // 接诊开关 +// $is_open = 0; +// +// // 接诊价格 +// $info['inquiry_price'] = 0; +// +// // 系统问诊配置表 +// $params = array(); +// $params['inquiry_type'] = $inquiry_type; +// $params['inquiry_mode'] = $inquiry_mode; +// $system_inquiry_config = SystemInquiryConfig::getOne($params); +// if (empty($system_inquiry_config)) { +// return fail(HttpEnumCode::SERVER_ERROR); +// } +// +// // 医生接诊配置表 +// $params = array(); +// $params['doctor_id'] = $user_info['client_user_id']; +// $params['inquiry_type'] = $inquiry_type; +// $params['inquiry_mode'] = $inquiry_mode; +// $doctor_inquiry_config = DoctorInquiryConfig::getOne($params); +// if (empty($doctor_inquiry_config)) { +// // 接诊价格 +// $info['inquiry_price'] = $system_inquiry_config['inquiry_price'] ?: 0; +// if ($inquiry_type == 3) { +// // 公益问诊,存在价格档次,默认第一档 +// $inquiry_price = explode(',', $system_inquiry_config['inquiry_price']); +// +// $info['inquiry_price'] = $inquiry_price[0]; +// } +// +// // 默认接诊人数 +// $info['work_num_day'] = $system_inquiry_config['default_work_num_day'] ?: 0; +// } else { +// // 接诊价格 +// $info['inquiry_price'] = $doctor_inquiry_config['inquiry_price'] ?: 0; +// if ($inquiry_type == 2) { +// // 快速-系统配置 +// $info['inquiry_price'] = $system_inquiry_config['inquiry_price']; +// } +// +// $info['work_num_day'] = $doctor_inquiry_config['work_num_day'] ?: 0; +// +// // 接诊开关 +// if ($doctor_inquiry_config['is_enable'] == 1){ +// $is_open = 1; +// } +// } +// +// // 接诊开关 +// $info['is_open'] = $is_open; +// +// // 每日最大接诊数量 +// $config['max_work_num_day'] = $system_inquiry_config['max_work_num_day']; +// +// // 最低接诊价格(专家问诊) +// $config['min_inquiry_price'] = $system_inquiry_config['min_inquiry_price'] ?: 0; +// +// // 最高接诊价格(专家问诊) +// $config['max_inquiry_price'] = $system_inquiry_config['max_inquiry_price'] ?: 0; +// +// // 默认价格 +// $config['default_inquiry_price'] = $system_inquiry_config['max_inquiry_price'] ?: 0; +// +// // 沟通次数(0为不限制次数) +// $config['times_number'] = $system_inquiry_config['times_number']; +// +// // 沟通时长(分钟,0为不限制时长) +// $config['duration'] = $system_inquiry_config['duration']; +// +// // 系统价格(公益问诊) +// $config['system_inquiry_price'] = []; +// if ($inquiry_type == 3) { +// $config['system_inquiry_price'] = explode(',', $system_inquiry_config['inquiry_price']); +// } +// +// $result['info'] = $info; +// $result['config'] = $config; +// +// return success($result); +// } + /** * 医生问诊开关 * @return array @@ -143,7 +270,7 @@ class DoctorInquiryService extends BaseService $user_info = $this->request->getAttribute("userInfo") ?? []; $inquiry_type = $this->request->input('inquiry_type');// 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊) - $inquiry_mode = $this->request->input('inquiry_mode');// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员) + $inquiry_mode = $this->request->input('inquiry_mode');// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊 7:附赠 8:健康包 9:随访包) $is_open = $this->request->input('is_open');// 是否开启(1:开启 0:关闭) // 获取医生信息 @@ -425,12 +552,12 @@ class DoctorInquiryService extends BaseService * 获取医生问诊配置-服务设置 * @return array */ - public function getInquiryServiceConfig(): array + public function getDoctorInquiryDifficultConfig(): array { $user_info = $this->request->getAttribute("userInfo") ?? []; $inquiry_type = $this->request->input('inquiry_type');// 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊) - $inquiry_mode = $this->request->input('inquiry_mode');// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊) + $inquiry_mode = $this->request->input('inquiry_mode');// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊 7:附赠 8:健康包 9:随访包) if ($inquiry_mode != 6){ return fail(); @@ -469,10 +596,10 @@ class DoctorInquiryService extends BaseService } /** - * 新增医生问诊配置-服务设置 + * 新增医生问诊配置-疑难会诊-服务设置 * @return array */ - public function addInquiryServiceConfig(): array + public function addDoctorInquiryDifficultConfig(): array { $user_info = $this->request->getAttribute("userInfo") ?? []; @@ -527,10 +654,10 @@ class DoctorInquiryService extends BaseService } /** - * 修改医生问诊配置-服务设置 + * 修改医生问诊配置-疑难会诊-服务设置 * @return array */ - public function putInquiryServiceConfig(): array + public function putDoctorInquiryDifficultConfig(): array { $user_info = $this->request->getAttribute("userInfo") ?? []; @@ -597,4 +724,295 @@ class DoctorInquiryService extends BaseService return success(); } + + /** + * 获取医生问诊配置-随访包 + * @return array + */ + public function getDoctorInquiryFollowConfig(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + // 获取医生信息 + $params = array(); + $params['doctor_id'] = $user_info['client_user_id']; + $doctor = UserDoctor::getOne($params); + if (empty($doctor)) { + return fail(HttpEnumCode::HTTP_ERROR, "未知医生"); + } + + if ($doctor['idcard_status'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先进行实名认证"); + } + + if ($doctor['iden_auth_status'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先进行身份认证"); + } + + if ($doctor['is_bind_bank'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先进行绑定结算银行卡"); + } + + $params = array(); + $params['doctor_id'] = $user_info['client_user_id']; + $doctor_config_follow_package = DoctorConfigFollowPackage::getOne($params); + if (empty($doctor_config_follow_package)){ + return success(null); + }else{ + return success($doctor_config_follow_package->toArray()); + } + } + + /** + * 获取医生问诊配置-随访包-列表 + * @return array + */ + public function getDoctorInquiryFollowItemConfig(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + // 获取医生信息 + $params = array(); + $params['doctor_id'] = $user_info['client_user_id']; + $doctor = UserDoctor::getOne($params); + if (empty($doctor)) { + return fail(HttpEnumCode::HTTP_ERROR, "未知医生"); + } + + if ($doctor['idcard_status'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先进行实名认证"); + } + + if ($doctor['iden_auth_status'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先进行身份认证"); + } + + if ($doctor['is_bind_bank'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先进行绑定结算银行卡"); + } + + $result = array(); + + $params = array(); + $params['doctor_id'] = $user_info['client_user_id']; + $doctor_config_follow_package = DoctorConfigFollowPackage::getOne($params); + if (!empty($doctor_config_follow_package)){ + $params = array(); + $params['follow_package_id'] = $doctor_config_follow_package['follow_package_id']; + $doctor_config_follow_package_item = DoctorConfigFollowPackageItem::getList($params); + if (!empty($doctor_config_follow_package_item)){ + $result = $doctor_config_follow_package_item->toArray(); + } + } + + return success($result); + } + + /** + * 新增医生问诊配置-随访包 + * @return array + */ + public function addDoctorInquiryFollowConfig(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $monthly_frequency = $this->request->input('monthly_frequency'); // 每月次数(0表示不限次) + $service_rounds = $this->request->input('service_rounds'); // 服务回合数(0表示不限次) + $items = $this->request->input('items'); // 随访包内容数据 + + if ($service_rounds != 0){ + return fail(HttpEnumCode::HTTP_ERROR,"服务回合数只允许为无限次"); + } + + // 获取医生信息 + $params = array(); + $params['doctor_id'] = $user_info['client_user_id']; + $doctor = UserDoctor::getOne($params); + if (empty($doctor)) { + return fail(HttpEnumCode::HTTP_ERROR, "未知医生"); + } + + if ($doctor['idcard_status'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先进行实名认证"); + } + + if ($doctor['iden_auth_status'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先进行身份认证"); + } + + if ($doctor['is_bind_bank'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先进行绑定结算银行卡"); + } + + $params = array(); + $params['doctor_id'] = $user_info['client_user_id']; + $doctor_config_follow_package = DoctorConfigFollowPackage::getOne($params); + if (!empty($doctor_config_follow_package)){ + return fail(HttpEnumCode::HTTP_ERROR, "已存在随访包配置,请勿重复设置"); + } + + Db::beginTransaction(); + + try { + $data = array(); + $data['doctor_id'] = $doctor['doctor_id']; + $data['monthly_frequency'] = $monthly_frequency; + $data['service_rounds'] = $service_rounds; + $doctor_config_follow_package = DoctorConfigFollowPackage::addDoctorConfigFollowPackage($data); + if (empty($doctor_config_follow_package)){ + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, "添加失败"); + } + + foreach ($items as $item){ + if (empty($item['service_period'])){ + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, "请填写服务周期"); + } + + if (!in_array($item['service_period'],[30,90,180,360])){ + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, "请填写服务周期"); + } + + if (empty($item['service_price'])){ + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, "请填写服务价格"); + } + + if ($item['service_price'] < 10 || $item['service_price'] > 9999){ + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, "服务价格只允许设置在10-9999范围内"); + } + + // 新增医生配置-随访包明细 + $data = array(); + $data['follow_package_id'] = $doctor_config_follow_package['follow_package_id']; + $data['service_period'] = $item['service_period']; + $data['service_price'] = $item['service_price']; + $doctor_config_follow_package_item = DoctorConfigFollowPackageItem::addDoctorConfigFollowPackageItem($data); + if (empty($doctor_config_follow_package_item)){ + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, "保存失败"); + } + } + + Db::commit(); + }catch (\Throwable $e){ + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage()); + } + + return success(); + } + + /** + * 修改医生问诊配置-随访包 + * @return array + */ + public function putDoctorInquiryFollowConfig(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $monthly_frequency = $this->request->input('monthly_frequency'); // 每月次数(0表示不限次) + $service_rounds = $this->request->input('service_rounds'); // 服务回合数(0表示不限次) + $items = $this->request->input('items'); // 随访包内容数据 + + if ($service_rounds != 0){ + return fail(HttpEnumCode::HTTP_ERROR,"服务回合数只允许为无限次"); + } + + // 获取医生信息 + $params = array(); + $params['doctor_id'] = $user_info['client_user_id']; + $doctor = UserDoctor::getOne($params); + if (empty($doctor)) { + return fail(HttpEnumCode::HTTP_ERROR, "未知医生"); + } + + if ($doctor['idcard_status'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先进行实名认证"); + } + + if ($doctor['iden_auth_status'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先进行身份认证"); + } + + if ($doctor['is_bind_bank'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先进行绑定结算银行卡"); + } + + $params = array(); + $params['doctor_id'] = $user_info['client_user_id']; + $doctor_config_follow_package = DoctorConfigFollowPackage::getOne($params); + if (empty($doctor_config_follow_package)){ + return fail(HttpEnumCode::HTTP_ERROR, "请添加后再修改"); + } + + Db::beginTransaction(); + + try { + // 修改随访包数据 + $follow_package_data = array(); + if ($doctor_config_follow_package['monthly_frequency'] != $monthly_frequency){ + $follow_package_data['monthly_frequency'] = $monthly_frequency; + } + + if ($doctor_config_follow_package['service_rounds'] != $service_rounds){ + $follow_package_data['service_rounds'] = $service_rounds; + } + + if (!empty($follow_package_data)){ + $params = array(); + $params['follow_package_id'] = $doctor_config_follow_package['follow_package_id']; + DoctorConfigFollowPackage::edit($params,$follow_package_data); + } + + // 删除随访包内容明细 + $params = array(); + $params['follow_package_id'] = $doctor_config_follow_package['follow_package_id']; + DoctorConfigFollowPackageItem::del($params); + + // 新增随访包内容明细 + foreach ($items as $item){ + if (empty($item['service_period'])){ + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, "请填写服务周期"); + } + + if (!in_array($item['service_period'],[30,90,180,360])){ + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, "请填写服务周期"); + } + + if (empty($item['service_price'])){ + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, "请填写服务价格"); + } + + if ($item['service_price'] < 10 || $item['service_price'] > 9999){ + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, "服务价格只允许设置在10-9999范围内"); + } + + // 新增医生配置-随访包明细 + $data = array(); + $data['follow_package_id'] = $doctor_config_follow_package['follow_package_id']; + $data['service_period'] = $item['service_period']; + $data['service_price'] = $item['service_price']; + $doctor_config_follow_package_item = DoctorConfigFollowPackageItem::addDoctorConfigFollowPackageItem($data); + if (empty($doctor_config_follow_package_item)){ + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, "保存失败"); + } + } + + Db::commit(); + }catch (\Throwable $e){ + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage()); + } + + return success(); + } } \ No newline at end of file diff --git a/app/Services/SystemService.php b/app/Services/SystemService.php index 8a30d61..52fdc10 100644 --- a/app/Services/SystemService.php +++ b/app/Services/SystemService.php @@ -2,8 +2,11 @@ namespace App\Services; +use App\Constants\HttpEnumCode; +use App\Model\DoctorInquiryConfig; use App\Model\SystemInquiryConfig; use App\Model\SystemInquiryTime; +use App\Model\UserDoctor; /** * 系统配置 @@ -80,4 +83,35 @@ class SystemService extends BaseService return success($result); } + + /** + * 获取系统问诊配置 + * @return array + */ + public function getSystemInquiryConfig(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $inquiry_type = $this->request->input('inquiry_type');// 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊) + $inquiry_mode = $this->request->input('inquiry_mode');// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊 7:附赠 8:健康包 9:随访包) + + // 系统问诊配置表 + $params = array(); + $params['inquiry_type'] = $inquiry_type; + $params['inquiry_mode'] = $inquiry_mode; + $system_inquiry_config = SystemInquiryConfig::getOne($params); + if (empty($system_inquiry_config)) { + return fail(HttpEnumCode::SERVER_ERROR); + } + + $system_inquiry_config = $system_inquiry_config->toArray(); + + // 系统价格(公益问诊) + $system_inquiry_config['system_inquiry_price'] = []; + if ($inquiry_type == 3) { + $system_inquiry_config['system_inquiry_price'] = explode(',', $system_inquiry_config['inquiry_price']); + } + + return success($system_inquiry_config); + } } \ No newline at end of file diff --git a/config/routes.php b/config/routes.php index a469f7b..1cc3246 100644 --- a/config/routes.php +++ b/config/routes.php @@ -100,23 +100,47 @@ Router::addGroup('/doctor', function () { Router::addGroup('/inquiry', function () { // 问诊配置 Router::addGroup('/config', function () { + // 问诊服务开关 + Router::addGroup('/open', function () { + // 获取医生问诊服务开启状态 + Router::get('', [DoctorInquiryConfigController::class, 'getDoctorInquiryConfigOpenStatus']); + + // 医生问诊开关 + Router::put('', [DoctorInquiryConfigController::class, 'putDoctorInquiryOpen']); + }); + // 获取医生问诊配置 Router::get('', [DoctorInquiryConfigController::class, 'getDoctorInquiryConfig']); // 修改医生问诊配置 Router::put('', [DoctorInquiryConfigController::class, 'putDoctorInquiryConfig']); - // 医生问诊开关 - Router::put('/open', [DoctorInquiryConfigController::class, 'putDoctorInquiryOpen']); + // 疑难会诊 + Router::addGroup('/difficult', function () { + // 获取医生问诊配置-疑难会诊-服务设置 + Router::get('', [DoctorInquiryConfigController::class, 'getDoctorInquiryDifficultConfig']); - // 获取医生问诊配置-疑难会诊-服务设置 - Router::get('/service', [DoctorInquiryConfigController::class, 'getInquiryServiceConfig']); + // 新增医生问诊配置-疑难会诊-服务设置 + Router::post('', [DoctorInquiryConfigController::class, 'addDoctorInquiryDifficultConfig']); - // 新增医生问诊配置-疑难会诊-服务设置 - Router::post('/service', [DoctorInquiryConfigController::class, 'addInquiryServiceConfig']); + // 修改医生问诊配置-疑难会诊-服务设置 + Router::put('/{config_service_id:\d+}', [DoctorInquiryConfigController::class, 'putDoctorInquiryDifficultConfig']); + }); - // 修改医生问诊配置-疑难会诊-服务设置 - Router::put('/service/{config_service_id:\d+}', [DoctorInquiryConfigController::class, 'putInquiryServiceConfig']); + // 随访包 + Router::addGroup('/follow', function () { + // 获取医生问诊配置-随访包 + Router::get('', [DoctorInquiryConfigController::class, 'getDoctorInquiryFollowConfig']); + + // 新增医生问诊配置-随访包 + Router::post('', [DoctorInquiryConfigController::class, 'addDoctorInquiryFollowConfig']); + + // 获取医生问诊配置-随访包-列表 + Router::get('/item', [DoctorInquiryConfigController::class, 'getDoctorInquiryFollowItemConfig']); + + // 修改医生问诊配置-随访包 + Router::put('', [DoctorInquiryConfigController::class, 'putDoctorInquiryFollowConfig']); + }); }); // 获取医生问诊消息列表 @@ -692,6 +716,9 @@ Router::addGroup('/system', function () { Router::addGroup('/inquiry', function () { // 获取系统问诊时间 快速问诊-问诊购药 Router::get('/time', [SystemController::class, 'getSystemInquiryTime']); + + // 获取系统问诊配置 + Router::get('/config', [SystemController::class, 'getSystemInquiryConfig']); }); });