新增患者个人中心-详情接口
This commit is contained in:
parent
7740dad0e5
commit
76cbcff76a
@ -3,6 +3,7 @@
|
|||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Request\UserPatientRequest;
|
use App\Request\UserPatientRequest;
|
||||||
|
use App\Services\UserPatientService;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
@ -12,5 +13,25 @@ use Psr\Http\Message\ResponseInterface;
|
|||||||
*/
|
*/
|
||||||
class UserPatientController extends AbstractController
|
class UserPatientController extends AbstractController
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* 获取患者个人中心数据
|
||||||
|
* @return ResponseInterface
|
||||||
|
*/
|
||||||
|
public function getPatientCenter(): ResponseInterface
|
||||||
|
{
|
||||||
|
$UserPatientService = new UserPatientService();
|
||||||
|
$data = $UserPatientService->getPatientCenter();
|
||||||
|
return $this->response->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取患者信息
|
||||||
|
* @return ResponseInterface
|
||||||
|
*/
|
||||||
|
public function getPatientCenterInfo(): ResponseInterface
|
||||||
|
{
|
||||||
|
$UserPatientService = new UserPatientService();
|
||||||
|
$data = $UserPatientService->getPatientCenterInfo();
|
||||||
|
return $this->response->json($data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -43,12 +43,12 @@ class Coupon extends Model
|
|||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*/
|
*/
|
||||||
protected array $fillable = ['coupon_id', 'coupon_name', 'coupon_icon', 'coupon_client', 'coupon_type', 'coupon_status', 'distribution_object', 'application_scope', 'is_display', 'distribution_with_day', 'coupon_count', 'coupon_take_count', 'coupon_ used_count', 'coupon_price', 'with_amount', 'valid_type', 'valid_days', 'valid_start_time', 'valid_end_time', 'created_at', 'updated_at'];
|
protected array $fillable = ['coupon_id', 'coupon_name', 'coupon_icon', 'coupon_client', 'coupon_type', 'coupon_status', 'distribution_object', 'application_scope', 'is_display', 'distribution_with_day', 'coupon_count', 'coupon_take_count', 'coupon_used_count', 'coupon_price', 'with_amount', 'valid_type', 'valid_days', 'valid_start_time', 'valid_end_time', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that should be cast to native types.
|
* The attributes that should be cast to native types.
|
||||||
*/
|
*/
|
||||||
protected array $casts = ['coupon_id' => 'string', 'coupon_client' => 'integer', 'coupon_type' => 'integer', 'coupon_status' => 'integer', 'distribution_object' => 'integer', 'application_scope' => 'integer', 'is_display' => 'integer', 'distribution_with_day' => 'integer', 'coupon_count' => 'integer', 'coupon_take_count' => 'integer', 'coupon_ used_count' => 'integer', 'valid_type' => 'integer', 'valid_days' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
|
protected array $casts = ['coupon_id' => 'string', 'coupon_client' => 'integer', 'coupon_type' => 'integer', 'coupon_status' => 'integer', 'distribution_object' => 'integer', 'application_scope' => 'integer', 'is_display' => 'integer', 'distribution_with_day' => 'integer', 'coupon_count' => 'integer', 'coupon_take_count' => 'integer', 'coupon_used_count' => 'integer', 'valid_type' => 'integer', 'valid_days' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
|
||||||
|
|
||||||
protected string $primaryKey = "coupon_id";
|
protected string $primaryKey = "coupon_id";
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
|||||||
* @property int $order_prescription_id 主键id
|
* @property int $order_prescription_id 主键id
|
||||||
* @property int $order_inquiry_id 订单-问诊id
|
* @property int $order_inquiry_id 订单-问诊id
|
||||||
* @property int $doctor_id 医生id
|
* @property int $doctor_id 医生id
|
||||||
|
* @property int $patient_id 患者id
|
||||||
* @property int $pharmacist_id 药师id
|
* @property int $pharmacist_id 药师id
|
||||||
* @property int $prescription_status 处方状态(1:待审核 3:待使用 4:已失效 5:已使用)
|
* @property int $prescription_status 处方状态(1:待审核 3:待使用 4:已失效 5:已使用)
|
||||||
* @property int $pharmacist_audit_status 药师审核状态(0:审核中 1:审核成功 2:审核驳回)
|
* @property int $pharmacist_audit_status 药师审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||||||
@ -46,7 +47,7 @@ class OrderPrescription extends Model
|
|||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*/
|
*/
|
||||||
protected array $fillable = ['order_prescription_id', 'order_inquiry_id', 'doctor_id', 'pharmacist_id', 'prescription_status', 'pharmacist_audit_status', 'pharmacist_fail_reason', 'platform_audit_status', 'platform_fail_reason', 'is_delete', 'prescription_code', 'doctor_name', 'patient_name', 'patient_sex', 'patient_age', 'prescription_img', 'doctor_advice', 'created_at', 'updated_at'];
|
protected array $fillable = ['order_prescription_id', 'order_inquiry_id', 'doctor_id', 'patient_id', 'pharmacist_id', 'prescription_status', 'pharmacist_audit_status', 'pharmacist_fail_reason', 'platform_audit_status', 'platform_fail_reason', 'is_delete', 'prescription_code', 'doctor_name', 'patient_name', 'patient_sex', 'patient_age', 'prescription_img', 'doctor_advice', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
protected string $primaryKey = "order_prescription_id";
|
protected string $primaryKey = "order_prescription_id";
|
||||||
|
|
||||||
@ -157,4 +158,14 @@ class OrderPrescription extends Model
|
|||||||
return self::create($data);
|
return self::create($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取数量
|
||||||
|
* @param array $params
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function getCount(array $params): int
|
||||||
|
{
|
||||||
|
return self::where($params)->count();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
|||||||
* @property int $order_inquiry_id 订单-问诊id
|
* @property int $order_inquiry_id 订单-问诊id
|
||||||
* @property int $order_prescription_id 订单-处方id
|
* @property int $order_prescription_id 订单-处方id
|
||||||
* @property int $doctor_id 医生id
|
* @property int $doctor_id 医生id
|
||||||
|
* @property int $patient_id 患者id
|
||||||
* @property string $order_product_no 订单编号
|
* @property string $order_product_no 订单编号
|
||||||
* @property string $escrow_trade_no 第三方支付流水号
|
* @property string $escrow_trade_no 第三方支付流水号
|
||||||
* @property int $order_product_status 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已完成 6:已取消)
|
* @property int $order_product_status 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已完成 6:已取消)
|
||||||
@ -55,7 +56,7 @@ class OrderProduct extends Model
|
|||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*/
|
*/
|
||||||
protected array $fillable = ['order_product_id', 'order_inquiry_id', 'order_prescription_id', 'doctor_id', 'order_product_no', 'escrow_trade_no', 'order_product_status', 'pay_channel', 'pay_status', 'cancel_reason', 'amount_total', 'payment_amount_total', 'logistics_fee', 'logistics_no', 'pay_time', 'remarks', 'refund_status', 'cancel_remarks', 'province_id', 'province', 'city_id', 'city', 'county_id', 'county', 'address', 'address_mask', 'consignee_name', 'consignee_name_mask', 'consignee_tel', 'consignee_tel_mask', 'created_at', 'updated_at'];
|
protected array $fillable = ['order_product_id', 'order_inquiry_id', 'order_prescription_id', 'doctor_id', 'patient_id', 'order_product_no', 'escrow_trade_no', 'order_product_status', 'pay_channel', 'pay_status', 'cancel_reason', 'amount_total', 'payment_amount_total', 'logistics_fee', 'logistics_no', 'pay_time', 'remarks', 'refund_status', 'cancel_remarks', 'province_id', 'province', 'city_id', 'city', 'county_id', 'county', 'address', 'address_mask', 'consignee_name', 'consignee_name_mask', 'consignee_tel', 'consignee_tel_mask', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
protected string $primaryKey = "order_product_id";
|
protected string $primaryKey = "order_product_id";
|
||||||
|
|
||||||
@ -90,4 +91,14 @@ class OrderProduct extends Model
|
|||||||
{
|
{
|
||||||
return self::where($params)->exists();
|
return self::where($params)->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取数量
|
||||||
|
* @param array $params
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function getCount(array $params): int
|
||||||
|
{
|
||||||
|
return self::where($params)->count();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -203,6 +203,7 @@ class BasicDataService extends BaseService
|
|||||||
$fields = [
|
$fields = [
|
||||||
'product_id',
|
'product_id',
|
||||||
'product_name',
|
'product_name',
|
||||||
|
'product_price',
|
||||||
'product_cover_img',
|
'product_cover_img',
|
||||||
'product_spec',
|
'product_spec',
|
||||||
'manufacturer',
|
'manufacturer',
|
||||||
|
|||||||
@ -435,4 +435,18 @@ class InquiryService extends BaseService
|
|||||||
|
|
||||||
return $amount_total_sum ?: 0;
|
return $amount_total_sum ?: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取患者某一状态下的问诊订单数量
|
||||||
|
* @param string $patient_id 患者id
|
||||||
|
* @param int $inquiry_status 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getPatientInquiryWithStatus(string $patient_id,int $inquiry_status): int
|
||||||
|
{
|
||||||
|
$params = array();
|
||||||
|
$params['patient_id'] = $patient_id;
|
||||||
|
$params['inquiry_status'] = $inquiry_status;
|
||||||
|
return OrderInquiry::getCount($params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -96,4 +96,19 @@ class OrderPrescriptionService extends BaseService
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取患者某一状态下的处方数量
|
||||||
|
* @param string $patient_id 患者id
|
||||||
|
* @param int $prescription_status 处方状态(1:待审核 3:待使用 4:已失效 5:已使用)
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getPatientPrescriptionWithStatus(string $patient_id,int $prescription_status): int
|
||||||
|
{
|
||||||
|
$params = array();
|
||||||
|
$params['patient_id'] = $patient_id;
|
||||||
|
$params['prescription_status'] = $prescription_status;
|
||||||
|
$params['pharmacist_audit_status'] = 1;
|
||||||
|
return OrderPrescription::getCount($params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
22
app/Services/OrderProductService.php
Normal file
22
app/Services/OrderProductService.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Model\OrderProduct;
|
||||||
|
|
||||||
|
class OrderProductService extends BaseService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取患者某一状态下的商品订单数量
|
||||||
|
* @param string $patient_id 患者id
|
||||||
|
* @param int $order_product_status 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已完成 6:已取消)
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getPatientProductWithStatus(string $patient_id,int $order_product_status): int
|
||||||
|
{
|
||||||
|
$params = array();
|
||||||
|
$params['patient_id'] = $patient_id;
|
||||||
|
$params['order_product_status'] = $order_product_status;
|
||||||
|
return OrderProduct::getCount($params);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -511,6 +511,7 @@ class UserDoctorService extends BaseService
|
|||||||
$estimate_income = $estimate_income * 0.75;
|
$estimate_income = $estimate_income * 0.75;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$user_doctor['avatar'] = addAliyunOssWebsite($user_doctor['avatar']);
|
||||||
$user_doctor['balance_account'] = $balance_account;
|
$user_doctor['balance_account'] = $balance_account;
|
||||||
$user_doctor['estimate_income'] = $estimate_income;
|
$user_doctor['estimate_income'] = $estimate_income;
|
||||||
|
|
||||||
|
|||||||
@ -3,13 +3,149 @@
|
|||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Constants\HttpEnumCode;
|
use App\Constants\HttpEnumCode;
|
||||||
|
use App\Model\Coupon;
|
||||||
use App\Model\OrderInquiry;
|
use App\Model\OrderInquiry;
|
||||||
|
use App\Model\UserCoupon;
|
||||||
|
use App\Model\UserPatient;
|
||||||
|
use App\Utils\Mask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 患者
|
* 患者
|
||||||
*/
|
*/
|
||||||
class UserPatientService extends BaseService
|
class UserPatientService extends BaseService
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* 获取患者个人中心数据
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getPatientCenter(): array
|
||||||
|
{
|
||||||
|
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||||
|
|
||||||
|
// 获取患者信息
|
||||||
|
$fields = [
|
||||||
|
'patient_id',
|
||||||
|
'user_id',
|
||||||
|
'user_name',
|
||||||
|
'avatar',
|
||||||
|
];
|
||||||
|
$params = array();
|
||||||
|
$params['patient_id'] = $user_info['client_user_id'];
|
||||||
|
$user_patient = UserPatient::getOne($params,$fields);
|
||||||
|
if (empty($user_patient)){
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "非法用户");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取福利数据
|
||||||
|
$coupon = $this->getPatientAvailableCouponList($user_patient['user_id'],1);
|
||||||
|
|
||||||
|
// 获取问诊数量-待支付
|
||||||
|
$InquiryService = new InquiryService();
|
||||||
|
$order_inquiry_count = $InquiryService->getPatientInquiryWithStatus($user_patient['patient_id'],1);
|
||||||
|
|
||||||
|
// 获取处方数量-未使用
|
||||||
|
$OrderPrescriptionService = new OrderPrescriptionService();
|
||||||
|
$order_prescription_count = $OrderPrescriptionService->getPatientPrescriptionWithStatus($user_patient['patient_id'],3);
|
||||||
|
|
||||||
|
// 获取药品数量-待支付
|
||||||
|
$OrderProductService = new OrderProductService();
|
||||||
|
$order_product_count = $OrderProductService->getPatientProductWithStatus($user_patient['patient_id'],1);
|
||||||
|
|
||||||
|
// 处理头像
|
||||||
|
$user_patient['avatar'] = addAliyunOssWebsite($user_patient['avatar']);
|
||||||
|
|
||||||
|
$result = array();
|
||||||
|
$result['patient_id'] = $user_patient['patient_id'];
|
||||||
|
$result['avatar'] = $user_patient['avatar'];
|
||||||
|
$result['user_name'] = $user_patient['user_name'];
|
||||||
|
$result['coupon'] = empty($coupon);
|
||||||
|
$result['order_inquiry_count'] = $order_inquiry_count;
|
||||||
|
$result['order_prescription_count'] = $order_prescription_count;
|
||||||
|
$result['order_product_count'] = $order_product_count;
|
||||||
|
return success($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取患者信息
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getPatientCenterInfo(): array
|
||||||
|
{
|
||||||
|
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||||
|
|
||||||
|
// 获取患者信息
|
||||||
|
$fields = [
|
||||||
|
'patient_id',
|
||||||
|
'user_id',
|
||||||
|
'user_name',
|
||||||
|
'mobile',
|
||||||
|
'avatar',
|
||||||
|
];
|
||||||
|
$params = array();
|
||||||
|
$params['patient_id'] = $user_info['client_user_id'];
|
||||||
|
$user_patient = UserPatient::getOne($params,$fields);
|
||||||
|
if (empty($user_patient)){
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "非法用户");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 手机号
|
||||||
|
$user_patient['mobile'] = Mask::maskPhoneStr($user_patient['mobile']);
|
||||||
|
|
||||||
|
// 头像
|
||||||
|
$user_patient['avatar'] = addAliyunOssWebsite($user_patient['avatar']);
|
||||||
|
|
||||||
|
return success($user_patient->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户可领取优惠卷
|
||||||
|
* @param string|int $user_id
|
||||||
|
* @param int $coupon_client
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getPatientAvailableCouponList(string|int $user_id,int $coupon_client): array
|
||||||
|
{
|
||||||
|
// 获取全部优惠卷
|
||||||
|
$params = array();
|
||||||
|
$params['coupon_client'] = $coupon_client;
|
||||||
|
$params['coupon_status'] = 1;
|
||||||
|
$params['is_display'] = 1;
|
||||||
|
$coupon = Coupon::getList($params);
|
||||||
|
if (empty($coupon)){
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理优惠卷
|
||||||
|
$result = array();
|
||||||
|
foreach ($coupon as $item){
|
||||||
|
if ($item['coupon_count'] <= $item['coupon_take_count']){
|
||||||
|
// 已发放完毕
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($item['valid_type'] == 1){
|
||||||
|
// 绝对时效
|
||||||
|
$date = date('Y-m-d H:i:s',time());
|
||||||
|
if ($item['valid_end_time'] < $date){
|
||||||
|
// 超出结束使用时间
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测当前优惠卷是否被用户领取
|
||||||
|
$params = array();
|
||||||
|
$params['user_id'] = $user_id;
|
||||||
|
$params['coupon_id'] = $item['coupon_id'];
|
||||||
|
$user_coupon = UserCoupon::getOne($params);
|
||||||
|
if (empty($user_coupon)){
|
||||||
|
// 未被领取
|
||||||
|
$result[] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取患者未完成订单
|
* 获取患者未完成订单
|
||||||
* @param string $patient_id
|
* @param string $patient_id
|
||||||
|
|||||||
@ -174,6 +174,16 @@ Router::addGroup('/patient', function () {
|
|||||||
// 首页
|
// 首页
|
||||||
Router::get('/index', [IndexController::class, 'patientIndex']);
|
Router::get('/index', [IndexController::class, 'patientIndex']);
|
||||||
|
|
||||||
|
// 个人中心
|
||||||
|
Router::addGroup('/center', function () {
|
||||||
|
// 获取患者个人中心数据
|
||||||
|
Router::get('', [UserPatientController::class, 'getPatientCenter']);
|
||||||
|
|
||||||
|
// 获取患者信息
|
||||||
|
Router::get('/info', [UserPatientController::class, 'getPatientCenterInfo']);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// 个人中心-我的医生
|
// 个人中心-我的医生
|
||||||
Router::addGroup('/my_doctor', function () {
|
Router::addGroup('/my_doctor', function () {
|
||||||
// 删除我的医生
|
// 删除我的医生
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user