0
0

更新代码

This commit is contained in:
2020-08-04 10:09:42 +08:00
parent 6118b5b63b
commit c2ac5d964e
478 changed files with 34410 additions and 0 deletions

46
app/Models/Payment.php Normal file
View File

@@ -0,0 +1,46 @@
<?php
namespace App\Models;
use RuLong\Order\Models\Order;
class Payment extends Model
{
public static function boot()
{
parent::boot();
self::creating(function ($model) {
$model->state = 'INIT';
$model->trade_no = 'T' . date('ymdHis') . sprintf("%07d", mt_rand(0, pow(10, 7) - 1));
});
}
public function order()
{
return $this->belongsTo(Order::class);
}
protected function getTypeTextAttribute()
{
if($this->type == 'BALANCE'){
return '<span style="color: orangered">余额支付</span>';
}elseif($this->type == 'WECHAT'){
return '<span style="color: green">微信支付</span>';
}else{
return $this->type;
}
}
protected function getStateTextAttribute()
{
if($this->state == 'SUCCESS'){
return '<span style="color: green">支付完成</span>';
}elseif($this->state == 'INIT'){
return '<span style="color: orangered">待支付</span>';
}else{
return $this->state;
}
}
}