Browse Source

支付宝二维码添加过期时间

wangkaiyue 6 years ago
parent
commit
3360b86927
2 changed files with 10 additions and 6 deletions
  1. 3 1
      src/jfw/pay/aliPay.go
  2. 7 5
      src/jfw/pay/dataExportPay.go

+ 3 - 1
src/jfw/pay/aliPay.go

@@ -42,6 +42,7 @@ type BizContent struct {
 	ProductCode  string  `json:"product_code"`
 	Qr_pay_mode  string  `json:"qr_pay_mode"`
 	Qrcode_width int     `json:"qrcode_width"`
+	Time_expire  string  `json:"time_expire"` //支付超时时间yyyy-MM-dd HH:mm:ss
 }
 
 type AliPayAction struct {
@@ -82,7 +83,7 @@ func (w *AliPayStruct) GetTradeno() string {
 }
 
 //获取支付连接
-func (a *AliPayStruct) GetPayUrl(order_money float64) (string, string, error) {
+func (a *AliPayStruct) GetPayUrl(order_money float64, time_expire string) (string, string, error) {
 	tradeno := a.GetTradeno()
 	bizContent := BizContent{
 		Subject:      a.Subject,
@@ -91,6 +92,7 @@ func (a *AliPayStruct) GetPayUrl(order_money float64) (string, string, error) {
 		ProductCode:  "FAST_INSTANT_TRADE_PAY",
 		Qr_pay_mode:  "4",
 		Qrcode_width: a.Qr_width,
+		Time_expire:  time_expire,
 	}
 	bizbyte, err := json.Marshal(bizContent)
 	if err != nil {

+ 7 - 5
src/jfw/pay/dataExportPay.go

@@ -74,7 +74,8 @@ func (p *DataExportPayAction) SacnPay_WaitPay() error {
 					}
 				}
 			} else if pay_way == "支付宝" {
-				if qr_url, tradeno, err := Alipay.GetPayUrl(util.Float64All(orderMoney)); err == nil {
+				payOutTime := now.Add(time.Minute * 2)
+				if qr_url, tradeno, err := Alipay.GetPayUrl(util.Float64All(orderMoney), util.FormatDate(&payOutTime, util.Date_Full_Layout)); err == nil {
 					if public.Mysql.Update("dataexport_order", map[string]interface{}{
 						"id": orderid,
 					}, map[string]interface{}{
@@ -228,8 +229,8 @@ func (p *DataExportPayAction) SacnPay_CreateOrder() {
 	}
 	order_money := int(order_money_ * 100)
 	original_price := int(original_price_ * 100)
-	order_money = 1
-	original_price = 1
+	//order_money = 1
+	//original_price = 1
 	filter_keys, filter_publishtime, filter := "", "", ""
 	//
 	isPass := func() bool {
@@ -304,8 +305,9 @@ func (p *DataExportPayAction) SacnPay_CreateOrder() {
 				log.Println("生成微信预支付交易单失败", ret)
 			}
 		} else if pay_way == "支付宝" {
-			if qr_url, tradeno, err := Alipay.GetPayUrl(util.Float64All(order_money)); err == nil {
-				now := time.Now()
+			now := time.Now()
+			payOutTime := now.Add(time.Minute * 2)
+			if qr_url, tradeno, err := Alipay.GetPayUrl(util.Float64All(order_money), util.FormatDate(&payOutTime, util.Date_Full_Layout)); err == nil {
 				ordercode := public.GetOrderCode(openId)
 				orderid := public.Mysql.Insert("dataexport_order", map[string]interface{}{
 					"order_money":        order_money,