订单详情下发字段

pull/1/head
ztt 11 months ago
parent 2c74675e17
commit dffb33b703
  1. 13
      app/common/model/OrderRefund.php
  2. 2
      app/store/model/OrderRefund.php

@ -12,6 +12,7 @@ declare (strict_types=1);
namespace app\common\model;
use app\common\enum\order\refund\RefundType;
use cores\BaseModel;
use think\model\relation\BelongsTo;
use think\model\relation\HasMany;
@ -30,6 +31,13 @@ class OrderRefund extends BaseModel
// 定义主键
protected $pk = 'order_refund_id';
/**
* 追加字段
*/
protected $append = [
'refund_type_text'
];
/**
* 关联用户表
* @return BelongsTo
@ -113,4 +121,9 @@ class OrderRefund extends BaseModel
{
return static::get($where, $with);
}
public function getRefundTypeTextAttr($value, $data): string
{
return !empty(RefundType::data()[$data['type']]) ? RefundType::data()[$data['type']]['name'] : '';
}
}

@ -104,7 +104,7 @@ class OrderRefund extends OrderRefundModel
$list = $query->order(['refund.create_time' => 'desc', 'refund.' . $this->getPk()])
->paginate(10);
// 加载关联订单数据
$list = static::preload($list, ['goods.image', 'orderData', 'user.avatar'], true);
$list = static::preload($list, ['goods.image', 'orderData', 'user.avatar','images.file'], true);
foreach ($list['data'] as $key => $row) {
$row['orderData']['pay_method_text'] = Method::data()[$row['orderData']['pay_method']]['name'];//支付方式
$row['orderData']['delivery_type_text'] = DeliveryType::data()[$row['orderData']['delivery_type']]['name'];//配送方式

Loading…
Cancel
Save