From fe369784f8c97869d25ca0c787d8dd87a0bfb238 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Mon, 3 Apr 2023 13:15:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=94=AF=E4=BB=98=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E4=B8=BA0=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/OrderPrescriptionService.php | 2 +- app/Services/PatientOrderService.php | 42 ++++++++++++++--------- app/Services/UserDoctorService.php | 8 +++-- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/app/Services/OrderPrescriptionService.php b/app/Services/OrderPrescriptionService.php index f37389e..1302afa 100644 --- a/app/Services/OrderPrescriptionService.php +++ b/app/Services/OrderPrescriptionService.php @@ -145,7 +145,7 @@ class OrderPrescriptionService extends BaseService $user_entity_id = "491925054435950592"; } else{ $user_pharmacist_info = UserPharmacistInfo::getOne($params); - if (!empty($user_pharmacist_info)){ + if (empty($user_pharmacist_info)){ throw new BusinessException("用户数据错误"); } diff --git a/app/Services/PatientOrderService.php b/app/Services/PatientOrderService.php index d5ab127..934cc9a 100644 --- a/app/Services/PatientOrderService.php +++ b/app/Services/PatientOrderService.php @@ -659,17 +659,22 @@ class PatientOrderService extends BaseService $result['payment_amount_total'] = $order_inquiry['payment_amount_total']; // 实际订单金额 $result['coupon_amount_total'] = $order_inquiry['coupon_amount_total'];; // 优惠金额 - // 发起支付 - $WechatPay = new WechatPay(1,1); + if ($order_inquiry['payment_amount_total'] > 0){ + // 发起支付 + $WechatPay = new WechatPay(1,1); - // 获取预支付交易会话标识 - $prepay = $WechatPay->getJsapiPrepayId($order_no, $order_inquiry['payment_amount_total'] * 100, $user_info['open_id']); - if (empty($prepay)) { - return fail(HttpEnumCode::SERVER_ERROR); + // 获取预支付交易会话标识 + $prepay = $WechatPay->getJsapiPrepayId($order_no, $order_inquiry['payment_amount_total'] * 100, $user_info['open_id']); + if (empty($prepay)) { + return fail(HttpEnumCode::SERVER_ERROR); + } + + // 获取小程序支付配置 + $pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']); } - // 获取小程序支付配置 - $result['pay_config'] = $WechatPay->getAppletsPayConfig($prepay['prepay_id']); + + } elseif ($order_type == 2) { // 药品订单 $params = array(); @@ -704,21 +709,26 @@ class PatientOrderService extends BaseService $result['payment_amount_total'] = $order_product['payment_amount_total']; // 实际订单金额 $result['coupon_amount_total'] = 0; // 优惠金额 - // 发起支付 - $WechatPay = new WechatPay(1,2); + if ($order_product['payment_amount_total'] > 0 ){ + // 发起支付 + $WechatPay = new WechatPay(1,2); - // 获取预支付交易会话标识 - $prepay = $WechatPay->getJsapiPrepayId($order_no, $order_product['payment_amount_total'] * 100, $user_info['open_id']); - if (empty($prepay)) { - return fail(HttpEnumCode::SERVER_ERROR); + // 获取预支付交易会话标识 + $prepay = $WechatPay->getJsapiPrepayId($order_no, $order_product['payment_amount_total'] * 100, $user_info['open_id']); + if (empty($prepay)) { + return fail(HttpEnumCode::SERVER_ERROR); + } + + // 获取小程序支付配置 + $pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']); } - // 获取小程序支付配置 - $result['pay_config'] = $WechatPay->getAppletsPayConfig($prepay['prepay_id']); } else { return fail(); } + $result['pay_config'] = $pay_config ?? []; + return success($result); } diff --git a/app/Services/UserDoctorService.php b/app/Services/UserDoctorService.php index 77e0bd6..622fc1b 100644 --- a/app/Services/UserDoctorService.php +++ b/app/Services/UserDoctorService.php @@ -1078,6 +1078,7 @@ class UserDoctorService extends BaseService OrderPrescriptionProduct::deleteOrderPrescriptionProduct($params); // 处方商品数据 + $product_name = ""; foreach ($prescription_product as $item) { // 获取商品数据 $params = array(); @@ -1121,6 +1122,7 @@ class UserDoctorService extends BaseService return fail(); } + $product_name = $product_name . ";" . $product['product_name']; unset($product); } @@ -1160,7 +1162,7 @@ class UserDoctorService extends BaseService $message_content_data['desc'] = ""; $message_content_data['data']['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id']; $message_content_data['data']['order_prescription_id'] = (string)$order_prescription['order_prescription_id']; - $message_content_data['data']['product_name'] = $product_name ?? "药品"; + $message_content_data['data']['product_name'] = $product_name ?: "药品"; $message_content_data['data']['pharmacist_verify_time'] = date('Y-m-d H:i:s',time());; $message_content = [ 'Data' => json_encode($message_content_data,JSON_UNESCAPED_UNICODE), @@ -1300,6 +1302,7 @@ class UserDoctorService extends BaseService } // 商品数据 + $product_name = ""; foreach ($prescription_product as $item) { // 获取商品数据 $params =array(); @@ -1350,6 +1353,7 @@ class UserDoctorService extends BaseService return fail(); } + $product_name = $product_name . ";" . $product['product_name']; unset($product); } @@ -1390,7 +1394,7 @@ class UserDoctorService extends BaseService $message_content_data['desc'] = ""; $message_content_data['data']['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id']; $message_content_data['data']['order_prescription_id'] = (string)$order_prescription['order_prescription_id']; - $message_content_data['data']['product_name'] = $product_name ?? "药品"; + $message_content_data['data']['product_name'] = $product_name ?: "药品"; $message_content_data['data']['pharmacist_verify_time'] = date('Y-m-d H:i:s',time());; $message_content = [ 'Data' => json_encode($message_content_data,JSON_UNESCAPED_UNICODE),