93 lines
2.4 KiB
PHP
93 lines
2.4 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 $service_product_id 主键id
|
|
* @property int $order_service_id 订单-服务包id
|
|
* @property int $order_product_id 订单-商品id
|
|
* @property string $order_product_no 订单-商品系统编号
|
|
* @property int $product_item_id 订单-商品明细id
|
|
* @property int $product_id 商品id
|
|
* @property int $used_quantity 订单使用数量
|
|
* @property Carbon $created_at 创建时间
|
|
* @property Carbon $updated_at 修改时间
|
|
*/
|
|
class OrderServicePackageProduct extends Model
|
|
{
|
|
use Snowflake;
|
|
|
|
/**
|
|
* The table associated with the model.
|
|
*/
|
|
protected ?string $table = 'order_service_package_product';
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected array $fillable = ['service_product_id', 'order_service_id', 'order_product_id', 'order_product_no', 'product_item_id', 'product_id', 'used_quantity', 'created_at', 'updated_at'];
|
|
|
|
protected string $primaryKey = "service_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 $data
|
|
* @return OrderServicePackageProduct|\Hyperf\Database\Model\Model
|
|
*/
|
|
public static function addOrderServicePackageProduct(array $data): \Hyperf\Database\Model\Model|OrderServicePackageProduct
|
|
{
|
|
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);
|
|
}
|
|
|
|
/**
|
|
* 删除
|
|
* @param array $params
|
|
* @return int|mixed
|
|
*/
|
|
public static function deleteOrderServicePackageProduct(array $params): mixed
|
|
{
|
|
return self::where($params)->delete();
|
|
}
|
|
}
|