更新数据库结构

This commit is contained in:
技术老胡
2026-03-10 13:47:28 +08:00
parent 54ad21ac8f
commit 9de902231f
54 changed files with 5070 additions and 501 deletions

36
app/models/Admin.php Normal file
View File

@@ -0,0 +1,36 @@
<?php
namespace app\models;
use app\common\base\BaseModel;
/**
* 管理员模型
*
* 对应表ma_admin
*/
class Admin extends BaseModel
{
protected $table = 'ma_admin';
protected $fillable = [
'user_name',
'password',
'nick_name',
'avatar',
'mobile',
'email',
'status',
'login_ip',
'login_at',
];
public $timestamps = true;
protected $casts = [
'status' => 'integer',
'login_at' => 'datetime',
];
protected $hidden = ['password'];
}

27
app/models/Merchant.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
namespace app\models;
use app\common\base\BaseModel;
/**
* 商户模型
*/
class Merchant extends BaseModel
{
protected $table = 'ma_merchant';
protected $fillable = [
'merchant_no',
'merchant_name',
'funds_mode',
'status',
];
public $timestamps = true;
protected $casts = [
'status' => 'integer',
];
}

View File

@@ -0,0 +1,30 @@
<?php
namespace app\models;
use app\common\base\BaseModel;
/**
* 商户应用模型
*/
class MerchantApp extends BaseModel
{
protected $table = 'ma_merchant_app';
protected $fillable = [
'merchant_id',
'api_type',
'app_id',
'app_secret',
'app_name',
'status',
];
public $timestamps = true;
protected $casts = [
'merchant_id' => 'integer',
'status' => 'integer',
];
}

View File

@@ -0,0 +1,33 @@
<?php
namespace app\models;
use app\common\base\BaseModel;
/**
* 支付回调日志模型
*
* 对应表ma_pay_callback_log
*/
class PaymentCallbackLog extends BaseModel
{
protected $table = 'ma_pay_callback_log';
protected $fillable = [
'order_id',
'channel_id',
'callback_type',
'request_data',
'verify_status',
'process_status',
'process_result',
];
public $timestamps = true;
protected $casts = [
'channel_id' => 'integer',
'verify_status' => 'integer',
'process_status' => 'integer',
];
}

View File

@@ -0,0 +1,62 @@
<?php
namespace app\models;
use app\common\base\BaseModel;
/**
* 支付通道模型
*
* 对应表ma_pay_channel
*/
class PaymentChannel extends BaseModel
{
protected $table = 'ma_pay_channel';
protected $fillable = [
'merchant_id',
'merchant_app_id',
'chan_code',
'chan_name',
'plugin_code',
'method_id',
'config_json',
'split_ratio',
'chan_cost',
'chan_mode',
'daily_limit',
'daily_cnt',
'min_amount',
'max_amount',
'status',
'sort',
];
public $timestamps = true;
protected $casts = [
'merchant_id' => 'integer',
'merchant_app_id' => 'integer',
'method_id' => 'integer',
'config_json' => 'array',
'split_ratio' => 'decimal:2',
'chan_cost' => 'decimal:2',
'daily_limit' => 'decimal:2',
'daily_cnt' => 'integer',
'min_amount' => 'decimal:2',
'max_amount' => 'decimal:2',
'status' => 'integer',
'sort' => 'integer',
];
public function getConfigArray(): array
{
return $this->config_json ?? [];
}
public function getEnabledProducts(): array
{
$config = $this->getConfigArray();
return $config['enabled_products'] ?? [];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace app\models;
use app\common\base\BaseModel;
/**
* 支付方式模型
*
* 对应表ma_pay_method
*/
class PaymentMethod extends BaseModel
{
protected $table = 'ma_pay_method';
protected $fillable = [
'method_code',
'method_name',
'icon',
'sort',
'status',
];
public $timestamps = true;
protected $casts = [
'sort' => 'integer',
'status' => 'integer',
];
}

View File

@@ -0,0 +1,42 @@
<?php
namespace app\models;
use app\common\base\BaseModel;
/**
* 商户通知任务模型
*
* 对应表ma_notify_task
*/
class PaymentNotifyTask extends BaseModel
{
protected $table = 'ma_notify_task';
protected $fillable = [
'order_id',
'merchant_id',
'merchant_app_id',
'notify_url',
'notify_data',
'status',
'retry_cnt',
'next_retry_at',
'last_notify_at',
'last_response',
];
public $timestamps = true;
protected $casts = [
'merchant_id' => 'integer',
'merchant_app_id' => 'integer',
'retry_cnt' => 'integer',
'next_retry_at' => 'datetime',
'last_notify_at' => 'datetime',
];
const STATUS_PENDING = 'PENDING';
const STATUS_SUCCESS = 'SUCCESS';
const STATUS_FAIL = 'FAIL';
}

View File

@@ -0,0 +1,62 @@
<?php
namespace app\models;
use app\common\base\BaseModel;
/**
* 支付订单模型
*
* 对应表ma_pay_order
*/
class PaymentOrder extends BaseModel
{
protected $table = 'ma_pay_order';
protected $fillable = [
'order_id',
'merchant_id',
'merchant_app_id',
'mch_order_no',
'method_id',
'channel_id',
'amount',
'real_amount',
'fee',
'currency',
'subject',
'body',
'status',
'chan_order_no',
'chan_trade_no',
'pay_at',
'expire_at',
'client_ip',
'notify_stat',
'notify_cnt',
'extra',
];
public $timestamps = true;
protected $casts = [
'merchant_id' => 'integer',
'merchant_app_id' => 'integer',
'method_id' => 'integer',
'channel_id' => 'integer',
'amount' => 'decimal:2',
'real_amount' => 'decimal:2',
'fee' => 'decimal:2',
'status' => 'integer',
'notify_stat' => 'integer',
'notify_cnt' => 'integer',
'extra' => 'array',
'pay_at' => 'datetime',
'expire_at' => 'datetime',
];
const STATUS_PENDING = 0;
const STATUS_SUCCESS = 1;
const STATUS_FAIL = 2;
const STATUS_CLOSED = 3;
}

View File

@@ -0,0 +1,34 @@
<?php
namespace app\models;
use app\common\base\BaseModel;
/**
* 支付插件模型
*
* 对应表ma_pay_plugin主键 plugin_code
*/
class PaymentPlugin extends BaseModel
{
protected $table = 'ma_pay_plugin';
protected $primaryKey = 'plugin_code';
public $incrementing = false;
protected $keyType = 'string';
protected $fillable = [
'plugin_code',
'plugin_name',
'class_name',
'status',
];
public $timestamps = true;
protected $casts = [
'status' => 'integer',
];
}

View File

@@ -1,30 +0,0 @@
<?php
namespace app\models;
use app\common\base\BaseModel;
/**
* 用户模型
*
* 对应表users
*/
class User extends BaseModel
{
/**
* 表名
*
* @var string
*/
protected $table = 'users';
/**
* 关联角色(多对多)
*/
public function roles()
{
return $this->belongsToMany(Role::class, 'role_user', 'user_id', 'role_id');
}
}