1
This commit is contained in:
@@ -5,6 +5,8 @@ declare(strict_types=1);
|
||||
namespace App\Command;
|
||||
|
||||
use App\Model\OrderProduct;
|
||||
use App\Model\UserPatient;
|
||||
use App\Services\MessagePush;
|
||||
use App\Services\OrderPrescriptionService;
|
||||
use App\Services\OrderProductService;
|
||||
use Hyperf\Command\Command as HyperfCommand;
|
||||
@@ -68,7 +70,7 @@ class ReportPreProductOrderCommand extends HyperfCommand
|
||||
$redis_value = $redis->get($redis_key);
|
||||
$redis->incr($redis_key);
|
||||
if(!empty($redis_value)){
|
||||
if ($redis_value >= 2){
|
||||
if ($redis_value >= 100){
|
||||
// 存储上报失败
|
||||
$this->savaReportFail($item['order_product_id'],"超出最大上报次数");
|
||||
|
||||
@@ -80,6 +82,14 @@ class ReportPreProductOrderCommand extends HyperfCommand
|
||||
$OrderProductService = new OrderProductService();
|
||||
$OrderProductService->OrderProductRefund($item['order_product_id'],"药品订单退款");
|
||||
|
||||
// 获取患者用户id
|
||||
$user_id = $this->getPatientUserId($item['patient_id']);
|
||||
if (!empty($user_id)){
|
||||
// 发送站内、订阅、短信消息-药品订单退款成功
|
||||
$MessagePush = new MessagePush($user_id);
|
||||
$MessagePush->refundProductSuccess($item['order_product_id']);
|
||||
}
|
||||
|
||||
// 清空缓存
|
||||
$redis->del($redis_key);
|
||||
|
||||
@@ -99,12 +109,7 @@ class ReportPreProductOrderCommand extends HyperfCommand
|
||||
try {
|
||||
// 上报处方平台
|
||||
$orderPrescriptionService = new OrderPrescriptionService();
|
||||
$res = $orderPrescriptionService->reportPrescription($item['order_product_id']);
|
||||
if (!$res){
|
||||
// 上报失败
|
||||
$this->line("上报失败");
|
||||
continue;
|
||||
}
|
||||
$orderPrescriptionService->reportPrescription($item['order_product_id']);
|
||||
|
||||
// 存储上报成功
|
||||
$this->savaReportSuccess($item['order_product_id']);
|
||||
@@ -114,7 +119,7 @@ class ReportPreProductOrderCommand extends HyperfCommand
|
||||
Db::rollBack();
|
||||
// 记录失败次数
|
||||
$redis->incr($redis_key);
|
||||
$this->line("商品订单上报处方平台失败:失败原因" . $e->getMessage());
|
||||
$this->line("上报失败:失败原因" . $e->getMessage());
|
||||
}
|
||||
|
||||
// 清空缓存
|
||||
@@ -139,6 +144,7 @@ class ReportPreProductOrderCommand extends HyperfCommand
|
||||
|
||||
$fields = [
|
||||
'order_product_id',
|
||||
'patient_id',
|
||||
];
|
||||
|
||||
$order_product = OrderProduct::getList($params,$fields);
|
||||
@@ -202,4 +208,22 @@ class ReportPreProductOrderCommand extends HyperfCommand
|
||||
$data['cancel_remarks'] = $cancel_remarks; // 订单取消备注(自动添加)
|
||||
OrderProduct::edit($params,$data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者用户id
|
||||
* @param string $patient_id
|
||||
* @return string
|
||||
*/
|
||||
protected function getPatientUserId(string $patient_id): string
|
||||
{
|
||||
// 获取患者数据
|
||||
$params = array();
|
||||
$params['patient_id'] = $patient_id;
|
||||
$user_patient = UserPatient::getOne($params);
|
||||
if (empty($user_patient)){
|
||||
return "";
|
||||
}
|
||||
|
||||
return $user_patient['user_id'];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user