Commit 96a7b480 authored by jiangjiantao's avatar jiangjiantao

Merge branch 'dev-1.0' of…

Merge branch 'dev-1.0' of https://gitlab.infra.miyatech.com/pengguangpu/doublescreen-front into dev-1.0
parents 2c3fb903 96c43b17
...@@ -34,6 +34,7 @@ Page({ ...@@ -34,6 +34,7 @@ Page({
}, },
/** /**
* 保存最近支付成功的相关信息,每次支付成功都需刷新 * 保存最近支付成功的相关信息,每次支付成功都需刷新
* @param paySuccessGoodsList 支付成功的商品列表信息 * @param paySuccessGoodsList 支付成功的商品列表信息
...@@ -188,16 +189,17 @@ Page({ ...@@ -188,16 +189,17 @@ Page({
if(res == null){ if(res == null){
return; return;
} }
if(res.code > 0){ if(res.resultCode == 1){
//成功 //成功
console.log("支付回调成功,跳转 " ); console.log("支付回调成功,跳转 " );
// if(data.isCashierClosed == true){ // if(data.isCashierClosed == true){
my.ix.offCashierEventReceive(); my.ix.offCashierEventReceive();
saveData(this.data.list, res);
my.redirectTo({ my.redirectTo({
url: '/pages/paysuccess/paysuccess?orderPrice=' + this.data.totalPrice + "&couponPrice=" + this.data.couponPrice + "&payPrice=" + this.data.payPrice+"&totalCount="+this.data.totalCount, url: '/pages/paysuccess/paysuccess?orderPrice=' + this.data.totalPrice + "&couponPrice=" + this.data.couponPrice + "&payPrice=" + this.data.payPrice+"&totalCount="+this.data.totalCount,
}); });
// } // }
}else{ } else {
console.log("支付回调失败,toast提示 "); console.log("支付回调失败,toast提示 ");
my.ix.offCashierEventReceive(); my.ix.offCashierEventReceive();
my.showToast({ my.showToast({
...@@ -209,6 +211,21 @@ Page({ ...@@ -209,6 +211,21 @@ Page({
}.bind(this)); }.bind(this));
}, },
/**
* 保存最近支付成功的相关信息,每次支付成功都需刷新
* @param paySuccessGoodsList 支付成功的商品列表信息
* @param paySuccessResponse 支付成功响应,即云中台返回响应中的data信息
*/
saveData(paySuccessGoodsList, paySuccessResponse) {
my.setStorageSync({
key: 'paySuccessGoodsList',
data: paySuccessGoodsList
});
my.setStorageSync({
key: 'paySuccessResponse',
data: paySuccessResponse
});
},
}); });
...@@ -195,16 +195,16 @@ function pay(tradeNo, payCode, payPrice, list, callback, retryCount){ ...@@ -195,16 +195,16 @@ function pay(tradeNo, payCode, payPrice, list, callback, retryCount){
console.log("支付接口回掉 ==>" + JSON.stringify(res)); console.log("支付接口回掉 ==>" + JSON.stringify(res));
//增加数据判断,增加重试 //增加数据判断,增加重试
console.log("支付接口回调 ==>" + JSON.stringify(res)); console.log("支付接口回调 ==>" + JSON.stringify(res));
if (res == null|| res.data == null|| res.data.success != true/*||res.data.data == null*/) { if (res == null|| res.data == null|| res.data.success != true || res.data.data == null) {
console.log("支付未成功 ==>" + JSON.stringify(res.data.message)); console.log("支付未成功 ==>" + JSON.stringify(res.data.message));
retryOrFailed(tradeNo, payCode, payPrice, list, callback, retryCount); retryOrFailed(tradeNo, payCode, payPrice, list, callback, retryCount);
} else { } else {
console.log("支付返回值 ==>" + JSON.stringify(res.data)); console.log("支付返回值 ==>" + JSON.stringify(res.data));
if(res.data.data.tradeStatus == "3"){ if(res.data.data.tradeStatus == "3"){
onPaySuccess(res.data.data,callback); onPaySuccess(res.data.data, callback);
} else if(res.data.data.tradeStatus == "1"){//需要查询结果 } else if(res.data.data.tradeStatus == "1"){//需要查询结果
//轮询查询,最多12次 //轮询查询,最多12次
queryPayStateWithRetry(tradeNo,callback,0); queryPayStateWithRetry(tradeNo, callback, 0);
} else { } else {
//查询一次 //查询一次
queryPayState(tradeNo,callback); queryPayState(tradeNo,callback);
...@@ -250,7 +250,6 @@ function queryPayStateWithRetry(tradeNo, callback, retryCount){ ...@@ -250,7 +250,6 @@ function queryPayStateWithRetry(tradeNo, callback, retryCount){
callback(response); callback(response);
return; return;
} }
retryCount++;
var queryStateRequest = api.createCommonRequest(); var queryStateRequest = api.createCommonRequest();
queryStateRequest.tradeNo = tradeNo; queryStateRequest.tradeNo = tradeNo;
queryStateRequest.batchNo = "" + Date.parse(new Date()); queryStateRequest.batchNo = "" + Date.parse(new Date());
...@@ -266,6 +265,7 @@ function queryPayStateWithRetry(tradeNo, callback, retryCount){ ...@@ -266,6 +265,7 @@ function queryPayStateWithRetry(tradeNo, callback, retryCount){
success: (res) => { success: (res) => {
console.log("支付结果回掉"+JSON.stringify(res)); console.log("支付结果回掉"+JSON.stringify(res));
//增加数据判断,增加重试 //增加数据判断,增加重试
console.log("查询结果"+JSON.stringify(res));
if (res == null|| res.data == null|| res.data.success != true||res.data.data == null) {//不知名原因导致失败,直接报失败 if (res == null|| res.data == null|| res.data.success != true||res.data.data == null) {//不知名原因导致失败,直接报失败
console.log("查询失败,支付失败"); console.log("查询失败,支付失败");
var response = {resultCode:-1,message:"支付失败"}; var response = {resultCode:-1,message:"支付失败"};
...@@ -274,9 +274,9 @@ function queryPayStateWithRetry(tradeNo, callback, retryCount){ ...@@ -274,9 +274,9 @@ function queryPayStateWithRetry(tradeNo, callback, retryCount){
if(res.data.data.tradeStatus == "3"){//成功直接报成功 if(res.data.data.tradeStatus == "3"){//成功直接报成功
onPaySuccess(res.data.data,callback); onPaySuccess(res.data.data,callback);
} else if(res.data.data.tradeStatus == "1"){//需要查询结果,继续轮询 } else if(res.data.data.tradeStatus == "1"){//需要查询结果,继续轮询
console.log("查询结果显示支付未成功 ==>" + res.data.message); console.log("查询结果显示支付未成功,重试 ");
sleep(5000); sleep(5000);
queryPayStateWithRetry(tradeNo,callback, retryCount); queryPayStateWithRetry(tradeNo,callback, ++retryCount);
} else {//其他状况直接报失败 } else {//其他状况直接报失败
var response = {resultCode:-1,message:"支付失败"}; var response = {resultCode:-1,message:"支付失败"};
callback(response); callback(response);
...@@ -286,7 +286,7 @@ function queryPayStateWithRetry(tradeNo, callback, retryCount){ ...@@ -286,7 +286,7 @@ function queryPayStateWithRetry(tradeNo, callback, retryCount){
fail: (res) => {//接口访问失败,继续轮询 fail: (res) => {//接口访问失败,继续轮询
console.log("查询失败 ==>" + JSON.stringify(res)); console.log("查询失败 ==>" + JSON.stringify(res));
sleep(5000); sleep(5000);
queryPayStateWithRetry(tradeNo,callback,retryCount); queryPayStateWithRetry(tradeNo,callback,++retryCount);
} }
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment