@be-link/ecommerce-promotion-service-node-sdk 0.0.24 → 0.0.25

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,7 +3,7 @@ import BaseService from '../BaseService';
3
3
  declare class PricingCalculationService extends BaseService implements Service.PricingCalculationController {
4
4
  protected prefixUrl: string;
5
5
  calculateOrderPrice(request: Service.Request.calculateOrderPrice): Promise<Service.Response.calculateOrderPrice>;
6
- calculateWithSelectedDiscounts(request: Service.Request.calculateWithSelectedDiscounts): Promise<Service.Response.calculateWithSelectedDiscounts>;
6
+ calculateWithSelectedDiscounts(request: Service.Request.calculateWithSelectedDiscounts): Promise<Service.Response.calculateOrderPrice>;
7
7
  calculatePointsMallOrder(request: Service.Request.calculatePointsMallOrder): Promise<Service.Response.calculatePointsMallOrder>;
8
8
  recalculatePointsMallOrder(request: Service.Request.recalculatePointsMallOrder): Promise<Service.Response.recalculatePointsMallOrder>;
9
9
  }
@@ -121,28 +121,6 @@ export declare namespace Service {
121
121
  }
122
122
  }
123
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
- optimalCoupons: {
138
- couponCode: string;
139
- discountAmount: number;
140
- }[];
141
- /** 可用优惠券模版 */
142
- availableCouponTemplates?: string[];
143
- /** 积分抵扣规则 */
144
- pointsDeductionRule?: Entity.PointsDeductionRule;
145
- }
146
124
  /** 优惠明细项 */
147
125
  interface DiscountDetailItem {
148
126
  /** 优惠类型(coupon-优惠券、points-积分) */
@@ -164,7 +142,7 @@ export declare namespace Service {
164
142
  invalidCoupons?: string[];
165
143
  }
166
144
  /** 用户手动选择优惠后算价响应 */
167
- interface calculateWithSelectedDiscounts {
145
+ interface calculateOrderPrice {
168
146
  /** 本单最多可用积分 */
169
147
  maxUsablePoints: number;
170
148
  /** 价格计算结果 */
@@ -180,7 +158,15 @@ export declare namespace Service {
180
158
  /** 剩余待支付金额(分) */
181
159
  remainingAmount: number;
182
160
  };
183
- validation: ValidateSelectedCouponResult;
161
+ /** 优惠券组合 */
162
+ selectedCoupons: {
163
+ couponCode: string;
164
+ discountAmount: number;
165
+ }[];
166
+ /** 可用优惠券模版 */
167
+ availableCouponTemplates: string[];
168
+ /** 校验结果 */
169
+ validation?: ValidateSelectedCouponResult;
184
170
  }
185
171
  /** 积分商城提单算价响应 */
186
172
  interface calculatePointsMallOrder {
@@ -229,7 +215,7 @@ export declare namespace Service {
229
215
  /** 提单页算价 */
230
216
  calculateOrderPrice(request: Service.Request.calculateOrderPrice, req: any): Promise<Service.Response.calculateOrderPrice>;
231
217
  /** 用户手动选择优惠后算价 */
232
- calculateWithSelectedDiscounts(request: Service.Request.calculateWithSelectedDiscounts, req: any): Promise<Service.Response.calculateWithSelectedDiscounts>;
218
+ calculateWithSelectedDiscounts(request: Service.Request.calculateWithSelectedDiscounts, req: any): Promise<Service.Response.calculateOrderPrice>;
233
219
  /** 积分商城提单算价 */
234
220
  calculatePointsMallOrder(request: Service.Request.calculatePointsMallOrder, req: any): Promise<Service.Response.calculatePointsMallOrder>;
235
221
  /** 积分商城用户选择后再次算价 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@be-link/ecommerce-promotion-service-node-sdk",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "description": "EcommercePromotionService Node.js SDK",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/utils/http.d.ts CHANGED
@@ -2,6 +2,9 @@ declare module '@fastify/request-context' {
2
2
  interface RequestContextData {
3
3
  requestId?: string;
4
4
  traceMessageId?: string;
5
+ pandoraUserId?: string;
6
+ beLinkUserId?: string;
7
+ pandoraRoleId?: string;
5
8
  }
6
9
  }
7
10
  export declare function callApi<T extends (...args: any[]) => Promise<any>>(url: string, request?: Parameters<T>[0]): Promise<Awaited<ReturnType<T>>>;
package/utils/http.js CHANGED
@@ -56,10 +56,18 @@ const request_context_1 = require("@fastify/request-context");
56
56
  });
57
57
  async function callApi(url, request) {
58
58
  const requestId = request_context_1.requestContext.get('requestId') || request_context_1.requestContext.get('traceMessageId') || (0, uuid_1.v4)();
59
+ const pandoraUserId = request_context_1.requestContext.get('pandoraUserId') || '';
60
+ const beLinkUserId = request_context_1.requestContext.get('beLinkUserId') || '';
61
+ const pandoraRoleId = request_context_1.requestContext.get('pandoraRoleId') || '';
59
62
  try {
60
63
  console.info(`准备发起ecommerce-promotion-service请求[${requestId}]: ${url}, 参数: ${JSON.stringify(request)}`);
61
64
  const response = await axios_1.default.post(url, request || {}, {
62
- headers: { 'x-request-id': requestId },
65
+ headers: {
66
+ 'x-request-id': requestId,
67
+ 'x-belink-pandora-userid': pandoraUserId,
68
+ 'x-belink-userid': beLinkUserId,
69
+ 'x-belink-pandora-roleid': pandoraRoleId,
70
+ },
63
71
  });
64
72
  const responseData = response.data;
65
73
  return responseData.data;