修改了预约视频时间、增加了创建音视频房间接口
This commit is contained in:
parent
fcfb84e6c6
commit
10aae768cb
@ -5,9 +5,10 @@ declare(strict_types=1);
|
|||||||
namespace App\Amqp\Consumer;
|
namespace App\Amqp\Consumer;
|
||||||
|
|
||||||
use App\Model\OrderInquiry;
|
use App\Model\OrderInquiry;
|
||||||
use App\Model\OrderInquiryVideo;
|
|
||||||
use App\Model\User;
|
use App\Model\User;
|
||||||
use App\Model\UserDoctor;
|
use App\Model\UserDoctor;
|
||||||
|
use App\Model\VideoRecord;
|
||||||
|
use App\Model\VideoReservation;
|
||||||
use App\Services\SendSmsService;
|
use App\Services\SendSmsService;
|
||||||
use App\Utils\Log;
|
use App\Utils\Log;
|
||||||
use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait;
|
use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait;
|
||||||
@ -96,25 +97,28 @@ class SendVideoNoticeDelayDirectConsumer extends ConsumerMessage
|
|||||||
// 获取视频预约状态
|
// 获取视频预约状态
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['order_inquiry_id'] = $data['order_inquiry_id'];
|
$params['order_inquiry_id'] = $data['order_inquiry_id'];
|
||||||
$order_inquiry_video = OrderInquiryVideo::getOne($params);
|
$video_reservation = VideoReservation::getOne($params);
|
||||||
if (empty($order_inquiry_video)){
|
if (empty($video_reservation)){
|
||||||
Log::getInstance("queue-SendVideoNotice")->error("缺少视频预约数据" );
|
Log::getInstance("queue-SendVideoNotice")->error("缺少视频预约数据" );
|
||||||
return Result::DROP;
|
return Result::DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($order_inquiry_video['is_send_reservation_notice'] == 1){
|
if ($video_reservation['is_send_reservation_notice'] == 1){
|
||||||
Log::getInstance("queue-SendVideoNotice")->info("已发送过一次通知,无需发送" );
|
Log::getInstance("queue-SendVideoNotice")->info("已发送过一次通知,无需发送" );
|
||||||
return Result::ACK;
|
return Result::ACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测是否已开过视频
|
// 检测是否已开过视频
|
||||||
if ($order_inquiry_video['is_video'] == 1){
|
$params = array();
|
||||||
|
$params['order_inquiry_id'] = $video_reservation['order_inquiry_id'];
|
||||||
|
$video_records = VideoRecord::getOne($params);
|
||||||
|
if (!empty($video_records)) {
|
||||||
Log::getInstance("queue-SendVideoNotice")->info("已开过视频,无需发送" );
|
Log::getInstance("queue-SendVideoNotice")->info("已开过视频,无需发送" );
|
||||||
return Result::ACK;
|
return Result::ACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测通知时间
|
// 检测通知时间
|
||||||
$reservation_time = strtotime($order_inquiry_video['reservation_time']);
|
$reservation_time = strtotime($video_reservation['reservation_time']);
|
||||||
if ($reservation_time < time()){
|
if ($reservation_time < time()){
|
||||||
Log::getInstance("queue-SendVideoNotice")->info("当前时间已超过预约时间,无需发送" );
|
Log::getInstance("queue-SendVideoNotice")->info("当前时间已超过预约时间,无需发送" );
|
||||||
return Result::ACK;
|
return Result::ACK;
|
||||||
@ -169,8 +173,8 @@ class SendVideoNoticeDelayDirectConsumer extends ConsumerMessage
|
|||||||
$data['is_send_reservation_notice'] = 1;
|
$data['is_send_reservation_notice'] = 1;
|
||||||
|
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['inquiry_video_id'] = $order_inquiry_video['inquiry_video_id'];
|
$params['inquiry_video_id'] = $video_reservation['inquiry_video_id'];
|
||||||
$res = OrderInquiryVideo::edit($params,$data);
|
$res = VideoReservation::edit($params,$data);
|
||||||
if (!$res){
|
if (!$res){
|
||||||
Db::rollBack();
|
Db::rollBack();
|
||||||
Log::getInstance("queue-SendVideoNotice")->error("修改失败");
|
Log::getInstance("queue-SendVideoNotice")->error("修改失败");
|
||||||
|
|||||||
@ -37,6 +37,7 @@ use App\Model\UserCoupon;
|
|||||||
use App\Model\UserDoctor;
|
use App\Model\UserDoctor;
|
||||||
use App\Model\UserPatient;
|
use App\Model\UserPatient;
|
||||||
use App\Model\UserSystem;
|
use App\Model\UserSystem;
|
||||||
|
use App\Model\VideoReservation;
|
||||||
use App\Services\BaseService;
|
use App\Services\BaseService;
|
||||||
use App\Services\ImService;
|
use App\Services\ImService;
|
||||||
use App\Services\InquiryService;
|
use App\Services\InquiryService;
|
||||||
@ -1714,10 +1715,10 @@ class CallBackController extends AbstractController
|
|||||||
$request_params = $this->request->getBody()->getContents();
|
$request_params = $this->request->getBody()->getContents();
|
||||||
$SdkAppId = $this->request->header("SdkAppId");
|
$SdkAppId = $this->request->header("SdkAppId");
|
||||||
$Sign = $this->request->header("Sign");
|
$Sign = $this->request->header("Sign");
|
||||||
|
$Sign = stripslashes($Sign);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Log::getInstance("CallBackController-trtcRoomCallBack")->info(json_encode($request_params, JSON_UNESCAPED_UNICODE));
|
Log::getInstance("CallBackController-trtcRoomCallBack")->info(json_encode($request_params, JSON_UNESCAPED_UNICODE));
|
||||||
Log::getInstance("CallBackController-trtcRoomCallBack")->info(json_encode($SdkAppId, JSON_UNESCAPED_UNICODE));
|
|
||||||
Log::getInstance("CallBackController-trtcRoomCallBack")->info(json_encode($Sign, JSON_UNESCAPED_UNICODE));
|
|
||||||
|
|
||||||
if (empty($SdkAppId)) {
|
if (empty($SdkAppId)) {
|
||||||
return $this->TrtcErrorReturn("缺少SdkAppId字段");
|
return $this->TrtcErrorReturn("缺少SdkAppId字段");
|
||||||
@ -1730,42 +1731,77 @@ class CallBackController extends AbstractController
|
|||||||
// 鉴定回调签名
|
// 鉴定回调签名
|
||||||
$VideoSafe = new VideoSafe();
|
$VideoSafe = new VideoSafe();
|
||||||
$result = $VideoSafe->validateSign($request_params,$Sign);
|
$result = $VideoSafe->validateSign($request_params,$Sign);
|
||||||
dump($result);
|
if (!$result) {
|
||||||
// if (!$result) {
|
return $this->TrtcErrorReturn("回调签名不匹配");
|
||||||
// return $this->TrtcErrorReturn("回调签名不匹配");
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
$request_params = json_decode($request_params,true);
|
$request_params = json_decode($request_params,true);
|
||||||
|
|
||||||
die;
|
// 验证参数
|
||||||
|
|
||||||
if (empty($request_params['EventGroupId'])){
|
if (empty($request_params['EventGroupId'])){
|
||||||
return $this->ImErrorReturn("回调事件为空");
|
return $this->TrtcErrorReturn("回调事件组为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
$userService = new UserService();
|
if (empty($request_params['EventType'])){
|
||||||
|
return $this->TrtcErrorReturn("回调事件类型为空");
|
||||||
|
}
|
||||||
|
|
||||||
if ($request_params['CallbackCommand'] == "State.StateChange"){
|
if (empty($request_params['EventInfo'])){
|
||||||
// 用户状态变更
|
return $this->TrtcErrorReturn("回调事件信息为空");
|
||||||
$result = $userService->userImLoginStatus($request_params);
|
|
||||||
if ($result['code'] == 0){
|
|
||||||
return $this->ImErrorReturn($result['message']);
|
|
||||||
}
|
}
|
||||||
}elseif ($request_params['CallbackCommand'] == "C2C.CallbackAfterSendMsg"){
|
|
||||||
// 用户im消息发送后回调
|
if (empty($request_params['EventInfo']['RoomId'])){
|
||||||
$result = $userService->userImAfterSendMsg($request_params);
|
return $this->TrtcErrorReturn("缺少房间id");
|
||||||
if ($result['code'] == 0){
|
|
||||||
return $this->ImErrorReturn($result['message']);
|
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
return $this->ImErrorReturn("非法事件");
|
// 排除数据
|
||||||
|
if ($request_params['EventGroupId'] != 1){
|
||||||
|
return $this->TrtcErrorReturn("回调地址推送错误");
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
if (!in_array($request_params['EventType'],[101,102,103])){
|
||||||
|
return $this->TrtcErrorReturn("事件类型错误");
|
||||||
|
}
|
||||||
|
} catch (\Throwable $e) {
|
||||||
// 验证失败
|
// 验证失败
|
||||||
return $this->ImErrorReturn($e->getMessage());
|
return $this->TrtcErrorReturn($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::getInstance()->info("Im回调数据处理成功");
|
// 处理业务逻辑
|
||||||
|
try {
|
||||||
|
// 检测缓存-只允许同时处理同一房间的一个请求,防止数据库冲突
|
||||||
|
$redis = $this->container->get(Redis::class);
|
||||||
|
$redis_key = "trtcCallBack_" . $request_params['EventInfo']['RoomId'];
|
||||||
|
$redis_value = $redis->get($redis_key);
|
||||||
|
if (!empty($redis_value)){
|
||||||
|
return $this->TrtcErrorReturn("存在正在处理的回调");
|
||||||
|
}
|
||||||
|
|
||||||
|
$redis->set($redis_key, 1, 10);
|
||||||
|
|
||||||
|
// 获取房间id
|
||||||
|
$params = array();
|
||||||
|
$params['room_id'] = $request_params['EventInfo']['RoomId'];
|
||||||
|
$video_reservation = VideoReservation::getLastOne($params);
|
||||||
|
if (empty($video_reservation)){
|
||||||
|
return $this->TrtcErrorReturn("存在正在处理的回调");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理创建房间
|
||||||
|
// 处理解散房间
|
||||||
|
// 处理进入房间
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 删除缓存
|
||||||
|
|
||||||
|
}catch (\Throwable $e){
|
||||||
|
// 验证失败
|
||||||
|
return $this->TrtcErrorReturn($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::getInstance("CallBackController-trtcRoomCallBack")->info("音视频回调-房间数据处理成功");
|
||||||
return $this->ImSuccessReturn();
|
return $this->ImSuccessReturn();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1783,8 +1819,6 @@ class CallBackController extends AbstractController
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Log::getInstance("CallBackController-trtcMediaCallBack")->info(json_encode($request_params, JSON_UNESCAPED_UNICODE));
|
Log::getInstance("CallBackController-trtcMediaCallBack")->info(json_encode($request_params, JSON_UNESCAPED_UNICODE));
|
||||||
Log::getInstance("CallBackController-trtcMediaCallBack")->info(json_encode($SdkAppId, JSON_UNESCAPED_UNICODE));
|
|
||||||
Log::getInstance("CallBackController-trtcMediaCallBack")->info(json_encode($Sign, JSON_UNESCAPED_UNICODE));
|
|
||||||
|
|
||||||
if (empty($SdkAppId)) {
|
if (empty($SdkAppId)) {
|
||||||
return $this->TrtcErrorReturn("缺少SdkAppId字段");
|
return $this->TrtcErrorReturn("缺少SdkAppId字段");
|
||||||
|
|||||||
@ -164,22 +164,6 @@ class InquiryController extends AbstractController
|
|||||||
return $this->response->json($data);
|
return $this->response->json($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 医生设置视频预约时间
|
|
||||||
* @return ResponseInterface
|
|
||||||
* @throws ContainerExceptionInterface
|
|
||||||
* @throws NotFoundExceptionInterface
|
|
||||||
*/
|
|
||||||
public function addVideoReservationDate(): ResponseInterface
|
|
||||||
{
|
|
||||||
$request = $this->container->get(InquiryRequest::class);
|
|
||||||
$request->scene('addVideoReservationDate')->validateResolved();
|
|
||||||
|
|
||||||
$InquiryService = new InquiryService();
|
|
||||||
$data = $InquiryService->addVideoReservationDate();
|
|
||||||
return $this->response->json($data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取视频问诊消息内页基础数据
|
* 获取视频问诊消息内页基础数据
|
||||||
* @return ResponseInterface
|
* @return ResponseInterface
|
||||||
|
|||||||
49
app/Controller/VideoController.php
Normal file
49
app/Controller/VideoController.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Request\InquiryRequest;
|
||||||
|
use App\Request\VideoRequest;
|
||||||
|
use App\Services\InquiryService;
|
||||||
|
use App\Services\VideoService;
|
||||||
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频
|
||||||
|
*/
|
||||||
|
class VideoController extends AbstractController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 医生设置视频预约时间
|
||||||
|
* @return ResponseInterface
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
public function addVideoReservationDate(): ResponseInterface
|
||||||
|
{
|
||||||
|
$request = $this->container->get(VideoRequest::class);
|
||||||
|
$request->scene('addVideoReservationDate')->validateResolved();
|
||||||
|
|
||||||
|
$videoService = new VideoService();
|
||||||
|
$data = $videoService->addVideoReservationDate();
|
||||||
|
return $this->response->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建音视频房间
|
||||||
|
* @return ResponseInterface
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
public function addVideoRoom(): ResponseInterface
|
||||||
|
{
|
||||||
|
$request = $this->container->get(VideoRequest::class);
|
||||||
|
$request->scene('addVideoRoom')->validateResolved();
|
||||||
|
|
||||||
|
$videoService = new VideoService();
|
||||||
|
$data = $videoService->addVideoRoom();
|
||||||
|
return $this->response->json($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,30 +9,30 @@ namespace App\Model;
|
|||||||
use Hyperf\Snowflake\Concern\Snowflake;
|
use Hyperf\Snowflake\Concern\Snowflake;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $inquiry_video_id 主键id
|
* @property int $records_id 主键id
|
||||||
* @property int $order_inquiry_id 问诊订单id
|
* @property int $order_inquiry_id 问诊订单id
|
||||||
* @property string $reservation_time 预约时间
|
* @property string $room_id 房间id
|
||||||
* @property int $is_send_reservation_notice 是否已发送预约通知(0:否 1:是)
|
* @property int $video_status 视频状态(1:已发起 2:患者进入房间 3:开始通话 4:结束)
|
||||||
* @property int $is_video 是否已开视频(0:否 1:是)
|
* @property string $start_video_time 开始视频时间
|
||||||
* @property int $update_number 修改次数
|
* @property string $stop_video_time 结束视频时间
|
||||||
* @property \Carbon\Carbon $created_at 创建时间
|
* @property \Carbon\Carbon $created_at 创建时间
|
||||||
* @property \Carbon\Carbon $updated_at 修改时间
|
* @property \Carbon\Carbon $updated_at 修改时间
|
||||||
*/
|
*/
|
||||||
class OrderInquiryVideo extends Model
|
class VideoRecord extends Model
|
||||||
{
|
{
|
||||||
use Snowflake;
|
use Snowflake;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The table associated with the model.
|
* The table associated with the model.
|
||||||
*/
|
*/
|
||||||
protected ?string $table = 'order_inquiry_video';
|
protected ?string $table = 'video_records';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*/
|
*/
|
||||||
protected array $fillable = ['inquiry_video_id', 'order_inquiry_id', 'reservation_time', 'is_send_reservation_notice', 'is_video', 'update_number', 'created_at', 'updated_at'];
|
protected array $fillable = ['records_id', 'order_inquiry_id', 'room_id', 'video_status', 'start_video_time', 'stop_video_time', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
protected string $primaryKey = "inquiry_video_id";
|
protected string $primaryKey = "records_id";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取信息-单条
|
* 获取信息-单条
|
||||||
@ -59,9 +59,9 @@ class OrderInquiryVideo extends Model
|
|||||||
/**
|
/**
|
||||||
* 新增-批量
|
* 新增-批量
|
||||||
* @param array $data 新增数据
|
* @param array $data 新增数据
|
||||||
* @return \Hyperf\Database\Model\Model|OrderInquiryVideo
|
* @return \Hyperf\Database\Model\Model|VideoRecord
|
||||||
*/
|
*/
|
||||||
public static function addOrderInquiryVideo(array $data): \Hyperf\Database\Model\Model|OrderInquiryVideo
|
public static function addVideoRecord(array $data): \Hyperf\Database\Model\Model|VideoRecord
|
||||||
{
|
{
|
||||||
return self::create($data);
|
return self::create($data);
|
||||||
}
|
}
|
||||||
88
app/Model/VideoReservation.php
Normal file
88
app/Model/VideoReservation.php
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Model;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
use Hyperf\Snowflake\Concern\Snowflake;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $reservation_id 主键id
|
||||||
|
* @property int $patient_id 患者id
|
||||||
|
* @property int $patient_user_id 患者用户id
|
||||||
|
* @property int $doctor_id 医生id
|
||||||
|
* @property int $doctor_user_id 医生用户id
|
||||||
|
* @property int $order_inquiry_id 问诊订单id
|
||||||
|
* @property string $room_id 房间号
|
||||||
|
* @property string $reservation_time 预约时间
|
||||||
|
* @property int $is_send_reservation_notice 是否已发送预约通知(0:否 1:是)
|
||||||
|
* @property int $update_number 修改次数
|
||||||
|
* @property \Carbon\Carbon $created_at 创建时间
|
||||||
|
* @property \Carbon\Carbon $updated_at 修改时间
|
||||||
|
*/
|
||||||
|
class VideoReservation extends Model
|
||||||
|
{
|
||||||
|
use Snowflake;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*/
|
||||||
|
protected ?string $table = 'video_reservation';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*/
|
||||||
|
protected array $fillable = ['reservation_id', 'patient_id', 'patient_user_id', 'doctor_id', 'doctor_user_id', 'order_inquiry_id', 'room_id', 'reservation_time', 'is_send_reservation_notice', 'update_number', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
|
protected string $primaryKey = "reservation_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 object|null
|
||||||
|
*/
|
||||||
|
public static function getList(array $params, array $fields = ['*']): object|null
|
||||||
|
{
|
||||||
|
return self::where($params)->get($fields);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增-批量
|
||||||
|
* @param array $data 新增数据
|
||||||
|
* @return \Hyperf\Database\Model\Model|VideoReservation
|
||||||
|
*/
|
||||||
|
public static function addVideoReservation(array $data): \Hyperf\Database\Model\Model|VideoReservation
|
||||||
|
{
|
||||||
|
return self::create($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function edit(array $params = [], array $data = []): int
|
||||||
|
{
|
||||||
|
return self::where($params)->update($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取信息-最后一条
|
||||||
|
* @param array $params
|
||||||
|
* @param array $fields
|
||||||
|
* @return object|null
|
||||||
|
*/
|
||||||
|
public static function getLastOne(array $params, array $fields = ['*']): object|null
|
||||||
|
{
|
||||||
|
return self::where($params)->latest()->first($fields);
|
||||||
|
}
|
||||||
|
}
|
||||||
52
app/Request/VideoRequest.php
Normal file
52
app/Request/VideoRequest.php
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Request;
|
||||||
|
|
||||||
|
use App\Constants\HttpEnumCode;
|
||||||
|
use Hyperf\Validation\Request\FormRequest;
|
||||||
|
use Hyperf\Validation\Rule;
|
||||||
|
|
||||||
|
class VideoRequest extends FormRequest
|
||||||
|
{
|
||||||
|
protected array $scenes = [
|
||||||
|
'addVideoReservationDate' => [ // 医生设置视频预约时间
|
||||||
|
'order_inquiry_id',
|
||||||
|
'reservation_time', // 预约时间
|
||||||
|
],
|
||||||
|
'addVideoRoom' => [ // 创建音视频房间
|
||||||
|
'order_inquiry_id',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'order_inquiry_id' => 'required',
|
||||||
|
'reservation_time' => "required",
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取已定义验证规则的错误消息.
|
||||||
|
*/
|
||||||
|
public function messages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'order_inquiry_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
'reservation_time.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -22,7 +22,6 @@ use App\Model\OrderInquiry;
|
|||||||
use App\Model\OrderInquiryCase;
|
use App\Model\OrderInquiryCase;
|
||||||
use App\Model\OrderInquiryCoupon;
|
use App\Model\OrderInquiryCoupon;
|
||||||
use App\Model\OrderInquiryRefund;
|
use App\Model\OrderInquiryRefund;
|
||||||
use App\Model\OrderInquiryVideo;
|
|
||||||
use App\Model\OrderPrescription;
|
use App\Model\OrderPrescription;
|
||||||
use App\Model\OrderProductCoupon;
|
use App\Model\OrderProductCoupon;
|
||||||
use App\Model\PatientFamily;
|
use App\Model\PatientFamily;
|
||||||
@ -37,6 +36,8 @@ use App\Model\User;
|
|||||||
use App\Model\UserCoupon;
|
use App\Model\UserCoupon;
|
||||||
use App\Model\UserDoctor;
|
use App\Model\UserDoctor;
|
||||||
use App\Model\UserPatient;
|
use App\Model\UserPatient;
|
||||||
|
use App\Model\VideoRecord;
|
||||||
|
use App\Model\VideoReservation;
|
||||||
use App\Utils\Log;
|
use App\Utils\Log;
|
||||||
use App\Utils\Mask;
|
use App\Utils\Mask;
|
||||||
use App\Utils\PcreMatch;
|
use App\Utils\PcreMatch;
|
||||||
@ -1334,181 +1335,6 @@ class InquiryService extends BaseService
|
|||||||
return success($result);
|
return success($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 医生设置视频预约时间
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function addVideoReservationDate(): array
|
|
||||||
{
|
|
||||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
|
||||||
|
|
||||||
$order_inquiry_id = $this->request->input('order_inquiry_id');
|
|
||||||
$reservation_time = $this->request->input('reservation_time');
|
|
||||||
|
|
||||||
// 检测预约时间
|
|
||||||
if (time() >= strtotime($reservation_time)){
|
|
||||||
return fail(HttpEnumCode::HTTP_ERROR, "预约时间须大于当前时间");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取问诊订单数据
|
|
||||||
$params = array();
|
|
||||||
$params['order_inquiry_id'] = $order_inquiry_id;
|
|
||||||
$params['doctor_id'] = $user_info['client_user_id'];
|
|
||||||
$order_inquiry = OrderInquiry::getOne($params);
|
|
||||||
if (empty($order_inquiry)) {
|
|
||||||
return fail();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($order_inquiry['inquiry_type'] != 1){
|
|
||||||
return fail();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($order_inquiry['inquiry_mode'] != 2){
|
|
||||||
return fail(HttpEnumCode::HTTP_ERROR, "订单类型错误");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检测订单状态
|
|
||||||
if ($order_inquiry['inquiry_status'] != 4){
|
|
||||||
return fail(HttpEnumCode::HTTP_ERROR, "订单状态错误");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取系统问诊配置
|
|
||||||
$params = array();
|
|
||||||
$params['inquiry_type'] = $order_inquiry['inquiry_type'];
|
|
||||||
$params['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
|
||||||
$system_inquiry_config = SystemInquiryConfig::getOne($params);
|
|
||||||
if (empty($system_inquiry_config)){
|
|
||||||
return fail();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 问诊结束时间
|
|
||||||
$complete_time = strtotime($order_inquiry['reception_time']) + $system_inquiry_config['duration'] * 60 - 10 * 60;
|
|
||||||
|
|
||||||
// 检测问诊结束时间 预约时间不可超出视频问诊结束时间
|
|
||||||
if (strtotime($reservation_time) >= $complete_time){
|
|
||||||
return fail(HttpEnumCode::HTTP_ERROR, "预约时间不可超出视频问诊结束时间");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取是否已经预约
|
|
||||||
$is_reservation = false;
|
|
||||||
|
|
||||||
$params = array();
|
|
||||||
$params['order_inquiry_id'] = $order_inquiry_id;
|
|
||||||
$order_inquiry_video = OrderInquiryVideo::getOne($params);
|
|
||||||
if (!empty($order_inquiry_video)){
|
|
||||||
// 检测是否已开过视频
|
|
||||||
if ($order_inquiry_video['is_video'] == 1){
|
|
||||||
return fail(HttpEnumCode::HTTP_ERROR, "已开过视频时间,无需再修改预约时间");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检测预约时间修改次数
|
|
||||||
if ($order_inquiry_video['update_number'] >= 1){
|
|
||||||
return fail(HttpEnumCode::HTTP_ERROR, "已无法设置/修改视频时间,可立即发起视频");
|
|
||||||
}
|
|
||||||
|
|
||||||
$is_reservation = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Db::beginTransaction();
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (empty($order_inquiry_video)){
|
|
||||||
// 创建视频预约数据
|
|
||||||
$data = array();
|
|
||||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
|
||||||
$data['reservation_time'] = $reservation_time;
|
|
||||||
$order_inquiry_video = OrderInquiryVideo::addOrderInquiryVideo($data);
|
|
||||||
if (empty($order_inquiry_video)){
|
|
||||||
Db::rollBack();
|
|
||||||
return fail(HttpEnumCode::SERVER_ERROR, "设置失败");
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
// 修改预约时间
|
|
||||||
$data = array();
|
|
||||||
$data['reservation_time'] = $reservation_time;
|
|
||||||
$data['update_number'] = 1;
|
|
||||||
|
|
||||||
$params = array();
|
|
||||||
$params['inquiry_video_id'] = $order_inquiry_video['inquiry_video_id'];
|
|
||||||
$res = OrderInquiryVideo::edit($params,$data);
|
|
||||||
if (!$res){
|
|
||||||
Db::rollBack();
|
|
||||||
return fail(HttpEnumCode::SERVER_ERROR, "设置失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Db::commit();
|
|
||||||
}catch (\Throwable $e){
|
|
||||||
Db::rollBack();
|
|
||||||
Log::getInstance("InquiryService-addDoctorGiveInquiryOrder")->error($e->getMessage());
|
|
||||||
return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 发送消息
|
|
||||||
try {
|
|
||||||
// 获取订单医生数据
|
|
||||||
$params = array();
|
|
||||||
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
|
||||||
$user_doctor = UserDoctor::getOne($params);
|
|
||||||
if (empty($user_doctor)) {
|
|
||||||
return fail(HttpEnumCode::SERVER_ERROR, "设置失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取订单用户数据
|
|
||||||
$params = array();
|
|
||||||
$params['user_id'] = $order_inquiry['user_id'];
|
|
||||||
$user = User::getOne($params);
|
|
||||||
if (empty($user)){
|
|
||||||
return fail(HttpEnumCode::SERVER_ERROR, "设置失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 发送im消息
|
|
||||||
$imService = new ImService();
|
|
||||||
|
|
||||||
if ($is_reservation){
|
|
||||||
// 修改
|
|
||||||
// 已成功预约视频问诊时间-医生
|
|
||||||
$imService->addVideoReservationTimeToDoctor($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id'],$reservation_time);
|
|
||||||
|
|
||||||
// 已成功预约视频问诊时间-患者
|
|
||||||
$imService->addVideoReservationTimeToPatient($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id'],$reservation_time);
|
|
||||||
}else{
|
|
||||||
// 新增
|
|
||||||
// 已成功修改视频问诊时间-医生
|
|
||||||
$imService->modifyVideoReservationTimeToDoctor($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id'],$reservation_time);
|
|
||||||
|
|
||||||
// 已成功修改视频问诊时间-患者
|
|
||||||
$imService->modifyVideoReservationTimeToPatient($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id'],$reservation_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 患者-通知患者视频时间
|
|
||||||
$sendSmsService = new SendSmsService($user['mobile']);
|
|
||||||
$sendSmsService->noticePatientVideoTime($user_doctor['user_name'],$reservation_time);
|
|
||||||
|
|
||||||
// 增加延迟队列通知-视频问诊即将开始-时间大于5分钟
|
|
||||||
$time = strtotime($reservation_time) - 5*60;
|
|
||||||
if ($time > time()){
|
|
||||||
$data = array();
|
|
||||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
|
||||||
$message = new SendVideoNoticeDelayDirectProducer($data);
|
|
||||||
$message->setDelayMs(1000 * (strtotime($reservation_time) - time()));
|
|
||||||
$producer = $this->container->get(Producer::class);
|
|
||||||
$res = $producer->produce($message);
|
|
||||||
if (!$res) {
|
|
||||||
return fail(HttpEnumCode::SERVER_ERROR, "设置失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}catch (\Throwable $e){
|
|
||||||
Log::getInstance("InquiryService-addDoctorGiveInquiryOrder")->error($e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = array();
|
|
||||||
$result['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id']; // 订单主键id
|
|
||||||
$result['inquiry_no'] = (string)$order_inquiry['inquiry_no']; // 订单编号
|
|
||||||
|
|
||||||
return success($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取视频问诊消息内页基础数据
|
* 获取视频问诊消息内页基础数据
|
||||||
* @return array
|
* @return array
|
||||||
@ -1547,15 +1373,19 @@ class InquiryService extends BaseService
|
|||||||
// 获取视频预约数据
|
// 获取视频预约数据
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['order_inquiry_id'] = $order_inquiry_id;
|
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||||
$order_inquiry_video = OrderInquiryVideo::getOne($params);
|
$video_reservation = VideoReservation::getOne($params);
|
||||||
if (!empty($order_inquiry_video)){
|
if (!empty($video_reservation)) {
|
||||||
$is_reservation_time = true; // 是否已设置预约时间
|
$is_reservation_time = true; // 是否已设置预约时间
|
||||||
|
|
||||||
if ($order_inquiry_video['is_video'] == 1){
|
$update_number = $video_reservation['update_number']; // 修改次数
|
||||||
|
|
||||||
|
// 检测是否已开过视频
|
||||||
|
$params = array();
|
||||||
|
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||||
|
$video_records = VideoRecord::getOne($params);
|
||||||
|
if (!empty($video_records)) {
|
||||||
$is_video = true; // 是否已开视频(0:否 1:是)
|
$is_video = true; // 是否已开视频(0:否 1:是)
|
||||||
}
|
}
|
||||||
|
|
||||||
$update_number = $order_inquiry_video['update_number']; // 修改次数
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|||||||
@ -2,9 +2,295 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Amqp\Producer\SendVideoNoticeDelayDirectProducer;
|
||||||
|
use App\Constants\HttpEnumCode;
|
||||||
use App\Exception\BusinessException;
|
use App\Exception\BusinessException;
|
||||||
|
use App\Model\OrderInquiry;
|
||||||
|
use App\Model\SystemInquiryConfig;
|
||||||
|
use App\Model\User;
|
||||||
|
use App\Model\UserDoctor;
|
||||||
|
use App\Model\VideoRecord;
|
||||||
|
use App\Model\VideoReservation;
|
||||||
|
use App\Utils\Log;
|
||||||
use Extend\TencentVideo\Safe as VideoSafe;
|
use Extend\TencentVideo\Safe as VideoSafe;
|
||||||
|
use Hyperf\Amqp\Producer;
|
||||||
|
use Hyperf\DbConnection\Db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频
|
||||||
|
*/
|
||||||
class VideoService extends BaseService
|
class VideoService extends BaseService
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* 医生设置视频预约时间
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function addVideoReservationDate(): array
|
||||||
|
{
|
||||||
|
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||||
|
|
||||||
|
$order_inquiry_id = $this->request->input('order_inquiry_id');
|
||||||
|
$reservation_time = $this->request->input('reservation_time');
|
||||||
|
|
||||||
|
// 检测预约时间
|
||||||
|
if (time() >= strtotime($reservation_time)) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "预约时间须大于当前时间");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取问诊订单数据
|
||||||
|
$params = array();
|
||||||
|
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||||
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
|
$order_inquiry = OrderInquiry::getOne($params);
|
||||||
|
if (empty($order_inquiry)) {
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($order_inquiry['inquiry_type'] != 1) {
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($order_inquiry['inquiry_mode'] != 2) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "订单类型错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测订单状态
|
||||||
|
if ($order_inquiry['inquiry_status'] != 4) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "订单状态错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取系统问诊配置
|
||||||
|
$params = array();
|
||||||
|
$params['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||||
|
$params['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||||
|
$system_inquiry_config = SystemInquiryConfig::getOne($params);
|
||||||
|
if (empty($system_inquiry_config)) {
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 问诊结束时间
|
||||||
|
$complete_time = strtotime($order_inquiry['reception_time']) + $system_inquiry_config['duration'] * 60 - 10 * 60;
|
||||||
|
|
||||||
|
// 检测问诊结束时间 预约时间不可超出视频问诊结束时间
|
||||||
|
if (strtotime($reservation_time) >= $complete_time) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "预约时间不可超出视频问诊结束时间");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取是否已经预约
|
||||||
|
$is_reservation = false;
|
||||||
|
|
||||||
|
$params = array();
|
||||||
|
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||||
|
$video_reservation = VideoReservation::getOne($params);
|
||||||
|
if (!empty($video_reservation)) {
|
||||||
|
// 检测预约时间修改次数
|
||||||
|
if ($video_reservation['update_number'] >= 1) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "已无法设置/修改视频时间,可立即发起视频");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测是否已开过视频
|
||||||
|
$params = array();
|
||||||
|
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||||
|
$video_records = VideoRecord::getOne($params);
|
||||||
|
if (!empty($video_records)) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "已开过视频时间,无需再修改预约时间");
|
||||||
|
}
|
||||||
|
|
||||||
|
$is_reservation = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::beginTransaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (empty($video_reservation)) {
|
||||||
|
// 获取用户-医生数据
|
||||||
|
$params = array();
|
||||||
|
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||||
|
$user_doctor = UserDoctor::getOne($params);
|
||||||
|
if (empty($user_doctor)) {
|
||||||
|
Db::rollBack();
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR, "设置失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建视频预约数据
|
||||||
|
$data = array();
|
||||||
|
$data['patient_id'] = $order_inquiry['patient_id'];
|
||||||
|
$data['patient_user_id'] = $order_inquiry['user_id'];
|
||||||
|
$data['doctor_id'] = $order_inquiry['doctor_id'];
|
||||||
|
$data['doctor_user_id'] = $user_doctor['user_id'];
|
||||||
|
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||||
|
$data['room_id'] = substr($order_inquiry['doctor_id'], -5) . substr(time(), -4);
|
||||||
|
$data['reservation_time'] = $reservation_time;
|
||||||
|
$video_reservation = VideoReservation::addVideoReservation($data);
|
||||||
|
if (empty($video_reservation)) {
|
||||||
|
Db::rollBack();
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR, "设置失败");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 修改预约时间
|
||||||
|
$data = array();
|
||||||
|
$data['reservation_time'] = $reservation_time;
|
||||||
|
$data['update_number'] = 1;
|
||||||
|
|
||||||
|
$params = array();
|
||||||
|
$params['inquiry_video_id'] = $video_reservation['inquiry_video_id'];
|
||||||
|
$res = VideoReservation::edit($params, $data);
|
||||||
|
if (!$res) {
|
||||||
|
Db::rollBack();
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR, "设置失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Db::rollBack();
|
||||||
|
Log::getInstance("InquiryService-addDoctorGiveInquiryOrder")->error($e->getMessage());
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送消息
|
||||||
|
try {
|
||||||
|
// 获取订单医生数据
|
||||||
|
$params = array();
|
||||||
|
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||||
|
$user_doctor = UserDoctor::getOne($params);
|
||||||
|
if (empty($user_doctor)) {
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR, "设置失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取订单用户数据
|
||||||
|
$params = array();
|
||||||
|
$params['user_id'] = $order_inquiry['user_id'];
|
||||||
|
$user = User::getOne($params);
|
||||||
|
if (empty($user)) {
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR, "设置失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送im消息
|
||||||
|
$imService = new ImService();
|
||||||
|
|
||||||
|
if ($is_reservation) {
|
||||||
|
// 修改
|
||||||
|
// 已成功预约视频问诊时间-医生
|
||||||
|
$imService->addVideoReservationTimeToDoctor($order_inquiry, $user_doctor['user_id'], $order_inquiry['user_id'], $reservation_time);
|
||||||
|
|
||||||
|
// 已成功预约视频问诊时间-患者
|
||||||
|
$imService->addVideoReservationTimeToPatient($order_inquiry, $user_doctor['user_id'], $order_inquiry['user_id'], $reservation_time);
|
||||||
|
} else {
|
||||||
|
// 新增
|
||||||
|
// 已成功修改视频问诊时间-医生
|
||||||
|
$imService->modifyVideoReservationTimeToDoctor($order_inquiry, $user_doctor['user_id'], $order_inquiry['user_id'], $reservation_time);
|
||||||
|
|
||||||
|
// 已成功修改视频问诊时间-患者
|
||||||
|
$imService->modifyVideoReservationTimeToPatient($order_inquiry, $user_doctor['user_id'], $order_inquiry['user_id'], $reservation_time);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 患者-通知患者视频时间
|
||||||
|
$sendSmsService = new SendSmsService($user['mobile']);
|
||||||
|
$sendSmsService->noticePatientVideoTime($user_doctor['user_name'], $reservation_time);
|
||||||
|
|
||||||
|
// 增加延迟队列通知-视频问诊即将开始-时间大于5分钟
|
||||||
|
$time = strtotime($reservation_time) - 5 * 60;
|
||||||
|
if ($time > time()) {
|
||||||
|
$data = array();
|
||||||
|
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||||
|
$message = new SendVideoNoticeDelayDirectProducer($data);
|
||||||
|
$message->setDelayMs(1000 * (strtotime($reservation_time) - time()));
|
||||||
|
$producer = $this->container->get(Producer::class);
|
||||||
|
$res = $producer->produce($message);
|
||||||
|
if (!$res) {
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR, "设置失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::getInstance("InquiryService-addDoctorGiveInquiryOrder")->error($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = array();
|
||||||
|
$result['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id']; // 订单主键id
|
||||||
|
$result['inquiry_no'] = (string)$order_inquiry['inquiry_no']; // 订单编号
|
||||||
|
|
||||||
|
return success($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建音视频房间
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function addVideoRoom(): array
|
||||||
|
{
|
||||||
|
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||||
|
|
||||||
|
$order_inquiry_id = $this->request->input('order_inquiry_id');
|
||||||
|
|
||||||
|
// 获取问诊订单数据
|
||||||
|
$params = array();
|
||||||
|
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||||
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
|
$order_inquiry = OrderInquiry::getOne($params);
|
||||||
|
if (empty($order_inquiry)) {
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($order_inquiry['inquiry_type'] != 1) {
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($order_inquiry['inquiry_mode'] != 2) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "订单类型错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测订单状态-问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||||
|
if ($order_inquiry['inquiry_status'] == 3) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "订单未接诊,无法发起视频");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($order_inquiry['inquiry_status'] == 5) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "订单已完成,无法发起视频");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($order_inquiry['inquiry_status'] == 6) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "订单已结束,无法发起视频");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($order_inquiry['inquiry_status'] == 7) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "订单已取消,无法发起视频");
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = array();
|
||||||
|
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||||
|
$video_reservation = VideoReservation::getOne($params);
|
||||||
|
if (empty($video_reservation)) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "您还没有和患者预约视频时间,无法发起视频");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($video_reservation['room_id'])){
|
||||||
|
// 视频房间创建错误,无房间号
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::beginTransaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 增加视频记录
|
||||||
|
$data = array();
|
||||||
|
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||||
|
$data['room_id'] = $video_reservation['room_id'];
|
||||||
|
$data['video_status'] = 1;
|
||||||
|
$data['start_video_time'] = date('Y-m-d H:i:s', time());
|
||||||
|
$video_records = VideoRecord::addVideoRecord($data);
|
||||||
|
if (empty($video_records)) {
|
||||||
|
Db::rollBack();
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR, "发起视频失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Db::rollBack();
|
||||||
|
Log::getInstance("VideoService-addVideoRoom")->error($e->getMessage());
|
||||||
|
return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return success($video_reservation['room_id']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -34,6 +34,7 @@ use App\Controller\UserController;
|
|||||||
use App\Controller\UserDoctorController;
|
use App\Controller\UserDoctorController;
|
||||||
use App\Controller\UserPatientController;
|
use App\Controller\UserPatientController;
|
||||||
use App\Controller\UserPharmacistController;
|
use App\Controller\UserPharmacistController;
|
||||||
|
use App\Controller\VideoController;
|
||||||
use App\Middleware\Rule\LockRequestMiddleware;
|
use App\Middleware\Rule\LockRequestMiddleware;
|
||||||
use Hyperf\HttpServer\Router\Router;
|
use Hyperf\HttpServer\Router\Router;
|
||||||
|
|
||||||
@ -142,7 +143,10 @@ Router::addGroup('/doctor', function () {
|
|||||||
// 视频
|
// 视频
|
||||||
Router::addGroup('/video', function () {
|
Router::addGroup('/video', function () {
|
||||||
// 医生设置视频预约时间
|
// 医生设置视频预约时间
|
||||||
Router::post('/date', [InquiryController::class, 'addVideoReservationDate']);
|
Router::post('/date', [VideoController::class, 'addVideoReservationDate']);
|
||||||
|
|
||||||
|
// 创建音视频房间
|
||||||
|
Router::post('/room', [VideoController::class, 'addVideoRoom']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -24,14 +24,16 @@ class Safe extends Base
|
|||||||
*/
|
*/
|
||||||
public function validateSign(string $body, string $sign): bool
|
public function validateSign(string $body, string $sign): bool
|
||||||
{
|
{
|
||||||
$token = config('video.token');
|
// $token = config('video.token');
|
||||||
if (empty($token)) {
|
// if (empty($token)) {
|
||||||
throw new BusinessException("Video Token Config Error");
|
// throw new BusinessException("Video Token Config Error");
|
||||||
}
|
// }
|
||||||
|
// dump($token);
|
||||||
|
|
||||||
$hash = hash_hmac( 'sha256', $body, "123654", true );
|
$hash = hash_hmac( 'sha256', $body, "NDc5MzExMDIYdusl2NDMxNDg5L", true );
|
||||||
|
|
||||||
$sys_sign = base64_encode($hash);
|
$sys_sign = base64_encode($hash);
|
||||||
|
|
||||||
dump($sign);
|
dump($sign);
|
||||||
dump($sys_sign);
|
dump($sys_sign);
|
||||||
if ($sign != $sys_sign) {
|
if ($sign != $sys_sign) {
|
||||||
@ -40,4 +42,5 @@ class Safe extends Base
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user