@ -792,4 +792,64 @@ class ExpressTplService extends AbstractService {
}
return $result;
}
public function getAllNetSites($wbUserId, $operatorInfo) {
$accessToken = $operatorInfo['accessToken'];
$searchWaybillRet = PddApi::searchPddWaybill(null, $accessToken, $wbUserId);
CheckClient::checkIsFailRet($searchWaybillRet);
$companyCodeAndNetSitesMap = [];
foreach ($searchWaybillRet['waybillApplyInfos'] as $companyCode => $netSiteInfo) {
$companyCodeAndNetSitesMap[$companyCode] = $this->buildNetSiteList($netSiteInfo);
}
return $companyCodeAndNetSitesMap;
}
public function getAppliedLogisticsSysExpressTpl($operatorInfo) {
$logisticsList = $this->opSysExpressTplDao->getExistsLogisticsList();
$logisticsIdAndLogisticsNameMap = array_column($logisticsList, 'logisticsName', 'logisticsId');
$logisticsIds = array_column($logisticsList, 'logisticsId');
$companyCodeAndLogisticsIdMap = $this->logisticsPlatformDao->getCompanyCodeAndLogisticsIdMap($logisticsIds, AppConst::appPlatformPdd);
$companyCodeAndNetSitesMap = $this->getAllNetSites(0, $operatorInfo);
$appliedLogisticsList = [];
$appliedLogisticsIds = [];
foreach ($companyCodeAndLogisticsIdMap as $logisticsId => $companyCode) {
if (empty($companyCodeAndNetSitesMap[$companyCode])) {
continue;
}
$appliedLogisticsList[] = [
'logisticsId' => strval($logisticsId),
'logisticsName' => $logisticsIdAndLogisticsNameMap[$logisticsId],
'netsites' => $companyCodeAndNetSitesMap[$companyCode],
];
$appliedLogisticsIds[] = $logisticsId;
}
if ($appliedLogisticsList) {
$sysExpressTplPageData = $this->getSysExpressTplList(['logisticsIds' => $appliedLogisticsIds, 'waybillType' => LogisticsConst::waybillPdd, 'pageSize' => 50 * count($appliedLogisticsIds)]);
$tplList = $sysExpressTplPageData['list'];
$logisticsIdsAndSysTplMap = ZcArrayHelper::changeKey($tplList, 'logisticsId', true);
foreach ($appliedLogisticsList as & $appliedLogistics) {
$appliedLogistics['sysExpressTplList'] = $this->usortExpressTplList($logisticsIdsAndSysTplMap[$appliedLogistics['logisticsId']]);
}
}
return $appliedLogisticsList;
}
private function usortExpressTplList($tplList) {
$scoreList = [];
foreach ($tplList as $tpl) {
if (strpos($tpl['tplName'], '一联') !== false) {
$score = 10;
} elseif (strpos($tpl['tplName'], '二联') !== false) {
$score = 8;
} else {
$score = 0;
}
$scoreList[] = $score;
}
array_multisort($scoreList, SORT_DESC, $tplList);
return $tplList;
}
}