1
0

提交代码

This commit is contained in:
2020-08-06 14:45:56 +08:00
commit 9d0d5f4be9
361 changed files with 36445 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Models;
class CardPayment extends Model
{
public static function boot()
{
parent::boot();
self::creating(function ($model) {
$model->state = 'INIT';
$model->trade_no = 'C' . date('ymdHis') . sprintf("%07d", mt_rand(0, pow(10, 7) - 1));
});
}
public function order()
{
return $this->belongsTo(CardOrder::class, 'card_order_id', 'id');
}
public function getStateTextAttribute()
{
switch ($this->state) {
case 'INIT':
return '<span style="color:#2180ea">未支付</span>';
break;
case 'SUCCESS':
return '<span style="color:#14d000">已支付</span>';
break;
case 'OVER':
return '<span style="color:#ff0000">已结束</span>';
break;
default:
return "未知状态";
break;
}
}
}