开启服务时,处理医生健康包。获取医生问诊配置-健康包接口
This commit is contained in:
parent
5b54fcb752
commit
9c2150c785
@ -127,8 +127,6 @@ class DoctorInquiryConfigController extends AbstractController
|
||||
/**
|
||||
* 获取医生问诊配置-随访包
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getDoctorInquiryFollowConfig(): ResponseInterface
|
||||
{
|
||||
@ -180,4 +178,15 @@ class DoctorInquiryConfigController extends AbstractController
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生问诊配置-健康包
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function getDoctorInquiryHealthConfig(): ResponseInterface
|
||||
{
|
||||
$DoctorInquiryService = new DoctorInquiryService();
|
||||
$data = $DoctorInquiryService->getDoctorInquiryHealthConfig();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
}
|
||||
80
app/Model/ConfigHealthPackage.php
Normal file
80
app/Model/ConfigHealthPackage.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $config_health_package_id 主键id
|
||||
* @property int $service_count 总服务次数
|
||||
* @property int $monthly_frequency 每月次数
|
||||
* @property string $effective_days 服务有效天数
|
||||
* @property string $service_rate 服务费率。100为满值,表示1,正常费率。
|
||||
* @property Carbon $created_at 创建时间
|
||||
* @property Carbon $updated_at 修改时间
|
||||
*/
|
||||
class ConfigHealthPackage extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'config_health_package';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['config_health_package_id', 'service_count', 'monthly_frequency', 'effective_days', 'service_rate', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "config_health_package_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->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 ConfigHealthPackage|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addConfigHealthPackage(array $data): \Hyperf\Database\Model\Model|ConfigHealthPackage
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,7 @@ namespace App\Services;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\ConfigHealthPackage;
|
||||
use App\Model\DoctorConfigDifficultConsultation;
|
||||
use App\Model\DoctorConfigFollowPackage;
|
||||
use App\Model\DoctorConfigFollowPackageItem;
|
||||
@ -316,16 +317,6 @@ class DoctorInquiryService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
// 健康包
|
||||
if ($inquiry_type == 1 && $inquiry_mode == 8) {
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor_config_health_package = DoctorConfigHealthPackage::getOne($params);
|
||||
if (empty($doctor_config_health_package)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请设置服务价格后开启");
|
||||
}
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
|
||||
try {
|
||||
@ -336,6 +327,13 @@ class DoctorInquiryService extends BaseService
|
||||
$params['inquiry_mode'] = $inquiry_mode;
|
||||
$doctor_inquiry_config = DoctorInquiryConfig::getOne($params);
|
||||
if (empty($doctor_inquiry_config)) {
|
||||
if ($inquiry_type == 1 || $inquiry_type == 3){
|
||||
if ($inquiry_mode != 8 && $inquiry_mode != 9){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// 此处两个参数都默认设置为0,随访包以及健康包使用不到
|
||||
$work_num_day = 0; // 每日接诊数量
|
||||
$inquiry_price = null; // 接诊价格(专家问诊-公益问诊)
|
||||
@ -371,6 +369,39 @@ class DoctorInquiryService extends BaseService
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
// 处理医生健康包
|
||||
if ($inquiry_type == 1 || $inquiry_mode == 8){
|
||||
// 获取健康包配置
|
||||
$params = array();
|
||||
$config_health_package = ConfigHealthPackage::getOne($params);
|
||||
if (empty($config_health_package)){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
// 获取专家图文问诊价格
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$params['inquiry_type'] = 1;
|
||||
$params['inquiry_mode'] = 1;
|
||||
$doctor_inquiry_config = DoctorInquiryConfig::getOne($params);
|
||||
if (empty($doctor_inquiry_config)){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "本服务需设置图文问诊的价格,才可开启");
|
||||
}
|
||||
|
||||
// 创建医生健康包
|
||||
$data = array();
|
||||
$data['doctor_id'] = $user_info['client_user_id'];
|
||||
$data['config_health_package_id'] = $config_health_package['config_health_package_id'];
|
||||
$data['service_price'] = $doctor_inquiry_config['inquiry_price'] * $config_health_package['service_rate'] / 100 * 6;
|
||||
$doctor_config_health_package = DoctorConfigHealthPackage::addDoctorConfigHealthPackage($data);
|
||||
if (empty($doctor_config_health_package)){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "开启失败");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 已存在问诊配置,进行修改
|
||||
$params = array();
|
||||
@ -1057,4 +1088,61 @@ class DoctorInquiryService extends BaseService
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生问诊配置-健康包
|
||||
* @return array
|
||||
*/
|
||||
public function getDoctorInquiryHealthConfig(): 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, "请先进行绑定结算银行卡");
|
||||
}
|
||||
|
||||
if ($doctor['multi_point_status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "本服务需开处方,您还未做多点执业认证,是否前往?");
|
||||
}
|
||||
|
||||
// 获取专家图文问诊价格
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$params['inquiry_type'] = 1;
|
||||
$params['inquiry_mode'] = 1;
|
||||
$doctor_inquiry_config = DoctorInquiryConfig::getOne($params);
|
||||
if (empty($doctor_inquiry_config)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "本服务需设置图文问诊的价格,才可开通");
|
||||
}
|
||||
|
||||
// 获取健康包配置
|
||||
$params = array();
|
||||
$config_health_package = ConfigHealthPackage::getOne($params);
|
||||
if (empty($config_health_package)){
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$result['service_count'] = $config_health_package['service_count']; // 总服务次数
|
||||
$result['service_rate'] = $config_health_package['service_rate']; // 服务费率。100为满值,表示1,正常费率。
|
||||
$result['inquiry_price'] = $doctor_inquiry_config['inquiry_price']; // 专家问诊-图文接诊价格
|
||||
|
||||
return success($result);
|
||||
}
|
||||
}
|
||||
@ -141,6 +141,12 @@ Router::addGroup('/doctor', function () {
|
||||
// 修改医生问诊配置-随访包
|
||||
Router::put('', [DoctorInquiryConfigController::class, 'putDoctorInquiryFollowConfig']);
|
||||
});
|
||||
|
||||
// 健康包
|
||||
Router::addGroup('/health', function () {
|
||||
// 获取医生问诊配置-健康包
|
||||
Router::get('', [DoctorInquiryConfigController::class, 'getDoctorInquiryHealthConfig']);
|
||||
});
|
||||
});
|
||||
|
||||
// 获取医生问诊消息列表
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user