|
|
|
@ -68,10 +68,8 @@ class AgentService |
|
|
|
|
$dataInsert['agent_id'] = $agentId; |
|
|
|
|
$result = $this->modelCustomer->insert($dataInsert); |
|
|
|
|
// nếu agent id cũ != cái hiện tại check |
|
|
|
|
$checkOldCustomer = $this->modelCustomer->where('phone', $dataInput['phone'])->where('agent_id', '=',$agentId)->latest()->first(); |
|
|
|
|
if($agentId != $checkOldCustomer->agent_id){ |
|
|
|
|
$this->modelCustomer->where('phone', $dataInput['phone'])->where('agent_id', '<>',$agentId)->where('created_at', '<=', $dateNotToo)->delete(); |
|
|
|
|
} |
|
|
|
|
$this->modelCustomer->where('phone', $dataInput['phone'])->where('agent_id', '<>',$agentId)->delete(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
\DB::commit(); |
|
|
|
|