Ver Fonte

更新发货接口

zhanwencai há 1 ano atrás
pai
commit
8a92922ff3
1 ficheiros alterados com 21 adições e 4 exclusões
  1. 21 4
      webServer/src/controller/ApiController.ts

+ 21 - 4
webServer/src/controller/ApiController.ts

@@ -31,8 +31,11 @@ const callPay = async (ctx) => {
         msg: '发货失败'
     }
 
-    const redisClient = ctx.redis.client;
 
+    let data = ctx.request.body
+    logger.info("pay callback params:", { "url": ctx.href, "params": data })
+
+    const redisClient = ctx.redis.client;
     let access_token = await redisClient.get('access_token');
 
     if (!access_token) {
@@ -65,12 +68,10 @@ const callPay = async (ctx) => {
         return ret;
     }
 
-    let data = ctx.request.body
     let orderId = data.orderId
     let googleToken = data.purchaseToken
     let out_trade_no = ''
 
-    logger.info("pay callback params:", { "url": ctx.href, "params": data })
     const orderInfo = (await Order.getOrder(orderId))[0]
 
     if (!orderInfo) {
@@ -102,7 +103,7 @@ const callPay = async (ctx) => {
     // 使用 while 循环进行重试
     while (currentRetry < maxRetries) {
         try {
-            
+
             // // 尝试执行的操作
             const googleRes = await axios.get(apiUrl, {
                 headers: {
@@ -148,6 +149,22 @@ const callPay = async (ctx) => {
                 return;
             }
 
+            let acknowledgeUrl = `https://androidpublisher.googleapis.com/androidpublisher/v3/applications/${PackageName}/purchases/products/${productId}/tokens/${googleToken}:acknowledge?access_token=${access_token}`
+            console.log(acknowledgeUrl)
+            const acknowledgeRes = await axios.post(acknowledgeUrl,
+                {
+                    developerPayload: ""
+                }
+                ,
+                {
+                    headers: {
+                        
+                        'Content-Type': ' application/json'
+                    }
+                })
+
+            console.log(acknowledgeRes.data)
+
             const update_time = formatDate(new Date())
             const res = await Order.updateOrderStats(
                 orderId,