decimal_facade.js 889 B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * Created by zhang on 2017/11/22.
  3. */
  4. let projectsModel = require("../../pm/models/project_schema");
  5. let _ = require('lodash');
  6. module.exports ={
  7. getProjectDecimal:getProjectDecimal,
  8. getBillsQuantityDecimal:getBillsQuantityDecimal
  9. }
  10. async function getProjectDecimal(projectID) {
  11. let decimal = null;
  12. let project =await projectsModel.findOne({ID:projectID});
  13. if(project){
  14. decimal = project.property.decimal
  15. }
  16. return decimal;
  17. }
  18. async function getBillsQuantityDecimal(projectID,unit) {
  19. let decimal = null;
  20. let project =await projectsModel.findOne({ID:projectID});
  21. if(project){
  22. let billsQuantityDecimal = project.property.billsQuantityDecimal;
  23. let el = _.find(billsQuantityDecimal,{'unit':unit});
  24. if(!el){
  25. el = billsQuantityDecimal[0];
  26. }
  27. decimal = el.decimal
  28. }
  29. return decimal;
  30. }