|
@@ -2,7 +2,6 @@ package order
|
|
|
|
|
|
import (
|
|
|
"bytes"
|
|
|
- "encoding/base64"
|
|
|
"encoding/json"
|
|
|
logger "eta/eta_mini_ht_api/common/component/log"
|
|
|
"eta/eta_mini_ht_api/models"
|
|
@@ -11,6 +10,7 @@ import (
|
|
|
"eta/eta_mini_ht_api/models/order"
|
|
|
"fmt"
|
|
|
"math/rand"
|
|
|
+ "net/url"
|
|
|
"strconv"
|
|
|
"text/template"
|
|
|
"time"
|
|
@@ -24,13 +24,12 @@ const (
|
|
|
RefundFail = "fail"
|
|
|
PaySuccess = "success"
|
|
|
PayFail = "fail"
|
|
|
- PayUrlTemplate = "{{.Url}}?appId={{.AppId}}&totalOrder={{.Amount}}&sorderNo={{.TradeOrderNo}}&title={{.ProductTitle}}&description={{.ProductDescription}}&buyerId={{.BuyerId}}&payType={{.PayType}}&openid={{.OpenId}}"
|
|
|
+ PayUrlTemplate = "{{.Url}}?totalOrder={{.Amount}}&sorderNo={{.TradeOrderNo}}&title={{.ProductTitle}}&description={{.ProductDescription}}&buyerId={{.BuyerId}}&payType={{.PayType}}&openid={{.OpenId}}"
|
|
|
)
|
|
|
|
|
|
type PaymentWay string
|
|
|
type PayOrderDTO struct {
|
|
|
Url string
|
|
|
- AppId string
|
|
|
Amount string
|
|
|
ProductTitle string
|
|
|
ProductDescription string
|
|
@@ -73,8 +72,8 @@ func GenerateTradeOrderNo() string {
|
|
|
}
|
|
|
func generateMessage(data interface{}, tmpl string) (message string, err error) {
|
|
|
urlParams := data.(PayOrderDTO)
|
|
|
- urlParams.ProductTitle = base64.URLEncoding.EncodeToString([]byte(urlParams.ProductTitle))
|
|
|
- urlParams.ProductDescription = base64.URLEncoding.EncodeToString([]byte(urlParams.ProductDescription))
|
|
|
+ urlParams.ProductTitle = url.QueryEscape(urlParams.ProductTitle)
|
|
|
+ urlParams.ProductDescription = url.QueryEscape(urlParams.ProductDescription)
|
|
|
t := template.Must(template.New("messageTemplate").Parse(tmpl))
|
|
|
var buffer bytes.Buffer
|
|
|
err = t.Execute(&buffer, urlParams)
|