6
0
Fork 0

Merge branch 'develop' of gitee.com:zi-chunsheng-e-commerce/mall-server into 1.x

release
李静 2022-02-23 16:17:38 +08:00
commit 11fe2d1d1c
3 changed files with 20 additions and 10 deletions

View File

@ -21,7 +21,7 @@ class OrderResource extends JsonResource
'total_amount' => $this->total_amount, 'total_amount' => $this->total_amount,
'created_at' => $this->created_at->toDateTimeString(), 'created_at' => $this->created_at->toDateTimeString(),
'status' => $this->status, 'status' => $this->status,
'pay_way' => $this->pay_way ?? '', 'pay_way' => (string) $this->pay_way?->getDealerOrderLabel(),
'pay_info' => $this->getConsignorPayInfo(), 'pay_info' => $this->getConsignorPayInfo(),
'pay_image'=> $this->pay_image, 'pay_image'=> $this->pay_image,
'is_consignor' => $request->user()->id == $this->consignor_id, //是否发货人身份 'is_consignor' => $request->user()->id == $this->consignor_id, //是否发货人身份

View File

@ -19,11 +19,21 @@ enum PayWay: string {
return match ($this) { return match ($this) {
static::Offline => '#5b69bc', static::Offline => '#5b69bc',
static::Wallet => '#ff8acc', static::Wallet => '#ff8acc',
static::WxpayH5 => '#21b978', static::WxpayApp, static::WxpayH5, static::WxpayJs, static::WxpayMp => '#21b978',
default => '#ea5455', default => '#ea5455',
}; };
} }
public function getDealerOrderLabel()
{
return match ($this) {
static::Offline => 'offline',
static::Wallet => 'wallet',
static::WxpayH5 => 'wxpay',
default => 'unknown',
};
}
public function getDealerOrderText() public function getDealerOrderText()
{ {
return match ($this) { return match ($this) {

View File

@ -165,6 +165,14 @@ class DealerOrder extends Model
return $this->hasMany(DealerOrderRefuseLog::class, 'order_id'); return $this->hasMany(DealerOrderRefuseLog::class, 'order_id');
} }
/**
* 属于此订单的支付记录
*/
public function payLogs()
{
return $this->morphMany(PayLog::class, 'payable');
}
public function isUser($userId) public function isUser($userId)
{ {
return $this->user_id == $userId; return $this->user_id == $userId;
@ -308,12 +316,4 @@ class DealerOrder extends Model
} }
return $payInfo ?: null; return $payInfo ?: null;
} }
/**
* 属于此订单的支付记录
*/
public function payLogs()
{
return $this->morphMany(PayLog::class, 'payable');
}
} }