新增分配医生队列
This commit is contained in:
@@ -2,15 +2,18 @@
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Amqp\Producer\AssignDoctorProducer;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Services\BaseService;
|
||||
use App\Utils\Log;
|
||||
use Extend\Wechat\WechatPay;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Hyperf\HttpMessage\Stream\SwooleFileStream;
|
||||
use Hyperf\HttpMessage\Stream\SwooleStream;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class CallBackController extends AbstractController
|
||||
@@ -46,7 +49,6 @@ class CallBackController extends AbstractController
|
||||
Log::getInstance()->info("微信支付回调数据错误");
|
||||
return $server->serve();
|
||||
}
|
||||
dump($message);
|
||||
|
||||
// 查询订单
|
||||
$params = array();
|
||||
@@ -57,7 +59,6 @@ class CallBackController extends AbstractController
|
||||
Log::getInstance()->info("非法订单");
|
||||
return $server->serve();
|
||||
}
|
||||
dump(1);
|
||||
|
||||
// 验证订单状态
|
||||
if ($order_inquiry['inquiry_status'] != 1){
|
||||
@@ -66,7 +67,7 @@ class CallBackController extends AbstractController
|
||||
Log::getInstance()->info("订单状态错误:当前为" . $order_inquiry['inquiry_status']);
|
||||
return $server->serve();
|
||||
}
|
||||
dump(2);
|
||||
|
||||
// 支付状态无需验证,如第一次支付失败,会修改支付状态,再次支付时,会出现验证不通过的情况
|
||||
|
||||
// 修改支付状态
|
||||
@@ -75,6 +76,13 @@ class CallBackController extends AbstractController
|
||||
// 支付成功
|
||||
$data['inquiry_pay_status'] = 2;
|
||||
$data['pay_time'] = date('Y-m-d H:i:s',strtotime($message['success_time']));// 支付时间
|
||||
if ($order_inquiry['inquiry_type'] == 1 || $order_inquiry['inquiry_type'] == 3){
|
||||
// 专家-公益
|
||||
$data['inquiry_status'] = 3;// 3:待接诊
|
||||
}elseif ($order_inquiry['inquiry_type'] == 2 || $order_inquiry['inquiry_type'] == 4){
|
||||
// 快速-购药
|
||||
$data['inquiry_status'] = 2;// 2:待分配
|
||||
}
|
||||
}elseif($message['trade_state'] == "CLOSED"){
|
||||
// 已关闭
|
||||
$data['inquiry_pay_status'] = 6;
|
||||
@@ -95,17 +103,59 @@ class CallBackController extends AbstractController
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
OrderInquiry::edit($params,$data);
|
||||
dump(3);
|
||||
|
||||
// 处理分配医生问题
|
||||
if ($message['trade_state'] == "SUCCESS"){
|
||||
if ($order_inquiry['inquiry_type'] == 2 || $order_inquiry['inquiry_type'] == 4){
|
||||
// 快速-购药
|
||||
// 加入分配医生队列
|
||||
$data = array();
|
||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
|
||||
$message = new AssignDoctorProducer($data);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
$result = $producer->produce($message);
|
||||
if (!$result) {
|
||||
Db::rollBack();
|
||||
Log::getInstance()->info("加入分配医生队列失败");
|
||||
return $this->wxPayErrorReturn("加入分配医生队列失败");
|
||||
}
|
||||
}elseif ($order_inquiry['inquiry_type'] == 1 || $order_inquiry['inquiry_type'] == 3){
|
||||
// 专家-公益
|
||||
// 创建患者im账号
|
||||
// 检测医生im账号
|
||||
// 患者给医生发送im问诊消息
|
||||
// 消息订阅通知队列
|
||||
}
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return $server->serve();
|
||||
}catch (\Exception $e) {
|
||||
// 验证失败
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("微信支付回调数据验证失败:" . $e->getMessage());
|
||||
return $this->response->withStatus(500)->withBody(new SwooleStream(strval(json_encode(['code' => 'ERROR', 'message' => $e->getMessage()], JSON_UNESCAPED_UNICODE))));
|
||||
}
|
||||
return $this->wxPayErrorReturn($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付返回错误响应
|
||||
* @param string $message
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
protected function wxPayErrorReturn(string $message): ResponseInterface
|
||||
{
|
||||
return $this->response
|
||||
->withStatus(500)
|
||||
->withBody(
|
||||
new SwooleStream(
|
||||
strval(
|
||||
json_encode(['code' => 'ERROR', 'message' => $message], JSON_UNESCAPED_UNICODE)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
// im回调
|
||||
public function imCallBack(){
|
||||
$request_params = $this->request->all();
|
||||
|
||||
Reference in New Issue
Block a user