将待处理订单分成两队
当客户在网站上提交订单时..员工可以在管理后端查看待处理订单(从 mysql 中提取数据),但我希望将待处理订单分成两个团队。
示例
我们收到了 21 个待处理订单。
现有工作人员11人。
团队 1:5 名员工
团队 2:6 名员工
团队 1 可以查看 11 个订单,团队 2 可以查看 10 个订单
有时我每小时可能会收到 100 个订单 - PHP 应该决定将一半的挂单分成两个团队(动态)...
是否应该在订单表上设置 team_id ?例如:tbl_orders.team_id = 2
用户何时提交订单? ..但是如果没有足够的员工登录团队 1 或 2 该怎么办
When the customers submit the orders on the website.. staffs can view the pending orders (pull data from mysql) on the admin backend but I want the pending orders to split into two team.
Example
We have received 21 pending orders.
There are 11 staffs.
Team 1: 5 staffs
Team 2: 6 staffs
Team 1 can view 11 orders and Team 2 can view 10
Sometime I might get 100 orders every hour - PHP should determine to split half of the pending orders into two teams (dynamically)...
Should the team_id set on the order table? Eg: tbl_orders.team_id = 2
when users submit the orders? .. but what if not enough staffs logged in team 1 or 2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你有2种方法。
首先(动态)
首先计算所有未决的:
然后向团队 1 展示上半场:
团队 2 获得:
如果您有更多团队,则只需将插入的团队总数除以 2。
第二个选项(固定)
当插入待处理时,您将它们与一个团队相关联。但您必须向表中添加另一个字段。
假设您有一个字段
team TINYINT(1) UNSIGNED
。当放置下一个待处理时,您检查插入的最后一个团队:
假设您有一个配置,其中存储了您的团队数量:
使用您通过查询选择的值:
现在您拥有可以与此相关的悬而未决。当然,您将其添加为
第二个解决方案可能会受到竞争条件的影响。 (IE:2个待处理的放置在几乎相同的位置可能与同一个团队相关联,但我相信这根本不会造成伤害)
Addum
要计算最近做过某事的团队,您有两种方法:
此时,可以轻松选择最近进行活动的团队数量。
使用表团队,您只需要执行以下操作:
有了这个数字,您就可以将您需要的所有待处理拆分为:
并在我的第一个解决方案中使用此偏移量
You have 2 ways.
First (dynamic)
First of all you count all the pendings:
Then you show the first half to team 1:
Team 2 gets:
If you have more team you just need to divide for the total number of teams insted by 2.
Second option (fixed)
When pending are inserted you associate them with a team. But you have to add another field to your table.
Let's say you have a field
team TINYINT(1) UNSIGNED
.When the next pending is placed you check the last team inserted with this:
Let's say you have a config where is stored your number of teams:
With the value that you have select with the query you do:
Now you have the team that can be associated with this pending. Of course you add it with
This second solution may suffer of race condition. (IE: 2 pending placed at nearly the same istant may be associated with the same team, but I believe this will not hurt at all )
Addedum
To count the team that recently have done something you have 2 ways:
teams
where you store the last login data of the staff.At this point it's easy to select the number of team with a recently activity.
Using the table team you just need to do a:
Having this number you can split all the pending you need with:
And use this offset within my first solution