初始化项目:添加后端代码、ThinkPHP框架、前端资源
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\app\physical;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 实物商品快递包裹模型
|
||||
*/
|
||||
class OrderExpress extends Model
|
||||
{
|
||||
protected $name = 'app_physical_order_express';
|
||||
|
||||
protected $autoWriteTimestamp = 'integer';
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
protected $deleteTime = false;
|
||||
|
||||
protected $append = ['status_text'];
|
||||
|
||||
/**
|
||||
* 根据订单ID获取快递信息
|
||||
* @param int $orderId 订单ID
|
||||
* @return array|null
|
||||
*/
|
||||
public static function getByOrderId($orderId)
|
||||
{
|
||||
$express = self::where([
|
||||
'order_id' => $orderId,
|
||||
'uniacid' => UNIACID
|
||||
])->find();
|
||||
|
||||
return $express ? $express->toArray() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取物流轨迹
|
||||
* @param int $expressId 快递包裹ID
|
||||
* @return array
|
||||
*/
|
||||
public function getLogs()
|
||||
{
|
||||
$logs = OrderExpressLog::where([
|
||||
'order_express_id' => $this->id,
|
||||
'uniacid' => UNIACID
|
||||
])->order('change_date', 'desc')
|
||||
->select();
|
||||
|
||||
if (is_array($logs)) {
|
||||
return $logs;
|
||||
}
|
||||
|
||||
return $logs->toArray();
|
||||
}
|
||||
|
||||
public function getStatusTextAttr($value, $data)
|
||||
{
|
||||
$statusList = [
|
||||
'noinfo' => '暂无信息',
|
||||
'collect' => '已揽件',
|
||||
'transport' => '运输中',
|
||||
'delivery' => '派送中',
|
||||
'signfor' => '已签收',
|
||||
'refuse' => '用户拒收',
|
||||
'difficulty' => '问题件',
|
||||
'invalid' => '无效件',
|
||||
'timeout' => '超时单',
|
||||
'fail' => '签收失败',
|
||||
'back' => '退回'
|
||||
];
|
||||
return $statusList[$data['status']] ?? '';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user