You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Model;
use App\Helper\DeviceType;
class Spend extends Model
{
const STATUS_FAILED = 0;
const STATUS_SUCCESS = 1;
protected $table = 'tab_spend';
public static $payWays = [
-1 => '绑币',
0 => '平台币',
1 => '支付宝',
2 => '微信',
3 => '微信APP',
9 => '双乾支付',
15 => '双乾支付-快捷',
17 => '易宝支付'
];
public static $payStatusList = [
self::STATUS_FAILED => '失败',
self::STATUS_SUCCESS => '成功',
];
public function getPayWayTextAttribute()
{
return self::$payWays[$this->pay_way] ?? '未知';
}
public function getDeviceTypeNameAttribute()
{
return DeviceType::getDeviceTypeText($this->sdk_version);
}
public function getPayStatusTextAttribute()
{
return self::$payStatusList[$this->pay_status] ?? '未知';
}
public function promote()
{
return $this->belongsTo(Promote::class, 'promote_id', 'id');
}
public function isSuccess()
{
return $this->pay_status === self::STATUS_SUCCESS;
}
}