LogsObject.py 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. from django.shortcuts import HttpResponse
  2. import simplejson as json
  3. class LogsObject(object):
  4. def __init__(self, lang='en'):
  5. self.lang = lang
  6. def data(self, code, res={}):
  7. data_en = {
  8. 0: 'Success',
  9. 5: 'Please try again one minute later!',
  10. 10: res,
  11. 12: 'You are not the primary user of the device!',
  12. 14: 'Device is not belong to you',
  13. 15: 'Device has been bound',
  14. 16: 'WeChat has been bound, please log in and unbind using WeChat',
  15. 17: 'No email or mobile phone login',
  16. 44: 'System error! Can not send email',
  17. 48: 'System object error!',
  18. 89: 'Already send the code, please check it or get it again after 10m',
  19. 90: 'please check code or get it again after 1m',
  20. 99: 'Mail doesn\'t exist!',
  21. 100: 'Phone format error!',
  22. 101: 'Phone already existed!',
  23. 102: 'Phone doesn\'t exist!',
  24. 103: 'Mail already existed!',
  25. 104: 'Account doesn\'t exist!',
  26. 105: 'Email format error!',
  27. 107: 'The username not conform to the rules!',
  28. 109: 'The password not conform to the rules!',
  29. 110: 'user doesn\'t activated',
  30. 111: 'Error password',
  31. 112: 'Fingerprint login is not turned on',
  32. 119: 'The qr code has expired',
  33. 120: 'The code has expired',
  34. 121: 'The verification code is wrong!',
  35. 173: 'Data does not exists!',
  36. 174: 'Data already exists!',
  37. 176: 'Delete error',
  38. 177: 'Update error',
  39. 178: 'ADD error',
  40. 179: 'Nickname repeated',
  41. 201: 'You can only add 3 custom voice at most',
  42. 306: 'The link has expired!',
  43. 309: 'Please ReLogin! errmsg token',
  44. 404: 'You don not have permission to access this!',
  45. 414: 'Please confirm the request url!',
  46. 424: 'Database Error !',
  47. 444: 'Wrong parameters!',
  48. 474: 'System Maintaining!',
  49. 475: 'App Version too low, please upgrade!',
  50. 500: 'Query Database Error:',
  51. 700: 'Upload file error',
  52. 701: 'The file does not exist!',
  53. 711: 'Do not downgrade',
  54. 712: 'Area needs to be consistent',
  55. 713: 'Storage rules cannot be changed during the validity period',
  56. 717: 'Authorization expires',
  57. 800: 'Order does not exist',
  58. 801: 'The refund amount cannot be greater than the order price',
  59. 802: 'The order has been completed and cannot be cancelled',
  60. 804: 'Refund, please do not repeat the operation',
  61. 900: 'There is no information about this version!',
  62. 901: 'Getting URL failure!',
  63. 902: 'No update!',
  64. 903: 'Error filename',
  65. 904: 'Version does not support this feature!',
  66. 906: 'Cause of file operation error',
  67. 907: 'The download file does not exist!',
  68. 908: 'userId cannot be empty',
  69. 10001: 'Customer number, customer confidentiality error',
  70. 10002: 'Check your configuration: no customer number, customer confidentiality',
  71. 10003: 'The authorization code does not exist. Please reauthorize',
  72. 10004: 'The request method is incorrect. Please contact the developer',
  73. 10005: 'Wrong configuration, wrong customer number',
  74. 10006: 'Configuration error. The path value is incorrect',
  75. 10007: 'This device is not an experience package and cannot be reset',
  76. 10008: 'The user does not have this device and cannot transfer',
  77. 10009: 'The user already owns the device and cannot transfer it',
  78. 10010: 'Devices that are not under the same account cannot be transferred',
  79. 10011: 'Receiving transfer device does not exist and cannot be transferred',
  80. 10012: 'Experience packages cannot be transferred',
  81. 10013: 'Original equipment package has expired and cannot be transferred',
  82. 10014: 'Accept transfer of equipment packages that have not expired and cannot be transferred',
  83. 10015: 'Shared devices cannot be transferred',
  84. 10030: 'No purchase of cloud storage',
  85. 10031: 'The cloud storage has expired',
  86. 10032: 'The switched cloud storage package ID cannot be the same as the one in use',
  87. 10033: 'The primary user of the device cannot purchase it',
  88. 10034: 'Non device primary users cannot view cloud storage',
  89. 10035: 'Non device primary users cannot experience cloud storage',
  90. 10036: 'Non device primary users cannot exchange for cloud storage',
  91. 10037: 'Non device primary user cannot transfer device',
  92. 10038: 'Non device primary user cannot transfer packages',
  93. 10039: 'Activation code has been used',
  94. 10040: 'Invalid activation code'
  95. }
  96. data_cn = {
  97. 0: '成功',
  98. 5: '请一分钟后再尝试',
  99. 10: res,
  100. 12: '非设备主用户',
  101. 14: '设备不属于您',
  102. 15: '设备已被绑定',
  103. 16: '微信已被绑定,请使用微信登录并解绑',
  104. 17: '未绑定邮箱或者手机登录方式',
  105. 44: '系统错误!无法发送电子邮件',
  106. 48: '系统对象错误',
  107. 89: '已发验证码,请检测或10分钟后重新获取。',
  108. 90: '请检测或1分钟后重新获取。',
  109. 99: '邮箱不存在!',
  110. 100: '手机格式错误!',
  111. 101: '手机已存在!',
  112. 102: '手机不存在!',
  113. 103: '邮箱已存在!',
  114. 104: '账户不存在!',
  115. 105: '邮箱格式错误!',
  116. 107: '用户名格式不符合!',
  117. 109: '密码格式不符合!',
  118. 110: '用户未激活!',
  119. 111: '密码不正确!',
  120. 112: '未开通指纹登录',
  121. 119: '二维码过期',
  122. 120: '验证码过期',
  123. 121: '验证码错了!',
  124. 173: '数据不存在!',
  125. 174: '数据已存在!',
  126. 176: '删除错误',
  127. 177: '更新错误',
  128. 178: '增加错误',
  129. 179: '名称不能重复',
  130. 201: '最多只能添加3条自定义语音',
  131. 306: '链接已超过有效期!',
  132. 309: '请重新登录!',
  133. 404: '您没有访问的权限!',
  134. 414: '请确认请求url!',
  135. 424: '数据库错误!',
  136. 444: '参数错误!',
  137. 474: '系统维护中!',
  138. 475: '版本过低,请升级程序!',
  139. 500: '查询数据库错误!',
  140. 700: '上传文件错误',
  141. 701: '文件不存在',
  142. 711: '不可降级',
  143. 712: '区域不一致',
  144. 713: '有效期内不可更改存储规则',
  145. 717: '授权过期',
  146. 800: '订单不存在',
  147. 801: '退款金额不能大于订单价格',
  148. 802: '订单已完成,不能撤销',
  149. 804: '订单已退款,请勿重复操作',
  150. 900: '版本信息不存在',
  151. 901: '获取链接失败',
  152. 902: '无更新!',
  153. 903: '文件名不符合!',
  154. 904: '版本不支持本功能!',
  155. 906: '文件操作错误',
  156. 907: '文件不存在!',
  157. 908: '用户id不能为空',
  158. 10001: '客户编号,客户机密错误',
  159. 10002: '检查您的配置:没有客户编号,客户机密',
  160. 10003: '授权码不存在,请重新授权',
  161. 10004: '请求方法不正确。请联系开发者',
  162. 10005: '配置错误,客户编号这个值是错误的',
  163. 10006: '配置错误,路径这个值是错误的',
  164. 10007: '此设备不是体验套餐,无法重置',
  165. 10008: '用户没有此设备,无法转移',
  166. 10009: '用户已拥有此设备,无法转移',
  167. 10010: '不是同一账户下的设备,无法转移',
  168. 10011: '接受转移设备不存在,无法转移',
  169. 10012: '体验套餐无法转移',
  170. 10013: '原设备套餐已过期,无法转移',
  171. 10014: '接受转移设备套餐未过期,无法转移',
  172. 10015: '分享的设备无法转移',
  173. 10030: '未购买云存',
  174. 10031: '云存已过期',
  175. 10032: '切换的云存套餐ID不能与正在使用中的相同',
  176. 10033: '非设备主用户无法购买',
  177. 10034: '非设备主用户无法查看云存',
  178. 10035: '非设备主用户无法体验云存',
  179. 10036: '非设备主用户无法兑换云存',
  180. 10037: '非设备主用户无法转移设备',
  181. 10038: '非设备主用户无法转移套餐',
  182. 10039: '激活码已被使用过',
  183. 10040: '无效激活码'
  184. }
  185. if self.lang == 'cn':
  186. msg = data_cn
  187. elif self.lang == 'zh-Hans':
  188. msg = data_cn
  189. elif self.lang == 'zh-Hant':
  190. msg = data_cn
  191. else:
  192. msg = data_en
  193. try:
  194. message = msg[code]
  195. except Exception as e:
  196. message = '系统错误,code不存在'
  197. print(self.lang == 'cn')
  198. print(msg)
  199. return {'result_code': code, 'reason': message, 'result': res, 'error_code': code}
  200. def formal(self, code, res={}):
  201. formal_data = self.data(code, res)
  202. return json.dumps(formal_data, ensure_ascii=False)
  203. def json(self, code, res={}):
  204. result = self.formal(code, res)
  205. return HttpResponse(result)