| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace common\models\goods;
- use addons\GroupBuy\common\enums\GroupBuyEnum;
- use common\enums\StatusEnum;
- use common\models\base\BaseActiveRecord;
- use Yii;
- /**
- * This is the model class for table "qimall_goods_marketing".
- *
- *
- * @property int $id
- * @property int $mall_id
- * @property int $goods_id 商品ID
- * @property int $marketing_id 营销ID
- * @property string $marketing_type 营销名称
- * @property int $status 状态[1正常 -1删除]
- * @property int $created_at 创建时间
- * @property int $updated_at 修改时间
- */
- class GoodsMarketing extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%goods_marketing}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id','goods_id', 'marketing_id', 'status', 'created_at', 'updated_at'], 'integer'],
- [['marketing_type'], 'string', 'max' => 255],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商品ID',
- 'goods_id' => '商品ID',
- 'marketing_id' => '营销ID',
- 'marketing_type' => '营销名称',
- 'status' => '状态[1正常 -1删除]',
- 'created_at' => '创建时间',
- 'updated_at' => '修改时间',
- ];
- }
- /**
- * @desc:保存数据
- * @Author: hua
- * @Date: 2022/1/6
- * @Time: 18:01
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param array $params
- * @return GoodsMarketing|false
- */
- public static function setData(array $params){
- try{
- if(!empty($params['mall_id'])&&!empty($params['marketing_id'])&&!empty($params['marketing_type'])){
- $model = self::findOne([
- 'mall_id' => $params['mall_id'],
- 'marketing_id'=>$params['marketing_id'],
- 'marketing_type'=>$params['marketing_type'],
- ]);
- if(empty($model)){
- $model = new self();
- $model->loadDefaultValues();
- }
- }else{
- $model = new self();
- $model->loadDefaultValues();
- }
- if(!$model->load($params,'') || !$model->save()){
- throw new \Exception($model->getErrorMessage());
- }
- return $model;
- }catch(\Exception $e){
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|