|
|
@ -80,7 +80,28 @@ class AgentService |
|
|
|
} |
|
|
|
} |
|
|
|
return ['status' => false, 'msg' => $this->getMessageReturn('failed_insert')]; |
|
|
|
return ['status' => false, 'msg' => $this->getMessageReturn('failed_insert')]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Summary of myCustomer |
|
|
|
|
|
|
|
* @param array $input |
|
|
|
|
|
|
|
* @return array |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function myCustomer($input){ |
|
|
|
|
|
|
|
$listCustomer = []; |
|
|
|
|
|
|
|
$myAgent = $this->modelAgentUser->where('user_id', auth()->user()->id)->latest()->first(); |
|
|
|
|
|
|
|
if(empty($myAgent) || empty($myAgent->agent_id)){ |
|
|
|
|
|
|
|
return ['status' => false, 'msg' => $this->getMessageReturn('no_data_agent')]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$agentId = $myAgent->agent_id; |
|
|
|
|
|
|
|
$queryAgent = $this->modelCustomer->where('agent_id', $agentId); |
|
|
|
|
|
|
|
if(!empty($input['start_date']) && !empty($input['end_date'])){ |
|
|
|
|
|
|
|
$queryAgent->whereBetween('created_at', [$input['start_date'], $input['end_date']]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(!empty($input['keyword'])){ |
|
|
|
|
|
|
|
$queryAgent->where('name', 'LIKE', '%' . $input['keyword'] . '%'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$listCustomer = $queryAgent->orderBy('name', 'asc')->get(); |
|
|
|
|
|
|
|
return ['status' => true, 'data' => $listCustomer, 'msg' => $this->getMessageReturn('success')]; |
|
|
|
|
|
|
|
} |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Summary of formatCreateCustomer |
|
|
|
* Summary of formatCreateCustomer |
|
|
|
* @param array $data |
|
|
|
* @param array $data |
|
|
@ -123,6 +144,7 @@ class AgentService |
|
|
|
'no_data_agent' => 'Đại lý không tồn tại.', |
|
|
|
'no_data_agent' => 'Đại lý không tồn tại.', |
|
|
|
'success_insert_customer' => 'Thêm khách hàng thành công.', |
|
|
|
'success_insert_customer' => 'Thêm khách hàng thành công.', |
|
|
|
'failed_insert' => 'Thêm khách hàng thành công.', |
|
|
|
'failed_insert' => 'Thêm khách hàng thành công.', |
|
|
|
|
|
|
|
'success' => 'Load data thành công.' |
|
|
|
]; |
|
|
|
]; |
|
|
|
return $msgArr[$errorKey] ?? "Không có dữ liệu."; |
|
|
|
return $msgArr[$errorKey] ?? "Không có dữ liệu."; |
|
|
|
} |
|
|
|
} |
|
|
|