You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
ymww_backend/application/admin/model/Order.php

69 lines
2.1 KiB

<?php
namespace app\admin\model;
use think\Model;
class Order extends Model
{
// 表名
protected $name = 'order';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
'pay_time_text'
];
public function getLogisticsCompanyList()
{
return ['1' => __('百世快递'), '0' => __('中通快递'),'2' => __('申通快递'), '3' => __('圆通快递'),'4' => __('韵达快递'), '5' => __('邮政快递包裹'), '6' => __('EMS'), '7' => __('天天快递'),'8' => __('京东物流'),'9' => __('优速快递'),'10' => __('德邦'),'11' => __('宅急送'),'12' => __('爱尔兰邮政')];
}
public function getStatusList()
{
return ['1' => __('待收款确认'), '0' => __('待付款确认'),'2' => __('待委托'), '3' => __('投诉订单'),'4' => __('待发货'), '5' => __('待收货'), '6' => __('已完成'), '-1' => __('已取消'),'7' => __('已上架')];
}
public function getPayTimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['pay_time']) ? $data['pay_time'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
protected function setPayTimeAttr($value)
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
public function user()
{
return $this->belongsTo('\app\admin\model\User', 'buyer_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function user1()
{
return $this->belongsTo('\app\admin\model\User', 'seller_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function warehouse()
{
return $this->belongsTo('\app\admin\model\Warehouse', 'warehouse_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function detail()
{
return $this->belongsTo('\app\admin\model\order\Detail', 'id', 'order_id', [], 'LEFT')->setEagerlyType(0);
}
}