统一时间格式和时区

This commit is contained in:
yml2213
2026-07-31 12:57:17 +08:00
parent 667bfbde06
commit 949a0eb8f7
24 changed files with 342 additions and 49 deletions
+2 -1
View File
@@ -17,6 +17,7 @@ import (
"time"
"affiliate_dash/internal/model"
"affiliate_dash/internal/pkg/timeutil"
"github.com/google/uuid"
"gorm.io/gorm"
@@ -140,7 +141,7 @@ func (s *CallbackService) Enqueue(tx *gorm.DB, merchantID uint, event string, da
payload, err := json.Marshal(map[string]interface{}{
"event_id": eventID,
"event": event,
"occurred_at": now.UTC().Format(time.RFC3339Nano),
"occurred_at": timeutil.FormatAPITime(now),
"data": data,
})
if err != nil {
+2 -1
View File
@@ -16,6 +16,7 @@ import (
"time"
"affiliate_dash/internal/model"
"affiliate_dash/internal/pkg/timeutil"
"gorm.io/gorm"
"gorm.io/gorm/clause"
@@ -349,7 +350,7 @@ func (s *DeliveryService) claimDeliverySubmission(merchantID, apiClientID uint,
}
raw, _ := json.Marshal(map[string]interface{}{
"source": "delivery_proxy",
"submit_started_at": time.Now().UTC().Format(time.RFC3339),
"submit_started_at": timeutil.FormatAPITime(time.Now()),
"provider_order_stage": "claimed",
})
if err := tx.Model(&order).Updates(map[string]interface{}{
+5 -6
View File
@@ -10,6 +10,7 @@ import (
"unicode/utf8"
"affiliate_dash/internal/model"
"affiliate_dash/internal/pkg/timeutil"
"github.com/google/uuid"
"gorm.io/gorm"
@@ -599,11 +600,11 @@ func (s *FulfillmentService) ListWalletLedger(merchantID uint, page, size int) (
}
func newFulfillmentOrderNo() string {
return "FO" + time.Now().UTC().Format("20060102150405") + strings.ReplaceAll(uuid.NewString()[:12], "-", "")
return "FO" + timeutil.Now().Format(timeutil.OrderNoLayout) + strings.ReplaceAll(uuid.NewString()[:12], "-", "")
}
func newTestFulfillmentOrderNo() string {
return "O" + time.Now().UTC().Format("20060102150405") + strings.ReplaceAll(uuid.NewString()[:12], "-", "")
return "O" + timeutil.Now().Format(timeutil.OrderNoLayout) + strings.ReplaceAll(uuid.NewString()[:12], "-", "")
}
// calculateServiceFee 按"百分比或固定"二选一计算手续费:
@@ -712,9 +713,7 @@ func (s *FulfillmentService) Dashboard(merchantID uint, isPlatformAdmin bool) (*
if isPlatformAdmin {
stats.Scope = "platform"
}
now := time.Now()
year, month, day := now.Date()
todayStart := time.Date(year, month, day, 0, 0, 0, 0, now.Location())
todayStart := timeutil.StartOfDay(time.Now())
productScope := func() *gorm.DB {
tx := s.db.Model(&model.MerchantProduct{})
@@ -1130,7 +1129,7 @@ func buildShipNotifyResultData(existing string, in ShipNotifyInput, shippedAt *t
m["fail_reason"] = in.FailReason
}
if shippedAt != nil {
m["shipped_at"] = shippedAt.Format(time.RFC3339)
m["shipped_at"] = timeutil.FormatAPITime(*shippedAt)
}
if in.GameChannel != nil {
m["game_channel"] = *in.GameChannel