<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Tracking\Util; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Exception\BizException; class CodeUtil { public static function transportCodeTextToCodes($ldny2) { goto l3Ey_; xsn82: foreach (explode('
', $ldny2) as $xJa9H) { goto y77XZ; y77XZ: $xJa9H = trim($xJa9H); goto UH1TL; BRenL: $wnO4c[] = $xJa9H; goto uEbO5; UH1TL: if (empty($xJa9H)) { continue; } goto BRenL; uEbO5: } goto ryZBG; ryZBG: return $wnO4c; goto mi6P2; l3Ey_: $wnO4c = array(); goto xsn82; mi6P2: } public static function getCodeIdsByTransportCodes($ldny2) { goto wFhfU; ysXRW: $zHsSx = array_build($IcSwb, function ($QBy8K, $cG5OI) { return array($cG5OI['transportCode'], $cG5OI); }); goto CEW_1; ty0O5: $IcSwb = ModelUtil::model('tracking_code')->whereIn('transportCode', $wnO4c)->get(array('id', 'transportCode'))->toArray(); goto ysXRW; wFhfU: $wnO4c = self::transportCodeTextToCodes($ldny2); goto PvzEo; CEW_1: foreach ($wnO4c as $hN9uG) { BizException::throwsIf('物流码' . $hN9uG . '不存在', empty($zHsSx[$hN9uG])); } goto TQfOo; TQfOo: return array_map(function ($MipNh) { return $MipNh['id']; }, $IcSwb); goto aGDna; PvzEo: BizException::throwsIfEmpty('物流码为空', $wnO4c); goto ty0O5; aGDna: } public static function param() { return array('{code}' => '防伪码', '{firstQueryTime}' => '第一次查询时间', '{enableTime}' => '启用时间', '{hits}' => '查询次数', '{product.title}' => '产品名称', '{agent.name}' => '经销商名称'); } public static function replaceCodeParam($ZA40Q, $DP7np) { $f_HcG = array('{code}' => $DP7np['code'], '{firstQueryTime}' => $DP7np['firstQueryTime'], '{enableTime}' => $DP7np['enableTime'], '{hits}' => $DP7np['hits'], '{product.title}' => $DP7np['_product'] ? $DP7np['_product']['title'] : '[无]', '{agent.name}' => !empty($DP7np['_agent']) ? $DP7np['_agent']['name'] : '[无]'); return str_replace(array_keys($f_HcG), array_values($f_HcG), $ZA40Q); } }