PtActivity.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use app\jobs\storeSync\DiyCommon;
  9. use yii\behaviors\TimestampBehavior;
  10. use yii\db\ActiveRecord;
  11. /**
  12. * This is the model class for table "{{%pt_activity}}".
  13. *
  14. * @property integer $id
  15. * @property string $name
  16. * @property integer $start_time
  17. * @property integer $end_time
  18. * @property integer $party_size
  19. * @property integer $party_winner_size
  20. * @property integer $split_time
  21. * @property integer $join_num
  22. * @property integer $created_at
  23. * @property integer $updated_at
  24. * @property integer $is_delete
  25. * @property integer $store_id
  26. * @property integer $status
  27. * @property string $rules
  28. * @property integer $head_is_free
  29. * @property integer $head_integral
  30. * @property integer $is_platform
  31. * @property integer $is_platform_audit
  32. * @property integer $order_goods_limit
  33. */
  34. class PtActivity extends \yii\db\ActiveRecord
  35. {
  36. /**
  37. * @inheritdoc
  38. */
  39. public static function tableName()
  40. {
  41. return '{{%pt_activity}}';
  42. }
  43. public function behaviors()
  44. {
  45. return [
  46. [
  47. 'class' => TimestampBehavior::class,
  48. 'attributes' => [
  49. ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
  50. ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
  51. ]
  52. ]
  53. ];
  54. }
  55. /**
  56. * @inheritdoc
  57. */
  58. public function rules()
  59. {
  60. return [
  61. [['id', 'start_time', 'end_time', 'party_size', 'join_num', 'is_delete', 'store_id', 'status', 'split_time', 'party_winner_size', 'head_is_free', 'head_integral', 'is_platform', 'is_platform_audit', 'order_goods_limit'], 'integer'],
  62. [['name', 'rules'], 'string'],
  63. [['created_at', 'updated_at', 'party_type', 'party_goods_count'], 'safe']
  64. ];
  65. }
  66. public function beforeSave($insert)
  67. {
  68. if (parent::beforeSave($insert)) {
  69. //$this->dirtyAttributes 改动的项目 改动的项目中不包含is_platform_audit时把is_platform_audit改为0
  70. if (intval($this->is_platform === 1) && !empty($this->dirtyAttributes) && !isset($this->dirtyAttributes['status']) && !in_array($this->dirtyAttributes['is_platform_audit'], [1, 2])) {
  71. $this->is_platform_audit = 0;
  72. }
  73. return true;
  74. }
  75. return false;
  76. }
  77. public function afterSave($insert, $changedAttributes)
  78. {
  79. parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
  80. (new DiyCommon)->JobBehaviors($this->store_id, StoreSyncExtLog::TYPE_PT, [$this->id]);
  81. }
  82. /**
  83. * @inheritdoc
  84. */
  85. public function attributeLabels()
  86. {
  87. return [
  88. 'id' => 'ID',
  89. 'name' => '活动名称',
  90. 'start_time' => '开始时间',
  91. 'end_time' => '结束时间',
  92. 'party_size' => '成团人数',
  93. 'join_num' => '每人参加次数',
  94. 'created_at' => '创建时间',
  95. 'updated_at' => '修改时间',
  96. 'is_delete' => 'is_delete',
  97. 'store_id' => 'Store Id',
  98. 'status' => '状态',
  99. 'split_time' => '解散时间',
  100. 'rules' => '活动规则',
  101. 'party_winner_size' => '拼团成功人数',
  102. 'head_integral' => '团长开团消耗积分数量',
  103. 'head_is_free' => '团长是否免单',
  104. 'is_platform' => '是否是平台活动',
  105. 'is_platform_audit' => '平台是否审核活动'
  106. ];
  107. }
  108. }