bill_facade.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * Created by zhang on 2018/1/22.
  3. */
  4. let model = require("../../bills_lib/models/bills_lib_model");
  5. let Bills = model.billsMod;
  6. let _ = require("lodash");
  7. module.exports={
  8. getSectionInfo : async function (data) {
  9. console.log(data);
  10. let conditions=[];
  11. let fxList=[];
  12. let billsLibId=0;
  13. let sectionInfo ={};
  14. for(let libID in data){
  15. let codes=[];
  16. let temp={};
  17. let billsLibId = libID;
  18. codes= _.keys(data[libID]);
  19. temp['billsLibId']=libID;
  20. temp['code'] = {"$in": codes};
  21. conditions.push(temp);
  22. }
  23. if(conditions.length>0){
  24. fxList = await Bills.find({"$or":conditions});
  25. }
  26. if(fxList.length>0){
  27. let sectionIDs = {};
  28. for(let f of fxList){
  29. if(f._doc.sectionInfo){
  30. f._doc.sectionInfo.first?sectionIDs[f._doc.sectionInfo.first]=true:"";
  31. f._doc.sectionInfo.second?sectionIDs[f._doc.sectionInfo.second]=true:"";
  32. f._doc.sectionInfo.third?sectionIDs[f._doc.sectionInfo.third]=true:"";
  33. }
  34. }
  35. let IDList = _.keys(sectionIDs);
  36. let sectionList = await Bills.find({"billsLibId":billsLibId,'ID':{'$in':IDList}});
  37. console.log(sectionList);
  38. console.log('getData');
  39. }
  40. }
  41. }