Database

db={"col1":[{_id:"61241ad82fcb9a369e59868a","name":"aaaa","products":[{"_id":"611803232eeaf825336e26c4","name":"products1","pricePolicy":{"costPrice":10}},{"_id":"611803232eeaf825336e26c5","name":"products2","pricePolicy":{"costPrice":10}}]},{_id:"61241ad82fcb9a369e59868b","name":"bbb","products":[{"_id":"611803232eeaf825336e26c4","name":"products1","pricePolicy":{"costPrice":20}},{"_id":"611803232eeaf825336e26c5","name":"products2","pricePolicy":{"costPrice":10}}]}],"col2":[{"_id":"61179c8d4ef00f31df195223","name":"zzzz","listProduct":[{"id":"611803232eeaf825336e26c4","name":"products1","costPrice":100},{"id":"611803232eeaf825336e26c6","name":"products3","costPrice":10}]}]}

Query

db.col1.aggregate([{$unwind:"$products"},{$group:{_id:null,col1:{$push:{_id:"$products._id",name:"$products.name",totalCollection1:"$products.pricePolicy.costPrice"}}}},{$lookup:{from:"col2",pipeline:[{$unwind:"$listProduct"},{$project:{_id:"$listProduct.id",name:"$listProduct.name",totalCollection2:"$listProduct.costPrice"}}],as:"col2"}},{$project:{products:{$concatArrays:["$col1","$col2"]}}},{$unwind:"$products"},{$group:{_id:"$products._id",name:{$first:"$products.name"},totalCollection1:{$sum:{$ifNull:["$products.totalCollection1",0]}},totalCollection2:{$sum:{$ifNull:["$products.totalCollection2",0]}}}},{$addFields:{total:{$sum:["$totalCollection1","$totalCollection2"]}}},{$sort:{total:-1}}])

Result