base.py 853 B

123456789101112131415161718192021222324252627282930313233343536
  1. #coding=utf-8
  2. class Formater():
  3. @staticmethod
  4. def formatStr(value):
  5. res = u''
  6. if value != None:
  7. try:
  8. res = str(value)
  9. except:
  10. pass
  11. return res
  12. @staticmethod
  13. def formatCount(value):
  14. return int(round(float(value or 0) * 100,0))
  15. @staticmethod
  16. def formatPrice(value):
  17. return int(round(float(value or 0) * 100,0))
  18. @staticmethod
  19. def formatCountShow(value):
  20. return '%.2f' % (float(value or 0)/100.0)
  21. @staticmethod
  22. def formatPriceShow(value):
  23. return '%.2f' % (float(value or 0)/100.0)
  24. @staticmethod
  25. def formatAmount(value):
  26. return int(round(float(value or 0) * 10000,0))
  27. @staticmethod
  28. def formatAmountShow(value):
  29. return '%.2f' % (float(value or 0) / 10000.0 + 0.0000001)