新增对接检测所,新增医生短信推送
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Amqp\Producer\AutoCompleteInquiryDelayDirectProducer;
|
||||
use App\Constants\DoctorTitleCode;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\BasicDetectionOrgan;
|
||||
use App\Model\BasicLogisticsCompany;
|
||||
use App\Model\DetectionProject;
|
||||
use App\Model\Hospital;
|
||||
@@ -35,6 +36,7 @@ use App\Services\InquiryService;
|
||||
use App\Services\MessagePush;
|
||||
use App\Services\OrderPrescriptionService;
|
||||
use App\Utils\Log;
|
||||
use Extend\Alibaba\Oss;
|
||||
use Extend\TencentIm\Account;
|
||||
use Extend\TencentIm\Message;
|
||||
use Extend\TencentIm\Profile;
|
||||
@@ -1328,12 +1330,54 @@ class CallBackController extends AbstractController
|
||||
public function DetectionResultCallBack(): ResponseInterface
|
||||
{
|
||||
$request_params = $this->request->all();
|
||||
$auth = $this->request->getHeader("Authorization");
|
||||
if (empty($auth)){
|
||||
return $this->detectionResultFailReturn("非法请求");
|
||||
}
|
||||
|
||||
try {
|
||||
Log::getInstance("detectionResult")->info(json_encode($request_params, JSON_UNESCAPED_UNICODE));
|
||||
// 检测参数
|
||||
if (!isset($request_params['appId'])){
|
||||
return $this->detectionResultFailReturn("缺少appId参数");
|
||||
}
|
||||
|
||||
if (!isset($request_params['orderCode'])){
|
||||
return $this->detectionResultFailReturn("缺少orderCode参数");
|
||||
}
|
||||
|
||||
if (!isset($request_params['detectBarcode'])){
|
||||
return $this->detectionResultFailReturn("缺少detectBarcode参数");
|
||||
}
|
||||
|
||||
if (!isset($request_params['pdfReport'])){
|
||||
return $this->detectionResultFailReturn("缺少pdfReport参数");
|
||||
}
|
||||
|
||||
// 检测签名
|
||||
// $params = array();
|
||||
// $params['app_id'] = $request_params['appId'];
|
||||
// $basic_detection_organ = BasicDetectionOrgan::getOne($params);
|
||||
// if (empty($basic_detection_organ)){
|
||||
// return $this->detectionResultFailReturn("非法appId");
|
||||
// }
|
||||
//
|
||||
// $time = date('Y-m-d');
|
||||
// $sign = md5($basic_detection_organ['app_id'] . $basic_detection_organ['app_secret'] . $time);
|
||||
// if ($auth != $sign){
|
||||
// return $this->detectionResultFailReturn("签名错误");
|
||||
// }
|
||||
|
||||
// 检测pdf文件
|
||||
$pdfData = base64_decode($request_params['pdfReport']);
|
||||
if (!$pdfData){
|
||||
return $this->detectionResultFailReturn("文件错误");
|
||||
}
|
||||
|
||||
Log::getInstance("CallBackController-DetectionResultCallBack")->info(json_encode($request_params, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
// 获取检测订单数据
|
||||
$params = array();
|
||||
$params['detection_no'] = "D549534850211602432";
|
||||
$params['detection_no'] = $request_params['orderCode'];
|
||||
$order_detection = OrderDetection::getOne($params);
|
||||
if (empty($order_detection)){
|
||||
return $this->detectionResultFailReturn("非法订单");
|
||||
@@ -1344,6 +1388,14 @@ class CallBackController extends AbstractController
|
||||
return $this->detectionResultFailReturn("订单状态错误,无法处理");
|
||||
}
|
||||
|
||||
if (!empty($order_detection['detection_result_pdf'])){
|
||||
return $this->detectionResultSuccessReturn();
|
||||
}
|
||||
|
||||
// if ($order_detection['detection_bar_code'] != $request_params['detectBarcode']){
|
||||
// return $this->detectionResultFailReturn("检测条码无法对应");
|
||||
// }
|
||||
|
||||
// 获取医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_detection['doctor_id'];
|
||||
@@ -1377,6 +1429,12 @@ class CallBackController extends AbstractController
|
||||
return $this->detectionResultFailReturn("患者信息错误");
|
||||
}
|
||||
|
||||
// 上传处方图片至oss
|
||||
$oss = new Oss();
|
||||
$detection_result_pdf_name = "applet/patient/detection/pdf/" . $order_detection['order_detection_id'] . '.' . 'pdf';
|
||||
$detection_result_pdf = $oss->putObject($detection_result_pdf_name, $pdfData);
|
||||
$detection_result_pdf = '/' . $detection_result_pdf;
|
||||
|
||||
Db::beginTransaction();
|
||||
|
||||
try {
|
||||
@@ -1431,10 +1489,11 @@ class CallBackController extends AbstractController
|
||||
return $this->detectionResultFailReturn("问诊订单病例创建失败");
|
||||
}
|
||||
|
||||
// 修改检测状态
|
||||
// 修改检测订单
|
||||
$data = array();
|
||||
$data['detection_status'] = 4;
|
||||
$data['detection_time'] = date('Y-m-d H:i:s',time());
|
||||
$data['detection_result_pdf'] = $detection_result_pdf;
|
||||
$data['detection_result_date'] = date('Y-m-d H:i:s',time());
|
||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];// 订单-问诊id
|
||||
|
||||
$params = array();
|
||||
@@ -1494,7 +1553,9 @@ class CallBackController extends AbstractController
|
||||
$MessagePush = new MessagePush($order_detection['user_id']);
|
||||
$MessagePush->patientDetectionResultNotice($order_detection['order_detection_id']);
|
||||
|
||||
// 医生-发送检测报告短信
|
||||
// 医生-通知医生患者检测报告已生成
|
||||
$MessagePush = new MessagePush($user_doctor['user_id']);
|
||||
$MessagePush->doctorDetectionResultNotice($order_detection['order_detection_id']);
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("detectionResult")->error($e->getMessage());
|
||||
}
|
||||
@@ -1518,9 +1579,8 @@ class CallBackController extends AbstractController
|
||||
new SwooleStream(
|
||||
strval(
|
||||
json_encode([
|
||||
'result' => false,
|
||||
'returnCode' => "500",
|
||||
'message' => $message,
|
||||
'code' => 0,
|
||||
'msg' => $message,
|
||||
], JSON_UNESCAPED_UNICODE)
|
||||
)
|
||||
)
|
||||
@@ -1540,9 +1600,8 @@ class CallBackController extends AbstractController
|
||||
new SwooleStream(
|
||||
strval(
|
||||
json_encode([
|
||||
'result' => true,
|
||||
'returnCode' => "200",
|
||||
'message' => $message,
|
||||
'code' => 1,
|
||||
'msg' => $message,
|
||||
], JSON_UNESCAPED_UNICODE)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -39,7 +39,9 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property int $patient_age 患者年龄-就诊人
|
||||
* @property string $detection_bar_code 检测条码
|
||||
* @property string $detection_pic 检测管图片(逗号分隔)
|
||||
* @property string $detection_time 检测时间
|
||||
* @property string $detection_time 上传检测时间
|
||||
* @property string $detection_result_pdf 检测结果
|
||||
* @property string $detection_result_date 检测结果时间
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
@@ -55,7 +57,7 @@ class OrderDetection extends Model
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['order_detection_id', 'user_id', 'patient_id', 'doctor_id', 'family_id', 'detection_project_id', 'purpose_id', 'detection_organ_id', 'order_inquiry_id', 'detection_status', 'is_delete', 'detection_refund_status', 'detection_pay_channel', 'detection_pay_status', 'detection_no', 'escrow_trade_no', 'amount_total', 'coupon_amount_total', 'payment_amount_total', 'pay_time', 'cancel_time', 'cancel_reason', 'cancel_remarks', 'patient_name', 'patient_name_mask', 'patient_sex', 'patient_age', 'detection_bar_code', 'detection_pic', 'detection_time', 'created_at', 'updated_at'];
|
||||
protected array $fillable = ['order_detection_id', 'user_id', 'patient_id', 'doctor_id', 'family_id', 'detection_project_id', 'purpose_id', 'detection_organ_id', 'order_inquiry_id', 'detection_status', 'is_delete', 'detection_refund_status', 'detection_pay_channel', 'detection_pay_status', 'detection_no', 'escrow_trade_no', 'amount_total', 'coupon_amount_total', 'payment_amount_total', 'pay_time', 'cancel_time', 'cancel_reason', 'cancel_remarks', 'patient_name', 'patient_name_mask', 'patient_sex', 'patient_age', 'detection_bar_code', 'detection_pic', 'detection_time', 'detection_result_pdf', 'detection_result_date', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "order_detection_id";
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ use App\Model\UserDoctor;
|
||||
use App\Model\UserLocation;
|
||||
use App\Utils\Log;
|
||||
use App\Utils\PcreMatch;
|
||||
use Extend\Detection\Wy;
|
||||
use Extend\Wechat\WechatPay;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\DbConnection\Db;
|
||||
@@ -537,16 +538,27 @@ class DetectionService extends BaseService
|
||||
$detection_pic = PcreMatch::pregRemoveOssWebsite($detection_pic);
|
||||
}
|
||||
|
||||
// 获取检测所
|
||||
// 检测检测管编码是否已被使用
|
||||
$params = array();
|
||||
$params['detection_bar_code'] = $request_params['detection_bar_code'];
|
||||
$result = OrderDetection::getOne($params);
|
||||
if (!empty($result)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"检测管已被使用");
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 上报数据
|
||||
$wy = new Wy($order_detection['detection_organ_id']);
|
||||
$wy->report($order_detection);
|
||||
|
||||
// 修改检测订单
|
||||
$data = array();
|
||||
$data['detection_pic'] = $detection_pic ?? "";
|
||||
$data['detection_bar_code'] = $request_params['detection_bar_code'];
|
||||
$data['detection_status'] = 3;
|
||||
$data['detection_organ_id'] = 1;// 检测机构id
|
||||
$data['detection_time'] = date('Y-m-d H:i:s', time());// 上传检测时间
|
||||
|
||||
$params = array();
|
||||
$params['order_detection_id'] = $order_detection_id;
|
||||
@@ -556,12 +568,11 @@ class DetectionService extends BaseService
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"绑定失败");
|
||||
}
|
||||
|
||||
// 上报数据
|
||||
|
||||
Db::commit();
|
||||
}catch (\Exception $e){
|
||||
}catch (\Throwable $e){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
|
||||
Log::getInstance("DetectionService-bindDetectionTube")->error($e->getMessage());
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "绑定失败");
|
||||
}
|
||||
|
||||
return success();
|
||||
|
||||
@@ -729,7 +729,7 @@ class ImService extends BaseService
|
||||
$cloud_custom_data['patient_family_data']['patient_age'] = $order_detection['patient_age'];
|
||||
|
||||
$message_content = [
|
||||
'Text' => $doctor_name . "医生您好,我在您那里开具的【" . $detection_project_name . "】服务,报告单已出,请您查看报告并详细的做一下解读,谢谢医生。",
|
||||
'Text' => $doctor_name . "医生您好,您给我开具的【" . $detection_project_name . "】检测项目报告已经出来啦,请您抽空查看报告并做一下解读,谢谢。",
|
||||
];
|
||||
|
||||
$this->sendMessage($patient_user_id,$doctor_user_id, $message_content, "TIMTextElem", $cloud_custom_data);
|
||||
|
||||
@@ -2338,7 +2338,7 @@ class MessagePush extends BaseService
|
||||
// 短信
|
||||
$sms_data = array();
|
||||
$sms_data['template_code'] = "SMS_462035956";
|
||||
$sms_data['scene_desc'] = "您的{$detection_project['detection_project_name']}报告单已出,请联系医生做报告解读。平台已赠送您和医生5个沟通回合,请珍惜沟通机会,请前往肝胆相照互联网医院微信小程序“个人中心”-“检测订单”-“订单详情”查看报告。";
|
||||
$sms_data['scene_desc'] = "新报告生成通知";
|
||||
$sms_data['phone'] = $this->user['mobile'];
|
||||
$sms_data['user_id'] = $this->user['user_id'];
|
||||
|
||||
@@ -2360,4 +2360,52 @@ class MessagePush extends BaseService
|
||||
Log::getInstance("MessagePush-patientDetectionResultNotice")->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 医生-通知医生患者检测报告已生成
|
||||
* 短信
|
||||
* @param string $order_detection_id
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function doctorDetectionResultNotice(string $order_detection_id): void
|
||||
{
|
||||
// 获取检测订单
|
||||
$params = array();
|
||||
$params['order_detection_id'] = $order_detection_id;
|
||||
$order_detection = OrderDetection::getOne($params);
|
||||
if (empty($order_detection)) {
|
||||
Log::getInstance("MessagePush-patientDetectionResultNotice")->error("无检测订单数据");
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取检测项目
|
||||
$params = array();
|
||||
$params['detection_project_id'] = $order_detection['detection_project_id'];
|
||||
$detection_project = DetectionProject::getOne($params);
|
||||
if (empty($detection_project)) {
|
||||
Log::getInstance("MessagePush-patientDetectionResultNotice")->error("检测项目错误");
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取系统接诊配置
|
||||
$data = array();
|
||||
$data['template_code'] = "SMS_461980700";
|
||||
$data['scene_desc'] = "通知医生患者检测报告已生成";
|
||||
$data['phone'] = $this->user['mobile'];
|
||||
$data['user_id'] = $this->user['user_id'];
|
||||
|
||||
$template_param = array();
|
||||
$template_param['name'] = $order_detection['patient_name'];
|
||||
$template_param['report'] = $detection_project['detection_project_name'];
|
||||
$data['template_param'] = $template_param;
|
||||
|
||||
$message = new SendSmsMessageProducer($data);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
$result = $producer->produce($message);
|
||||
if (!$result) {
|
||||
throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -28,17 +28,17 @@ class Auth
|
||||
"/callback/wxpay/inquiry/refund" => "post", // 微信问诊退款回调
|
||||
"/callback/wxpay/product/success" => "post", // 微信药品支付回调
|
||||
"/callback/wxpay/product/refund" => "post", // 微信药品退款回调
|
||||
"/callback/wxpay/detection/success" => "post", // 微信药品支付回调
|
||||
"/callback/wxpay/detection/refund" => "post", // 微信药品退款回调
|
||||
"/callback/wxpay/detection/success" => "post", // 微信检测订单支付回调
|
||||
"/callback/wxpay/detection/refund" => "post", // 微信检测订单退款回调
|
||||
"/callback/im" => "post", // im回调
|
||||
"/callback/platform/logistics" => "post", // 处方平台物流回调
|
||||
"/callback/logistics" => "post", // 快递100订阅回调
|
||||
"/popup" => "get", // 获取弹窗数据
|
||||
"/basic/keyword/search" => "get", // 获取热门搜索关键词
|
||||
"/test/uninquiry" => "get", // 获取未接诊的医生
|
||||
|
||||
"/test/refund" => "get", // 测试退款
|
||||
"/test" => "get", // 测试
|
||||
"/callback/detection" => "post", // 检测所结果回调
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user