修改
This commit is contained in:
@@ -494,13 +494,16 @@ func (s *Service) AllocateCards(ctx context.Context, req *dto.AllocateStandalone
|
||||
}
|
||||
}
|
||||
|
||||
shopMap := s.loadShopNames(ctx, cards)
|
||||
targetShopName := s.getAuditShopName(ctx, &req.ToShopID)
|
||||
beforeData := make([]map[string]any, 0, len(cards))
|
||||
for _, card := range cards {
|
||||
beforeData = append(beforeData, map[string]any{
|
||||
"id": card.ID,
|
||||
"iccid": card.ICCID,
|
||||
"shop_id": card.ShopID,
|
||||
"status": card.Status,
|
||||
"id": card.ID,
|
||||
"iccid": card.ICCID,
|
||||
"shop_id": card.ShopID,
|
||||
"shop_name": shopMapValue(shopMap, card.ShopID),
|
||||
"status": card.Status,
|
||||
})
|
||||
}
|
||||
s.logCardAudit(ctx, assetAuditSvc.BuildLogParams{
|
||||
@@ -515,6 +518,7 @@ func (s *Service) AllocateCards(ctx context.Context, req *dto.AllocateStandalone
|
||||
},
|
||||
AfterData: map[string]any{
|
||||
"to_shop_id": req.ToShopID,
|
||||
"to_shop_name": targetShopName,
|
||||
"new_status": newStatus,
|
||||
"failed_items": failedItems,
|
||||
},
|
||||
@@ -702,13 +706,16 @@ func (s *Service) RecallCards(ctx context.Context, req *dto.RecallStandaloneCard
|
||||
}
|
||||
}
|
||||
|
||||
shopMap := s.loadShopNames(ctx, successCards)
|
||||
targetShopName := s.getAuditRecallTargetShopName(ctx, newShopID)
|
||||
beforeData := make([]map[string]any, 0, len(successCards))
|
||||
for _, card := range successCards {
|
||||
beforeData = append(beforeData, map[string]any{
|
||||
"id": card.ID,
|
||||
"iccid": card.ICCID,
|
||||
"shop_id": card.ShopID,
|
||||
"status": card.Status,
|
||||
"id": card.ID,
|
||||
"iccid": card.ICCID,
|
||||
"shop_id": card.ShopID,
|
||||
"shop_name": shopMapValue(shopMap, card.ShopID),
|
||||
"status": card.Status,
|
||||
})
|
||||
}
|
||||
s.logCardAudit(ctx, assetAuditSvc.BuildLogParams{
|
||||
@@ -722,9 +729,10 @@ func (s *Service) RecallCards(ctx context.Context, req *dto.RecallStandaloneCard
|
||||
"cards": beforeData,
|
||||
},
|
||||
AfterData: map[string]any{
|
||||
"to_shop_id": newShopID,
|
||||
"new_status": newStatus,
|
||||
"failed_items": failedItems,
|
||||
"to_shop_id": newShopID,
|
||||
"target_shop_name": targetShopName,
|
||||
"new_status": newStatus,
|
||||
"failed_items": failedItems,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -774,6 +782,31 @@ func (s *Service) validateDirectSubordinate(ctx context.Context, operatorShopID
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) getAuditShopName(ctx context.Context, shopID *uint) string {
|
||||
if shopID == nil || *shopID == 0 {
|
||||
return ""
|
||||
}
|
||||
var shop model.Shop
|
||||
if err := s.db.WithContext(ctx).Unscoped().First(&shop, *shopID).Error; err != nil {
|
||||
return ""
|
||||
}
|
||||
return shop.ShopName
|
||||
}
|
||||
|
||||
func (s *Service) getAuditRecallTargetShopName(ctx context.Context, shopID *uint) string {
|
||||
if shopID == nil {
|
||||
return "平台库存"
|
||||
}
|
||||
return s.getAuditShopName(ctx, shopID)
|
||||
}
|
||||
|
||||
func shopMapValue(shopMap map[uint]string, shopID *uint) string {
|
||||
if shopID == nil {
|
||||
return ""
|
||||
}
|
||||
return shopMap[*shopID]
|
||||
}
|
||||
|
||||
func (s *Service) getCardsForAllocation(ctx context.Context, req *dto.AllocateStandaloneCardsRequest, operatorShopID *uint) ([]*model.IotCard, error) {
|
||||
switch req.SelectionType {
|
||||
case dto.SelectionTypeList:
|
||||
@@ -1443,9 +1476,9 @@ func (s *Service) BatchUpdatePollingStatus(ctx context.Context, cardIDs []uint,
|
||||
BatchTotal: len(cardIDs),
|
||||
FailCount: len(cardIDs),
|
||||
AfterData: map[string]any{
|
||||
"card_ids": cardIDs,
|
||||
"enable_polling": enablePolling,
|
||||
"trigger_source": "batch",
|
||||
"card_ids": cardIDs,
|
||||
"enable_polling": enablePolling,
|
||||
"trigger_source": "batch",
|
||||
},
|
||||
})
|
||||
return err
|
||||
@@ -1857,11 +1890,11 @@ func (s *Service) ManualUpdateRealnameStatus(ctx context.Context, cardID uint, r
|
||||
AssetID: freshCard.ID,
|
||||
AssetIdentifier: freshCard.ICCID,
|
||||
BeforeData: map[string]any{
|
||||
"real_name_status": oldStatus,
|
||||
"real_name_status": oldStatus,
|
||||
"first_realname_at": card.FirstRealnameAt,
|
||||
},
|
||||
AfterData: map[string]any{
|
||||
"real_name_status": freshCard.RealNameStatus,
|
||||
"real_name_status": freshCard.RealNameStatus,
|
||||
"first_realname_at": freshCard.FirstRealnameAt,
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user