72 lines
1.4 KiB
PHP

<?php
namespace app\common\model;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* Order模型
* Class Order
* @package app\common\model
*/
class Order extends BaseModel
{
use SoftDelete;
const StatusMap = [
0 => '待发货',
1 => '待收货',
2 => '待评价',
3 => '已完成',
9 => '拼团中',
10 => '待付尾款',
11 => '尾款超时未付',
-1 => '已退款',
];
const OrderTypeMap = [
1 => '普通订单',
2 => '自提订单',
];
const PayStatusMap = [
0 => '待支付',
1 => '已支付',
];
protected $name = 'order';
protected $deleteTime = 'delete_time';
public function project()
{
return $this->hasOne(Project::class, 'id', 'project_id')->field('id,name');
}
public function orderDishes()
{
return $this->hasMany(OrderDishes::class, 'order_id', 'id');
}
public function orderProduct()
{
return $this->hasMany(OrderProduct::class, 'order_id', 'id');
}
public function getStatusTextAttr($value)
{
return self::StatusMap[$this->status];
}
public function getOrderTypeTextAttr($value)
{
return self::OrderTypeMap[$this->order_type];
}
public function getPayStatusTextAttr($value)
{
return self::PayStatusMap[$this->paid];
}
}