67 lines
1.8 KiB
PHP
Executable File
67 lines
1.8 KiB
PHP
Executable File
<?php
|
||
|
||
namespace app\model;
|
||
|
||
use think\model\relation\HasMany;
|
||
use think\model\relation\HasOne;
|
||
|
||
class Order extends Base
|
||
{
|
||
public const STATUS_ORDER_PLACED = 'order_placed';//已下单 (已付款待发货)
|
||
public const STATUS_MAKEING = 'makeing';//制作中
|
||
public const STATUS_SHIPPED = 'shipped';//已发货
|
||
public const STATUS_ARRIVED = 'arrived';//已送达
|
||
public const STATUS_CANCEL = 'cancel';//已取消
|
||
|
||
public const CHECK_TYPE_FRONTEND = 'frontend';//核验类型 前端核验|线下核验
|
||
public const CHECK_TYPE_BACKEND = 'backend';//核验类型 后台核验|线上核验
|
||
|
||
public const PAY_TYPE_WECHAT = 'wechat';//微信
|
||
public const PAY_TYPE_SCORE = 'score';//积分
|
||
|
||
/**
|
||
* 核验方式列表
|
||
*
|
||
* @return string[]
|
||
*/
|
||
public static function checkTypeList(): array
|
||
{
|
||
return [self::CHECK_TYPE_FRONTEND, self::CHECK_TYPE_BACKEND];
|
||
}
|
||
|
||
/**
|
||
* 模型关联:订单下的sku
|
||
* 一对多关系
|
||
*
|
||
* @return HasMany
|
||
*/
|
||
public function skus(): HasMany
|
||
{
|
||
return $this->hasMany(OrderSku::class, 'order_coding', 'coding')->whereNull('deleted_at');
|
||
}
|
||
|
||
/**
|
||
* 模型关联:下单会员
|
||
* @return HasOne
|
||
*/
|
||
public function account(): HasOne
|
||
{
|
||
return $this->hasOne(Account::class, 'id', 'account_id');
|
||
}
|
||
|
||
/**
|
||
* 订单状态描述
|
||
*/
|
||
public static function statusTextList(): array
|
||
{
|
||
return [
|
||
self::STATUS_ORDER_PLACED => '已下单',
|
||
self::STATUS_MAKEING => '制作中',
|
||
self::STATUS_SHIPPED => '已发货',
|
||
self::STATUS_ARRIVED => '已送达',
|
||
self::STATUS_CANCEL => '已取消',
|
||
];
|
||
}
|
||
|
||
|
||
} |