Browse Source

no message

xingzai 8 months ago
parent
commit
699af8f82a
2 changed files with 22 additions and 1 deletions
  1. 1 1
      services/order.go
  2. 21 0
      services/wx_pay.go

+ 1 - 1
services/order.go

@@ -35,12 +35,12 @@ func CancelCygxOrder(cont context.Context) (err error) {
 	}
 	//订单量不大,先这么写吧
 	for _, v := range orderList {
-		fmt.Println(v.OrderCode)
 		e = order.CancelCygxOrder(v)
 		if e != nil && e.Error() != utils.ErrNoRow() {
 			err = errors.New("CancelCygxOrder, Err: " + e.Error())
 			return
 		}
+		go ExampleJsapiApiService_CloseOrder(v.OutTradeNo)
 	}
 	return
 }

+ 21 - 0
services/wx_pay.go

@@ -95,6 +95,27 @@ func GetQueryOrderByOutTradeNo(outTradeNo string) (tradeState string, statusCode
 	return
 }
 
+// 订单超时手动关闭订单
+func ExampleJsapiApiService_CloseOrder(OutTradeNo string) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg(fmt.Sprint("订单超时手动关闭订单 失败 ExampleJsapiApiService_CloseOrder, err:", err.Error(), "OrderCode:", OutTradeNo), 2)
+		}
+	}()
+
+	ctx := context.Background()
+	svc := jsapi.JsapiApiService{Client: utils.WechatCertClient}
+	_, err = svc.CloseOrder(ctx,
+		jsapi.CloseOrderRequest{
+			OutTradeNo: core.String(OutTradeNo),
+			Mchid:      core.String(utils.Mchid),
+		},
+	)
+	return
+}
+
 // Transaction
 type Transaction struct {
 	Amount          TransactionAmount `json:"amount,omitempty"`