From e1a6606169984685670d0e4caab08b23701f48d7 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Mon, 27 Mar 2023 16:14:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=84=E6=96=B9=E5=95=86?= =?UTF-8?q?=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/UserDoctorController.php | 19 ------ app/Model/OrderPrescriptionProduct.php | 77 +++++++++++-------------- app/Model/OrderProductItem.php | 5 ++ app/Model/PatientFamily.php | 4 +- 4 files changed, 40 insertions(+), 65 deletions(-) diff --git a/app/Controller/UserDoctorController.php b/app/Controller/UserDoctorController.php index 254cbd1..e618ed7 100644 --- a/app/Controller/UserDoctorController.php +++ b/app/Controller/UserDoctorController.php @@ -292,25 +292,6 @@ class UserDoctorController extends AbstractController */ public function addPrescription(): ResponseInterface { - -// $data = array(); -// $data['order_prescription_id'] = "498883041773666305"; -// $data['icd_id'] = 111; -// $order_prescription_icd = OrderPrescriptionIcd::addOrderPrescriptionIcd($data); -// if (empty($order_prescription_icd)) { -// dump(111); -// } -// die; -// $data = array(); -// $data['order_prescription_id'] = "498883041773666305"; -// $data['product_id'] = 2; -// $data['prescription_product_num'] = 1; -// $order_prescription_product = OrderPrescriptionProduct::addOrderPrescriptionProduct($data); -// if (empty($order_prescription_product)) { -// dump(111); -// } -// dump(222);die; - $request = $this->container->get(UserDoctorRequest::class); $request->scene('addPrescription')->validateResolved(); diff --git a/app/Model/OrderPrescriptionProduct.php b/app/Model/OrderPrescriptionProduct.php index 452865c..bacf4e1 100644 --- a/app/Model/OrderPrescriptionProduct.php +++ b/app/Model/OrderPrescriptionProduct.php @@ -7,8 +7,8 @@ namespace App\Model; use Hyperf\Database\Model\Collection; -use Hyperf\Database\Model\Model; use Hyperf\Database\Model\Relations\HasOne; +use Hyperf\Snowflake\Concern\Snowflake; /** * @property int $prescription_product_id 主键id @@ -30,6 +30,8 @@ use Hyperf\Database\Model\Relations\HasOne; */ class OrderPrescriptionProduct extends Model { + use Snowflake; + /** * The table associated with the model. */ @@ -41,6 +43,7 @@ class OrderPrescriptionProduct extends Model protected array $fillable = ['prescription_product_id', 'order_prescription_id', 'product_id', 'use_status', 'prescription_product_num', 'product_name', 'product_spec', 'license_number', 'manufacturer', 'single_unit', 'single_use', 'packaging_unit', 'frequency_use', 'available_days', 'created_at', 'updated_at']; protected string $primaryKey = "prescription_product_id"; + /** * 关联商品表 */ @@ -82,20 +85,29 @@ class OrderPrescriptionProduct extends Model } /** - * 获取数据-关联商品表 - * 限制数量 - * @param array $params - * @param array $fields - * @return Collection|array + * 新增 + * @param array $data + * @return \Hyperf\Database\Model\Model|OrderPrescriptionProduct */ - public static function getWithProductLimit(array $params = [], array $fields = ['*']): Collection|array + public static function addOrderPrescriptionProduct(array $data): \Hyperf\Database\Model\Model|OrderPrescriptionProduct { - return self::with([ - "Product" - ]) - ->where($params) - ->limit(10) - ->get($fields); + return self::create($data); + } + + public static function edit(array $params = [], array $data = []): int + { + return self::where($params)->update($data); + } + + + /** + * 删除 + * @param array $params + * @return int|mixed + */ + public static function deleteOrderPrescriptionProduct(array $params): mixed + { + return self::where($params)->delete(); } /** @@ -113,42 +125,19 @@ class OrderPrescriptionProduct extends Model } /** - * 删除 - * @param array $params - * @return int|mixed - */ - public static function deleteOrderPrescriptionProduct(array $params): mixed - { - return self::where($params)->delete(); - } - - /** - * 新增 - * @param array $data - * @return Model|OrderPrescriptionProduct - */ - public static function addOrderPrescriptionProduct(array $data): Model|OrderPrescriptionProduct - { - return self::create($data); - } - - /** - * 获取信息-单条 + * 获取数据-关联商品表 + * 限制数量 * @param array $params * @param array $fields - * @return object|null + * @return Collection|array */ - public static function getWithProductList(array $params, array $fields = ['*']): object|null + public static function getWithProductLimit(array $params = [], array $fields = ['*']): Collection|array { return self::with([ - 'Product' + "Product" ]) - ->where($params)->first($fields); - - } - - public static function edit(array $params = [], array $data = []): int - { - return self::where($params)->update($data); + ->where($params) + ->limit(10) + ->get($fields); } } diff --git a/app/Model/OrderProductItem.php b/app/Model/OrderProductItem.php index 82e8712..dd6b378 100644 --- a/app/Model/OrderProductItem.php +++ b/app/Model/OrderProductItem.php @@ -107,4 +107,9 @@ class OrderProductItem extends Model { return self::create($data); } + + public static function edit(array $params = [], array $data = []): int + { + return self::where($params)->update($data); + } } diff --git a/app/Model/PatientFamily.php b/app/Model/PatientFamily.php index ac46baa..a2768fe 100644 --- a/app/Model/PatientFamily.php +++ b/app/Model/PatientFamily.php @@ -81,9 +81,9 @@ class PatientFamily extends Model /** * 新增数据 * @param array $data - * @return Model|PatientFamily + * @return \Hyperf\Database\Model\Model|PatientFamily */ - public static function addPatientFamily(array $data = []): Model|PatientFamily + public static function addPatientFamily(array $data = []): \Hyperf\Database\Model\Model|PatientFamily { return self::create($data); }