|
|
@@ -14,6 +14,7 @@ use App\Services\OrderService;
|
|
|
use Carbon\Carbon;
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
use Illuminate\Http\Request;
|
|
|
+use Illuminate\Http\Response;
|
|
|
|
|
|
class WeightBaseController
|
|
|
{
|
|
|
@@ -346,4 +347,56 @@ class WeightBaseController
|
|
|
return $orderPackage->save();
|
|
|
}
|
|
|
// endregion
|
|
|
+
|
|
|
+// region ---上传快递单号处理
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 快递单号处理
|
|
|
+ *
|
|
|
+ * @param $code
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ public function processCode($code): string
|
|
|
+ {
|
|
|
+ /** 如果是$code 是数组处理 */
|
|
|
+ if(is_array($code)){
|
|
|
+ return $this->processCodeArr($code);
|
|
|
+ }
|
|
|
+ return $this->processCodeStr($code);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 快递单号 array 处理
|
|
|
+ *
|
|
|
+ * @param array $code
|
|
|
+ * @return mixed|string
|
|
|
+ */
|
|
|
+ public function processCodeArr(array $code): string
|
|
|
+ {
|
|
|
+ usort($code,function($codeA,$codeB){
|
|
|
+ if(strlen($codeA) == strlen($codeB))return 0;
|
|
|
+ return strlen($codeA) > strlen($codeB) ? 1 : -1;
|
|
|
+ });
|
|
|
+ return $code[0];
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 快递单号 string 处理
|
|
|
+ *
|
|
|
+ * @param $code
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ public function processCodeStr($code): string
|
|
|
+ {
|
|
|
+ $codes = preg_split('/[,,@ ]+/is',$code);
|
|
|
+
|
|
|
+ foreach ($codes as $item) {
|
|
|
+ if(mb_strpos($item,'-'))continue;
|
|
|
+ if(strlen(trim($item,' ')) < 5)continue;
|
|
|
+ return $item;
|
|
|
+ }
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+
|
|
|
+// endregion
|
|
|
}
|