Files
hyperf_service/app/Model/Sku.php
2025-01-07 17:55:58 +08:00

62 lines
1.7 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Model;
use App\Constants\Common\GoodCode;
use Hyperf\Database\Model\Builder;
use Hyperf\DbConnection\Model\Model;
/**
* @property int $id
* @property int $spu_id
* @property string $title
* @property string $image_ids
* @property string $price
* @property string $param
* @property string $extra
* @property int $total_stock
* @property int $surplus_stock
* @property int $sales_num
* @property int $order_num
* @property int $cancel_num
* @property int $ahead_refund_num
* @property int $behind_refund_num
* @property int $saleable
* @property int $is_del
* @property string $create_time
* @property string $update_time
*/
class Sku extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'sku';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
protected array $guarded = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['id' => 'integer', 'spu_id' => 'integer', 'total_stock' => 'integer', 'surplus_stock' => 'integer', 'sales_num' => 'integer', 'order_num' => 'integer', 'cancel_num' => 'integer', 'ahead_refund_num' => 'integer', 'behind_refund_num' => 'integer', 'saleable' => 'integer'];
const string CREATED_AT = 'create_time';
const string UPDATED_AT = 'update_time';
/**
* @param int $id
* @return Builder|\Hyperf\Database\Model\Model|null
*/
public function getInfoById(int $id): \Hyperf\Database\Model\Model|Builder|null
{
return $this->where('id',$id)->where('is_del',GoodCode::SKU_IS_NO_DEL)->first();
}
}