56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
<?php
|
|
namespace App\Domains\Virtual\Services;
|
|
|
|
use App\Dicts;
|
|
|
|
class CommonService
|
|
{
|
|
/**
|
|
* 将数字转换为字符串
|
|
*
|
|
* @param string $companyId
|
|
* @return int
|
|
*/
|
|
public static function stringifyCompanyId($companyId)
|
|
{
|
|
return sprintf('No%011d', $companyId);
|
|
return intval(str_replace('No', '', $companyId));
|
|
}
|
|
|
|
/**
|
|
* 获取支付方式中文
|
|
*
|
|
* @param string $payChannel
|
|
* @return string
|
|
*/
|
|
public static function namePayChannel($payChannel)
|
|
{
|
|
$payChannels = app(Dicts::class)->get('pay_channel');
|
|
|
|
foreach ($payChannels as $key => $value) {
|
|
if (in_array($payChannel, $value)) {
|
|
return $key;
|
|
}
|
|
}
|
|
|
|
return '';
|
|
}
|
|
|
|
/**
|
|
* 生成套餐编号
|
|
*
|
|
* @param int $type
|
|
* @param int $carrierOperator
|
|
* @param int $flow
|
|
* @param int $serviceMonths
|
|
* @return string
|
|
*/
|
|
public static function generatePackageSn($type, $carrierOperator, $flow, $reset_months, $serviceMonths)
|
|
{
|
|
$typeSN = ['BS', 'RW', 'RP', 'FP', 'OP', 'AP'];
|
|
$carrierOperatorSN = ['LT', 'YD', 'DX', 'QW'];
|
|
|
|
return "{$typeSN[$type]}_{$carrierOperatorSN[$carrierOperator]}_{$flow}_{$reset_months}_{$serviceMonths}";
|
|
}
|
|
}
|