| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- /**
- * 厦门云联储网络科技有限公司
- * https://www.baokuaiyun.com
- * Copyright (c) 2023 爆块云 All rights reserved.
- */
- namespace app\models;
- use yii\behaviors\TimestampBehavior;
- use yii\db\ActiveRecord;
- /**
- * This is the model class for table "{{%activity_new_user_goods}}".
- *
- * @property integer $id
- * @property integer $activity_id
- * @property integer $goods_id
- * @property string $attr
- * @property integer $virtual_sales
- * @property float $price
- * @property integer $store_id
- * @property integer $is_delete
- * @property integer $created_at
- * @property integer $updated_at
- * @property integer $use_attr
- * @property integer $sale_num
- */
- class FreeQueueGoods extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%free_queue_goods}}';
- }
- 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', 'goods_id', 'virtual_sales', 'store_id', 'is_delete', 'activity_id', 'use_attr', 'sale_num'], 'integer'],
- [['attr'], 'string'],
- [['price'], 'number'],
- [['created_at', 'updated_at'], 'safe']
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'activity_id' => '活动ID',
- 'goods_id' => '商品ID',
- 'attr' => '商品规格',
- 'virtual_sales' => '虚拟销量',
- 'price' => '活动价格',
- 'store_id' => 'Store Id',
- 'is_delete' => 'Is Delete',
- 'created_at' => '创建时间',
- 'updated_at' => '修改时间',
- 'use_attr' => '是否使用规格',
- ];
- }
- public static function saveAll($list, $activity_id)
- {
- // 删除旧数据
- self::deleteAll(['activity_id' => $activity_id]);
- // 添加新数据
- foreach ($list as $item) {
- $model = new self();
- $model->attributes = $item;
- $model->save();
- }
- }
- }
|