@gt6/sdk 1.0.32 → 1.0.34
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/dist/core/types.d.ts +3 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/gt6-sdk.cjs.js +65 -0
- package/dist/gt6-sdk.cjs.js.map +1 -1
- package/dist/gt6-sdk.esm.js +65 -0
- package/dist/gt6-sdk.esm.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/modules/products.d.ts +4 -0
- package/dist/modules/products.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/gt6-sdk.esm.js
CHANGED
@@ -743,6 +743,65 @@ class ProductsAPI {
|
|
743
743
|
}
|
744
744
|
return product;
|
745
745
|
}
|
746
|
+
/**
|
747
|
+
* 1.2. 根据产品ID全部产品详情(包括自定义和平台)
|
748
|
+
*/
|
749
|
+
async getProduct_all(productId) {
|
750
|
+
const product = await this.client.request(`/products_all/${productId}.json`);
|
751
|
+
// 检查产品是否有销售区域和税费模板
|
752
|
+
if (product.regions && product.regions.length > 0 &&
|
753
|
+
product.taxTemplates && product.taxTemplates.length > 0) {
|
754
|
+
try {
|
755
|
+
// 获取税费信息
|
756
|
+
const taxInfo = await this.getTaxInfo();
|
757
|
+
// 为每个税费模板添加规则
|
758
|
+
product.taxTemplates = product.taxTemplates.map(template => {
|
759
|
+
const matchingTemplate = taxInfo.templates.find(t => t.templateId === template.templateId);
|
760
|
+
if (matchingTemplate) {
|
761
|
+
// 过滤出产品可销售区域的规则
|
762
|
+
const productRegionIds = product.regions_Parent.map(r => r.regionId);
|
763
|
+
const applicableRules = matchingTemplate.rules.filter(rule => productRegionIds.includes(rule.regionId));
|
764
|
+
return {
|
765
|
+
...template,
|
766
|
+
rules: applicableRules
|
767
|
+
};
|
768
|
+
}
|
769
|
+
return template;
|
770
|
+
});
|
771
|
+
}
|
772
|
+
catch (error) {
|
773
|
+
// 如果获取税费信息失败,不影响产品详情返回
|
774
|
+
console.warn('Failed to fetch tax info:', error);
|
775
|
+
}
|
776
|
+
}
|
777
|
+
// 检查产品是否有销售区域和运费模板
|
778
|
+
if (product.regions && product.regions.length > 0 &&
|
779
|
+
product.shippingTemplates && product.shippingTemplates.length > 0) {
|
780
|
+
try {
|
781
|
+
// 获取运费信息
|
782
|
+
const shippingInfo = await this.getShippingInfo();
|
783
|
+
// 为每个运费模板添加规则
|
784
|
+
product.shippingTemplates = product.shippingTemplates.map(template => {
|
785
|
+
const matchingTemplate = shippingInfo.templates.find(t => t.templateId === template.templateId);
|
786
|
+
if (matchingTemplate) {
|
787
|
+
// 过滤出产品可销售区域的规则
|
788
|
+
const productRegionIds = product.regions.map(r => r.regionId);
|
789
|
+
const applicableRules = matchingTemplate.rules.filter(rule => productRegionIds.includes(rule.regionId));
|
790
|
+
return {
|
791
|
+
...template,
|
792
|
+
rules: applicableRules
|
793
|
+
};
|
794
|
+
}
|
795
|
+
return template;
|
796
|
+
});
|
797
|
+
}
|
798
|
+
catch (error) {
|
799
|
+
// 如果获取运费信息失败,不影响产品详情返回
|
800
|
+
console.warn('Failed to fetch shipping info:', error);
|
801
|
+
}
|
802
|
+
}
|
803
|
+
return product;
|
804
|
+
}
|
746
805
|
/**
|
747
806
|
* 2. 获取产品分类列表
|
748
807
|
*/
|
@@ -2881,6 +2940,12 @@ class GT6SDK {
|
|
2881
2940
|
async getProduct_p(productId) {
|
2882
2941
|
return this.products.getProduct_p(productId);
|
2883
2942
|
}
|
2943
|
+
/**
|
2944
|
+
* 8.1.1. 便捷方法:根据产品ID获取全部产品详情(包括自定义和平台)
|
2945
|
+
*/
|
2946
|
+
async getProduct_all(productId) {
|
2947
|
+
return this.products.getProduct_all(productId);
|
2948
|
+
}
|
2884
2949
|
/**
|
2885
2950
|
* 8.2. 便捷方法:获取父平台产品分类列表
|
2886
2951
|
*/
|