SeckillActivityGoods.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 "{{%seckill_activity_goods}}".
  13. *
  14. * @property integer $id
  15. * @property integer $goods_id
  16. * @property string $attr
  17. * @property integer $virtual_sales
  18. * @property integer $virtual_num
  19. * @property integer $seckill_num
  20. * @property float $seckill_price
  21. * @property integer $store_id
  22. * @property integer $is_delete
  23. * @property integer $activity_id
  24. * @property integer $created_at
  25. * @property integer $updated_at
  26. * @property integer $use_attr
  27. * @property integer $sale_num
  28. */
  29. class SeckillActivityGoods extends \yii\db\ActiveRecord
  30. {
  31. /**
  32. * @inheritdoc
  33. */
  34. public static function tableName()
  35. {
  36. return '{{%seckill_activity_goods}}';
  37. }
  38. public function behaviors()
  39. {
  40. return [
  41. [
  42. 'class' => TimestampBehavior::class,
  43. 'attributes' => [
  44. ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
  45. ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
  46. ]
  47. ]
  48. ];
  49. }
  50. /**
  51. * @inheritdoc
  52. */
  53. public function rules()
  54. {
  55. return [
  56. [['id', 'goods_id', 'virtual_sales', 'virtual_num', 'seckill_num', 'store_id', 'is_delete', 'activity_id', 'use_attr', 'sale_num'], 'integer'],
  57. [['attr'], 'string'],
  58. [['seckill_price'], 'number'],
  59. [['created_at', 'updated_at', 'virtual_num'], 'safe']
  60. ];
  61. }
  62. /**
  63. * @inheritdoc
  64. */
  65. public function attributeLabels()
  66. {
  67. return [
  68. 'id' => 'ID',
  69. 'goods_id' => '商品ID',
  70. 'attr' => '商品规格',
  71. 'virtual_sales' => '虚拟销量',
  72. 'virtual_num' => '虚拟库存',
  73. 'seckill_num' => '秒杀数量',
  74. 'seckill_price' => '秒杀单价',
  75. 'store_id' => 'Store Id',
  76. 'is_delete' => 'Is Delete',
  77. 'activity_id' => '活动ID',
  78. 'created_at' => '创建时间',
  79. 'updated_at' => '修改时间',
  80. 'use_attr' => '是否使用规格',
  81. 'sale_num' => '销售数量'
  82. ];
  83. }
  84. public function afterSave($insert, $changedAttributes)
  85. {
  86. parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
  87. (new DiyCommon)->JobBehaviors($this->activity_id, StoreSyncExtLog::TYPE_SECKILL);
  88. }
  89. }