package utils

import (
	"fmt"
	"merchant/sys/enum"
	"net/http"
	"net/url"
)

// SendSmsForPay 发送提现通知
func SendSmsForPay(mobile, code string) bool {
	tplValue := url.Values{"#code#": {code}}.Encode()
	dataTplSms := url.Values{
		"apikey":    {enum.ApiKey},
		"mobile":    {mobile},
		"tpl_id":    {fmt.Sprintf("%d", enum.TPL1)},
		"tpl_value": {tplValue}}
	_, err := http.PostForm(enum.SendSmsUrl, dataTplSms)
	if err != nil {
		LogError("sms send fail,err:", err)
		return false
	}
	LogInfo(fmt.Sprintf("sms send to %s is success", mobile))
	return true
}
