fix add customer

main
nocode 1 year ago
parent 1e6e24b143
commit 8a951d644a
  1. 15
      Modules/Agents/Services/AgentService.php

@ -59,8 +59,8 @@ class AgentService
//
$isInAgentDistance = $this->modelCustomer->byPhone($dataInput['phone'])->whereDate('created_at', '>', $dateNotToo)->orderBy('created_at','asc')->get();
if (empty($isInAgentDistance)) { // ko co trong DS 15 ngay
// dd(empty($isInAgentDistance[0]));
if (empty($isInAgentDistance[0])) { // ko co trong DS 15 ngay
$dataInsert['agent_id'] = $agentId;
$this->modelCustomer->insert($dataInsert);
$this->modelCustomer->byPhone($dataInput['phone'])->notAgent($agentId)->delete();
@ -68,13 +68,14 @@ class AgentService
$agentIdBelonging = $isInAgentDistance[0]->agent_id;
if($agentIdBelonging == $agentId){
$dataInsert['agent_id'] = $agentId;
$this->modelCustomer->insert($dataInsert);
$idAgentInsert = $agentIdBelonging;
}else{
$dataInsert['agent_id'] = $agentIdBelonging;
$this->modelCustomer->insert($dataInsert);
$this->modelCustomer->byPhone($dataInput['phone'])->notAgent($agentIdBelonging)->delete();
$idAgentInsert = $agentId;
$this->modelCustomer->byPhone($dataInput['phone'])->notAgent($agentId)->delete();
}
$dataInsert['agent_id'] = $agentIdBelonging;
$this->modelCustomer->insert($dataInsert);
}
\DB::commit();

Loading…
Cancel
Save