新增检测回调、修改自动完成订单、新增im推送、
This commit is contained in:
parent
00937e9154
commit
3bb279ab57
@ -147,6 +147,9 @@ class AutoCompleteInquiryDelayDirectConsumer extends ConsumerMessage
|
|||||||
|
|
||||||
// 是否需要推送消息
|
// 是否需要推送消息
|
||||||
$is_push_prescription_verify_fail = true;
|
$is_push_prescription_verify_fail = true;
|
||||||
|
|
||||||
|
// 驳回处方id
|
||||||
|
$order_prescription_id = $item['order_prescription_id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,8 +180,9 @@ class AutoCompleteInquiryDelayDirectConsumer extends ConsumerMessage
|
|||||||
try {
|
try {
|
||||||
if (isset($is_push_prescription_verify_fail)){
|
if (isset($is_push_prescription_verify_fail)){
|
||||||
// 站内、订阅失败发送短信-医生开具的处方审核未通过
|
// 站内、订阅失败发送短信-医生开具的处方审核未通过
|
||||||
|
$order_prescription_id = $order_prescription_id ?? "";
|
||||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']);
|
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']);
|
||||||
$MessagePush->prescriptionVerifyFail($order_prescription['order_prescription_id']);
|
$MessagePush->prescriptionVerifyFail($order_prescription_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送IM消息-问诊已完成
|
// 发送IM消息-问诊已完成
|
||||||
|
|||||||
@ -3,15 +3,19 @@
|
|||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Amqp\Producer\AssignDoctorDelayDirectProducer;
|
use App\Amqp\Producer\AssignDoctorDelayDirectProducer;
|
||||||
|
use App\Amqp\Producer\AutoCompleteInquiryDelayDirectProducer;
|
||||||
use App\Constants\DoctorTitleCode;
|
use App\Constants\DoctorTitleCode;
|
||||||
use App\Constants\HttpEnumCode;
|
use App\Constants\HttpEnumCode;
|
||||||
use App\Exception\BusinessException;
|
use App\Exception\BusinessException;
|
||||||
use App\Model\BasicLogisticsCompany;
|
use App\Model\BasicLogisticsCompany;
|
||||||
|
use App\Model\DetectionProject;
|
||||||
use App\Model\Hospital;
|
use App\Model\Hospital;
|
||||||
use App\Model\MessageIm;
|
use App\Model\MessageIm;
|
||||||
use App\Model\OrderDetection;
|
use App\Model\OrderDetection;
|
||||||
|
use App\Model\OrderDetectionCase;
|
||||||
use App\Model\OrderDetectionRefund;
|
use App\Model\OrderDetectionRefund;
|
||||||
use App\Model\OrderInquiry;
|
use App\Model\OrderInquiry;
|
||||||
|
use App\Model\OrderInquiryCase;
|
||||||
use App\Model\OrderInquiryCoupon;
|
use App\Model\OrderInquiryCoupon;
|
||||||
use App\Model\OrderInquiryRefund;
|
use App\Model\OrderInquiryRefund;
|
||||||
use App\Model\OrderPrescription;
|
use App\Model\OrderPrescription;
|
||||||
@ -19,6 +23,7 @@ use App\Model\OrderProduct;
|
|||||||
use App\Model\OrderProductItem;
|
use App\Model\OrderProductItem;
|
||||||
use App\Model\OrderProductLogistic;
|
use App\Model\OrderProductLogistic;
|
||||||
use App\Model\OrderProductRefund;
|
use App\Model\OrderProductRefund;
|
||||||
|
use App\Model\PatientFamily;
|
||||||
use App\Model\Product;
|
use App\Model\Product;
|
||||||
use App\Model\ProductPlatformAmount;
|
use App\Model\ProductPlatformAmount;
|
||||||
use App\Model\UserCoupon;
|
use App\Model\UserCoupon;
|
||||||
@ -40,6 +45,7 @@ use Hyperf\DbConnection\Db;
|
|||||||
use Hyperf\HttpMessage\Stream\SwooleFileStream;
|
use Hyperf\HttpMessage\Stream\SwooleFileStream;
|
||||||
use Hyperf\HttpMessage\Stream\SwooleStream;
|
use Hyperf\HttpMessage\Stream\SwooleStream;
|
||||||
use Hyperf\Redis\Redis;
|
use Hyperf\Redis\Redis;
|
||||||
|
use Hyperf\Snowflake\IdGeneratorInterface;
|
||||||
use Hyperf\Utils\ApplicationContext;
|
use Hyperf\Utils\ApplicationContext;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
@ -1303,4 +1309,218 @@ class CallBackController extends AbstractController
|
|||||||
return $server->serve();
|
return $server->serve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测所结果回调
|
||||||
|
* @return ResponseInterface
|
||||||
|
*/
|
||||||
|
public function DetectionResultCallBack(): ResponseInterface
|
||||||
|
{
|
||||||
|
$request_params = $this->request->all();
|
||||||
|
try {
|
||||||
|
Log::getInstance("detectionResult")->info(json_encode($request_params, JSON_UNESCAPED_UNICODE));
|
||||||
|
|
||||||
|
// 获取检测订单数据
|
||||||
|
$params = array();
|
||||||
|
$params['detection_no'] = "D547019667026825217";
|
||||||
|
$order_detection = OrderDetection::getOne($params);
|
||||||
|
if (empty($order_detection)){
|
||||||
|
return $this->detectionResultFailReturn("非法订单");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测订单状态
|
||||||
|
if ($order_detection['detection_status'] != 3){
|
||||||
|
return $this->detectionResultFailReturn("订单状态错误,无法处理");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取医生数据
|
||||||
|
$params = array();
|
||||||
|
$params['doctor_id'] = $order_detection['doctor_id'];
|
||||||
|
$user_doctor = UserDoctor::getOne($params);
|
||||||
|
if (empty($user_doctor)){
|
||||||
|
return $this->detectionResultFailReturn("订单数据错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取检测病例数据
|
||||||
|
$params = array();
|
||||||
|
$params['order_detection_id'] = $order_detection['order_detection_id'];
|
||||||
|
$order_detection_case = OrderDetectionCase::getOne($params);
|
||||||
|
if (empty($order_detection_case)){
|
||||||
|
return $this->detectionResultFailReturn("订单数据错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取检测项目数据
|
||||||
|
$params = array();
|
||||||
|
$params['detection_project_id'] = $order_detection['detection_project_id'];
|
||||||
|
$detection_project = DetectionProject::getOne($params);
|
||||||
|
if (empty($detection_project)){
|
||||||
|
return $this->detectionResultFailReturn("订单数据错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测家庭成员是否存在
|
||||||
|
$params = array();
|
||||||
|
$params['family_id'] = $order_detection['family_id'];
|
||||||
|
$params['patient_id'] = $order_detection['user_id'];
|
||||||
|
$patient_family = PatientFamily::getOne($params);
|
||||||
|
if (empty($patient_family)) {
|
||||||
|
return $this->detectionResultFailReturn("患者信息错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::beginTransaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 修改检测状态
|
||||||
|
$data = array();
|
||||||
|
$data['detection_status'] = 4;
|
||||||
|
$data['detection_time'] = date('Y-m-d H:i:s',time());
|
||||||
|
|
||||||
|
$params = array();
|
||||||
|
$params['order_detection_id'] = $order_detection['order_detection_id'];
|
||||||
|
OrderDetection::editOrderDetection($params,$data);
|
||||||
|
|
||||||
|
$generator = $this->container->get(IdGeneratorInterface::class);
|
||||||
|
|
||||||
|
// 创建问诊订单
|
||||||
|
$data = array();
|
||||||
|
$data['user_id'] = $order_detection['user_id'];
|
||||||
|
$data['patient_id'] = $order_detection['patient_id'];
|
||||||
|
$data['doctor_id'] = $order_detection['doctor_id'];
|
||||||
|
$data['family_id'] = $order_detection['family_id'];
|
||||||
|
$data['inquiry_type'] = 5; // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测)
|
||||||
|
$data['inquiry_mode'] = 1; // 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)
|
||||||
|
$data['inquiry_status'] = 4; // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||||
|
$data['inquiry_pay_channel'] = 3; // 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付)
|
||||||
|
$data['inquiry_pay_status'] = 2; // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||||
|
$data['inquiry_no'] = $generator->generate();// 订单编号
|
||||||
|
$data['escrow_trade_no'] = "GD" . $generator->generate(); // 第三方支付流水号
|
||||||
|
$data['amount_total'] = 0;// 订单金额
|
||||||
|
$data['coupon_amount_total'] = 0;// 优惠卷总金额
|
||||||
|
$data['payment_amount_total'] = 0;// 实际付款金额
|
||||||
|
$data['pay_time'] = date('Y-m-d H:i:s', time());// 支付时间
|
||||||
|
$data['reception_time'] = date('Y-m-d H:i:s', time());// 接诊时间
|
||||||
|
$data['patient_name'] = $patient_family['card_name'];// 患者姓名-就诊人
|
||||||
|
$data['patient_name_mask'] = $patient_family['card_name_mask'];// 患者姓名-就诊人(掩码)
|
||||||
|
$data['patient_sex'] = $patient_family['sex'];// 患者性别-就诊人(0:未知 1:男 2:女)
|
||||||
|
$data['patient_age'] = $patient_family['age'];// 患者年龄-就诊人
|
||||||
|
$order_inquiry = OrderInquiry::addOrderInquiry($data);
|
||||||
|
if (empty($order_inquiry)) {
|
||||||
|
Db::rollBack();
|
||||||
|
return $this->detectionResultFailReturn("问诊订单创建失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 增加患者问诊病例
|
||||||
|
$data = array();
|
||||||
|
$data['user_id'] = $order_detection['user_id'];
|
||||||
|
$data['patient_id'] = $order_detection['patient_id'];
|
||||||
|
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];// 订单-问诊id
|
||||||
|
$data['family_id'] = $patient_family['family_id']; // 家庭成员id
|
||||||
|
$data['relation'] = $patient_family['relation']; // 与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他 )
|
||||||
|
$data['name'] = $patient_family['card_name']; // 患者名称
|
||||||
|
$data['sex'] = $patient_family['sex'] ?? 0; // 患者性别(0:未知 1:男 2:女)
|
||||||
|
$data['age'] = $patient_family['age'] ?? null; // 患者年龄
|
||||||
|
$data['height'] = $patient_family['height'] ?: null; // 身高(cm)
|
||||||
|
$data['weight'] = $patient_family['weight'] ?: null;; // 体重(kg)
|
||||||
|
$order_inquiry_case = OrderInquiryCase::addOrderInquiryCase($data);
|
||||||
|
if (empty($order_inquiry_case)) {
|
||||||
|
Db::rollBack();
|
||||||
|
return $this->detectionResultFailReturn("问诊订单病例创建失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加自动完成队列
|
||||||
|
$time = 1000 * 60 * 60 * 24 * 3;
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||||
|
|
||||||
|
$message = new AutoCompleteInquiryDelayDirectProducer($data);
|
||||||
|
$message->setDelayMs($time);
|
||||||
|
$producer = $this->container->get(Producer::class);
|
||||||
|
$res = $producer->produce($message);
|
||||||
|
if (!$res) {
|
||||||
|
Db::rollBack();
|
||||||
|
return $this->detectionResultFailReturn("添加自动完成队列失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送IM消息-检测报告结果
|
||||||
|
$imService = new ImService();
|
||||||
|
$imService->detectionTestReport(
|
||||||
|
$order_detection,
|
||||||
|
$user_doctor['user_id'],
|
||||||
|
$order_detection['user_id'],
|
||||||
|
$order_detection_case['detection_disease_class_names'],
|
||||||
|
$detection_project['detection_project_name']
|
||||||
|
);
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollBack();
|
||||||
|
return $this->detectionResultFailReturn($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 发送IM消息-检测报告结果-文字
|
||||||
|
$imService->detectionTestReportStr(
|
||||||
|
$user_doctor['user_name'],
|
||||||
|
$detection_project['detection_project_name'],
|
||||||
|
$user_doctor['user_id'],
|
||||||
|
$order_detection['user_id'],
|
||||||
|
$order_detection_case['detection_disease_class_names']
|
||||||
|
);
|
||||||
|
|
||||||
|
// 患者-通知患者报告生成结果
|
||||||
|
|
||||||
|
// 医生-发送检测报告短信
|
||||||
|
}catch (\Exception $e){
|
||||||
|
Log::getInstance("detectionResult")->error($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->detectionResultSuccessReturn();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->detectionResultFailReturn("异常:" . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测所结果回调失败
|
||||||
|
* @param string $message
|
||||||
|
* @return ResponseInterface
|
||||||
|
*/
|
||||||
|
protected function detectionResultFailReturn(string $message): ResponseInterface
|
||||||
|
{
|
||||||
|
return $this->response
|
||||||
|
->withStatus(200)
|
||||||
|
->withBody(
|
||||||
|
new SwooleStream(
|
||||||
|
strval(
|
||||||
|
json_encode([
|
||||||
|
'result' => false,
|
||||||
|
'returnCode' => "500",
|
||||||
|
'message' => $message,
|
||||||
|
], JSON_UNESCAPED_UNICODE)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测所结果回调成功
|
||||||
|
* @param string $message
|
||||||
|
* @return ResponseInterface
|
||||||
|
*/
|
||||||
|
protected function detectionResultSuccessReturn(string $message = ""): ResponseInterface
|
||||||
|
{
|
||||||
|
return $this->response
|
||||||
|
->withStatus(200)
|
||||||
|
->withBody(
|
||||||
|
new SwooleStream(
|
||||||
|
strval(
|
||||||
|
json_encode([
|
||||||
|
'result' => true,
|
||||||
|
'returnCode' => "200",
|
||||||
|
'message' => $message,
|
||||||
|
], JSON_UNESCAPED_UNICODE)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -38,6 +38,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
|||||||
* @property int $patient_age 患者年龄-就诊人
|
* @property int $patient_age 患者年龄-就诊人
|
||||||
* @property string $detection_bar_code 检测条码
|
* @property string $detection_bar_code 检测条码
|
||||||
* @property string $detection_pic 检测管图片(逗号分隔)
|
* @property string $detection_pic 检测管图片(逗号分隔)
|
||||||
|
* @property string $detection_time 检测时间
|
||||||
* @property \Carbon\Carbon $created_at 创建时间
|
* @property \Carbon\Carbon $created_at 创建时间
|
||||||
* @property \Carbon\Carbon $updated_at 修改时间
|
* @property \Carbon\Carbon $updated_at 修改时间
|
||||||
*/
|
*/
|
||||||
@ -53,7 +54,7 @@ class OrderDetection extends Model
|
|||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* 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', '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', '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', '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 string $primaryKey = "order_detection_id";
|
protected string $primaryKey = "order_detection_id";
|
||||||
|
|
||||||
|
|||||||
@ -52,7 +52,6 @@ class DetectionRequest extends FormRequest
|
|||||||
'doctor_id' => 'required',
|
'doctor_id' => 'required',
|
||||||
'client_type' => 'required|integer|min:1|max:2',
|
'client_type' => 'required|integer|min:1|max:2',
|
||||||
'detection_bar_code' => 'required',
|
'detection_bar_code' => 'required',
|
||||||
'detection_pic' => 'required',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +71,7 @@ class DetectionRequest extends FormRequest
|
|||||||
'client_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
'client_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
'client_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
'client_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
'client_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
'client_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
|
'detection_bar_code.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,7 @@ use App\Model\OrderDetection;
|
|||||||
use App\Model\OrderDetectionCase;
|
use App\Model\OrderDetectionCase;
|
||||||
use App\Model\OrderDetectionRefund;
|
use App\Model\OrderDetectionRefund;
|
||||||
use App\Model\PatientFamily;
|
use App\Model\PatientFamily;
|
||||||
|
use App\Model\ReportDetection;
|
||||||
use App\Model\UserDoctor;
|
use App\Model\UserDoctor;
|
||||||
use App\Model\UserLocation;
|
use App\Model\UserLocation;
|
||||||
use App\Utils\Log;
|
use App\Utils\Log;
|
||||||
@ -493,7 +494,10 @@ class DetectionService extends BaseService
|
|||||||
return success($order_detection['detection_no']);
|
return success($order_detection['detection_no']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 绑定检测管
|
/**
|
||||||
|
* 绑定检测管
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function bindDetectionTube(): array
|
public function bindDetectionTube(): array
|
||||||
{
|
{
|
||||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||||
@ -502,10 +506,6 @@ class DetectionService extends BaseService
|
|||||||
|
|
||||||
$request_params = $this->request->all();
|
$request_params = $this->request->all();
|
||||||
|
|
||||||
if (count($request_params['detection_pic']) < 1){
|
|
||||||
return fail(HttpEnumCode::HTTP_ERROR,"请上传检测管图片");
|
|
||||||
}
|
|
||||||
|
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['patient_id'] = $user_info['client_user_id'];
|
$params['patient_id'] = $user_info['client_user_id'];
|
||||||
$params['order_detection_id'] = $order_detection_id;
|
$params['order_detection_id'] = $order_detection_id;
|
||||||
@ -527,24 +527,39 @@ class DetectionService extends BaseService
|
|||||||
return fail(HttpEnumCode::HTTP_ERROR,"请勿重复绑定");
|
return fail(HttpEnumCode::HTTP_ERROR,"请勿重复绑定");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($order_detection['detection_pic'])){
|
if (!empty($order_detection['detection_pic']) && !empty($request_params['detection_pic'])){
|
||||||
return fail(HttpEnumCode::HTTP_ERROR,"请勿重复绑定");
|
return fail(HttpEnumCode::HTTP_ERROR,"请勿重复绑定");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理检测管图片
|
// 处理检测管图片
|
||||||
$detection_pic = implode(',', $request_params['detection_pic']);
|
if (!empty($request_params['detection_pic'])){
|
||||||
$detection_pic = PcreMatch::pregRemoveOssWebsite($detection_pic);
|
$detection_pic = implode(',', $request_params['detection_pic']);
|
||||||
|
$detection_pic = PcreMatch::pregRemoveOssWebsite($detection_pic);
|
||||||
|
}
|
||||||
|
|
||||||
$data = array();
|
|
||||||
$data['detection_pic'] = $detection_pic;
|
|
||||||
$data['detection_bar_code'] = $request_params['detection_bar_code'];
|
|
||||||
$data['detection_status'] = 3;
|
|
||||||
|
|
||||||
$params = array();
|
Db::beginTransaction();
|
||||||
$params['order_detection_id'] = $order_detection_id;
|
try {
|
||||||
$res = OrderDetection::editOrderDetection($params,$data);
|
// 修改检测订单
|
||||||
if (!$res){
|
$data = array();
|
||||||
return fail(HttpEnumCode::HTTP_ERROR,"绑定失败");
|
$data['detection_pic'] = $detection_pic ?? "";
|
||||||
|
$data['detection_bar_code'] = $request_params['detection_bar_code'];
|
||||||
|
$data['detection_status'] = 3;
|
||||||
|
|
||||||
|
$params = array();
|
||||||
|
$params['order_detection_id'] = $order_detection_id;
|
||||||
|
$res = OrderDetection::editOrderDetection($params,$data);
|
||||||
|
if (!$res){
|
||||||
|
Db::rollBack();
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR,"绑定失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 上报数据
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
}catch (\Exception $e){
|
||||||
|
Db::rollBack();
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return success();
|
return success();
|
||||||
|
|||||||
@ -662,4 +662,71 @@ class ImService extends BaseService
|
|||||||
throw new BusinessException($e->getMessage());
|
throw new BusinessException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 糖组检测报告
|
||||||
|
* @param array|object $order_detection 检测订单数据
|
||||||
|
* @param string $doctor_user_id 医生user_id
|
||||||
|
* @param string $patient_user_id 患者user_id
|
||||||
|
* @param string $disease_class_names 疾病数据
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function detectionTestReport(array|object $order_detection,string $doctor_user_id, string $patient_user_id,string $disease_class_names,string $detection_project_name): void
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// 发送消息
|
||||||
|
$cloud_custom_data = array();
|
||||||
|
$cloud_custom_data['is_system'] = 1;
|
||||||
|
$cloud_custom_data['inquiry_type'] = 5; // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测)
|
||||||
|
$cloud_custom_data['message_rounds'] = 0;
|
||||||
|
$cloud_custom_data['order_no'] = $order_detection['order_no'];
|
||||||
|
$cloud_custom_data['patient_family_data']['patient_name'] = $order_detection['patient_name'];
|
||||||
|
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_detection['patient_sex'];
|
||||||
|
$cloud_custom_data['patient_family_data']['patient_age'] = $order_detection['patient_age'];
|
||||||
|
|
||||||
|
// 消息内容
|
||||||
|
$message_content_data = array();
|
||||||
|
$message_content_data['message_type'] = 10;
|
||||||
|
$message_content_data['title'] = $detection_project_name;
|
||||||
|
$message_content_data['desc'] = "";
|
||||||
|
$message_content_data['data']['order_no'] = (string)$order_detection['order_no'];
|
||||||
|
$message_content_data['data']['disease_class_names'] = $disease_class_names;
|
||||||
|
$message_content_data['data']['message_path'] = "/pages/checkOrderDetail/checkOrderDetail?order_detection_id=" . $order_detection['detection_no']; // 跳转地址(小程序内页)
|
||||||
|
$message_content = [
|
||||||
|
'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE),
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->sendMessage($patient_user_id,$doctor_user_id, $message_content, "TIMCustomElem", $cloud_custom_data);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw new BusinessException($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 糖组检测报告-文字
|
||||||
|
* @param array|object $doctor_name 医生名称
|
||||||
|
* @param string $detection_project_name 检测项目名称
|
||||||
|
* @param string $doctor_user_id 医生user_id
|
||||||
|
* @param string $patient_user_id 患者user_id
|
||||||
|
* @param string $disease_class_names 疾病数据
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function detectionTestReportStr(string $doctor_name,string $detection_project_name,string $doctor_user_id, string $patient_user_id,string $disease_class_names): void
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// 消息内容
|
||||||
|
$message_content_data = array();
|
||||||
|
$message_content_data['Text'] = $doctor_name . "医生您好,我在您那里开具的【" . $detection_project_name . "】服务,报告单已出,请您查看报告并详细的做一下解读,谢谢医生。";
|
||||||
|
$message_content = [
|
||||||
|
'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE),
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->sendMessage($patient_user_id,$doctor_user_id, $message_content, "TIMTextElem", []);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw new BusinessException($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1394,7 +1394,7 @@ class MessagePush extends BaseService
|
|||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function prescriptionVerifyFail(string $order_prescription_id): void
|
public function prescriptionVerifyFail(string $order_prescription_id = ""): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// 获取问诊订单处方数据
|
// 获取问诊订单处方数据
|
||||||
@ -2232,14 +2232,14 @@ class MessagePush extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 患者-订单取消成功通知
|
* 患者-检测订单取消成功通知
|
||||||
* 订阅
|
* 订阅
|
||||||
* @param string $order_detection_id
|
* @param string $order_detection_id
|
||||||
* @return void
|
* @return void
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function patientCancelOrderSuccess(string $order_detection_id): void
|
public function patientCancelDetectionOrderSuccess(string $order_detection_id): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// 获取检测订单
|
// 获取检测订单
|
||||||
@ -2263,7 +2263,7 @@ class MessagePush extends BaseService
|
|||||||
$sub_data = array();
|
$sub_data = array();
|
||||||
$sub_data['push_user_id'] = $this->user['user_id'];
|
$sub_data['push_user_id'] = $this->user['user_id'];
|
||||||
$sub_data['wx_template_id'] = "5aJSrO8SU5rxqdB99zzl4rMVgcOTjt5mQh56cpZI1Hg";//咨询提醒
|
$sub_data['wx_template_id'] = "5aJSrO8SU5rxqdB99zzl4rMVgcOTjt5mQh56cpZI1Hg";//咨询提醒
|
||||||
$sub_data['params']['page'] = "/pages/checkOrderDetail/checkOrderDetail?order_detection_id=" . $order_detection['order_detection_id'];
|
$sub_data['params']['page'] = "/pages/checkOrderDetail/checkOrderDetail?order_detection_id=" . $order_detection['detection_no'];
|
||||||
$sub_data['params']['data'] = [
|
$sub_data['params']['data'] = [
|
||||||
"thing1" => $order_detection['patient_name'],// 就诊人
|
"thing1" => $order_detection['patient_name'],// 就诊人
|
||||||
"thing7" => (string)$detection_project['detection_project_name'],// 服务项目
|
"thing7" => (string)$detection_project['detection_project_name'],// 服务项目
|
||||||
@ -2286,4 +2286,65 @@ class MessagePush extends BaseService
|
|||||||
Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage());
|
Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 患者-新报告生成通知
|
||||||
|
// 订阅发送失败发送短信
|
||||||
|
public function patientDetectionResultNotice(string $order_detection_id){
|
||||||
|
try {
|
||||||
|
// 获取检测订单
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 订阅
|
||||||
|
$sub_data = array();
|
||||||
|
$sub_data['push_user_id'] = $this->user['user_id'];
|
||||||
|
$sub_data['wx_template_id'] = "dNj3azLupP_w3j649v6lqz7je_ScqwgwFsnug6pKvyI"; // 处方审核结果通知
|
||||||
|
$sub_data['params']['page'] = "/pages/checkOrderDetail/checkOrderDetail?order_detection_id=" . $order_detection['detection_no'];
|
||||||
|
$sub_data['params']['data'] = [
|
||||||
|
"thing1" => $order_detection['patient_name'],// 报告名称
|
||||||
|
"time3" => (string)$detection_project['detection_project_name'],// 生成时间
|
||||||
|
"thing9" => date('Y年m月d日 H:i'),// 就诊人
|
||||||
|
"thing4" => $order_detection['payment_amount_total'],// 单位名称-检测所名称
|
||||||
|
"thing8" => "订单取消成功,支付金额将立即原路退回。",// 测评结果
|
||||||
|
];
|
||||||
|
|
||||||
|
// 短信
|
||||||
|
$sms_data = array();
|
||||||
|
$sms_data['template_code'] = "SMS_271905264";
|
||||||
|
$sms_data['scene_desc'] = "您为{$this->order_inquiry['patient_name']}患者开具的电子处方药师审核不通过,请尽快前往微信小程序“处方管理”中查看原因,并重开处方。模版code:SMS_271905264";
|
||||||
|
$sms_data['phone'] = $this->user['mobile'];
|
||||||
|
$sms_data['user_id'] = $this->user['user_id'];
|
||||||
|
|
||||||
|
$template_param = array();
|
||||||
|
$template_param['name'] = $this->order_inquiry['patient_name'];
|
||||||
|
$sms_data['template_param'] = $template_param;
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
$data['sub_data'] = $sub_data;
|
||||||
|
$data['sms_data'] = $sms_data;
|
||||||
|
|
||||||
|
$message = new SendSubMessageProducer($data);
|
||||||
|
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||||
|
$result = $producer->produce($message);
|
||||||
|
if (!$result) {
|
||||||
|
Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -196,11 +196,11 @@ class PatientOrderService extends BaseService
|
|||||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||||
$order_inquiry_case = OrderInquiryCase::getOne($params, $fields);
|
$order_inquiry_case = OrderInquiryCase::getOne($params, $fields);
|
||||||
if (empty($order_inquiry_case)) {
|
if (empty($order_inquiry_case)) {
|
||||||
return fail();
|
$order_inquiry['case'] = [];
|
||||||
|
}else{
|
||||||
|
$order_inquiry['case'] = $order_inquiry_case->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
$order_inquiry['case'] = $order_inquiry_case->toArray();
|
|
||||||
|
|
||||||
// 获取医生数据
|
// 获取医生数据
|
||||||
$order_inquiry['user_doctor'] = [];
|
$order_inquiry['user_doctor'] = [];
|
||||||
if (!empty($order_inquiry['doctor_id'])) {
|
if (!empty($order_inquiry['doctor_id'])) {
|
||||||
@ -1861,7 +1861,7 @@ class PatientOrderService extends BaseService
|
|||||||
try {
|
try {
|
||||||
// 推送患者-订单取消成功通知
|
// 推送患者-订单取消成功通知
|
||||||
$MessagePush = new MessagePush($order_detection['user_id']);
|
$MessagePush = new MessagePush($order_detection['user_id']);
|
||||||
$MessagePush->patientCancelOrderSuccess($order_detection['order_detection_id']);
|
$MessagePush->patientCancelDetectionOrderSuccess($order_detection['order_detection_id']);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -665,6 +665,12 @@ Router::addGroup('/callback', function () {
|
|||||||
// 快递订阅查询
|
// 快递订阅查询
|
||||||
Router::post('', [CallBackController::class, 'LogisticsCallBack']);
|
Router::post('', [CallBackController::class, 'LogisticsCallBack']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 检测
|
||||||
|
Router::addGroup('/detection', function () {
|
||||||
|
// 检测所结果回调
|
||||||
|
Router::post('', [CallBackController::class, 'DetectionResultCallBack']);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// 用户
|
// 用户
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user