流量池检测卡
This commit is contained in:
parent
a905842515
commit
835bfd1b89
@ -319,25 +319,9 @@ class FlowPoolController extends Controller
|
||||
|
||||
$flowPools = app(FlowPoolRepository::class)->withConditions(['id' => array_unique(array_pluck($data, 'pool_id'))])->get()->keyBy('id')->toArray();
|
||||
|
||||
$simPackage = [];
|
||||
|
||||
foreach (array_chunk($data, 10000) as $value) {
|
||||
$cards = app(OrderCardPartitionRepository::class)->select(['sim', 'package_id'])->withConditions([
|
||||
'type' => [0, 1, 2],
|
||||
'sim' => array_pluck($value, 'sim'),
|
||||
'now' => 1,
|
||||
])->get()->pluck('package_id', 'sim')->toArray();
|
||||
|
||||
foreach ($cards as $sim => $package_id) {
|
||||
$simPackage[$sim] = $package_id;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($data as &$item) {
|
||||
if (!isset($simPackage[$item['sim']])) {
|
||||
throw new NotExistException('卡不在VD上 #:' . $item['sim']);
|
||||
}
|
||||
|
||||
$package_id = $simPackage[$item['sim']];
|
||||
|
||||
$pool = $flowPools[$item['pool_id']];
|
||||
@ -349,7 +333,7 @@ class FlowPoolController extends Controller
|
||||
$item['package_id'] = $simPackage[$item['sim']];
|
||||
}
|
||||
|
||||
DB::transaction(function () use ($data) {
|
||||
DB::transaction(function () use ($data, $flowPools) {
|
||||
$monthGroupBy = array_groupBy($data, 'month');
|
||||
|
||||
foreach ($monthGroupBy as $month => $values) {
|
||||
@ -367,6 +351,24 @@ class FlowPoolController extends Controller
|
||||
$values = array_collapse($simGroupBy);
|
||||
|
||||
foreach (array_chunk($values, 10000) as $news) {
|
||||
$cards = app(OrderCardPartitionRepository::class)->select(['sim', 'package_id'])->withConditions([
|
||||
'type' => [0, 1, 2],
|
||||
'sim' => array_pluck($news, 'sim'),
|
||||
'month' => substr_replace($month, '-', 4, 0),
|
||||
])->get()->pluck('package_id', 'sim')->toArray();
|
||||
|
||||
foreach ($news as $item) {
|
||||
if (!isset($cards[$item['sim']])) {
|
||||
throw new NotExistException('卡服务周期不正确或不存在 #:' . $item['sim']);
|
||||
}
|
||||
|
||||
$pool = $flowPools[$item['pool_id']];
|
||||
|
||||
if (!in_array($cards[$item['sim']], $pool['package_ids'])) {
|
||||
throw new InvalidArgumentException("卡不属于流量池 {$item['pool_id']} #: {$item['sim']}");
|
||||
}
|
||||
}
|
||||
|
||||
app(FlowPoolMonth::class)->setTable($table)->upsert($news, ['sim', 'month']);
|
||||
}
|
||||
}
|
||||
|
@ -124,15 +124,6 @@ trait OrderCardConcern
|
||||
$relation->where('transaction_no', 'like', "%{$conditions['transaction_no']}%");
|
||||
});
|
||||
}
|
||||
|
||||
if ($conditions['now']) {
|
||||
$query->where(function ($subQuery) {
|
||||
$subQuery->where(function ($timeQuery) {
|
||||
$timeQuery->where('service_start_at', '<=', Carbon::now())
|
||||
->where('service_end_at', '>=', Carbon::now());
|
||||
})->orWhereNull('service_start_at');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (isset($conditions['card_status'])) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user