去除获取处方平台状态退款消息推送(回调会推)。
This commit is contained in:
parent
bbc1135e56
commit
0902ca321d
@ -117,8 +117,11 @@ class AssignPharmacistConsumer extends ConsumerMessage
|
|||||||
* 分配失败
|
* 分配失败
|
||||||
* @param string $order_prescription_id
|
* @param string $order_prescription_id
|
||||||
* @param string $doctor_user_id
|
* @param string $doctor_user_id
|
||||||
|
* @param string $patient_user_id
|
||||||
* @param string $order_inquiry_id
|
* @param string $order_inquiry_id
|
||||||
* @return void
|
* @return void
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function reject(string $order_prescription_id, string $doctor_user_id, string $patient_user_id, string $order_inquiry_id): void
|
public function reject(string $order_prescription_id, string $doctor_user_id, string $patient_user_id, string $order_inquiry_id): void
|
||||||
{
|
{
|
||||||
|
|||||||
@ -25,6 +25,10 @@ use PhpAmqpLib\Message\AMQPMessage;
|
|||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自动完成问诊订单
|
||||||
|
* 延迟队列
|
||||||
|
*/
|
||||||
#[Consumer(nums: 1)]
|
#[Consumer(nums: 1)]
|
||||||
class AutoCompleteInquiryDelayDirectConsumer extends ConsumerMessage
|
class AutoCompleteInquiryDelayDirectConsumer extends ConsumerMessage
|
||||||
{
|
{
|
||||||
|
|||||||
@ -128,8 +128,6 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 下载医生签章文件
|
|
||||||
Db::beginTransaction();
|
|
||||||
try {
|
try {
|
||||||
Log::getInstance("queue-AutoPharmacistCaVerify")->info("检测执行次数");
|
Log::getInstance("queue-AutoPharmacistCaVerify")->info("检测执行次数");
|
||||||
|
|
||||||
@ -139,7 +137,7 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
|
|||||||
Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:超出最大执行次数或检测错误");
|
Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:超出最大执行次数或检测错误");
|
||||||
|
|
||||||
// 修改处方表为未通过
|
// 修改处方表为未通过
|
||||||
$this->modifyOrderPrescription($data['order_prescription_id'],2,"请联系平台客服,请勿重开处方");
|
$this->modifyOrderPrescription($data['order_prescription_id'], 2, "请联系平台客服,请勿重开处方");
|
||||||
|
|
||||||
// 医生-开具的处方审核未通过
|
// 医生-开具的处方审核未通过
|
||||||
$MessagePush = new MessagePush($user_doctor['user_id'], $order_prescription['order_inquiry_id']);
|
$MessagePush = new MessagePush($user_doctor['user_id'], $order_prescription['order_inquiry_id']);
|
||||||
@ -149,14 +147,35 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
|
|||||||
$MessagePush = new MessagePush($user_patient['user_id'], $order_prescription['order_inquiry_id']);
|
$MessagePush = new MessagePush($user_patient['user_id'], $order_prescription['order_inquiry_id']);
|
||||||
$MessagePush->patientPrescriptionVerifyFail();
|
$MessagePush->patientPrescriptionVerifyFail();
|
||||||
|
|
||||||
Db::commit();
|
|
||||||
return Result::ACK;
|
return Result::ACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (time() < 1682251200){
|
|
||||||
Db::rollBack();
|
}catch (\Exception $e){
|
||||||
return Result::REQUEUE;
|
// 检测次数失败
|
||||||
|
Log::getInstance("queue-AutoPharmacistCaVerify")->info("错误:" . $e->getMessage());
|
||||||
|
return Result::ACK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下载医生签章文件
|
||||||
|
Db::beginTransaction();
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
// 检测执行次数
|
||||||
|
$res = $this->checkHandleNumber($data['prescription_file_id']);
|
||||||
|
if (!$res) {
|
||||||
|
Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:超出最大执行次数或检测错误");
|
||||||
|
|
||||||
|
// 修改处方表为未通过
|
||||||
|
$this->modifyOrderPrescription($data['order_prescription_id'],2,"请联系平台客服,请勿重开处方");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取处方文件数据
|
// 获取处方文件数据
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['prescription_file_id'] = $data['prescription_file_id'];
|
$params['prescription_file_id'] = $data['prescription_file_id'];
|
||||||
|
|||||||
@ -4,11 +4,13 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Command;
|
namespace App\Command;
|
||||||
|
|
||||||
|
use App\Model\OrderPrescription;
|
||||||
use App\Model\OrderProduct;
|
use App\Model\OrderProduct;
|
||||||
use App\Model\UserPatient;
|
use App\Model\UserPatient;
|
||||||
use App\Services\MessagePush;
|
use App\Services\MessagePush;
|
||||||
use App\Services\OrderPrescriptionService;
|
use App\Services\OrderPrescriptionService;
|
||||||
use App\Services\OrderProductService;
|
use App\Services\OrderProductService;
|
||||||
|
use App\Utils\Log;
|
||||||
use Hyperf\Command\Command as HyperfCommand;
|
use Hyperf\Command\Command as HyperfCommand;
|
||||||
use Hyperf\Command\Annotation\Command;
|
use Hyperf\Command\Annotation\Command;
|
||||||
use Hyperf\DbConnection\Db;
|
use Hyperf\DbConnection\Db;
|
||||||
@ -41,20 +43,20 @@ class ReportPreProductOrderCommand extends HyperfCommand
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$this->line("上报处方平台商品订单开始");
|
$this->line("开始");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 获取可上报商品订单
|
// 获取可上报商品订单
|
||||||
$order_product_ids = $this->getExecProductOrder();
|
$order_product_ids = $this->getExecProductOrder();
|
||||||
if (empty($order_product_ids)){
|
if (empty($order_product_ids)){
|
||||||
$this->line("上报处方平台商品订单结束,无可上报的商品订单");
|
$this->line("结束,无可上报的商品订单");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取缓存
|
// 获取缓存
|
||||||
$redis = $this->container->get(Redis::class);
|
$redis = $this->container->get(Redis::class);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->line("上报处方平台商品订单失败:" . $e->getMessage());
|
$this->line("错误:" . $e->getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,62 +65,50 @@ class ReportPreProductOrderCommand extends HyperfCommand
|
|||||||
|
|
||||||
Db::beginTransaction();
|
Db::beginTransaction();
|
||||||
|
|
||||||
$redis_key = "ReportPreProductOrder" . $item['order_product_id'];
|
|
||||||
|
|
||||||
// 处理超出最大执行次数/退款问题
|
|
||||||
try {
|
try {
|
||||||
$redis_value = $redis->get($redis_key);
|
// 检测执行次数
|
||||||
$redis->incr($redis_key);
|
$res = $this->checkHandleNumber($item['order_product_id']);
|
||||||
if(!empty($redis_value)){
|
if (!$res) {
|
||||||
if ($redis_value >= 2){
|
Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:超出最大执行次数或检测错误");
|
||||||
// 存储上报失败
|
|
||||||
$this->savaReportFail($item['order_product_id'],"超出最大上报次数");
|
|
||||||
|
|
||||||
// 修改失败时药品订单数据
|
// 修改药品订单表上报处方平台状态
|
||||||
$this->savePreFailedOrderStatus($item['order_product_id'],"复核失败");
|
$this->saveOrderProductPeportPreStatus($item['order_product_id'],2,"超出最大上报次数");
|
||||||
|
|
||||||
// 退款
|
// 修改失败时药品订单数据
|
||||||
$this->line("超出最大执行次数,执行退款");
|
$this->savePreFailedOrderStatus($item['order_product_id'],"复核失败");
|
||||||
$OrderProductService = new OrderProductService();
|
|
||||||
$OrderProductService->OrderProductRefund($item['order_product_id'],"药品订单退款");
|
|
||||||
|
|
||||||
// 清空缓存
|
// 退款
|
||||||
$redis->del($redis_key);
|
$OrderProductService = new OrderProductService();
|
||||||
|
$OrderProductService->OrderProductRefund($item['order_product_id'],"药品订单退款");
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}catch(\Exception $e){
|
||||||
Db::commit();
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
Db::rollBack();
|
Db::rollBack();
|
||||||
// 记录失败次数
|
// 记录失败次数
|
||||||
$this->line("商品订单上报处方平台失败:失败原因" . $e->getMessage());
|
$this->line("错误:" . $e->getMessage());
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理上报处方平台问题
|
|
||||||
try {
|
try {
|
||||||
// 上报处方平台
|
// 上报处方平台
|
||||||
$orderPrescriptionService = new OrderPrescriptionService();
|
$orderPrescriptionService = new OrderPrescriptionService();
|
||||||
$orderPrescriptionService->reportPrescription($item['order_product_id']);
|
$orderPrescriptionService->reportPrescription($item['order_product_id']);
|
||||||
|
|
||||||
// 存储上报成功
|
// 修改药品订单表上报处方平台状态
|
||||||
$this->savaReportSuccess($item['order_product_id']);
|
$this->saveOrderProductPeportPreStatus($item['order_product_id'],1);
|
||||||
|
|
||||||
// 清空缓存
|
$this->line("成功");
|
||||||
$redis->del($redis_key);
|
|
||||||
|
|
||||||
$this->line("商品订单上报处方平台成功");
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
continue;
|
continue;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Db::rollBack();
|
Db::rollBack();
|
||||||
$this->line("上报失败:失败原因" . $e->getMessage());
|
$this->line("错误" . $e->getMessage());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->line("商品订单上报处方平台全部结束");
|
$this->line("全部结束");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,7 +125,9 @@ class ReportPreProductOrderCommand extends HyperfCommand
|
|||||||
|
|
||||||
$fields = [
|
$fields = [
|
||||||
'order_product_id',
|
'order_product_id',
|
||||||
|
'user_id',
|
||||||
'patient_id',
|
'patient_id',
|
||||||
|
'order_prescription_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
$order_product = OrderProduct::getList($params,$fields);
|
$order_product = OrderProduct::getList($params,$fields);
|
||||||
@ -147,38 +139,24 @@ class ReportPreProductOrderCommand extends HyperfCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 存储上报失败
|
* 修改药品订单表上报处方平台状态
|
||||||
* @param string $order_product_id 商品订单id
|
* @param string $order_product_id
|
||||||
* @param string $report_pre_fail_reason 上报失败原因
|
* @param int $report_pre_status
|
||||||
|
* @param string $report_pre_fail_reason
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function savaReportFail(string $order_product_id,string $report_pre_fail_reason = ""): void
|
protected function saveOrderProductPeportPreStatus(string $order_product_id,int $report_pre_status,string $report_pre_fail_reason = ""): void
|
||||||
{
|
{
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['order_product_id'] = $order_product_id;
|
$params['order_product_id'] = $order_product_id;
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
$data['report_pre_status'] = 2; // 上报处方平台状态(0:未上报 1:已上报 2:上报失败))
|
$data['report_pre_status'] = $report_pre_status; // 上报处方平台状态(0:未上报 1:已上报 2:上报失败))
|
||||||
if (!empty($report_pre_fail_reason)){
|
|
||||||
$data['report_pre_fail_reason'] = $report_pre_fail_reason;
|
|
||||||
}
|
|
||||||
OrderProduct::edit($params,$data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 存储上报成功
|
|
||||||
* @param string $order_product_id 商品订单id
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function savaReportSuccess(string $order_product_id): void
|
|
||||||
{
|
|
||||||
$params = array();
|
|
||||||
$params['order_product_id'] = $order_product_id;
|
|
||||||
|
|
||||||
$data = array();
|
|
||||||
$data['report_pre_status'] = 1; // 上报处方平台状态(0:未上报 1:已上报 2:上报失败))
|
|
||||||
$data['report_pre_time'] = date('Y-m-d H:i:s',time()); // 上报处方平台时间
|
$data['report_pre_time'] = date('Y-m-d H:i:s',time()); // 上报处方平台时间
|
||||||
$data['report_pre_fail_reason'] = ""; // 上报失败原因 置为空
|
if (!empty($report_pre_fail_reason)){
|
||||||
|
$data['report_pre_fail_reason'] = ""; // 上报失败原因 置为空
|
||||||
|
}
|
||||||
|
|
||||||
OrderProduct::edit($params,$data);
|
OrderProduct::edit($params,$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,4 +178,37 @@ class ReportPreProductOrderCommand extends HyperfCommand
|
|||||||
OrderProduct::edit($params,$data);
|
OrderProduct::edit($params,$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测执行次数
|
||||||
|
* @param string $order_product_id
|
||||||
|
* @return bool
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
protected function checkHandleNumber(string $order_product_id): bool
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$redis = $this->container->get(Redis::class);
|
||||||
|
|
||||||
|
$redis_key = "ReportPreProductOrder" . $order_product_id;
|
||||||
|
$redis_value = $redis->get($redis_key);
|
||||||
|
if (empty($redis_value)) {
|
||||||
|
$redis->set($redis_key, 1, 60 * 60 * 24 * 5);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行次数过多
|
||||||
|
if ($redis_value > 3) {
|
||||||
|
// 加入短信队列,通知管理员
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$redis->incr($redis_key);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,9 +52,6 @@ class getPrescriptionOrderStatusCommand extends HyperfCommand
|
|||||||
foreach ($order_product_ids as $item) {
|
foreach ($order_product_ids as $item) {
|
||||||
Db::beginTransaction();
|
Db::beginTransaction();
|
||||||
|
|
||||||
// 是否执行了退款-预定义变量
|
|
||||||
$is_refund = 0;
|
|
||||||
|
|
||||||
$this->line("本次请求订单号:" . $item['order_product_id']);
|
$this->line("本次请求订单号:" . $item['order_product_id']);
|
||||||
|
|
||||||
// 获取药品订单处方数据
|
// 获取药品订单处方数据
|
||||||
@ -108,9 +105,6 @@ class getPrescriptionOrderStatusCommand extends HyperfCommand
|
|||||||
// 执行退款
|
// 执行退款
|
||||||
$OrderProductService = new OrderProductService();
|
$OrderProductService = new OrderProductService();
|
||||||
$OrderProductService->OrderProductRefund($item['order_product_id'],"订单退款");
|
$OrderProductService->OrderProductRefund($item['order_product_id'],"订单退款");
|
||||||
|
|
||||||
// 标记为执行了退款
|
|
||||||
$is_refund = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result['status'] == "CFD05"){
|
if ($result['status'] == "CFD05"){
|
||||||
@ -157,23 +151,6 @@ class getPrescriptionOrderStatusCommand extends HyperfCommand
|
|||||||
// 记录失败次数
|
// 记录失败次数
|
||||||
$this->line("获取处方平台订单数据失败:" . $e->getMessage());
|
$this->line("获取处方平台订单数据失败:" . $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测是否执行了退款
|
|
||||||
if ($is_refund == 1){
|
|
||||||
try {
|
|
||||||
$this->line("发送消息推送");
|
|
||||||
|
|
||||||
// 获取患者用户id
|
|
||||||
$user_id = $this->getPatientUserId($item['patient_id']);
|
|
||||||
if (!empty($user_id)){
|
|
||||||
// 发送站内、订阅、短信消息-药品订单退款成功
|
|
||||||
$MessagePush = new MessagePush($user_id);
|
|
||||||
$MessagePush->refundProductSuccess($item['order_product_id']);
|
|
||||||
}
|
|
||||||
}catch(\Exception $e){
|
|
||||||
$this->line("发送消息推送失败:" . $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->line("获取处方平台订单数据全部处理结束");
|
$this->line("获取处方平台订单数据全部处理结束");
|
||||||
|
|||||||
@ -17,6 +17,7 @@ use App\Model\Product;
|
|||||||
use App\Model\SystemInquiryConfig;
|
use App\Model\SystemInquiryConfig;
|
||||||
use App\Model\User;
|
use App\Model\User;
|
||||||
use App\Model\UserDoctor;
|
use App\Model\UserDoctor;
|
||||||
|
use App\Utils\Log;
|
||||||
use Hyperf\Amqp\Producer;
|
use Hyperf\Amqp\Producer;
|
||||||
use Hyperf\Utils\ApplicationContext;
|
use Hyperf\Utils\ApplicationContext;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
@ -1300,7 +1301,7 @@ class MessagePush extends BaseService
|
|||||||
$params['order_prescription_id'] = $order_prescription_id;
|
$params['order_prescription_id'] = $order_prescription_id;
|
||||||
$order_prescription = OrderPrescription::getOne($params);
|
$order_prescription = OrderPrescription::getOne($params);
|
||||||
if (empty($order_prescription)) {
|
if (empty($order_prescription)) {
|
||||||
throw new BusinessException("加入推送队列失败:处方数据为空");
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 订阅
|
// 订阅
|
||||||
@ -1337,7 +1338,8 @@ class MessagePush extends BaseService
|
|||||||
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
|
throw new BusinessException("加入推送队列失败" . json_encode($data,JSON_UNESCAPED_UNICODE));
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw new BusinessException("加入推送队列失败" . $e->getMessage());
|
Log::getInstance("MessagePush")->error("错误:" . $e->getMessage());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user