k.zhang 1 tahun lalu
induk
melakukan
525572970c
2 mengubah file dengan 20 tambahan dan 1 penghapusan
  1. 8 0
      apis/shanghu/models/pay.go
  2. 12 1
      apis/shanghu/pay.go

+ 8 - 0
apis/shanghu/models/pay.go

@@ -10,3 +10,11 @@ type UnifiedOrderRequest struct {
 	Amount         decimal.Decimal `json:"amount"`           // 交易金额
 
 }
+
+type UnifiedOrderReply struct {
+	Timestamp string `json:"timestamp"` // 时间戳
+	NonceStr  string `json:"nonce_str"` // 随机字符串,长度为32个字符以下
+	Package   string `json:"package"`   // prepay_id 参数值
+	PaySign   string `json:"pay_sign"`  // 签名
+	SignType  string `json:"sign_type"` // 签名类型
+}

+ 12 - 1
apis/shanghu/pay.go

@@ -36,6 +36,7 @@ var (
 func UnifiedOrder(c *gin.Context) {
 	var inData models.UnifiedOrderRequest
 	var sqlData shanghu.ClientPayTrans
+	var outData models.UnifiedOrderReply
 
 	err := c.ShouldBindJSON(&inData)
 	if err != nil {
@@ -105,12 +106,22 @@ func UnifiedOrder(c *gin.Context) {
 		return
 	}
 
+	timestamp := strconv.FormatInt(time.Now().Unix(), 10)
+	pac := "prepay_id=" + wxResp.PrepayId
+	paySign := wechat.GetMiniPaySign("wx25357518f710b8ce", wxResp.NonceStr, pac, wechat.SignType_MD5, timestamp, "1RKRJBVH4vaRrF0XPW9GX2M3ZSImukIz")
+
+	outData.Timestamp = timestamp
+	outData.NonceStr = wxResp.NonceStr
+	outData.Package = pac
+	outData.PaySign = paySign
+	outData.SignType = wechat.SignType_MD5
+
 	//merchant, count, err := sqlData.GetOpenIdList(pageSize, pageIndex)
 	//if err != nil {
 	//	app.Error(c, 500, err, err.Error())
 	//	return
 	//}
-	app.OK(c, wxResp, app.Success)
+	app.OK(c, outData, app.Success)
 
 }