90 lines
2.6 KiB
PHP
90 lines
2.6 KiB
PHP
<?php
|
||
/**
|
||
* Created by PhpStorm.
|
||
* User: zn
|
||
* Date: 2017/6/13
|
||
* Time: 14:42
|
||
*/
|
||
|
||
namespace common\modules\rebate;
|
||
|
||
|
||
use common\models\User;
|
||
use common\utils\CommUtil;
|
||
use yii\behaviors\TimestampBehavior;
|
||
use yii\db\ActiveRecord;
|
||
|
||
/**
|
||
CREATE TABLE `farm_rebate` (
|
||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||
`from_user_id` int(11) NOT NULL COMMENT '发起操作的用户',
|
||
`be_user_id` int(11) NOT NULL COMMENT '受到返点的用户ID',
|
||
`rebate_gold` int(11) NOT NULL DEFAULT '0' COMMENT '返点金币',
|
||
`level` int(11) NOT NULL DEFAULT '1' COMMENT '几级返点,1,2,3',
|
||
`type` int(11) NOT NULL DEFAULT '0' COMMENT '返点类型,推广、买卖等等',
|
||
`created_at` int(11) NOT NULL DEFAULT '0',
|
||
`updated_at` int(11) NOT NULL DEFAULT '0',
|
||
PRIMARY KEY (`id`),
|
||
KEY `i_from_user_id` (`from_user_id`),
|
||
KEY `i_be_user_id` (`be_user_id`),
|
||
KEY `i_level` (`level`),
|
||
KEY `i_created_at` (`created_at`),
|
||
KEY `i_updated_at` (`updated_at`),
|
||
KEY `i_type` (`type`)
|
||
) ENGINE=InnoDB AUTO_INCREMENT=10530 DEFAULT CHARSET=utf8 COMMENT='返点信息记录'
|
||
|
||
*/
|
||
|
||
/**
|
||
* 推广盈利
|
||
* Class Rebate
|
||
* @property int $id
|
||
* @property int $from_user_id 发起操作的用户
|
||
* @property int $be_user_id 受到返点的用户ID
|
||
* @property int $rebate_gold 返点金币
|
||
* @property int $level 几级返点,1,2,3
|
||
* @property int $type 返点类型,推广、买卖等等
|
||
* @property int $created_at
|
||
* @property int $updated_at
|
||
*/
|
||
class Rebate extends ActiveRecord
|
||
{
|
||
public function behaviors()
|
||
{
|
||
return [
|
||
TimestampBehavior::className(),
|
||
];
|
||
}
|
||
|
||
public function rules()
|
||
{
|
||
return [
|
||
['from_user_id', 'required'],
|
||
['from_user_id', 'exist', 'targetClass' => '\common\models\User', 'targetAttribute' => 'id'],
|
||
|
||
['be_user_id', 'required'],
|
||
['be_user_id', 'exist', 'targetClass' => '\common\models\User', 'targetAttribute' => 'id'],
|
||
|
||
['level', 'default', 'value' => 1],
|
||
['level', 'number', 'min' => RebateUtil::MIN_LEVEL, 'max' => RebateUtil::MAX_LEVEL],
|
||
|
||
['type', 'in', 'range' => RebateUtil::TYPE_LIST],
|
||
|
||
['created_at', 'default', 'value' => 0],
|
||
['updated_at', 'default', 'value' => 0],
|
||
];
|
||
}
|
||
|
||
public function genClientData()
|
||
{
|
||
return [
|
||
'from_user_id' => $this->from_user_id,
|
||
'be_user_id' => $this->be_user_id,
|
||
'rebate_gold' => $this->rebate_gold,
|
||
'level' => $this->level,
|
||
'type' => $this->type,
|
||
'created_at' => $this->created_at,
|
||
'updated_at' => $this->updated_at,
|
||
];
|
||
}
|
||
} |