20240120-ljl-routeConfig
ljl 10 months ago
parent 3560132b27
commit 0842a44854

@ -489,6 +489,14 @@ class PrintSettingController extends AbstractApiController {
return $this->renderSuccess($data);
}
/**
* @api GET 获取已申请的物流和对应的系统模板
*/
public function getAppliedLogisticsSysExpressTpl() {
$appliedLogisticsList = $this->expressTplService->getAppliedLogisticsSysExpressTpl(CommonTool::getOperatorInfo());
return $this->renderSuccess(['appliedLogisticsList' => $appliedLogisticsList]);
}
/**
* @api GET 获取有系统快递单模板的快递公司列表
*/

@ -11,6 +11,11 @@ class LogisticsPlatformDao extends AbstractDao {
return $this->queryFirstField('select company_code from %b where logistics_id = %i and platform = %s', $this->getTable(), $logisticsId, $platform);
}
public function getCompanyCodeAndLogisticsIdMap($logisticsIds, $platform) {
$rows = $this->query('select company_code, logistics_id from %b where logistics_id in %li and platform = %s', $this->getTable(), $logisticsIds, $platform);
return array_column($rows, 'companyCode', 'logisticsId');
}
public function getByCompanyId($companyId, $platform) {
return $this->queryFirstRow('select * from %b where company_id = %i and platform = %s', $this->getTable(), $companyId, $platform);
}

@ -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;
}
}
Loading…
Cancel
Save