新增药品订单支付回调

This commit is contained in:
2023-03-14 15:52:22 +08:00
parent 54214fb5e9
commit 2a4b4f41fa
10 changed files with 357 additions and 65 deletions
+25 -23
View File
@@ -622,6 +622,18 @@ class PatientOrderService extends BaseService
$payment_amount_total = $order_inquiry['payment_amount_total'];
$coupon_amount_total = $order_inquiry['coupon_amount_total'];
// 发起支付
$WechatPay = new WechatPay(1,1);
// 获取预支付交易会话标识
$prepay = $WechatPay->getJsapiPrepayId($order_no, $payment_amount_total * 100, $user_info['open_id']);
if (empty($prepay)) {
return fail(HttpEnumCode::SERVER_ERROR);
}
// 获取小程序支付配置
$pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']);
} elseif ($order_type == 2) {
// 药品订单
$params = array();
@@ -650,22 +662,22 @@ class PatientOrderService extends BaseService
$amount_total = $order_product['amount_total'];
$payment_amount_total = $order_product['payment_amount_total'];
$coupon_amount_total = 0;
// 发起支付
$WechatPay = new WechatPay(1,2);
// 获取预支付交易会话标识
$prepay = $WechatPay->getJsapiPrepayId($order_no, $payment_amount_total * 100, $user_info['open_id']);
if (empty($prepay)) {
return fail(HttpEnumCode::SERVER_ERROR);
}
// 获取小程序支付配置
$pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']);
} else {
return fail();
}
// 发起支付
$WechatPay = new WechatPay(1);
// 获取预支付交易会话标识
$prepay = $WechatPay->getJsapiPrepayId($order_no, $payment_amount_total * 100, $user_info['open_id']);
if (empty($prepay)) {
return fail(HttpEnumCode::SERVER_ERROR);
}
// 获取小程序支付配置
$pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']);
$result = array();
$result['amount_total'] = $amount_total; // 订单金额
$result['payment_amount_total'] = $payment_amount_total; // 实际订单金额
@@ -715,16 +727,6 @@ class PatientOrderService extends BaseService
return fail(HttpEnumCode::HTTP_ERROR, "处方未审核");
}
// 检测是否已经存在药品订单数据
$params = array();
$params['order_inquiry_id'] = $order_prescription['order_inquiry_id'];
$params['order_prescription_id'] = $order_prescription['order_prescription_id'];
$params['patient_id'] = $user_info['client_user_id'];
$order_product = OrderProduct::getExists($params);
if ($order_product) {
return fail(HttpEnumCode::HTTP_ERROR, "处方已使用");
}
// 检测收货地址
$params = array();
$params['user_id'] = $user_info['user_id'];
@@ -890,7 +892,7 @@ class PatientOrderService extends BaseService
$data['order_type'] = 2;
$message = new CancelUnpayOrdersDelayDirectProducer($data);
$message->setDelayMs(1000 * 30 * 1);
$message->setDelayMs(1000 * 60 * 30);
$producer = $this->container->get(Producer::class);
$res = $producer->produce($message);
if (!$res) {