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.
189 lines
8.7 KiB
PHP
189 lines
8.7 KiB
PHP
<?php
|
|
class OrderTool {
|
|
public static function removeConsigneeSuffix($orderSn, $purchaseOrder) {
|
|
$purchaseSetting = $purchaseOrder['purchaseSetting'];
|
|
if (!$purchaseSetting['isAddConsigneeSuffix']) {
|
|
$purchaseOrder['purchaseOrderFullnameWithoutSuffix'] = $purchaseOrder['purchaseOrderFullname'];
|
|
$purchaseOrder['purchaseOrderFullAddressWithoutSuffix'] = $purchaseOrder['purchaseOrderFullAddress'];
|
|
return $purchaseOrder;
|
|
}
|
|
$addConsigneeNameSuffixFields = $purchaseSetting['addConsigneeNameSuffixFields'];
|
|
$addConsigneeAddressSuffixFields = $purchaseSetting['addConsigneeAddressSuffixFields'];
|
|
$purchaseOrder['purchaseOrderFullnameWithoutSuffix'] = self::replaceConsigneeSuffix($addConsigneeNameSuffixFields, $orderSn, $purchaseOrder, $purchaseOrder['purchaseOrderFullname']);
|
|
$purchaseOrder['purchaseOrderFullAddressWithoutSuffix'] = self::replaceConsigneeSuffix($addConsigneeAddressSuffixFields, $orderSn, $purchaseOrder, $purchaseOrder['purchaseOrderFullAddress']);
|
|
return $purchaseOrder;
|
|
}
|
|
|
|
public static function replaceConsigneeSuffix($addConsigneeSuffixFields, $orderSn, $purchaseOrder, $purchaseOrderField) {
|
|
foreach ($addConsigneeSuffixFields as $field) {
|
|
switch ($field) {
|
|
case 'orderIdLastFour':
|
|
$purchaseOrderField = str_replace(substr($orderSn, -4), '', $purchaseOrderField);
|
|
$purchaseOrderField = str_replace(substr($purchaseOrder['orderId'], -4), '', $purchaseOrderField);
|
|
break;
|
|
case 'mobilePhoneNumber':
|
|
$purchaseOrderField = str_replace($purchaseOrder['purchaseOrderMobile'], '', $purchaseOrderField);
|
|
break;
|
|
case 'randomChar':
|
|
$purchaseOrderField = substr($purchaseOrderField, 0, strlen($purchaseOrderField) - 1);
|
|
break;
|
|
case 'randomLetter':
|
|
$purchaseOrderField = substr($purchaseOrderField, 0, strlen($purchaseOrderField) - 1);
|
|
break;
|
|
}
|
|
}
|
|
return $purchaseOrderField;
|
|
}
|
|
|
|
public static function formatOpOrderConsigneeInfo($order, $sensitiveInfo) {
|
|
$receiverName = $sensitiveInfo['receiverName'];
|
|
$receiverPhone = $sensitiveInfo['receiverPhone'];
|
|
$fullAddress = sprintf('%s%s%s%s', $order['province'], $order['city'], $order['town'], $sensitiveInfo['receiverAddress']);
|
|
|
|
$consignee = array(
|
|
'fullname' => $receiverName,
|
|
'telephone' => $receiverPhone,
|
|
'mobile' => $receiverPhone,
|
|
'countryAreaId' => $order['countryId'],
|
|
'country' => $order['country'],
|
|
'provinceAreaId' => $order['provinceId'],
|
|
'province' => $order['province'],
|
|
'cityAreaId' => $order['cityId'],
|
|
'city' => $order['city'],
|
|
'countyAreaId' => $order['townId'],
|
|
'county' => $order['town'],
|
|
'address' => $sensitiveInfo['receiverAddress'],
|
|
'fullAddress' => $fullAddress,
|
|
);
|
|
|
|
return $consignee;
|
|
}
|
|
|
|
public static function getOrderStatusLabel($orderStatus, $refundStatus) {
|
|
$orderRefundStatusAndClassNameMap = [
|
|
OrderConst::refundStatusProcessing => 'label-danger',
|
|
OrderConst::refundStatusRefunding => 'label-danger',
|
|
OrderConst::refundStatusSuccess => 'label-default',
|
|
];
|
|
$orderStatusAndClassNameMap = [
|
|
OrderConst::orderStatusWaitSellerSendGoods => 'label-azure',
|
|
OrderConst::orderStatusWaitBuyerConfirmGoods => 'label-success',
|
|
OrderConst::orderStatusFinished => 'label-success',
|
|
];
|
|
|
|
if ($refundStatus != 1) {
|
|
$className = $orderRefundStatusAndClassNameMap[$refundStatus] ?: 'label-default';
|
|
return '<span class="label ' . $className . '">' . OrderConst::getRefundStatusMap()[$refundStatus] . '</span>';
|
|
}
|
|
|
|
$className = $orderStatusAndClassNameMap[$orderStatus] ?: 'label-default';
|
|
return '<span class="label ' . $className . '">' . OrderConst::getOrderStatusMap()[$orderStatus] . '</span>';
|
|
}
|
|
|
|
public static function getPurchaseOrderTabInfoByOrder($order) {
|
|
if ($order['is_isolation']) {
|
|
return ['remark' => '隔离订单', 'tab' => PurchaseOrderConst::purchaseOrderTabIsolation];
|
|
}
|
|
if ($order['refund_status'] == OrderConst::refundStatusNoRefund && $order['order_status'] == OrderConst::orderStatusWaitSellerSendGoods) {
|
|
if (in_array($order['filter_purchase_status'], [PurchaseOrderConst::filterPurchaseStatusWaitPurchase, PurchaseOrderConst::filterPurchaseStatusPartPurchase])) {
|
|
return ['remark' => '等待拿货下单', 'tab' => PurchaseOrderConst::purchaseOrderTabWaitPurchase];
|
|
}
|
|
if (in_array($order['filter_purchase_status'], [PurchaseOrderConst::filterPurchaseStatusHasPurchase, PurchaseOrderConst::filterPurchaseStatusManualHasPurchase])) {
|
|
return ['remark' => '已拿货待发货', 'tab' => PurchaseOrderConst::purchaseOrderTabWaitSend];
|
|
}
|
|
} elseif ($order['refund_status'] == OrderConst::refundStatusNoRefund && $order['order_status'] == OrderConst::orderStatusWaitBuyerConfirmGoods) {
|
|
return ['remark' => '已发货', 'tab' => PurchaseOrderConst::purchaseOrderTabHasSend];
|
|
} elseif ($order['refund_status'] == OrderConst::refundStatusNoRefund && $order['order_status'] == OrderConst::orderStatusFinished) {
|
|
return ['remark' => '已完成', 'tab' => PurchaseOrderConst::purchaseOrderTabFinished];
|
|
} elseif (in_array($order['refund_status'], [OrderConst::refundStatusProcessing, OrderConst::refundStatusRefunding])) {
|
|
return ['remark' => '退款中', 'tab' => PurchaseOrderConst::purchaseOrderTabReturn];
|
|
} elseif ($order['refund_status'] == OrderConst::refundStatusSuccess) {
|
|
return ['remark' => '已取消', 'tab' => PurchaseOrderConst::purchaseOrderTabCanceled];
|
|
} elseif ($order['risk_control_status'] == 1) {
|
|
return ['remark' => '风控订单', 'tab' => PurchaseOrderConst::purchaseOrderTabRisk];
|
|
}
|
|
return [];
|
|
}
|
|
|
|
public static function getOrderPrintTabInfoByOrder($order) {
|
|
if ($order['is_isolation']) {
|
|
return ['remark'=>'隔离订单','tab'=>PurchaseOrderConst::purchaseOrderTabIsolation] ;
|
|
}
|
|
return ['remark' => '全部', 'tab' => PurchaseOrderConst::purchaseOrderTabAll];
|
|
}
|
|
|
|
public static function getOrderOutstorageHistoryTagMap() {
|
|
return [
|
|
'deliveryTimeType' => [
|
|
'right_now' => '上游订单发货时立即自动发货',
|
|
'logistics_accept' => '上游订单揽收后发货',
|
|
'disabled' => '不自动发货',
|
|
],
|
|
'isPurchaseLogisticsUpdateToPlatform' => [
|
|
0 => '不更新物流到下游',
|
|
1 => '更新物流到下游',
|
|
],
|
|
'nearExpShipTime' => [
|
|
1 => '物流一直未揽收,系统自动发货,防止发货超时'
|
|
],
|
|
];
|
|
}
|
|
|
|
public static function buildOutstorageTagList($tags) {
|
|
$tagList = [];
|
|
if ($tags) {
|
|
$tapMap = self::getOrderOutstorageHistoryTagMap();
|
|
foreach (['nearExpShipTime', 'deliveryTimeType'] as $tagField) {
|
|
$tagValue = $tags[$tagField];
|
|
if (!is_null($tagValue) && $tapMap[$tagField][$tagValue]) {
|
|
$tagList[] = $tapMap[$tagField][$tagValue];
|
|
}
|
|
}
|
|
}
|
|
|
|
return $tagList;
|
|
}
|
|
|
|
public static function buildOrderAddressHash($order) {
|
|
if (empty($order)) {
|
|
return null;
|
|
}
|
|
|
|
$arr = [
|
|
$order['receiver_name_smd5'],
|
|
$order['receiver_phone_smd5'],
|
|
$order['province'],
|
|
$order['city'],
|
|
$order['town'] ?: '',
|
|
$order['address_smd5'],
|
|
];
|
|
|
|
if ($order['mall_id']) {
|
|
$mergeLog = Zc::getLog('timer/ds_order/merge_log/' . date('Ymd') . '/' . $order['mall_id']);
|
|
} else {
|
|
$mergeLog = Zc::getLog('timer/ds_order/merge_log');
|
|
}
|
|
$filterOrder = ZcArrayHelper::filterColumns($order, [
|
|
'receiver_name_smd5',
|
|
'receiver_phone_smd5',
|
|
'province',
|
|
'city',
|
|
'town',
|
|
'address_smd5',
|
|
'order_status',
|
|
'refund_status',
|
|
'order_sn',
|
|
'updated_at',
|
|
'gmt_modified',
|
|
]);
|
|
$mergeLog->info("route[{$_GET['route']}] orderSn[{$order['order_sn']}] orderJson:" . json_encode($filterOrder, JSON_UNESCAPED_UNICODE));
|
|
|
|
$originalCount = count($arr);
|
|
$arr = array_unique(array_filter($arr));
|
|
if ($originalCount != count($arr)) {
|
|
return null;
|
|
}
|
|
|
|
return md5(implode('+', $arr));
|
|
}
|
|
} |