@be-link/ecommerce-promotion-service-node-sdk 0.0.32 → 0.1.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.
@@ -3,11 +3,16 @@
3
3
  * 所有服务类都应该继承此类
4
4
  */
5
5
  export default abstract class BaseService {
6
+ private isPublicEnv;
6
7
  /** URL一级路径 */
7
8
  protected abstract prefixUrl: string;
8
9
  /** 子网域名 */
9
- protected readonly natDevHost = "https://promotion-service-196345-5-1304510571.sh.run.tcloudbase.com";
10
- protected readonly natProdHost = "";
10
+ protected readonly natDevHost = "http://promotion:8090";
11
+ protected readonly natProdHost = "http://promotion:8090";
12
+ /** 公网域名 */
13
+ protected readonly publicDevHost = "https://ecommerce-dev.wejourney.top";
14
+ protected readonly publicProdHost = "";
15
+ constructor();
11
16
  /** 获取API URL */
12
17
  protected getApiUrl(func: Function): string;
13
18
  }
@@ -12,12 +12,23 @@ const string_1 = require("../utils/string");
12
12
  class BaseService {
13
13
  constructor() {
14
14
  /** 子网域名 */
15
- this.natDevHost = 'https://promotion-service-196345-5-1304510571.sh.run.tcloudbase.com';
16
- this.natProdHost = '';
15
+ this.natDevHost = 'http://promotion:8090';
16
+ this.natProdHost = 'http://promotion:8090';
17
+ /** 公网域名 */
18
+ this.publicDevHost = 'https://ecommerce-dev.wejourney.top';
19
+ this.publicProdHost = '';
20
+ /** 如果是云函数环境, 默认走公网访问 */
21
+ this.isPublicEnv = (process.env.CONTAINER_ENV || 'SCF') === 'SCF';
17
22
  }
18
23
  /** 获取API URL */
19
24
  getApiUrl(func) {
20
- const host = env_1.default.isProduction() ? this.natProdHost : this.natDevHost;
25
+ const host = this.isPublicEnv
26
+ ? env_1.default.isProduction()
27
+ ? this.publicProdHost
28
+ : this.publicDevHost
29
+ : env_1.default.isProduction()
30
+ ? this.natProdHost
31
+ : this.natDevHost;
21
32
  return `${host}${this.prefixUrl}/${(0, string_1.camelToKebabCase)(func.name)}`;
22
33
  }
23
34
  }
@@ -65,8 +65,6 @@ export declare namespace Service {
65
65
  couponId: string;
66
66
  /** 活动ID(业务ID) */
67
67
  activityId: string;
68
- /** 业务编号:唯一标识 */
69
- bizNo: string;
70
68
  }
71
69
  /** 会员等级积分发放 */
72
70
  interface issueMemberPoints {
@@ -97,24 +95,6 @@ export declare namespace Service {
97
95
  /** 失败原因 */
98
96
  message?: string;
99
97
  }
100
- /** 分渠道统计数据 */
101
- interface ChannelStats {
102
- /** 渠道 */
103
- channel: ENUM.AWARD_ENUM.DISTRIBUTION_CHANNEL;
104
- /** 数量 */
105
- count: number;
106
- }
107
- /** 统计直播间发放数据响应 */
108
- interface getLiveRoomDistributionStats {
109
- /** 券发放总数量 */
110
- totalCouponCount: number;
111
- /** 积分发放总数量 */
112
- totalPointsCount: number;
113
- /** 券按渠道统计 */
114
- couponByChannel: ChannelStats[];
115
- /** 积分按渠道统计 */
116
- pointsByChannel: ChannelStats[];
117
- }
118
98
  }
119
99
  interface PrizeDistributionController {
120
100
  /** 发放奖励 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@be-link/ecommerce-promotion-service-node-sdk",
3
- "version": "0.0.32",
3
+ "version": "0.1.0",
4
4
  "description": "EcommercePromotionService Node.js SDK",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -13,9 +13,7 @@
13
13
  "@fastify/request-context": "6.2.1",
14
14
  "axios": "1.13.2",
15
15
  "axios-retry": "4.0.0",
16
- "uuid": "9.0.1"
17
- },
18
- "devDependencies": {
16
+ "uuid": "9.0.1",
19
17
  "tsoa": "^6.6.0"
20
18
  },
21
19
  "scripts": {
package/utils/http.js CHANGED
@@ -80,7 +80,7 @@ async function callApi(url, request) {
80
80
  console.error(`ecommerce-promotion-service 异常: ${axiosError.message},requestId: ${requestId}`);
81
81
  console.info('响应信息', data.message);
82
82
  console.error('异常堆栈', JSON.stringify(error.stack));
83
- throw new Error(data.errorType + ' - ' + data.message);
83
+ throw error;
84
84
  }
85
85
  // 调用dns模块解析url
86
86
  const dns = await Promise.resolve().then(() => __importStar(require('dns')));