Each time a new member is registered, a total of three customer service personnel are automatically assigned (more customer service personnel will be added later). how can this problem be solved? First new member, customer service 1 second new member, customer service 2 third new member, customer service 3 fourth new member, customer service 1... I first query all the customer service in the customer service table, and then more... one customer service is automatically assigned each time a new member is registered.
There are three customer service personnel (more customer service personnel will be added in the future). how can this problem be solved?
First new member, customer service 1
Second new member, customer service 2
Third new member, customer service 3
Fourth new member, customer service 1
...
I first query all the customer service in the customer service table, and then update the customer service field in the newly registered member table.
How can we make one-to-one correspondence between them?
Reply content:
One customer service is automatically assigned each time a new member is registered.
There are three customer service personnel (more customer service personnel will be added in the future). how can this problem be solved?
First new member, customer service 1
Second new member, customer service 2
Third new member, customer service 3
Fourth new member, customer service 1
...
I first query all the customer service in the customer service table, and then update the customer service field in the newly registered member table.
How can we make one-to-one correspondence between them?
Do you want to consider the idle status of customer service?
For example, customer service a B c
At this time, three people assigned a B c
At this time, c has already helped you deal with your affairs.
At this moment, the fourth person is assigned to whom
If this condition does not exist
$number = file_get_contents("log.txt");file_put_contents("log.txt", ($number +1)%3);
Work with redis.
Use the List structure to create a customer service list. when a new user comes in, RPOP is used by a team-end customer service, and then LPUSH the customer service to the team head.
When new customer service is added, if you want to keep the sequence number unchanged, for example, the current order is 2 3 1, and the List after new 4 is changed to 2 3 4 1, you need to remove the queue for logical judgment. If you do not need to, you can directly migrate the LPUSH to the queue header.
Write files without redis."\r\n"
The separation rules are the same as those above.
Thank you! I wrote a simple function. do you want to do this?
Output result
1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,4,1,2,3,4,1,
setNum($num); } function getService(){ if($this->count >= $this->num){ $this->count = 0; } $this->count ++; return $this->count; } function setNum($num){ $this->num = $num; }}$factory = new serviceFactory(3);echo $factory->getService(),",";echo $factory->getService(),",";echo $factory->getService(),",";echo $factory->getService(),",";echo $factory->getService(),",";echo $factory->getService(),",";echo $factory->getService(),",";echo $factory->getService(),",";echo $factory->getService(),",";$factory->setNum(4);echo $factory->getService(),",";echo $factory->getService(),",";echo $factory->getService(),",";echo $factory->getService(),",";echo $factory->getService(),",";
This is a simple hash algorithm. the customer service count is n. the new user id m is registered, and the assigned customer service is m % n + 1.
I have written a similar one before, but it is not a customer service. I will not post code here to talk about my personal practices:
The ultimate goal is to keep every customer service busy and not to keep users waiting.
Therefore, assign a new user:
If (number of idle Customer Service> = 0) {// The customer service that is allocated to the first customer service that enters the idle state} else {// indicates that every customer service currently has a user who is consulting and may be waiting in queue for the user to obtain the start time of each customer service ** Current consulting task ** assigns this user the earliest start time of the current information task and the customer service with the least number of people in the queue. // In fact, there is a weight above. problems, for example, the start time of the current customer information task of customer service A is 2 minutes earlier than that of customer service B, but the number of people queuing after customer service A is one more than that of customer service B, this requires weight values to calculate whether to allocate to A or B .}
I personally think that virtual customer service X can be allocated first, which is actually a machine Q & A System. after a customer service is completed, users in the queue will be allocated immediately, in this case, there are no queues or other troubles. At the same time, it is easy to make every customer service busy.
I have just got in touch with this kind of knowledge. if you have a bad answer, please correct me more. thank you.