feat: sku

This commit is contained in:
2025-01-07 17:55:58 +08:00
parent fd18cffeab
commit fd70dfabf5
8 changed files with 295 additions and 21 deletions

View File

@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace App\Model;
use App\Constants\Common\GoodCode;
use Hyperf\Database\Model\Builder;
use Hyperf\DbConnection\Model\Model;
/**
@@ -21,7 +23,8 @@ use Hyperf\DbConnection\Model\Model;
* @property int $cancel_num
* @property int $ahead_refund_num
* @property int $behind_refund_num
* @property int $saleable
* @property int $saleable
* @property int $is_del
* @property string $create_time
* @property string $update_time
*/
@@ -37,8 +40,22 @@ class Sku extends Model
*/
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();
}
}