add flutter

This commit is contained in:
Ariska
2026-03-11 15:29:37 +07:00
parent c253e1a370
commit 619d758027
9490 changed files with 135801 additions and 1353 deletions
+17 -5
View File
@@ -10,6 +10,7 @@ class Merchant extends REST_Controller
parent::__construct();
$this->load->helper("url");
$this->load->helper('fcm_v1_helper');
$this->load->database();
$this->load->model('Merchantapi_model');
$this->load->model('wallet_model', 'wallet');
@@ -64,9 +65,13 @@ class Merchant extends REST_Controller
$data = file_get_contents("php://input");
$decoded_data = json_decode($data);
$reg_id = array(
'token_merchant' => $decoded_data->token
);
// Only save FCM token when valid (relogin overwrites invalid/placeholder tokens).
$token = isset($decoded_data->token) ? trim((string) $decoded_data->token) : '';
$token = (isset($decoded_data->reg_id) && trim((string) $decoded_data->reg_id) !== '') ? trim((string) $decoded_data->reg_id) : $token;
$reg_id = array();
if ($token !== '' && function_exists('fcm_v1_is_valid_device_token') && fcm_v1_is_valid_device_token($token)) {
$reg_id['token_merchant'] = $token;
}
$condition = array(
'password' => sha1($decoded_data->password),
@@ -84,7 +89,9 @@ class Merchant extends REST_Controller
$cek_login = $this->Merchantapi_model->get_data_merchant($condition);
$message = array();
if ($cek_login->num_rows() > 0) {
$this->Merchantapi_model->edit_profile_token($reg_id, $decoded_data->no_telepon);
if (!empty($reg_id)) {
$this->Merchantapi_model->edit_profile_token($reg_id, $decoded_data->no_telepon);
}
$get_pelanggan = $this->Merchantapi_model->get_data_merchant($condition);
$message = array(
'code' => '200',
@@ -183,6 +190,11 @@ class Merchant extends REST_Controller
$path = "images/merchant/" . $namafoto;
file_put_contents($path, base64_decode($image));
// Merchant apps prior to FCM v1 do not send a Firebase token on register.
// Generate a deterministic placeholder from email so token_merchant is never empty.
// This value is NOT a real FCM token; Notification_model will ignore it for push.
$tokenPlaceholder = 'R' . sprintf('%u', crc32(strtolower(trim((string) $dec_data->email))));
$data_merchant = array(
'id_fitur' => $dec_data->id_fitur,
'nama_merchant' => $dec_data->nama_merchant,
@@ -197,7 +209,7 @@ class Merchant extends REST_Controller
'phone_merchant' => $dec_data->phone,
'country_code_merchant' => $dec_data->countrycode,
'status_merchant' => '0',
'token_merchant' => time()
'token_merchant' => $tokenPlaceholder
);
$imagektp = $dec_data->foto_ktp;