Bug: [Event Generation] KafkaTimestamp change from second to millisecond



Kafka timestamp currently is in second * 1000 to convert to millisecond precision
Issue with that is Kafka messages are getting out of order while pushing events as changes are happening in millisecond level
Due to which re-ordering of messages is taking place and causing inconsistency in analytics and state of payment in sync sources
diff --git a/crates/router/src/services/kafka.rs b/crates/router/src/services/kafka.rs
index d1abda2105d..baa78339d91 100644
--- a/crates/router/src/services/kafka.rs
+++ b/crates/router/src/services/kafka.rs
@@ -319,11 +319,15 @@ impl KafkaProducer {
                 BaseRecord::to(topic)
                     .key(&event.key())
                     .payload(&event.value()?)
-                    .timestamp(
-                        event
-                            .creation_timestamp()
-                            .unwrap_or_else(|| OffsetDateTime::now_utc().unix_timestamp() * 1_000),
-                    ),
+                    .timestamp(event.creation_timestamp().unwrap_or_else(|| {
+                        (OffsetDateTime::now_utc().unix_timestamp_nanos() / 1_000_000)
+                            .try_into()
+                            .unwrap_or_else(|_| {
+                                // kafka producer accepts milliseconds
+                                // try converting nanos to millis if that fails convert seconds to millis
+                                OffsetDateTime::now_utc().unix_timestamp() * 1_000
+                            })
+                    })),
             )
             .map_err(|(error, record)| report!(error).attach_printable(format!("{record:?}")))
             .change_context(KafkaError::GenericError)

## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [x] Bugfix
- [ ] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->
Adds millisecond timestamp to the kafka timestamp, would help in solving the re-ordering of events in kafka while pushing

### Additional Changes

- [ ] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

<!--
Provide links to the files with corresponding changes.

Following are the paths where you can find config files:
1. `config`
2. `crates/router/src/configs`
3. `loadtest/config`
-->


## Motivation and Context
<!--
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.
Issue link -> https://github.com/juspay/hyperswitch/issues/5201
If you don't have an issue, we'd recommend starting with one first so the PR
can focus on the implementation (unless it is an obvious bug or documentation fix
that will have little conversation).
-->


## How did you test it?
<!--
Did you write an integration/unit/API test to verify the code changes?
Or did you test this change manually (provide relevant screenshots)

-->

<img width="1486" alt="Screenshot 2024-07-04 at 3 02 32 PM" src="https://github.com/juspay/hyperswitch/assets/104988143/f25e41af-f74a-4acf-947d-ebe4a6895fe7">


<img width="1486" alt="Screenshot 2024-07-04 at 3 02 50 PM" src="https://github.com/juspay/hyperswitch/assets/104988143/4bc31792-f7d3-4d88-987b-34c7d628ea7e">

<img width="1472" alt="Screenshot 2024-07-04 at 3 07 25 PM" src="https://github.com/juspay/hyperswitch/assets/104988143/937cbcfa-7e49-4127-9ba8-f5a57b5e2f1a">

## Checklist
<!-- Put an `x` in the boxes that apply -->

- [ ] I formatted the cod
- [ ] `cargo +nightly fmt --all`
- [ ] I addressed lints thrown by `cargo clippy`
- [ ] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
