feat : rank
This commit is contained in:
36
app/Service/ServiceTrait/Common/PickupCodeTrait.php
Normal file
36
app/Service/ServiceTrait/Common/PickupCodeTrait.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service\ServiceTrait\Common;
|
||||
|
||||
trait PickupCodeTrait
|
||||
{
|
||||
/**
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function buildPickupCodeListData(array $data): array
|
||||
{
|
||||
$result = [];
|
||||
foreach ($data as $item) {
|
||||
// 提取关键字段
|
||||
$orderId = $item["order_id"];
|
||||
$copies = $item["copies"];
|
||||
$pickupCode = $item["pickup_code"];
|
||||
$heapsort = $item["heapsort"];
|
||||
|
||||
// 按层级构建数组结构
|
||||
if (!isset($result[$orderId])) {
|
||||
$result[$orderId] = [];
|
||||
}
|
||||
|
||||
if (!isset($result[$orderId][$copies])) {
|
||||
$result[$orderId][$copies] = [
|
||||
'pickup_code' => $pickupCode,
|
||||
'heapsort' => $heapsort,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user