From ebf34e28e7d5a23ea30cbaf043c37114dfd0d3f5 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Thu, 23 Feb 2023 09:54:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=88=91=E7=9A=84=E8=B4=A6?= =?UTF-8?q?=E6=88=B7=E6=97=A5=E8=B4=A6=E5=8D=95=E6=98=8E=E7=BB=86=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/DoctorAccountController.php | 18 ++++- app/Model/OrderInquiry.php | 22 ++++-- app/Request/DoctorAccountRequest.php | 5 +- app/Services/DoctorAccountService.php | 78 +++++++++++++++++++--- app/Services/PatientDoctorService.php | 2 +- app/Services/UserDoctorService.php | 33 --------- config/routes.php | 15 +++-- 7 files changed, 117 insertions(+), 56 deletions(-) diff --git a/app/Controller/DoctorAccountController.php b/app/Controller/DoctorAccountController.php index e9cfd33..35b40c7 100644 --- a/app/Controller/DoctorAccountController.php +++ b/app/Controller/DoctorAccountController.php @@ -15,7 +15,7 @@ use Psr\Http\Message\ResponseInterface; class DoctorAccountController extends AbstractController { /** - * 获取医生我的账户数据 + * 获取我的账户数据 * @return ResponseInterface * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface @@ -29,4 +29,20 @@ class DoctorAccountController extends AbstractController $data = $DoctorAccountService->getDoctorAccount(); return $this->response->json($data); } + + /** + * 获取我的账户日账单明细数据 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function getDoctorAccountInfo(): ResponseInterface + { + $request = $this->container->get(DoctorAccountRequest::class); + $request->scene('getDoctorAccountInfo')->validateResolved(); + + $DoctorAccountService = new DoctorAccountService(); + $data = $DoctorAccountService->getDoctorAccountInfo(); + return $this->response->json($data); + } } \ No newline at end of file diff --git a/app/Model/OrderInquiry.php b/app/Model/OrderInquiry.php index 199c050..c42835d 100644 --- a/app/Model/OrderInquiry.php +++ b/app/Model/OrderInquiry.php @@ -104,17 +104,29 @@ class OrderInquiry extends Model } /** - * 获取医生某天预计收益 + * 获取医生接诊列表 * 已完成-已结束 * @param array $params - * @param array $reception_time 接诊时间区间 + * @param array $reception_time 接诊时间区间 ['2023-01-02','2023-01-03'] + * @param array $fields + * @param int|null $page + * @param int|null $per_page * @return int|mixed|string */ - public static function getDoctorOneDayAmountTotal(array $params, array $reception_time): mixed + public static function getDoctorAccountInfoPage(array $params, array $reception_time,array $fields = ["*"], int $page = null, ?int $per_page = 10): mixed { - return self::where($params) + $raw = self::where($params) ->whereIn('inquiry_status',[5,6]) ->whereBetween('reception_time',$reception_time) - ->sum("amount_total"); + ->paginate($per_page, $fields, "page", $page); + + $data = array(); + $data['current_page'] = $raw->currentPage();// 当前页码 + $data['total'] = $raw->total();//数据总数 + $data['data'] = $raw->items();//数据 + $data['per_page'] = $raw->perPage();//每页个数 + $data['last_page'] = $raw->lastPage();//最后一页 + + return $data; } } diff --git a/app/Request/DoctorAccountRequest.php b/app/Request/DoctorAccountRequest.php index 0267529..41bffe4 100644 --- a/app/Request/DoctorAccountRequest.php +++ b/app/Request/DoctorAccountRequest.php @@ -10,7 +10,10 @@ use Hyperf\Validation\Request\FormRequest; class DoctorAccountRequest extends FormRequest { protected array $scenes = [ - 'getInquiryConfig' => [ // 获取医生问诊配置 + 'getInquiryConfig' => [ // 获取我的账户数据 + 'date', + ], + 'getDoctorAccountInfo' => [ // 获取我的账户日账单明细数据 'date', ], ]; diff --git a/app/Services/DoctorAccountService.php b/app/Services/DoctorAccountService.php index 7cbba95..5f68606 100644 --- a/app/Services/DoctorAccountService.php +++ b/app/Services/DoctorAccountService.php @@ -5,6 +5,7 @@ namespace App\Services; use App\Model\DoctorAccount; use App\Model\DoctorAccountDay; use App\Model\DoctorAccountMonth; +use App\Model\OrderInquiry; /** * 医生账户 @@ -12,7 +13,7 @@ use App\Model\DoctorAccountMonth; class DoctorAccountService extends BaseService { /** - * 获取医生账户数据 + * 获取我的账户数据 * @return array */ public function getDoctorAccount(): array @@ -41,9 +42,13 @@ class DoctorAccountService extends BaseService $withdrawal_amount_month = $doctor_account_month['withdrawal_amount'] ?: 0; } - // 获取医生每日数据 + // 获取医生每日账单数据 + $bill = []; + $fields = [ - 'total_amount_day' + 'total_amount_day', + 'month', + 'day', ]; $params = array(); @@ -51,17 +56,19 @@ class DoctorAccountService extends BaseService $params['year'] = date('Y',strtotime($date)); $params['month'] = date('m',strtotime($date)); $doctor_account_days = DoctorAccountDay::getList($params,$fields); - if (empty($doctor_account_days)){ - $bill = []; - }else{ - foreach ($doctor_account_days as &$doctor_account_day){ - $doctor_account_day['total_amount_day'] = $doctor_account_day['total_amount_day'] * 0.75; + if (!empty($doctor_account_days)){ + foreach ($doctor_account_days as $doctor_account_day){ + $data = array(); + $data['total_amount_day'] = $doctor_account_day['total_amount_day'] * 0.75; + $data['month'] = $doctor_account_day['month']; + $data['day'] = $doctor_account_day['day']; + $bill[] = $data; } - $bill = $doctor_account_days; + unset($doctor_account_days); } $result = array(); - $result['balance_account'] = $balance_account; // 获取医生账户余额-未提现金额 + $result['balance_account'] = $balance_account; // 账户余额 $result['amount_total_month'] = $amount_total_month * 0.75; // 月预计收益 $result['withdrawal_amount_month'] = $withdrawal_amount_month; // 月已提现金额 $result['bill'] = $bill; // 账单 @@ -69,6 +76,57 @@ class DoctorAccountService extends BaseService return success($result); } + /** + * 获取我的账户日账单明细数据 + * @return array + */ + public function getDoctorAccountInfo(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $date = $this->request->input('date'); + $page = $this->request->input('page', 1); + $per_page = $this->request->input('per_page', 10); + + // 获取当天开始时间 + $start_date = date('Y-m-d 00:00:00',strtotime($date)); + + // 获取当天结束时间 + $end_date = date('Y-m-d 23:59:59',strtotime($date)); + + $reception_time = [$start_date,$end_date]; + + // 获取医生当日接诊订单金额 + $fields = [ + 'order_inquiry_id', + 'inquiry_type', + 'inquiry_mode', + 'inquiry_status', + 'inquiry_refund_status', + 'inquiry_no', + 'amount_total', + 'payment_amount_total', + 'reception_time', + 'patient_name', + 'patient_sex', + 'patient_age', + ]; + + $params = array(); + $params['doctor_id'] = $user_info['client_user_id']; + $params['inquiry_refund_status'] = 0; // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭) + $params['inquiry_pay_status'] = 2; // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款) + + $order_inquiry = OrderInquiry::getDoctorAccountInfoPage($params,$reception_time,$fields); + if (!empty($order_inquiry['data'])){ + foreach ($order_inquiry['data'] as &$item){ + $item['estimate_income'] = $item['amount_total'] * 0.75; + } + } + + return success($order_inquiry); + } + /** * 获取医生账户余额 * @param string $doctor_id diff --git a/app/Services/PatientDoctorService.php b/app/Services/PatientDoctorService.php index 03ddb16..714db59 100644 --- a/app/Services/PatientDoctorService.php +++ b/app/Services/PatientDoctorService.php @@ -307,7 +307,7 @@ class PatientDoctorService extends BaseService } } - return $order_evaluation; + return success($order_evaluation); } /** diff --git a/app/Services/UserDoctorService.php b/app/Services/UserDoctorService.php index 8c229c2..b69c987 100644 --- a/app/Services/UserDoctorService.php +++ b/app/Services/UserDoctorService.php @@ -505,37 +505,4 @@ class UserDoctorService extends BaseService return success($user_doctor); } - - /** - * 获取医生某天预计收益 - * 当日完成的订单金额*0.75 - * @param string $doctor_id - * @param string $date - * @return float - */ - public function getDoctorOneDayAmountTotal(string $doctor_id,string $date): float - { - // 获取当天开始时间 - $start_date = date('Y-m-d 00:00:00',strtotime($date)); - - // 获取当天结束时间 - $end_date = date('Y-m-d 23:59:59',strtotime($date)); - - // 获取医生当日接诊订单金额 - $params = array(); - $params['doctor_id'] = $doctor_id; - $params['inquiry_refund_status'] = 0; // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭) - $params['inquiry_pay_status'] = 2; // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款) - $params['settlement_status'] = 0; // 订单与医生结算状态(0:未结算 1:已结算) - - $reception_time = [$start_date,$end_date]; - - $amount_total_sum = OrderInquiry::getDoctorOneDayAmountTotal($params,$reception_time); - - if (!empty($amount_total_sum)){ - $amount_total_sum = $amount_total_sum * 0.75; - } - - return $amount_total_sum ?: 0; - } } \ No newline at end of file diff --git a/config/routes.php b/config/routes.php index 1908255..5ff0cbf 100644 --- a/config/routes.php +++ b/config/routes.php @@ -97,11 +97,16 @@ Router::addGroup('/doctor', function () { // 获取医生个人中心数据 Router::get('', [UserDoctorController::class, 'getDoctorCenter']); - // 医生我的账户 - Router::addGroup('/account', function () { - // 获取医生我的账户数据 - Router::get('', [DoctorAccountController::class, 'getDoctorAccount']); - }); + + }); + + // 我的账户 + Router::addGroup('/account', function () { + // 获取我的账户数据 + Router::get('', [DoctorAccountController::class, 'getDoctorAccount']); + + // 获取我的账户日账单明细数据 + Router::get('/info', [DoctorAccountController::class, 'getDoctorAccountInfo']); }); // 处方