老师,我这边是查询订单确认成功后才给配置券,现在大部分情况是OK的,就是一天有一两个会配置失败,导致顾客付款成功,实际没有券。看下边标黄色的。
不知道是不是因为网络卡顿的原因,在想是不是要用多进程,用异步函数什么的?
其他没标黄色的可以略过不看,就是查询订单的代码。
如下图,09分的实际是有支付成功的,但是没有填入卡券信息。不知道是不是10分的时候同时有流量进来,是的卡顿了。
此主题相关图片如下:微信截图_20190326062038.png
'查询订单是否正常,存在则返回true
Dim id As String = args(0) 'out_trade_no或者是transaction_id,仿真测试下建议使用out_trade_no
Dim queryType As Integer = args(1) '查询条件,0为out_trade_no,其它值为transaction_id
'用例测试当前订单表,仿真测试的时候发现,刷卡测试查询接口返回的交易类型不是MICROPAY,而是APP,本实例是拿交易类型来做表名称的
Dim tn As String =""
If args.length > 2 Then
tn = args(2) '刷卡支付用例传入"MICROPAY"
End If
Dim req As WxPayData = Functions.Execute("GetWxPayData")
If queryType = 0 Then '0表示是通过out_trade_no进行查询,适合没有接收到支付结果通知的情况
req.SetValue("out_trade_no", id)
Else
req.SetValue("transaction_id", id) '通过transaction_id进行查询,适合接收到支付结果通知的情况
End If
req.SetValue("appid", Vars("appid"))'//公众账号ID
req.SetValue("mch_id", Vars("mchid"))'//商户号
req.SetValue("nonce_str", req.GenerateNonceStr())'//随机字符串
req.SetValue("sign", req.MakeSign())'//签名
Dim url As String = Functions.Execute("GetApiUrl","api_orderquery")
Dim hc As New HttpClient(url)
hc.C
hc.Timeout = 6
hc.Content = req.ToXML
Dim ret As String = hc.GetData()
If ret= "" Then
Functions.Execute("logtext","订单查询超时没有返回结果.")
Return False
End If
Functions.Execute("logtext","订单查询结果: " & ret)
Dim result As WxPayData = Functions.Execute("GetWxPayData")
result.FromXml(ret)
If result.GetValue("return_code") = "FAIL" Then
Functions.Execute("logtext","订单查询失败: " & result.GetValue("return_msg"))
Return False
End If
Dim dr As DataRow
If tn = "" Then
tn = result.GetValue("trade_type")
End If
If queryType = 0 Then '0表示是通过out_trade_no进行查询,适合没有接收到支付结果通知的情况
' dr = DataTables(tn).Find("out_trade_no='" & id & "'")
dr = DataTables("公众号支付订单").Find("out_trade_no='" & id & "' ")
Else
dr = DataTables(tn).Find("transacti")
End If
If dr IsNot Nothing Then
dr("result_code") = result.GetValue("result_code")
dr("err_code") = result.GetValue("err_code")
dr("err_code_des") = result.GetValue("err_code_des")
dr.save()
End If
If result.GetValue("return_code") = "SUCCESS" AndAlso result.GetValue("result_code") = "SUCCESS" Then
If dr Is Nothing Then
' dr = DataTables(tn).Find("out_trade_no='" & result.GetValue("out_trade_no") & "'")
dr = DataTables("公众号支付订单").Find("out_trade_no='" & result.GetValue("out_trade_no") & "'")
End If
If dr Is Nothing Then
Functions.Execute("logtext","无此业务订单,out_trade_no= " & result.GetValue("out_trade_no") )
Return False
End If
dr("trade_state") = result.GetValue("trade_state")
If result.GetValue("trade_state").ToString() = "SUCCESS" Then
'PopMessage("chaxun:" & id)
'vars("out_trade_no") = result.GetValue("out_trade_no")
'vars(id) = id 'id = out_trade_no
'vars("transaction_id") = result.GetValue("transaction_id")
'PopMessage("chaxun:" & vars(id))
vars(dr("openid")) = result.GetValue("transaction_id")
dr("transaction_id") = result.GetValue("transaction_id")
dr("trade_type") = result.GetValue("trade_type")
dr("total_fee") = result.GetValue("total_fee")
dr("cash_fee") = result.GetValue("cash_fee")
dr("time_end") = Date.ParseExact(result.GetValue("time_end"),"yyyyMMddHHmmss",System.Globalization.CultureInfo.InvariantCulture)
dr("trade_state_desc") = result.GetValue("trade_state_desc")
If req.IsSet("settlement_total_fee") Then
dr("settlement_total_fee") = req.GetValue("settlement_total_fee")
End If
If req.IsSet("coupon_fee") Then
dr("coupon_fee") = req.GetValue("coupon_fee")
End If
Dim dr1 As DataRow = DataTables("预售下发券号").sqlfind("发送状态 = '0' and product_id = '" & dr("product_id") & "'")
Dim qh1 As String = dr1("券号1")
Dim qh2 As String = dr1("券号2")
Dim qh3 As String = dr1("券号3")
Dim qh4 As String = dr1("券号4")
Dim qh5 As String = dr1("券号5")
Dim qh As String = dr1("券号")
Dim cardid1 As String = dr1("卡券ID1")
Dim cardid2 As String = dr1("卡券ID2")
Dim cardid3 As String = dr1("卡券ID3")
Dim cardid4 As String = dr1("卡券ID4")
Dim cardid5 As String = dr1("卡券ID5")
Dim cardid As String = dr1("卡券ID")
dr("卡券ID1") = cardid1
dr("卡券ID2") = cardid2
dr("卡券ID3") = cardid3
dr("卡券ID4") = cardid4
dr("卡券ID5") = cardid5
dr("卡券ID") = cardid
dr("券号1") = qh1
dr("券号2") = qh2
dr("券号3") = qh3
dr("券号4") = qh4
dr("券号5") = qh5
dr("券号") = qh
dr.Save
dr1("发送状态") = "1"
dr1.save()
Else
Return False
End If
Return True
End If
Return False
[此贴子已经被作者于2019/3/26 6:20:44编辑过]