@gt6/sdk 1.0.45 → 1.0.46

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.
@@ -1877,6 +1877,64 @@ class ProductsAPI {
1877
1877
  }
1878
1878
  return product;
1879
1879
  }
1880
+ /* 1.1 根据产品ID获取产品详情(平台用户都可以使用)
1881
+ */
1882
+ async getProduct01_all(productId) {
1883
+ const product = await this.client.request(`/products_all/${productId}.json`);
1884
+ // 检查产品是否有销售区域和税费模板
1885
+ if (product.regions && product.regions.length > 0 &&
1886
+ product.taxTemplates && product.taxTemplates.length > 0) {
1887
+ try {
1888
+ // 获取税费信息
1889
+ const taxInfo = await this.getTaxInfo();
1890
+ // 为每个税费模板添加规则
1891
+ product.taxTemplates = product.taxTemplates.map(template => {
1892
+ const matchingTemplate = taxInfo.templates.find(t => t.templateId === template.templateId);
1893
+ if (matchingTemplate) {
1894
+ // 过滤出产品可销售区域的规则
1895
+ const productRegionIds = product.regions.map(r => r.regionId);
1896
+ const applicableRules = matchingTemplate.rules.filter(rule => productRegionIds.includes(rule.regionId));
1897
+ return {
1898
+ ...template,
1899
+ rules: applicableRules
1900
+ };
1901
+ }
1902
+ return template;
1903
+ });
1904
+ }
1905
+ catch (error) {
1906
+ // 如果获取税费信息失败,不影响产品详情返回
1907
+ console.warn('Failed to fetch tax info:', error);
1908
+ }
1909
+ }
1910
+ // 检查产品是否有销售区域和运费模板
1911
+ if (product.regions && product.regions.length > 0 &&
1912
+ product.shippingTemplates && product.shippingTemplates.length > 0) {
1913
+ try {
1914
+ // 获取运费信息
1915
+ const shippingInfo = await this.getShippingInfo();
1916
+ // 为每个运费模板添加规则
1917
+ product.shippingTemplates = product.shippingTemplates.map(template => {
1918
+ const matchingTemplate = shippingInfo.templates.find(t => t.templateId === template.templateId);
1919
+ if (matchingTemplate) {
1920
+ // 过滤出产品可销售区域的规则
1921
+ const productRegionIds = product.regions.map(r => r.regionId);
1922
+ const applicableRules = matchingTemplate.rules.filter(rule => productRegionIds.includes(rule.regionId));
1923
+ return {
1924
+ ...template,
1925
+ rules: applicableRules
1926
+ };
1927
+ }
1928
+ return template;
1929
+ });
1930
+ }
1931
+ catch (error) {
1932
+ // 如果获取运费信息失败,不影响产品详情返回
1933
+ console.warn('Failed to fetch shipping info:', error);
1934
+ }
1935
+ }
1936
+ return product;
1937
+ }
1880
1938
  /**
1881
1939
  * 1.2 获取平台产品分类列表
1882
1940
  */
@@ -3590,6 +3648,9 @@ class GT6SDK {
3590
3648
  async getProduct_all(productId) {
3591
3649
  return this.products.getProduct_all(productId);
3592
3650
  }
3651
+ async getProduct01_all(productId) {
3652
+ return this.products.getProduct01_all(productId);
3653
+ }
3593
3654
  /**
3594
3655
  * 8.2. 便捷方法:获取父平台产品分类列表
3595
3656
  */