diff --git a/app/crmAdmin/service/CustomerService.php b/app/crmAdmin/service/CustomerService.php index a7f2cea..635b6cf 100644 --- a/app/crmAdmin/service/CustomerService.php +++ b/app/crmAdmin/service/CustomerService.php @@ -529,14 +529,16 @@ class CustomerService $uidRotator = new \app\common\utils\RedisUidRotator('allocation_customer_user'); $uidRotator->setUids($userId, false); - Customer::whereIn('user_id',$resignUerIds)->chunk(500, function ($customers) use ($uidRotator){ - foreach ($customers as $customer) { - // 获取下一个分配的UID - $newUserId = $uidRotator->next(); - $customer->user_id = $newUserId; - $customer->save(); - } - }); + Customer::whereIn('user_id', $resignUerIds) + ->orderBy('id', 'asc') + ->chunkById(500, function ($customers) use ($uidRotator) { + foreach ($customers as $customer) { + // 获取下一个分配的UID + $newUserId = $uidRotator->next(); + $customer->user_id = $newUserId; + $customer->save(); + } + }, 'id'); return [