fix: 修复挂号,缴费接口相关BUG

master
Rmiku 2 weeks ago
parent 90a80a5767
commit ecf9758d64
  1. 1
      .gitignore
  2. 9
      app/Http/Controllers/Outpatient/PaymentController.php
  3. 2
      app/Http/Controllers/Registration/RegisterController.php
  4. 6
      app/Http/Logics/Notify/NotifyLogic.php
  5. 81
      app/Http/Logics/Outpatient/PaymentLogic.php
  6. 2
      app/Http/Logics/Registration/RecordLogic.php
  7. 18
      app/Http/Logics/Registration/RegisterLogic.php
  8. 62
      app/Models/Order.php
  9. 4
      app/Utils/Transfer/HisHttpClient/ClientMockHttpTransfer.php
  10. 13
      bootstrap/app.php
  11. 3
      bootstrap/providers.php
  12. 113
      config/unify.php
  13. 14
      packagist/unify_payment/src/Factory.php
  14. 6
      packagist/unify_payment/src/UnifyServiceProvider.php
  15. 2
      routes/api.php

1
.gitignore vendored

@ -9,6 +9,7 @@
.env
.env.backup
.env.production
.env.example
.phpactor.json
.phpunit.result.cache
Homestead.json

@ -26,22 +26,19 @@ class PaymentController
* 缴费
* @param Request $request
* @param string $patient_id
* @param string $serial_no
* @return JsonResponse
* @throws GeneralException
*/
public function payment(Request $request, string $patient_id, string $serial_no): JsonResponse
public function payment(Request $request, string $patient_id): JsonResponse
{
$validated = $request->validate([
'prescription_ids' => 'required',
'reg_id' => 'required',
], [
'prescription_ids.required' => '请选择要缴纳的处方',
'reg_id.required' => '请选择要缴纳的处方',
]);
$response = $this->payment_logic->payment($patient_id, $serial_no, $validated['prescription_ids'], $validated['reg_id']);
$response = $this->payment_logic->payment($patient_id, $validated['prescription_ids']);
return jsonResponse(Response::HTTP_OK, 'success', PendingListsResource::make($response)->toArray());
return jsonResponse(Response::HTTP_OK, 'success', $response);
}
}

@ -36,6 +36,6 @@ class RegisterController
$response = $this->register_logic->register($patient_id, $validated['date'], $validated['dept_id'], $validated['doctor_id'], $validated['reg_id']);
return jsonResponse(Response::HTTP_OK, 'success', RecordListsResource::make($response)->toArray());
return jsonResponse(Response::HTTP_OK, 'success', $response);
}
}

@ -24,6 +24,8 @@ use Exception;
use ReflectionException;
use UnifyPayment\Cores\Struct\ConfirmOrderForEx;
use UnifyPayment\Cores\Struct\RefundOrder;
use UnifyPayment\Mock\ConfirmOrderForExHandler;
use UnifyPayment\Mock\RefundOrderHandler;
use UnifyPayment\Unify;
class NotifyLogic
@ -228,7 +230,7 @@ class NotifyLogic
{
try {
$refund = new RefundOrder($order_id, $refund_order_id, (string)($refund_fee / 100), '确认挂号失败,自动冲正,错误消息:'. $refund_reason);
$response = Unify::common(env('unify'))->order->refund($refund);
$response = Unify::common(config('unify'))->order->setMockHandler([new RefundOrderHandler(true)])->refund($refund);
$this->info('退号退费结果', $response);
if ($response['status'] === 200 || $response['success'] === true) {
@ -320,7 +322,7 @@ class NotifyLogic
{
try {
$confirm_order = new ConfirmOrderForEx($order_id, $his_serial_no, $pay_account, $tran_no);
$response = Unify::common(env('unify'))->order->confirmForEx($confirm_order);
$response = Unify::common(config('unify'))->order->setMockHandler([new ConfirmOrderForExHandler(true)])->confirmForEx($confirm_order);
$this->info('支付平台确认结果', $response);
if ($response['status'] === 200 || $response['success'] === true) {

@ -9,6 +9,7 @@ use App\Dictionary\Order\Type;
use App\Dictionary\Patient\CardType;
use App\Exceptions\GeneralException;
use App\Models\Order;
use App\Models\Patient;
use App\Services\HisHttp\Client;
use App\Utils\Traits\Logger;
use App\Utils\Traits\MiniProgramAuth;
@ -18,6 +19,7 @@ use Symfony\Component\HttpFoundation\Response;
use UnifyPayment\Cores\Exceptions\InvalidConfigException;
use UnifyPayment\Cores\Exceptions\RuntimeException;
use UnifyPayment\Cores\Struct\CreateOrder;
use UnifyPayment\Mock\CreateOrderHandler;
use UnifyPayment\Unify;
class PaymentLogic
@ -29,6 +31,8 @@ class PaymentLogic
private Order $order_model;
private Patient $patient_model;
/**
* PaymentLogic Construct
* @throws AuthenticationException
@ -39,28 +43,27 @@ class PaymentLogic
$this->setChannel('outpatient');
$this->his_client = app('HisHttpService');
$this->order_model = new Order();
$this->patient_model = new Patient();
}
/**
* 支付
* @param string $patient_id
* @param string $serial_no
* @param string $prescription_ids
* @param string $reg_id
* @return array
* @throws GeneralException
*/
public function payment(string $patient_id, string $serial_no, string $prescription_ids, string $reg_id): array
public function payment(string $patient_id, string $prescription_ids): array
{
// 基础信息
$patient_info = $this->getPatientInfo($patient_id, $this->open_id);
$pending_info = $this->getPendingPrescriptionDetails($patient_id, $serial_no, $prescription_ids, $reg_id);
$pending_info = $this->getPendingPrescriptionDetails($patient_id, $prescription_ids);
// 创建订单
$order_type = Type::OUTPATIENT_PAYMENT;
$pay_type = PayType::WECHAT_PAY;
$order_id = $this->order_model->getOrderId($pay_type, 'M');
$total_fee = (float)(string) array_sum(array_column($pending_info['prescription_lists'], 'ZFJE'));
$total_fee = (float)(string) array_sum(array_column($pending_info, 'CFFYJE'));
$order = $this->createOrder($order_id, $pay_type, $total_fee, $order_type, $patient_info, $pending_info);
@ -95,21 +98,19 @@ class PaymentLogic
// 添加Patient 表ID
$patient_info['id'] = $info['id'];
$this->info('缴费患者信息', $info);
return $info;
$this->info('缴费患者信息', $patient_info);
return $patient_info;
}
/**
* 获取缴费处方详情
* @param string $patient_id
* @param string $serial_no
* @param string $prescription_ids
* @param string $reg_id
* @return array
* @
* @throws GeneralException
*/
protected function getPendingPrescriptionDetails(string $patient_id, string $serial_no, string $prescription_ids, string $reg_id): array
protected function getPendingPrescriptionDetails(string $patient_id, string $prescription_ids): array
{
$response = $this->his_client->getPendingLists($patient_id);
@ -120,36 +121,26 @@ class PaymentLogic
// 获取具体的缴费详情
$response = xmlArrayToListByKey($response, 'ITEM');
foreach ($response['ITEM'] as $v) {
if ($v['JZXH'] === $serial_no) {
$info = $v;
break;
if (str_contains($prescription_ids, $v['CFID'])) {
$lists[] = $v;
}
}
if (empty($info)) {
if (empty($lists)) {
throw new GeneralException('查询不到待缴费处方,请重新再试!', Response::HTTP_SERVICE_UNAVAILABLE);
}
$response = $this->his_client->getPendingDetails($prescription_ids, $serial_no, $reg_id);
if (!isset($response['RESULTCODE']) || $response['RESULTCODE'] !== '0') {
throw new GeneralException($response['ERRORMSG'] ?? '暂无相关缴费记录!', Response::HTTP_SERVICE_UNAVAILABLE);
}
// 获取具体的缴费详情
$response = xmlArrayToListByKey($response, 'ITEM');
foreach ($response['ITEM'] as $v) {
if (strpos($prescription_ids, $v['CFID'])) {
$info['prescription_lists'][] = $v;
break;
foreach ($lists as $k => $v) {
$response = $this->his_client->getPendingDetails($v['CFID'], $v['JZXH'], $v['REGID'] ?: '');
if (!isset($response['RESULTCODE']) || $response['RESULTCODE'] !== '0') {
throw new GeneralException($response['ERRORMSG'] ?? '暂无相关缴费记录!', Response::HTTP_SERVICE_UNAVAILABLE);
}
}
if (empty($info['prescription_lists'])) {
throw new GeneralException('查询不到待缴费处方详情,请重新再试!', Response::HTTP_SERVICE_UNAVAILABLE);
$response = xmlArrayToListByKey($response, 'ITEM');
$lists[$k]['prescription_lists'] = $response['ITEM'];
}
$info['prescription_ids'] = $prescription_ids;
return $info;
return $lists;
}
/**
@ -167,22 +158,26 @@ class PaymentLogic
{
// 挂号记录表
$pay_record_data = [
'relate_patient_id' => $patient_info['id'],
'dept_id' => $pending_info['BQDM'],
'dept_name' => $pending_info['BQMC'],
'doctor_id' => $pending_info['YSGH'],
'doctor_name' => $pending_info['YSMC'],
'visit_date' => date('Y-m-d', strtotime($pending_info['JZRQ'])),
'total_amount' => $total_fee,
'pre_settle_status' => 0,
'extra_info' => json_encode($pending_info, JSON_UNESCAPED_UNICODE),
];
$pay_record_data = [];
foreach ($pending_info as $v) {
$pay_record_data[] = [
'relate_patient_id' => $patient_info['id'],
'dept_id' => $v['BQDM'],
'dept_name' => $v['BQMC'],
'doctor_id' => $v['YSGH'],
'doctor_name' => $v['YSMC'],
'visit_date' => date('Y-m-d', strtotime($v['JZRQ'])),
'total_amount' => $total_fee,
'pre_settle_status' => 0,
'extra_info' => json_encode($v, JSON_UNESCAPED_UNICODE),
];
}
$order = $this->order_model->createOrder(
$order_id,
$pay_type,
$total_fee * 100,
0,
$this->open_id,
$patient_info['PATIENTID'],
$patient_info['NAME'],
@ -194,7 +189,7 @@ class PaymentLogic
throw new GeneralException('创建缴费单失败,请重新再试!');
}
$this->info('创建订单,ID:'. $order_id->id);
$this->info('创建订单,ID:'. $order->id);
return $order;
}
@ -222,7 +217,7 @@ class PaymentLogic
url('/Api/Notify', [], true)
);
$response = Unify::pay(env('unify'))->mini->jsapi($order_obj);
$response = Unify::pay(config('unify'))->mini->setMockHandler([new CreateOrderHandler(true)])->jsapi($order_obj);
$this->info('jsapi 支付参数', $response);
if (!$response['success'] || empty($response['response'])) {

@ -146,7 +146,7 @@ class RecordLogic
// 退款
try {
$refund_order_obj = new RefundOrder($order_id, $refund_order_id, $fee, '患者自行退号退费');
$response = Unify::common(env('unify'))->order->refund($refund_order_obj);
$response = Unify::common(config('unify'))->order->refund($refund_order_obj);
$this->info('退号退费结果', $response);
} catch (ReflectionException $e) {

@ -19,6 +19,7 @@ use Symfony\Component\HttpFoundation\Response;
use UnifyPayment\Cores\Exceptions\InvalidConfigException;
use UnifyPayment\Cores\Exceptions\RuntimeException;
use UnifyPayment\Cores\Struct\CreateOrder;
use UnifyPayment\Mock\CreateOrderHandler;
use UnifyPayment\Unify;
class RegisterLogic
@ -66,7 +67,7 @@ class RegisterLogic
$order_type = $date === date('Y-m-d') ? Type::TODAY_REGISTRATION : Type::APPOINTMENT_REGISTRATION;
$pay_type = PayType::WECHAT_PAY;
$order_id = $this->order_model->getOrderId($pay_type, 'M');
$reg_fee = (float)(string) $schedule_info['FEE'];
$reg_fee = (float)(string) $schedule_info['SHIFT']['FEE'];
$order = $this->createOrder($order_id, $pay_type, $reg_fee, $order_type, $patient_info, $schedule_info);
@ -101,8 +102,8 @@ class RegisterLogic
// 添加Patient 表ID
$patient_info['id'] = $info['id'];
$this->info('挂号患者信息', $info);
return $info;
$this->info('挂号患者信息', $patient_info);
return $patient_info;
}
/**
@ -129,7 +130,7 @@ class RegisterLogic
if ($v['DOCTID'] === $doctor_id) {
$v = xmlArrayToListByKey($v, 'SHIFT');
foreach ($v['SHIFT'] as $v2) {
if ($v2['REGID'] === $reg_id && $v['FDATE'] === $date) {
if ($v2['REGID'] === $reg_id && $v2['FDATE'] === $date) {
$v['SHIFT'] = $v2;
$info = $v;
}
@ -179,13 +180,13 @@ class RegisterLogic
// 挂号记录表
$reg_record_data = [
'relate_patient_id' => $patient_info['id'],
'reg_id' => $schedule_info,
'reg_id' => $schedule_info['SHIFT']['REGID'],
'dept_id' => $schedule_info['dept_id'],
'dept_name' => $schedule_info['dept_name'],
'dept_location' => $schedule_info['DEPLOCATION'],
'doctor_id' => $schedule_info['DOCTID'],
'doctor_name' => $schedule_info['DOCTNAME'],
'visit_date' => $schedule_info['SHIFT']['FDATE'],
'visit_date' => date('Y-m-d', strtotime($schedule_info['SHIFT']['FDATE'])),
'begin_time' => $schedule_info['SHIFT']['STARTTIME'],
'end_time' => $schedule_info['SHIFT']['ENDTIME'],
'lock_status' => 0,
@ -196,6 +197,7 @@ class RegisterLogic
$order_id,
$pay_type,
$reg_fee * 100,
0,
$this->open_id,
$patient_info['PATIENTID'],
$patient_info['NAME'],
@ -207,7 +209,7 @@ class RegisterLogic
throw new GeneralException('创建挂号单失败,请重新再试!');
}
$this->info('创建订单,ID:'. $order_id->id);
$this->info('创建订单,ID:'. $order->id);
return $order;
}
@ -235,7 +237,7 @@ class RegisterLogic
url('/Api/Notify', [], true)
);
$response = Unify::pay(env('unify'))->mini->jsapi($order_obj);
$response = Unify::pay(config('unify'))->mini->setMockHandler([new CreateOrderHandler(true)])->jsapi($order_obj);
$this->info('jsapi 支付参数', $response);
if (!$response['success'] || empty($response['response'])) {

@ -101,11 +101,11 @@ class Order extends Model
/**
* Relationships OutpatientPaymentRecord Model.
* @return HasOne
* @return hasMany
*/
public function outpatientPaymentRecord(): HasOne
public function outpatientPaymentRecord(): hasMany
{
return $this->hasOne(OutpatientPaymentRecord::class, 'relate_order_id');
return $this->hasMany(OutpatientPaymentRecord::class, 'relate_order_id');
}
/**
@ -165,16 +165,16 @@ class Order extends Model
* @param string $order_id
* @param PayType $pay_type
* @param float $fee
* @param float $reduce_fee
* @param string $open_id
* @param string $patient_id
* @param string $patient_name
* @param Type $order_type
* @param SourceId $source_id
* @param array $reg_info
* @param array $outpatient_info
* @param array $record_info
* @return mixed
*/
public function createOrder(string $order_id, PayType $pay_type, float $fee, string $open_id, string $patient_id, string $patient_name, Type $order_type, SourceId $source_id, array $reg_info = [], array $outpatient_info = []): mixed
public function createOrder(string $order_id, PayType $pay_type, float $fee, float $reduce_fee, string $open_id, string $patient_id, string $patient_name, Type $order_type, SourceId $source_id, array $record_info = []): mixed
{
$order_info = [
@ -188,7 +188,8 @@ class Order extends Model
'pay_type' => $pay_type,
'pay_mode' => PayMode::PAYMENT->value,
'fee' => $fee, //分
'self_fee' => $fee, //分
'reduce_fee' => $reduce_fee, //分
'self_fee' => $fee - $reduce_fee, //分
'refund_fee' => 0,
'open_id' => $open_id,
'patient_id' => $patient_id,
@ -204,14 +205,14 @@ class Order extends Model
])) {
$result = $this->create($order_info);
if (!empty($result)) {
if (!empty($result) && !empty($record_info)) {
switch ($order_type->value) {
case Type::TODAY_REGISTRATION->value:
case Type::APPOINTMENT_REGISTRATION->value:
$result->registrationRecord()->create($reg_info);
$result->registrationRecord()->create($record_info);
break;
case Type::OUTPATIENT_PAYMENT->value:
$result->outpatientPaymentRecord()->create($outpatient_info);
$result->outpatientPaymentRecord()->createMany($record_info);
break;
default:
break;
@ -250,6 +251,7 @@ class Order extends Model
'pay_type' => $pay_type,
'pay_mode' => PayMode::REFUND->value,
'fee' => $fee, //分
'reduce_fee' => 0, //分
'self_fee' => 0, //分
'refund_fee' => 0,
'open_id' => $open_id,
@ -286,11 +288,13 @@ class Order extends Model
$record->update(['extra_info' => json_encode($extra_info, JSON_UNESCAPED_UNICODE)]);
break;
case Type::OUTPATIENT_PAYMENT->value:
$record = $order->outpatientPaymentREcord;
$record = $order->outpatientPaymentRecord;
$extra_info = json_decode($record->extra_info, true);
$extra_info['confirm_response'] = $response;
$record->update(['extra_info' => json_encode($extra_info, JSON_UNESCAPED_UNICODE)]);
foreach ($record as $v) {
$v->update(['extra_info' => json_encode($extra_info, JSON_UNESCAPED_UNICODE)]);
}
break;
default:
break;
@ -378,38 +382,4 @@ class Order extends Model
$order->status = Status::FAILURE->value;
$order->save();
}
/**
* 操作订单冲正
* @param string $order_id
* @param int $order_type
* @param string $patient_id
* @param string $patient_name
* @param PayType $pay_type
* @param float $fee
* @param array $pay_params
* @param array $pay_res_data
* @return string
*/
public function handleOrderReverse(string $order_id, int $order_type, string $patient_id, string $patient_name, PayType $pay_type, float $fee, array $pay_params, array $pay_res_data)
{
$relate_order_info = $this->getOrderInfoByOrderId($order_id);
// 创建冲正订单
$r_order_id = $this->getRefundOrderId($order_id);
$this->createRefundOReverseOrder($relate_order_info['id'], $r_order_id, $pay_type, $fee * 100, $patient_id, $patient_name, $order_type);
// 退款
$refund_res = fastOrderRefund($pay_type, $order_id, $r_order_id, $fee, $pay_params, $pay_res_data);
$this->addLog('order reverse', '订单冲正', $refund_res);
// 冲正失败
if (!$refund_res[0]) {
$this->reverseOrderOpera($r_order_id, $fee, false);
return '冲正失败,失败原因:'. $refund_res[1]. ',请前往人工窗口进行退款!';
}
$this->reverseOrderOpera($r_order_id, $fee, true);
return '冲正成功,请稍后再行尝试!';
}
}

@ -134,8 +134,8 @@ class ClientMockHttpTransfer extends HttpTransferAbstract
*/
private function mockGetDoctorLists(array $params): self
{
$this->transfer_response = '<RESPONSE><RESULTCODE>0</RESULTCODE><ERRORMSG>Success</ERRORMSG><ITEM><DOCTID>10001</DOCTID><YBDOCTID>20001</YBDOCTID><DOCTNAME>张三</DOCTNAME><DEPLOCATION>内科一诊室</DEPLOCATION><TYPENAME>主任医师</TYPENAME><ISKSDOC>1</ISKSDOC><SHIFT><DOCTID>10001</DOCTID><REGID>30001</REGID><FDATE>2024-12-27</FDATE><RANKID>1</RANKID><RANKNAME>上午班</RANKNAME><STARTTIME>08:00</STARTTIME><ENDTIME>12:00</ENDTIME><FEE>50.00</FEE><FEECODE>001</FEECODE><REGCOUNT>20</REGCOUNT><JZCOUNT>15</JZCOUNT></SHIFT><SHIFT><DOCTID>10001</DOCTID><REGID>30002</REGID><FDATE>2024-12-28</FDATE><RANKID>2</RANKID><RANKNAME>下午班</RANKNAME><STARTTIME>14:00</STARTTIME><ENDTIME>18:00</ENDTIME><FEE>55.00</FEE><FEECODE>002</FEECODE><REGCOUNT>18</REGCOUNT><JZCOUNT>12</JZCOUNT></SHIFT><SHIFT><DOCTID>10001</DOCTID><REGID>30003</REGID><FDATE>2024-12-29</FDATE><RANKID>3</RANKID><RANKNAME>夜班</RANKNAME><STARTTIME>20:00</STARTTIME><ENDTIME>00:00</ENDTIME><FEE>60.00</FEE><FEECODE>003</FEECODE><REGCOUNT>10</REGCOUNT><JZCOUNT>8</JZCOUNT></SHIFT><XMBH>XM001</XMBH><GJMLBM>1234567890</GJMLBM><XMMC>挂号诊查费</XMMC><JG>50</JG><MCYL>10</MCYL><JE>500</JE></ITEM><ITEM><DOCTID>10002</DOCTID><YBDOCTID>20002</YBDOCTID><DOCTNAME>李四</DOCTNAME><DEPLOCATION>外科二诊室</DEPLOCATION><TYPENAME>副主任医师</TYPENAME><ISKSDOC>0</ISKSDOC><SHIFT><DOCTID>10002</DOCTID><REGID>30004</REGID><FDATE>2024-12-27</FDATE><RANKID>1</RANKID><RANKNAME>上午班</RANKNAME><STARTTIME>08:00</STARTTIME><ENDTIME>12:00</ENDTIME><FEE>60.00</FEE><FEECODE>004</FEECODE><REGCOUNT>25</REGCOUNT><JZCOUNT>20</JZCOUNT></SHIFT><SHIFT><DOCTID>10002</DOCTID><REGID>30005</REGID><FDATE>2024-12-28</FDATE><RANKID>2</RANKID><RANKNAME>下午班</RANKNAME><STARTTIME>14:00</STARTTIME><ENDTIME>18:00</ENDTIME><FEE>65.00</FEE><FEECODE>005</FEECODE><REGCOUNT>20</REGCOUNT><JZCOUNT>18</JZCOUNT></SHIFT><XMBH>XM002</XMBH><GJMLBM>0987654321</GJMLBM><XMMC>挂号诊查费</XMMC><JG>100</JG><MCYL>15</MCYL><JE>1500</JE></ITEM></RESPONSE>
';
$date = &$params['json']['date'];
$this->transfer_response = '<RESPONSE><RESULTCODE>0</RESULTCODE><ERRORMSG>Success</ERRORMSG><ITEM><DOCTID>10001</DOCTID><YBDOCTID>20001</YBDOCTID><DOCTNAME>张三</DOCTNAME><DEPLOCATION>内科一诊室</DEPLOCATION><TYPENAME>主任医师</TYPENAME><ISKSDOC>1</ISKSDOC><SHIFT><DOCTID>10001</DOCTID><REGID>30001</REGID><FDATE>'.$date.'</FDATE><RANKID>1</RANKID><RANKNAME>上午班</RANKNAME><STARTTIME>08:00</STARTTIME><ENDTIME>12:00</ENDTIME><FEE>50.00</FEE><FEECODE>001</FEECODE><REGCOUNT>20</REGCOUNT><JZCOUNT>15</JZCOUNT></SHIFT><SHIFT><DOCTID>10001</DOCTID><REGID>30002</REGID><FDATE>'.$date.'</FDATE><RANKID>2</RANKID><RANKNAME>下午班</RANKNAME><STARTTIME>14:00</STARTTIME><ENDTIME>18:00</ENDTIME><FEE>55.00</FEE><FEECODE>002</FEECODE><REGCOUNT>18</REGCOUNT><JZCOUNT>12</JZCOUNT></SHIFT><SHIFT><DOCTID>10001</DOCTID><REGID>30003</REGID><FDATE>'.$date.'</FDATE><RANKID>3</RANKID><RANKNAME>夜班</RANKNAME><STARTTIME>20:00</STARTTIME><ENDTIME>00:00</ENDTIME><FEE>60.00</FEE><FEECODE>003</FEECODE><REGCOUNT>10</REGCOUNT><JZCOUNT>8</JZCOUNT></SHIFT><XMBH>XM001</XMBH><GJMLBM>1234567890</GJMLBM><XMMC>挂号诊查费</XMMC><JG>50</JG><MCYL>10</MCYL><JE>500</JE></ITEM><ITEM><DOCTID>10002</DOCTID><YBDOCTID>20002</YBDOCTID><DOCTNAME>李四</DOCTNAME><DEPLOCATION>外科二诊室</DEPLOCATION><TYPENAME>副主任医师</TYPENAME><ISKSDOC>0</ISKSDOC><SHIFT><DOCTID>10002</DOCTID><REGID>30004</REGID><FDATE>'.$date.'</FDATE><RANKID>1</RANKID><RANKNAME>上午班</RANKNAME><STARTTIME>08:00</STARTTIME><ENDTIME>12:00</ENDTIME><FEE>60.00</FEE><FEECODE>004</FEECODE><REGCOUNT>25</REGCOUNT><JZCOUNT>20</JZCOUNT></SHIFT><SHIFT><DOCTID>10002</DOCTID><REGID>30005</REGID><FDATE>'.$date.'</FDATE><RANKID>2</RANKID><RANKNAME>下午班</RANKNAME><STARTTIME>14:00</STARTTIME><ENDTIME>18:00</ENDTIME><FEE>65.00</FEE><FEECODE>005</FEECODE><REGCOUNT>20</REGCOUNT><JZCOUNT>18</JZCOUNT></SHIFT><XMBH>XM002</XMBH><GJMLBM>0987654321</GJMLBM><XMMC>挂号诊查费</XMMC><JG>100</JG><MCYL>15</MCYL><JE>1500</JE></ITEM></RESPONSE>';
return $this;
}

@ -27,10 +27,13 @@ return Application::configure(basePath: dirname(__DIR__))
]);
})
->withExceptions(function (Exceptions $exceptions) {
$exceptions->dontReportDuplicates();
$exceptions->dontReport([
GeneralException::class,
]);
// Exception错误拦截
$exceptions->render(function (Exception $exception, Request $request) {
// 错误消息
$err_msg = $exception->getMessage();
@ -75,4 +78,14 @@ return Application::configure(basePath: dirname(__DIR__))
return jsonResponse(Response::HTTP_INTERNAL_SERVER_ERROR, $record_msg);
});
// Throwable错误拦截
$exceptions->render(function (Throwable $e, $request) {
// 错误消息
$err_msg = $e->getMessage();
$record_msg = $err_msg. ' in '. $e->getFile(). ':'. $e->getLine();
// 500 错误拦截
recordLog('AppError', $record_msg);
return jsonResponse(Response::HTTP_INTERNAL_SERVER_ERROR, $record_msg);
});
})->create();

@ -1,5 +1,6 @@
<?php
return [
App\Providers\AppServiceProvider::class
App\Providers\AppServiceProvider::class,
UnifyPayment\UnifyServiceProvider::class
];

@ -0,0 +1,113 @@
<?php
namespace UnifyPayment;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger;
return [
/*
|--------------------------------------------------------------------------
| Request Platform Config
|--------------------------------------------------------------------------
| domain:支付平台地址。
| apiSecret: 应用秘钥
|
*/
'domain' => 'http://fangding.picp.vip:5025',
'apiSecret' => '123456',
/*
|--------------------------------------------------------------------------
| Payment Channels Config
|--------------------------------------------------------------------------
|
| 统一支付平台支付渠道配置参数
| merchantId: 商户号
| secret: 秘钥
| channelId: 支付渠道
| operatorId: [ 操作员1 , 操作员2 ]
|
*/
'channels' => [
'default' => [
'merchantId' => 'QY2Y20230301',
'secret' => 'af4d32227ed4d63e1bb8726ebd0b6110',
'channelId' => 'FD001',
'operatorId' => [
'wx001',
],
]
],
/*
|--------------------------------------------------------------------------
| Logger Config
|--------------------------------------------------------------------------
|
| 详细使用方式见 MonoLog 文档:https://github.com/Seldaek/monolog/blob/2.x/README.md
| format:
| LineFormatter 字符串
| JsonFormatter Json
| ...
| handler:
| StreamHandler 单个文件
| RotatingFileHandler 每日记录一次
| RedisHandler Redis
| ...
| handler_with:
| RotatingFileHandler:
| file 文件名称
| max_files 最大记录日志文件数量,0为无限制
| level 日志记录等级
| OtherHandler详见MonoLog文档
| ...
|
*/
'log' => [
// 时区
'timezone' => 'Asia/Shanghai',
// 日期格式
'date_format' => 'Y-m-d H:i:s',
// 格式化器
'formatter' => LineFormatter::class,
// 对应格式化器构造参数
'formatter_with' => [
// 输出格式字符串
'output' => "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n\n"
],
// 处理器
'handler' => RotatingFileHandler::class,
// 对应处理器构造参数
'handler_with' => [
// 文件
'file' => storage_path('logs/UnifyLog/payment.log'),
// 最大文件 0 无限制
'max_files' => 0,
// 记录等级
'level' => Logger::DEBUG
]
],
/*
|--------------------------------------------------------------------------
| Http Client Config
|--------------------------------------------------------------------------
|
| 详细使用方式见 Guzzle 文档:https://guzzle-cn.readthedocs.io/zh_CN/latest/request-options.html
|
*/
'http' => [
'verify' => false,
'timeout' => 20,
'connect_timeout' => 5.0,
]
];

@ -26,6 +26,18 @@ class Factory
$this->registerLogService();
}
/**
* Dynamically pass methods to the application.
* @param string $name
* @param array $arguments
* @return mixed
* @throws ClassNotExistsException
*/
public function __call(string $name, array $arguments)
{
return $this->make($name);
}
/**
* Dynamically pass methods to the application.
*
@ -74,4 +86,4 @@ class Factory
Log::setInstance($logger);
}
}
}

@ -16,8 +16,8 @@ class UnifyServiceProvider extends ServiceProvider
public function boot(): void
{
$this->publishes([
__DIR__ . '/../config/unify.php.php' => config_path('unify.php'),
]);
__DIR__ . '/../config/unify.php' => config_path('unify.php'),
], 'config');
}
/**
@ -36,4 +36,4 @@ class UnifyServiceProvider extends ServiceProvider
return new Factory(config('unify'));
});
}
}
}

@ -45,7 +45,7 @@ Route::middleware(['apiLog'])->group(function() {
Route::prefix('Outpatient')->group(function () {
Route::get('/{patient_id}/pending', [PendingController::class, 'lists']);
Route::get('/{patient_id}/pending/{serial_no}/', [PendingController::class, 'details']);
Route::post('/{patient_id}/pending/{serial_no}/payment', [PaymentController::class, 'payment']);
Route::post('/{patient_id}/pending/payment', [PaymentController::class, 'payment']);
Route::get('/{patient_id}/record', [OutpatientRecordController::class, 'lists']);
Route::get('/{patient_id}/record/{serial_no}/', [OutpatientRecordController::class, 'details']);

Loading…
Cancel
Save