wash_recommend.j2 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. {%- set greeting = '亲爱的用户' if hour < 11 else '中午好' if hour < 14 else '下午好' if hour < 18 else '晚上好' -%}
  2. {%- set period = '早晨' if hour < 9 else '上午' if hour < 12 else '中午' if hour < 14 else '下午' if hour < 18 else '晚上' -%}
  3. {%- set is_hot = temperature is defined and temperature >= 30 -%}
  4. {%- set is_cold = temperature is defined and temperature <= 10 -%}
  5. {%- set has_rain = weather is defined and weather is string and '雨' in weather -%}
  6. {%- set condition =
  7. '炎热' if is_hot else
  8. '寒冷' if is_cold else
  9. '下雨' if has_rain else
  10. weather|default('美好') -%}
  11. {%- set proportion_pct = (user_proportion * 100)|round(1) if user_proportion is defined and user_proportion is not none else none -%}
  12. {%- set popularity_level =
  13. '最受欢迎' if proportion_pct is defined and proportion_pct is not none and proportion_pct >= 70 else
  14. '人气很高' if proportion_pct is defined and proportion_pct is not none and proportion_pct >= 50 else
  15. '很多人选择' if proportion_pct is defined and proportion_pct is not none and proportion_pct >= 30 else
  16. '值得一试' -%}
  17. {%- set user_desc =
  18. '超过' ~ user_count ~ '位用户' if user_count is defined and user_count is not none and user_count >= 10000 else
  19. user_count ~ '位用户' if user_count is defined and user_count is not none else
  20. '很多用户' -%}
  21. {# 第一段:基础推荐 + 数据支撑 #}
  22. {{ greeting }},为你推荐{{ feature_name|default('这类衣物') }}的{{ program_name }}程序,
  23. {%- if user_count is defined or user_proportion is defined %}
  24. 这可是你的老朋友了,数据显示在{{ season }}{{ city|default('本地') }}{{ period }},
  25. {{ user_desc }}{% if proportion_pct is defined and proportion_pct is not none %},占比高达{{ proportion_pct }}%{% endif %}都爱用它洗呢。
  26. {%- else %}
  27. 非常适合当前季节和衣物类型。
  28. {%- endif %}
  29. {# 第二段:季节场景化推荐 #}
  30. {%- if season in ['夏季', '冬天'] or is_hot or is_cold or has_rain %}
  31. {{ season }}洗衣时,
  32. {%- if is_hot %}高温天气下,{% elif is_cold %}寒冷天气下,{% elif has_rain %}雨天,{% endif %}
  33. {{ feature_name|default('这类衣物') }}的{{ program_name }}程序最懂你心意,
  34. {%- if proportion_pct is defined and proportion_pct is not none %}
  35. {{ city|default('本地') }}{{ period }}时段有{{ proportion_pct }}%用户选择它呢。
  36. {%- else %}
  37. 很适合现在使用。
  38. {%- endif %}
  39. {%- endif %}
  40. {# 第三段:助手提醒(总是输出,增强亲切感) #}
  41. 洗衣助手提醒你,{{ feature_name|default('这类衣物') }}的{{ program_name }}程序真不错,
  42. {%- if proportion_pct is defined and proportion_pct is not none %}
  43. {{ city|default('本地') }}{{ period }}时段人气也很旺,属于{{ popularity_level }}的洗衣方案。
  44. {%- else %}
  45. 非常实用,值得一试。
  46. {%- endif %}
  47. {# 第四段:天气+时段氛围感推荐 #}
  48. 又是一个{{ season }}{{ condition }}的{{ period }},
  49. 为你推荐{{ feature_name|default('这类衣物') }}的{{ program_name }}程序,
  50. {%- if proportion_pct is defined and proportion_pct is not none %}
  51. 这是{{ popularity_level }}的洗衣方案之一,{{ city|default('本地') }}{{ proportion_pct }}%用户都在用。
  52. {%- else %}
  53. 这是当前最合适的洗涤方式。
  54. {%- endif %}
  55. {# 结尾温柔提醒 #}
  56. 祝你洗衣愉快,衣物干净如新!