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); }