| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?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 "{{%activity_rebate_order_self_goods}}".
- *
- * @property integer $id
- */
- class ActivityOrderRebateSelfGoods extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%activity_rebate_order_self_goods}}';
- }
- public function behaviors()
- {
- return [];
- }
-
- public static function saveList($gids = [], $activity_id = 0) {
- if($activity_id){
- $oldList = self::find()->where(['act_id' => $activity_id])->select('goods_id')->column();
- $delGids = array_diff($oldList, $gids);
- $addGids = array_diff($gids, $oldList);
- if($delGids){
- self::deleteAll(['act_id' => $activity_id, 'goods_id' => $delGids]);
- }
- foreach($addGids as $item){
- $model = new self();
- $model->act_id = $activity_id;
- $model->goods_id = $item;
- $save = $model->save();
- if(!$save){
- \Yii::error([__METHOD__, $model->attributes]);
- return [
- 'code' => 1,
- 'msg' => '商品信息保存失败:' . array_shift($model->getFirstErrors()),
- ];
- }
- }
- }
- return [
- 'code' => 0,
- 'msg' => 'ok',
- ];
- }
- }
|