修正获取处方详情接口返回数据
This commit is contained in:
@@ -6,6 +6,7 @@ namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
@@ -31,10 +32,37 @@ class OrderPrescriptionIcd extends Model
|
||||
*/
|
||||
protected array $fillable = ['prescription_icd_id', 'order_prescription_id', 'icd_id', 'icd_name', 'icd_code', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*/
|
||||
protected array $casts = ['prescription_icd_id' => 'integer', 'order_prescription_id' => 'integer', 'icd_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
|
||||
|
||||
protected string $primaryKey = "prescription_icd_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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,18 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property int $order_prescription_id 订单-处方id
|
||||
* @property int $product_id 商品id
|
||||
* @property int $prescription_product_num 商品数量
|
||||
* @property string $product_name 商品名称
|
||||
* @property string $product_spec 商品规格
|
||||
* @property string $license_number 批准文号
|
||||
* @property string $manufacturer 生产厂家
|
||||
* @property string $single_unit 单次剂量(例:1次1包)
|
||||
* @property string $single_use 单次用法(例:口服)
|
||||
* @property string $packaging_unit 基本包装单位(例:盒/瓶)
|
||||
* @property string $frequency_use 使用频率(例:1天3次)
|
||||
* @property int $available_days 可用天数(3)
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
* @property-read Product $Product
|
||||
*/
|
||||
class OrderPrescriptionProduct extends Model
|
||||
{
|
||||
@@ -30,7 +40,7 @@ class OrderPrescriptionProduct extends Model
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['prescription_product_id', 'order_prescription_id', 'product_id', 'prescription_product_num', 'created_at', 'updated_at'];
|
||||
protected array $fillable = ['prescription_product_id', 'order_prescription_id', 'product_id', '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";
|
||||
/**
|
||||
@@ -75,16 +85,32 @@ class OrderPrescriptionProduct extends Model
|
||||
|
||||
/**
|
||||
* 获取数据-关联商品表
|
||||
* 限制数量
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getWithProductList(array $params = [], array $fields = ['*']): Collection|array
|
||||
public static function getWithProductLimit(array $params = [], array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::with([
|
||||
"Product"
|
||||
])
|
||||
->where($params)
|
||||
->limit(10)
|
||||
->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据
|
||||
* 限制数量
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getLimit(array $params = [], array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)
|
||||
->limit(10)
|
||||
->get($fields);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,4 +93,24 @@ class Product extends Model
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取关键字搜索列表
|
||||
* @param array $params
|
||||
* @param string $keyword
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getSearchKeywordList(array $params = [],string $keyword = '',array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::when($keyword, function ($query, $keyword) {
|
||||
$query->where(function ($query) use ($keyword) {
|
||||
$query->orwhere("product_name", 'like', '%' . $keyword . '%');
|
||||
$query->orwhere("common_name", 'like', '%' . $keyword . '%');
|
||||
$query->orwhere("mnemonic_code", 'like', '%' . $keyword . '%');
|
||||
});
|
||||
})
|
||||
->where($params)
|
||||
->get($fields);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user