108 lines
2.6 KiB
PHP
108 lines
2.6 KiB
PHP
<?php
|
||
|
||
namespace common\modules\qixunpay\vo;
|
||
|
||
use common\modules\qixunpay\PayUtil;
|
||
use Yii;
|
||
use yii\behaviors\TimestampBehavior;
|
||
use yii\db\ActiveRecord;
|
||
|
||
/**
|
||
*
|
||
CREATE TABLE `pay` (
|
||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||
`user_id` int(11) NOT NULL,
|
||
`order_id` int(11) NOT NULL,
|
||
`price` decimal(10,2) NOT NULL,
|
||
`gem` int(11) NOT NULL COMMENT '钻石',
|
||
`status` int(11) NOT NULL COMMENT '状态',
|
||
`pay_from` int(11) NOT NULL COMMENT '支付平台',
|
||
`config_id` int(11) NOT NULL,
|
||
`created_at` int(11) DEFAULT NULL,
|
||
`updated_at` int(11) DEFAULT NULL,
|
||
PRIMARY KEY (`id`),
|
||
KEY `user_id` (`user_id`),
|
||
KEY `order_id` (`order_id`),
|
||
KEY `price` (`price`),
|
||
KEY `status` (`status`),
|
||
KEY `pay_from` (`pay_from`),
|
||
KEY `created_at` (`created_at`),
|
||
KEY `updated_at` (`updated_at`)
|
||
) ENGINE=InnoDB AUTO_INCREMENT=301 DEFAULT CHARSET=utf8 COMMENT='充值情况'
|
||
*/
|
||
|
||
/**
|
||
* 充值情况
|
||
* @property int $id
|
||
* @property int $user_id
|
||
* @property int $order_id
|
||
* @property float $price
|
||
* @property int $gem//钻石
|
||
* @property int $status //状态
|
||
* @property int $pay_from //支付平台
|
||
* @property int $config_id
|
||
* @property int $config_type //configID字段所属类型,0:充值,1:周卡月卡
|
||
* @property int $created_at
|
||
* @property int $updated_at
|
||
*/
|
||
class Pay extends ActiveRecord
|
||
{
|
||
public function behaviors()
|
||
{
|
||
return [
|
||
TimestampBehavior::className(),
|
||
];
|
||
}
|
||
|
||
public function rules()
|
||
{
|
||
return [
|
||
['id', 'default', 'value' => 0],
|
||
|
||
['user_id', 'required'],
|
||
['user_id', 'exist', 'targetClass' => '\common\models\User', 'targetAttribute' => 'id'],
|
||
|
||
['order_id', 'required'],
|
||
['order_id', 'trim'],
|
||
|
||
['price', 'required'],
|
||
|
||
['gem', 'default', 'value' => 0],
|
||
|
||
['status', 'required'],
|
||
['status', 'in', 'range' => PayUtil::PAY_STATUS_LIST],
|
||
|
||
['pay_from', 'default', 'value' => 0],
|
||
|
||
['config_id', 'required'],
|
||
|
||
['config_type', 'default', 'value' => 0],
|
||
|
||
['created_at', 'default', 'value' => 0],
|
||
['updated_at', 'default', 'value' => 0],
|
||
];
|
||
}
|
||
|
||
/**
|
||
* @param $orderID
|
||
* @return Pay
|
||
*/
|
||
public static function findByOrderID($orderID)
|
||
{
|
||
return self::findOne(['order_id' => $orderID]);
|
||
}
|
||
|
||
public static function getPayGroupBy($userID)
|
||
{
|
||
$mysql = '
|
||
SELECT count(id) as count ,config_id FROM pay where user_id=:user_id group by config_id
|
||
';
|
||
|
||
$listDbData = Yii::$app->db->createCommand($mysql)
|
||
->bindValue(':user_id', $userID)
|
||
->queryAll();
|
||
|
||
return $listDbData;
|
||
}
|
||
}
|