This commit is contained in:
技术老胡
2026-04-01 14:30:50 +08:00
parent 0eee3b92c2
commit d34bd386ec
15 changed files with 542 additions and 186 deletions

View File

@@ -9,19 +9,25 @@ use app\common\base\BaseModel;
*/
class Merchant extends BaseModel
{
protected $table = 'ma_merchant';
protected $table = 'ma_mer';
protected $fillable = [
'merchant_no',
'merchant_name',
'balance',
'email',
'funds_mode',
'status',
'remark',
'extra',
];
public $timestamps = true;
protected $casts = [
'balance' => 'decimal:2',
'status' => 'integer',
'extra' => 'array',
];
}

View File

@@ -9,22 +9,65 @@ use app\common\base\BaseModel;
*/
class MerchantApp extends BaseModel
{
protected $table = 'ma_merchant_app';
protected $table = 'ma_pay_app';
protected $fillable = [
'merchant_id',
'mer_id',
'api_type',
'app_id',
'app_code',
'app_secret',
'app_name',
'status',
'remark',
'package_code',
'notify_url',
'return_url',
'callback_mode',
'sign_type',
'order_expire_minutes',
'callback_retry_limit',
'ip_whitelist',
'amount_min',
'amount_max',
'daily_limit',
'notify_enabled',
'extra',
];
public $timestamps = true;
protected $appends = ['merchant_id', 'app_id'];
protected $casts = [
'merchant_id' => 'integer',
'mer_id' => 'integer',
'order_expire_minutes' => 'integer',
'callback_retry_limit' => 'integer',
'amount_min' => 'decimal:2',
'amount_max' => 'decimal:2',
'daily_limit' => 'decimal:2',
'notify_enabled' => 'integer',
'status' => 'integer',
'extra' => 'array',
];
public function getMerchantIdAttribute()
{
return $this->attributes['mer_id'] ?? null;
}
public function setMerchantIdAttribute($value): void
{
$this->attributes['mer_id'] = (int)$value;
}
public function getAppIdAttribute()
{
return $this->attributes['app_code'] ?? null;
}
public function setAppIdAttribute($value): void
{
$this->attributes['app_code'] = (string)$value;
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace app\models;
use app\common\base\BaseModel;
/**
* 商户后台用户模型
*/
class MerchantUser extends BaseModel
{
protected $table = 'ma_mer_user';
protected $fillable = [
'mer_id',
'username',
'password',
'nick_name',
'avatar',
'mobile',
'email',
'role_code',
'is_owner',
'status',
'login_ip',
'login_at',
];
public $timestamps = true;
protected $appends = ['merchant_id'];
protected $casts = [
'mer_id' => 'integer',
'is_owner' => 'integer',
'status' => 'integer',
'login_at' => 'datetime',
];
protected $hidden = ['password'];
public function getMerchantIdAttribute()
{
return $this->attributes['mer_id'] ?? null;
}
public function setMerchantIdAttribute($value): void
{
$this->attributes['mer_id'] = (int)$value;
}
}

View File

@@ -14,13 +14,13 @@ class PaymentChannel extends BaseModel
protected $table = 'ma_pay_channel';
protected $fillable = [
'merchant_id',
'merchant_app_id',
'mer_id',
'app_id',
'chan_code',
'chan_name',
'plugin_code',
'method_id',
'config_json',
'pay_type_id',
'config',
'split_ratio',
'chan_cost',
'chan_mode',
@@ -34,13 +34,16 @@ class PaymentChannel extends BaseModel
public $timestamps = true;
protected $appends = ['merchant_id', 'merchant_app_id', 'method_id', 'config_json'];
protected $casts = [
'merchant_id' => 'integer',
'merchant_app_id' => 'integer',
'method_id' => 'integer',
'config_json' => 'array',
'mer_id' => 'integer',
'app_id' => 'integer',
'pay_type_id' => 'integer',
'config' => 'array',
'split_ratio' => 'decimal:2',
'chan_cost' => 'decimal:2',
'chan_mode' => 'integer',
'daily_limit' => 'decimal:2',
'daily_cnt' => 'integer',
'min_amount' => 'decimal:2',
@@ -51,7 +54,7 @@ class PaymentChannel extends BaseModel
public function getConfigArray(): array
{
return $this->config_json ?? [];
return $this->config ?? [];
}
public function getEnabledProducts(): array
@@ -59,4 +62,44 @@ class PaymentChannel extends BaseModel
$config = $this->getConfigArray();
return $config['enabled_products'] ?? [];
}
public function getMerchantIdAttribute()
{
return $this->attributes['mer_id'] ?? null;
}
public function setMerchantIdAttribute($value): void
{
$this->attributes['mer_id'] = (int)$value;
}
public function getMerchantAppIdAttribute()
{
return $this->attributes['app_id'] ?? null;
}
public function setMerchantAppIdAttribute($value): void
{
$this->attributes['app_id'] = (int)$value;
}
public function getMethodIdAttribute()
{
return $this->attributes['pay_type_id'] ?? null;
}
public function setMethodIdAttribute($value): void
{
$this->attributes['pay_type_id'] = (int)$value;
}
public function getConfigJsonAttribute()
{
return $this->attributes['config'] ?? [];
}
public function setConfigJsonAttribute($value): void
{
$this->attributes['config'] = $value;
}
}

View File

@@ -11,11 +11,11 @@ use app\common\base\BaseModel;
*/
class PaymentMethod extends BaseModel
{
protected $table = 'ma_pay_method';
protected $table = 'ma_pay_type';
protected $fillable = [
'method_code',
'method_name',
'type',
'name',
'icon',
'sort',
'status',
@@ -23,8 +23,30 @@ class PaymentMethod extends BaseModel
public $timestamps = true;
protected $appends = ['method_code', 'method_name'];
protected $casts = [
'sort' => 'integer',
'status' => 'integer',
];
public function getMethodCodeAttribute()
{
return $this->attributes['type'] ?? null;
}
public function setMethodCodeAttribute($value): void
{
$this->attributes['type'] = (string)$value;
}
public function getMethodNameAttribute()
{
return $this->attributes['name'] ?? null;
}
public function setMethodNameAttribute($value): void
{
$this->attributes['name'] = (string)$value;
}
}