| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <?php
- namespace App\Module\Transfer\Models;
- use App\Module\Transfer\Casts\TransferAppCast;
- use UCore\ModelCore;
- /**
- * 划转应用配置模型
- *
- * field start
- * @property int $id 主键ID
- * @property string $keyname 应用标识符
- * @property string $title 应用显示名称
- * @property string $description 应用描述信息
- * @property int $out_id2 开放接口ID
- * @property int $out_id3 三方平台ID
- * @property int $currency_id 货币类型ID
- * @property int $fund_id 资金账户类型ID
- * @property int $fund_to_uid 转入目标账户UID
- * @property int $fund_in_uid 转入来源账户UID
- * @property float $exchange_rate 汇率(钱包:业务)
- * @property string $order_callback_url 结果通知API地址(为空则不通知)
- * @property string $order_in_info_url 转入查询API地址(为空则不查询)
- * @property string $order_out_create_url 转出创建API地址(为空则不创建)
- * @property string $order_out_info_url 转出查询API地址(为空则不查询)
- * @property bool $is_enabled 是否启用(1=启用,0=禁用)
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- * @property \Carbon\Carbon $deleted_at 删除时间
- * field end
- */
- class TransferApp extends ModelCore
- {
- /**
- * 数据表名
- */
- protected $table = 'transfer_apps';
- // attrlist start
- protected $fillable = [
- 'id',
- 'keyname',
- 'title',
- 'description',
- 'out_id2',
- 'out_id3',
- 'currency_id',
- 'fund_id',
- 'fund_to_uid',
- 'fund_in_uid',
- 'exchange_rate',
- 'order_callback_url',
- 'order_in_info_url',
- 'order_out_create_url',
- 'order_out_info_url',
- 'is_enabled',
- ];
- // attrlist end
- /**
- * 属性类型转换
- */
- protected $casts = [
- 'id' => 'integer',
- 'out_id2' => 'integer',
- 'out_id3' => 'integer',
- 'currency_id' => 'integer',
- 'fund_id' => 'integer',
- 'fund_to_uid' => 'integer',
- 'fund_in_uid' => 'integer',
- 'exchange_rate' => 'decimal:4',
- 'is_enabled' => 'boolean',
- 'created_at' => 'datetime',
- 'updated_at' => 'datetime',
- 'deleted_at' => 'datetime',
- ];
- /**
- * 软删除
- */
- protected $dates = ['deleted_at'];
- /**
- * 隐藏字段
- */
- protected $hidden = [];
- /**
- * 关联划转订单
- */
- public function orders()
- {
- return $this->hasMany(TransferOrder::class, 'transfer_app_id');
- }
- /**
- * 获取启用状态文本
- */
- public function getEnabledTextAttribute(): string
- {
- return $this->is_enabled ? '启用' : '禁用';
- }
- /**
- * 获取启用状态颜色
- */
- public function getEnabledColorAttribute(): string
- {
- return $this->is_enabled ? 'success' : 'danger';
- }
- /**
- * 判断是否为农场内部模式
- */
- public function isInternalMode(): bool
- {
- return empty($this->order_callback_url) &&
- empty($this->order_in_info_url) &&
- empty($this->order_out_create_url) &&
- empty($this->order_out_info_url);
- }
- /**
- * 判断是否支持转入
- */
- public function supportsTransferIn(): bool
- {
- return !empty($this->order_in_info_url) || $this->isInternalMode();
- }
- /**
- * 判断是否支持转出
- */
- public function supportsTransferOut(): bool
- {
- return !empty($this->order_out_create_url) || $this->isInternalMode();
- }
- /**
- * 判断是否支持回调
- */
- public function supportsCallback(): bool
- {
- return !empty($this->order_callback_url);
- }
- }
|