同步库存增加库存记录
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $amount_record_id 主键id
|
||||
* @property int $product_id 商品id
|
||||
* @property int $change_quantity 库存变动的数量
|
||||
* @property int $quantity 变动后库存数量
|
||||
* @property string $change_time 变动时间
|
||||
* @property string $remark 备注
|
||||
* @property Carbon $created_at 创建时间
|
||||
* @property Carbon $updated_at 修改时间
|
||||
*/
|
||||
class ProductAmountRecord extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'product_amount_record';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['amount_record_id', 'product_id', 'change_quantity', 'quantity', 'change_time', 'remark', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "amount_record_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 \Hyperf\Database\Model\Model|ProductAmountRecord
|
||||
*/
|
||||
public static function addProductAmountRecord(array $data = []): \Hyperf\Database\Model\Model|ProductAmountRecord
|
||||
{
|
||||
return self::create($data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user