param('cart_id', []); $addressId = request()->param('address_id'); if (empty($addressId)) { return app('json')->fail('请选择收货地址'); } $postagePrice = 0; // 判断是否是阿里巴巴商品 $cartInfo = Db::name('store_cart')->whereIn('cart_id', $cartId)->select()->toArray(); $productInfo = Db::name('store_product')->whereIn('product_id', array_column($cartInfo, 'product_id'))->find(); if (!$productInfo['is_alibaba']) { return app('json')->success(['postagePrice' => $postagePrice]); } // 获取地址 $addressInfo = Db::name('user_address')->where('address_id', $addressId)->find(); $addressParam = [ 'fullName' => $addressInfo['real_name'], 'mobile' => $addressInfo['phone'], 'provinceText' => $addressInfo['province'], 'cityText' => $addressInfo['city'], 'areaText' => $addressInfo['district'], 'address' => $addressInfo['detail'], ]; // 获取商品规格 $quantity = array_column($cartInfo, 'cart_num')[0]; $offerId = $productInfo['spu_id']; $specId = Db::name('store_product_attr_value')->where('product_id', $productInfo['product_id'])->whereIn('unique', array_column($cartInfo, 'product_attr_unique'))->value('spec_id'); $cargoParamList = [ 'offerId' => $offerId, 'specId' => $specId, 'quantity' => $quantity ]; $orderService = new OrderService(); $res = $orderService->previewOrder(['cargoParamList' => $cargoParamList, 'addressParam' => $addressParam]); if (!$res) { return app('json')->fail('预下单失败'); } return app('json')->success(['postagePrice' => $res['preview']['sumCarriage'] / 100, 'flow' => $res['preview']['flowFlag']]); } /** * 查询退款退货原因列表 * * API: alibaba.trade.getRefundReasonList-1 * * @return \think\Response */ public function refundReasonList() { $orderId = request()->param('order_id'); $orderEntryIds = request()->param('order_entry_ids', ''); $goodsStatus = request()->param('goods_status', ''); if (empty($orderId)) { return app('json')->fail('订单号不能为空'); } $orderService = new OrderService(); $params = ['orderId' => $orderId]; if (!empty($orderEntryIds)) { $params['orderEntryIds'] = $orderEntryIds; } if (!empty($goodsStatus)) { $params['goodsStatus'] = $goodsStatus; } $result = $orderService->getRefundReasonList($params); if ($result === false) { return app('json')->fail('获取退款原因失败'); } return app('json')->success($result); } }