cgserver 6.2.9 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -157,12 +157,12 @@ class IWebSocket {
157
157
  try {
158
158
  if (Core_1.core.isAsyncFunc(otherfunc)) {
159
159
  //默认支持其他所有处理消息
160
- await otherfunc.call(jsonData).catch((reason) => {
160
+ await otherfunc.call(this, jsonData).catch((reason) => {
161
161
  Log_1.GLog.error(reason);
162
162
  });
163
163
  }
164
164
  else {
165
- otherfunc.call(jsonData);
165
+ otherfunc.call(this, jsonData);
166
166
  }
167
167
  }
168
168
  catch (e) {
@@ -177,12 +177,12 @@ class IWebSocket {
177
177
  try {
178
178
  if (Core_1.core.isAsyncFunc(func)) {
179
179
  //默认支持其他所有处理消息
180
- await func.call(jsonData).catch((reason) => {
180
+ await func.call(this, jsonData).catch((reason) => {
181
181
  Log_1.GLog.error(reason);
182
182
  });
183
183
  }
184
184
  else {
185
- func.call(jsonData);
185
+ func.call(this, jsonData);
186
186
  }
187
187
  }
188
188
  catch (e) {
@@ -2,11 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GAlipayTool = void 0;
4
4
  const alipay_sdk_1 = require("alipay-sdk");
5
+ const aliUtil = require("alipay-sdk/lib/util");
5
6
  const AliPayUtil_1 = require("alipay_sdk2/AliPayUtil");
6
7
  const fs = require("fs");
7
8
  const FrameworkConfig_1 = require("../Config/FrameworkConfig");
8
9
  const form_1 = require("alipay-sdk/lib/form");
9
10
  const Log_1 = require("../Logic/Log");
11
+ const cgserver_1 = require("../cgserver");
10
12
  exports.GAlipayTool = null;
11
13
  class AlipayTool {
12
14
  _alipaySdk = null;
@@ -66,6 +68,46 @@ class AlipayTool {
66
68
  });
67
69
  }
68
70
  }
71
+ /**
72
+ * charset:"utf-8",method:"alipay.trade.app.pay",sign_type:"RSA2,version:"1.0"
73
+ * @param out_trade_no
74
+ * @param total_amount
75
+ * @param subject
76
+ * @param body
77
+ * @param timeout_express
78
+ * @param product_code
79
+ * @returns
80
+ */
81
+ _buildOrderParams(out_trade_no, total_amount, subject = "1", body = "我是测试数据", timeout_express = "30m", product_code = "QUICK_MSECURITY_PAY") {
82
+ let order_params = {
83
+ app_id: this._cfg.app_id,
84
+ biz_content: JSON.stringify({
85
+ timeout_express: timeout_express,
86
+ product_code: product_code,
87
+ total_amount: total_amount + "",
88
+ subject: encodeURIComponent(subject),
89
+ body: encodeURIComponent(body),
90
+ out_trade_no: out_trade_no
91
+ }),
92
+ charset: "utf-8",
93
+ method: "alipay.trade.app.pay",
94
+ sign_type: "RSA2",
95
+ timestamp: cgserver_1.core.format(Date.now(), "yyyy-MM-dd hh:mm::ss"),
96
+ version: "1.0"
97
+ };
98
+ return order_params;
99
+ }
100
+ _sign(order_params) {
101
+ let sign = aliUtil.sign("alipay.trade.app.pay", order_params, this._alipaySdk.config);
102
+ return sign;
103
+ }
104
+ getOrderInfo(out_trade_no, total_amount, subject = "1", body = "我是测试数据") {
105
+ let order_params = this._buildOrderParams(out_trade_no, total_amount, subject, body);
106
+ let sign = this._sign(order_params);
107
+ let { url, execParams } = this._alipaySdk["formatUrl"]("", sign);
108
+ const order_info = (url + '&biz_content=' + encodeURIComponent(execParams.biz_content)).substring(1);
109
+ return order_info;
110
+ }
69
111
  /**
70
112
  *
71
113
  * @param title
@@ -8,6 +8,7 @@ class Response {
8
8
  _res = null;
9
9
  _cookie_prefix = "";
10
10
  _cfg = null;
11
+ _create_time = -1;
11
12
  constructor(res, cfg) {
12
13
  this._cfg = cfg;
13
14
  this._res = res;
@@ -15,6 +16,7 @@ class Response {
15
16
  this._init();
16
17
  }
17
18
  _init() {
19
+ this._create_time = Date.now();
18
20
  }
19
21
  /**
20
22
  *
@@ -91,6 +93,7 @@ class Response {
91
93
  if (!this._cfg.debug) {
92
94
  return;
93
95
  }
96
+ Log_1.GLog.info("dttime:" + (Date.now() - this._create_time).toLocaleString() + "ms", true);
94
97
  Log_1.GLog.info(data, true);
95
98
  }
96
99
  }
@@ -17,6 +17,27 @@ declare class AlipayTool {
17
17
  notify_url: string;
18
18
  };
19
19
  init(): boolean;
20
+ /**
21
+ * charset:"utf-8",method:"alipay.trade.app.pay",sign_type:"RSA2,version:"1.0"
22
+ * @param out_trade_no
23
+ * @param total_amount
24
+ * @param subject
25
+ * @param body
26
+ * @param timeout_express
27
+ * @param product_code
28
+ * @returns
29
+ */
30
+ protected _buildOrderParams(out_trade_no: string, total_amount: number, subject?: string, body?: string, timeout_express?: string, product_code?: string): {
31
+ app_id: string;
32
+ biz_content: string;
33
+ charset: string;
34
+ method: string;
35
+ sign_type: string;
36
+ timestamp: any;
37
+ version: string;
38
+ };
39
+ protected _sign(order_params: any): any;
40
+ getOrderInfo(out_trade_no: string, total_amount: number, subject?: string, body?: string): string;
20
41
  /**
21
42
  *
22
43
  * @param title
@@ -4,6 +4,7 @@ export declare class Response {
4
4
  protected _res: Express.Response;
5
5
  protected _cookie_prefix: string;
6
6
  protected _cfg: WebServerConfig;
7
+ protected _create_time: number;
7
8
  constructor(res: Express.Response, cfg: WebServerConfig);
8
9
  protected _init(): void;
9
10
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cgserver",
3
- "version": "6.2.9",
3
+ "version": "6.3.0",
4
4
  "author": "trojan",
5
5
  "type": "commonjs",
6
6
  "description": "free for all.Websocket or Http",
@@ -46,7 +46,6 @@
46
46
  "@types/underscore": "^1.11.3",
47
47
  "@types/urlencode": "^1.1.2",
48
48
  "@types/websocket": "^1.0.4",
49
- "alipay_sdk2": "^1.1.6",
50
49
  "alipay-sdk": "^3.1.7",
51
50
  "colors": "^1.4.0",
52
51
  "cookie-parser": "^1.4.5",