defs.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # -*- coding: utf-8 -*-
  2. import re
  3. from .const import Const
  4. class GoodsRecommendStatus(Const):
  5. normal = (False, u'普通')
  6. recommend = (True, u'推荐')
  7. class OrderStatus(Const):
  8. closed = ('closed', u'已关闭')
  9. unpaid = ('unpaid', u'待支付')
  10. pending = ('pending', u'待发货')
  11. unconfirmed = ('unconfirmed', u'待收货')
  12. unevaluated = ('unevaluated', u'待评价')
  13. completed = ('completed', u'已完成')
  14. class OrderRequestStatus(Const):
  15. closed = (-1, 'closed')
  16. unpaid = (0, 'unpaid')
  17. pending = (1, 'pending')
  18. unconfirmed = (2, 'unconfirmed')
  19. unevaluated = (3, 'unevaluated')
  20. completed = (4, 'completed')
  21. class OrderResponseStatus(Const):
  22. closed = ('closed', -1)
  23. unpaid = ('unpaid', 0)
  24. pending = ('pending', 1)
  25. unconfirmed = ('unconfirmed', 2)
  26. unevaluated = ('unevaluated', 3)
  27. completed = ('completed', 4)
  28. class BannerStatus(Const):
  29. visible = (True, u'显示')
  30. invisible = (False, u'不显示')
  31. class WechatUserRegisterType(Const):
  32. app = ('app', u'小程序')
  33. class WechatUserStatus(Const):
  34. default = ('default', u'默认')
  35. class PaymentStatus(Const):
  36. unpaid = ('unpaid', '未支付')
  37. success = ('success', '成功')
  38. fail = ('fail', '失败')
  39. def hump2underline(hunp_str):
  40. '''
  41. 驼峰形式字符串转成下划线形式
  42. :param hunp_str: 驼峰形式字符串
  43. :return: 字母全小写的下划线形式字符串
  44. '''
  45. p = re.compile(r'([a-z]|\d)([A-Z])')
  46. sub = re.sub(p, r'\1_\2', hunp_str).lower()
  47. return sub
  48. def underline2hump(underline_str):
  49. '''
  50. 下划线形式字符串转成驼峰形式
  51. :param underline_str: 下划线形式字符串
  52. :return: 驼峰形式字符串
  53. '''
  54. sub = re.sub(r'(_\w)',lambda x:x.group(1)[1].upper(),underline_str)
  55. return sub