| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- namespace app\models;
- use yii\behaviors\TimestampBehavior;
- /**
- * This is the model class for table "{{%share_group_purchase_user}}".
- *
- * @property integer $id
- * @property integer $user_id
- * @property integer $parent_user_id
- * @property integer $store_id
- * @property float $direct_price
- * @property float $support_price
- * @property float $group_price
- * @property float $total_price
- * @property float $price
- * @property integer $created_at
- * @property integer $updated_at
- */
- class ShareGroupPurchaseUser extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%share_group_purchase_user}}';
- }
- public function behaviors()
- {
- return [
- [
- 'class' => TimestampBehavior::class
- ]
- ];
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['id', 'user_id', 'store_id', 'created_at', 'updated_at', 'parent_user_id'], 'integer'],
- [['direct_price', 'support_price', 'group_price', 'total_price', 'price'], 'number']
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => '',
- 'user_id' => '用户ID',
- 'parent_user_id' => '上级用户ID',
- 'store_id' => 'Store Id',
- 'direct_price' => '当前点位直推佣金',
- 'support_price' => '当前点位扶持佣金',
- 'group_price' => '成团佣金',
- 'total_price' => '累计佣金',
- 'price' => '可提现佣金',
- 'created_at' => '',
- 'updated_at' => '',
- ];
- }
- public function beforeSave($insert)
- {
- if (parent::beforeSave($insert)) {
- if ($insert) {
- $self = self::findOne(['user_id' => $this->user_id]);
- if ($self) {
- $this->addError('user', '用户已存在');
- return false;
- }
- }
- return true;
- }
- return false;
- }
- }
|