xiongzhu 3 anos atrás
pai
commit
d170fe3ea3
1 arquivos alterados com 23 adições e 22 exclusões
  1. 23 22
      notify.js

+ 23 - 22
notify.js

@@ -1,29 +1,30 @@
 const axios = require("axios");
 const qs = require("qs");
 const fs = require("fs");
-const encryptUtil = require("./encryptUtil");
-const { Producer, PushConsumer } = require("apache-rocketmq");
+const queue = require("queue");
 
-const producer = new Producer("my-producer-dev", "test", {
-    nameServer: "120.24.204.226:9876",
+axios.defaults.baseURL = "https://test.raex.vip";
+const q = queue({ results: [], concurrency: 500 });
+JSON.parse(fs.readFileSync("orders.json").toString()).forEach((orderId) => {
+    q.push((cb) => {
+        axios
+            .post(
+                "/adapay/ordertest/" +
+                    orderId +
+                    "?transactionId=" +
+                    new Date().getTime()
+            )
+            .then((res) => {
+                console.log(orderId + " ok");
+                cb();
+            })
+            .catch((e) => {
+                console.log(orderId + " fail");
+                cb();
+            });
+    });
 });
 
-producer.start(function (err) {
-    if (err) {
-        console.log(err);
-    } else {
-        JSON.parse(fs.readFileSync("orders.json").toString()).forEach(
-            (order) => {
-                producer.send(
-                    "order-notify-topic-test",
-                    JSON.stringify({
-                        orderId: order.id,
-                        payMethod: "ALIPAY",
-                        transactionId: new Date().getTime(),
-                        time: new Date().getTime(),
-                    })
-                );
-            }
-        );
-    }
+q.start(() => {
+    console.log("done");
 });