+ Timezone of dates is now providing by user : Fixed v3

This commit is contained in:
Djery-Tom 2020-11-16 09:13:57 +01:00
parent 24fab34805
commit bf2e38508d
5 changed files with 24 additions and 14 deletions

View File

@ -82,7 +82,7 @@ class CreditController extends Controller
$this->sendPushNotificationToAgent($agent->code_membre, $this->sendPushNotificationToAgent($agent->code_membre,
trans('notifications.accepted_credit_request', trans('notifications.accepted_credit_request',
['amount' => $this->toMoneyWithCurrencyCode($demand->montant, $walletAgentParrain->currency_code), "godfather" => $parrain->lastname . ' ' . $parrain->lastname]), $data); ['amount' => $this->toMoneyWithCurrencyCode($demand->montant, $walletAgentParrain->currency_code), "godfather" => $parrain->lastname . ' ' . $parrain->lastname]), $data, $datetime);
return $this->successResponse(trans('messages.success_treated_demand')); return $this->successResponse(trans('messages.success_treated_demand'));
} }
@ -103,7 +103,10 @@ class CreditController extends Controller
$agent = AgentPlus::where('code_membre', $demand->code_membre)->firstOrFail(); $agent = AgentPlus::where('code_membre', $demand->code_membre)->firstOrFail();
$parrain = AgentPlus::where('code_membre', $demand->code_parrain)->firstOrFail(); $parrain = AgentPlus::where('code_membre', $demand->code_parrain)->firstOrFail();
$walletAgentParrain = WalletAgent::where('agent_id', $parrain->id)->firstOrFail(); $walletAgentParrain = WalletAgent::where('agent_id', $parrain->id)->firstOrFail();
$datetime = $this->getCurrentTime($walletAgentParrain->network->country_id);
$data = new \stdClass(); $data = new \stdClass();
$data->screen = "notificationview"; $data->screen = "notificationview";
@ -112,7 +115,7 @@ class CreditController extends Controller
$this->sendPushNotificationToAgent($agent->code_membre, $this->sendPushNotificationToAgent($agent->code_membre,
trans('notifications.refused_credit_request', trans('notifications.refused_credit_request',
['amount' => $this->toMoneyWithCurrencyCode($demand->montant, $walletAgentParrain->currency_code), "godfather" => $parrain->lastname . ' ' . $parrain->lastname]), $data); ['amount' => $this->toMoneyWithCurrencyCode($demand->montant, $walletAgentParrain->currency_code), "godfather" => $parrain->lastname . ' ' . $parrain->lastname]), $data, $datetime);
return $this->successResponse(trans('messages.canceled_demand')); return $this->successResponse(trans('messages.canceled_demand'));
} }
} }

View File

@ -134,7 +134,7 @@ class NanoCreditController extends Controller
$data->data->id = $demande->id; $data->data->id = $demande->id;
$this->sendPushNotificationToAgent($walletHyper->codeMembre, $this->sendPushNotificationToAgent($walletHyper->codeMembre,
trans('notifications.group_nano_credit_request', ['name' => $group->nom]), $data); trans('notifications.group_nano_credit_request', ['name' => $group->nom]), $data, $demande->date_creation);
return $this->successResponse(trans('messages.successful_nano_credit_sent_to_hypervisor')); return $this->successResponse(trans('messages.successful_nano_credit_sent_to_hypervisor'));
} else { } else {

View File

@ -184,7 +184,7 @@ class UserGroupController extends Controller
$data->data = new \stdClass();; $data->data = new \stdClass();;
$data->data->id = $request->id_demande; $data->data->id = $request->id_demande;
$this->sendPushNotificationToUser($group->createur->user_code, $this->sendPushNotificationToUser($group->createur->user_code,
trans('notifications.accepted_group_validation_request', ['name' => $sponsor->lastname . ' ' . $sponsor->firstname]), $data); trans('notifications.accepted_group_validation_request', ['name' => $sponsor->lastname . ' ' . $sponsor->firstname]), $data, $demande->date_validation);
return $this->successResponse(trans_choice('messages.successful_group_validation', 3 - $group->nombre_validation, ['count' => (3 - $group->nombre_validation)])); return $this->successResponse(trans_choice('messages.successful_group_validation', 3 - $group->nombre_validation, ['count' => (3 - $group->nombre_validation)]));
@ -219,14 +219,14 @@ class UserGroupController extends Controller
if ($demande->type == 'creation') { if ($demande->type == 'creation') {
$this->sendPushNotificationToUser($group->createur->user_code, $this->sendPushNotificationToUser($group->createur->user_code,
trans('notifications.refused_group_validation_request', ['name' => $sponsor->lastname . ' ' . $sponsor->firstname]), $data); trans('notifications.refused_group_validation_request', ['name' => $sponsor->lastname . ' ' . $sponsor->firstname]), $data, $demande->date_validation);
return $this->successResponse(trans('messages.successful_refused_group_validation')); return $this->successResponse(trans('messages.successful_refused_group_validation'));
} }
if ($demande->type == 'suppression') { if ($demande->type == 'suppression') {
$this->sendPushNotificationToUser($group->createur->user_code, $this->sendPushNotificationToUser($group->createur->user_code,
trans('notifications.refused_group_deleting_request', ['name' => $sponsor->lastname . ' ' . $sponsor->firstname]), $data); trans('notifications.refused_group_deleting_request', ['name' => $sponsor->lastname . ' ' . $sponsor->firstname]), $data, $demande->date_validation);
return $this->successResponse(trans('messages.successful_refused_group_deleting')); return $this->successResponse(trans('messages.successful_refused_group_deleting'));
} }
@ -234,14 +234,14 @@ class UserGroupController extends Controller
if ($demande->type == 'adhesion') { if ($demande->type == 'adhesion') {
$user = User::findOrFail($demande->id_user); $user = User::findOrFail($demande->id_user);
$this->sendPushNotificationToUser($user->user_code, $this->sendPushNotificationToUser($user->user_code,
trans('notifications.successful_canceled_group_membership_request', ['name' => $sponsor->lastname . ' ' . $sponsor->firstname]), $data); trans('notifications.successful_canceled_group_membership_request', ['name' => $sponsor->lastname . ' ' . $sponsor->firstname]), $data, $demande->date_validation);
return $this->successResponse(trans('messages.successful_canceled_group_membership_request')); return $this->successResponse(trans('messages.successful_canceled_group_membership_request'));
} }
if ($demande->type == 'nano_credit') { if ($demande->type == 'nano_credit') {
$user = User::findOrFail($demande->id_user); $user = User::findOrFail($demande->id_user);
$this->sendPushNotificationToUser($user->user_code, trans('notifications.refused_group_nano_credit_request'), $data); $this->sendPushNotificationToUser($user->user_code, trans('notifications.refused_group_nano_credit_request'), $data, $demande->date_validation);
return $this->successResponse(trans('messages.successful_canceled_nano_credit_request')); return $this->successResponse(trans('messages.successful_canceled_nano_credit_request'));
} }
@ -383,7 +383,7 @@ class UserGroupController extends Controller
$data->data->id = $demande->id; $data->data->id = $demande->id;
$this->sendPushNotificationToUser($sponsor_code, $this->sendPushNotificationToUser($sponsor_code,
trans($message_id, ['name' => $sender->lastname . ' ' . $sender->firstname]), $data); trans($message_id, ['name' => $sender->lastname . ' ' . $sender->firstname]), $data, $demande->date_creation);
} }
@ -474,7 +474,7 @@ ug.date_creation as date_creation_groupe , ug.createur , ug.sponsor1 , ug.sponso
$data->data = new \stdClass();; $data->data = new \stdClass();;
$data->data->id = $request->id_demande; $data->data->id = $request->id_demande;
$this->sendPushNotificationToUser($user->user_code, $this->sendPushNotificationToUser($user->user_code,
trans('notifications.accepted_group_membership_request', ['name' => $sponsor->lastname . ' ' . $sponsor->firstname]), $data); trans('notifications.accepted_group_membership_request', ['name' => $sponsor->lastname . ' ' . $sponsor->firstname]), $data, $demande->date_validation);
return $this->successResponse(trans('messages.successful_accepted_group_membership_request')); return $this->successResponse(trans('messages.successful_accepted_group_membership_request'));
@ -533,7 +533,7 @@ ug.date_creation as date_creation_groupe , ug.createur , ug.sponsor1 , ug.sponso
$data->data = new \stdClass();; $data->data = new \stdClass();;
$data->data->id = $request->id_demande; $data->data->id = $request->id_demande;
$this->sendPushNotificationToUser($group->createur->user_code, $this->sendPushNotificationToUser($group->createur->user_code,
trans('notifications.accepted_group_deleting_request', ['name' => $sponsor->lastname . ' ' . $sponsor->firstname]), $data); trans('notifications.accepted_group_deleting_request', ['name' => $sponsor->lastname . ' ' . $sponsor->firstname]), $data, $demande->date_validation);
return $this->successResponse(trans_choice('messages.successful_group_deleting', 3 - $group->nombre_validation, ['count' => (3 - $group->nombre_validation)])); return $this->successResponse(trans_choice('messages.successful_group_deleting', 3 - $group->nombre_validation, ['count' => (3 - $group->nombre_validation)]));
@ -615,7 +615,7 @@ ug.date_creation , ug.createur , ug.sponsor1 , ug.sponsor2 , ug.sponsor3, ug.cou
$data->screen = "notificationview"; $data->screen = "notificationview";
$data->data = new \stdClass();; $data->data = new \stdClass();;
$data->data->id = $request->id_demande; $data->data->id = $request->id_demande;
$this->sendPushNotificationToUser($user->user_code, trans('notifications.accepted_group_nano_credit_request'), $data); $this->sendPushNotificationToUser($user->user_code, trans('notifications.accepted_group_nano_credit_request'), $data, $demande->date_validation);
$message = trans('messages.successful_user_group_nano_credit_demand', $message = trans('messages.successful_user_group_nano_credit_demand',
['id_demand' => $demande_credit->id_demande, 'amount' => $this->toMoneyWithCurrencyCode($montant_total, $currency_code), ['id_demand' => $demande_credit->id_demande, 'amount' => $this->toMoneyWithCurrencyCode($montant_total, $currency_code),

View File

@ -64,4 +64,9 @@ class WalletAgent extends Model
'currency_code', 'currency_code',
'transactionNumber' 'transactionNumber'
]; ];
public function network()
{
return $this->belongsTo(Network::class, 'network_id');
}
} }

View File

@ -47,7 +47,7 @@ trait Helper
// return $this->successResponse("mail envoye"); // return $this->successResponse("mail envoye");
} }
public function sendPushNotificationToUser($user_code, $message, $data = null) public function sendPushNotificationToUser($user_code, $message, $data = null, $date = null)
{ {
$client = new \GuzzleHttp\Client([ $client = new \GuzzleHttp\Client([
'base_uri' => env('NOTIFICATION_SERVICE_URL'), 'base_uri' => env('NOTIFICATION_SERVICE_URL'),
@ -59,6 +59,7 @@ trait Helper
$body->user_code = $user_code; $body->user_code = $user_code;
$body->message = $message; $body->message = $message;
$body->data = $data; $body->data = $data;
$body->date = $date;
$promise = $client->requestAsync('POST', '/onesignal/pushToUser', ['json' => $body, 'headers' => $headers])->then(); $promise = $client->requestAsync('POST', '/onesignal/pushToUser', ['json' => $body, 'headers' => $headers])->then();
// function (ResponseInterface $res) { // function (ResponseInterface $res) {
// echo $res->getStatusCode() . "\n"; // echo $res->getStatusCode() . "\n";
@ -72,7 +73,7 @@ trait Helper
// return $response->getBody()->getContents(); // return $response->getBody()->getContents();
} }
public function sendPushNotificationToAgent($agent_code, $message, $data = null) public function sendPushNotificationToAgent($agent_code, $message, $data = null, $date = null)
{ {
$client = new \GuzzleHttp\Client([ $client = new \GuzzleHttp\Client([
'base_uri' => env('NOTIFICATION_SERVICE_URL'), 'base_uri' => env('NOTIFICATION_SERVICE_URL'),
@ -84,6 +85,7 @@ trait Helper
$body->agent_code = $agent_code; $body->agent_code = $agent_code;
$body->message = $message; $body->message = $message;
$body->data = $data; $body->data = $data;
$body->date = $date;
$promise = $client->requestAsync('POST', '/onesignal/pushToAgent', ['json' => $body, 'headers' => $headers])->then(); $promise = $client->requestAsync('POST', '/onesignal/pushToAgent', ['json' => $body, 'headers' => $headers])->then();
$promise->wait(); $promise->wait();
} }