64 lines
1.6 KiB
PHP
64 lines
1.6 KiB
PHP
|
|
<?php
|
|||
|
|
|
|||
|
|
namespace App\Models\business;
|
|||
|
|
|
|||
|
|
use App\BaseApp\BaseBusinessModel;
|
|||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|||
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 订单(cc_order)
|
|||
|
|
*
|
|||
|
|
* 金额字段一律是整数分。状态用显式状态机(见 OrderService::transition),
|
|||
|
|
* 不要在业务代码里散落 if-else 直接改 status。
|
|||
|
|
*/
|
|||
|
|
class OrderModel extends BaseBusinessModel
|
|||
|
|
{
|
|||
|
|
protected $table = 'order';
|
|||
|
|
|
|||
|
|
protected $guarded = [];
|
|||
|
|
|
|||
|
|
public const STATUS_UNPAID = 0;
|
|||
|
|
public const STATUS_PAID = 1;
|
|||
|
|
public const STATUS_SHIPPED = 2;
|
|||
|
|
public const STATUS_DONE = 3;
|
|||
|
|
public const STATUS_CANCELLED = 4;
|
|||
|
|
|
|||
|
|
public const PAY_TYPE_VOUCHER = 1;
|
|||
|
|
public const PAY_TYPE_WECHAT = 2;
|
|||
|
|
|
|||
|
|
public const PAY_STATUS_UNPAID = 0;
|
|||
|
|
public const PAY_STATUS_AUDITING = 1;
|
|||
|
|
public const PAY_STATUS_PAID = 2;
|
|||
|
|
public const PAY_STATUS_REJECTED = 3;
|
|||
|
|
|
|||
|
|
public const DELIVERY_EXPRESS = 1;
|
|||
|
|
public const DELIVERY_PICKUP = 2;
|
|||
|
|
public const DELIVERY_COMPANY = 3;
|
|||
|
|
|
|||
|
|
public function items(): HasMany
|
|||
|
|
{
|
|||
|
|
return $this->hasMany(OrderItemModel::class, 'order_id', 'id');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public function payments(): HasMany
|
|||
|
|
{
|
|||
|
|
return $this->hasMany(OrderPaymentModel::class, 'order_id', 'id');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public function deliveries(): HasMany
|
|||
|
|
{
|
|||
|
|
return $this->hasMany(OrderDeliveryModel::class, 'order_id', 'id');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public function user(): BelongsTo
|
|||
|
|
{
|
|||
|
|
return $this->belongsTo(WxUserModel::class, 'user_id', 'id');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public function enterprise(): BelongsTo
|
|||
|
|
{
|
|||
|
|
return $this->belongsTo(EnterpriseModel::class, 'enterprise_id', 'id');
|
|||
|
|
}
|
|||
|
|
}
|