@be-link/ecommerce-promotion-service-node-sdk 0.0.33 → 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.
- package/modules/BaseService.d.ts +7 -2
- package/modules/BaseService.js +14 -3
- package/modules/award/service.d.ts +1 -2
- package/modules/award/service.js +20 -8
- package/modules/award/types.d.ts +7 -39
- package/modules/pricingCalculation/types.d.ts +0 -4
- package/package.json +2 -4
- package/utils/http.js +1 -1
package/modules/BaseService.d.ts
CHANGED
|
@@ -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 = "
|
|
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
|
}
|
package/modules/BaseService.js
CHANGED
|
@@ -12,12 +12,23 @@ const string_1 = require("../utils/string");
|
|
|
12
12
|
class BaseService {
|
|
13
13
|
constructor() {
|
|
14
14
|
/** 子网域名 */
|
|
15
|
-
this.natDevHost = '
|
|
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 =
|
|
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
|
}
|
|
@@ -4,8 +4,7 @@ declare class AwardService extends BaseService implements Service.PrizeDistribut
|
|
|
4
4
|
protected prefixUrl: string;
|
|
5
5
|
distributePrize(request: Service.Request.distributePrize): Promise<Service.Response.distributePrize>;
|
|
6
6
|
reversePrize(request: Service.Request.reversePrize): Promise<Service.Response.distributePrize>;
|
|
7
|
-
liveRoomIssueCoupon(request: Service.Request.
|
|
8
|
-
queryLiveRoomDistributionStats(request: Service.Request.queryLiveRoomDistributionStats): Promise<Service.Response.queryLiveRoomDistributionStatsResponse>;
|
|
7
|
+
liveRoomIssueCoupon(request: Service.Request.liveRoomIssueCoupon): Promise<Service.Response.distributePrize>;
|
|
9
8
|
}
|
|
10
9
|
export declare const awardService: AwardService;
|
|
11
10
|
export default awardService;
|
package/modules/award/service.js
CHANGED
|
@@ -20,6 +20,26 @@ let AwardService = class AwardService extends BaseService_1.default {
|
|
|
20
20
|
constructor() {
|
|
21
21
|
super(...arguments);
|
|
22
22
|
this.prefixUrl = '/award';
|
|
23
|
+
// @OperationId('会员等级积分发放')
|
|
24
|
+
// @Post('issue-member-points')
|
|
25
|
+
// public issueMemberPoints(
|
|
26
|
+
// @Body() request: Service.Request.issueMemberPoints,
|
|
27
|
+
// ): Promise<Service.Response.distributePrize> {
|
|
28
|
+
// return callApi<Service.PrizeDistributionController['issueMemberPoints']>(
|
|
29
|
+
// this.getApiUrl(this.issueMemberPoints),
|
|
30
|
+
// request,
|
|
31
|
+
// )
|
|
32
|
+
// }
|
|
33
|
+
// @OperationId('统计直播间发放数据')
|
|
34
|
+
// @Post('get-live-room-distribution-stats')
|
|
35
|
+
// public getLiveRoomDistributionStats(
|
|
36
|
+
// @Body() request: Service.Request.getLiveRoomDistributionStats,
|
|
37
|
+
// ): Promise<Service.Response.getLiveRoomDistributionStats> {
|
|
38
|
+
// return callApi<Service.PrizeDistributionController['getLiveRoomDistributionStats']>(
|
|
39
|
+
// this.getApiUrl(this.getLiveRoomDistributionStats),
|
|
40
|
+
// request,
|
|
41
|
+
// )
|
|
42
|
+
// }
|
|
23
43
|
}
|
|
24
44
|
distributePrize(request) {
|
|
25
45
|
return (0, http_1.callApi)(this.getApiUrl(this.distributePrize), request);
|
|
@@ -30,9 +50,6 @@ let AwardService = class AwardService extends BaseService_1.default {
|
|
|
30
50
|
liveRoomIssueCoupon(request) {
|
|
31
51
|
return (0, http_1.callApi)(this.getApiUrl(this.liveRoomIssueCoupon), request);
|
|
32
52
|
}
|
|
33
|
-
queryLiveRoomDistributionStats(request) {
|
|
34
|
-
return (0, http_1.callApi)(this.getApiUrl(this.queryLiveRoomDistributionStats), request);
|
|
35
|
-
}
|
|
36
53
|
};
|
|
37
54
|
__decorate([
|
|
38
55
|
(0, tsoa_1.OperationId)('发放奖励'),
|
|
@@ -49,11 +66,6 @@ __decorate([
|
|
|
49
66
|
(0, tsoa_1.Post)('live-room-issue-coupon'),
|
|
50
67
|
__param(0, (0, tsoa_1.Body)())
|
|
51
68
|
], AwardService.prototype, "liveRoomIssueCoupon", null);
|
|
52
|
-
__decorate([
|
|
53
|
-
(0, tsoa_1.OperationId)('直播间积分&券发放统计'),
|
|
54
|
-
(0, tsoa_1.Post)('query-live-room-distribution-stats'),
|
|
55
|
-
__param(0, (0, tsoa_1.Body)())
|
|
56
|
-
], AwardService.prototype, "queryLiveRoomDistributionStats", null);
|
|
57
69
|
AwardService = __decorate([
|
|
58
70
|
(0, tsoa_1.Route)('award'),
|
|
59
71
|
(0, tsoa_1.Tags)('Award')
|
package/modules/award/types.d.ts
CHANGED
|
@@ -65,18 +65,6 @@ export declare namespace Service {
|
|
|
65
65
|
couponId: string;
|
|
66
66
|
/** 活动ID(业务ID) */
|
|
67
67
|
activityId: string;
|
|
68
|
-
/** 时间戳 */
|
|
69
|
-
timestamp: number;
|
|
70
|
-
}
|
|
71
|
-
interface liveRoomIssueCouponEncrypt {
|
|
72
|
-
/** 加密后的数据 */
|
|
73
|
-
encryptData: string;
|
|
74
|
-
/** 加密密钥 */
|
|
75
|
-
encryptKey: string;
|
|
76
|
-
/** 初始化向量 */
|
|
77
|
-
iv: string;
|
|
78
|
-
/** 认证标签 */
|
|
79
|
-
authTag: string;
|
|
80
68
|
}
|
|
81
69
|
/** 会员等级积分发放 */
|
|
82
70
|
interface issueMemberPoints {
|
|
@@ -89,16 +77,14 @@ export declare namespace Service {
|
|
|
89
77
|
/** 业务编号 */
|
|
90
78
|
bizNo: string;
|
|
91
79
|
}
|
|
92
|
-
/**
|
|
93
|
-
interface
|
|
80
|
+
/** 统计直播间发放数据 */
|
|
81
|
+
interface getLiveRoomDistributionStats {
|
|
94
82
|
/** 直播间ID */
|
|
95
83
|
liveRoomId: string;
|
|
96
|
-
/**
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
|
|
100
|
-
/** 每页数量 */
|
|
101
|
-
pageSize?: number;
|
|
84
|
+
/** 开始时间(时间戳) */
|
|
85
|
+
startTime: number;
|
|
86
|
+
/** 结束时间(时间戳) */
|
|
87
|
+
endTime: number;
|
|
102
88
|
}
|
|
103
89
|
}
|
|
104
90
|
namespace Response {
|
|
@@ -109,22 +95,6 @@ export declare namespace Service {
|
|
|
109
95
|
/** 失败原因 */
|
|
110
96
|
message?: string;
|
|
111
97
|
}
|
|
112
|
-
/** 直播间积分&券发放统计响应 */
|
|
113
|
-
interface queryLiveRoomDistributionStatsResponse {
|
|
114
|
-
/** 总数 */
|
|
115
|
-
total: number;
|
|
116
|
-
/** 数据列表 */
|
|
117
|
-
list: {
|
|
118
|
-
/** 用户ID */
|
|
119
|
-
userId: string;
|
|
120
|
-
/** 积分发放数量 */
|
|
121
|
-
points: number;
|
|
122
|
-
/** 券发放数量 */
|
|
123
|
-
coupons: number;
|
|
124
|
-
/** 发放渠道 */
|
|
125
|
-
getChannel: ENUM.AWARD_ENUM.DISTRIBUTION_CHANNEL;
|
|
126
|
-
}[];
|
|
127
|
-
}
|
|
128
98
|
}
|
|
129
99
|
interface PrizeDistributionController {
|
|
130
100
|
/** 发放奖励 */
|
|
@@ -132,8 +102,6 @@ export declare namespace Service {
|
|
|
132
102
|
/** 作废奖励 */
|
|
133
103
|
reversePrize(request: Service.Request.reversePrize, req: any): Promise<Service.Response.distributePrize>;
|
|
134
104
|
/** 直播间发券 */
|
|
135
|
-
liveRoomIssueCoupon(request: Service.Request.
|
|
136
|
-
/** 直播间积分&券发放统计 */
|
|
137
|
-
queryLiveRoomDistributionStats(request: Service.Request.queryLiveRoomDistributionStats, req: any): Promise<Service.Response.queryLiveRoomDistributionStatsResponse>;
|
|
105
|
+
liveRoomIssueCoupon(request: Service.Request.liveRoomIssueCoupon, req: any): Promise<Service.Response.distributePrize>;
|
|
138
106
|
}
|
|
139
107
|
}
|
|
@@ -186,8 +186,6 @@ export declare namespace Service {
|
|
|
186
186
|
availableCouponStats?: Entity.CouponGroupStats[];
|
|
187
187
|
/** 用户可用积分数量 */
|
|
188
188
|
userAvailablePoints?: number;
|
|
189
|
-
/** 使用兑换券券码列表 */
|
|
190
|
-
usedCoupons?: string[];
|
|
191
189
|
}
|
|
192
190
|
/** 积分商城用户选择后再次算价响应 */
|
|
193
191
|
interface recalculatePointsMallOrder {
|
|
@@ -203,8 +201,6 @@ export declare namespace Service {
|
|
|
203
201
|
requiredCoupons?: number;
|
|
204
202
|
/** 使用积分数量 */
|
|
205
203
|
usedPoints?: number;
|
|
206
|
-
/** 用户可用积分数量 */
|
|
207
|
-
userAvailablePoints?: number;
|
|
208
204
|
/** 用户选择优惠券聚合 */
|
|
209
205
|
selectedCouponStats?: Entity.CouponGroupStats[];
|
|
210
206
|
/** 使用兑换券券码列表 */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@be-link/ecommerce-promotion-service-node-sdk",
|
|
3
|
-
"version": "0.0
|
|
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
|
|
83
|
+
throw error;
|
|
84
84
|
}
|
|
85
85
|
// 调用dns模块解析url
|
|
86
86
|
const dns = await Promise.resolve().then(() => __importStar(require('dns')));
|