64], [['change_type'], 'string', 'max' => 12], [['source_table', 'desc'], 'string', 'max' => 255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'setting_id' => 'Setting ID', 'goods_id' => 'Goods ID', 'user_id' => 'User ID', 'change_num' => 'Change Num', 'current_num' => 'Current Num', 'order_no' => 'Order No', 'source_table' => 'Source Table', 'source_table_id' => 'Source Table ID', 'desc' => 'Desc', 'status' => 'Status', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'change_type' => 'Change Type', 'store_id' => 'Store Id', ]; } /** * 保存数据 * @Author: lun * @DateTime: 2021/10/20 0020 18:01 * @Copyright: copyright (c) 2021 广东七件事集团 * @param array $params * @return AddonsBossLevel|bool */ public static function setData(array $params){ $trans = Yii::$app->db->beginTransaction(); try{ if(!empty($params['id'])){ $model = self::findOne(['and',['id' => $params['id'],'mall_id' => $params['mall_id']],['<>','status',StatusEnum::DELETE]]); if(empty($model)) throw new \Exception('数据不存在或已删除'); }else{ $model = new self(); $model->loadDefaultValues(); $model->mall_id = $params['mall_id']; } if(!$model->load($params,'') || !$model->save()){ throw new \Exception($model->getErrorMessage()); } $trans->commit(); return $model; }catch(\Exception $e){ $trans->rollBack(); self::$static_error = $e->getMessage(); return false; } } }