From 201ffd5174f29987cfaafb571f7bb8960e89dd6a Mon Sep 17 00:00:00 2001 From: ljl Date: Wed, 24 Jan 2024 19:08:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/class.PrintSettingController.php | 10 +++++ .../services/OrderPrint/ExpressTplService.php | 42 ++++++++++++++++++ app/libs/tool/class.CommonTool.php | 1 + app/libs/tool/class.PddApi.php | 43 +++++++++---------- 4 files changed, 74 insertions(+), 22 deletions(-) diff --git a/app/libs/controller/order/class.PrintSettingController.php b/app/libs/controller/order/class.PrintSettingController.php index 97d383d..60847fb 100644 --- a/app/libs/controller/order/class.PrintSettingController.php +++ b/app/libs/controller/order/class.PrintSettingController.php @@ -547,6 +547,16 @@ class PrintSettingController extends AbstractApiController { return $this->renderSuccess(); } + /** + * @api GET 获取物流网点 + * @param int logisticsId * 物流ID + * @param int wbUserId 授权账号ID + */ + public function getLogisticsNetSites() { + $netSiteList = $this->expressTplService->getLogisticsNetSites($_GET['logisticsId'], $_GET['wbUserId'] ?: 0, CommonTool::getOperatorInfo()); + return $this->renderSuccess(['netSiteList' => $netSiteList]); + } + /** * @api POST 添加发货单模板 * @param string sysTplId * 系统模板ID diff --git a/app/libs/services/OrderPrint/ExpressTplService.php b/app/libs/services/OrderPrint/ExpressTplService.php index a39ec9d..34f7d64 100644 --- a/app/libs/services/OrderPrint/ExpressTplService.php +++ b/app/libs/services/OrderPrint/ExpressTplService.php @@ -701,4 +701,46 @@ class ExpressTplService extends AbstractService { } return $authCodeInfo['authCode']; } + + public function getLogisticsNetSites($logisticsId, $wbUserId, $operatorInfo) { + CheckClient::checkEmpty($logisticsId, 'logisticsId'); + $accessToken = $operatorInfo['accessToken']; + $wbUserId = intval($wbUserId); + $companyCode = $this->logisticsPlatformDao->getCompanyCodeByLogisticsId($logisticsId, AppConst::appPlatformPdd); + $searchWaybillRet = PddApi::searchPddWaybill($companyCode, $accessToken, $wbUserId); + CheckClient::checkIsFailRet($searchWaybillRet); + $netSiteInfo = $searchWaybillRet['waybillApplyInfos'][$companyCode] ?: null; + return $this->buildNetSiteList($netSiteInfo); + } + + private function buildNetSiteList($netSiteInfo) { + if (empty($netSiteInfo)) { + return null; + } + $netsiteList = []; + foreach ($netSiteInfo['branch_account_cols'] as $item) { + foreach($item['shipp_address_cols'] as $address) { + $addressList[] = [ + 'branchCode' => $item['branch_code'], + 'province' => $address['province'], + 'city' => $address['city'], + 'county' => $address['district'], + 'address' => $address['detail'], + ]; + } + $netsiteList[] = [ + 'wpType' => $netSiteInfo['wp_type'], + 'logisticsCode' => $netSiteInfo['wp_code'], + 'branchCode' => $item['branch_code'], + 'branchName' => $item['branch_name'], + 'quantity' => $item['quantity'], + 'cancelQuantity' => $item['cancel_quantity'], + 'recycledQuantity' => $item['recycled_quantity'], + 'allocatedQuantity' => $item['allocated_quantity'], + 'serviceInfo' => $item['service_info_cols'], + 'addressList' => $addressList + ]; + } + return $netsiteList; + } } \ No newline at end of file diff --git a/app/libs/tool/class.CommonTool.php b/app/libs/tool/class.CommonTool.php index 690a473..f7d244f 100644 --- a/app/libs/tool/class.CommonTool.php +++ b/app/libs/tool/class.CommonTool.php @@ -2757,6 +2757,7 @@ class CommonTool { 'mallId' => $_SESSION[SessionConst::mallId], 'mallName' => $_SESSION[SessionConst::mallName], 'mallSubAccountId' => $_SESSION[SessionConst::mallSubAccountId], + 'accessToken' => $_SESSION[SessionConst::accessToken], 'ip' => self::clientIp(), 'hostname' => gethostname(), 'currentUrl' => ZcUrlHelper::getCurrentUrl(false), diff --git a/app/libs/tool/class.PddApi.php b/app/libs/tool/class.PddApi.php index 811cc1a..62e94fe 100644 --- a/app/libs/tool/class.PddApi.php +++ b/app/libs/tool/class.PddApi.php @@ -32,7 +32,7 @@ class PddApi extends PddApiAbstract { public static function kmsSearchBatch($inputList, $accessToken) { $req = new PddOpenKmsSearchBatchRequest(); $req->setInputList(json_encode($inputList)); - $response = self::getClient()->execute($req, $accessToken); + $response = self::execute($req, $accessToken); return self::handleResponse($response); } @@ -46,7 +46,7 @@ class PddApi extends PddApiAbstract { public static function getKmsEncryptList($dataList, $accessToken) { $req = new PddOpenKmsEncryptBatchRequest(); $req->setDataList(json_encode($dataList)); - $response = self::getClient()->execute($req, $accessToken); + $response = self::execute($req, $accessToken); return self::handleResponse($response); } @@ -68,7 +68,7 @@ class PddApi extends PddApiAbstract { public static function getDecryptMaskList($dataList, $accessToken) { $req = new PddOpenDecryptMaskBatchRequest(); $req->setDataList(json_encode($dataList)); - $response = self::getClient()->execute($req, $accessToken); + $response = self::execute($req, $accessToken); return self::handleResponse($response); } @@ -77,7 +77,7 @@ class PddApi extends PddApiAbstract { $req = new PddOpenVirtualNumberCheck(); $req->setOrderSn($orderSn); $req->setVirtualNumber($virtualNumber); - $response = self::getClient()->execute($req, $accessToken); + $response = self::execute($req, $accessToken); return self::handleResponse($response); } @@ -94,7 +94,7 @@ class PddApi extends PddApiAbstract { $req->setAddress($receiverInfo['address']); $req->setReceiverName($receiverInfo['receiverName']); $req->setReceiverPhone($receiverInfo['receiverPhone']); - $response = self::getClient()->execute($req, $accessToken); + $response = self::execute($req, $accessToken); return self::handleResponse($response); } @@ -104,7 +104,7 @@ class PddApi extends PddApiAbstract { $req->setTag($tag ?: ''); $req->setNote($note ?: ''); $req->setTagName($tagName ?: ''); - $response = self::getClient()->execute($req, $accessToken); + $response = self::execute($req, $accessToken); return self::handleResponse($response); } @@ -112,7 +112,7 @@ class PddApi extends PddApiAbstract { $req = new PddOpenDecryptBatchRequest(); $req->setDataList(json_encode($dataList)); - $response = self::getClient()->execute($req, $accessToken); + $response = self::execute($req, $accessToken); return self::handleResponse($response); } @@ -121,7 +121,7 @@ class PddApi extends PddApiAbstract { $req = new PddOpenWaybillTypeReportRequest(); $req->setOrderSnList(json_encode($orderSnList)); $req->setWaybillType($waybillType); - $response = self::getClient()->execute($req, $accessToken); + $response = self::execute($req, $accessToken); return self::handleResponse($response); } @@ -130,7 +130,7 @@ class PddApi extends PddApiAbstract { $req = new PddOpenOrderChannelReportRequest(); $req->setOrderSnList(json_encode($orderSnList)); $req->setOrderChannel($orderChannel); - $response = self::getClient()->execute($req, $accessToken); + $response = self::execute($req, $accessToken); return self::handleResponse($response); } @@ -154,7 +154,7 @@ class PddApi extends PddApiAbstract { $req->setRefundAddressId($deliveryInfo['refundAddressId']); } - $response = self::getClient()->execute($req, $accessToken); + $response = self::execute($req, $accessToken); return self::handleResponse($response); } @@ -170,7 +170,7 @@ class PddApi extends PddApiAbstract { $req->setExtraTrackType($extraTrackType); } - $response = self::getClient()->execute($req, $accessToken); + $response = self::execute($req, $accessToken); return self::handleResponse($response); } @@ -179,7 +179,7 @@ class PddApi extends PddApiAbstract { $req->setWpCode($wpCode); $req->setWaybillCode($waybillCode); - $response = self::getClient()->execute($req, $accessToken); + $response = self::execute($req, $accessToken); return self::handleResponse($response); } @@ -189,8 +189,7 @@ class PddApi extends PddApiAbstract { $req->setWpCode($wpCode); } - $response = self::getClient()->execute($req, $accessToken, $wbUserId); - + $response = self::execute($req, $accessToken, $wbUserId); if (CommonTool::isFailRet($response)) { return $response; } @@ -205,7 +204,7 @@ class PddApi extends PddApiAbstract { $req->setWpCode($wpCode); } - $response = self::getClient()->execute($req, $accessToken, $wbUserId); + $response = self::execute($req, $accessToken, $wbUserId); if (CommonTool::isFailRet($response)) { return $response; } @@ -477,7 +476,7 @@ class PddApi extends PddApiAbstract { public static function getRefundAddressList($accessToken) { $req = new PddRefundAddressListGet(); - $response = self::getClient()->execute($req, $accessToken); + $response = self::execute($req, $accessToken); return self::handleResponse($response); } @@ -498,7 +497,7 @@ class PddApi extends PddApiAbstract { $req->setReturnAddressId($deliveryInfo['returnAddressId']); } - $response = self::getClient()->execute($req, $accessToken); + $response = self::execute($req, $accessToken); return self::handleResponse($response); } @@ -508,7 +507,7 @@ class PddApi extends PddApiAbstract { $req->setMailNo($mailNo); $req->setCache($cache); - $response = self::getClient()->execute($req); + $response = self::execute($req); return self::handleResponse($response); } @@ -518,7 +517,7 @@ class PddApi extends PddApiAbstract { $req->setTrackNo($expressNo); $req->setTel($tel); - $response = self::getClient()->execute($req); + $response = self::execute($req); return self::handleResponse($response); } @@ -527,7 +526,7 @@ class PddApi extends PddApiAbstract { return CommonTool::failResult('禁止请求该接口'); } $req = new PddFdsRoleGetRequest(); - $response = self::getClient()->execute($req, $accessToken); + $response = self::execute($req, $accessToken); return self::handleResponse($response); } @@ -543,14 +542,14 @@ class PddApi extends PddApiAbstract { $req = new PddFdsOrderGetRequest(); $req->setParamFdsOrderGetRequest(json_encode($paramFdsOrderGetRequest)); - $response = self::getClient()->execute($req, $accessToken); + $response = self::execute($req, $accessToken); return self::handleResponse($response); } public static function getGoodsDetail($goodsId, $accessToken) { $req = new PddGoodsDetailGetRequest(); $req->setGoodsId($goodsId); - $response = self::getClient()->execute($req, $accessToken); + $response = self::execute($req, $accessToken); return self::handleResponse($response); } } \ No newline at end of file