<?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);
    }

    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;
    }
}
