|
|
|
@ -59,7 +59,7 @@ class AgentService |
|
|
|
|
// tìm các dữ liệu từ ngày hiện tại trừ đi không được quá 15 ngày |
|
|
|
|
$customerAgentAll = $this->modelCustomer->where('phone', $dataInput['phone'])->where('agent_id', '<>', $agentId)->where('created_at', '>=', $dateNotToo)->latest()->first(); |
|
|
|
|
$dataInsert['created_at'] = now(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($customerAgentAll)) { |
|
|
|
|
// chưa quá 15 ngày thì lấy cái agent_id cũ, đang trực thuộc |
|
|
|
|
$dataInsert['agent_id'] = $customerAgentAll->agent_id; |
|
|
|
@ -109,7 +109,7 @@ class AgentService |
|
|
|
|
; |
|
|
|
|
} |
|
|
|
|
// dd($queryAgent->toSql(),$queryAgent->getBindings()); |
|
|
|
|
$listCustomer = $queryAgent->orderBy('name', 'asc')->get(); |
|
|
|
|
$listCustomer = $queryAgent->orderBy('created_at', 'desc')->get(); |
|
|
|
|
if (!empty($listCustomer)) { |
|
|
|
|
foreach ($listCustomer as $listC) { |
|
|
|
|
$finalAgentData[] = [ |
|
|
|
|