From 5132a5775282db4ff447b8f194f09c9da7d0305c Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Wed, 22 Feb 2023 15:14:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8C=BB=E7=94=9F=E8=B4=A6?= =?UTF-8?q?=E6=88=B7=E6=A8=A1=E5=9E=8B=EF=BC=8C=E4=BF=AE=E6=94=B9=E7=9C=81?= =?UTF-8?q?=E5=B8=82=E5=8C=BA=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/UserDoctorController.php | 11 +++++ app/Model/DoctorAccount.php | 64 +++++++++++++++++++++++++ app/Model/OrderInquiry.php | 14 +++++- app/Services/AreaService.php | 6 ++- app/Services/OrderInquiryService.php | 2 +- app/Services/UserDoctorService.php | 62 ++++++++++++++++++++++++ config/routes.php | 6 +++ 7 files changed, 161 insertions(+), 4 deletions(-) create mode 100644 app/Model/DoctorAccount.php diff --git a/app/Controller/UserDoctorController.php b/app/Controller/UserDoctorController.php index 7b758c3..221a725 100644 --- a/app/Controller/UserDoctorController.php +++ b/app/Controller/UserDoctorController.php @@ -142,4 +142,15 @@ class UserDoctorController extends AbstractController $data = $UserDoctorService->getPrescriptionList(); return $this->response->json($data); } + + /** + * 获取医生个人中心数据 + * @return ResponseInterface + */ + public function getDoctorCenter(): ResponseInterface + { + $UserDoctorService = new UserDoctorService(); + $data = $UserDoctorService->getDoctorCenter(); + return $this->response->json($data); + } } \ No newline at end of file diff --git a/app/Model/DoctorAccount.php b/app/Model/DoctorAccount.php new file mode 100644 index 0000000..4081b52 --- /dev/null +++ b/app/Model/DoctorAccount.php @@ -0,0 +1,64 @@ + 'integer', 'doctor_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime']; + + protected string $primaryKey = "account_id"; + + /** + * 获取信息-单条 + * @param array $params + * @param array $fields + * @return object|null + */ + public static function getOne(array $params, array $fields = ['*']): object|null + { + return self::where($params)->first($fields); + } + + /** + * 获取信息-多条 + * @param array $params + * @param array $fields + * @return object|null + */ + public static function getList(array $params, array $fields = ['*']): object|null + { + return self::where($params)->get($fields); + } +} diff --git a/app/Model/OrderInquiry.php b/app/Model/OrderInquiry.php index 1e97ac8..b0d7be8 100644 --- a/app/Model/OrderInquiry.php +++ b/app/Model/OrderInquiry.php @@ -77,7 +77,7 @@ class OrderInquiry extends Model * @param array $data 新增数据 * @return \Hyperf\Database\Model\Model|OrderInquiry */ - public static function addUserDoctor(array $data): \Hyperf\Database\Model\Model|OrderInquiry + public static function addOrderInquiry(array $data): \Hyperf\Database\Model\Model|OrderInquiry { return self::create($data); } @@ -102,4 +102,16 @@ class OrderInquiry extends Model { return self::where($params)->count(); } + + /** + * 获取医生某天预计收益 + * @param array $params + * @return int|mixed|string + */ + public static function getDoctorOneDayEstimateIncome(array $params): mixed + { + return self::where($params) + ->whereIn('inquiry_status',[4,5,6]) + ->sum("amount_total"); + } } diff --git a/app/Services/AreaService.php b/app/Services/AreaService.php index 85629f9..b24dbcc 100644 --- a/app/Services/AreaService.php +++ b/app/Services/AreaService.php @@ -113,7 +113,8 @@ class AreaService extends BaseService public function getCity(): array { $area_id = $this->request->input('area_id'); - return $this->getAreaByParentId($area_id); + $city = $this->getAreaByParentId($area_id); + return success($city); } /** @@ -123,7 +124,8 @@ class AreaService extends BaseService public function getCounty(): array { $area_id = $this->request->input('area_id'); - return $this->getAreaByParentId($area_id); + $county = $this->getAreaByParentId($area_id); + return success($county); } /** diff --git a/app/Services/OrderInquiryService.php b/app/Services/OrderInquiryService.php index 478b84a..ceaf728 100644 --- a/app/Services/OrderInquiryService.php +++ b/app/Services/OrderInquiryService.php @@ -185,7 +185,7 @@ class OrderInquiryService extends BaseService $data['patient_name_mask'] = $patient_family['card_name_mask'];// 患者姓名-就诊人(掩码) $data['patient_sex'] = $patient_family['sex'];// 患者性别-就诊人(0:未知 1:男 2:女) $data['patient_age'] = $patient_family['age'];// 患者年龄-就诊人 - $order_inquiry = OrderInquiry::addUserDoctor($data); + $order_inquiry = OrderInquiry::addOrderInquiry($data); if (empty($order_inquiry)){ return fail(HttpEnumCode::SERVER_ERROR,"订单创建失败"); } diff --git a/app/Services/UserDoctorService.php b/app/Services/UserDoctorService.php index c86e816..8f56803 100644 --- a/app/Services/UserDoctorService.php +++ b/app/Services/UserDoctorService.php @@ -7,6 +7,7 @@ use App\Exception\BusinessException; use App\Model\BasicBank; use App\Model\DiseaseClassExpertise; use App\Model\DiseaseClassIcd; +use App\Model\DoctorAccount; use App\Model\DoctorBankCard; use App\Model\DoctorExpertise; use App\Model\DoctorInquiryConfig; @@ -452,4 +453,65 @@ class UserDoctorService extends BaseService return success($order_prescriptions); } + + // 获取医生个人中心数据 + public function getDoctorCenter(){ + $user_info = $this->request->getAttribute("userInfo") ?? []; + + // 获取医生信息 + $params = array(); + $params['doctor_id'] = $user_info['client_user_id']; + + $fields = [ + 'doctor_id', + 'user_name', + 'iden_auth_status', + 'idcard_status', + 'multi_point_status', + 'avatar', + ]; + $user_doctor = UserDoctor::getOne($params, $fields); + if (empty($user_doctor)) { + return fail(HttpEnumCode::HTTP_ERROR, "非法医生"); + } + + if ($user_doctor['iden_auth_status'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先完成身份认证"); + } + + if ($user_doctor['idcard_status'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先完成实名认证"); + } + + if ($user_doctor['multi_point_status'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先完成多点执业认证"); + } + + // 获取账户余额 + $params = array(); + $params['doctor_id'] = $user_info['client_user_id']; + $doctor_account = DoctorAccount::getOne($params); + if (!empty($doctor_account)){ + $balance_account = $doctor_account['balance_account']; + } + + // 获取当日预计收益 当日接诊的订单金额*0.75 + + + } + + // 获取医生某天预计收益 + // 当日接诊的订单金额*0.75 + protected function getDoctorOneDayEstimateIncome(string $doctor_id,string $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:已结算) + $params[] = ['reception_time','>' ,$date]; // 接诊时间(已接诊) + + + + } } \ No newline at end of file diff --git a/config/routes.php b/config/routes.php index 30f9162..09b18f0 100644 --- a/config/routes.php +++ b/config/routes.php @@ -91,6 +91,12 @@ Router::addGroup('/doctor', function () { Router::put('/{bank_card_id:\d+}', [UserDoctorController::class, 'putDoctorBankCard']); }); + // 个人中心 + Router::addGroup('/center', function () { + // 获取医生个人中心数据 + Router::get('', [UserDoctorController::class, 'getDoctorCenter']); + }); + // 处方 Router::addGroup('/prescription', function () { // 获取处方列表