Explorar o código

feat(store): 集成阿里巴巴订单服务并计算运费

- 引入 AlibabaAgent 订单服务类
- 使用商品 SPU ID 和规格 ID 替代硬编码参数
- 添加订单预览功能调用
- 集成运费计算逻辑到购物车处理流程
- 更新运费价格累加计算方式
shichen hai 3 meses
pai
achega
fe19dd685c
Modificáronse 1 ficheiros con 21 adicións e 18 borrados
  1. 21 18
      app/common/repositories/store/order/StoreOrderRepository.php

+ 21 - 18
app/common/repositories/store/order/StoreOrderRepository.php

@@ -110,6 +110,7 @@ use app\entity\request\api\store\order\CalculatePostageRequestEntity;
110 110
 use app\entity\request\api\store\order\StoreOrderCreateRequestEntity;
111 111
 use app\model\common\JdOrderModel;
112 112
 use app\model\common\TbOrderModel;
113
+use app\services\ThirdParty\AlibabaAgent\OrderService;
113 114
 use app\traits\GongApiRequest;
114 115
 use app\traits\HuiPay;
115 116
 use app\traits\ShouxinyiApiRequest;
@@ -2615,6 +2616,26 @@ class StoreOrderRepository extends BaseRepository
2615 2616
             }
2616 2617
 
2617 2618
 
2619
+            // 1688商品获取运费
2620
+            if($cart['product']['is_alibaba'] == 1) {
2621
+                $addressParam = [
2622
+                    'fullName' => $address['real_name'],
2623
+                    'mobile' => $address['phone'],
2624
+                    'provinceText' => $address['province'],
2625
+                    'cityText' => $address['city'],
2626
+                    'areaText' => $address['district'],
2627
+                    'address' => $address['detail'],
2628
+                ];
2629
+                $cargoParamList = [
2630
+                    'offerId' => $cart['product']['spu_id'],
2631
+                    'specId' => $cart['productAttr']['spec_id'],
2632
+                    'quantity' => $cart['cart_num']
2633
+                ];
2634
+                $orderService = new OrderService();
2635
+                $ailOrder = $orderService->previewOrder(['cargoParamList' => $cargoParamList, 'addressParam' => $addressParam]);
2636
+                $postage_price = bcadd($postage_price, $ailOrder['preview']['sumCarriage'] / 100, 2);
2637
+            }
2638
+
2618 2639
             $take = $merchantTakeRepository->get($cartInfo['mer_id']);
2619 2640
             $org_price = bcadd(bcsub($total_price, $valid_total_price, 2), max($_pay_price, 0), 2);
2620 2641
             $coupon_price = set_price_rtrim(min($coupon_price, $total_price));
@@ -2632,24 +2653,6 @@ class StoreOrderRepository extends BaseRepository
2632 2653
 
2633 2654
             //var_dump( $cartInfo['list'][$_k]);
2634 2655
 
2635
-            // 1688商品获取运费
2636
-            if($cart['product']['is_alibaba'] == 1) {
2637
-                $addressParam = [
2638
-                    'fullName' => $address['real_name'],
2639
-                    'mobile' => $address['phone'],
2640
-                    'provinceText' => $address['province'],
2641
-                    'cityText' => $address['city'],
2642
-                    'areaText' => $address['district'],
2643
-                    'address' => $address['detail'],
2644
-                ];
2645
-
2646
-                $cargoParamList = [
2647
-                    'offerId' => $offerId,
2648
-                    'specId' => $specId,
2649
-                    'quantity' => $quantity
2650
-                ];
2651
-            }
2652
-
2653 2656
             $cartInfo['take'] = $take['mer_take_status'] == '1' ? $take : ['mer_take_status' => 0];
2654 2657
             $cartInfo['coupon'] = array_values($cartInfo['coupon']);
2655 2658
             $cartInfo['order'] = compact('valid_total_price', 'product_cart', 'product_price', 'postage_price', 'org_price', 'total_price', 'total_num', 'pay_price', 'coupon_price', 'use_coupon_product', 'use_store_coupon', 'youhui_price');