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.
1542 lines
59 KiB
PHP
1542 lines
59 KiB
PHP
<?php
|
|
class OrderPrintTool{
|
|
public static function convertTplInfo($tpl) {
|
|
$tplData = array(
|
|
'width' => $tpl['tpl_width'],
|
|
'height' => $tpl['tpl_height'],
|
|
'x' => $tpl['offset_x'] ? $tpl['offset_x'] : 0,
|
|
'y' => $tpl['offset_y'] ? $tpl['offset_y'] : 0,
|
|
'hasHole' => $tpl['has_hole'] ? true : false,
|
|
'imageUrl' => OssTool::getPubOssUrlByOssPath($tpl['tpl_img_url']),
|
|
'templateUrl' => $tpl['template_url'],
|
|
'customTemplateUrl' => $tpl['custom_template_url'] ?: '',
|
|
'cpCode' => $tpl['cp_code'],
|
|
'expressType' => $tpl['express_type'],
|
|
'waybillType' => $tpl['waybill_type'],
|
|
'waybillAccount' => $tpl['waybill_account'],
|
|
'printer' => $tpl['printer'],
|
|
'printSecondSectionWatermark' => $tpl['print_second_section_watermark'] ? 1 : 0,
|
|
'isChildParent' => $tpl['is_child_parent'] ? 1 : 0,
|
|
'globalStyle' => $tpl['global_style'] ? $tpl['global_style'] : array()
|
|
);
|
|
$tplData['nodes'] = $tpl['position_map'] ? $tpl['position_map'] : array();
|
|
return $tplData;
|
|
}
|
|
|
|
public static function convertExpressTplInfo($tpl) {
|
|
$tplData = array(
|
|
'tplId' => $tpl['op_vender_express_tpl_id'],
|
|
'tplName' => $tpl['tpl_name'],
|
|
'width' => $tpl['tpl_width'],
|
|
'height' => $tpl['tpl_height'],
|
|
'x' => $tpl['offset_x'] ? $tpl['offset_x'] : 0,
|
|
'y' => $tpl['offset_y'] ? $tpl['offset_y'] : 0,
|
|
'hasHole' => $tpl['has_hole'] ? true : false,
|
|
'imageUrl' => OssTool::getPubOssUrlByOssPath($tpl['tpl_img_url']),
|
|
'templateUrl' => $tpl['template_url'],
|
|
'cpCode' => $tpl['cp_code'],
|
|
'expressType' => $tpl['express_type'],
|
|
'waybillType' => $tpl['waybill_type'],
|
|
'waybillAccount' => $tpl['waybill_account'],
|
|
'printLogo' => $tpl['waybill_account']['printLogo'] ? true : false,
|
|
'printer' => $tpl['printer'],
|
|
'printSecondSectionWatermark' => $tpl['print_second_section_watermark'] ? true : false,
|
|
'isChildParent' => $tpl['is_child_parent'] ? true : false,
|
|
'globalStyle' => $tpl['global_style'] ? $tpl['global_style'] : array(),
|
|
'isDefault' => $tpl['is_default'] ? true : false,
|
|
'status' => $tpl['status']
|
|
);
|
|
$tplData['nodes'] = $tpl['position_map'] ? $tpl['position_map'] : array();
|
|
return $tplData;
|
|
}
|
|
|
|
public static function printSenderAddress($senderAddress, $return = false) {
|
|
$string = sprintf('%s %s %s %s %s %s %s %s', $senderAddress['fullname'], $senderAddress['mobile'], $senderAddress['telephone'], $senderAddress['province'], $senderAddress['city'], $senderAddress['county'], $senderAddress['town'], $senderAddress['address']);
|
|
if ($return) {
|
|
return $string;
|
|
}
|
|
echo $string;
|
|
}
|
|
|
|
public static function formatSenderAddress($senderAddress) {
|
|
if (empty($senderAddress)) {
|
|
return array();
|
|
}
|
|
return array (
|
|
'province' => $senderAddress['province'],
|
|
'provinceAreaId' => $senderAddress['province_area_id'],
|
|
'city' => $senderAddress['city'],
|
|
'cityAreaId' => $senderAddress['city_area_id'],
|
|
'county' => $senderAddress['county'],
|
|
'countyAreaId' => $senderAddress['county_area_id'],
|
|
'town' => $senderAddress['town'],
|
|
'townAreaId' => $senderAddress['town_area_id'],
|
|
'fullname' => $senderAddress['fullname'],
|
|
'address' => $senderAddress['address'],
|
|
'mobile' => $senderAddress['mobile'],
|
|
'telephone' => $senderAddress['telephone'],
|
|
'fullAddress' => $senderAddress['province'] . $senderAddress['city'] . $senderAddress['county'] . $senderAddress['town'] . $senderAddress['address']
|
|
);
|
|
}
|
|
|
|
public static function formartOrderDetailNv($orderDetail) {
|
|
$nvMap = array(
|
|
'shop_id' => 'shopId',
|
|
'order_id' => 'orderId',
|
|
'biz_order_num' => 'orderId',
|
|
'self_order_num' => 'selfOrderNum',
|
|
'custom_order_id' => 'customOrderId',
|
|
'order_source' => 'orderSource',
|
|
'b_type' => 'orderSource',
|
|
'order_status' => 'orderStatus',
|
|
'order_status_text' => 'orderStatusText',
|
|
'pay_type' => 'payType',
|
|
'pay_type_text' => 'payTypeText',
|
|
'order_seller_price' => 'orderSellerPrice',
|
|
'order_payment' => 'orderPayment',
|
|
'freight_price' => 'freightPrice',
|
|
'seller_discount' => 'sellerDiscount',
|
|
'order_remark' => 'orderRemark',
|
|
'buyer_words' => 'orderRemark',
|
|
'vender_note' => 'venderNote',
|
|
'shop_note' => 'venderNote',
|
|
'pin' => 'pin',
|
|
'user_name' => 'pin',
|
|
'logistics_code' => 'waybill',
|
|
'waybill' => 'waybill',
|
|
'pay_time' => 'payTime',
|
|
'logistics_id' => 'logisticsId',
|
|
'logistics_name' => 'logisticsName',
|
|
'order_type' => 'orderType',
|
|
'order_start_time' => 'orderStartTime',
|
|
'gmt_create_time' => 'orderStartTime',
|
|
'order_end_time' => 'orderEndTime',
|
|
'gmt_update_time' => 'modified',
|
|
'seller_words' => 'venderRemark',
|
|
'vender_remark' => 'venderRemark',
|
|
'vender_flag' => 'venderFlag',
|
|
'vender_remark_flag' => 'venderFlag',
|
|
'seller_remark_stars' => 'venderFlag',
|
|
'print_express_status' => 'printExpressStatus',
|
|
'print_invoice_status' => 'printInvoiceStatus',
|
|
'express_type' => 'expressType',
|
|
'gmt_print_express' => 'gmtPrintExpress',
|
|
'gmt_print_invoice' => 'gmtPrintInvoice',
|
|
'gmt_create' => 'gmtCreate',
|
|
'gmt_exp_ship_time' => 'gmtExpShipTime',
|
|
'items' => 'items',
|
|
'sug_home_deliver' => 'sugHomeDeliver',
|
|
'is_isolation' => 'isIsolation',
|
|
'order_total_amount' => 'orderTotalAmount'
|
|
);
|
|
$tradeRow = array();
|
|
foreach ($orderDetail as $key => $value) {
|
|
if (array_key_exists($key, $nvMap)) {
|
|
if ($key == 'items') {
|
|
$value = self::formartOrderItemInfoNv($value);
|
|
}
|
|
$tradeRow[$nvMap[$key]] = $value;
|
|
}
|
|
}
|
|
|
|
return $tradeRow;
|
|
}
|
|
|
|
public static function formartOrderItemInfoNv($orderItems) {
|
|
$nvMap = array(
|
|
'custom_item_info_id' => 'itemId',
|
|
'op_order_child_id' => 'itemId',
|
|
'order_id' => 'orderId',
|
|
'child_order_id' => 'childOrderId',
|
|
'sku_id' => 'skuId',
|
|
// 'outer_sku_id' => 'outerSkuId',
|
|
// 'out_sku_id' => 'outerSkuId',
|
|
'code' => 'code',
|
|
'title' => 'title',
|
|
'sku_name' => 'skuName',
|
|
'jd_price' => 'jdPrice',
|
|
'gift_point' => 'giftPoint',
|
|
'ware_id' => 'wareId',
|
|
'item_num' => 'itemNum',
|
|
'item_total' => 'itemTotal',
|
|
'logo' => 'logo',
|
|
'sku_sub_name' => 'skuSubName',
|
|
'total_price' => 'totalPrice',
|
|
'short_title' => 'shortTitle',
|
|
'weight' => 'weight',
|
|
'short_weight' => 'shortWeight',
|
|
'coupon_type' => 'couponType',
|
|
'coupon_price' => 'couponPrice',
|
|
'source_link' => 'sourceLink',
|
|
'product_name' => 'title',
|
|
'combo_num' => 'itemTotal',
|
|
'combo_id' => 'skuId',
|
|
'product_id' => 'wareId',
|
|
'product_pic' => 'logo',
|
|
'order_status' => 'orderStatus',
|
|
'shipped_num' => 'shippedNum',
|
|
'given_product_type' => 'givenProductType',
|
|
'old_sku_info' => 'oldSkuInfo',
|
|
'after_sale_info' => 'afterSaleInfo',
|
|
'c_biz' => 'cBiz',
|
|
);
|
|
|
|
$nvItems = array();
|
|
foreach ($orderItems as $key => $item) {
|
|
$nvItem = array();
|
|
foreach ($item as $n => $value) {
|
|
if (array_key_exists($n, $nvMap)) {
|
|
$nvItem[$nvMap[$n]] = $value;
|
|
if ($n == 'after_sale_info') {
|
|
$nvItem[$nvMap[$n]] = OrderPrintTool::formatAfterSaleInfo($value);
|
|
}
|
|
}
|
|
}
|
|
$nvItems[$key] = $nvItem;
|
|
}
|
|
|
|
return $nvItems;
|
|
}
|
|
|
|
public static function formatDistrOrderDetailNv($orderDetail) {
|
|
$nvMap = array(
|
|
'shop_id' => 'shopId',
|
|
'distr_order_id' => 'orderId',
|
|
'user_name' => 'pin',
|
|
'return_time' => 'returnTime',
|
|
'distr_time' => 'distrTime',
|
|
'distr_status' => 'distrStatus',
|
|
'logistics_code' => 'waybill',
|
|
'waybill' => 'waybill',
|
|
'logistics_id' => 'logisticsId',
|
|
'logistics_name' => 'logisticsName',
|
|
'seller_words' => 'venderRemark',
|
|
'print_express_status' => 'printExpressStatus',
|
|
'print_invoice_status' => 'printInvoiceStatus',
|
|
'express_type' => 'expressType',
|
|
'gmt_print_express' => 'gmtPrintExpress',
|
|
'gmt_print_invoice' => 'gmtPrintInvoice',
|
|
'gmt_create' => 'gmtCreate',
|
|
'items' => 'items'
|
|
);
|
|
$tradeRow = array();
|
|
foreach ($orderDetail as $key => $value) {
|
|
if (array_key_exists($key, $nvMap)) {
|
|
$tradeRow[$nvMap[$key]] = $value;
|
|
}
|
|
}
|
|
|
|
return $tradeRow;
|
|
}
|
|
|
|
public static function getColorAndOrderFlagMap() {
|
|
return [
|
|
'gray' => '0',
|
|
'purple' => '1',
|
|
'blue' => '2',
|
|
'green' => '3',
|
|
'orange' => '4',
|
|
'red' => '5',
|
|
];
|
|
}
|
|
|
|
public static function getOrderFlagColor($orderFlag) {
|
|
return array_search($orderFlag, self::getColorAndOrderFlagMap());
|
|
}
|
|
|
|
public static function getOrderFlags($colors) {
|
|
$flags = [];
|
|
$map = self::getColorAndOrderFlagMap();
|
|
foreach ($colors as $color) {
|
|
if (isset($map[$color])) {
|
|
$flags[] = $map[$color];
|
|
}
|
|
}
|
|
return $flags;
|
|
}
|
|
|
|
public static function getOrderFlagName($flag = null) {
|
|
if (is_null($flag)) {
|
|
return '';
|
|
}
|
|
$flagNameMap = [
|
|
'0' => '灰色',
|
|
'1' => '紫色',
|
|
'2' => '青色',
|
|
'3' => '绿色',
|
|
'4' => '橙色',
|
|
'5' => '红色',
|
|
];
|
|
|
|
return $flagNameMap[$flag];
|
|
}
|
|
|
|
public static function getOrderFlag($flag = null) {
|
|
$flagImgs = array(
|
|
'0' => 'flag-gray.png',
|
|
'1' => 'flag-purple.png',
|
|
'2' => 'flag-cyan.png',
|
|
'3' => 'flag-green.png',
|
|
'4' => 'flag-orange.png',
|
|
'5' => 'flag-red.png',
|
|
);
|
|
|
|
return $flagImgs[$flag] ? $flagImgs[$flag] : $flagImgs;
|
|
}
|
|
|
|
public static function buildOrderFlagUrl($flag) {
|
|
$flagImg = self::getOrderFlag((int)$flag);
|
|
return HtmlTool::getStaticUrl('img/flags/' . $flagImg);
|
|
}
|
|
|
|
public static function formatWangdianWlbData($waybillInfo, $subIndex = 0, $printSecondSectionWatermark, $width) {
|
|
if ($subIndex == 0) {
|
|
$waybillCode = $waybillInfo['waybillCode'];
|
|
} else {
|
|
$waybillCode = $waybillInfo['subWaybillCodes'][$subIndex - 1];
|
|
}
|
|
if ($printSecondSectionWatermark) {
|
|
$routeCodeArray = explode(' ', $waybillInfo['shortName']);
|
|
$secondSectionCode = count($routeCodeArray) == 1 ? $routeCodeArray[0] : $routeCodeArray[1];
|
|
$secondSectionCodeWatermark = self::generateSecondSectionCodeWatermark($secondSectionCode, $width);
|
|
}
|
|
return array(
|
|
LogisticsConst::wlbCode => $waybillCode,
|
|
LogisticsConst::wlbBarcode => $waybillCode,
|
|
LogisticsConst::parentWlbCode => $waybillInfo['waybillCode'],
|
|
LogisticsConst::originName => $waybillInfo['originName'],
|
|
LogisticsConst::originCode => $waybillInfo['originCode'],
|
|
LogisticsConst::consolidationName => $waybillInfo['consolidationName'],
|
|
LogisticsConst::consolidationCode => $waybillInfo['consolidationCode'],
|
|
LogisticsConst::targetName => $waybillInfo['targetName'],
|
|
LogisticsConst::targeCode => $waybillInfo['targeCode'],
|
|
LogisticsConst::shortName => $waybillInfo['shortName'],
|
|
LogisticsConst::secondSectionCodeWatermark => $secondSectionCodeWatermark,
|
|
LogisticsConst::secondSectionCode => empty($secondSectionCode) ? '' : $secondSectionCode,
|
|
'isChildWaybill' => $subIndex == 0 ? false : true
|
|
);
|
|
}
|
|
|
|
public static function formatJdAlphaWlbData($waybillInfo, $printSecondSectionWatermark, $width) {
|
|
$waybillInfo['shortName'] = trim($waybillInfo['shortName'], '-');
|
|
$waybillInfo['secondSectionCode'] = trim($waybillInfo['secondSectionCode'], '-');
|
|
$waybillInfo['thirdSectionCode'] = trim($waybillInfo['thirdSectionCode'], '-');
|
|
|
|
$shortName = implode('-', array_filter(array($waybillInfo['shortName'], $waybillInfo['secondSectionCode'], $waybillInfo['thirdSectionCode'])));
|
|
|
|
$realSecondSectionCode = self::getRealJdAlphaSecondSectionCodeByShortName($shortName, $waybillInfo['secondSectionCode']);
|
|
if ($printSecondSectionWatermark) {
|
|
$secondSectionCodeWatermark = self::generateSecondSectionCodeWatermark($realSecondSectionCode, $width);
|
|
}
|
|
$returnData = array(
|
|
LogisticsConst::wlbCode => $waybillInfo['waybillCode'],
|
|
LogisticsConst::wlbBarcode => $waybillInfo['waybillCode'],
|
|
LogisticsConst::originName => $waybillInfo['originName'],
|
|
LogisticsConst::originCode => $waybillInfo['originCode'],
|
|
LogisticsConst::consolidationName => $waybillInfo['consolidationName'],
|
|
LogisticsConst::consolidationCode => $waybillInfo['consolidationCode'],
|
|
LogisticsConst::targetName => $waybillInfo['targetName'],
|
|
LogisticsConst::targeCode => $waybillInfo['targeCode'],
|
|
LogisticsConst::shortName => $shortName,
|
|
LogisticsConst::fromBranchName => $waybillInfo['fromBranchName'],
|
|
LogisticsConst::toBranchName => $waybillInfo['toBranchName'],
|
|
LogisticsConst::secondSectionCodeWatermark => $secondSectionCodeWatermark ? : '',
|
|
LogisticsConst::secondSectionCode => empty($realSecondSectionCode) ? '' : $realSecondSectionCode,
|
|
LogisticsConst::road => $waybillInfo['road']
|
|
);
|
|
if (!empty($waybillInfo['packageNo'])) {
|
|
$returnData[LogisticsConst::packageNo] = $waybillInfo['packageNo'];
|
|
}
|
|
return $returnData;
|
|
}
|
|
|
|
private static function getRealJdAlphaSecondSectionCodeByShortName($shortName, $oriSecondSectionCode) {
|
|
$codes = explode('-', $shortName);
|
|
$codesCount = count($codes);
|
|
if ($codesCount <= 2) {
|
|
return $oriSecondSectionCode;
|
|
}
|
|
if ($codesCount == 3) {
|
|
return $codes[1];
|
|
}
|
|
array_shift($codes);
|
|
array_pop($codes);
|
|
return implode('-', $codes);
|
|
}
|
|
|
|
public static function formatJdWlbData($receiveOrderInfo, $waybillAccount) {
|
|
$waybillCode = $receiveOrderInfo['deliveryId'];
|
|
$waybillInfo = $receiveOrderInfo['preSortResult'];
|
|
$waybillAccount['jdPromiseTimeType'] = $receiveOrderInfo['promiseTimeType'];
|
|
$waybillAccount['jdAddedService'] = $receiveOrderInfo['addedService'];
|
|
|
|
$waybillProductType = LogisticsConst::getWaybillProductTypeName(LogisticsConst::waybillJd, LogisticsConst::JD, $waybillAccount);
|
|
$waybillServiceType = LogisticsConst::getWaybillServiceTypeName(LogisticsConst::waybillJd, LogisticsConst::JD, $waybillAccount);
|
|
$waybillAddedService = LogisticsConst::getWaybillAddedServiceName(LogisticsConst::waybillJd, LogisticsConst::JD, $waybillAccount);
|
|
$transportationMode = LogisticsConst::getJdWaybillTransportationMode($receiveOrderInfo['promiseTimeType'], $receiveOrderInfo['expressOperationMode'], $waybillInfo['aging']);
|
|
$navigationMark = LogisticsConst::getJdWaybillNavigationMark($receiveOrderInfo['transType']);
|
|
|
|
return array(
|
|
LogisticsConst::wlbCode => $waybillCode,
|
|
LogisticsConst::wlbBarcode => $waybillCode,
|
|
LogisticsConst::originName => $waybillInfo['sourceSortCenterName'],
|
|
LogisticsConst::originCode => sprintf('%s-%s', $waybillInfo['sourceCrossCode'], $waybillInfo['sourceTabletrolleyCode']),
|
|
LogisticsConst::targetName => $waybillInfo['targetSortCenterName'],
|
|
LogisticsConst::targeCode => sprintf('%s-%s', $waybillInfo['slideNo'], $waybillInfo['targetTabletrolleyCode']),
|
|
LogisticsConst::shortName => $waybillInfo['siteName'],
|
|
LogisticsConst::road => $waybillInfo['road'],
|
|
LogisticsConst::waybillProductType => $waybillProductType,
|
|
LogisticsConst::waybillServiceType => $waybillServiceType,
|
|
LogisticsConst::waybillAddedService => $waybillAddedService,
|
|
LogisticsConst::transportationMode => $transportationMode,
|
|
LogisticsConst::navigationMark => $navigationMark,
|
|
LogisticsConst::fromBranchName => $waybillInfo['sourceSortCenterName'],
|
|
LogisticsConst::toBranchName => $waybillInfo['targetSortCenterName']
|
|
);
|
|
}
|
|
|
|
public static function formatCainiaoWlbData($caiNiaoData, $printSecondSectionWatermark, $width) {
|
|
$routingInfo = $caiNiaoData['routingInfo'];
|
|
$routeCodeArray = explode(' ', $routingInfo['routeCode']);
|
|
if ($printSecondSectionWatermark) {
|
|
$secondSectionCodeWatermark = self::generateSecondSectionCodeWatermark($routeCodeArray[0], $width);
|
|
}
|
|
return array(
|
|
LogisticsConst::wlbCode => $caiNiaoData['waybillCode'],
|
|
LogisticsConst::wlbBarcode => $caiNiaoData['waybillCode'],
|
|
LogisticsConst::originName => $routingInfo['origin']['name'],
|
|
LogisticsConst::originCode => $routingInfo['origin']['code'],
|
|
LogisticsConst::consolidationName => $routingInfo['consolidation']['name'],
|
|
LogisticsConst::consolidationCode => $routingInfo['consolidation']['code'],
|
|
LogisticsConst::shortName => $routingInfo['sortation']['name'] . $routingInfo['routeCode'],
|
|
LogisticsConst::secondSectionCodeWatermark => $secondSectionCodeWatermark,
|
|
LogisticsConst::secondSectionCode => empty($routeCodeArray[0]) ? '' : $routeCodeArray[0],
|
|
);
|
|
}
|
|
|
|
public static function generateSecondSectionCodeWatermark($secondSectionCode, $width = 377, $height = 74) {
|
|
if (empty($secondSectionCode)) {
|
|
return '';
|
|
}
|
|
$codeCharCount = mb_strlen($secondSectionCode, 'utf-8');
|
|
|
|
$dir = Zc::C('temp.dir') . 'runtime/second_section_code_watermark/' . explode('-', $secondSectionCode)[0] . '/';
|
|
if (!is_dir($dir)) {
|
|
mkdir($dir, 0755, true);
|
|
}
|
|
$filename = $dir . md5($secondSectionCode) . '_' . $width . '_px.png';
|
|
|
|
if (file_exists($filename)) {
|
|
return 'data:image/png;base64,' . base64_encode(file_get_contents($filename));
|
|
}
|
|
$im = imagecreatetruecolor($width, $height);
|
|
|
|
$bg = imagecolorallocatealpha($im, 255, 255, 255, 127);
|
|
$fontColor = imagecolorallocate($im, 86, 87, 89);
|
|
imagealphablending($im , false);
|
|
imagefilledrectangle($im, 0, 0, $width, $height, $bg);
|
|
|
|
$font = Zc::C(ZcConfigConst::DirFsApp) . '/views/static/fonts/fzch.ttf';
|
|
|
|
$fontSize = 70;
|
|
$textWidth = 0;
|
|
$maxTextWidth = $width - 35;
|
|
$maxTextHeight = $height - 5;
|
|
$loop = 0;
|
|
do {
|
|
if (++$loop > 10) {
|
|
break;
|
|
}
|
|
$box = imagettfbbox($fontSize, 0, $font, $secondSectionCode);
|
|
$minX = min(array($box[0], $box[2], $box[4], $box[6]));
|
|
$maxX = max(array($box[0], $box[2], $box[4], $box[6]));
|
|
$minY = min(array($box[1], $box[3], $box[5], $box[7]));
|
|
$maxY = max(array($box[1], $box[3], $box[5], $box[7]));
|
|
|
|
$textWidth = $maxX - $minX;
|
|
$textHeight = $maxY - $minY;
|
|
|
|
if ($textWidth <= $maxTextWidth) {
|
|
$x = ceil(($width - $textWidth) / 2);
|
|
|
|
$textHeight = $maxY - $minY;
|
|
$y = $height - ceil(($height - $textHeight) / 2);
|
|
break;
|
|
}
|
|
|
|
$fontSize = ceil($fontSize * ($maxTextWidth /$textWidth));
|
|
|
|
if ($textWidth > $maxTextWidth || $textHeight > $maxTextHeight) {
|
|
$fontSize --;
|
|
}
|
|
|
|
} while(true);
|
|
|
|
imagettftext($im, $fontSize, 0, ($x - 5), $y, $fontColor, $font, $secondSectionCode);
|
|
|
|
imagesavealpha($im , true);
|
|
imagepng($im, $filename);
|
|
imagedestroy($im);
|
|
|
|
return 'data:image/png;base64,' . base64_encode(file_get_contents($filename));
|
|
}
|
|
|
|
public static function convertMm2Px($mm) {
|
|
$unit = 3.779528;
|
|
return round($mm * $unit);
|
|
}
|
|
|
|
public static function convertPx2Mm($px) {
|
|
$px = preg_replace('/[^\d+|\.]/isU', '', $px);
|
|
$unit = 0.264583;
|
|
return round($px * $unit, 1);
|
|
}
|
|
|
|
public static function convertPx2Pt ($px){
|
|
$px = preg_replace('/[^\d+|\.]/isU', '', $px);
|
|
$unit = 0.75;
|
|
return round($px * $unit, 2);
|
|
}
|
|
|
|
public static function buildJdViewProduct($wareId) {
|
|
return sprintf('https://ware.shop.jd.com/onSaleWare/onSaleWare_viewProduct.action?wareId=%s', $wareId);
|
|
}
|
|
|
|
public static function waybillMockData($cpCode, $wlbType, $printSecondSectionWatermark, $width) {
|
|
return self::opWaybillMockData($cpCode, $wlbType, $printSecondSectionWatermark, $width);
|
|
}
|
|
|
|
private static function msorderWaybillMockData($cpCode, $wlbType, $printSecondSectionWatermark, $width) {
|
|
if ($cpCode == LogisticsConst::JD) {
|
|
return array (
|
|
LogisticsConst::wlbCode => 'JDVC03492217264',
|
|
LogisticsConst::wlbBarcode => 'JDVC03492217264',
|
|
LogisticsConst::originName => '深圳龙华分拣中心',
|
|
LogisticsConst::originCode => '302-B-5',
|
|
LogisticsConst::targetName => '广州博展分拣中心',
|
|
LogisticsConst::targeCode => '9-9-5',
|
|
LogisticsConst::shortName => '*广州龙口营业部',
|
|
LogisticsConst::road => '36'
|
|
);
|
|
}
|
|
if ($printSecondSectionWatermark) {
|
|
$secondSectionCodeWatermark = self::generateSecondSectionCodeWatermark('B100', $width);
|
|
}
|
|
if ($cpCode == LogisticsConst::SF) {
|
|
return array(
|
|
LogisticsConst::consolidationCode => '',
|
|
LogisticsConst::consolidationName => '',
|
|
LogisticsConst::originCode => '',
|
|
LogisticsConst::originName => '',
|
|
LogisticsConst::secondSectionCode => $secondSectionCodeWatermark,
|
|
LogisticsConst::targeCode => '',
|
|
LogisticsConst::targetName => '',
|
|
LogisticsConst::wlbBarcode => 'SF8888888888',
|
|
LogisticsConst::wlbCode => 'SF8888888888',
|
|
);
|
|
}
|
|
return array(
|
|
LogisticsConst::wlbCode => '545724347893',
|
|
LogisticsConst::wlbBarcode => '545724347893',
|
|
LogisticsConst::parentWlbCode => '545724347893',
|
|
LogisticsConst::originName => '厦门转',
|
|
LogisticsConst::originCode => '',
|
|
LogisticsConst::targetName => '厦门分拨中心',
|
|
LogisticsConst::targeCode => '',
|
|
LogisticsConst::shortName => '221-B100-03',
|
|
LogisticsConst::secondSectionCode => $secondSectionCodeWatermark
|
|
);
|
|
}
|
|
|
|
private static function opWaybillMockData($cpCode, $wlbType, $printSecondSectionWatermark, $width) {
|
|
if ($cpCode == LogisticsConst::JD) {
|
|
return array (
|
|
LogisticsConst::wlbCode => 'JDVC00965716114',
|
|
LogisticsConst::wlbBarcode => 'JDVC00965716114',
|
|
LogisticsConst::originName => '广州萝岗分拣中心',
|
|
LogisticsConst::originCode => '95-C-02-E',
|
|
LogisticsConst::targetName => '厦门分拨中心',
|
|
LogisticsConst::targeCode => '41-E-03',
|
|
LogisticsConst::shortName => '三明永安站',
|
|
LogisticsConst::road => '99'
|
|
);
|
|
}
|
|
if ($printSecondSectionWatermark) {
|
|
$secondSectionCodeWatermark = self::generateSecondSectionCodeWatermark('517', $width);
|
|
}
|
|
if ($cpCode == LogisticsConst::SF) {
|
|
return array(
|
|
LogisticsConst::consolidationCode => '',
|
|
LogisticsConst::consolidationName => '',
|
|
LogisticsConst::originCode => '',
|
|
LogisticsConst::originName => '',
|
|
LogisticsConst::secondSectionCodeWatermark => $secondSectionCodeWatermark,
|
|
LogisticsConst::secondSectionCode => '517',
|
|
LogisticsConst::targeCode => '',
|
|
LogisticsConst::targetName => '',
|
|
LogisticsConst::wlbBarcode => 'SF1011111773562',
|
|
LogisticsConst::wlbCode => 'SF1011111773562',
|
|
);
|
|
}
|
|
return array(
|
|
LogisticsConst::wlbCode => '9890000160004',
|
|
LogisticsConst::wlbBarcode => '9890000160004',
|
|
LogisticsConst::parentWlbCode => '9890000160004',
|
|
LogisticsConst::originName => '福田G',
|
|
LogisticsConst::originCode => '210901',
|
|
LogisticsConst::targetName => '厦门分拨中心',
|
|
LogisticsConst::targeCode => '41-E-03',
|
|
LogisticsConst::shortName => '440-517',
|
|
LogisticsConst::secondSectionCodeWatermark => $secondSectionCodeWatermark,
|
|
LogisticsConst::secondSectionCode => '517'
|
|
);
|
|
}
|
|
|
|
public static function getPrintOrderPageSizeArray() {
|
|
return array(20, 30, 50, 100, 200, 500, 1000);
|
|
}
|
|
|
|
public static function getPrintOrderSortTypeMap($needPrintExpressTime = false, $needShipTime = false) {
|
|
if ($needPrintExpressTime) {
|
|
$sortTypeMap = array(
|
|
'orderStartTimeDesc' => '下单时间↓',
|
|
'orderStartTimeAsc' => '下单时间↑',
|
|
'payTimeDesc' => '付款时间↓',
|
|
'payTimeAsc' => '付款时间↑',
|
|
'printExpressTimeDesc' => '打印时间↓',
|
|
'printExpressTimeAsc' => '打印时间↑',
|
|
'skuIdAsc' => '按SKUID排序↑',
|
|
'skuIdDesc' => '按SKUID排序↓',
|
|
'orderTotalAmountDesc' => '付款金额↓',
|
|
'orderTotalAmountAsc' => '付款金额↑',
|
|
);
|
|
} else {
|
|
$sortTypeMap = array(
|
|
'orderStartTimeDesc' => '下单时间↓',
|
|
'orderStartTimeAsc' => '下单时间↑',
|
|
'payTimeDesc' => '付款时间↓',
|
|
'payTimeAsc' => '付款时间↑',
|
|
'skuIdAsc' => '按SKUID排序↑',
|
|
'skuIdDesc' => '按SKUID排序↓',
|
|
'orderTotalAmountDesc' => '付款金额↓',
|
|
'orderTotalAmountAsc' => '付款金额↑',
|
|
);
|
|
}
|
|
if ($needShipTime) {
|
|
$sortTypeMap['shipTimeDesc'] = '发货时间↓';
|
|
$sortTypeMap['shipTimeAsc'] = '发货时间↑';
|
|
}
|
|
return $sortTypeMap;
|
|
}
|
|
|
|
public static function getPrintCustomOrderSortTypeMap() {
|
|
return array(
|
|
'orderStartTimeDesc' => '创建时间↓',
|
|
'orderStartTimeAsc' => '创建时间↑',
|
|
'orderAmountDesc' => '订单金额↓',
|
|
'orderAmountAsc' => '订单金额↑',
|
|
'itemTotalDesc' => '商品件数↓',
|
|
'itemTotalAsc' => '商品件数↑',
|
|
);
|
|
}
|
|
|
|
public static function getPrintDistrOrderSortTypeMap() {
|
|
return array(
|
|
'distrTimeDesc' => '分配时间↓',
|
|
'distrTimeAsc' => '分配时间↑',
|
|
'returnTimeDesc' => '回传时间↓',
|
|
'returnTimeAsc' => '回传时间↑',
|
|
);
|
|
}
|
|
|
|
public static function getDistributeOrderSortTypeMap() {
|
|
return array(
|
|
'payTimeDesc' => '按付款时间降序↓',
|
|
'payTimeAsc' => '按付款时间降序↑',
|
|
'distrTimeDesc' => '按分配时间降序↓',
|
|
'distrTimeAsc' => '按分配时间降序↑',
|
|
);
|
|
}
|
|
|
|
public static function getExportFieldsMap() {
|
|
$fieldsMap = array(
|
|
'orderFields' => array(
|
|
'orderId' => '订单编号',
|
|
'shopName' => '店铺名称',
|
|
'orderStartTime' => '下单时间',
|
|
'orderStatus' => '订单状态',
|
|
'orderPayment' => '实收金额',
|
|
'payType' => '支付方式',
|
|
'logisticsInfo' => '物流信息'
|
|
),
|
|
'itemFields' => array(
|
|
'title' => '商品标题',
|
|
'wareId' => '商品ID',
|
|
'jdPrice' => '商品单价',
|
|
'itemTotal' => '商品数量',
|
|
'orderStatus' => '售后状态',
|
|
'totalPrice' => '商品总价',
|
|
'couponInfo' => '优惠信息',
|
|
'totalAmount' => '商品实收金额',
|
|
'skuSubName' => '规格',
|
|
'itemNum' => '货号',
|
|
'code' => '商家编码',
|
|
'skuId' => 'SKUID',
|
|
),
|
|
'receiveFields' => array(
|
|
'fullname' => '收件人',
|
|
'mobile' => '联系方式',
|
|
'fullAddress' => '收货地址',
|
|
'orderRemark' => '用户留言',
|
|
),
|
|
'purchaseFields' => array(
|
|
'purchasePlatform' => '采购平台',
|
|
'purchaseOrderBuyer' => '采购账号',
|
|
'purchaseOrderSn' => '采购订单号',
|
|
'purchaseOrderPayment' => '采购金额',
|
|
'purchaseOrderStartTime' => '采购下单时间',
|
|
'purchaseLogisticsInfo' => '采购单物流信息',
|
|
),
|
|
'otherFields' => array(
|
|
'venderRemark' => '商家备注',
|
|
'venderNote' => '本地备注',
|
|
),
|
|
);
|
|
return $fieldsMap;
|
|
}
|
|
|
|
public static function getSysDefaultExportFields() {
|
|
$exportFields = self::getExportFieldsMap();
|
|
$sysFields = [];
|
|
foreach ($exportFields as $fieldGroupName => $fieldAndFieldNameMap) {
|
|
$sysFields[$fieldGroupName] = array_keys($fieldAndFieldNameMap);
|
|
}
|
|
return $sysFields;
|
|
}
|
|
|
|
public static function getWangdianExpressServiceTypeOptions($cpCode) {
|
|
if ($cpCode == LogisticsConst::SF) {
|
|
return array(
|
|
'1' => '标准快递',
|
|
'2' => '顺丰特惠',
|
|
'5' => '顺丰次晨',
|
|
'6' => '顺丰即日',
|
|
'112' => '顺丰空配',
|
|
'202' => '顺丰微小件',
|
|
'13' => '物流普运',
|
|
'14' => '冷运宅配',
|
|
'15' => '生鲜速配',
|
|
'16' => '大闸蟹专递',
|
|
'17' => '汽配专线',
|
|
'18' => '汽配吉运',
|
|
'19' => '全球顺',
|
|
'37' => '云仓专配次日',
|
|
'38' => '云仓专配隔日',
|
|
'208' => '特惠专配'
|
|
);
|
|
} elseif ($cpCode == LogisticsConst::YTO) {
|
|
return array(
|
|
'1' => '标准快递',
|
|
'2' => '次日达',
|
|
'4' => '次晨达',
|
|
'8' => '当日达',
|
|
);
|
|
} else {
|
|
return array(
|
|
'1' => '标准快递',
|
|
);
|
|
}
|
|
}
|
|
|
|
public static function getJdAlphaOrderExpressTypeOptions() {
|
|
return array(
|
|
'1' => '顺丰标快',
|
|
'2' => '顺丰特惠',
|
|
'5' => '顺丰次晨',
|
|
'6' => '顺丰即日',
|
|
'231' => '陆运包裹',
|
|
'208' => '特惠专配',
|
|
'202' => '顺丰微小件',
|
|
'204' => '陆运微小件',
|
|
'154' => '重货包裹',
|
|
'13' => '物流普运',
|
|
'199' => '极速包裹',
|
|
'111' => '顺丰干配',
|
|
'112' => '顺丰空配',
|
|
'155' => '小票零旦'
|
|
);
|
|
}
|
|
|
|
public static function getWangdianExpressOrderTypeOptions($cpCode) {
|
|
if (in_array($cpCode, array(LogisticsConst::SF, LogisticsConst::YUNDA, LogisticsConst::YTO))) {
|
|
return array(
|
|
'1' => '普通订单',
|
|
'2' => '货到付款'
|
|
);
|
|
} else {
|
|
return array(
|
|
'1' => '普通订单'
|
|
);
|
|
}
|
|
}
|
|
|
|
public static function getJdAlphaOrderWaybillTypeOptions() {
|
|
return array(
|
|
LogisticsConst::jdAlphaWaybillTypeNormal => '普通运单',
|
|
LogisticsConst::jdAlphaWaybillTypeFresh => '生鲜',
|
|
LogisticsConst::jdAlphaWaybillTypeAir => '航空',
|
|
);
|
|
}
|
|
|
|
public static function getOrderPrintExpressLogExportFieldsMap() {
|
|
$fieldsMap = array(
|
|
'shopName' => '店铺',
|
|
'orderId' => '订单号 ',
|
|
'sellerMemo' => '商家备注 ',
|
|
'buyerMemo' => '买家备注 ',
|
|
'waybillCode' => '物流单号',
|
|
'logisticsName' => '物流公司',
|
|
'fullname' => '收货人',
|
|
'fullMobile' => '收货人手机',
|
|
'fullAddress' => '收货地址',
|
|
'printTime' => '打印日期',
|
|
'senderName' => '发货人',
|
|
'senderMobile' => '发货人手机',
|
|
'senderAddress' => '发货地址',
|
|
'payAmount' => '订单金额',
|
|
'goodsName' => '商品标题',
|
|
'goodsId' => '商品ID',
|
|
'goodsSpec' => '商品规格',
|
|
'skuId' => 'SKU ID',
|
|
'outerId' => 'SKU编码',
|
|
'goodsCount' => '数量',
|
|
'cBizName' => '流量来源',
|
|
'realCommission' => '达人佣金',
|
|
);
|
|
return $fieldsMap;
|
|
}
|
|
|
|
public static function getDistrOrderPrintExpressLogExportFieldsMap() {
|
|
$fieldsMap = array(
|
|
'shopName' => '厂家店铺',
|
|
'userName' => '代打店铺',
|
|
'orderId' => '代发订单号 ',
|
|
'waybillCode' => '物流单号',
|
|
'logisticsName' => '物流公司',
|
|
'fullname' => '收货人',
|
|
'fullAddress' => '收货地址',
|
|
'printTime' => '打印日期',
|
|
'senderName' => '发货人',
|
|
'senderMobile' => '发货人手机',
|
|
'senderAddress' => '发货地址',
|
|
'sellerMemo' => '卖家备注',
|
|
'buyerMemo' => '买家备注',
|
|
'payAmount' => '订单金额',
|
|
'goodsName' => '商品标题',
|
|
'goodsId' => '商品ID',
|
|
'goodsSpec' => '商品规格',
|
|
'outerId' => 'SKU编码',
|
|
'goodsCount' => '数量',
|
|
);
|
|
return $fieldsMap;
|
|
}
|
|
|
|
public static function getCustomPrintExpressLogExportFieldsMap() {
|
|
$fieldsMap = array(
|
|
'shopName' => '店铺',
|
|
'orderSn' => '订单号',
|
|
'waybillCode' => '物流单号',
|
|
'logisticsName' => '物流公司',
|
|
'fullname' => '收货人',
|
|
'mobile' => '收货人手机',
|
|
'fullAddress' => '收货地址',
|
|
'printTime' => '打印日期',
|
|
'senderName' => '发货人',
|
|
'senderMobile' => '发货人手机',
|
|
'senderAddress' => '发货地址',
|
|
'sellerMemo' => '卖家备注',
|
|
'buyerMemo' => '买家备注',
|
|
'payAmount' => '订单金额',
|
|
'goodsName' => '商品标题',
|
|
'goodsId' => '商品ID',
|
|
'goodsSpec' => '商品规格',
|
|
'skuId' => 'SKUID',
|
|
'outerId' => 'SKU编码',
|
|
'goodsCount' => '数量',
|
|
);
|
|
return $fieldsMap;
|
|
}
|
|
|
|
public static function formateReceiverAddressHtml($province, $city, $county, $town, $address) {
|
|
$search = array(
|
|
'乡',
|
|
'镇',
|
|
'村',
|
|
);
|
|
$replace = array(
|
|
'<span class="red"><strong>乡</strong></span>',
|
|
'<span class="red"><strong>镇</strong></span>',
|
|
'<span class="red"><strong>村</strong></span>',
|
|
);
|
|
$county = str_replace($search, $replace, $county);
|
|
$town = str_replace($search, $replace, $town);
|
|
$address = str_replace($search, $replace, $address);
|
|
return sprintf('<span class="mr_5">%s</span><span class="mr_5">%s</span><span class="mr_5">%s</span><span class="mr_5">%s</span><span>%s</span>', $province, $city, $county, $town, $address);
|
|
}
|
|
|
|
public static function formateSenderAddressHtml($sender) {
|
|
$fullAddress = printf('<span class="mr_5">%s</span><span class="mr_5">%s</span><span class="mr_5">%s</span><span class="mr_5">%s</span><span>%s</span>', $sender['province'], $sender['city'], $sender['county'], $sender['town'], $sender['address']);
|
|
$search = array(
|
|
'乡',
|
|
'镇',
|
|
'村',
|
|
);
|
|
$replace = array(
|
|
'<span class="red"><strong>乡</strong></span>',
|
|
'<span class="red"><strong>镇</strong></span>',
|
|
'<span class="red"><strong>村</strong></span>',
|
|
);
|
|
$fullAddress = str_replace($search, $replace, $fullAddress);
|
|
return $fullAddress;
|
|
}
|
|
|
|
public static function replaceTplImageFieldsImgSrcToOssUrl($nodes) {
|
|
foreach ($nodes as &$node) {
|
|
if (empty($node['imgSrc']) || !preg_match('/^(data:\s*image\/(\w+);base64,)/', $node['imgSrc'])) {
|
|
continue;
|
|
}
|
|
$uploadRet = OrderPrintTool::uploadTplImageToOss($node['imgSrc']);
|
|
if (CommonTool::isFailRet($uploadRet)) {
|
|
return CommonTool::failResult("上传图片失败: " . $uploadRet['reason']);
|
|
}
|
|
$node['imgSrc'] = '';
|
|
$node['imgPath'] = $uploadRet['ossPath'];
|
|
}
|
|
return CommonTool::successResult('nodes', $nodes);
|
|
}
|
|
|
|
public static function uploadTplImageToOss($imgDataBase64) {
|
|
if (!preg_match('/^(data:\s*image\/(\w+);base64,)/', $imgDataBase64, $result)) {
|
|
return CommonTool::failResult('数据格式错误');
|
|
}
|
|
$ext = $result[2];
|
|
|
|
if (!in_array($ext, array('jpg', 'jpeg', 'gif', 'png'))) {
|
|
return CommonTool::failResult('只允许上传jpg、png、gif的图片');
|
|
}
|
|
|
|
$dir = 'tpl/image/' . date('Y-m-d') . '/';
|
|
$name = CommonTool::getUuidName() . '.' . $ext;
|
|
|
|
$ossPath = $dir . $name;
|
|
|
|
$ret = OssTool::uploadImmutableObjectByContent($ossPath, base64_decode(str_replace($result[1], '', $imgDataBase64)));
|
|
|
|
if (CommonTool::isFailRet($ret)) {
|
|
return $ret;
|
|
}
|
|
|
|
$srcUrl = OssTool::getPubOssUrlByOssPath($ossPath);
|
|
return CommonTool::successResult(array(
|
|
'src' => $srcUrl,
|
|
'ossPath' => $ossPath,
|
|
));
|
|
}
|
|
|
|
public static function buildInvoiceInfoStr($invoiceInfo) {
|
|
if (empty($invoiceInfo['invoice_type'])) {
|
|
return '不需要开具发票';
|
|
}
|
|
return sprintf('发票类型:%s;发票抬头:%s;发票内容:%s', OrderPrintConst::getInvoiceTypeName($invoiceInfo['invoice_type']), $invoiceInfo['invoice_title'], OrderPrintConst::getInvoiceContent($invoiceInfo['invoice_content_id']));
|
|
}
|
|
|
|
public static function getPurchaseOrderExportFieldsMap() {
|
|
$fieldsMap = array(
|
|
'purchaseOrderFields' => array(
|
|
'purchaseOrderSeller' => '采购店铺',
|
|
'purchasePlatform' => '采购平台',
|
|
'purchaseOrderBuyer' => '采购账号',
|
|
'purchaseOrderSn' => '采购单号',
|
|
'purchaseOrderStartTime' => '采购时间',
|
|
'purchaseOrderStatusText' => '采购单状态',
|
|
'gmtLastCheckStatus' => '同步时间',
|
|
'purchaseOrderPayment' => '采购实付金额',
|
|
'purchaseOrderRefundMoney' => '退款金额',
|
|
),
|
|
'itemFields' => array(
|
|
'title' => '标题',
|
|
'wareId' => '商品编码',
|
|
'itemNum' => '货号',
|
|
'outerSkuId' => '商家SKU',
|
|
'skuId' => 'SKU ID',
|
|
'skuSubName' => '规格',
|
|
'jdPrice' => '单价',
|
|
'purchaseNum' => '数量',
|
|
),
|
|
'orderFields' => array(
|
|
'relationStatus' => '采购单是否关联抖店订单',
|
|
'orderId' => '订单编号',
|
|
'orderStartTime' => '下单时间',
|
|
'orderStateText' => '订单状态',
|
|
'shopName' => '店铺名称',
|
|
),
|
|
);
|
|
return $fieldsMap;
|
|
}
|
|
|
|
public static function getTplFontFamilyMap() {
|
|
return array('宋体' => '宋体', '新宋体' => '新宋体', '黑体' => '黑体', '微软雅黑' => '微软雅黑');
|
|
}
|
|
|
|
|
|
public static function buildWarehouseShelvesKey($warehouse, $shelves) {
|
|
return sprintf('%s_%s', $warehouse, $shelves);
|
|
}
|
|
|
|
public static function getExportExpressLogItemFields(){
|
|
return ['goodsName', 'goodsId', 'itemSkuId', 'goodsSpec', 'skuId', 'outerId', 'goodsCount'];
|
|
}
|
|
|
|
public static function checkNeedJoinItem($fields){
|
|
$need = false;
|
|
$result = array_intersect($fields, self::getExportExpressLogItemFields());
|
|
if(!empty($result)){
|
|
$need = true;
|
|
}
|
|
return $need;
|
|
}
|
|
|
|
public static function buildOrderPreMergeKey($fullnameSmd5, $mobileSmd5) {
|
|
return CommonTool::smd5Value($fullnameSmd5 . $mobileSmd5);
|
|
}
|
|
|
|
public static function analyzeFilterNeedInvoiceVal($invoiceInfo) {
|
|
$invoiceInfos = explode(";", $invoiceInfo);
|
|
$invoiceInfoFields = [];
|
|
foreach ($invoiceInfos as $item){
|
|
list($key, $val) = explode(":", $item);
|
|
$invoiceInfoFields[$key] = $val;
|
|
}
|
|
|
|
if (($invoiceInfoFields['发票类型'] == '普通发票') && ($invoiceInfoFields['发票抬头'] == '个人' || empty($invoiceInfoFields['发票抬头']))) {
|
|
return OrderPrintConst::filterNeedInvoiceNormalPersonal;
|
|
}
|
|
if ($invoiceInfoFields['发票类型'] == '普通发票') {
|
|
return OrderPrintConst::filterNeedInvoiceNormalCompany;
|
|
}
|
|
if ($invoiceInfoFields['发票类型'] == '增值税发票') {
|
|
return OrderPrintConst::filterNeedInvoiceTax;
|
|
}
|
|
if (($invoiceInfoFields['发票类型'] == '电子发票') && ($invoiceInfoFields['发票抬头'] == '个人' || empty($invoiceInfoFields['发票抬头']))) {
|
|
return OrderPrintConst::filterNeedInvoiceElectronicPersonal;
|
|
}
|
|
if ($invoiceInfoFields['发票类型'] == '电子发票') {
|
|
return OrderPrintConst::filterNeedInvoiceElectronicCompany;
|
|
}
|
|
}
|
|
|
|
public static function formatExpressItem($expressNo, $logisticsId, $expressType, $waybillType, $packageId, $packageCount, $isChildParent) {
|
|
return array(
|
|
'expressNo' => $expressNo,
|
|
'logisticsId' => $logisticsId,
|
|
'expressType' => $expressType,
|
|
'waybillType' => $waybillType,
|
|
'packageId' => $packageId,
|
|
'packageCount' => $packageCount,
|
|
'isChildParent' => $isChildParent ? 1 : 0,
|
|
);
|
|
}
|
|
|
|
public static function getCainiaoCustomAreaTemplateOssPath($venderId, $opVenderExpressTplId) {
|
|
$fileName = $opVenderExpressTplId . '.xml';
|
|
return sprintf('express_template/cainiao_custom_template/%s/%s', $venderId, $fileName);
|
|
}
|
|
|
|
public static function getJdAlphaExpressPayMethodOptions() {
|
|
return array(
|
|
LogisticsConst::jdAlphaExpressPayMethodPleaseSelect => '请选择',
|
|
LogisticsConst::jdAlphaExpressPayMethodSendPay => '寄方付',
|
|
LogisticsConst::jdAlphaExpressPayMethodReceiverPay => '收方付',
|
|
LogisticsConst::jdAlphaExpressPayMethodAnotherPay => '第三方付',
|
|
LogisticsConst::jdAlphaExpressPayMethodPayNow => '现结运单',
|
|
);
|
|
}
|
|
|
|
public static function getWangdianExpressPayTypeOptions($logisticsCode){
|
|
if ($logisticsCode == LogisticsConst::ZYKD) {
|
|
return [
|
|
LogisticsConst::zhongyouPayTypeSendPay => '寄付',
|
|
LogisticsConst::zhongyouPayTypeReceiverPay => '到付',
|
|
LogisticsConst::zhongyouPayTypeMonthPay => '月结'
|
|
];
|
|
} elseif ($logisticsCode == LogisticsConst::SF) {
|
|
return array(
|
|
LogisticsConst::wangdianPayTypePleaseSelect => '请选择',
|
|
LogisticsConst::wangdianPayTypePayNow => '现付',
|
|
LogisticsConst::wangdianPayTypePayReceive => '到付',
|
|
LogisticsConst::wangdianPayTypeMonthPay => '月结',
|
|
LogisticsConst::wangdianPayTypePayAnother => '第三方支付',
|
|
);
|
|
} else {
|
|
return [];
|
|
}
|
|
}
|
|
|
|
public static function formatOrderPrintConsignee($order, $opOrderDecryptAddressInfo, $isEnsconceString = true) {
|
|
if (empty($opOrderDecryptAddressInfo)) {
|
|
$fullname = $isEnsconceString ? CommonTool::ensconceString($order['post_receiver']) : $order['post_receiver'];
|
|
$mobile = $isEnsconceString ? CommonTool::ensconceString(CommonTool::decrypt($order['post_tel_s']), 'mobile') : CommonTool::decrypt($order['post_tel_s']);
|
|
$detail = $order['addr_detail'];
|
|
} else {
|
|
$fullname = $opOrderDecryptAddressInfo['post_receiver'];
|
|
$mobile = $opOrderDecryptAddressInfo['post_tel'];
|
|
$detail = $opOrderDecryptAddressInfo['detail'];
|
|
}
|
|
|
|
if (OrderTool::isVirtualNumber($mobile)) {
|
|
list($mobile, $virtualNumberSuffix) = OrderTool::parseVirtualNumber($mobile);
|
|
}
|
|
|
|
$consignee = array(
|
|
'bFullname' => $fullname,
|
|
'bTelephone' => $mobile,
|
|
'bMobile' => $mobile,
|
|
'bProvinceAreaId' => $order['province_id'],
|
|
'bProvince' => $order['province'],
|
|
'bCityAreaId' => $order['city_id'],
|
|
'bCity' => $order['city'],
|
|
'bCountyAreaId' => $order['county_id'],
|
|
'bCounty' => $order['county'],
|
|
'bTownAreaId' => 0,
|
|
'bTown' => $order['town'] ?: '',
|
|
'bAddress' => $detail,
|
|
'bFullAddress' => sprintf('%s %s %s %s%s', $order['province'], $order['city'], $order['county'], $order['town'] ?: '', $detail),
|
|
'orderPreMergeKey' => OrderPrintTool::buildOrderPreMergeKey(CommonTool::smd5Value($order['post_receiver']), CommonTool::smd5Value(CommonTool::decrypt($order['post_tel_s'])))
|
|
);
|
|
|
|
if (!empty($virtualNumberSuffix)) {
|
|
$consignee['virtualNumberSuffix'] = $virtualNumberSuffix;
|
|
}
|
|
|
|
return $consignee;
|
|
}
|
|
|
|
public static function formatOrderPrintCustomAddress($customAddressInfo, $isEnsconceString = true) {
|
|
$customAddress = [];
|
|
if (empty($customAddressInfo)) {
|
|
return $customAddress;
|
|
}
|
|
$customAddress = [
|
|
'bFullname' => $isEnsconceString ? CommonTool::ensconceString($customAddressInfo['fullname']) : $customAddressInfo['fullname'],
|
|
'bTelephone' => $isEnsconceString ? CommonTool::ensconceString($customAddressInfo['telephone'], 'mobile') : $customAddressInfo['telephone'],
|
|
'bMobile' => $isEnsconceString ? CommonTool::ensconceString($customAddressInfo['mobile'], 'mobile') : $customAddressInfo['mobile'],
|
|
'bProvinceAreaId' => $customAddressInfo['province_area_id'],
|
|
'bProvince' => $customAddressInfo['province'],
|
|
'bCityAreaId' => $customAddressInfo['city_area_id'],
|
|
'bCity' => $customAddressInfo['city'],
|
|
'bCountyAreaId' => $customAddressInfo['county_area_id'],
|
|
'bCounty' => $customAddressInfo['county'],
|
|
'bTownAreaId' => $customAddressInfo['town_area_id'],
|
|
'bTown' => $customAddressInfo['town'],
|
|
'bAddress' => $customAddressInfo['address'],
|
|
'bFullAddress' => $customAddressInfo['full_address'],
|
|
'orderPreMergeKey' => OrderPrintTool::buildOrderPreMergeKey(CommonTool::smd5Value($customAddressInfo['fullname']), CommonTool::smd5Value($customAddressInfo['mobile']))
|
|
];
|
|
|
|
return $customAddress;
|
|
}
|
|
|
|
public static function formatDistrOrderPrintConsignee($order) {
|
|
return [
|
|
'bFullname' => '',
|
|
'bTelephone' => '',
|
|
'bMobile' => '',
|
|
'bProvinceAreaId' => $order['province_id'],
|
|
'bProvince' => $order['province'],
|
|
'bCityAreaId' => $order['city_id'],
|
|
'bCity' => $order['city'],
|
|
'bCountyAreaId' => $order['district_id'],
|
|
'bCounty' => $order['district'],
|
|
'bTownAreaId' => $order['street_id'],
|
|
'bTown' => $order['street'],
|
|
'bAddress' => '',
|
|
'bFullAddress' => '',
|
|
'orderPreMergeKey' => $order['receiver_id']
|
|
];
|
|
}
|
|
|
|
public static function formatWlbWangdianData($waybillInfo, $subIndex = 0, $printSecondSectionWatermark, $width) {
|
|
if ($subIndex == 0) {
|
|
$waybillCode = $waybillInfo['waybillCode'];
|
|
} else {
|
|
$waybillCode = $waybillInfo['subWaybillCodes'][$subIndex - 1];
|
|
}
|
|
if ($printSecondSectionWatermark) {
|
|
$routeCodeArray = explode(' ', $waybillInfo['shortName']);
|
|
$secondSectionCode = count($routeCodeArray) == 1 ? $routeCodeArray[0] : $routeCodeArray[1];
|
|
$secondSectionCodeWatermark = self::generateSecondSectionCodeWatermark($routeCodeArray[0], $width);
|
|
}
|
|
$returnData = array(
|
|
LogisticsConst::wlbCode => $waybillCode,
|
|
LogisticsConst::wlbBarcode => $waybillCode,
|
|
LogisticsConst::parentWlbCode => $waybillInfo['waybillCode'],
|
|
LogisticsConst::originName => $waybillInfo['originName'],
|
|
LogisticsConst::originCode => $waybillInfo['originCode'],
|
|
LogisticsConst::consolidationName => $waybillInfo['consolidationName'],
|
|
LogisticsConst::consolidationCode => $waybillInfo['consolidationCode'],
|
|
LogisticsConst::targetName => $waybillInfo['targetName'],
|
|
LogisticsConst::targeCode => $waybillInfo['targeCode'],
|
|
LogisticsConst::shortName => $waybillInfo['shortName'],
|
|
LogisticsConst::secondSectionCodeWatermark => $secondSectionCodeWatermark,
|
|
LogisticsConst::secondSectionCode => empty($secondSectionCode) ? '' : $secondSectionCode,
|
|
LogisticsConst::fromBranchName => $waybillInfo['fromBranchName'],
|
|
LogisticsConst::toBranchName => $waybillInfo['toBranchName'],
|
|
LogisticsConst::road => $waybillInfo['road'],
|
|
'isChildWaybill' => $subIndex == 0 ? false : true
|
|
);
|
|
if (!empty($waybillInfo['packageNo'])) {
|
|
$returnData[LogisticsConst::packageNo] = $waybillInfo['packageNo'];
|
|
}
|
|
return $returnData;
|
|
}
|
|
|
|
public static function isEnsconcedMobile($mobile) {
|
|
return strpos($mobile, '*') ? true : false;
|
|
}
|
|
|
|
public static function joinFullAddress($province, $city, $county, $address) {
|
|
return sprintf('%s%s%s%s', $province, $city, $county, $address);
|
|
}
|
|
|
|
public static function formartCustomOrderDetailNv($orderDetail) {
|
|
$nvMap = array(
|
|
'custom_order_id' => 'orderId',
|
|
'biz_order_num' => 'orderSn',
|
|
'order_status' => 'orderStatus',
|
|
'order_status_name' => 'orderStatusName',
|
|
'pay_type' => 'payType',
|
|
'goods_amount' => 'goodsAmount',
|
|
'pay_amount' => 'payAmount',
|
|
'postage' => 'postage',
|
|
'discount_amount' => 'discountAmount',
|
|
'buyer_memo' => 'buyerMemo',
|
|
'waybill' => 'waybill',
|
|
'payment_confirm_time' => 'paymentConfirmTime',
|
|
'logistics_id' => 'logisticsId',
|
|
'logistics_name' => 'logisticsName',
|
|
'order_start_time' => 'orderStartTime',
|
|
'remark' => 'sellerMemo',
|
|
'print_express_status' => 'printExpressStatus',
|
|
'print_invoice_status' => 'printInvoiceStatus',
|
|
'express_type' => 'expressType',
|
|
'is_shipped' => 'isShipped',
|
|
'gmt_print_express' => 'gmtPrintExpress',
|
|
'gmt_print_invoice' => 'gmtPrintInvoice',
|
|
'gmt_shipped' => 'gmtShipped',
|
|
'gmt_create' => 'gmtCreate',
|
|
'goodsList' => 'items'
|
|
);
|
|
$tradeRow = array();
|
|
foreach ($orderDetail as $key => $value) {
|
|
if (array_key_exists($key, $nvMap)) {
|
|
if ($key == 'goodsList') {
|
|
$value = self::formartCustomOrderGoodsInfoNv($value);
|
|
}
|
|
$tradeRow[$nvMap[$key]] = $value;
|
|
}
|
|
}
|
|
|
|
return $tradeRow;
|
|
}
|
|
|
|
public static function formartCustomOrderGoodsInfoNv($orderGoodsList) {
|
|
$nvMap = array(
|
|
'custom_goods_info_id' => 'itemId',
|
|
'order_id' => 'orderId',
|
|
'sku_id' => 'skuId',
|
|
'title' => 'title',
|
|
'goods_name' => 'goodsName',
|
|
'sku_name' => 'skuName',
|
|
'goods_price' => 'goodsPrice',
|
|
'outer_goods_id' => 'outerGoodsId',
|
|
'outer_id' => 'outerId',
|
|
'goods_count' => 'goodsCount',
|
|
'total_price' => 'totalPrice',
|
|
'goods_img' => 'goodsImg',
|
|
'goods_spec' => 'goodsSpec',
|
|
'sku_sub_name' => 'skuSubName',
|
|
'short_title' => 'shortTitle',
|
|
'weight' => 'weight',
|
|
'short_weight' => 'shortWeight',
|
|
'is_shipped' => 'isShipped',
|
|
'is_can_print' => 'isCanPrint',
|
|
'item_total' => 'itemTotal',
|
|
'jd_price' => 'jdPrice',
|
|
'coupon_price' => 'couponPrice',
|
|
'logo' => 'logo',
|
|
);
|
|
|
|
$nvGoodsList = array();
|
|
foreach ($orderGoodsList as $key => $goods) {
|
|
$nvGoods = array();
|
|
foreach ($goods as $n => $value) {
|
|
if (array_key_exists($n, $nvMap)) {
|
|
$nvGoods[$nvMap[$n]] = $value;
|
|
}
|
|
}
|
|
$nvGoodsList[$key] = $nvGoods;
|
|
}
|
|
|
|
return $nvGoodsList;
|
|
}
|
|
|
|
public static function formatLastExpressInfo($tplId, $orderLastExpress, $logisticsList, $opShopExpressTpls, $lastExpressNos) {
|
|
return [
|
|
'opShopExpressTplId' => $orderLastExpress['op_shop_express_tpl_id'],
|
|
'logisticsId' => $orderLastExpress['logistics_id'],
|
|
'logisticsCode' => $logisticsList[$orderLastExpress['logistics_id']]['logistics_code'],
|
|
'logisticsName' => $logisticsList[$orderLastExpress['logistics_id']]['logistics_name'],
|
|
'expressType' => $orderLastExpress['express_type'],
|
|
'waybillType' => $orderLastExpress['waybill_type'],
|
|
'packageCount' => $orderLastExpress['package_count'],
|
|
'tplId' => $tplId,
|
|
'tplName' => $opShopExpressTpls[$tplId]['tpl_name'] . (($opShopExpressTpls[$tplId]['status'] == StatusConst::delete) ? '【已删除】' : ''),
|
|
'expressNos' => $lastExpressNos,
|
|
];
|
|
}
|
|
|
|
public static function getQuickSearchOrderFilterOptions() {
|
|
return [
|
|
'' => '不限',
|
|
'hasMergeOrder' => '合并订单',
|
|
'notMergerOrder' => '非合并订单',
|
|
'hasPreMergeOrder' => '待合并订单',
|
|
'partDeliveryOrder' => '部分发货订单',
|
|
'hasVenderNote' => '有本地备注',
|
|
'noVenderNote' => '无本地备注',
|
|
'invoicePrinted' => '已打印发货单',
|
|
'invoiceNoPrinted' => '未打印发货单',
|
|
'preSaleDeposit' => '定金预售',
|
|
'preSaleAll' => '全款预售',
|
|
'notPreSale' => '非预售订单',
|
|
'hasFreeProduct' => '有赠品订单',
|
|
'notFreeProduct' => '无赠品订单',
|
|
'freeFreight' => '包邮订单',
|
|
'notFreeFreight' => '非包邮订单',
|
|
'isTownOrder' => '乡、村、镇订单',
|
|
'hasPriceProtection' => '有价保订单',
|
|
'notPriceProtection' => '无价保订单',
|
|
'sugHomeDeliver' => '建议音尊达',
|
|
'noSugHomeDeliver' => '非建议音尊达',
|
|
'consigneeAreaAbnormal' => '异常地址订单',
|
|
'notConsigneeAreaAbnormal' => '非异常地址订单',
|
|
'cBizValueAlliance' => '精选联盟',
|
|
'cBizValueShopSelf' => '小店自卖',
|
|
'isReceiverAddressChanged' => '买家已修改地址',
|
|
];
|
|
}
|
|
|
|
public static function getQuickSearcCustomhOrderFilterOptions() {
|
|
return [
|
|
'' => '不限',
|
|
'invoicePrinted' => '已打印发货单',
|
|
'invoiceNoPrinted' => '未打印发货单',
|
|
'freeFreight' => '包邮订单',
|
|
'notFreeFreight' => '非包邮订单',
|
|
'isTownOrder' => '乡、村、镇订单',
|
|
];
|
|
}
|
|
|
|
public static function getDdExpressServiceTypeOptions($logisticsId) {
|
|
$logisticsIdAndServiceInfoMap = LogisticsConst::getDdLogisticsIdAndServiceInfoMap();
|
|
return $logisticsIdAndServiceInfoMap[$logisticsId] ?: [];
|
|
}
|
|
|
|
public static function getDdExpressPayTypeOptions() {
|
|
return [
|
|
LogisticsConst::ddPayTypeDefault => '默认',
|
|
LogisticsConst::ddPayTypeSendPayNow => '寄付月结',
|
|
LogisticsConst::ddPayTypeSendPayMonth => '寄付现结',
|
|
];
|
|
}
|
|
|
|
public static function getDdExpressOrderTypeOptions($logisticsId) {
|
|
$logisticsIdAndProductInfoMap = LogisticsConst::getDdLogisticsIdAndProductInfoMap();
|
|
return $logisticsIdAndProductInfoMap[$logisticsId] ?: [];
|
|
}
|
|
|
|
public static function formatAfterSaleInfo($afterSaleInfo) {
|
|
if (empty($afterSaleInfo)) {
|
|
return [];
|
|
}
|
|
|
|
return [
|
|
'afterSaleStatus' => $afterSaleInfo['after_sale_status'] ?: $afterSaleInfo['aftersale_status'],
|
|
'afterSaleType' => $afterSaleInfo['after_sale_type'] ?: $afterSaleInfo['aftersale_type'],
|
|
'refundStatus' => $afterSaleInfo['refund_status']
|
|
];
|
|
}
|
|
|
|
public static function checkChildOrderHasAfterSale($childOrderAfterSaleInfo) {
|
|
if (empty($childOrderAfterSaleInfo)) {
|
|
return false;
|
|
}
|
|
|
|
if (!empty($childOrderAfterSaleInfo['afterSaleStatus']) && in_array($childOrderAfterSaleInfo['afterSaleStatus'], AfterSaleConst::getAfterSaleCloseOrCancelStatusList())) {
|
|
return false;
|
|
}
|
|
|
|
if (!empty($childOrderAfterSaleInfo['afterSaleStatus'])) {
|
|
return true;
|
|
}
|
|
|
|
if (!empty($childOrderAfterSaleInfo['refundStatus'])) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public static function getChildOrderIdAndAfterSaleInfoMap($afterSaleList) {
|
|
if (!$afterSaleList) {
|
|
return [];
|
|
}
|
|
array_multisort(array_column($afterSaleList, 'aftersale_id'), SORT_ASC, $afterSaleList);
|
|
reset($afterSaleList);
|
|
|
|
$childOrderIdAndAfterSaleInfoMap = [];
|
|
foreach ($afterSaleList as $afterSale) {
|
|
$childOrderIdAndAfterSaleInfoMap[$afterSale['order_id']] = self::formatAfterSaleInfo($afterSale);
|
|
}
|
|
|
|
return $childOrderIdAndAfterSaleInfoMap;
|
|
}
|
|
|
|
public static function checkIsCanPrint($item, $childAfterSaleInfo) {
|
|
if ($item['orderStatus'] == OrderConst::orderStatusCancel) {
|
|
return false;
|
|
}
|
|
|
|
if (self::checkChildOrderHasAfterSale($childAfterSaleInfo)) {
|
|
return false;
|
|
}
|
|
|
|
if (self::checkChildOrderHasAfterSale($item['afterSaleInfo'])) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static function rebuildPrintFailReason($reason) {
|
|
if (!$reason) {
|
|
return '';
|
|
}
|
|
switch ($reason) {
|
|
case '京东产品类型必传':
|
|
$reason = '京东快递产品类型必传';
|
|
break;
|
|
}
|
|
return $reason;
|
|
}
|
|
|
|
public static function moneyToCent($money) {
|
|
list($moneyElement, $decimal) = explode('.', $money);
|
|
$moneyElementArr = explode(',', $moneyElement);
|
|
$moneyString = join("", $moneyElementArr);
|
|
return Intval($moneyString);
|
|
}
|
|
|
|
public static function getPrintExpressHistoryExportFieldsMap() {
|
|
$logisticsInfosMap = [
|
|
'shopName' => '店铺',
|
|
'waybillCode' => '物流单号',
|
|
'logisticsName' => '物流公司',
|
|
'fullname' => '收货人',
|
|
'fullMobile' => '收货人手机',
|
|
'fullAddress' => '收货地址',
|
|
'printTime' => '打印日期',
|
|
'senderName' => '发货人',
|
|
'senderMobile' => '发货人手机',
|
|
'senderAddress' => '发货地址',
|
|
];
|
|
|
|
$orderInfosMap = [
|
|
'orderId' => '订单号 ',
|
|
'sellerMemo' => '商家备注 ',
|
|
'buyerMemo' => '买家备注 ',
|
|
'payAmount' => '订单金额',
|
|
'cBizName' => '流量来源',
|
|
'realCommission' => '达人佣金',
|
|
];
|
|
|
|
$goodsInfosMap = [
|
|
'goodsName' => '商品标题',
|
|
'goodsId' => '商品ID',
|
|
'goodsSpec' => '商品规格',
|
|
'skuId' => 'SKU ID',
|
|
'outerId' => 'SKU编码',
|
|
'goodsCount' => '数量',
|
|
];
|
|
|
|
|
|
return [$logisticsInfosMap, $orderInfosMap, $goodsInfosMap];
|
|
|
|
}
|
|
|
|
public static function getCustomPrintExpressHistoryExportFieldsMap() {
|
|
$logisticsInfosMap = [
|
|
'shopName' => '店铺',
|
|
'waybillCode' => '物流单号',
|
|
'logisticsName' => '物流公司',
|
|
'fullname' => '收货人',
|
|
'mobile' => '收货人手机',
|
|
'fullAddress' => '收货地址',
|
|
'printTime' => '打印日期',
|
|
'senderName' => '发货人',
|
|
'senderMobile' => '发货人手机',
|
|
'senderAddress' => '发货地址',
|
|
];
|
|
|
|
$orderInfosMap = [
|
|
'orderSn' => '订单号',
|
|
'sellerMemo' => '商家备注 ',
|
|
'buyerMemo' => '买家备注 ',
|
|
'payAmount' => '订单金额',
|
|
];
|
|
|
|
$goodsInfosMap = [
|
|
'goodsName' => '商品标题',
|
|
'goodsId' => '商品ID',
|
|
'goodsSpec' => '商品规格',
|
|
'skuId' => 'SKU ID',
|
|
'outerId' => 'SKU编码',
|
|
'goodsCount' => '数量',
|
|
];
|
|
|
|
return [$logisticsInfosMap, $orderInfosMap, $goodsInfosMap];
|
|
|
|
}
|
|
|
|
public static function getSourcePlatformByPrintFrom($printFrom) {
|
|
$map = [
|
|
OrderPrintConst::printFromSooxieDsOrder => PurchaseOrderConst::purchasePlatformSooxieDS
|
|
];
|
|
return $map[$printFrom];
|
|
}
|
|
|
|
public static function getDdCompanyCodeAndSooxieCompanyCodeMap() {
|
|
return [
|
|
DdLogisticsCodeConst::yuantong => 'yto',
|
|
DdLogisticsCodeConst::yuantongkuaiyun => 'yto',
|
|
DdLogisticsCodeConst::zhongtong => 'zto',
|
|
DdLogisticsCodeConst::zhongtongkuaiyun => 'zto',
|
|
DdLogisticsCodeConst::shentong => 'sto',
|
|
DdLogisticsCodeConst::yunda => 'yd',
|
|
DdLogisticsCodeConst::yundakuaiyun => 'yd',
|
|
DdLogisticsCodeConst::shunfeng => 'sf',
|
|
DdLogisticsCodeConst::shunfengkuaiyun => 'sf',
|
|
DdLogisticsCodeConst::ems => 'ems',
|
|
// DdLogisticsCodeConst::jd => 'jd',
|
|
];
|
|
}
|
|
} |