erp/app/Utils/GeneratorUtils.php

45 lines
1010 B
PHP
Raw Permalink Normal View History

2024-08-13 18:17:03 +08:00
<?php
namespace App\Utils;
use App\Utils\NumberUtils;
use Yeepay\Yop\Sdk\Utils\Http\HttpUtils;
class GeneratorUtils
{
public static function generateBatchNumber($type = "add")
{
$code = "A";//批量添加
if ($type != 1) {
$code = "I";//导入
}
return $code.date("YmdHis") . rand(1000, 10000);
}
2024-08-14 17:02:31 +08:00
public static function generateCombinationGoodNumber($goods)
{
$code = "";
foreach ($goods as $v){
$code.=static::getChCode($v['item_id'])."Z".static::getChCode($v['item_num'])."Z";
}
rtrim($code,"Z");
return $code;
}
/**
* 获取非z的字符串
* @param $intValue
* @return string
*/
public static function getChCode($intValue)
{
$ch = range('A', 'Y');
$result = '';
while ($intValue) {
$result = $ch[$intValue % 25] . $result;
$intValue = intval($intValue / 25);
}
return $result;
}
2024-08-13 18:17:03 +08:00
}