1
This commit is contained in:
parent
02bb102a4d
commit
0f098b1df6
@ -191,7 +191,7 @@ class AssignDoctorConsumer extends ConsumerMessage
|
||||
}
|
||||
|
||||
// 发送消息
|
||||
$ImService->sendTextMessage($user_doctor['user_id'],$order_inquiry['user_id'],"等待医生接诊",$order_inquiry['order_inquiry_id']);
|
||||
$ImService->sendTextMessage($user_doctor['user_id'],$order_inquiry['user_id'],"等待医生接诊",$order_inquiry['order_inquiry_id'],$order_inquiry['inquiry_type']);
|
||||
|
||||
Log::getInstance()->info("分配医生成功,发送系统问诊消息成功");
|
||||
}catch (\Exception $e) {
|
||||
|
||||
@ -8,6 +8,7 @@ use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\Hospital;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderInquiryRefund;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Model\UserPatient;
|
||||
use App\Services\BaseService;
|
||||
@ -18,6 +19,7 @@ use Extend\TencentIm\Message;
|
||||
use Extend\TencentIm\Profile;
|
||||
use Extend\Wechat\WechatPay;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\Amqp\Result;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Hyperf\HttpMessage\Stream\SwooleFileStream;
|
||||
use Hyperf\HttpMessage\Stream\SwooleStream;
|
||||
@ -115,7 +117,6 @@ class CallBackController extends AbstractController
|
||||
}
|
||||
|
||||
Log::getInstance()->info("微信支付回调处理成功");
|
||||
Log::getInstance()->info("微信支付回调处理成功,开始发送系统问诊消息");
|
||||
|
||||
try {
|
||||
if ($message['trade_state'] == "SUCCESS"){
|
||||
@ -134,6 +135,8 @@ class CallBackController extends AbstractController
|
||||
}
|
||||
}elseif ($order_inquiry['inquiry_type'] == 1 || $order_inquiry['inquiry_type'] == 3){
|
||||
// 专家-公益,发送im消息
|
||||
Log::getInstance()->info("开始发送im消息");
|
||||
|
||||
$ImService = new ImService();
|
||||
|
||||
// 获取订单医生数据
|
||||
@ -146,9 +149,9 @@ class CallBackController extends AbstractController
|
||||
}
|
||||
|
||||
// 发送消息
|
||||
$ImService->sendTextMessage($user_doctor['user_id'],$order_inquiry['user_id'],"等待医生接诊",$order_inquiry['order_inquiry_id']);
|
||||
$ImService->sendTextMessage($user_doctor['user_id'],$order_inquiry['user_id'],"等待医生接诊",$order_inquiry['order_inquiry_id'],$order_inquiry['inquiry_type']);
|
||||
|
||||
Log::getInstance()->info("微信支付回调数据处理成功,发送系统问诊消息成功");
|
||||
Log::getInstance()->info("发送im消息成功");
|
||||
}
|
||||
}
|
||||
}catch (\Exception $e) {
|
||||
@ -157,7 +160,7 @@ class CallBackController extends AbstractController
|
||||
return $server->serve();
|
||||
}
|
||||
|
||||
Log::getInstance()->info("微信支付回调处理成功,发送系统问诊消息成功");
|
||||
Log::getInstance()->info("微信支付回调处理成功");
|
||||
|
||||
return $server->serve();
|
||||
}
|
||||
@ -171,6 +174,8 @@ class CallBackController extends AbstractController
|
||||
*/
|
||||
public function wxPayRefundCallBack(): ResponseInterface
|
||||
{
|
||||
Db::beginTransaction();
|
||||
|
||||
try {
|
||||
// 处理支付结果事件
|
||||
$WechatPay = new WechatPay(1);
|
||||
@ -187,13 +192,91 @@ class CallBackController extends AbstractController
|
||||
$app->getValidator()->validate($app->getRequest());
|
||||
|
||||
Log::getInstance()->info("微信退款回调数据:" . json_encode($message->toArray(),JSON_UNESCAPED_UNICODE));
|
||||
return $server->serve();
|
||||
|
||||
if (empty($message['out_trade_no'])){
|
||||
Log::getInstance()->info("微信退款回调数据错误");
|
||||
return $server->serve();
|
||||
}
|
||||
|
||||
// 验证订单数据
|
||||
$params = array();
|
||||
$params['inquiry_no'] = $message['out_trade_no'];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)){
|
||||
Log::getInstance()->info("非法订单");
|
||||
return $server->serve();
|
||||
}
|
||||
|
||||
// 验证订单状态
|
||||
if ($order_inquiry['inquiry_status'] == 1){
|
||||
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
Log::getInstance()->info("订单状态错误:当前为" . $order_inquiry['inquiry_status']);
|
||||
return $server->serve();
|
||||
}
|
||||
|
||||
|
||||
// 验证订单退款状态
|
||||
if ($order_inquiry['inquiry_refund_status'] == 3) {
|
||||
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
Log::getInstance()->info("订单退款状态错误:当前为" . $order_inquiry['inquiry_refund_status']);
|
||||
return $server->serve();
|
||||
}
|
||||
|
||||
// 验证订单支付状态
|
||||
if (in_array($order_inquiry['inquiry_pay_status'],[1,3,4,5,6,7])) {
|
||||
// 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
Log::getInstance()->error("队列执行失败原因:订单未支付");
|
||||
return $server->serve();
|
||||
}
|
||||
|
||||
// 退款状态
|
||||
if ($message['refund_status'] == "SUCCESS"){
|
||||
// 退款成功
|
||||
$inquiry_refund_status = 3;
|
||||
}elseif ($message['refund_status'] == "CLOSED"){
|
||||
// 退款关闭
|
||||
$inquiry_refund_status = 5;
|
||||
}elseif ($message['refund_status'] == "ABNORMAL"){
|
||||
// 退款异常
|
||||
$inquiry_refund_status = 6;
|
||||
}
|
||||
|
||||
if (empty($inquiry_refund_status)){
|
||||
// 错误,无退款状态
|
||||
Log::getInstance()->error("队列执行失败原因:订单未支付");
|
||||
return $this->wxPayErrorReturn("退款状态错误");
|
||||
}
|
||||
|
||||
// 修改订单
|
||||
$data = array();
|
||||
$data['inquiry_refund_status'] = $inquiry_refund_status;
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
OrderInquiry::edit($params,$data);
|
||||
|
||||
// 修改退款订单
|
||||
$data = array();
|
||||
$data['inquiry_refund_status'] = $inquiry_refund_status;
|
||||
$data['success_time'] = $message['success_time'];
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
OrderInquiryRefund::edit($params,$data);
|
||||
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
// 验证失败
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("微信支付回调数据验证失败:" . $e->getMessage());
|
||||
return $this->wxPayErrorReturn($e->getMessage());
|
||||
}
|
||||
|
||||
Log::getInstance()->info("微信退款回调处理成功");
|
||||
|
||||
// 发送短信消息
|
||||
|
||||
return $server->serve();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -342,6 +425,7 @@ class CallBackController extends AbstractController
|
||||
// 存储redisList
|
||||
if (!empty($order_inquiry) && !empty($request_params['CloudCustomData'])){
|
||||
if (!empty($order_inquiry['doctor_id'])){
|
||||
$data = array();
|
||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$data['to_user_id'] = $request_params['To_Account'];
|
||||
$data['patient_name'] = $order_inquiry['patient_name'];
|
||||
|
||||
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Request\OrderInquiryRequest;
|
||||
use App\Request\PatientDoctorRequest;
|
||||
use App\Services\OrderInquiryService;
|
||||
use App\Services\PatientDoctorService;
|
||||
use App\Services\UserDoctorService;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
|
||||
@ -88,18 +88,18 @@ class UserController extends AbstractController
|
||||
$out_trade_no = $this->request->input('out_trade_no');
|
||||
// $generator = $this->container->get(IdGeneratorInterface::class);
|
||||
//
|
||||
$WechatPay = new WechatPay(1);
|
||||
// $WechatPay = new WechatPay(1);
|
||||
//
|
||||
// 获取预支付交易会话标识
|
||||
$total = 0.01 * 100;
|
||||
$prepay = $WechatPay->getJsapiPrepayId($out_trade_no,$total,"omgU35DlE-rxTAGgcBjOuc4xdcX8");
|
||||
if (empty($prepay)){
|
||||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||||
}
|
||||
|
||||
// 获取小程序支付配置
|
||||
$pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']);
|
||||
return $this->response->json($pay_config);
|
||||
// // 获取预支付交易会话标识
|
||||
// $total = 0.01 * 100;
|
||||
// $prepay = $WechatPay->getJsapiPrepayId($out_trade_no,$total,"omgU35DlE-rxTAGgcBjOuc4xdcX8");
|
||||
// if (empty($prepay)){
|
||||
// return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||||
// }
|
||||
//
|
||||
// // 获取小程序支付配置
|
||||
// $pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']);
|
||||
// return $this->response->json($pay_config);
|
||||
|
||||
// 发起退款
|
||||
// $WechatPay = new WechatPay(1);
|
||||
@ -152,15 +152,16 @@ class UserController extends AbstractController
|
||||
|
||||
// 发送消息
|
||||
// $arg = array();
|
||||
// $arg['From_Account'] = "10002"; // 发送方user_id 如系统发送,无需填写
|
||||
// $arg['From_Account'] = "10000"; // 发送方user_id 如系统发送,无需填写
|
||||
// $arg['To_Account'] = "123456"; // 接收方user_id
|
||||
// $arg['ForbidCallbackControl'] = ['ForbidBeforeSendMsgCallback'];
|
||||
// $arg['SendMsgControl'] = [];
|
||||
//
|
||||
// $arg['MsgBody'] = [
|
||||
// [
|
||||
// "MsgType" => "TIMTextElem",
|
||||
// "MsgContent" => [
|
||||
// "Text" => "测试消息33",
|
||||
// "Text" => "发送11122",
|
||||
// ],
|
||||
// ]
|
||||
// ];
|
||||
@ -169,13 +170,14 @@ class UserController extends AbstractController
|
||||
// $cloud_custom_data = array();
|
||||
// $cloud_custom_data['order_inquiry_id'] = 491963820554948608;
|
||||
// $cloud_custom_data['is_system'] = 0;
|
||||
// $cloud_custom_data['inquiry_type'] = 2;
|
||||
//
|
||||
// $arg['CloudCustomData'] = json_encode($cloud_custom_data,JSON_UNESCAPED_UNICODE);
|
||||
//
|
||||
// $result = $message->sendMessage($arg);
|
||||
|
||||
// $result = $profile->getOneAccountPortraitList("123456");
|
||||
|
||||
//
|
||||
//// $result = $profile->getOneAccountPortraitList("123456");
|
||||
//
|
||||
// dump($result);
|
||||
|
||||
|
||||
@ -193,6 +195,22 @@ class UserController extends AbstractController
|
||||
// // 发送消息
|
||||
// $ImService->sendTextMessage($user_doctor['user_id'],"491923510680424449","等待医生接诊",491937904055369728);
|
||||
|
||||
//
|
||||
// $data = array();
|
||||
// $data['order_inquiry_id'] = 4;
|
||||
// $data['to_user_id'] = 10004;
|
||||
// $data['patient_name'] = "用户4";
|
||||
// $data['patient_sex'] = 2;
|
||||
// $data['patient_age'] = 19;
|
||||
// $data['inquiry_status'] = 1;
|
||||
// $data['message_send_time'] = 1678112190;
|
||||
// $data['message_seq'] = 101;
|
||||
// $data['message_type'] = "TIMTextElem";
|
||||
// $data['last_message_content']['Text'] = "测试消息4";
|
||||
//
|
||||
// $imService = new ImService();
|
||||
// $imService->addRecentContactRecordCache("491925054779883520", 2, 10004, $data);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -69,4 +69,9 @@ class OrderInquiryRefund extends Model
|
||||
{
|
||||
return self::create($data);
|
||||
}
|
||||
|
||||
public static function edit(array $params = [], array $data = []): int
|
||||
{
|
||||
return self::where($params)->update($data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,10 +171,11 @@ class ImService extends BaseService
|
||||
* @param string $to_user_id 接受者id
|
||||
* @param string $content 内容
|
||||
* @param string $order_inquiry_id 订单id
|
||||
* @param int $inquiry_type
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function sendTextMessage(string $from_user_id,string $to_user_id,string $content,string $order_inquiry_id): void
|
||||
public function sendTextMessage(string $from_user_id,string $to_user_id,string $content,string $order_inquiry_id,int $inquiry_type): void
|
||||
{
|
||||
if (!empty($from_user_id)){
|
||||
// 检测并创建发送者账号
|
||||
@ -208,6 +209,7 @@ class ImService extends BaseService
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = $order_inquiry_id;
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $inquiry_type;
|
||||
|
||||
$arg['CloudCustomData'] = json_encode($cloud_custom_data,JSON_UNESCAPED_UNICODE);
|
||||
|
||||
|
||||
@ -261,7 +261,7 @@ class InquiryService extends BaseService
|
||||
// 获取小程序支付配置
|
||||
$pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']);
|
||||
|
||||
// 增加至退款延迟队列
|
||||
// 增加至取消订单延迟队列
|
||||
$data = array();
|
||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ class PatientDoctorService extends BaseService
|
||||
$province_id = $this->request->input('province_id');
|
||||
$city_id = $this->request->input('city_id');
|
||||
$sort_order = $this->request->input('sort_order');
|
||||
$keyword = $this->request->input('keyword');
|
||||
$keyword = $this->request->input('keyword',"");
|
||||
|
||||
// 组合条件
|
||||
$hospital_params = array();// 医院搜索
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user