| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- /**
- * 厦门云联储网络科技有限公司
- * https://www.baokuaiyun.com
- * Copyright (c) 2023 爆块云 All rights reserved.
- */
- namespace app\models;
- use Yii;
- use yii\behaviors\TimestampBehavior;
- use yii\db\ActiveRecord;
- /**
- * This is the model class for table "{{%salesman}}".
- *
- * @property integer $id
- * @property integer $saas_user_id
- * @property integer $admin_id
- * @property integer $type
- * @property integer $is_delete
- * @property integer $created_at
- * @property integer $updated_at
- * @property integer $status
- */
- class Salesmannew extends \yii\db\ActiveRecord
- {
- const TYPE_DEFAULT = 0; //默认类型
- const TYPE_BD = 1; //推广代理下业务员
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%salesmannew}}';
- }
- public function behaviors()
- {
- return [
- [
- 'class' => TimestampBehavior::class,
- 'attributes' => [
- ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
- ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
- ]
- ]
- ];
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['id', 'saas_user_id', 'admin_id', 'type', 'is_delete', 'created_at', 'updated_at', 'status'], 'integer'],
- ['weight', 'number'],
- ];
- }
-
- public function beforeSave($insert) {
- if (parent::beforeSave($insert)) {
- if($insert){
- //业务员类型,默认新业务员类型(2023-02-06版本以后为新类型)
- $this->type = self::TYPE_BD;
- }
- return true;
- }
- return false;
- }
- }
|