@be-link/ecommerce-promotion-service-node-sdk 0.0.1
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/README.md +39 -0
- package/enum.d.ts +219 -0
- package/enum.js +248 -0
- package/index.d.ts +11 -0
- package/index.js +16 -0
- package/modules/BaseService.d.ts +13 -0
- package/modules/BaseService.js +24 -0
- package/modules/award/service.d.ts +12 -0
- package/modules/award/service.js +70 -0
- package/modules/award/types.d.ts +126 -0
- package/modules/award/types.js +2 -0
- package/modules/config/service.d.ts +8 -0
- package/modules/config/service.js +38 -0
- package/modules/config/types.d.ts +17 -0
- package/modules/config/types.js +2 -0
- package/modules/coupon/service.d.ts +13 -0
- package/modules/coupon/service.js +78 -0
- package/modules/coupon/types.d.ts +371 -0
- package/modules/coupon/types.js +2 -0
- package/modules/pointsMall/service.d.ts +12 -0
- package/modules/pointsMall/service.js +70 -0
- package/modules/pointsMall/types.d.ts +135 -0
- package/modules/pointsMall/types.js +19 -0
- package/modules/pricingCalculation/service.d.ts +11 -0
- package/modules/pricingCalculation/service.js +62 -0
- package/modules/pricingCalculation/types.d.ts +219 -0
- package/modules/pricingCalculation/types.js +2 -0
- package/package.json +28 -0
- package/utils/env.d.ts +12 -0
- package/utils/env.js +18 -0
- package/utils/http.d.ts +7 -0
- package/utils/http.js +97 -0
- package/utils/string.d.ts +9 -0
- package/utils/string.js +14 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
9
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.pointsMallService = void 0;
|
|
16
|
+
const tsoa_1 = require("tsoa");
|
|
17
|
+
const http_1 = require("../../utils/http");
|
|
18
|
+
const BaseService_1 = __importDefault(require("../BaseService"));
|
|
19
|
+
let PointsMallService = class PointsMallService extends BaseService_1.default {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.prefixUrl = '/points-mall';
|
|
23
|
+
}
|
|
24
|
+
createProduct(request) {
|
|
25
|
+
return (0, http_1.callApi)(this.getApiUrl(this.createProduct), request);
|
|
26
|
+
}
|
|
27
|
+
updateProduct(request) {
|
|
28
|
+
return (0, http_1.callApi)(this.getApiUrl(this.updateProduct), request);
|
|
29
|
+
}
|
|
30
|
+
batchToggleProductEnabled(request) {
|
|
31
|
+
return (0, http_1.callApi)(this.getApiUrl(this.batchToggleProductEnabled), request);
|
|
32
|
+
}
|
|
33
|
+
batchToggleProductOnline(request) {
|
|
34
|
+
return (0, http_1.callApi)(this.getApiUrl(this.batchToggleProductOnline), request);
|
|
35
|
+
}
|
|
36
|
+
queryProducts(request) {
|
|
37
|
+
return (0, http_1.callApi)(this.getApiUrl(this.queryProducts), request);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, tsoa_1.OperationId)('创建积分商城商品'),
|
|
42
|
+
(0, tsoa_1.Post)('create-product'),
|
|
43
|
+
__param(0, (0, tsoa_1.Body)())
|
|
44
|
+
], PointsMallService.prototype, "createProduct", null);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, tsoa_1.OperationId)('编辑积分商城商品'),
|
|
47
|
+
(0, tsoa_1.Post)('update-product'),
|
|
48
|
+
__param(0, (0, tsoa_1.Body)())
|
|
49
|
+
], PointsMallService.prototype, "updateProduct", null);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, tsoa_1.OperationId)('批量是否开启'),
|
|
52
|
+
(0, tsoa_1.Post)('batch-toggle-product-enabled'),
|
|
53
|
+
__param(0, (0, tsoa_1.Body)())
|
|
54
|
+
], PointsMallService.prototype, "batchToggleProductEnabled", null);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, tsoa_1.OperationId)('批量是否上下架'),
|
|
57
|
+
(0, tsoa_1.Post)('batch-toggle-product-online'),
|
|
58
|
+
__param(0, (0, tsoa_1.Body)())
|
|
59
|
+
], PointsMallService.prototype, "batchToggleProductOnline", null);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, tsoa_1.OperationId)('根据条件查询积分商城商品'),
|
|
62
|
+
(0, tsoa_1.Post)('query-products'),
|
|
63
|
+
__param(0, (0, tsoa_1.Body)())
|
|
64
|
+
], PointsMallService.prototype, "queryProducts", null);
|
|
65
|
+
PointsMallService = __decorate([
|
|
66
|
+
(0, tsoa_1.Route)('points-mall'),
|
|
67
|
+
(0, tsoa_1.Tags)('PointsMall')
|
|
68
|
+
], PointsMallService);
|
|
69
|
+
exports.pointsMallService = new PointsMallService();
|
|
70
|
+
exports.default = exports.pointsMallService;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
export declare namespace Service {
|
|
2
|
+
/** 兑换类型 */
|
|
3
|
+
enum ExchangeType {
|
|
4
|
+
/** 仅积分 */
|
|
5
|
+
POINTS_ONLY = "POINTS_ONLY",
|
|
6
|
+
/** 仅券 */
|
|
7
|
+
COUPON_ONLY = "COUPON_ONLY",
|
|
8
|
+
/** 积分+券 */
|
|
9
|
+
POINTS_AND_COUPON = "POINTS_AND_COUPON",
|
|
10
|
+
/** 其他 */
|
|
11
|
+
OTHER = "OTHER"
|
|
12
|
+
}
|
|
13
|
+
namespace Entity {
|
|
14
|
+
/** 商品积分兑换配置 */
|
|
15
|
+
interface ProductPointExchange {
|
|
16
|
+
/** 主键ID */
|
|
17
|
+
id: string;
|
|
18
|
+
/** 创建时间 */
|
|
19
|
+
createdAt: number;
|
|
20
|
+
/** 更新时间 */
|
|
21
|
+
updatedAt: number;
|
|
22
|
+
/** 删除时间 */
|
|
23
|
+
deletedAt: number;
|
|
24
|
+
/** 商品ID */
|
|
25
|
+
productId: string;
|
|
26
|
+
/** 所需券的数量 */
|
|
27
|
+
couponRequired: number;
|
|
28
|
+
/** 所需积分的数量 */
|
|
29
|
+
pointsRequired: number;
|
|
30
|
+
/** 兑换类型 */
|
|
31
|
+
exchangeType: ExchangeType;
|
|
32
|
+
/** 是否开启 */
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
/** 是否上架 */
|
|
35
|
+
online: boolean;
|
|
36
|
+
/** 排序权重 */
|
|
37
|
+
sortOrder: number;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
namespace Request {
|
|
41
|
+
/** 创建积分商城商品 */
|
|
42
|
+
interface createProduct {
|
|
43
|
+
/** 商品ID */
|
|
44
|
+
productId: string;
|
|
45
|
+
/** 所需券的数量 */
|
|
46
|
+
couponRequired?: number;
|
|
47
|
+
/** 所需积分的数量 */
|
|
48
|
+
pointsRequired?: number;
|
|
49
|
+
/** 兑换类型 */
|
|
50
|
+
exchangeType: ExchangeType;
|
|
51
|
+
/** 是否开启 */
|
|
52
|
+
enabled?: boolean;
|
|
53
|
+
/** 是否上架 */
|
|
54
|
+
online?: boolean;
|
|
55
|
+
/** 排序权重 */
|
|
56
|
+
sortOrder: number;
|
|
57
|
+
}
|
|
58
|
+
/** 编辑积分商城商品 */
|
|
59
|
+
interface updateProduct {
|
|
60
|
+
/** 主键ID */
|
|
61
|
+
id: string;
|
|
62
|
+
/** 商品ID */
|
|
63
|
+
productId?: string;
|
|
64
|
+
/** 所需券的数量 */
|
|
65
|
+
couponRequired?: number;
|
|
66
|
+
/** 所需积分的数量 */
|
|
67
|
+
pointsRequired?: number;
|
|
68
|
+
/** 兑换类型 */
|
|
69
|
+
exchangeType?: ExchangeType;
|
|
70
|
+
/** 是否开启 */
|
|
71
|
+
enabled?: boolean;
|
|
72
|
+
/** 是否上架 */
|
|
73
|
+
online?: boolean;
|
|
74
|
+
/** 排序权重 */
|
|
75
|
+
sortOrder?: number;
|
|
76
|
+
}
|
|
77
|
+
/** 批量是否开启 */
|
|
78
|
+
interface batchToggleProductEnabled {
|
|
79
|
+
/** 主键ID列表 */
|
|
80
|
+
ids: string[];
|
|
81
|
+
/** 是否开启 */
|
|
82
|
+
enabled: boolean;
|
|
83
|
+
}
|
|
84
|
+
/** 批量是否上下架 */
|
|
85
|
+
interface batchToggleProductOnline {
|
|
86
|
+
/** 主键ID列表 */
|
|
87
|
+
ids: string[];
|
|
88
|
+
/** 是否上架 */
|
|
89
|
+
online: boolean;
|
|
90
|
+
}
|
|
91
|
+
/** 根据条件查询积分商城商品 */
|
|
92
|
+
interface queryProducts {
|
|
93
|
+
/** 主键ID */
|
|
94
|
+
id?: string;
|
|
95
|
+
/** 是否开启 */
|
|
96
|
+
enabled?: boolean;
|
|
97
|
+
/** 是否上架 */
|
|
98
|
+
online?: boolean;
|
|
99
|
+
/** 页码 */
|
|
100
|
+
page?: number;
|
|
101
|
+
/** 每页数量 */
|
|
102
|
+
pageSize?: number;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
namespace Response {
|
|
106
|
+
/** 创建积分商城商品响应 */
|
|
107
|
+
interface createProduct {
|
|
108
|
+
/** 主键ID */
|
|
109
|
+
id: string;
|
|
110
|
+
}
|
|
111
|
+
/** 查询积分商城商品响应 */
|
|
112
|
+
interface queryProducts {
|
|
113
|
+
/** 商品列表 */
|
|
114
|
+
items: Entity.ProductPointExchange[];
|
|
115
|
+
/** 总数 */
|
|
116
|
+
total: number;
|
|
117
|
+
/** 当前页码 */
|
|
118
|
+
page: number;
|
|
119
|
+
/** 每页数量 */
|
|
120
|
+
pageSize: number;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
interface PointsMallController {
|
|
124
|
+
/** 创建积分商城商品 */
|
|
125
|
+
createProduct(request: Service.Request.createProduct, req: any): Promise<Service.Response.createProduct>;
|
|
126
|
+
/** 编辑积分商城商品 */
|
|
127
|
+
updateProduct(request: Service.Request.updateProduct, req: any): Promise<void>;
|
|
128
|
+
/** 批量是否开启 */
|
|
129
|
+
batchToggleProductEnabled(request: Service.Request.batchToggleProductEnabled, req: any): Promise<void>;
|
|
130
|
+
/** 批量是否上下架 */
|
|
131
|
+
batchToggleProductOnline(request: Service.Request.batchToggleProductOnline, req: any): Promise<void>;
|
|
132
|
+
/** 根据条件查询积分商城商品 */
|
|
133
|
+
queryProducts(request: Service.Request.queryProducts, req: any): Promise<Service.Response.queryProducts>;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Service = void 0;
|
|
4
|
+
var Service;
|
|
5
|
+
(function (Service) {
|
|
6
|
+
// ==================== 枚举类型 ====================
|
|
7
|
+
/** 兑换类型 */
|
|
8
|
+
let ExchangeType;
|
|
9
|
+
(function (ExchangeType) {
|
|
10
|
+
/** 仅积分 */
|
|
11
|
+
ExchangeType["POINTS_ONLY"] = "POINTS_ONLY";
|
|
12
|
+
/** 仅券 */
|
|
13
|
+
ExchangeType["COUPON_ONLY"] = "COUPON_ONLY";
|
|
14
|
+
/** 积分+券 */
|
|
15
|
+
ExchangeType["POINTS_AND_COUPON"] = "POINTS_AND_COUPON";
|
|
16
|
+
/** 其他 */
|
|
17
|
+
ExchangeType["OTHER"] = "OTHER";
|
|
18
|
+
})(ExchangeType = Service.ExchangeType || (Service.ExchangeType = {}));
|
|
19
|
+
})(Service || (exports.Service = Service = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Service } from './types';
|
|
2
|
+
import BaseService from '../BaseService';
|
|
3
|
+
declare class PricingCalculationService extends BaseService implements Service.PricingCalculationController {
|
|
4
|
+
protected prefixUrl: string;
|
|
5
|
+
calculateOrderPrice(request: Service.Request.calculateOrderPrice): Promise<Service.Response.calculateOrderPrice>;
|
|
6
|
+
calculateWithSelectedDiscounts(request: Service.Request.calculateWithSelectedDiscounts): Promise<Service.Response.calculateWithSelectedDiscounts>;
|
|
7
|
+
calculatePointsMallOrder(request: Service.Request.calculatePointsMallOrder): Promise<Service.Response.calculatePointsMallOrder>;
|
|
8
|
+
recalculatePointsMallOrder(request: Service.Request.recalculatePointsMallOrder): Promise<Service.Response.recalculatePointsMallOrder>;
|
|
9
|
+
}
|
|
10
|
+
export declare const pricingCalculationService: PricingCalculationService;
|
|
11
|
+
export default pricingCalculationService;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
9
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.pricingCalculationService = void 0;
|
|
16
|
+
const tsoa_1 = require("tsoa");
|
|
17
|
+
const http_1 = require("../../utils/http");
|
|
18
|
+
const BaseService_1 = __importDefault(require("../BaseService"));
|
|
19
|
+
let PricingCalculationService = class PricingCalculationService extends BaseService_1.default {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.prefixUrl = '/pricing-calculation';
|
|
23
|
+
}
|
|
24
|
+
calculateOrderPrice(request) {
|
|
25
|
+
return (0, http_1.callApi)(this.getApiUrl(this.calculateOrderPrice), request);
|
|
26
|
+
}
|
|
27
|
+
calculateWithSelectedDiscounts(request) {
|
|
28
|
+
return (0, http_1.callApi)(this.getApiUrl(this.calculateWithSelectedDiscounts), request);
|
|
29
|
+
}
|
|
30
|
+
calculatePointsMallOrder(request) {
|
|
31
|
+
return (0, http_1.callApi)(this.getApiUrl(this.calculatePointsMallOrder), request);
|
|
32
|
+
}
|
|
33
|
+
recalculatePointsMallOrder(request) {
|
|
34
|
+
return (0, http_1.callApi)(this.getApiUrl(this.recalculatePointsMallOrder), request);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, tsoa_1.OperationId)('提单页算价'),
|
|
39
|
+
(0, tsoa_1.Post)('calculate-order-price'),
|
|
40
|
+
__param(0, (0, tsoa_1.Body)())
|
|
41
|
+
], PricingCalculationService.prototype, "calculateOrderPrice", null);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, tsoa_1.OperationId)('用户手动选择优惠后算价'),
|
|
44
|
+
(0, tsoa_1.Post)('calculate-with-selected-discounts'),
|
|
45
|
+
__param(0, (0, tsoa_1.Body)())
|
|
46
|
+
], PricingCalculationService.prototype, "calculateWithSelectedDiscounts", null);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, tsoa_1.OperationId)('积分商城提单算价'),
|
|
49
|
+
(0, tsoa_1.Post)('calculate-points-mall-order'),
|
|
50
|
+
__param(0, (0, tsoa_1.Body)())
|
|
51
|
+
], PricingCalculationService.prototype, "calculatePointsMallOrder", null);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, tsoa_1.OperationId)('积分商城用户选择后再次算价'),
|
|
54
|
+
(0, tsoa_1.Post)('recalculate-points-mall-order'),
|
|
55
|
+
__param(0, (0, tsoa_1.Body)())
|
|
56
|
+
], PricingCalculationService.prototype, "recalculatePointsMallOrder", null);
|
|
57
|
+
PricingCalculationService = __decorate([
|
|
58
|
+
(0, tsoa_1.Route)('pricing-calculation'),
|
|
59
|
+
(0, tsoa_1.Tags)('PricingCalculation')
|
|
60
|
+
], PricingCalculationService);
|
|
61
|
+
exports.pricingCalculationService = new PricingCalculationService();
|
|
62
|
+
exports.default = exports.pricingCalculationService;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { ENUM } from '../../enum';
|
|
2
|
+
export declare namespace Service {
|
|
3
|
+
namespace Entity {
|
|
4
|
+
/** 商品信息 */
|
|
5
|
+
interface ProductItem {
|
|
6
|
+
/** 商品ID */
|
|
7
|
+
productId: string;
|
|
8
|
+
/** 商品名称 */
|
|
9
|
+
productName?: string;
|
|
10
|
+
/** 商品数量 */
|
|
11
|
+
quantity: number;
|
|
12
|
+
/** 商品单价(分) */
|
|
13
|
+
unitPrice: number;
|
|
14
|
+
/** SKU ID */
|
|
15
|
+
skuId?: string;
|
|
16
|
+
/** SKU信息 */
|
|
17
|
+
skuInfo?: any;
|
|
18
|
+
}
|
|
19
|
+
/** 优惠券信息 */
|
|
20
|
+
interface CouponInfo {
|
|
21
|
+
/** 用户券ID */
|
|
22
|
+
userCouponId: string;
|
|
23
|
+
/** 券模板ID */
|
|
24
|
+
couponId: string;
|
|
25
|
+
/** 券码 */
|
|
26
|
+
couponCode: string;
|
|
27
|
+
/** 券名称 */
|
|
28
|
+
couponName: string;
|
|
29
|
+
/** 券类型 */
|
|
30
|
+
couponType: ENUM.PRICING_CALCULATION_ENUM.CouponType;
|
|
31
|
+
/** 优惠金额(分) */
|
|
32
|
+
discountAmount: number;
|
|
33
|
+
/** 生效时间 */
|
|
34
|
+
effectAt: number;
|
|
35
|
+
/** 过期时间 */
|
|
36
|
+
expireAt: number;
|
|
37
|
+
/** 优惠规则描述 */
|
|
38
|
+
ruleDescription?: string;
|
|
39
|
+
/** 最优选中 */
|
|
40
|
+
isSelected?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** 积分抵扣规则 */
|
|
43
|
+
interface PointsDeductionRule {
|
|
44
|
+
/** 是否可用积分 */
|
|
45
|
+
available: boolean;
|
|
46
|
+
/** 用户可用积分 */
|
|
47
|
+
userAvailablePoints: number;
|
|
48
|
+
/** 本单最多可用积分 */
|
|
49
|
+
maxUsablePoints: number;
|
|
50
|
+
/** 本单最少可用积分 */
|
|
51
|
+
minUsablePoints: number;
|
|
52
|
+
/** 积分抵扣比例(如:10积分=1元,则值为10) */
|
|
53
|
+
pointsToMoneyRatio: number;
|
|
54
|
+
/** 积分抵扣规则描述 */
|
|
55
|
+
ruleDescription?: string;
|
|
56
|
+
}
|
|
57
|
+
/** 优惠券分组统计 */
|
|
58
|
+
interface CouponGroupStats {
|
|
59
|
+
/** 券类型 */
|
|
60
|
+
couponType: ENUM.PRICING_CALCULATION_ENUM.CouponType;
|
|
61
|
+
/** 该类型券可用数量 */
|
|
62
|
+
count?: number;
|
|
63
|
+
/** 最优选中数量 */
|
|
64
|
+
selectedCount: number;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
namespace Request {
|
|
68
|
+
/** 提单页算价 */
|
|
69
|
+
interface calculateOrderPrice {
|
|
70
|
+
/** 用户ID */
|
|
71
|
+
userId: string;
|
|
72
|
+
/** 商品ID */
|
|
73
|
+
productId: string;
|
|
74
|
+
/** 商品数量 */
|
|
75
|
+
quantity: number;
|
|
76
|
+
/** SKU ID */
|
|
77
|
+
skuId: string;
|
|
78
|
+
/** 订单来源 */
|
|
79
|
+
source: ENUM.PRICING_CALCULATION_ENUM.OrderSource;
|
|
80
|
+
}
|
|
81
|
+
/** 用户手动选择优惠后算价 */
|
|
82
|
+
interface calculateWithSelectedDiscounts {
|
|
83
|
+
/** 用户ID */
|
|
84
|
+
userId: string;
|
|
85
|
+
/** 商品ID */
|
|
86
|
+
productId: string;
|
|
87
|
+
/** 商品数量 */
|
|
88
|
+
quantity: number;
|
|
89
|
+
/** SKU ID */
|
|
90
|
+
skuId: string;
|
|
91
|
+
/** 选择的优惠券券码列表 */
|
|
92
|
+
selectedCouponCodes?: string[];
|
|
93
|
+
/** 使用的积分数量 */
|
|
94
|
+
pointsToUse?: number;
|
|
95
|
+
}
|
|
96
|
+
/** 积分商城提单算价 */
|
|
97
|
+
interface calculatePointsMallOrder {
|
|
98
|
+
/** 商品ID */
|
|
99
|
+
productId: string;
|
|
100
|
+
/** 用户ID */
|
|
101
|
+
userId: string;
|
|
102
|
+
/** 商品数量 */
|
|
103
|
+
quantity: number;
|
|
104
|
+
/** SKU ID */
|
|
105
|
+
skuId: string;
|
|
106
|
+
}
|
|
107
|
+
/** 积分商城用户选择后再次算价 */
|
|
108
|
+
interface recalculatePointsMallOrder {
|
|
109
|
+
/** 用户ID */
|
|
110
|
+
userId: string;
|
|
111
|
+
/** 商品ID */
|
|
112
|
+
productId: string;
|
|
113
|
+
/** SKU ID */
|
|
114
|
+
skuId: string;
|
|
115
|
+
/** 商品数量 */
|
|
116
|
+
quantity: number;
|
|
117
|
+
/** 用户选择优惠券 */
|
|
118
|
+
selectedCouponStats: Entity.CouponGroupStats[];
|
|
119
|
+
/** 使用的积分数量 */
|
|
120
|
+
pointsToUse?: number;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
namespace Response {
|
|
124
|
+
/** 提单页算价响应 */
|
|
125
|
+
interface calculateOrderPrice {
|
|
126
|
+
/** 商品原价总计(分) */
|
|
127
|
+
originalAmount: number;
|
|
128
|
+
/** 总优惠金额(分) */
|
|
129
|
+
totalDiscountAmount: number;
|
|
130
|
+
/** 优惠后金额(分) */
|
|
131
|
+
discountedAmount: number;
|
|
132
|
+
/** 最高抵扣金额(分) */
|
|
133
|
+
pointsMaxDeductionAmount: number;
|
|
134
|
+
/** 剩余待支付金额(分) */
|
|
135
|
+
remainingAmount: number;
|
|
136
|
+
/** 最优优惠券组合 */
|
|
137
|
+
/** 积分抵扣规则 */
|
|
138
|
+
pointsDeductionRule: Entity.PointsDeductionRule;
|
|
139
|
+
/** 用户所有可用优惠券列表 */
|
|
140
|
+
availableCoupons?: Entity.CouponInfo[];
|
|
141
|
+
}
|
|
142
|
+
/** 优惠明细项 */
|
|
143
|
+
interface DiscountDetailItem {
|
|
144
|
+
/** 优惠类型(coupon-优惠券、points-积分) */
|
|
145
|
+
type: string;
|
|
146
|
+
/** 优惠名称 */
|
|
147
|
+
name: string;
|
|
148
|
+
/** 优惠金额(分) */
|
|
149
|
+
amount: number;
|
|
150
|
+
/** 明细ID(如券码、积分记录ID) */
|
|
151
|
+
detailId?: string;
|
|
152
|
+
}
|
|
153
|
+
/** 用户手动选择优惠后算价响应 */
|
|
154
|
+
interface calculateWithSelectedDiscounts {
|
|
155
|
+
/** 订单原价(分) */
|
|
156
|
+
originalAmount: number;
|
|
157
|
+
/** 券优惠金额(分) */
|
|
158
|
+
couponDiscountAmount: number;
|
|
159
|
+
/** 积分抵扣金额(分) */
|
|
160
|
+
pointsDeductionAmount: number;
|
|
161
|
+
/** 总优惠金额(分) */
|
|
162
|
+
totalDiscountAmount: number;
|
|
163
|
+
/** 最终待支付金额(分) */
|
|
164
|
+
finalPayableAmount: number;
|
|
165
|
+
/** 实际使用的积分数量 */
|
|
166
|
+
actualUsedPoints: number;
|
|
167
|
+
/** 使用的优惠券列表 */
|
|
168
|
+
usedCoupons: Entity.CouponInfo[];
|
|
169
|
+
/** 是否有效(优惠券或积分是否可用) */
|
|
170
|
+
isValid: boolean;
|
|
171
|
+
/** 无效原因(如果无效) */
|
|
172
|
+
invalidReason?: string;
|
|
173
|
+
}
|
|
174
|
+
/** 积分商城提单算价响应 */
|
|
175
|
+
interface calculatePointsMallOrder {
|
|
176
|
+
/** 商品ID */
|
|
177
|
+
productId: string;
|
|
178
|
+
/** SKU ID */
|
|
179
|
+
skuId: string;
|
|
180
|
+
/** 商品数量 */
|
|
181
|
+
quantity: number;
|
|
182
|
+
/** 兑换所需积分 */
|
|
183
|
+
requiredPoints: number;
|
|
184
|
+
/** 兑换所需优惠券数量 */
|
|
185
|
+
requiredCoupons: number;
|
|
186
|
+
/** 用户可用优惠券分组统计 */
|
|
187
|
+
availableCouponStats: Entity.CouponGroupStats[];
|
|
188
|
+
/** 用户可用积分数量 */
|
|
189
|
+
userAvailablePoints?: number;
|
|
190
|
+
}
|
|
191
|
+
/** 积分商城用户选择后再次算价响应 */
|
|
192
|
+
interface recalculatePointsMallOrder {
|
|
193
|
+
/** 商品ID */
|
|
194
|
+
productId: string;
|
|
195
|
+
/** SKU ID */
|
|
196
|
+
skuId: string;
|
|
197
|
+
/** 商品数量 */
|
|
198
|
+
quantity: number;
|
|
199
|
+
/** 兑换所需积分 */
|
|
200
|
+
requiredPoints: number;
|
|
201
|
+
/** 兑换所需优惠券数量 */
|
|
202
|
+
requiredCoupons: number;
|
|
203
|
+
/** 使用积分数量 */
|
|
204
|
+
usedPoints: number;
|
|
205
|
+
/** 使用兑换券明细列表 */
|
|
206
|
+
usedCoupons: Entity.CouponInfo[];
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
interface PricingCalculationController {
|
|
210
|
+
/** 提单页算价 */
|
|
211
|
+
calculateOrderPrice(request: Service.Request.calculateOrderPrice, req: any): Promise<Service.Response.calculateOrderPrice>;
|
|
212
|
+
/** 用户手动选择优惠后算价 */
|
|
213
|
+
calculateWithSelectedDiscounts(request: Service.Request.calculateWithSelectedDiscounts, req: any): Promise<Service.Response.calculateWithSelectedDiscounts>;
|
|
214
|
+
/** 积分商城提单算价 */
|
|
215
|
+
calculatePointsMallOrder(request: Service.Request.calculatePointsMallOrder, req: any): Promise<Service.Response.calculatePointsMallOrder>;
|
|
216
|
+
/** 积分商城用户选择后再次算价 */
|
|
217
|
+
recalculatePointsMallOrder(request: Service.Request.recalculatePointsMallOrder, req: any): Promise<Service.Response.recalculatePointsMallOrder>;
|
|
218
|
+
}
|
|
219
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@be-link/ecommerce-promotion-service-node-sdk",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "EcommercePromotionService Node.js SDK",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"author": "",
|
|
8
|
+
"license": "ISC",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@fastify/request-context": "6.2.1",
|
|
14
|
+
"axios": "1.13.2",
|
|
15
|
+
"axios-retry": "4.0.0",
|
|
16
|
+
"uuid": "9.0.1"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"tsoa": "^6.6.0"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "rm -rf ./dist && tsc && cp package.json README.md ./dist/ 2>/dev/null || true",
|
|
23
|
+
"test": "jest",
|
|
24
|
+
"swagger": "tsoa spec",
|
|
25
|
+
"build:swagger": "npm run swagger && npm run build && npm run swagger",
|
|
26
|
+
"generate:service": "node scripts/generate-service.js"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/utils/env.d.ts
ADDED
package/utils/env.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class EnvUtils {
|
|
4
|
+
/**
|
|
5
|
+
* 判断是否为生产环境
|
|
6
|
+
*/
|
|
7
|
+
isProduction() {
|
|
8
|
+
return process.env.NODE_ENV === 'prod';
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 获取环境变量
|
|
12
|
+
*/
|
|
13
|
+
getEnv(key, defaultValue) {
|
|
14
|
+
return process.env[key] || defaultValue;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const envUtils = new EnvUtils();
|
|
18
|
+
exports.default = envUtils;
|
package/utils/http.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare module '@fastify/request-context' {
|
|
2
|
+
interface RequestContextData {
|
|
3
|
+
requestId?: string;
|
|
4
|
+
traceMessageId?: string;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export declare function callApi<T extends (...args: any[]) => Promise<any>>(url: string, request?: Parameters<T>[0]): Promise<Awaited<ReturnType<T>>>;
|