Browse Source

付款优化

shish 2 weeks ago
parent
commit
0400a916ab

+ 8 - 6
ghsApp/src/admin/billing/toPay.vue

@@ -67,7 +67,7 @@
  */
 import { mapGetters } from "vuex";
 import { IMGHOST } from '@/config'
-import { cancel,debtPay,getDetail,codePay,codePayCheck} from "@/api/order";
+import { cancel,debtPay,getDetail,codePay,codePayCheck,codePayVerify} from "@/api/order";
 export default {
   name: "toPay",
   components: {
@@ -89,6 +89,7 @@ export default {
 			typescan: 'scan-listener',
       remindText:'',
       returnCode:'',
+      authCode:'', // 存储付款码数字
       pollingTimer:null, // 后台自动复查定时器
       pollingCount:0, // 自动复查次数
       isPaymentProcessing:false // 防重复扫码标志
@@ -232,6 +233,7 @@ export default {
         this.isPaymentProcessing = true
         this.remindText = ''
         this.returnCode = ''
+        this.authCode = authCode // 记录当前支付码
         this.clearPolling()
 
         codePay({id:this.orderId,authCode:authCode}).then(res=>{
@@ -246,7 +248,7 @@ export default {
                     that.returnCode = res.data.returnCode ? res.data.returnCode : ''
                     that.goPay = 2
                     
-                    // 11105(用户输入密码中) 或 10000(其它密码状态),启动4秒一次、最多5次(20秒)的自动复查定时器
+                    // 11105(用户输入密码中) 或 10000(其它密码状态),启动4秒一次、最多4次(16秒)的自动复查定时器
                     if (that.returnCode == 'BBS11105' || that.returnCode == 'BBS10000') {
                         that.startPolling()
                     } else {
@@ -268,7 +270,7 @@ export default {
     },
     /**
      * 启动低频后台付款复查定时器
-     * 4秒轮询一次,限查5次,极大地减轻服务器压力的同时保证业务流闭环
+     * 4秒轮询一次,限查4次,极大地减轻服务器压力的同时保证业务流闭环
      */
     startPolling(){
         this.clearPolling()
@@ -279,7 +281,7 @@ export default {
         let that = this;
         this.pollingTimer = setInterval(() => {
             that.pollingCount++
-            if (that.pollingCount > 5) {
+            if (that.pollingCount > 4) {
                 that.clearPolling()
                 that.isPaymentProcessing = false
                 that.goPay = 2
@@ -287,9 +289,9 @@ export default {
                 return
             }
 
-            that.remindText = `正在自动复查支付结果 (${that.pollingCount}/5)...`
+            that.remindText = `正在自动复查支付结果 (${that.pollingCount}/4)...`
 
-            codePayCheck({id:that.orderId}).then(res=>{
+            codePayVerify({id:that.orderId,authCode:that.authCode}).then(res=>{
                 if(res.code == 1){
                     if(res.data && res.data.returnStatus == 'SUCCESS'){
                         that.clearPolling()

+ 3 - 0
ghsApp/src/api/order/index.js

@@ -268,6 +268,9 @@ export const codePay = data => https.get("/order/code-pay", data);
 //微信和支付宝付款码支付复查
 export const codePayCheck = data => https.get("/order/code-pay-check", data);
 
+//微信和支付宝付款码支付验证(带付款码)
+export const codePayVerify = data => https.get("/order/code-pay-verify", data);
+
 //收款语音播报
 export const getPayVoice = data => https.get("/order/get-pay-voice", data);
 

+ 3 - 0
ghsPad/src/api/order/index.js

@@ -198,6 +198,9 @@ export const codePay = data => https.get("/order/code-pay", data);
 //微信和支付宝付款码支付复查
 export const codePayCheck = data => https.get("/order/code-pay-check", data);
 
+//微信和支付宝付款码支付验证(带付款码)
+export const codePayVerify = data => https.get("/order/code-pay-verify", data);
+
 //收款语音播报
 export const getPayVoice = data => https.get("/order/get-pay-voice", data);
 

+ 7 - 5
ghsPad/src/pages/home/components/toPay.vue

@@ -58,7 +58,7 @@
  * 扫码支付组件(供货商收银机端)
  * 解决客户扫码后转圈状态被卡住、钱未到账的问题,支持网络异常降级和自动后台复查
  */
-import { codePay,codePayCheck,cancelOrderFn,getDetail} from "@/api/order";
+import { codePay,codePayCheck,codePayVerify,cancelOrderFn,getDetail} from "@/api/order";
 export default {
     name:'toPayWay',
     components:{
@@ -70,6 +70,7 @@ export default {
             goPay:0, // 0: 未支付,1: 支付请求中/自动复查中,2: 支付失败或异常提示
             remindText:'',
             returnCode:'',
+            authCode:'', // 存储付款码数字
             cancelText:'确认要取消?',
             isCancelDialogOpen:false,
             isPaymentProcessing:false, // 标志位:防重复扫码
@@ -163,6 +164,7 @@ export default {
             this.isPaymentProcessing = true
             this.remindText = ''
             this.returnCode = ''
+            this.authCode = authCode // 记录支付码
             this.clearPolling() // 每次开始扫码前,确保清除旧的定时器
             
             codePay({id:this.orderId,authCode:authCode}).then(res=>{
@@ -201,7 +203,7 @@ export default {
         },
         /**
          * 启动自动后台付款复查定时器
-         * 职责:降低轮询频率至4秒,且将次数限为5次(总计20秒),极大地减轻服务器压力的同时保证业务完整
+         * 职责:降低轮询频率至4秒,且将次数限为4次(总计16秒),极大地减轻服务器压力的同时保证业务完整
          */
         startPolling(){
             this.clearPolling()
@@ -212,7 +214,7 @@ export default {
             let that = this
             this.pollingTimer = setInterval(() => {
                 that.pollingCount++
-                if (that.pollingCount > 5) {
+                if (that.pollingCount > 4) {
                     // 超时未确认,停止轮询,允许商户手动操作或重新扫码
                     that.clearPolling()
                     that.isPaymentProcessing = false
@@ -222,9 +224,9 @@ export default {
                 }
                 
                 // 界面上展示当前自动复查的进度,提升收银员体验
-                that.remindText = `正在自动复查支付结果 (第 ${that.pollingCount}/5 次)...`
+                that.remindText = `正在自动复查支付结果 (第 ${that.pollingCount}/4 次)...`
                 
-                codePayCheck({id:that.orderId}).then(res=>{
+                codePayVerify({id:that.orderId,authCode:that.authCode}).then(res=>{
                     if(res.code == 1){
                         if(res.data && res.data.returnStatus == 'SUCCESS'){
                             // 复查确认成功,停止轮询并显示成功界面

+ 8 - 6
hdApp/src/admin/billing/toPay.vue

@@ -54,7 +54,7 @@
  * 扫码支付组件(零售花店App/微信端)
  * 优化转圈状态锁死问题,支持低频自动复查及网络异常优雅降级
  */
-import { cancelOrder,debtPay,getDetail,codePay,codePayCheck} from "@/api/order";
+import { cancelOrder,debtPay,getDetail,codePay,codePayCheck,codePayVerify} from "@/api/order";
 export default {
   name: "toPay",
   components: {
@@ -77,6 +77,7 @@ export default {
 			typescan: 'scan-listener',
       remindText:'',
       returnCode:'',
+      authCode:'', // 存储付款码数字
       pollingTimer:null, // 后台自动复查定时器
       pollingCount:0, // 自动复查次数
       isPaymentProcessing:false // 防重复扫码标志
@@ -160,6 +161,7 @@ export default {
         this.isPaymentProcessing = true
         this.remindText = ''
         this.returnCode = ''
+        this.authCode = authCode // 记录支付码
         this.clearPolling()
 
         codePay({id:this.orderId,authCode:authCode}).then(res=>{
@@ -174,7 +176,7 @@ export default {
                     that.returnCode = res.data.returnCode ? res.data.returnCode : ''
                     that.goPay = 2
                     
-                    // 11105(用户输入密码中) 或 10000(其它密码状态),启动4秒一次、最多5次(20秒)的自动复查定时器
+                    // 11105(用户输入密码中) 或 10000(其它密码状态),启动4秒一次、最多4次(16秒)的自动复查定时器
                     if (that.returnCode == 'BBS11105' || that.returnCode == 'BBS10000') {
                         that.startPolling()
                     } else {
@@ -196,7 +198,7 @@ export default {
     },
     /**
      * 启动低频后台付款复查定时器
-     * 4秒轮询一次,限查5次,极大地减轻服务器压力的同时保证业务流闭环
+     * 4秒轮询一次,限查4次,极大地减轻服务器压力的同时保证业务流闭环
      */
     startPolling(){
         this.clearPolling()
@@ -207,7 +209,7 @@ export default {
         let that = this
         this.pollingTimer = setInterval(() => {
             that.pollingCount++
-            if (that.pollingCount > 5) {
+            if (that.pollingCount > 4) {
                 that.clearPolling()
                 that.isPaymentProcessing = false
                 that.goPay = 2
@@ -215,9 +217,9 @@ export default {
                 return
             }
 
-            that.remindText = `正在自动复查支付结果 (${that.pollingCount}/5)...`
+            that.remindText = `正在自动复查支付结果 (${that.pollingCount}/4)...`
 
-            codePayCheck({id:that.orderId}).then(res=>{
+            codePayVerify({id:that.orderId,authCode:that.authCode}).then(res=>{
                 if(res.code == 1){
                     if(res.data && res.data.returnStatus == 'SUCCESS'){
                         that.clearPolling()

+ 3 - 0
hdApp/src/api/order/index.js

@@ -10,6 +10,9 @@ export const codePay = data => https.get("/order/code-pay", data);
 //微信和支付宝付款码支付复查
 export const codePayCheck = data => https.get("/order/code-pay-check", data);
 
+//微信和支付宝付款码支付验证(带付款码)
+export const codePayVerify = data => https.get("/order/code-pay-verify", data);
+
 export const updateOrder = data => {
 	return https.post("/order/update", data);
 };

+ 3 - 0
hdPad/src/api/order/index.js

@@ -198,6 +198,9 @@ export const codePay = data => https.get("/order/code-pay", data);
 //微信和支付宝付款码支付复查
 export const codePayCheck = data => https.get("/order/code-pay-check", data);
 
+//微信和支付宝付款码支付验证(带付款码)
+export const codePayVerify = data => https.get("/order/code-pay-verify", data);
+
 //收款语音播报
 export const getPayVoice = data => https.get("/order/get-pay-voice", data);
 

+ 7 - 5
hdPad/src/pages/home/components/toPay.vue

@@ -47,7 +47,7 @@
  * 扫码支付组件(零售花店收银机端)
  * 解决扫码时转圈状态被卡住、钱未到账的问题,支持网络异常降级和后台复查
  */
-import { codePay,codePayCheck,cancelOrderFn,getDetail} from "@/api/order";
+import { codePay,codePayCheck,codePayVerify,cancelOrderFn,getDetail} from "@/api/order";
 export default {
     name:'toPayWay',
     components:{
@@ -59,6 +59,7 @@ export default {
             goPay:0, // 0: 未支付,1: 支付请求中/复查中,2: 支付失败或异常提示
             remindText:'',
             returnCode:'',
+            authCode:'', // 存储付款码数字
             cancelText:'确认要取消?',
             isCancelDialogOpen:false,
             isPaymentProcessing:false, // 标志位:防重复扫码
@@ -144,6 +145,7 @@ export default {
             this.isPaymentProcessing = true
             this.remindText = ''
             this.returnCode = ''
+            this.authCode = authCode // 记录支付码
             this.clearPolling() // 每次开始扫码前,确保清除旧的定时器
             
             codePay({id:this.orderId,authCode:authCode,version:2}).then(res=>{
@@ -182,7 +184,7 @@ export default {
         },
         /**
          * 启动自动后台付款复查定时器
-         * 职责:降低轮询频率至4秒,且将次数限为5次(总计20秒),极大地减轻服务器压力的同时保证业务完整
+         * 职责:降低轮询频率至4秒,且将次数限为4次(总计16秒),极大地减轻服务器压力的同时保证业务完整
          */
         startPolling(){
             this.clearPolling()
@@ -193,7 +195,7 @@ export default {
             let that = this
             this.pollingTimer = setInterval(() => {
                 that.pollingCount++
-                if (that.pollingCount > 5) {
+                if (that.pollingCount > 4) {
                     // 超时未确认,停止轮询,允许商户手动操作或重新扫码
                     that.clearPolling()
                     that.isPaymentProcessing = false
@@ -203,9 +205,9 @@ export default {
                 }
                 
                 // 界面展示当前自动复查的进度,提升收银员体验
-                that.remindText = `正在自动复查支付结果 (第 ${that.pollingCount}/5 次)...`
+                that.remindText = `正在自动复查支付结果 (第 ${that.pollingCount}/4 次)...`
                 
-                codePayCheck({id:that.orderId}).then(res=>{
+                codePayVerify({id:that.orderId,authCode:that.authCode}).then(res=>{
                     if(res.code == 1){
                         if(res.data && res.data.returnStatus == 'SUCCESS'){
                             // 复查确认成功,停止轮询并显示成功界面