<?php
namespace app\common\model\sharing;
use app\common\model\BaseModel;
class OrderRefund extends BaseModel
{
protected $name = 'sharing_order_refund';
public function user()
{
$module = self::getCalledModule() ?: 'common';
return $this->belongsTo("app\\{$module}\\model\\User");
}
public function orderMaster()
{
return $this->belongsTo('Order');
}
public function orderGoods()
{
return $this->belongsTo('OrderGoods');
}
public function image()
{
return $this->hasMany('OrderRefundImage', 'order_refund_id');
}
public function express()
{
$module = self::getCalledModule() ?: 'common';
return $this->belongsTo("app\\{$module}\\model\\Express");
}
public function address()
{
return $this->hasOne('OrderRefundAddress', 'order_refund_id');
}
public function getTypeAttr($value)
{
$status = [10 => '退货退款', 20 => '换货'];
return ['text' => $status[$value], 'value' => $value];
}
public function getIsAgreeAttr($value)
{
$status = [0 => '待审核', 10 => '已同意', 20 => '已拒绝'];
return ['text' => $status[$value], 'value' => $value];
}
public function getStatusAttr($value)
{
$status = [0 => '进行中', 10 => '已拒绝', 20 => '已完成', 30 => '已取消'];
return ['text' => $status[$value], 'value' => $value];
}
public static function detail($where)
{
return static::get($where, ['image.file', 'order_goods.image', 'express', 'address']);
}
}