ServeManagementController.py 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. import hashlib
  4. import json
  5. import time
  6. import urllib
  7. import uuid
  8. import boto3
  9. import threading
  10. import logging
  11. import xlwt
  12. from boto3.session import Session
  13. from django.http import JsonResponse, HttpResponseRedirect, HttpResponse, StreamingHttpResponse
  14. from django.views.generic.base import View
  15. from Model.models import Device_Info, Role, MenuModel, VodBucketModel, CDKcontextModel, Store_Meal, Order_Model, \
  16. UID_Bucket, ExperienceContextModel, Lang, Device_User, CloudLogModel, UidSetModel, Unused_Uid_Meal
  17. from Object.ResponseObject import ResponseObject
  18. from Object.TokenObject import TokenObject
  19. from Object.UidTokenObject import UidTokenObject
  20. from Service.CommonService import CommonService
  21. from django.db.models import Q, F
  22. from time import strftime
  23. class serveManagement(View):
  24. def get(self, request, *args, **kwargs):
  25. request.encoding = 'utf-8'
  26. operation = kwargs.get('operation')
  27. return self.validation(request.GET, request, operation)
  28. def post(self, request, *args, **kwargs):
  29. request.encoding = 'utf-8'
  30. operation = kwargs.get('operation')
  31. return self.validation(request.POST, request, operation)
  32. def validation(self, request_dict, request, operation):
  33. language = request_dict.get('language', 'en')
  34. response = ResponseObject(language, 'pc')
  35. if operation == 'exportCloudUserList': # 导出云存用户信息
  36. return self.exportCloudUserList(request_dict, response)
  37. elif operation == 'getCloudDataList':
  38. return self.getCloudDataList(request_dict, response)
  39. else:
  40. tko = TokenObject(
  41. request.META.get('HTTP_AUTHORIZATION'),
  42. returntpye='pc')
  43. if tko.code != 0:
  44. return response.json(tko.code)
  45. response.lang = tko.lang
  46. userID = tko.userID
  47. if operation == 'getVodBucketList':
  48. return self.getVodBucketList(userID, request_dict, response)
  49. elif operation == 'addOrEditVodBucket':
  50. return self.addOrEditVodBucket(userID, request_dict, response)
  51. elif operation == 'deleteVodBucket':
  52. return self.deleteVodBucket(userID, request_dict, response)
  53. elif operation == 'getStoreMealList':
  54. return self.getStoreMealList(userID, request_dict, response)
  55. elif operation == 'addOrEditStoreMeal':
  56. return self.addOrEditStoreMeal(userID, request_dict, response)
  57. elif operation == 'deleteStoreMeal':
  58. return self.deleteStoreMeal(userID, request_dict, response)
  59. elif operation == 'getStoreMealLanguage':
  60. return self.getStoreMealLanguage(
  61. userID, request_dict, response)
  62. elif operation == 'addOrEditStoreMealLanguage':
  63. return self.addOrEditStoreMealLanguage(
  64. userID, request_dict, response)
  65. elif operation == 'deleteStoreMealLanguage':
  66. return self.deleteStoreMealLanguage(
  67. userID, request_dict, response)
  68. elif operation == 'getCdkList':
  69. return self.getCdkList(userID, request_dict, response)
  70. elif operation == 'createCdk':
  71. return self.createCdk(request_dict, response)
  72. elif operation == 'deleteCdk':
  73. return self.deleteCdk(request_dict, response)
  74. elif operation == 'downloadCDK':
  75. return self.downloadCDK(request_dict, response)
  76. elif operation == 'getDeviceOrderList':
  77. return self.getDeviceOrderList(request_dict, response)
  78. elif operation == 'deleteDeviceOrder':
  79. return self.deleteDeviceOrder(userID, request_dict, response)
  80. elif operation == 'getDevicePackageList':
  81. return self.getDevicePackageList(request_dict, response)
  82. elif operation == 'deleteDevicePackage':
  83. return self.deleteDevicePackage(userID, request_dict, response)
  84. elif operation == 'experiencereset': # 重置设备云存体验
  85. return self.do_experience_reset(request_dict, userID, response)
  86. elif operation == 'getCloudUserList': # 获取云存用户信息
  87. return self.getCloudUserList(request_dict, response)
  88. else:
  89. return response.json(404)
  90. def getVodBucketList(self, userID, request_dict, response):
  91. # 查询存储桶数据
  92. print('request_dict: ', request_dict)
  93. isSelect = request_dict.get('isSelect', None)
  94. if isSelect:
  95. # 获取全部数据作为存储桶选项
  96. vod_bucket_qs = VodBucketModel.objects.all().values('id', 'bucket')
  97. return response.json(
  98. 0, {'list': CommonService.qs_to_list(vod_bucket_qs)})
  99. bucket = request_dict.get('bucket', None)
  100. mold = request_dict.get('mold', None)
  101. is_free = request_dict.get('is_free', None)
  102. pageNo = request_dict.get('pageNo', None)
  103. pageSize = request_dict.get('pageSize', None)
  104. if not all([pageNo, pageSize]):
  105. return response.json(444)
  106. page = int(pageNo)
  107. line = int(pageSize)
  108. try:
  109. if bucket or mold or is_free: # 条件查询
  110. if bucket:
  111. vod_bucket_qs = VodBucketModel.objects.filter(
  112. bucket=bucket)
  113. elif mold:
  114. vod_bucket_qs = VodBucketModel.objects.filter(
  115. mold=int(mold))
  116. elif is_free:
  117. vod_bucket_qs = VodBucketModel.objects.filter(
  118. is_free=int(is_free))
  119. else: # 查询全部
  120. vod_bucket_qs = VodBucketModel.objects.filter().all()
  121. total = len(vod_bucket_qs)
  122. vod_buckets = vod_bucket_qs[(page - 1) * line:page * line]
  123. vod_bucket_list = []
  124. for vod_bucket in vod_buckets:
  125. vod_bucket_list.append({
  126. 'bucketID': vod_bucket.id,
  127. 'bucket': vod_bucket.bucket,
  128. 'content': vod_bucket.content,
  129. 'mold': vod_bucket.mold,
  130. 'area': vod_bucket.area,
  131. 'region': vod_bucket.region,
  132. 'endpoint': vod_bucket.endpoint,
  133. 'is_free': vod_bucket.is_free,
  134. 'storeDay': vod_bucket.storeDay,
  135. 'region_id': vod_bucket.region_id,
  136. 'addTime': time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(vod_bucket.addTime)),
  137. 'updTime': time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(vod_bucket.updTime)),
  138. })
  139. print('vod_bucket_list: ', vod_bucket_list)
  140. return response.json(
  141. 0, {'list': vod_bucket_list, 'total': total})
  142. except Exception as e:
  143. print(e)
  144. return response.json(500, repr(e))
  145. def addOrEditVodBucket(self, userID, request_dict, response):
  146. # 添加/编辑存储桶
  147. print('request_dict: ', request_dict)
  148. bucketID = request_dict.get('bucketID', None)
  149. bucket = request_dict.get('bucket', '').strip() # 移除字符串头尾的空格
  150. content = request_dict.get('content', '').strip()
  151. mold = int(request_dict.get('mold', 1))
  152. area = request_dict.get('area', '').strip()
  153. region = request_dict.get('region', '').strip()
  154. endpoint = request_dict.get('endpoint', '').strip()
  155. is_free = int(request_dict.get('is_free', 0))
  156. storeDay = int(request_dict.get('storeDay', 0))
  157. region_id = int(request_dict.get('region_id', 1))
  158. isEdit = request_dict.get('isEdit', None)
  159. if not all([bucket, content, area, region, endpoint]):
  160. return response.json(444)
  161. try:
  162. now_time = int(time.time())
  163. vod_bucket_data = {
  164. 'bucket': bucket,
  165. 'content': content,
  166. 'mold': mold,
  167. 'area': area,
  168. 'region': region,
  169. 'endpoint': endpoint,
  170. 'is_free': is_free,
  171. 'storeDay': storeDay,
  172. 'region_id': region_id,
  173. }
  174. if isEdit:
  175. if not bucketID:
  176. return response.json(444)
  177. vod_bucket_data['updTime'] = now_time
  178. VodBucketModel.objects.filter(
  179. id=bucketID).update(
  180. **vod_bucket_data)
  181. else:
  182. vod_bucket_data['addTime'] = now_time
  183. VodBucketModel.objects.create(**vod_bucket_data)
  184. return response.json(0)
  185. except Exception as e:
  186. print(e)
  187. return response.json(500, repr(e))
  188. def deleteVodBucket(self, userID, request_dict, response):
  189. # 删除存储桶
  190. print('request_dict: ', request_dict)
  191. bucketID = request_dict.get('bucketID', None)
  192. if not bucketID:
  193. return response.json(444)
  194. try:
  195. VodBucketModel.objects.filter(id=bucketID).delete()
  196. return response.json(0)
  197. except Exception as e:
  198. print(e)
  199. return response.json(500, repr(e))
  200. def getStoreMealList(self, userID, request_dict, response):
  201. # 获取云存套餐信息数据
  202. print('request_dict: ', request_dict)
  203. isSelect = request_dict.get('isSelect', None)
  204. if isSelect:
  205. # 获取套餐ID作为选项
  206. store_meal_qs = Store_Meal.objects.all().values('id', 'bucket__bucket')
  207. return response.json(
  208. 0, {'list': CommonService.qs_to_list(store_meal_qs)})
  209. bucket = request_dict.get('bucket', None)
  210. pageNo = request_dict.get('pageNo', None)
  211. pageSize = request_dict.get('pageSize', None)
  212. if not all([pageNo, pageSize]):
  213. return response.json(444)
  214. page = int(pageNo)
  215. line = int(pageSize)
  216. try:
  217. if bucket: # 条件查询
  218. bucket_id = VodBucketModel.objects.filter(
  219. bucket=bucket).values('id')[0]['id']
  220. store_meal_qs = Store_Meal.objects.filter(
  221. bucket_id=bucket_id)
  222. else: # 查询全部
  223. store_meal_qs = Store_Meal.objects.filter()
  224. store_meal_val = store_meal_qs.values(
  225. 'id',
  226. 'bucket__bucket',
  227. 'day',
  228. 'expire',
  229. 'commodity_type',
  230. 'commodity_code',
  231. 'is_discounts',
  232. 'discount_price',
  233. 'virtual_price',
  234. 'price',
  235. 'currency',
  236. 'symbol',
  237. 'is_show',
  238. 'add_time',
  239. 'update_time')
  240. total = len(store_meal_val)
  241. store_meals = store_meal_val[(page - 1) * line:page * line]
  242. store_meal_list = []
  243. for store_meal in store_meals:
  244. # 获取支付方式列表
  245. pay_type_list = [
  246. pay_type['id'] for pay_type in Store_Meal.objects.get(
  247. id=store_meal['id']).pay_type.values('id')]
  248. # 组织响应数据
  249. store_meal_list.append({
  250. 'storeMealID': store_meal['id'],
  251. 'bucket': store_meal['bucket__bucket'],
  252. 'day': store_meal['day'],
  253. 'expire': store_meal['expire'],
  254. 'commodity_type': store_meal['commodity_type'],
  255. 'pay_type': pay_type_list,
  256. 'commodity_code': store_meal['commodity_code'],
  257. 'is_discounts': store_meal['is_discounts'],
  258. 'discount_price': store_meal['discount_price'],
  259. 'virtual_price': store_meal['virtual_price'],
  260. 'price': store_meal['price'],
  261. 'currency': store_meal['currency'],
  262. 'symbol': store_meal['symbol'],
  263. 'is_show': store_meal['is_show'],
  264. 'addTime': store_meal['add_time'].strftime("%Y-%m-%d %H:%M:%S"),
  265. 'updTime': store_meal['update_time'].strftime("%Y-%m-%d %H:%M:%S"),
  266. })
  267. print('store_meal_list: ', store_meal_list)
  268. return response.json(
  269. 0, {'list': store_meal_list, 'total': total})
  270. except Exception as e:
  271. print(e)
  272. return response.json(500, repr(e))
  273. def addOrEditStoreMeal(self, userID, request_dict, response):
  274. # 添加/编辑套餐
  275. print('request_dict: ', request_dict)
  276. storeMealID = request_dict.get('storeMealID', None)
  277. bucket = request_dict.get('bucket', '')
  278. day = int(request_dict.get('day', 0))
  279. expire = int(request_dict.get('expire', 0))
  280. commodity_type = int(request_dict.get('commodity_type', 0))
  281. pay_type = request_dict.get(
  282. 'pay_type', '')[
  283. 1:-1].split(',') # '[1,2]' -> ['1','2']
  284. commodity_code = request_dict.get('commodity_code', '')
  285. is_discounts = int(request_dict.get('is_discounts', 0))
  286. discount_price = request_dict.get('discount_price', '')
  287. virtual_price = request_dict.get('virtual_price', '')
  288. price = request_dict.get('price', '')
  289. currency = request_dict.get('currency', '')
  290. symbol = request_dict.get('symbol', '')
  291. is_show = int(request_dict.get('is_show', 0))
  292. isEdit = request_dict.get('isEdit', None)
  293. if not all([bucket, pay_type, price, currency, symbol]):
  294. return response.json(444)
  295. try:
  296. bucket_id = VodBucketModel.objects.filter(
  297. bucket=bucket).values('id')[0]['id']
  298. store_meal_data = {
  299. 'bucket_id': bucket_id,
  300. 'day': day,
  301. 'expire': expire,
  302. 'commodity_type': commodity_type,
  303. 'commodity_code': commodity_code,
  304. 'is_discounts': is_discounts,
  305. 'discount_price': discount_price,
  306. 'virtual_price': virtual_price,
  307. 'price': price,
  308. 'currency': currency,
  309. 'symbol': symbol,
  310. 'is_show': is_show,
  311. }
  312. if isEdit:
  313. if not storeMealID:
  314. return response.json(444)
  315. Store_Meal.objects.filter(
  316. id=storeMealID).update(
  317. **store_meal_data)
  318. Store_Meal.objects.get(id=storeMealID).pay_type.set(pay_type)
  319. else:
  320. Store_Meal.objects.create(
  321. **store_meal_data).pay_type.set(pay_type)
  322. return response.json(0)
  323. except Exception as e:
  324. print(e)
  325. return response.json(500, repr(e))
  326. def deleteStoreMeal(self, userID, request_dict, response):
  327. # 删除套餐信息
  328. print('request_dict: ', request_dict)
  329. storeMealID = request_dict.get('storeMealID', None)
  330. if not storeMealID:
  331. return response.json(444)
  332. try:
  333. Store_Meal.objects.filter(id=storeMealID).delete()
  334. return response.json(0)
  335. except Exception as e:
  336. print(e)
  337. return response.json(500, repr(e))
  338. def getStoreMealLanguage(self, userID, request_dict, response):
  339. # 获取套餐语言
  340. print('request_dict: ', request_dict)
  341. storeMealID = request_dict.get('storeMealID', None)
  342. pageNo = request_dict.get('pageNo', None)
  343. pageSize = request_dict.get('pageSize', None)
  344. if not all([pageNo, pageSize]):
  345. return response.json(444)
  346. page = int(pageNo)
  347. line = int(pageSize)
  348. try:
  349. if storeMealID: # 条件查询
  350. store_meal_lang_qs = Store_Meal.objects.filter(id=storeMealID)
  351. else: # 查询全部
  352. store_meal_lang_qs = Store_Meal.objects.filter(
  353. lang__isnull=False)
  354. store_meal_lang_val = store_meal_lang_qs.values(
  355. 'id',
  356. 'lang__id',
  357. 'lang__lang',
  358. 'lang__title',
  359. 'lang__content',
  360. 'lang__discount_content',
  361. )
  362. total = len(store_meal_lang_val)
  363. store_meal_langs = store_meal_lang_val[(
  364. page - 1) * line:page * line]
  365. store_meal_lang_list = []
  366. for store_meal_lang in store_meal_langs:
  367. store_meal_lang_list.append({
  368. 'storeMealID': store_meal_lang['id'],
  369. 'langID': store_meal_lang['lang__id'],
  370. 'lang': store_meal_lang['lang__lang'],
  371. 'title': store_meal_lang['lang__title'],
  372. 'content': store_meal_lang['lang__content'],
  373. 'discountContent': store_meal_lang['lang__discount_content'],
  374. })
  375. print('store_meal_lang_list: ', store_meal_lang_list)
  376. return response.json(
  377. 0, {'list': store_meal_lang_list, 'total': total})
  378. except Exception as e:
  379. print(e)
  380. return response.json(500, repr(e))
  381. def addOrEditStoreMealLanguage(self, userID, request_dict, response):
  382. # 添加/编辑套餐语言
  383. print('request_dict: ', request_dict)
  384. storeMealID = request_dict.get('storeMealID', None)
  385. lang = request_dict.get('lang', None)
  386. title = request_dict.get('title', None)
  387. content = request_dict.get('content', None)
  388. discount_content = request_dict.get('discount_content', '')
  389. isEdit = request_dict.get('isEdit', None)
  390. if not all([storeMealID, lang, title, content]):
  391. return response.json(444)
  392. try:
  393. # 查询套餐是否存在
  394. store_meal_qs = Store_Meal.objects.get(id=storeMealID)
  395. if not store_meal_qs:
  396. return response.json(173)
  397. if isEdit: # 编辑
  398. langID = request_dict.get('langID', None)
  399. if not langID:
  400. return response.json(444)
  401. Lang.objects.filter(
  402. id=langID).update(
  403. lang=lang,
  404. title=title,
  405. content=content,
  406. discount_content=discount_content)
  407. else: # 添加
  408. lang_obj = Lang.objects.filter(
  409. lang=lang,
  410. title=title,
  411. content=content,
  412. discount_content=discount_content)
  413. if not lang_obj.exists():
  414. # 数据不存在,lang表创建数据
  415. Lang.objects.create(
  416. lang=lang,
  417. title=title,
  418. content=content,
  419. discount_content=discount_content)
  420. lang_obj = Lang.objects.filter(
  421. lang=lang,
  422. title=title,
  423. content=content,
  424. discount_content=discount_content)
  425. store_meal_qs.lang.add(*lang_obj) # store_meal表添加语言数据
  426. return response.json(0)
  427. except Exception as e:
  428. print(e)
  429. return response.json(500, repr(e))
  430. def deleteStoreMealLanguage(self, userID, request_dict, response):
  431. # 删除套餐语言
  432. storeMealID = request_dict.get('storeMealID', None)
  433. langID = request_dict.get('langID', None)
  434. if not all([storeMealID, langID]):
  435. return response.json(444)
  436. try:
  437. storeMeal_qs = Store_Meal.objects.get(id=storeMealID)
  438. if not storeMeal_qs:
  439. return response.json(173)
  440. lang_qs = Lang.objects.filter(id=langID)
  441. storeMeal_qs.lang.remove(*lang_qs)
  442. return response.json(0)
  443. except Exception as e:
  444. print(e)
  445. return response.json(500, repr(e))
  446. def getCdkList(self, userID, request_dict, response):
  447. # 获取激活码列表
  448. pageNo = request_dict.get('pageNo', None)
  449. pageSize = request_dict.get('pageSize', None)
  450. cdk = request_dict.get('cdk', None)
  451. order = request_dict.get('order', None)
  452. is_activate = request_dict.get('is_activate', None)
  453. mold = request_dict.get('mold', None)
  454. lang = request_dict.get('lang', 'cn')
  455. if not all([pageNo, pageSize]):
  456. return response.json(444)
  457. page = int(pageNo)
  458. line = int(pageSize)
  459. try:
  460. if cdk:
  461. searchVal = cdk.strip()
  462. if order:
  463. searchVal = order.strip()
  464. if is_activate:
  465. searchVal = is_activate.strip()
  466. cdk_qs = CDKcontextModel.objects.filter().all()
  467. if cdk:
  468. cdk_qs = cdk_qs.filter(cdk__contains=searchVal)
  469. if order:
  470. cdk_qs = cdk_qs.filter(order__contains=searchVal)
  471. if is_activate:
  472. cdk_qs = cdk_qs.filter(is_activate=searchVal)
  473. if mold:
  474. cdk_qs = cdk_qs.filter(rank__bucket__mold=mold)
  475. cdk_qs = cdk_qs.filter(rank__lang__lang=lang)
  476. cdk_qs = cdk_qs.annotate(rank__title=F('rank__lang__title'))
  477. cdk_qs = cdk_qs.values(
  478. 'id',
  479. 'cdk',
  480. 'create_time',
  481. 'valid_time',
  482. 'is_activate',
  483. 'is_down',
  484. 'rank__id',
  485. 'rank__title',
  486. 'order',
  487. 'create_time',
  488. 'rank__bucket__mold')
  489. cdk_qs = cdk_qs.order_by('-create_time') # 根据CDK创建时间降序排序
  490. count = cdk_qs.count()
  491. cdk_qs = cdk_qs[(page - 1) * line:page * line]
  492. return response.json(
  493. 0, {'list': list(cdk_qs), 'total': count})
  494. except Exception as e:
  495. print(e)
  496. return response.json(500, repr(e))
  497. def createCdk(self, request_dict, response):
  498. cdk_num = request_dict.get("cdknum", None)
  499. mold = request_dict.get('mold', None)
  500. order = request_dict.get('order', None)
  501. cdk_list = []
  502. sm_qs = Store_Meal.objects.filter(
  503. pay_type__payment='cdk_pay', bucket__mold=mold, is_show=0)
  504. if sm_qs.exists:
  505. rank = sm_qs[0].id
  506. for i in range(int(cdk_num)):
  507. nowTime = int(time.time())
  508. cdk = hashlib.md5((str(uuid.uuid1()) +
  509. str(nowTime)).encode('utf-8')).hexdigest()
  510. cdk_model = CDKcontextModel(
  511. cdk=cdk,
  512. create_time=nowTime,
  513. valid_time=0,
  514. is_activate=0,
  515. is_down=0,
  516. rank_id=rank,
  517. order=order,
  518. )
  519. cdk_list.append(cdk_model)
  520. try:
  521. CDKcontextModel.objects.bulk_create(cdk_list)
  522. except Exception as e:
  523. print(repr(e))
  524. return response.json(404, repr(e))
  525. else:
  526. return response.json(0)
  527. return response.json(0)
  528. def deleteCdk(self, request_dict, response):
  529. cdk_id = request_dict.get("id", None)
  530. try:
  531. CDKcontextModel.objects.get(id=cdk_id).delete()
  532. return response.json(0)
  533. except Exception as e:
  534. return response.json(500, repr(e))
  535. def downloadCDK(self, request_dict, response):
  536. region = request_dict.get('region', None)
  537. content = ''
  538. if region == 'cn':
  539. # 下载国内未使用激活码
  540. content += '激活码(国内)\n'
  541. cdk_inactivate_qs = CDKcontextModel.objects.filter(is_down=0, is_activate=0, rank__bucket__mold=0, rank__is_show=0).values('cdk')
  542. else:
  543. # 下载国外未使用激活码
  544. content += '激活码(国外)\n'
  545. cdk_inactivate_qs = CDKcontextModel.objects.filter(is_down=0, is_activate=0, rank__bucket__mold=1, rank__is_show=0).values('cdk')
  546. for cdk_inactivate in cdk_inactivate_qs:
  547. content += cdk_inactivate['cdk'] + '\n'
  548. # print(content)
  549. cdk_inactivate_qs.update(is_down=1)
  550. response = StreamingHttpResponse(content)
  551. response['Content-Type'] = 'application/octet-stream'
  552. response['Content-Disposition'] = 'attachment;filename="CDK.txt"'
  553. return response
  554. def getDeviceOrderList(self, request_dict, response):
  555. print('request_dict: ', request_dict)
  556. pageNo = request_dict.get('pageNo', None)
  557. pageSize = request_dict.get('pageSize', None)
  558. uid = request_dict.get('uid', None)
  559. channel = request_dict.get('channel', None)
  560. orderID = request_dict.get('orderID', None)
  561. userID__username = request_dict.get('userID__username', None)
  562. currency = request_dict.get('currency', None)
  563. payType = request_dict.get('payType', None)
  564. status = request_dict.get('status', None)
  565. timeRange = request_dict.getlist('timeRange[]', None)
  566. if not all([pageNo, pageSize]):
  567. return response.json(444)
  568. page = int(pageNo)
  569. line = int(pageSize)
  570. try:
  571. omqs = Order_Model.objects.all()
  572. # 筛选指定设备id的订单
  573. if uid:
  574. omqs = omqs.filter(UID=uid)
  575. if channel:
  576. omqs = omqs.filter(channel=channel)
  577. if orderID:
  578. omqs = omqs.filter(orderID=orderID)
  579. if userID__username:
  580. omqs = omqs.filter(userID__username=userID__username)
  581. if currency:
  582. omqs = omqs.filter(currency=currency)
  583. if payType:
  584. omqs = omqs.filter(payType=payType)
  585. if status:
  586. omqs = omqs.filter(status=status)
  587. if timeRange:
  588. startTime, endTime = int(
  589. timeRange[0][:-3]), int(timeRange[1][:-3])
  590. omqs = omqs.filter(
  591. addTime__gte=startTime,
  592. addTime__lte=endTime)
  593. if not omqs.exists():
  594. return response.json(0, [])
  595. count = omqs.count()
  596. order_ql = omqs.values(
  597. "orderID",
  598. "UID",
  599. "userID__username",
  600. "userID__NickName",
  601. "channel",
  602. "desc",
  603. "price",
  604. "refunded_amount",
  605. "currency",
  606. "addTime",
  607. "updTime",
  608. "paypal",
  609. "payType",
  610. "rank__day",
  611. "rank__price",
  612. "status")
  613. order_ql = order_ql.order_by('-addTime') # 根据CDK创建时间降序排序
  614. order_ql = order_ql[(page - 1) * line:page * line]
  615. return response.json(
  616. 0, {'list': list(order_ql), 'total': count})
  617. except Exception as e:
  618. print(e)
  619. return response.json(500, repr(e))
  620. def deleteDeviceOrder(self, userID, request_dict, response):
  621. orderID = request_dict.get('orderID', None)
  622. if orderID:
  623. Order_Model.objects.filter(orderID=orderID).delete()
  624. return response.json(0)
  625. else:
  626. return response.json(444)
  627. def getDevicePackageList(self, request_dict, response):
  628. pageNo = request_dict.get('pageNo', None)
  629. pageSize = request_dict.get('pageSize', None)
  630. uid = request_dict.get('uid', None)
  631. if not all([pageNo, pageSize]):
  632. return response.json(444)
  633. page = int(pageNo)
  634. line = int(pageSize)
  635. try:
  636. ubqs = UID_Bucket.objects.all()
  637. if uid:
  638. ubqs = ubqs.filter(uid__contains=uid)
  639. if not ubqs.exists():
  640. return response.json(0, [])
  641. count = ubqs.count()
  642. ubqs = ubqs.values(
  643. 'id',
  644. 'uid',
  645. 'channel',
  646. 'status',
  647. 'endTime',
  648. 'bucket__bucket',
  649. 'bucket__storeDay',
  650. 'bucket__area')
  651. ubqs = ubqs.order_by('-addTime') # 根据CDK创建时间降序排序
  652. ubqs = ubqs[(page - 1) * line:page * line]
  653. return response.json(
  654. 0, {'list': list(ubqs), 'total': count})
  655. except Exception as e:
  656. print(e)
  657. return response.json(500, repr(e))
  658. def deleteDevicePackage(self, userID, request_dict, response):
  659. orderID = request_dict.get('orderID', None)
  660. if orderID:
  661. Order_Model.objects.filter(orderID=orderID).delete()
  662. return response.json(0)
  663. else:
  664. return response.json(444)
  665. # 重置设备云存体验
  666. def do_experience_reset(self, request_dict, userID, response):
  667. bid = request_dict.get("id", None)
  668. ubq = UID_Bucket.objects.filter(id=bid)
  669. if ubq:
  670. eq = ExperienceContextModel.objects.filter(uid=ubq[0].uid)
  671. if eq:
  672. eq.delete()
  673. Order_Model.objects.filter(uid_bucket_id=bid).delete()
  674. ubq.delete()
  675. return response.json(0)
  676. else:
  677. return response.json(10007)
  678. else:
  679. return response.json(0, '重置云存体验失败')
  680. def getCloudUserList(self, request_dict, response):
  681. print('request_dict: ', request_dict)
  682. # UID_Bucket表查询数据
  683. uid = request_dict.get('uid', None)
  684. status = request_dict.get('status', None)
  685. use_status = request_dict.get('use_status', None)
  686. has_unused = request_dict.get('has_unused', None)
  687. addTimeRange = request_dict.getlist('addTimeRange[]', None)
  688. endTimeRange = request_dict.getlist('endTimeRange[]', None)
  689. # Order_Model表查询数据
  690. username = request_dict.get('username', None)
  691. phone = request_dict.get('phone', None)
  692. userEmail = request_dict.get('userEmail', None)
  693. payType = request_dict.get('payType', None)
  694. # uid_set 表查询
  695. ucode = request_dict.getlist('ucode', None)
  696. version = request_dict.getlist('version', None)
  697. # 日志表查询
  698. logTimeRange = request_dict.getlist('logTimeRange[]', None)
  699. pageNo = request_dict.get('pageNo', None)
  700. pageSize = request_dict.get('pageSize', None)
  701. if not all([pageNo, pageSize]):
  702. return response.json(444)
  703. page = int(pageNo)
  704. line = int(pageSize)
  705. try:
  706. uid_bucket_qs = UID_Bucket.objects.all()
  707. if uid:
  708. uid_bucket_qs = uid_bucket_qs.filter(uid__icontains=uid)
  709. if status:
  710. uid_bucket_qs = uid_bucket_qs.filter(status=status)
  711. if use_status:
  712. uid_bucket_qs = uid_bucket_qs.filter(use_status=use_status)
  713. if has_unused:
  714. uid_bucket_qs = uid_bucket_qs.filter(has_unused=has_unused)
  715. if addTimeRange:
  716. addStartTime, addEndTime = int(
  717. addTimeRange[0][:-3]), int(addTimeRange[1][:-3])
  718. uid_bucket_qs = uid_bucket_qs.filter(
  719. addTime__gte=addStartTime,
  720. addTime__lte=addEndTime)
  721. if endTimeRange:
  722. endStartTime, endEndTime = int(
  723. endTimeRange[0][:-3]), int(endTimeRange[1][:-3])
  724. uid_bucket_qs = uid_bucket_qs.filter(
  725. addTime__gte=endStartTime,
  726. addTime__lte=endEndTime)
  727. uid_list = []
  728. uid_set_dict = {}
  729. if ucode and ucode != ['']:
  730. uid_set_qs = UidSetModel.objects.filter(ucode__in=ucode).values('uid', 'ucode', 'version').distinct()
  731. for uid_set in uid_set_qs:
  732. uid_list.append(uid_set['uid'])
  733. uid_set_dict[uid_set['uid']] = {
  734. 'ucode': uid_set['ucode'],
  735. 'version': uid_set['version']
  736. }
  737. uid_bucket_qs = uid_bucket_qs.filter(uid__in=uid_list)
  738. else:
  739. uid_set_qs = UidSetModel.objects.filter().values('uid', 'ucode', 'version').distinct()
  740. for uid_set in uid_set_qs:
  741. uid_list.append(uid_set['uid'])
  742. uid_set_dict[uid_set['uid']] = {
  743. 'ucode': uid_set['ucode'],
  744. 'version': uid_set['version']
  745. }
  746. if not uid_bucket_qs.exists():
  747. return response.json(0, [])
  748. order_qs = Order_Model.objects.filter(uid_bucket_id__in=uid_bucket_qs.values('id'))
  749. if username or phone or userEmail or payType:
  750. if username:
  751. order_qs = order_qs.filter(userID__username=username)
  752. if phone:
  753. order_qs = order_qs.filter(userID__phone__contains=phone)
  754. if userEmail:
  755. order_qs = order_qs.filter(
  756. userID__userEmail__contains=userEmail)
  757. if payType:
  758. order_qs = order_qs.filter(payType=int(payType))
  759. # 过滤套餐关联的UID_Bucket数据
  760. uid_bucket_qs = uid_bucket_qs.filter(
  761. id__in=order_qs.values_list(
  762. 'uid_bucket_id', flat=True))
  763. cg_qs = CloudLogModel.objects.filter(
  764. operation='cloudstorage/queryvodlist')
  765. if logTimeRange:
  766. logStartTime, logEndTime = int(
  767. logTimeRange[0][:-3]), int(logTimeRange[1][:-3])
  768. cg_qs = cg_qs.filter(
  769. time__gte=logStartTime,
  770. time__lte=logEndTime)
  771. # 过滤套餐关联的UID_Bucket数据
  772. uid_bucket_qs = uid_bucket_qs.filter(
  773. uid__in=cg_qs.values('uid'))
  774. list_data = []
  775. count = uid_bucket_qs.count()
  776. uid_bucket_qs = uid_bucket_qs.order_by('-addTime')[(page - 1) * line:page * line]
  777. for uid_bucket in uid_bucket_qs:
  778. # 套餐到期时间累加未使用套餐
  779. unused_qs = Unused_Uid_Meal.objects.filter(uid=uid_bucket.uid).values('num', 'expire')
  780. if unused_qs.exists():
  781. addMonth = 0
  782. for unused in unused_qs:
  783. addMonth += unused['num'] * unused['expire']
  784. endTime = CommonService.calcMonthLater(addMonth, uid_bucket.endTime)
  785. endTime = time.strftime("%Y--%m--%d %H:%M:%S", time.localtime(endTime))
  786. else:
  787. endTime = time.strftime("%Y--%m--%d %H:%M:%S", time.localtime(uid_bucket.endTime))
  788. uid = uid_bucket.uid.upper()
  789. data = {
  790. 'id': uid_bucket.id,
  791. 'uid': uid,
  792. 'channel': uid_bucket.channel,
  793. 'status': uid_bucket.status,
  794. 'endTime': endTime,
  795. 'addTime': time.strftime(
  796. "%Y--%m--%d %H:%M:%S",
  797. time.localtime(
  798. uid_bucket.addTime)),
  799. 'use_status': uid_bucket.use_status,
  800. 'has_unused': uid_bucket.has_unused}
  801. for order in order_qs.filter(
  802. uid_bucket_id=uid_bucket.id).values(
  803. 'uid_bucket_id',
  804. 'desc',
  805. 'userID__userID',
  806. 'UID',
  807. 'price',
  808. 'payType',
  809. 'userID__username',
  810. 'userID__phone',
  811. 'userID__userEmail',
  812. 'userID__data_joined'):
  813. data['desc'] = order['desc']
  814. data['payType'] = order['payType']
  815. data['price'] = order['price']
  816. data['username'] = order['userID__username']
  817. data['phone'] = order['userID__phone']
  818. data['userEmail'] = order['userID__userEmail']
  819. data['data_joined'] = order['userID__data_joined'].strftime(
  820. "%Y-%m-%d %H:%M:%S")
  821. data['playcount'] = cg_qs.filter(
  822. operation='cloudstorage/queryvodlist', uid=order['UID']).count()
  823. data['ucode'] = uid_set_dict[uid]['ucode']
  824. data['version'] = uid_set_dict[uid]['version']
  825. list_data.append(data)
  826. return response.json(
  827. 0, {'list': list_data, 'total': count})
  828. except Exception as e:
  829. print(e)
  830. return response.json(500, repr(e))
  831. def exportCloudUserList(self, request_dict, response):
  832. # UID_Bucket表查询数据
  833. uid = request_dict.get('uid', None)
  834. status = request_dict.get('status', None)
  835. use_status = request_dict.get('use_status', None)
  836. has_unused = request_dict.get('has_unused', None)
  837. addTimeRange = request_dict.getlist('addTimeRange[]', None)
  838. endTimeRange = request_dict.getlist('endTimeRange[]', None)
  839. # Order_Model表查询数据
  840. username = request_dict.get('username', None)
  841. phone = request_dict.get('phone', None)
  842. userEmail = request_dict.get('userEmail', None)
  843. payType = request_dict.get('payType', None)
  844. #uid_set 表查询
  845. ucode = request_dict.getlist('ucode', None)
  846. version = request_dict.getlist('version', None)
  847. # 日志表查询
  848. logTimeRange = request_dict.getlist('logTimeRange[]', None)
  849. pageNo = request_dict.get('pageNo', None)
  850. pageSize = request_dict.get('pageSize', None)
  851. if not all([pageNo, pageSize]):
  852. return response.json(444)
  853. page = int(pageNo)
  854. line = int(pageSize)
  855. try:
  856. uid_bucket_qs = UID_Bucket.objects.all()
  857. if uid:
  858. uid_bucket_qs = uid_bucket_qs.filter(uid__contains=uid)
  859. if status:
  860. uid_bucket_qs = uid_bucket_qs.filter(status=status)
  861. if use_status:
  862. uid_bucket_qs = uid_bucket_qs.filter(use_status=use_status)
  863. if has_unused:
  864. uid_bucket_qs = uid_bucket_qs.filter(has_unused=has_unused)
  865. if addTimeRange:
  866. addStartTime, addEndTime = int(
  867. addTimeRange[0][:-3]), int(addTimeRange[1][:-3])
  868. uid_bucket_qs = uid_bucket_qs.filter(
  869. addTime__gte=addStartTime,
  870. addTime__lte=addEndTime)
  871. if endTimeRange:
  872. endStartTime, endEndTime = int(
  873. endTimeRange[0][:-3]), int(endTimeRange[1][:-3])
  874. uid_bucket_qs = uid_bucket_qs.filter(
  875. addTime__gte=endStartTime,
  876. addTime__lte=endEndTime)
  877. if not uid_bucket_qs.exists():
  878. return response.json(0, [])
  879. order_qs = Order_Model.objects.filter(
  880. uid_bucket_id__in=uid_bucket_qs.values('id'))
  881. if username or phone or userEmail or payType:
  882. if username:
  883. order_qs = order_qs.filter(userID__username=username)
  884. if phone:
  885. order_qs = order_qs.filter(userID__phone__contains=phone)
  886. if userEmail:
  887. order_qs = order_qs.filter(
  888. userID__userEmail__contains=userEmail)
  889. if payType:
  890. order_qs = order_qs.filter(payType=int(payType))
  891. # 过滤套餐关联的UID_Bucket数据
  892. uid_bucket_qs = uid_bucket_qs.filter(
  893. id__in=order_qs.values_list(
  894. 'uid_bucket_id', flat=True))
  895. uidset_qs = UidSetModel.objects.filter(
  896. uid__in=uid_bucket_qs.values('uid'))
  897. if ucode or version:
  898. if ucode:
  899. uidset_qs = uidset_qs.filter(ucode=ucode)
  900. if version:
  901. uidset_qs = uidset_qs.filter(version=version)
  902. cg_qs = CloudLogModel.objects.filter(
  903. operation='cloudstorage/queryvodlist')
  904. if logTimeRange:
  905. logStartTime, logEndTime = int(
  906. logTimeRange[0][:-3]), int(logTimeRange[1][:-3])
  907. cg_qs = cg_qs.filter(
  908. time__gte=logStartTime,
  909. time__lte=logEndTime)
  910. list_data = []
  911. count = uid_bucket_qs.count()
  912. uid_bucket_qs = uid_bucket_qs.order_by('-addTime')[(page - 1) * line:page * line]
  913. for uid_bucket in uid_bucket_qs:
  914. data = {
  915. 'id': uid_bucket.id,
  916. 'uid': uid_bucket.uid,
  917. 'channel': uid_bucket.channel,
  918. 'status': uid_bucket.status,
  919. 'endTime': time.strftime(
  920. "%Y--%m--%d %H:%M:%S",
  921. time.localtime(
  922. uid_bucket.endTime)),
  923. 'addTime': time.strftime(
  924. "%Y--%m--%d %H:%M:%S",
  925. time.localtime(
  926. uid_bucket.addTime)),
  927. 'use_status': uid_bucket.use_status,
  928. 'has_unused': uid_bucket.has_unused}
  929. for order in order_qs.filter(
  930. uid_bucket_id=uid_bucket.id).values(
  931. 'uid_bucket_id',
  932. 'desc',
  933. 'userID__userID',
  934. 'UID',
  935. 'price',
  936. 'payType',
  937. 'userID__username',
  938. 'userID__phone',
  939. 'userID__userEmail',
  940. 'userID__data_joined'):
  941. data['desc'] = order['desc']
  942. data['payType'] = order['payType']
  943. data['price'] = order['price']
  944. data['username'] = order['userID__username']
  945. data['phone'] = order['userID__phone']
  946. data['userEmail'] = order['userID__userEmail']
  947. data['data_joined'] = order['userID__data_joined'].strftime(
  948. "%Y-%m-%d %H:%M:%S")
  949. data['playcount'] = cg_qs.filter(
  950. operation='cloudstorage/queryvodlist', uid=order['UID']).count()
  951. for uidset in uidset_qs.filter(
  952. uid=uid_bucket.uid).values(
  953. 'ucode',
  954. 'version'):
  955. data['ucode'] = uidset['ucode']
  956. data['version'] = uidset['version']
  957. list_data.append(data)
  958. response = HttpResponse(content_type='application/vnd.ms-excel')
  959. response['Content-Disposition'] = 'attachment; filename=userinfo.xls'
  960. workbook = xlwt.Workbook(encoding='utf-8')
  961. sheet1 = workbook.add_sheet('UID')
  962. headtitle = [
  963. 'id',
  964. '用户账号',
  965. '用户手机号',
  966. '用户邮箱',
  967. '注册时间',
  968. '设备UID',
  969. '设备通道',
  970. '云存状态',
  971. '添加时间',
  972. '到期时间',
  973. '使用状态',
  974. '是否有未使用套餐',
  975. '套餐描述',
  976. '支付方式',
  977. '价格',
  978. '播放次数',
  979. '产品编码',
  980. '版本'
  981. ]
  982. headnum = 0
  983. for title in headtitle:
  984. sheet1.write(0, headnum, title)
  985. headnum= headnum+1
  986. fields = [
  987. 'id',
  988. 'username',
  989. 'phone',
  990. 'userEmail',
  991. 'data_joined',
  992. 'uid',
  993. 'channel',
  994. 'status',
  995. 'addTime',
  996. 'endTime',
  997. 'use_status',
  998. 'has_unused',
  999. 'desc',
  1000. 'payType',
  1001. 'price',
  1002. 'playcount',
  1003. 'ucode',
  1004. 'version'
  1005. ]
  1006. num = 1
  1007. for item in list_data:
  1008. fieldnum = 0
  1009. for key in fields:
  1010. val = item[key]
  1011. if key == 'payType':
  1012. if val == 1:
  1013. val = 'PayPal'
  1014. if val == 2:
  1015. val = '支付宝'
  1016. if val == 3:
  1017. val = '微信支付'
  1018. if val == 10:
  1019. val = '免费体验'
  1020. if val == 11:
  1021. val = '激活码'
  1022. sheet1.write(num, fieldnum, val)
  1023. fieldnum = fieldnum+1
  1024. num =num+1
  1025. workbook.save(response)
  1026. return response
  1027. except Exception as e:
  1028. print(e)
  1029. return response.json(500, repr(e))
  1030. def getCloudDataList(self, request_dict, response):
  1031. year = request_dict.get('year', None)
  1032. Jan = int(time.mktime(time.strptime(year + '-1-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
  1033. Feb = int(time.mktime(time.strptime(year + '-2-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
  1034. Mar = int(time.mktime(time.strptime(year + '-3-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
  1035. Apr = int(time.mktime(time.strptime(year + '-4-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
  1036. May = int(time.mktime(time.strptime(year + '-5-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
  1037. Jun = int(time.mktime(time.strptime(year + '-6-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
  1038. Jul = int(time.mktime(time.strptime(year + '-7-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
  1039. Aug = int(time.mktime(time.strptime(year + '-8-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
  1040. Sep = int(time.mktime(time.strptime(year + '-9-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
  1041. Oct = int(time.mktime(time.strptime(year + '-10-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
  1042. Nov = int(time.mktime(time.strptime(year + '-11-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
  1043. Dec = int(time.mktime(time.strptime(year + '-12-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
  1044. Jan_next = int(time.mktime(time.strptime(str(int(year)+1) + '-1-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
  1045. list_data = []
  1046. vod_bucket_qs = VodBucketModel.objects.filter()
  1047. if not vod_bucket_qs.exists():
  1048. return response.json(173)
  1049. try:
  1050. for vod_bucket in vod_bucket_qs:
  1051. vod_bucket_id = vod_bucket.id
  1052. store_meal = Store_Meal.objects.filter(bucket_id=vod_bucket_id, lang__lang='cn').values('lang__title', 'lang__content')
  1053. if not store_meal.exists():
  1054. continue
  1055. name = store_meal[0]['lang__title']+'-'+store_meal[0]['lang__content']
  1056. order = Order_Model.objects.filter(rank__bucket_id=vod_bucket_id)
  1057. Jan_count = order.filter(status=1, addTime__range=[Jan, Feb]).count()
  1058. Feb_count = order.filter(status=1, addTime__range=[Feb, Mar]).count()
  1059. Mar_count = order.filter(status=1, addTime__range=[Mar, Apr]).count()
  1060. Apr_count = order.filter(status=1, addTime__range=[Apr, May]).count()
  1061. May_count = order.filter(status=1, addTime__range=[May, Jun]).count()
  1062. Jun_count = order.filter(status=1, addTime__range=[Jun, Jul]).count()
  1063. Jul_count = order.filter(status=1, addTime__range=[Jul, Aug]).count()
  1064. Aug_count = order.filter(status=1, addTime__range=[Aug, Sep]).count()
  1065. Sep_count = order.filter(status=1, addTime__range=[Sep, Oct]).count()
  1066. Oct_count = order.filter(status=1, addTime__range=[Oct, Nov]).count()
  1067. Nov_count = order.filter(status=1, addTime__range=[Nov, Dec]).count()
  1068. Dec_count = order.filter(status=1, addTime__range=[Dec, Jan_next]).count()
  1069. data = [Jan_count, Feb_count, Mar_count, Apr_count, May_count, Jun_count, Jul_count, Aug_count, Sep_count,
  1070. Oct_count, Nov_count, Dec_count]
  1071. cloud_data = {
  1072. 'name': name,
  1073. 'type': 'line',
  1074. 'data': data,
  1075. }
  1076. list_data.append(cloud_data)
  1077. return response.json(0, {'list': list_data})
  1078. except Exception as e:
  1079. print(e)
  1080. return response.json(500, repr(e))