修改 医生问诊开关 接口,增加信息验证。以及每日接诊数量、接诊价格赋值内容

This commit is contained in:
wucongxing8150 2024-04-03 13:49:25 +08:00
parent 8784a93898
commit 547d4ded88
3 changed files with 255 additions and 53 deletions

View File

@ -0,0 +1,81 @@
<?php
declare(strict_types=1);
namespace App\Model;
use Carbon\Carbon;
use Hyperf\Database\Model\Collection;
use Hyperf\Snowflake\Concern\Snowflake;
/**
* @property int $difficult_consultation_id 主键id
* @property int $doctor_id 医生id
* @property string $service_content 服务内容
* @property string $service_process 服务流程
* @property int $service_period 服务周期
* @property int $service_rounds 服务回合数0表示不限次
* @property Carbon $created_at 创建时间
* @property Carbon $updated_at 修改时间
*/
class DoctorConfigDifficultConsultation extends Model
{
use Snowflake;
/**
* The table associated with the model.
*/
protected ?string $table = 'doctor_config_difficult_consultation';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['difficult_consultation_id', 'doctor_id', 'service_content', 'service_process', 'service_period', 'service_rounds', 'created_at', 'updated_at'];
protected string $primaryKey = "difficult_consultation_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 DoctorConfigDifficultConsultation|\Hyperf\Database\Model\Model
*/
public static function addDoctorConfigDifficultConsultation(array $data): \Hyperf\Database\Model\Model|DoctorConfigDifficultConsultation
{
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);
}
}

View File

@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
namespace App\Model;
use Carbon\Carbon;
use Hyperf\Database\Model\Collection;
use Hyperf\Snowflake\Concern\Snowflake;
/**
* @property int $health_package_id 主键id
* @property int $doctor_id 医生id
* @property int $config_health_package_id 健康包配置id
* @property string $service_price 服务价格(根据图文问诊价格计算)
* @property Carbon $created_at 创建时间
* @property Carbon $updated_at 修改时间
*/
class DoctorConfigHealthPackage extends Model
{
use Snowflake;
/**
* The table associated with the model.
*/
protected ?string $table = 'doctor_config_health_package';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['health_package_id', 'doctor_id', 'config_health_package_id', 'service_price', 'created_at', 'updated_at'];
protected string $primaryKey = "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 DoctorConfigHealthPackage|\Hyperf\Database\Model\Model
*/
public static function addDoctorConfigHealthPackage(array $data): \Hyperf\Database\Model\Model|DoctorConfigHealthPackage
{
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);
}
}

View File

@ -4,8 +4,10 @@ namespace App\Services;
use App\Constants\HttpEnumCode; use App\Constants\HttpEnumCode;
use App\Exception\BusinessException; use App\Exception\BusinessException;
use App\Model\DoctorConfigDifficultConsultation;
use App\Model\DoctorConfigFollowPackage; use App\Model\DoctorConfigFollowPackage;
use App\Model\DoctorConfigFollowPackageItem; use App\Model\DoctorConfigFollowPackageItem;
use App\Model\DoctorConfigHealthPackage;
use App\Model\DoctorInquiryConfig; use App\Model\DoctorInquiryConfig;
use App\Model\DoctorInquiryConfigService; use App\Model\DoctorInquiryConfigService;
use App\Model\DoctorInquiryPriceRecord; use App\Model\DoctorInquiryPriceRecord;
@ -68,7 +70,7 @@ class DoctorInquiryService extends BaseService
$params['inquiry_mode'] = $inquiry_mode; $params['inquiry_mode'] = $inquiry_mode;
$doctor_inquiry_config = DoctorInquiryConfig::getOne($params); $doctor_inquiry_config = DoctorInquiryConfig::getOne($params);
if (!empty($doctor_inquiry_config)) { if (!empty($doctor_inquiry_config)) {
if ($doctor_inquiry_config['is_enable'] == 1){ if ($doctor_inquiry_config['is_enable'] == 1) {
$is_open = 1; $is_open = 1;
} }
} }
@ -293,6 +295,37 @@ class DoctorInquiryService extends BaseService
return fail(HttpEnumCode::HTTP_ERROR, "请先进行绑定结算银行卡"); return fail(HttpEnumCode::HTTP_ERROR, "请先进行绑定结算银行卡");
} }
// 判断对应信息是否存在
if ($inquiry_type == 1 && $inquiry_mode == 6) {
// 疑难会诊
$params = array();
$params['doctor_id'] = $user_info['client_user_id'];
$doctor_config_difficult_consultation = DoctorConfigDifficultConsultation::getOne($params);
if (empty($doctor_config_difficult_consultation)){
return fail(HttpEnumCode::HTTP_ERROR, "请设置服务价格后开启");
}
}
// 随访包
if ($inquiry_type == 1 && $inquiry_mode == 9) {
$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, "请添加服务内容后开启");
}
}
// 健康包
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(); Db::beginTransaction();
try { try {
@ -303,6 +336,10 @@ class DoctorInquiryService extends BaseService
$params['inquiry_mode'] = $inquiry_mode; $params['inquiry_mode'] = $inquiry_mode;
$doctor_inquiry_config = DoctorInquiryConfig::getOne($params); $doctor_inquiry_config = DoctorInquiryConfig::getOne($params);
if (empty($doctor_inquiry_config)) { if (empty($doctor_inquiry_config)) {
// 此处两个参数都默认设置为0随访包以及健康包使用不到
$work_num_day = 0; // 每日接诊数量
$inquiry_price = 0; // 接诊价格(专家问诊-公益问诊)
// 获取系统问诊配置表 // 获取系统问诊配置表
$params = array(); $params = array();
$params['inquiry_type'] = $inquiry_type; $params['inquiry_type'] = $inquiry_type;
@ -313,6 +350,12 @@ class DoctorInquiryService extends BaseService
return fail(HttpEnumCode::SERVER_ERROR); return fail(HttpEnumCode::SERVER_ERROR);
} }
// 获取系统问诊配置表
if ($inquiry_mode != 8 && $inquiry_mode != 9){
$work_num_day = $system_inquiry_config['default_work_num_day'] ?: 0;
$inquiry_price = $system_inquiry_config['inquiry_price'];
}
// 快速问诊,需创建 // 快速问诊,需创建
$data = array(); $data = array();
$data['doctor_id'] = $user_info['client_user_id']; $data['doctor_id'] = $user_info['client_user_id'];
@ -321,15 +364,14 @@ class DoctorInquiryService extends BaseService
$data['inquiry_mode'] = $inquiry_mode; $data['inquiry_mode'] = $inquiry_mode;
$data['is_enable'] = 1; // 是否启用0:否 1:是) $data['is_enable'] = 1; // 是否启用0:否 1:是)
$data['last_enable_method'] = 1; // 最后开启方式1:自己 2:后台) $data['last_enable_method'] = 1; // 最后开启方式1:自己 2:后台)
$data['work_num_day'] = $system_inquiry_config['default_work_num_day'] ?: 0; $data['work_num_day'] = $work_num_day;
$data['inquiry_price'] = $system_inquiry_config['inquiry_price']; $data['inquiry_price'] = $inquiry_price;
$doctor_inquiry_config = DoctorInquiryConfig::addInquiryConfig($data); $doctor_inquiry_config = DoctorInquiryConfig::addInquiryConfig($data);
if (empty($doctor_inquiry_config)) { if (empty($doctor_inquiry_config)) {
Db::rollBack(); Db::rollBack();
return fail(HttpEnumCode::SERVER_ERROR); return fail(HttpEnumCode::SERVER_ERROR);
} }
}else{ } else {
// 已存在问诊配置,进行修改 // 已存在问诊配置,进行修改
$params = array(); $params = array();
$params['inquiry_config_id'] = $doctor_inquiry_config["inquiry_config_id"]; $params['inquiry_config_id'] = $doctor_inquiry_config["inquiry_config_id"];
@ -337,11 +379,11 @@ class DoctorInquiryService extends BaseService
$data = array(); $data = array();
$data['is_enable'] = $is_open; $data['is_enable'] = $is_open;
$data['last_enable_method'] = 1; $data['last_enable_method'] = 1;
DoctorInquiryConfig::editInquiryConfig($params,$data); DoctorInquiryConfig::editInquiryConfig($params, $data);
} }
Db::commit(); Db::commit();
}catch (\Throwable $e){ } catch (\Throwable $e) {
Db::rollBack(); Db::rollBack();
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage()); return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
} }
@ -515,7 +557,7 @@ class DoctorInquiryService extends BaseService
* @param string|int $inquiry_mode 订单问诊方式1:图文 2:视频 3:语音 4:电话 5:会员) * @param string|int $inquiry_mode 订单问诊方式1:图文 2:视频 3:语音 4:电话 5:会员)
* @param string|int $doctor_id 医生id * @param string|int $doctor_id 医生id
*/ */
public function getDoctorInquiryPrice(string|int $inquiry_type, string|int $inquiry_mode, string|int $doctor_id):float public function getDoctorInquiryPrice(string|int $inquiry_type, string|int $inquiry_mode, string|int $doctor_id): float
{ {
// 接诊类型1:专家问诊 2:快速问诊 3:公益问诊) // 接诊类型1:专家问诊 2:快速问诊 3:公益问诊)
if ($inquiry_type == 1 || $inquiry_type == 3) { if ($inquiry_type == 1 || $inquiry_type == 3) {
@ -559,7 +601,7 @@ class DoctorInquiryService extends BaseService
$inquiry_type = $this->request->input('inquiry_type');// 接诊类型1:专家问诊 2:快速问诊 3:公益问诊) $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:随访包) $inquiry_mode = $this->request->input('inquiry_mode');// 接诊方式1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊 7:附赠 8:健康包 9:随访包)
if ($inquiry_mode != 6){ if ($inquiry_mode != 6) {
return fail(); return fail();
} }
@ -588,9 +630,9 @@ class DoctorInquiryService extends BaseService
$params['inquiry_type'] = $inquiry_type; $params['inquiry_type'] = $inquiry_type;
$params['inquiry_mode'] = $inquiry_mode; $params['inquiry_mode'] = $inquiry_mode;
$doctor_inquiry_config_service = DoctorInquiryConfigService::getOne($params); $doctor_inquiry_config_service = DoctorInquiryConfigService::getOne($params);
if (empty($doctor_inquiry_config_service)){ if (empty($doctor_inquiry_config_service)) {
return success(null); return success(null);
}else{ } else {
return success($doctor_inquiry_config_service->toArray()); return success($doctor_inquiry_config_service->toArray());
} }
} }
@ -633,7 +675,7 @@ class DoctorInquiryService extends BaseService
$params['inquiry_type'] = 1; $params['inquiry_type'] = 1;
$params['inquiry_mode'] = 6; $params['inquiry_mode'] = 6;
$doctor_inquiry_config_service = DoctorInquiryConfigService::getOne($params); $doctor_inquiry_config_service = DoctorInquiryConfigService::getOne($params);
if (!empty($doctor_inquiry_config_service)){ if (!empty($doctor_inquiry_config_service)) {
return fail(HttpEnumCode::HTTP_ERROR, "已存在服务设置,请勿重复设置"); return fail(HttpEnumCode::HTTP_ERROR, "已存在服务设置,请勿重复设置");
} }
@ -642,11 +684,11 @@ class DoctorInquiryService extends BaseService
$data['inquiry_type'] = 1; $data['inquiry_type'] = 1;
$data['inquiry_mode'] = 6; $data['inquiry_mode'] = 6;
$data['service_content'] = $service_content; $data['service_content'] = $service_content;
$data['service_process'] =$service_process; $data['service_process'] = $service_process;
$data['service_period'] =$service_period; $data['service_period'] = $service_period;
$data['service_rounds'] =$service_rounds; $data['service_rounds'] = $service_rounds;
$doctor_inquiry_config_service = DoctorInquiryConfigService::addDoctorInquiryConfigService($data); $doctor_inquiry_config_service = DoctorInquiryConfigService::addDoctorInquiryConfigService($data);
if (empty($doctor_inquiry_config_service)){ if (empty($doctor_inquiry_config_service)) {
return fail(); return fail();
} }
@ -692,32 +734,32 @@ class DoctorInquiryService extends BaseService
$params['config_service_id'] = $config_service_id; $params['config_service_id'] = $config_service_id;
$params['doctor_id'] = $user_info['client_user_id']; $params['doctor_id'] = $user_info['client_user_id'];
$doctor_inquiry_config_service = DoctorInquiryConfigService::getOne($params); $doctor_inquiry_config_service = DoctorInquiryConfigService::getOne($params);
if (empty($doctor_inquiry_config_service)){ if (empty($doctor_inquiry_config_service)) {
return fail(); return fail();
} }
$data = array(); $data = array();
if ($doctor_inquiry_config_service['service_content'] != $service_content){ if ($doctor_inquiry_config_service['service_content'] != $service_content) {
$data['service_content'] = $service_content; $data['service_content'] = $service_content;
} }
if ($doctor_inquiry_config_service['service_process'] != $service_process){ if ($doctor_inquiry_config_service['service_process'] != $service_process) {
$data['service_process'] = $service_process; $data['service_process'] = $service_process;
} }
if ($doctor_inquiry_config_service['service_period'] != $service_period){ if ($doctor_inquiry_config_service['service_period'] != $service_period) {
$data['service_period'] = $service_period; $data['service_period'] = $service_period;
} }
if ($doctor_inquiry_config_service['service_rounds'] != $service_rounds){ if ($doctor_inquiry_config_service['service_rounds'] != $service_rounds) {
$data['service_rounds'] = $service_rounds; $data['service_rounds'] = $service_rounds;
} }
if (!empty($data)){ if (!empty($data)) {
$params = array(); $params = array();
$params['config_service_id'] = $doctor_inquiry_config_service['config_service_id']; $params['config_service_id'] = $doctor_inquiry_config_service['config_service_id'];
$res = DoctorInquiryConfigService::edit($params,$data); $res = DoctorInquiryConfigService::edit($params, $data);
if (!$res){ if (!$res) {
return fail(); return fail();
} }
} }
@ -756,9 +798,9 @@ class DoctorInquiryService extends BaseService
$params = array(); $params = array();
$params['doctor_id'] = $user_info['client_user_id']; $params['doctor_id'] = $user_info['client_user_id'];
$doctor_config_follow_package = DoctorConfigFollowPackage::getOne($params); $doctor_config_follow_package = DoctorConfigFollowPackage::getOne($params);
if (empty($doctor_config_follow_package)){ if (empty($doctor_config_follow_package)) {
return success(null); return success(null);
}else{ } else {
return success($doctor_config_follow_package->toArray()); return success($doctor_config_follow_package->toArray());
} }
} }
@ -796,11 +838,11 @@ class DoctorInquiryService extends BaseService
$params = array(); $params = array();
$params['doctor_id'] = $user_info['client_user_id']; $params['doctor_id'] = $user_info['client_user_id'];
$doctor_config_follow_package = DoctorConfigFollowPackage::getOne($params); $doctor_config_follow_package = DoctorConfigFollowPackage::getOne($params);
if (!empty($doctor_config_follow_package)){ if (!empty($doctor_config_follow_package)) {
$params = array(); $params = array();
$params['follow_package_id'] = $doctor_config_follow_package['follow_package_id']; $params['follow_package_id'] = $doctor_config_follow_package['follow_package_id'];
$doctor_config_follow_package_item = DoctorConfigFollowPackageItem::getList($params); $doctor_config_follow_package_item = DoctorConfigFollowPackageItem::getList($params);
if (!empty($doctor_config_follow_package_item)){ if (!empty($doctor_config_follow_package_item)) {
$result = $doctor_config_follow_package_item->toArray(); $result = $doctor_config_follow_package_item->toArray();
} }
} }
@ -820,8 +862,8 @@ class DoctorInquiryService extends BaseService
$service_rounds = $this->request->input('service_rounds'); // 服务回合数0表示不限次 $service_rounds = $this->request->input('service_rounds'); // 服务回合数0表示不限次
$items = $this->request->input('items'); // 随访包内容数据 $items = $this->request->input('items'); // 随访包内容数据
if ($service_rounds != 0){ if ($service_rounds != 0) {
return fail(HttpEnumCode::HTTP_ERROR,"服务回合数只允许为无限次"); return fail(HttpEnumCode::HTTP_ERROR, "服务回合数只允许为无限次");
} }
// 获取医生信息 // 获取医生信息
@ -847,7 +889,7 @@ class DoctorInquiryService extends BaseService
$params = array(); $params = array();
$params['doctor_id'] = $user_info['client_user_id']; $params['doctor_id'] = $user_info['client_user_id'];
$doctor_config_follow_package = DoctorConfigFollowPackage::getOne($params); $doctor_config_follow_package = DoctorConfigFollowPackage::getOne($params);
if (!empty($doctor_config_follow_package)){ if (!empty($doctor_config_follow_package)) {
return fail(HttpEnumCode::HTTP_ERROR, "已存在随访包配置,请勿重复设置"); return fail(HttpEnumCode::HTTP_ERROR, "已存在随访包配置,请勿重复设置");
} }
@ -859,28 +901,28 @@ class DoctorInquiryService extends BaseService
$data['monthly_frequency'] = $monthly_frequency; $data['monthly_frequency'] = $monthly_frequency;
$data['service_rounds'] = $service_rounds; $data['service_rounds'] = $service_rounds;
$doctor_config_follow_package = DoctorConfigFollowPackage::addDoctorConfigFollowPackage($data); $doctor_config_follow_package = DoctorConfigFollowPackage::addDoctorConfigFollowPackage($data);
if (empty($doctor_config_follow_package)){ if (empty($doctor_config_follow_package)) {
Db::rollBack(); Db::rollBack();
return fail(HttpEnumCode::HTTP_ERROR, "添加失败"); return fail(HttpEnumCode::HTTP_ERROR, "添加失败");
} }
foreach ($items as $item){ foreach ($items as $item) {
if (empty($item['service_period'])){ if (empty($item['service_period'])) {
Db::rollBack(); Db::rollBack();
return fail(HttpEnumCode::HTTP_ERROR, "请填写服务周期"); return fail(HttpEnumCode::HTTP_ERROR, "请填写服务周期");
} }
if (!in_array($item['service_period'],[30,90,180,360])){ if (!in_array($item['service_period'], [30, 90, 180, 360])) {
Db::rollBack(); Db::rollBack();
return fail(HttpEnumCode::HTTP_ERROR, "请填写服务周期"); return fail(HttpEnumCode::HTTP_ERROR, "请填写服务周期");
} }
if (empty($item['service_price'])){ if (empty($item['service_price'])) {
Db::rollBack(); Db::rollBack();
return fail(HttpEnumCode::HTTP_ERROR, "请填写服务价格"); return fail(HttpEnumCode::HTTP_ERROR, "请填写服务价格");
} }
if ($item['service_price'] < 10 || $item['service_price'] > 9999){ if ($item['service_price'] < 10 || $item['service_price'] > 9999) {
Db::rollBack(); Db::rollBack();
return fail(HttpEnumCode::HTTP_ERROR, "服务价格只允许设置在10-9999范围内"); return fail(HttpEnumCode::HTTP_ERROR, "服务价格只允许设置在10-9999范围内");
} }
@ -891,14 +933,14 @@ class DoctorInquiryService extends BaseService
$data['service_period'] = $item['service_period']; $data['service_period'] = $item['service_period'];
$data['service_price'] = $item['service_price']; $data['service_price'] = $item['service_price'];
$doctor_config_follow_package_item = DoctorConfigFollowPackageItem::addDoctorConfigFollowPackageItem($data); $doctor_config_follow_package_item = DoctorConfigFollowPackageItem::addDoctorConfigFollowPackageItem($data);
if (empty($doctor_config_follow_package_item)){ if (empty($doctor_config_follow_package_item)) {
Db::rollBack(); Db::rollBack();
return fail(HttpEnumCode::HTTP_ERROR, "保存失败"); return fail(HttpEnumCode::HTTP_ERROR, "保存失败");
} }
} }
Db::commit(); Db::commit();
}catch (\Throwable $e){ } catch (\Throwable $e) {
Db::rollBack(); Db::rollBack();
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage()); return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
} }
@ -918,8 +960,8 @@ class DoctorInquiryService extends BaseService
$service_rounds = $this->request->input('service_rounds'); // 服务回合数0表示不限次 $service_rounds = $this->request->input('service_rounds'); // 服务回合数0表示不限次
$items = $this->request->input('items'); // 随访包内容数据 $items = $this->request->input('items'); // 随访包内容数据
if ($service_rounds != 0){ if ($service_rounds != 0) {
return fail(HttpEnumCode::HTTP_ERROR,"服务回合数只允许为无限次"); return fail(HttpEnumCode::HTTP_ERROR, "服务回合数只允许为无限次");
} }
// 获取医生信息 // 获取医生信息
@ -945,7 +987,7 @@ class DoctorInquiryService extends BaseService
$params = array(); $params = array();
$params['doctor_id'] = $user_info['client_user_id']; $params['doctor_id'] = $user_info['client_user_id'];
$doctor_config_follow_package = DoctorConfigFollowPackage::getOne($params); $doctor_config_follow_package = DoctorConfigFollowPackage::getOne($params);
if (empty($doctor_config_follow_package)){ if (empty($doctor_config_follow_package)) {
return fail(HttpEnumCode::HTTP_ERROR, "请添加后再修改"); return fail(HttpEnumCode::HTTP_ERROR, "请添加后再修改");
} }
@ -954,18 +996,18 @@ class DoctorInquiryService extends BaseService
try { try {
// 修改随访包数据 // 修改随访包数据
$follow_package_data = array(); $follow_package_data = array();
if ($doctor_config_follow_package['monthly_frequency'] != $monthly_frequency){ if ($doctor_config_follow_package['monthly_frequency'] != $monthly_frequency) {
$follow_package_data['monthly_frequency'] = $monthly_frequency; $follow_package_data['monthly_frequency'] = $monthly_frequency;
} }
if ($doctor_config_follow_package['service_rounds'] != $service_rounds){ if ($doctor_config_follow_package['service_rounds'] != $service_rounds) {
$follow_package_data['service_rounds'] = $service_rounds; $follow_package_data['service_rounds'] = $service_rounds;
} }
if (!empty($follow_package_data)){ if (!empty($follow_package_data)) {
$params = array(); $params = array();
$params['follow_package_id'] = $doctor_config_follow_package['follow_package_id']; $params['follow_package_id'] = $doctor_config_follow_package['follow_package_id'];
DoctorConfigFollowPackage::edit($params,$follow_package_data); DoctorConfigFollowPackage::edit($params, $follow_package_data);
} }
// 删除随访包内容明细 // 删除随访包内容明细
@ -974,23 +1016,23 @@ class DoctorInquiryService extends BaseService
DoctorConfigFollowPackageItem::del($params); DoctorConfigFollowPackageItem::del($params);
// 新增随访包内容明细 // 新增随访包内容明细
foreach ($items as $item){ foreach ($items as $item) {
if (empty($item['service_period'])){ if (empty($item['service_period'])) {
Db::rollBack(); Db::rollBack();
return fail(HttpEnumCode::HTTP_ERROR, "请填写服务周期"); return fail(HttpEnumCode::HTTP_ERROR, "请填写服务周期");
} }
if (!in_array($item['service_period'],[30,90,180,360])){ if (!in_array($item['service_period'], [30, 90, 180, 360])) {
Db::rollBack(); Db::rollBack();
return fail(HttpEnumCode::HTTP_ERROR, "请填写服务周期"); return fail(HttpEnumCode::HTTP_ERROR, "请填写服务周期");
} }
if (empty($item['service_price'])){ if (empty($item['service_price'])) {
Db::rollBack(); Db::rollBack();
return fail(HttpEnumCode::HTTP_ERROR, "请填写服务价格"); return fail(HttpEnumCode::HTTP_ERROR, "请填写服务价格");
} }
if ($item['service_price'] < 10 || $item['service_price'] > 9999){ if ($item['service_price'] < 10 || $item['service_price'] > 9999) {
Db::rollBack(); Db::rollBack();
return fail(HttpEnumCode::HTTP_ERROR, "服务价格只允许设置在10-9999范围内"); return fail(HttpEnumCode::HTTP_ERROR, "服务价格只允许设置在10-9999范围内");
} }
@ -1001,14 +1043,14 @@ class DoctorInquiryService extends BaseService
$data['service_period'] = $item['service_period']; $data['service_period'] = $item['service_period'];
$data['service_price'] = $item['service_price']; $data['service_price'] = $item['service_price'];
$doctor_config_follow_package_item = DoctorConfigFollowPackageItem::addDoctorConfigFollowPackageItem($data); $doctor_config_follow_package_item = DoctorConfigFollowPackageItem::addDoctorConfigFollowPackageItem($data);
if (empty($doctor_config_follow_package_item)){ if (empty($doctor_config_follow_package_item)) {
Db::rollBack(); Db::rollBack();
return fail(HttpEnumCode::HTTP_ERROR, "保存失败"); return fail(HttpEnumCode::HTTP_ERROR, "保存失败");
} }
} }
Db::commit(); Db::commit();
}catch (\Throwable $e){ } catch (\Throwable $e) {
Db::rollBack(); Db::rollBack();
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage()); return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
} }