我有 4 个销售办事处,一旦所有 4 个销售办事处均收到 20 个销售线索,则只有 4 号销售办事处应该收到当天剩余的销售线索。我需要一些帮助来创建条件,以基本上检查销售办公室 1-4 是否均已收到 20 个潜在客户,然后显然按照说明继续进行
首先,我查询数据库来检查我的计数器(是的,我知道这可以更紧凑,并且可以在循环内完成)
$sales_office= 1; $sql = $conn->prepare("SELECT LeadsReceivedToday FROM Lead_Counter WHERE SalesOffice=?"); $sql->execute([$sales_office]); $result = $sql->fetch(); $sales_office1_count = $result['LeadsReceivedToday']; $sales_office= 2; $sql = $conn->prepare("SELECT LeadsReceivedToday FROM Lead_Counter WHERE SalesOffice=?"); $sql->execute([$sales_office]); $result = $sql->fetch(); $sales_office2_count = $result['LeadsReceivedToday']; $sales_office= 3; $sql = $conn->prepare("SELECT LeadsReceivedToday FROM Lead_Counter WHERE SalesOffice=?"); $sql->execute([$sales_office]); $result = $sql->fetch(); $sales_office3_count = $result['LeadsReceivedToday']; $sales_office= 4; $sql = $conn->prepare("SELECT LeadsReceivedToday FROM Lead_Counter WHERE SalesOffice=?"); $sql->execute([$sales_office]); $result = $sql->fetch(); $sales_office4_count = $result['LeadsReceivedToday'];
当我执行这个逻辑时,它没有按预期工作?一旦 sales_office = 1 达到 20 个销售线索,它就会直接转移到销售办公室 4?
if ($sales_office1_count != 20 && $sales_office2_count != 20 && $sales_office3_count != 20) { //distribute leads to sales office 1-4 in order of 1-4 } else { //only send leads to sales office no 4 }
您当前对所有办公室计数的逻辑检查,您必须分别检查每个办公室。