255], [['temp_content', 'temp_name'], 'string', 'max' => 1024], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => '自增id', 'temp_id' => '模板id', 'temp_content' => '模板内容', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'mall_id' => 'Mall ID', 'sms_key' => '键值', 'temp_name' => '模板名称', 'is_enable' => '是否开启通知;', 'status' => '状态[-1:删除;0:禁用;1启用]', ]; } /** * 保存数据 * @Author: ltm * @DateTime: 2022/6/8 0015 9:26 * @Copyright: copyright (c) 2021 * @param $mall_id * @param array $params * @return Rebate|bool */ public static function setData(array $params){ try{ $mall_id = $params['mall_id']; if(!empty($params['id'])){ $model = self::findOne(['and',['id' => $params['id'],'mall_id' => $mall_id],['<>','status', -1]]); if(empty($model)) throw new \Exception('活动不存在或已删除'); }else{ $model = new self(); $model->loadDefaultValues(); $model->mall_id = $mall_id; } // 将内容转为json字符串 if(!empty($params['reward_info'])) $params['recommen_reward'] = json_encode($params['reward_info']); if(!empty($params['be_reward_info'])) $params['be_recommen_reward'] = json_encode($params['be_reward_info']); if(!$model->load($params,'') || !$model->save()) throw new Exception($model->getErrorMessage()); return $model; }catch(\Exception $e){ self::setStaticError($e->getMessage()); return false; } } }