82 lines
2.1 KiB
PHP
82 lines
2.1 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace App\Model;
|
||
|
||
|
||
|
||
use Carbon\Carbon;
|
||
use Hyperf\Database\Model\Collection;
|
||
use Hyperf\Snowflake\Concern\Snowflake;
|
||
|
||
/**
|
||
* @property int $package_id 主键id
|
||
* @property int $service_count 总服务次数
|
||
* @property int $monthly_frequency 每月次数
|
||
* @property string $effective_days 服务有效天数
|
||
* @property string $service_rate 服务费率。100为满值,表示1,正常费率。
|
||
* @property string $discount_product_total_amount 折扣商品总价格
|
||
* @property Carbon $created_at 创建时间
|
||
* @property Carbon $updated_at 修改时间
|
||
*/
|
||
class HealthPackage extends Model
|
||
{
|
||
use Snowflake;
|
||
|
||
/**
|
||
* The table associated with the model.
|
||
*/
|
||
protected ?string $table = 'health_package';
|
||
|
||
/**
|
||
* The attributes that are mass assignable.
|
||
*/
|
||
protected array $fillable = ['package_id', 'service_count', 'monthly_frequency', 'effective_days', 'service_rate', 'discount_product_total_amount', 'created_at', 'updated_at'];
|
||
|
||
protected string $primaryKey = "package_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 $data
|
||
* @return HealthPackage|\Hyperf\Database\Model\Model
|
||
*/
|
||
public static function addHealthPackage(array $data): \Hyperf\Database\Model\Model|HealthPackage
|
||
{
|
||
return self::create($data);
|
||
}
|
||
|
||
/**
|
||
* 修改
|
||
* @param array $params
|
||
* @param array $data
|
||
* @return int
|
||
*/
|
||
public static function edit(array $params = [], array $data = []): int
|
||
{
|
||
return self::where($params)->update($data);
|
||
}
|
||
}
|