This commit is contained in:
wucongxing 2023-03-13 13:49:31 +08:00
parent 802a5081fb
commit 6d2c0374a3
6 changed files with 245 additions and 6 deletions

View File

@ -184,4 +184,26 @@ class PatientOrderController extends AbstractController
$data = $PatientOrderService->getPatientPrescriptionOrderInfo(); $data = $PatientOrderService->getPatientPrescriptionOrderInfo();
return $this->response->json($data); return $this->response->json($data);
} }
/**
* 获取处方订单支付页详情
* @return ResponseInterface
*/
public function getPatientPrescriptionOrderPayInfo(): ResponseInterface
{
$PatientOrderService = new PatientOrderService();
$data = $PatientOrderService->getPatientPrescriptionOrderPayInfo();
return $this->response->json($data);
}
/**
* 删除处方订单记录
* @return ResponseInterface
*/
public function deletePatientPrescriptionOrder(): ResponseInterface
{
$PatientOrderService = new PatientOrderService();
$data = $PatientOrderService->deletePatientPrescriptionOrder();
return $this->response->json($data);
}
} }

View File

@ -134,4 +134,19 @@ class OrderPrescriptionProduct extends Model
{ {
return self::create($data); return self::create($data);
} }
/**
* 获取信息-单条
* @param array $params
* @param array $fields
* @return object|null
*/
public static function getWithProductList(array $params, array $fields = ['*']): object|null
{
return self::with([
'Product'
])
->where($params)->first($fields);
}
} }

View File

@ -0,0 +1,93 @@
<?php
declare(strict_types=1);
namespace App\Model;
use Hyperf\Database\Model\Collection;
use Hyperf\Snowflake\Concern\Snowflake;
/**
* @property int $address_id 主键id
* @property int $user_id 用户id
* @property int $province_id 省份id
* @property string $province 省份
* @property int $city_id 城市id
* @property string $city 城市
* @property int $county_id 区县id
* @property string $county 区县
* @property int $consignee_town_id 镇id
* @property string $consignee_town
* @property string $address 详细地址
* @property string $address_mask 详细地址(掩码)
* @property string $consignee_name 收货人姓名
* @property string $consignee_name_mask 收货人姓名(掩码)
* @property string $consignee_tel 收货人电话
* @property string $consignee_tel_mask 收货人电话(掩码)
* @property string $consignee_zip_code 收货邮编
* @property int $is_default 默认地址0: 1:是)
* @property int $tag 地址标签1: 2:公司 3:学校)
* @property \Carbon\Carbon $created_at 创建时间
* @property \Carbon\Carbon $updated_at 修改时间
*/
class UserShipAddress extends Model
{
use Snowflake;
/**
* The table associated with the model.
*/
protected ?string $table = 'user_ship_address';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['address_id', 'user_id', 'province_id', 'province', 'city_id', 'city', 'county_id', 'county', 'consignee_town_id', 'consignee_town', 'address', 'address_mask', 'consignee_name', 'consignee_name_mask', 'consignee_tel', 'consignee_tel_mask', 'consignee_zip_code', 'is_default', 'tag', 'created_at', 'updated_at'];
protected string $primaryKey = "address_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 Collection|array
*/
public static function getList(array $params = [], array $fields = ['*']): Collection|array
{
return self::where($params)->get($fields);
}
/**
* 获取是否存在
* @param array $params
* @return bool
*/
public static function getExists(array $params): bool
{
return self::where($params)->exists();
}
/**
* 获取数量
* @param array $params
* @return int
*/
public static function getCount(array $params): int
{
return self::where($params)->count();
}
}

View File

@ -253,8 +253,13 @@ class PatientDoctorService extends BaseService
$result['doctor_inquiry_config'] = $doctor_inquiry_config; $result['doctor_inquiry_config'] = $doctor_inquiry_config;
} }
// 获取医生已选择专长
$UserDoctorService = new UserDoctorService();
$result['doctor_expertise'] = $UserDoctorService->getDoctorSelectedExpertise($user_doctor['doctor_id']);
// 好评率-超过5个已结束的订单后展示 // 好评率-超过5个已结束的订单后展示
$result['praise_rate'] = ceil($user_doctor['praise_rate'] * 0.05 * 100) / 100; $result['praise_rate'] = ceil($user_doctor['praise_rate'] * 0.05 * 100) / 100;
// 响应时间-超过5个已结束的订单后展示 // 响应时间-超过5个已结束的订单后展示
$result['avg_response_time'] = ceil($user_doctor['avg_response_time'] * 0.05 * 100) / 100 * 60; $result['avg_response_time'] = ceil($user_doctor['avg_response_time'] * 0.05 * 100) / 100 * 60;

View File

@ -8,9 +8,11 @@ use App\Model\Hospital;
use App\Model\OrderInquiry; use App\Model\OrderInquiry;
use App\Model\OrderInquiryCase; use App\Model\OrderInquiryCase;
use App\Model\OrderPrescription; use App\Model\OrderPrescription;
use App\Model\OrderPrescriptionProduct;
use App\Model\OrderProduct; use App\Model\OrderProduct;
use App\Model\OrderProductItem; use App\Model\OrderProductItem;
use App\Model\UserDoctor; use App\Model\UserDoctor;
use App\Model\UserShipAddress;
use Extend\Wechat\WechatPay; use Extend\Wechat\WechatPay;
use Hyperf\DbConnection\Db; use Hyperf\DbConnection\Db;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
@ -734,7 +736,12 @@ class PatientOrderService extends BaseService
return success($order_prescription); return success($order_prescription);
} }
public function getPatientPrescriptionOrderInfo(){ /**
* 获取处方订单详情
* @return array
*/
public function getPatientPrescriptionOrderInfo(): array
{
$user_info = $this->request->getAttribute("userInfo") ?? []; $user_info = $this->request->getAttribute("userInfo") ?? [];
$order_prescription_id = $this->request->route('order_prescription_id'); $order_prescription_id = $this->request->route('order_prescription_id');
@ -743,6 +750,7 @@ class PatientOrderService extends BaseService
$fields = [ $fields = [
'order_prescription_id', 'order_prescription_id',
'prescription_status', 'prescription_status',
'prescription_img',
]; ];
$params = array(); $params = array();
$params['order_prescription_id'] = $order_prescription_id; $params['order_prescription_id'] = $order_prescription_id;
@ -750,6 +758,102 @@ class PatientOrderService extends BaseService
$params['pharmacist_audit_status'] = 1; $params['pharmacist_audit_status'] = 1;
$params['platform_audit_status'] = 1; $params['platform_audit_status'] = 1;
$params['is_delete'] = 0; $params['is_delete'] = 0;
$order_prescription = OrderPrescription::getWithOne($params); $order_prescription = OrderPrescription::getOne($params,$fields);
if (empty($order_prescription)){
return fail();
}
$order_prescription['prescription_img'] = addAliyunOssWebsite($order_prescription['prescription_img']);
return success($order_prescription->toArray());
}
/**
* 获取处方订单支付页详情
* 我这边一直到6-7月份才能走得开。目前这几个月项目都正在开发中,没办法离开,也不好。
* @return array
*/
public function getPatientPrescriptionOrderPayInfo(): array
{
$user_info = $this->request->getAttribute("userInfo") ?? [];
$order_prescription_id = $this->request->route('order_prescription_id');
$fields = [
"order_prescription_id"
];
$params = array();
$params['order_prescription_id'] = $order_prescription_id;
$params['patient_id'] = $user_info['client_user_id'];
$params['is_delete'] = 0;
$order_prescription = OrderPrescription::getOne($params,$fields);
if (empty($order_prescription)){
return fail();
}
// 验证处方状态
if ($order_prescription['prescription_status'] == 1){
return fail(HttpEnumCode::HTTP_ERROR,"处方未审核");
}
if ($order_prescription['prescription_status'] == 3){
return fail(HttpEnumCode::HTTP_ERROR,"处方已失效");
}
if ($order_prescription['prescription_status'] == 4){
return fail(HttpEnumCode::HTTP_ERROR,"处方已使用");
}
// 获取处方药品信息
$params = array();
$params['order_prescription_id'] = $order_prescription['order_prescription_id'];
$order_prescription_product = OrderPrescriptionProduct::getWithProductList($params);
if (empty($order_prescription_product)){
return fail(HttpEnumCode::SERVER_ERROR);
}
$amount_total = 0;
$coupon_amount_total = 0;
$logistics_fee = 0; // 运费金额
foreach ($order_prescription_product as $item){
if (!empty($item['Product']['product_price'])){
$amount_total += $item['Product']['product_price'];
}
}
// 获取运费金额
// 实际支付金额
$payment_amount_total = $amount_total + $logistics_fee;
// 获取收货地址
$params = array();
$params['user_id'] = $user_info['user_id'];
$user_ship_addresss = UserShipAddress::getList($params);
foreach ($user_ship_addresss as $item){
if ($item['is_default'] == 1){
$user_ship_address = $item;
}
}
// 无默认地址,选择第一个
if (empty($user_ship_address)){
$user_ship_address = $user_ship_addresss[0] ?? [];
}
$result = array();
$result['amount_total'] = $amount_total;
$result['coupon_amount_total'] = $coupon_amount_total;
$result['payment_amount_total'] = $payment_amount_total;
$result['logistics_fee'] = $logistics_fee;
$result['user_ship_address'] = $user_ship_address;
return success($result);
}
public function deletePatientPrescriptionOrder(){
} }
} }

View File

@ -320,11 +320,11 @@ Router::addGroup('/patient', function () {
// 获取处方订单详情 // 获取处方订单详情
Router::get('/{order_prescription_id:\d+}', [PatientOrderController::class, 'getPatientPrescriptionOrderInfo']); Router::get('/{order_prescription_id:\d+}', [PatientOrderController::class, 'getPatientPrescriptionOrderInfo']);
// 获取处方订单支付页详情-处方管理 // 获取处方订单支付页详情
Router::post('/16', [PatientOrderController::class, 'imCallBack']); Router::get('/pay/{order_prescription_id:\d+}', [PatientOrderController::class, 'getPatientPrescriptionOrderPayInfo']);
// 删除处方订单记录-处方管理 // 删除处方订单记录
Router::post('/18', [PatientOrderController::class, 'imCallBack']); Router::delete('/{order_prescription_id:\d+}', [PatientOrderController::class, 'deletePatientPrescriptionOrder']);
}); });
// 获取患者订单支付数据 // 获取患者订单支付数据