hospital-applets-api/app/Model/ProductPlatformAmount.php

66 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Model;
use Hyperf\Snowflake\Concern\Snowflake;
/**
* @property int $amount_id 主键id
* @property int $product_platform_id 商品id
* @property string $product_platform_code 处方平台商品编码
* @property int $real_stock 实际库存
* @property int $stock 现有库存
* @property int $lock_stock 锁定库存
* @property \Carbon\Carbon $created_at 创建时间
* @property \Carbon\Carbon $updated_at 修改时间
*/
class ProductPlatformAmount extends Model
{
use Snowflake;
/**
* The table associated with the model.
*/
protected ?string $table = 'product_platform_amount';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['amount_id', 'product_platform_id', 'product_platform_code', 'real_stock', 'stock', 'lock_stock', 'created_at', 'updated_at'];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['amount_id' => 'integer', 'product_platform_id' => 'integer', 'real_stock' => 'integer', 'stock' => 'integer', 'lock_stock' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
protected string $primaryKey = "amount_id";
/**
* 自增
* @param array $params
* @param string $field
* @param float $numeral
* @return int
*/
public static function inc(array $params,string $field,float $numeral = 1): int
{
return self::where($params)->increment($field,$numeral);
}
/**
* 自减
* @param array $params
* @param string $field
* @param float $numeral
* @return int
*/
public static function dec(array $params,string $field,float $numeral = 1): int
{
return self::where($params)->decrement($field,$numeral);
}
}