From ad7e6551f111d60ff7ace2a484f9730e8156fb15 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Wed, 1 Mar 2023 14:21:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=84=E6=96=B9=E8=8D=AF?= =?UTF-8?q?=E5=93=81=E6=95=B0=E6=8D=AE=E8=8E=B7=E5=8F=96=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/OrderPrescriptionProduct.php | 90 +++++++++++++++++++++++ app/Services/OrderPrescriptionService.php | 27 ++++--- app/Services/UserDoctorService.php | 6 +- 3 files changed, 109 insertions(+), 14 deletions(-) create mode 100644 app/Model/OrderPrescriptionProduct.php diff --git a/app/Model/OrderPrescriptionProduct.php b/app/Model/OrderPrescriptionProduct.php new file mode 100644 index 0000000..f64eed4 --- /dev/null +++ b/app/Model/OrderPrescriptionProduct.php @@ -0,0 +1,90 @@ +hasOne(Product::class, 'product_id', 'product_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 + * @param array $fields + * @return Collection|array + */ + public static function getWithProductList(array $params = [], array $fields = ['*']): Collection|array + { + return self::with([ + "Product" + ]) + ->where($params) + ->get($fields); + } +} diff --git a/app/Services/OrderPrescriptionService.php b/app/Services/OrderPrescriptionService.php index b4ce5bf..d85e676 100644 --- a/app/Services/OrderPrescriptionService.php +++ b/app/Services/OrderPrescriptionService.php @@ -3,6 +3,7 @@ namespace App\Services; use App\Model\OrderPrescription; +use App\Model\OrderPrescriptionProduct; use App\Model\OrderProductItem; use Hyperf\Contract\LengthAwarePaginatorInterface; @@ -59,7 +60,7 @@ class OrderPrescriptionService extends BaseService } /** - * 获取处方订单中开方商品数据 + * 获取处方中开方药品 * @param string|int $order_inquiry_id * @param string|int $order_prescription_id * @return array @@ -69,23 +70,25 @@ class OrderPrescriptionService extends BaseService $params = array(); $params['order_inquiry_id'] = $order_inquiry_id; $params['order_prescription_id'] = $order_prescription_id; - $order_product_items = OrderProductItem::getWithProductList($params); - if(empty($order_product_items)){ + $order_prescription_products = OrderPrescriptionProduct::getWithProductList($params); + if(empty($order_prescription_products)){ return []; } $result = []; - foreach ($order_product_items as $order_product_item){ + foreach ($order_prescription_products as $order_prescription_product){ $data = array(); - $data['product_item_id'] = $order_product_item['product_item_id']; - $data['product_id'] = $order_product_item['product_id']; - $data['amount'] = $order_product_item['amount']; - $data['product_cover_img'] = addAliyunOssWebsite($order_product_item['product_cover_img']); - $data['single_unit'] = $order_product_item['Product']['single_unit']; - $data['single_use'] = $order_product_item['Product']['single_use']; - $data['packaging_unit'] = $order_product_item['Product']['packaging_unit']; - $data['frequency_use'] = $order_product_item['Product']['frequency_use']; + $data['prescription_product_id'] = $order_prescription_product['prescription_product_id']; + $data['product_id'] = $order_prescription_product['product_id']; + $data['prescription_product_num'] = $order_prescription_product['prescription_product_num']; + $data['product_name'] = $order_prescription_product['Product']['product_name']; + $data['product_cover_img'] = addAliyunOssWebsite($order_prescription_product['Product']['product_cover_img']); + $data['product_spec'] = $order_prescription_product['Product']['product_spec']; + $data['single_unit'] = $order_prescription_product['Product']['single_unit']; + $data['single_use'] = $order_prescription_product['Product']['single_use']; + $data['packaging_unit'] = $order_prescription_product['Product']['packaging_unit']; + $data['frequency_use'] = $order_prescription_product['Product']['frequency_use']; $result[] = $data; } diff --git a/app/Services/UserDoctorService.php b/app/Services/UserDoctorService.php index aca7916..d0ad601 100644 --- a/app/Services/UserDoctorService.php +++ b/app/Services/UserDoctorService.php @@ -848,12 +848,14 @@ class UserDoctorService extends BaseService // 订单-商品订单列表 $OrderPrescriptionService = new OrderPrescriptionService(); - $order_product_items = $OrderPrescriptionService->getproductList($order_inquiry_id,$order_prescription_id); + $order_prescription_product = $OrderPrescriptionService->getproductList($order_inquiry_id,$order_prescription_id); + + // 获取处方关联疾病表 } $result = array(); $result['inquiry_case_product'] = $inquiry_case_product;// 用药意向 - $result['order_product_items'] = $order_product_items ?? [];// 开方药品 + $result['order_prescription_product'] = $order_prescription_product ?? [];// 开方药品 $result['case'] = $order_inquiry_case;// 病例数据 $result['prescription']['doctor_advice'] = $order_prescription['doctor_advice'] ?? "";// 医嘱