修正无医生数据
This commit is contained in:
@@ -5,10 +5,14 @@ declare(strict_types=1);
|
||||
namespace App\Amqp\Consumer;
|
||||
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Services\ImService;
|
||||
use App\Services\InquiryService;
|
||||
use App\Services\UserDoctorService;
|
||||
use App\Utils\Log;
|
||||
use Extend\TencentIm\Message;
|
||||
use Extend\Wechat\WechatPay;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Hyperf\Amqp\Result;
|
||||
use Hyperf\Amqp\Annotation\Consumer;
|
||||
use Hyperf\Amqp\Message\ConsumerMessage;
|
||||
@@ -29,6 +33,7 @@ class AssignDoctorConsumer extends ConsumerMessage
|
||||
/**
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function consumeMessage($data, AMQPMessage $message): string
|
||||
{
|
||||
@@ -166,12 +171,65 @@ class AssignDoctorConsumer extends ConsumerMessage
|
||||
Db::commit();
|
||||
Log::getInstance()->error("分配医生 队列执行成功");
|
||||
|
||||
// 加入消息通知队列
|
||||
return Result::ACK;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("队列执行失败原因:" . $e->getMessage());
|
||||
return Result::REQUEUE; // 重回队列
|
||||
}
|
||||
|
||||
try {
|
||||
// 专家-公益
|
||||
$ImService = new ImService();
|
||||
|
||||
// 检测并创建患者账号
|
||||
$ImService->createAccount($order_inquiry['user_id']);
|
||||
|
||||
// 获取订单医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)){
|
||||
Log::getInstance()->info("医生数据错误");
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
// 检测并创建医生账号
|
||||
$ImService->createAccount($doctor_id);
|
||||
|
||||
// 医生给患者发送消息
|
||||
$message = new Message();
|
||||
|
||||
$arg = array();
|
||||
$arg['From_Account'] = $user_doctor['user_id']; // 发送方user_id 如系统发送,无需填写
|
||||
$arg['To_Account'] = $order_inquiry['user_id']; // 接收方user_id
|
||||
|
||||
$arg['MsgBody'] = [
|
||||
[
|
||||
"MsgType" => "TIMTextElem",
|
||||
"MsgContent" => [
|
||||
"Text" => "等待医生接诊",
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
// 自定义消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['message_type'] = 1;//1:系统发送 其余:用户发送
|
||||
|
||||
$arg['CloudCustomData'] = json_encode($cloud_custom_data,JSON_UNESCAPED_UNICODE);
|
||||
|
||||
$message->sendMessage($arg);
|
||||
|
||||
}catch (\Exception $e) {
|
||||
// 验证失败
|
||||
Log::getInstance()->error("分配医生成功,发送系统问诊消息失败:" . $e->getMessage());
|
||||
// 加入消息通知队列
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
// 加入消息通知队列
|
||||
return Result::ACK;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user