|
|
|
@ -31,6 +31,7 @@ use PddApi;
|
|
|
|
|
use PermissionTool;
|
|
|
|
|
use PurchaseOrderConst;
|
|
|
|
|
use Repository\Mall\MallOpRepository;
|
|
|
|
|
use Repository\OrderPrint\ExpressTplRepository;
|
|
|
|
|
use Repository\OrderPrint\OrderPrintRepository;
|
|
|
|
|
use Service\AbstractService;
|
|
|
|
|
use StatusConst;
|
|
|
|
@ -58,6 +59,8 @@ class OrderPrintService extends AbstractService {
|
|
|
|
|
private $opPrintExpressLogWaybillDao;
|
|
|
|
|
private $purchaseOrderFastPositionLogDao;
|
|
|
|
|
|
|
|
|
|
private $expressTplRepository;
|
|
|
|
|
|
|
|
|
|
protected function __construct() {
|
|
|
|
|
$this->mallOpRepository = MallOpRepository::instance();
|
|
|
|
|
$this->orderPrintRepository = OrderPrintRepository::instance();
|
|
|
|
@ -78,6 +81,8 @@ class OrderPrintService extends AbstractService {
|
|
|
|
|
$this->opPrintExpressLogOrderDao = OpPrintExpressLogOrderDao::instance();
|
|
|
|
|
$this->opPrintExpressLogWaybillDao = OpPrintExpressLogWaybillDao::instance();
|
|
|
|
|
$this->purchaseOrderFastPositionLogDao = PurchaseOrderFastPositionLogDao::instance();
|
|
|
|
|
|
|
|
|
|
$this->expressTplRepository = ExpressTplRepository::instance();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function searchOrderList($params, $operatorInfo) {
|
|
|
|
@ -615,17 +620,16 @@ class OrderPrintService extends AbstractService {
|
|
|
|
|
|
|
|
|
|
public function updateOrderExpressStatus($params, $operatorInfo) {
|
|
|
|
|
$mallId = $operatorInfo['mallId'];
|
|
|
|
|
$expressData = $params['expressData'];
|
|
|
|
|
$expressId = $params['expressId'];
|
|
|
|
|
$printRet = $params['printRet'];
|
|
|
|
|
$tradeList = $params['tradeList'];
|
|
|
|
|
$isPreview = empty($params['isPreview']) ? 0 : 1;
|
|
|
|
|
$isOutStorage = CommonTool::isTrue($params['isOutStorage']) ? 1 : 0;
|
|
|
|
|
$printFrom = empty($params['printFrom']) ? null : $params['printFrom'];
|
|
|
|
|
$tradeKeyAndFailListMap = $printRet['tradeKeyAndFailListMap'] ?: [];
|
|
|
|
|
$failList = ZcArrayHelper::changeKeyRow($printRet['failList'], 'tradeKey');
|
|
|
|
|
$printFailKeys = array_keys($failList);
|
|
|
|
|
|
|
|
|
|
$expressTpl = $this->expressTplRepository->getUserExpressTplById($mallId, $expressId);
|
|
|
|
|
|
|
|
|
|
$printStatus = CommonTool::isFailRet($printRet) ? StatusConst::fail : StatusConst::success;
|
|
|
|
|
$printReason = isset($printRet['reason']) ? $printRet['reason'] : null;
|
|
|
|
|
$tradeData = [];
|
|
|
|
@ -634,7 +638,7 @@ class OrderPrintService extends AbstractService {
|
|
|
|
|
$wlbCodes = [];
|
|
|
|
|
$curPrintStatus = in_array($tradeKey, $printFailKeys) ? StatusConst::fail : $printStatus;
|
|
|
|
|
foreach ($trade['wlbItems'] as $wlb) {
|
|
|
|
|
if ($wlb['logisticsId'] == $expressData['logistics_id']) {
|
|
|
|
|
if ($wlb['logisticsId'] == $expressTpl['logisticsId']) {
|
|
|
|
|
$wlbCodes[] = $wlb['wlbCode'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -660,11 +664,11 @@ class OrderPrintService extends AbstractService {
|
|
|
|
|
$tradeData[$tradeKey] = [
|
|
|
|
|
'orderIds' => $trade['orderIds'],
|
|
|
|
|
'waybillCodes' => $wlbCodes,
|
|
|
|
|
'logisticsId' => $expressData['logistics_id'],
|
|
|
|
|
'templateId' => $expressData['template_id'],
|
|
|
|
|
'expressId' => $expressData['op_user_express_tpl_id'],
|
|
|
|
|
'expressType' => $expressData['express_type'],
|
|
|
|
|
'waybillType' => $expressData['waybill_type'],
|
|
|
|
|
'logisticsId' => $expressTpl['logisticsId'],
|
|
|
|
|
'templateId' => $expressTpl['templateId'],
|
|
|
|
|
'expressId' => $expressTpl['opUserExpressTplId'],
|
|
|
|
|
'expressType' => $expressTpl['expressType'],
|
|
|
|
|
'waybillType' => $expressTpl['waybillType'],
|
|
|
|
|
'status' => $curPrintStatus,
|
|
|
|
|
'reason' => $printReason ?: $trade['waybillFailReason'],
|
|
|
|
|
'printPackageCount' => $trade['printPackageCount'],
|
|
|
|
@ -690,6 +694,7 @@ class OrderPrintService extends AbstractService {
|
|
|
|
|
$this->updateExpressPrintStatusByOrder($mallId, $expressId, $tradeKey, $orderInfos[$tradeKey], $trade, $isPreview, $isOutStorage);
|
|
|
|
|
$updateRet[$tradeKey] = CommonTool::successResult(array(
|
|
|
|
|
'orderId' => $tradeKey,
|
|
|
|
|
'logisticsId' => $expressTpl['logisticsId'],
|
|
|
|
|
'gmtPrintExpress' => ZcDateHelper::now(),
|
|
|
|
|
'printExpressStatus' => OrderPrintConst::pExpressStatusPrinted
|
|
|
|
|
));
|
|
|
|
@ -698,18 +703,7 @@ class OrderPrintService extends AbstractService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($isOutStorage && 'order' == $printFrom) {
|
|
|
|
|
foreach ($tradeList as $key => $row) {
|
|
|
|
|
$tradeList[$key]['printExpressLogId'] = $tradeData[$row['tradeKey']]['printExpressLogId'];
|
|
|
|
|
}
|
|
|
|
|
$outstorageRet = $this->orderOutstorageAfterExpressLog($tradeList, $expressData, array_keys($tradeKeyAndFailListMap), array_column($failList, 'tradeKey'));
|
|
|
|
|
} else {
|
|
|
|
|
throw new BizException('未达到记日志后发货条件');
|
|
|
|
|
}
|
|
|
|
|
return [
|
|
|
|
|
'updateRet' => $updateRet,
|
|
|
|
|
'outstorageRet' => $outstorageRet,
|
|
|
|
|
];
|
|
|
|
|
return $updateRet;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function updateExpressPrintStatusByOrder($mallId, $expressId, $tradeKey, $orderInfo, $trade, $isPreview, $isOutStorage = 0) {
|
|
|
|
@ -730,7 +724,7 @@ class OrderPrintService extends AbstractService {
|
|
|
|
|
$this->opPrintStatusDao->insertUpdate($printStatusData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$logs = array(
|
|
|
|
|
$logs = [
|
|
|
|
|
'mall_id' => $orderInfo['mallId'],
|
|
|
|
|
'order_id' => $tradeKey,
|
|
|
|
|
'order_sn' => $orderInfo['orderSn'],
|
|
|
|
@ -744,9 +738,8 @@ class OrderPrintService extends AbstractService {
|
|
|
|
|
'status' => $trade['status'],
|
|
|
|
|
'reason' => $trade['reason'],
|
|
|
|
|
'is_preview' => $isPreview,
|
|
|
|
|
'is_out_storage' => $isOutStorage,
|
|
|
|
|
'gmt_create' => $now
|
|
|
|
|
);
|
|
|
|
|
'is_out_storage' => $isOutStorage
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$this->opPrintExpressLogDao->insert( $logs);
|
|
|
|
|
$logId = $this->opPrintExpressLogDao->lastInsertId();
|
|
|
|
@ -758,7 +751,6 @@ class OrderPrintService extends AbstractService {
|
|
|
|
|
'mall_id' => $orderInfo['mallId'],
|
|
|
|
|
'order_id' => $orderId,
|
|
|
|
|
'is_master' => $orderId == $tradeKey ? 1 : 0,
|
|
|
|
|
'gmt_create' => $now
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$filterInfo = [
|
|
|
|
@ -784,82 +776,6 @@ class OrderPrintService extends AbstractService {
|
|
|
|
|
return $logId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function orderOutstorageAfterExpressLog($tradeList, $expressData, $printFailTradeKeys, $getWaybillFailTradeKeys) {
|
|
|
|
|
$deliveryInfos = $this->buildDeliveryInfos($tradeList, $expressData, $printFailTradeKeys, $getWaybillFailTradeKeys);
|
|
|
|
|
if ($deliveryInfos) {
|
|
|
|
|
$_POST['deliveryInfos'] = $deliveryInfos;
|
|
|
|
|
$_POST['source'] = 'print_after';
|
|
|
|
|
$_POST['isSendAgain'] = '0';
|
|
|
|
|
$_POST['logisticsId'] = $expressData['logistics_id'];
|
|
|
|
|
$_POST['sendMethod'] = 'online';
|
|
|
|
|
$_POST['expressId'] = $expressData['op_user_express_tpl_id'];
|
|
|
|
|
return $this->orderOutstorage(true);
|
|
|
|
|
}
|
|
|
|
|
return CommonTool::failResult('没有需要发货的订单');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function buildDeliveryInfos($tradeList, $expressData, $printFailTradeKeys, $getWaybillFailTradeKeys) {
|
|
|
|
|
$logger = \Zc::getLog('outstorage');
|
|
|
|
|
$deliveryInfos = [];
|
|
|
|
|
$orderIds = [];
|
|
|
|
|
foreach ($tradeList as $trade) {
|
|
|
|
|
$waybillCode = '';
|
|
|
|
|
$tradeKey = $trade['tradeKey'];
|
|
|
|
|
$orderIds = array_merge($orderIds, $trade['orderIds']);
|
|
|
|
|
|
|
|
|
|
if (in_array($tradeKey, $printFailTradeKeys)) {
|
|
|
|
|
$logger->info("$tradeKey in printFailTradeKeys");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (in_array($tradeKey, $getWaybillFailTradeKeys)) {
|
|
|
|
|
$logger->info("$tradeKey in getWaybillFailTradeKeys");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
foreach ($trade['wlbItems'] as $wlb) {
|
|
|
|
|
if ($wlb['logisticsId'] == $expressData['logistics_id'] && $wlb['wlbCode']) {
|
|
|
|
|
$waybillCode = $wlb['wlbCode'];
|
|
|
|
|
$packageCount = $wlb['packageCount'];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (empty($waybillCode)) {
|
|
|
|
|
$logger->info("$tradeKey waybillCodeEmpty");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$items = [];
|
|
|
|
|
foreach ($trade['orders'] as $order) {
|
|
|
|
|
foreach ($order['items'] as $item) {
|
|
|
|
|
$items[] = $item;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$orderIdAndItemsMap = ZcArrayHelper::changeKey($items, 'orderId', true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($trade['orderIds'] as $orderId) {
|
|
|
|
|
$orderItems = $orderIdAndItemsMap[$orderId];
|
|
|
|
|
$orderItemIds = ZcArrayHelper::getSub($orderItems, 'itemId');
|
|
|
|
|
$deliveryInfo = [
|
|
|
|
|
'tradeKey' => $tradeKey,
|
|
|
|
|
'orderId' => $orderId,
|
|
|
|
|
'logisticsId' => $expressData['logistics_id'],
|
|
|
|
|
'expressNo' => $waybillCode,
|
|
|
|
|
'itemIds' => $orderItemIds,
|
|
|
|
|
'printExpressLogId' => $trade['printExpressLogId'],
|
|
|
|
|
];
|
|
|
|
|
$deliveryInfos[] = $deliveryInfo;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (empty($deliveryInfos)) {
|
|
|
|
|
$logger->info("tradeKeyAndWaybillInfoMap empty " . implode(',', $orderIds));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $deliveryInfos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getHotGoodsList($mallId, $params) {
|
|
|
|
|
$authMallIds = $params['authMallIds'];
|
|
|
|
|
if ($authMallIds) {
|
|
|
|
@ -947,7 +863,6 @@ class OrderPrintService extends AbstractService {
|
|
|
|
|
array_push($goodsIdAndGoodsInfoMap[$goodsId]['orderIds'], $opOrderGood['orderId']);
|
|
|
|
|
$goodsIdAndGoodsInfoMap[$goodsId]['salesCount'] += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$returnOpOrderGoods = array_values($goodsIdAndGoodsInfoMap);
|
|
|
|
|