You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pdd-order-api/app/libs/repository/Common/LogisticsRepository.php

55 lines
2.0 KiB
PHP

<?php
namespace Repository\Common;
use Dao\Common\LogisticsDao;
use Dao\Common\LogisticsPlatformDao;
use Repository\AbstractRepository;
use ZcArrayHelper;
class LogisticsRepository extends AbstractRepository {
private $logisticsDao;
private $logisticsPlatformDao;
protected function __construct() {
parent::__construct();
$this->logisticsDao = LogisticsDao::instance();
$this->logisticsPlatformDao = LogisticsPlatformDao::instance();
}
public function getLogisticsListByLogisticsIds($logisticsIds) {
if (empty($logisticsIds)) {
return [];
}
$rows = $this->logisticsDao->getMapByIds($logisticsIds);
$logisticsPlatforms = $this->logisticsPlatformDao->getListByLogisticsId($logisticsIds);
foreach ($logisticsPlatforms as $logisticsPlatform) {
$rows[$logisticsPlatform['logisticsId']]['platforms'][$logisticsPlatform['platform']] = $logisticsPlatform;
}
return $rows;
}
public function getLogisticsByLogisticsId($logisticsId) {
$row = $this->logisticsDao->getById($logisticsId);
$logisticsPlatforms = $this->logisticsPlatformDao->getListByLogisticsId([$logisticsId]);
foreach ($logisticsPlatforms as $logisticsPlatform) {
$row['platforms'][$logisticsPlatform['platform']] = $logisticsPlatform;
}
return $row;
}
public function searchLogistics($filter) {
$rows = $this->logisticsDao->searchList($filter);
if (empty($rows)) {
return $rows;
}
$logisticsIds = ZcArrayHelper::getSub($rows, 'logisticsId');
$rows = ZcArrayHelper::changeKeyRow($rows, 'logisticsId');
$logisticsPlatforms = $this->logisticsPlatformDao->getListByLogisticsId($logisticsIds);
foreach ($logisticsPlatforms as $logisticsPlatform) {
$rows[$logisticsPlatform['logisticsId']]['platforms'][$logisticsPlatform['platform']] = $logisticsPlatform;
}
return ZcArrayHelper::changeKeyRow($rows, 'logisticsId');
}
}