['sms_key' => 'fill', 'temp_name' => '补货通知', 'temp_id' => '', 'temp_content' => '你有下级订单,请${hour}小时内补货。'], 'upgrade' => ['sms_key' => 'upgrade', 'temp_name' => '升级通知', 'temp_id' => '', 'temp_content' => '恭喜你,你的云库存代理商等级升到了${level_name}。'], 'bonus' => ['sms_key' => 'bonus', 'temp_name' => '收益通知', 'temp_id' => '', 'temp_content' => '恭喜你,获得了${money}元云库存收益。请注意查看'], 'early_warning' => ['sms_key' => 'early_warning', 'temp_name' => '库存预警通知', 'temp_id' => '', 'temp_content' => '您的${goods_name}库存不足,请及时进行补货'], ]; /** * {@inheritdoc} */ public static function tableName() { return '{{%addons_cloud_stock_sms}}'; } /** * {@inheritdoc} */ public function rules() { return [ [['temp_id', 'temp_content', 'sms_key', 'temp_name'], 'required'], [['mall_id', 'status', 'created_at', 'updated_at'], 'integer'], [['temp_id', 'sms_key'], 'string', 'max' => 255], [['temp_content', 'temp_name'], 'string', 'max' => 1024], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => '自增id', 'temp_id' => '模板id', 'temp_content' => '模板内容', 'mall_id' => '商城id', 'sms_key' => '键值', 'temp_name' => '模板名称', 'status' => '状态[-1:删除;0:禁用;1启用]', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } public static function setData(array $params) { try { if(!empty($params['id'])){ $model = self::findOne(['mall_id' => $params['mall_id'], 'id' => $params['id'], 'status' => [StatusEnum::ENABLED]]); if (empty($model)) throw new \Exception('服务不存在或已删除'); }else{ $model = new self(); $model->loadDefaultValues(); } if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage()); if (!$model->save()) throw new \Exception($model->getErrorMessage()); return $model; } catch (\Exception $e) { self::$static_error = $e->getMessage(); return false; } } }