新增获取我的问诊、关注医生列表接口
This commit is contained in:
parent
80dbd4bf93
commit
707a0eb6fd
21
app/Controller/CallBackController.php
Normal file
21
app/Controller/CallBackController.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Services\BaseService;
|
||||
use App\Utils\Log;
|
||||
|
||||
class CallBackController extends BaseService
|
||||
{
|
||||
// 微信支付回调
|
||||
public function wxPayCallBack(){
|
||||
$request_params = $this->request->all();
|
||||
Log::getInstance()->info(json_encode($request_params,JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
// im回调
|
||||
public function imCallBack(){
|
||||
$request_params = $this->request->all();
|
||||
Log::getInstance()->info(json_encode($request_params,JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
@ -70,4 +70,20 @@ class PatientDoctorController extends AbstractController
|
||||
$data = $PatientDoctorService->getDoctorInquiryCheck();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的问诊、关注医生列表
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getDoctorList(): ResponseInterface
|
||||
{
|
||||
$request = $this->container->get(PatientDoctorRequest::class);
|
||||
$request->scene('getDoctorList')->validateResolved();
|
||||
|
||||
$PatientDoctorService = new PatientDoctorService();
|
||||
$data = $PatientDoctorService->getDoctorList();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Utils\Log;
|
||||
|
||||
/**
|
||||
* 支付
|
||||
*/
|
||||
class PayController extends AbstractController
|
||||
{
|
||||
// 微信支付回调
|
||||
public function wxCallBack(){
|
||||
$request_params = $this->request->all();
|
||||
Log::getInstance()->info(json_encode($request_params,JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,9 @@ namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Database\Model\Relations\HasMany;
|
||||
use Hyperf\Database\Model\Relations\HasOne;
|
||||
use Hyperf\Database\Model\Relations\HasOneThrough;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
@ -29,13 +32,41 @@ class PatientFollow extends Model
|
||||
*/
|
||||
protected array $fillable = ['patient_follow_id', 'patient_id', 'doctor_id', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*/
|
||||
protected array $casts = ['patient_follow_id' => 'integer', 'patient_id' => 'integer', 'doctor_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
|
||||
|
||||
protected string $primaryKey = "patient_follow_id";
|
||||
|
||||
/**
|
||||
* 关联医生专长表
|
||||
* @return HasMany
|
||||
*/
|
||||
public function DoctorExpertise(): HasMany
|
||||
{
|
||||
return $this->hasMany(DoctorExpertise::class, "doctor_id", "doctor_id");
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联医生表
|
||||
*/
|
||||
public function UserDoctor(): HasOne
|
||||
{
|
||||
return $this->hasOne(UserDoctor::class, 'doctor_id','doctor_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程关联医生表-医院表
|
||||
* @return HasOneThrough
|
||||
*/
|
||||
public function UserDoctorHospital(): HasOneThrough
|
||||
{
|
||||
return $this->hasOneThrough(
|
||||
Hospital::class,
|
||||
UserDoctor::class,
|
||||
"doctor_id",
|
||||
"hospital_id",
|
||||
"doctor_id",
|
||||
"hospital_id",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否存在
|
||||
* @param array $params
|
||||
@ -45,4 +76,33 @@ class PatientFollow extends Model
|
||||
{
|
||||
return self::where($params)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分页数据
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @param int|null $page
|
||||
* @param int|null $per_page
|
||||
* @return array
|
||||
*/
|
||||
public static function getPage(array $params,array $fields = ["*"], int $page = null, ?int $per_page = 10): array
|
||||
{
|
||||
$query = self::with([
|
||||
'DoctorExpertise:doctor_expertise_id,doctor_id,expertise_id',
|
||||
'DoctorExpertise.DiseaseClassExpertise:expertise_id,expertise_name',
|
||||
"UserDoctor:doctor_id,user_name,avatar,doctor_title,hospital_id,multi_point_status,department_custom_name,be_good_at",
|
||||
"UserDoctor.Hospital:hospital_id,hospital_name"
|
||||
])
|
||||
->where($params)
|
||||
->paginate($per_page, $fields, "page", $page);
|
||||
|
||||
$data = array();
|
||||
$data['current_page'] = $query->currentPage();// 当前页码
|
||||
$data['total'] = $query->total();//数据总数
|
||||
$data['data'] = $query->items();//数据
|
||||
$data['per_page'] = $query->perPage();//每页个数
|
||||
$data['last_page'] = $query->lastPage();//最后一页
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ namespace App\Model;
|
||||
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Database\Model\Relations\BelongsTo;
|
||||
use Hyperf\Database\Model\Relations\HasMany;
|
||||
use Hyperf\Database\Model\Relations\HasOne;
|
||||
use Hyperf\Database\Model\Relations\HasOneThrough;
|
||||
use Hyperf\DbConnection\Db;
|
||||
@ -70,6 +71,15 @@ class PatientHistoryInquiry extends Model
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联医生专长表
|
||||
* @return HasMany
|
||||
*/
|
||||
public function DoctorExpertise(): HasMany
|
||||
{
|
||||
return $this->hasMany(DoctorExpertise::class, "doctor_id", "doctor_id");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
@ -120,7 +130,6 @@ class PatientHistoryInquiry extends Model
|
||||
->where($params)
|
||||
->limit($limit)
|
||||
->get($fields);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,4 +159,34 @@ class PatientHistoryInquiry extends Model
|
||||
{
|
||||
return self::where($params)->update($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分页数据
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @param int|null $page
|
||||
* @param int|null $per_page
|
||||
* @return array
|
||||
*/
|
||||
public static function getPage(array $params,array $fields = ["*"], int $page = null, ?int $per_page = 10): array
|
||||
{
|
||||
$query = self::with([
|
||||
'DoctorExpertise:doctor_expertise_id,doctor_id,expertise_id',
|
||||
'DoctorExpertise.DiseaseClassExpertise:expertise_id,expertise_name',
|
||||
"UserDoctor:doctor_id,user_name,avatar,doctor_title,hospital_id,multi_point_status,department_custom_name,be_good_at",
|
||||
"UserDoctor.Hospital:hospital_id,hospital_name"
|
||||
])
|
||||
->where($params)
|
||||
->groupBy('doctor_id')
|
||||
->paginate($per_page, $fields, "page", $page);
|
||||
|
||||
$data = array();
|
||||
$data['current_page'] = $query->currentPage();// 当前页码
|
||||
$data['total'] = $query->total();//数据总数
|
||||
$data['data'] = $query->items();//数据
|
||||
$data['per_page'] = $query->perPage();//每页个数
|
||||
$data['last_page'] = $query->lastPage();//最后一页
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,12 +10,21 @@ use Hyperf\Validation\Request\FormRequest;
|
||||
class PatientDoctorRequest extends FormRequest
|
||||
{
|
||||
protected array $scenes = [
|
||||
'getInquiryDoctorList' => ['expertise_id','province_id','city_id','sort_order','keyword'],
|
||||
'getInquiryDoctorList' => [
|
||||
'expertise_id',
|
||||
'province_id',
|
||||
'city_id',
|
||||
'sort_order',
|
||||
'keyword'
|
||||
],
|
||||
'getDoctorInquiryCheck' => [ // 检测是否可以接诊
|
||||
'inquiry_type', // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||
'inquiry_mode', // 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)
|
||||
'doctor_id', // 医生id(非必需)
|
||||
],
|
||||
'getDoctorList' => [ // 获取我的问诊、关注医生列表
|
||||
'my_doctor_type', // 医生类型(1:问诊 2:关注)
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
@ -35,6 +44,7 @@ class PatientDoctorRequest extends FormRequest
|
||||
'sort_order' => 'sometimes|integer|min:1|max:5',
|
||||
'inquiry_type' => 'required|integer|min:1|max:4',
|
||||
'inquiry_mode' => 'required|integer|min:1|max:5',
|
||||
'my_doctor_type' => 'required|integer|min:1|max:2',
|
||||
];
|
||||
}
|
||||
|
||||
@ -55,6 +65,10 @@ class PatientDoctorRequest extends FormRequest
|
||||
'inquiry_mode.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_mode.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_mode.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'my_doctor_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'my_doctor_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'my_doctor_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'my_doctor_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -440,62 +440,60 @@ class PatientDoctorService extends BaseService
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首页服务过患者的医生
|
||||
* 限制条数
|
||||
* @param string $patient_id
|
||||
* @return array
|
||||
* 获取我的问诊、关注医生列表
|
||||
* @return array|void
|
||||
*/
|
||||
public function getIndexPatientDoctorLimit(string $patient_id): array
|
||||
{
|
||||
$results = array();
|
||||
public function getDoctorList(){
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$params = array();
|
||||
$params['patient_id'] = $patient_id;
|
||||
$params['history_status'] = 1;
|
||||
$patient_history_doctors = PatientHistoryInquiryModel::getIndexHistoryDoctorLimit($params);
|
||||
if (!empty($patient_history_doctors)) {
|
||||
foreach ($patient_history_doctors as $patient_history_doctor) {
|
||||
if (empty($patient_history_doctor['userDoctor'])) {
|
||||
continue;
|
||||
}
|
||||
$my_doctor_type = $this->request->input('my_doctor_type'); // 医生类型(1:问诊 2:关注)
|
||||
$page = $this->request->input('page', 1);
|
||||
$per_page = $this->request->input('per_page', 10);
|
||||
|
||||
if (count($results) > 5){
|
||||
// 超出5个
|
||||
continue;
|
||||
}
|
||||
if ($my_doctor_type == 1){
|
||||
// 问诊
|
||||
$params = array();
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$params['history_status'] = 1;
|
||||
$result = PatientHistoryInquiryModel::getPage($params);
|
||||
}else{
|
||||
// 关注
|
||||
$params = array();
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$result = PatientFollow::getPage($params);
|
||||
}
|
||||
|
||||
// 检测是否重复,如果重复,删除最早的一个数据
|
||||
foreach ($results as $key => $result){
|
||||
if ($patient_history_doctor['doctor_id'] == $result['doctor_id']){
|
||||
unset($results[$key]);
|
||||
// 处理数据
|
||||
if (!empty($result['data'])) {
|
||||
foreach ($result['data'] as $item) {
|
||||
$data = array();
|
||||
|
||||
// 医生专长
|
||||
if (!empty($item['DoctorExpertise'])) {
|
||||
foreach ($item['DoctorExpertise'] as &$doctor_expertise) {
|
||||
if (!empty($doctor_expertise['DiseaseClassExpertise'])) {
|
||||
$doctor_expertise['expertise_name'] = $doctor_expertise['DiseaseClassExpertise']['expertise_name'];
|
||||
}
|
||||
unset($doctor_expertise['DiseaseClassExpertise']);
|
||||
}
|
||||
}
|
||||
$data['doctor_expertise'] = $item['DoctorExpertise'];
|
||||
|
||||
// 组合数据
|
||||
$data = array();
|
||||
$data['doctor_id'] = $patient_history_doctor['userDoctor']['doctor_id'];
|
||||
$data['user_name'] = $patient_history_doctor['userDoctor']['user_name'];
|
||||
$data['avatar'] = addAliyunOssWebsite($patient_history_doctor['userDoctor']['avatar']);
|
||||
$data['hospital_name'] = "";
|
||||
if (!empty($patient_history_doctor['userDoctor']['Hospital'])) {
|
||||
$data['hospital_name'] = $patient_history_doctor['userDoctor']['Hospital']['hospital_name'];
|
||||
}
|
||||
// 医生数据
|
||||
$data['user_doctor'] = $item['UserDoctor'];
|
||||
|
||||
// 按照天来计算,当日为1,前一天为2 未服务过为0
|
||||
if (empty($patient_history_doctor['created_at'])) {
|
||||
$data['days'] = 0;
|
||||
} else {
|
||||
$data['days'] = ceil((strtotime(date('Y-m-d', strtotime('+1 day'))) - strtotime($patient_history_doctor['created_at'])) / 86400);
|
||||
}
|
||||
// 头像
|
||||
$data['user_doctor']['avatar'] = addAliyunOssWebsite($data['user_doctor']['avatar']);
|
||||
|
||||
$results[] = $data;
|
||||
// 职称
|
||||
$data['user_doctor']['doctor_title_name'] = empty($data['user_doctor']['doctor_title']) ? "" : DoctorTitleCode::getMessage($data['user_doctor']['doctor_title']);
|
||||
|
||||
unset($data);
|
||||
$result['data'] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
$results = array_merge($results);
|
||||
return $results;
|
||||
return success($result);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -568,4 +566,63 @@ class PatientDoctorService extends BaseService
|
||||
}
|
||||
return success($results);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首页服务过患者的医生
|
||||
* 限制条数
|
||||
* @param string $patient_id
|
||||
* @return array
|
||||
*/
|
||||
public function getIndexPatientDoctorLimit(string $patient_id): array
|
||||
{
|
||||
$results = array();
|
||||
|
||||
$params = array();
|
||||
$params['patient_id'] = $patient_id;
|
||||
$params['history_status'] = 1;
|
||||
$patient_history_doctors = PatientHistoryInquiryModel::getIndexHistoryDoctorList($params);
|
||||
if (!empty($patient_history_doctors)) {
|
||||
foreach ($patient_history_doctors as $patient_history_doctor) {
|
||||
if (empty($patient_history_doctor['userDoctor'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count($results) > 5){
|
||||
// 超出5个
|
||||
continue;
|
||||
}
|
||||
|
||||
// 检测是否重复,如果重复,删除最早的一个数据
|
||||
foreach ($results as $key => $result){
|
||||
if ($patient_history_doctor['doctor_id'] == $result['doctor_id']){
|
||||
unset($results[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
// 组合数据
|
||||
$data = array();
|
||||
$data['doctor_id'] = $patient_history_doctor['userDoctor']['doctor_id'];
|
||||
$data['user_name'] = $patient_history_doctor['userDoctor']['user_name'];
|
||||
$data['avatar'] = addAliyunOssWebsite($patient_history_doctor['userDoctor']['avatar']);
|
||||
$data['hospital_name'] = "";
|
||||
if (!empty($patient_history_doctor['userDoctor']['Hospital'])) {
|
||||
$data['hospital_name'] = $patient_history_doctor['userDoctor']['Hospital']['hospital_name'];
|
||||
}
|
||||
|
||||
// 按照天来计算,当日为1,前一天为2 未服务过为0
|
||||
if (empty($patient_history_doctor['created_at'])) {
|
||||
$data['days'] = 0;
|
||||
} else {
|
||||
$data['days'] = ceil((strtotime(date('Y-m-d', strtotime('+1 day'))) - strtotime($patient_history_doctor['created_at'])) / 86400);
|
||||
}
|
||||
|
||||
$results[] = $data;
|
||||
|
||||
unset($data);
|
||||
}
|
||||
}
|
||||
|
||||
$results = array_merge($results);
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
@ -179,7 +179,6 @@ class UserPatientService extends BaseService
|
||||
return fail();
|
||||
}
|
||||
|
||||
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$params['history_status'] = 1; //
|
||||
|
||||
@ -67,4 +67,8 @@ return [
|
||||
"secretKey" => "bc5fc333fec0f16973bb4600cebf8f32",
|
||||
"busunessId" => "",
|
||||
],
|
||||
'im' =>[ // 腾讯im
|
||||
"app_id" => "1400796919",
|
||||
"secret" => "a5bcd8c583181cf004e9d91a47687d719d4b5d2a10ce33fbee95d587889447d8",
|
||||
],
|
||||
];
|
||||
|
||||
@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
|
||||
use App\Controller\AreaController;
|
||||
use App\Controller\BasicDataController;
|
||||
use App\Controller\CallBackController;
|
||||
use App\Controller\DoctorAccountController;
|
||||
use App\Controller\DoctorAuthController;
|
||||
use App\Controller\IndexController;
|
||||
@ -217,6 +218,9 @@ Router::addGroup('/patient', function () {
|
||||
|
||||
// 删除服务过患者的医生
|
||||
Router::delete('/{doctor_id:\d+}', [UserPatientController::class, 'deletePatientDoctor']);
|
||||
|
||||
// 获取我的问诊、关注医生列表
|
||||
Router::get('/list', [PatientDoctorController::class, 'getDoctorList']);
|
||||
});
|
||||
|
||||
// 家庭成员
|
||||
@ -319,7 +323,6 @@ Router::addGroup('/basic', function () {
|
||||
// 搜索商品
|
||||
Router::get('/search', [BasicDataController::class, 'getProductSearch']);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// 获取医生评价
|
||||
@ -334,12 +337,16 @@ Router::addGroup('/system', function () {
|
||||
});
|
||||
});
|
||||
|
||||
// 支付回调
|
||||
Router::addGroup('/pay', function () {
|
||||
// 回调
|
||||
Router::addGroup('/callback', function () {
|
||||
// 支付回调
|
||||
Router::addGroup('/wx', function () {
|
||||
Router::post('/callback', [PayController::class, 'wxCallBack']);
|
||||
Router::addGroup('/pay', function () {
|
||||
// 微信支付回调
|
||||
Router::post('/wx', [CallBackController::class, 'wxPayCallBack']);
|
||||
});
|
||||
|
||||
// im回调
|
||||
Router::post('/im', [CallBackController::class, 'imCallBack']);
|
||||
});
|
||||
|
||||
// 用户
|
||||
@ -352,4 +359,10 @@ Router::addGroup('/user', function () {
|
||||
|
||||
// 退出登陆
|
||||
Router::put('/loginout', [UserController::class, 'putLoginout']);
|
||||
});
|
||||
|
||||
// im
|
||||
Router::addGroup('/im', function () {
|
||||
// 修改用户头像
|
||||
Router::put('/avatar', [UserController::class, 'putUserAvatar']);
|
||||
});
|
||||
@ -95,7 +95,7 @@ class WechatPay
|
||||
"out_trade_no" => $out_trade_no, // 商户系统内部订单号
|
||||
"appid" => $this->config['app_id'],
|
||||
"description" => "问诊服务",
|
||||
"notify_url" => "https://dev.hospital.applets.igandanyiyuan.com/pay/wx/callback",
|
||||
"notify_url" => "https://dev.hospital.applets.igandanyiyuan.com/callback/pay/wx",
|
||||
"amount" => [
|
||||
"total" => $total,//订单总金额,单位为分。
|
||||
"currency" => "CNY"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user