fix: 更新数据库表名引用及配置

This commit is contained in:
2026-03-27 11:10:11 +08:00
parent b9ed1b2492
commit 70b8cf0316
12 changed files with 141 additions and 192 deletions

View File

@@ -114,7 +114,7 @@ func (s *inventoryCountDetail) fillListItemNames(ctx context.Context, details []
Id *bson.ObjectID `bson:"_id"`
Name string `bson:"assetName"`
}
if _, e := mongo.DB().Find(ctx, bson.M{"_id": bson.M{"$in": ids}}, &assets, public.AssetCollection, nil, nil); e == nil {
if _, e := mongo.DB().Find(ctx, bson.M{"_id": bson.M{"$in": ids}}, &assets, public.TableNameAsset, nil, nil); e == nil {
for _, a := range assets {
assetNameMap[a.Id.Hex()] = a.Name
}

View File

@@ -89,6 +89,7 @@ func (s *stockManage) GetStockFormFields(ctx context.Context, req *stockDto.GetS
// StockOperation 库存操作入口(入库/出库)
// 根据SKU的StockMode区分明细模式和批次模式计算差值后发布消息到NATS
func (s *stockManage) StockOperation(ctx context.Context, req *stockDto.StockOperationReq) (err error) {
// TODO 后续需要排一下查询应该不走缓存,否则会导致库存不准确
assetSku, err := assetDao.AssetSku.GetOne(ctx, &assetDto.GetAssetSkuReq{Id: req.AssetSkuId})
if err != nil {
return
@@ -179,7 +180,8 @@ func (s *stockManage) stockPublishMessage(ctx context.Context, assetSku *assetEn
// 使用Redis分布式锁防止并发冲突支持明细模式和批次模式
func (s *stockManage) AddStock(ctx context.Context, msg any) error {
var req = new(stockDto.StockPublishMessage)
if err := gconv.Struct(msg, &req); err != nil {
msgMap := gconv.Map(msg)
if err := gconv.Struct(msgMap["data"], &req); err != nil {
return err
}
// 设置 userId 和 tenantId 到 ctx