Skip to content

Instantly share code, notes, and snippets.

@85636682
Created October 7, 2018 07:46
Show Gist options
  • Save 85636682/a4787f6ee9a28f001b807ebd4520ce43 to your computer and use it in GitHub Desktop.
Save 85636682/a4787f6ee9a28f001b807ebd4520ce43 to your computer and use it in GitHub Desktop.
微信短信模板代码
```
activity_bonus_record = ActivityBonusRecord.create(
activity_id: activity_user.activity_id,
user_id: parent.id,
bonus: bonus,
response: response,
redpack_url: response["redpack_url"],
redpack_sn: response["redpack_sn"]
)
template = {
"template_id" => "DBsfQoDzQdanLD-y3qrR7UeXMogEuj0fhus-1IU2QF0",
"url" => response["redpack_url"],
"data" => {
"first" => {
"value" => "恭喜你获取一个红包"
},
"keyword1" => {
"value" => format("%.2f", bonus).to_f
},
"keyword2" => {
"value" => DateTime.parse(activity_bonus_record.created_at.iso8601).strftime('%Y年%m月%d日 %H:%M')
},
"remark" => {
"value" => "万人团购节,感谢你的参与!"
}
}
}
wechat.template_message_send Wechat::Message.to(openid).template(template)
```
@zh530102
Copy link

zh530102 commented Jan 3, 2023

您好

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment