Automatically assign a customer service for each new member registered
Customer service A total of 3 (will add more customer service later) How to deal with?
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 check out all customer service in the customer service form, and then update the Customer service field in the new registered membership form.
Now how to make the one by one correspondence between?
Reply content:
Automatically assign a customer service for each new member registered
Customer service A total of 3 (will add more customer service later) How to deal with?
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 check out all customer service in the customer service form, and then update the Customer service field in the new registered membership form.
Now how to make the one by one correspondence between?
Would you like to consider the idle state of customer service
such as customer service a B C
At this point, 3 people were given a B c.
At this point, C has done his job.
And then the fourth person to whom
If this condition does not exist
$number = file_get_contents("log.txt");file_put_contents("log.txt", ($number +1)%3);
Do it with Redis.
Use list structure, first build customer Service list, new users come in when Rpop a team end customer service use, and then put this customer service Lpush to Team head
When adding customer service, if you want the order of the sequence is unchanged, such as 2 3 1, the newly added 4 list to become 2 3 4 1 This time to remove the queue for logical judgment. If you do not need to lpush directly to the team head.
Write files without Redis, and each guest "\r\n"
takes the same rules as above
Xie invited, simply wrote a function, is that what you want?
输出结果
1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,4,1,2,3,4,1,
!--? phpclass servicefactory{private $num; Private $count = 0; function __construct ($num) {$this--->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 (), ",";
Super simple hash algorithm to a, customer service number n new registered user ID m then assigned the customer service is m% n + 1 can be
Previously wrote a similar, but not customer service, here is not posted code, talk about personal practices:
The ultimate goal is to make every customer service busy, and not keep users waiting.
So, to a new user, assign him one:
if ( 空闲状态的客服数 >= 0 ){ // 分配给最先进入空闲状态的那个客服}else{ // 说明现在每个客服都有用户在咨询 // 并且可能某些客服下还有在排队等待的用户 获取每个客服 **当前咨询任务** 的开始时间 将这个用户分配给 当前资讯任务 的开始时间最早的 并且 后面排队人数最少的哪个客服 // 其实上面还有一个权重的问题,比如 A 客服 当前客户资讯任务开始时间比 B 早 2分钟,但是 A 后面排队的人数比 B 客服多 1个,这就要靠 权重值 来计算是分配给 A 还是 B。}
Personally think Ha, can allocate virtual customer service X, is actually a machine question and answer system, and then a customer service end, immediately assign the queue of users in the past, so there is no jump queue or other troublesome things. At the same time, it's easy to get busy with every customer service.
I am also just contact with this knowledge, the answer is not good also ask you to correct, thank you