cxgj/models/PaymentOrderUnion.php
2023-11-27 09:45:13 +08:00

109 lines
3.2 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\models;
use Yii;
use app\models\Model;
/**
* This is the model class for table "{{%payment_order_union}}".
*
* @property int $id ID
* @property int $cx_mch_id 平台商户ID
* @property int $user_id 用户ID
* @property string $order_no 订单号
* @property float $amount 订单金额
* @property int $is_pay 支付状态0=未支付1=已支付
* @property int $pay_type 支付方式
* @property string $title 支付摘要
* @property string $support_pay_types 支持的支付方式JSON
* @property int|null $created_at 添加时间
* @property int|null $updated_at 更新时间
* @property string $out_trade_no 商户订单号
* @property string $transaction_id 交易流水号
*/
class PaymentOrderUnion extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return '{{%payment_order_union}}';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['order_no', 'support_pay_types', 'out_trade_no', 'transaction_id'], 'trim'],
[['cx_mch_id', 'order_no', 'amount', 'title', 'support_pay_types'], 'required'],
[['cx_mch_id', 'user_id', 'is_pay', 'pay_type', 'created_at', 'updated_at'], 'integer'],
[['amount'], 'number'],
[['support_pay_types'], 'string'],
[['order_no', 'out_trade_no', 'transaction_id'], 'string', 'max' => 64],
[['title'], 'string', 'max' => 128],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'cx_mch_id' => '平台商户ID',
'user_id' => '用户ID',
'order_no' => '订单号',
'amount' => '订单金额',
'is_pay' => '支付状态0=未支付1=已支付',
'pay_type' => '支付方式',
'title' => '支付摘要',
'support_pay_types' => '支持的支付方式JSON',
'created_at' => '添加时间',
'updated_at' => '更新时间',
'out_trade_no' => '商户订单号',
'transaction_id' => '交易流水号',
];
}
public function beforeSave($insert) {
if(parent::beforeSave($insert)){
if($this->isNewRecord){
$this->created_at = time();
}
$this->updated_at = time();
$this->htmlTagFilter();
return true;
} else {
return false;
}
}
public function htmlTagFilter()
{
$this->title = Model::htmlTagFilter($this->title);
}
public function encodeSupportPayTypes($data)
{
$serializer = new \app\components\Serializer();
return $serializer->encode($data);
}
public function decodeSupportPayTypes($data)
{
$serializer = new \app\components\Serializer();
return $serializer->decode($data);
}
public function getPaymentOrder()
{
return $this->hasMany(PaymentOrder::className(), ['payment_order_union_id' => 'id']);
}
}