64 lines
1.7 KiB
PHP
64 lines
1.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2021年6月11日
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
namespace app\models\common\payment;
|
|
|
|
|
|
use app\models\UniqueOrderNo;
|
|
use app\models\Model;
|
|
use app\models\User;
|
|
|
|
class PaymentTransfer extends Model
|
|
{
|
|
const TRANSFER_TYPE_WXPAY = 1;
|
|
const TRANSFER_TYPE_ALIPAY = 2;
|
|
|
|
public $cx_mch_id;
|
|
public $amount;
|
|
public $title;
|
|
public $user;
|
|
public $order_no;
|
|
public $transfer_type;
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['order_no', 'amount', 'user', 'title', 'transfer_type', 'cx_mch_id'], 'required'],
|
|
['order_no', 'string', 'max' => 32],
|
|
[['title'], 'string', 'max' => 128],
|
|
[['amount'], function ($attribute, $params) {
|
|
if (!is_float($this->amount) && !is_int($this->amount) && !is_double($this->amount)) {
|
|
$this->addError($attribute, '`amount`必须是数字类型。');
|
|
}
|
|
}],
|
|
[['amount'], 'number', 'min' => 0.01, 'max' => 100000000],
|
|
[['transfer_type'], 'in', 'range' => [1,2]],//@TODO 其他
|
|
['user', function ($attribute, $param) {
|
|
if (!$this->user instanceof User) {
|
|
$this->addError($attribute, 'user必须是app\\models\User的对象');
|
|
}
|
|
}]
|
|
];
|
|
}
|
|
|
|
/**
|
|
* PaymentTransfer constructor.
|
|
* @param array $config
|
|
*/
|
|
public function __construct(array $config = [])
|
|
{
|
|
parent::__construct($config);
|
|
if(!$this->validate()){
|
|
$this->dde($this->errors);
|
|
}
|
|
}
|
|
}
|