Salesmannew.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use Yii;
  9. use yii\behaviors\TimestampBehavior;
  10. use yii\db\ActiveRecord;
  11. /**
  12. * This is the model class for table "{{%salesman}}".
  13. *
  14. * @property integer $id
  15. * @property integer $saas_user_id
  16. * @property integer $admin_id
  17. * @property integer $type
  18. * @property integer $is_delete
  19. * @property integer $created_at
  20. * @property integer $updated_at
  21. * @property integer $status
  22. */
  23. class Salesmannew extends \yii\db\ActiveRecord
  24. {
  25. const TYPE_DEFAULT = 0; //默认类型
  26. const TYPE_BD = 1; //推广代理下业务员
  27. /**
  28. * @inheritdoc
  29. */
  30. public static function tableName()
  31. {
  32. return '{{%salesmannew}}';
  33. }
  34. public function behaviors()
  35. {
  36. return [
  37. [
  38. 'class' => TimestampBehavior::class,
  39. 'attributes' => [
  40. ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
  41. ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
  42. ]
  43. ]
  44. ];
  45. }
  46. /**
  47. * @inheritdoc
  48. */
  49. public function rules()
  50. {
  51. return [
  52. [['id', 'saas_user_id', 'admin_id', 'type', 'is_delete', 'created_at', 'updated_at', 'status'], 'integer'],
  53. ['weight', 'number'],
  54. ];
  55. }
  56. public function beforeSave($insert) {
  57. if (parent::beforeSave($insert)) {
  58. if($insert){
  59. //业务员类型,默认新业务员类型(2023-02-06版本以后为新类型)
  60. $this->type = self::TYPE_BD;
  61. }
  62. return true;
  63. }
  64. return false;
  65. }
  66. }