61 lines
1.6 KiB
PHP
61 lines
1.6 KiB
PHP
<?php
|
|
namespace App\Domains\Card\Services;
|
|
|
|
use Carbon\Carbon;
|
|
use App\Core\Service;
|
|
use App\Models\Mongo\TblCard;
|
|
|
|
class CardService extends Service
|
|
{
|
|
protected static $carrierOperators = [1, 0, 2];
|
|
|
|
/**
|
|
* 构造函数
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* 从MongoDB上获取卡详情
|
|
*
|
|
* @param array $simArray
|
|
* @return array
|
|
*/
|
|
public static function getMongoCardsInfo(array $simArray)
|
|
{
|
|
$simArray = array_map('strval', $simArray);
|
|
|
|
$res = TblCard::select(['cNo', 'iccid', 'imsi', 'oType', 'saDate', 'sDate'])
|
|
->whereIn('cNo', $simArray)->get();
|
|
|
|
$values = [];
|
|
|
|
foreach ($res as $value) {
|
|
$activated_at = $value['saDate'] ? $value['saDate']->toDateTime()->format('Y-m-d H:i:s') : null;
|
|
|
|
if ($activated_at && Carbon::parse($activated_at) < Carbon::parse('2000-01-01 00:00:00')) {
|
|
$activated_at = null;
|
|
}
|
|
|
|
$sim = intval(preg_replace('/\D/', '', $value['cNo']));
|
|
|
|
$values[$sim] = [
|
|
'sim' => $sim,
|
|
'imsi' => $value['imsi'] ?? '',
|
|
'iccid' => $value['iccid'] ?? '',
|
|
'carrier_operator' => self::$carrierOperators[$value['oType']] ?? 255,
|
|
'activated_at' => $activated_at,
|
|
'virtual_activated_at' => $activated_at,
|
|
'created_at' => $value['sDate'] ? $value['sDate']->toDateTime()->format('Y-m-d H:i:s') : null,
|
|
'updated_at' => date('Y-m-d H:i:s'),
|
|
];
|
|
}
|
|
|
|
return $values;
|
|
}
|
|
}
|