CampaignController.py 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. import time
  2. import json
  3. from Model.models import AppAdvertiseCampaign, DeviceTypeModel, CountryModel, OpenScreenCampaign
  4. from Ansjer.config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, SERVER_TYPE, LOGGER
  5. from django.core.paginator import Paginator
  6. from django.views import View
  7. from django.db.models import Prefetch
  8. from django.db.models import Q, F
  9. from Object.AWS.AmazonS3Util import AmazonS3Util
  10. from Object.ResponseObject import ResponseObject
  11. from Object.TokenObject import TokenObject
  12. class CampaignView(View):
  13. def get(self, request, *args, **kwargs):
  14. request.encoding = 'utf-8'
  15. operation = kwargs.get('operation')
  16. request_dict = request.GET
  17. return self.validation(request_dict, request, operation)
  18. def post(self, request, *args, **kwargs):
  19. request.encoding = 'utf-8'
  20. operation = kwargs.get('operation')
  21. request_dict = request.POST
  22. return self.validation(request_dict, request, operation)
  23. def validation(self, request_dict, request, operation):
  24. language = request_dict.get('language', 'en')
  25. response = ResponseObject(language, 'pc')
  26. if operation == 'getCountryList':
  27. return self.get_country_list(response)
  28. else:
  29. tko = TokenObject(
  30. request.META.get('HTTP_AUTHORIZATION'),
  31. returntpye='pc')
  32. if tko.code != 0:
  33. return response.json(tko.code)
  34. response.lang = tko.lang
  35. if operation == 'getCampaignList': # 获取广告活动列表
  36. return self.get_campaign_list(request_dict, response)
  37. elif operation == 'addCampaign': # 添加广告活动
  38. return self.add_campaign(request, request_dict, response)
  39. elif operation == 'updateCampaign': # 更新广告活动
  40. return self.update_campaign(request, request_dict, response)
  41. elif operation == 'deleteCampaign': # 删除广告活动
  42. return self.delete_campaign(request_dict, response)
  43. elif operation == 'switchCampaign': # 广告活动开关
  44. return self.switch_campaign(request_dict, response)
  45. elif operation == 'getUserBehaviorLog': # 获取用户行为日志
  46. return self.get_user_behavior_log(request_dict, response)
  47. else:
  48. return response.json(414)
  49. def get_campaign_list(self, request_dict, response):
  50. """
  51. 查询广告活动列表
  52. @param request_dict: 请求参数
  53. @param response: 响应对象
  54. @return: 响应对象包含广告活动列表
  55. """
  56. campaign_name = request_dict.get('campaign_name', None)
  57. campaign_country = request_dict.get('campaign_country', None)
  58. status = request_dict.get('status', None)
  59. pageNo = request_dict.get('pageNo', 1)
  60. pageSize = request_dict.get('pageSize', 20)
  61. unknown_country = 0
  62. try:
  63. # 连接并获取国家和设备类型
  64. country_prefetch = Prefetch('country', queryset=CountryModel.objects.only('country_name'),
  65. to_attr='country_list')
  66. device_type_prefetch = Prefetch('device_type', queryset=DeviceTypeModel.objects.only('name'),
  67. to_attr='device_type_list')
  68. app_advertise_campaign_qs = AppAdvertiseCampaign.objects.prefetch_related(country_prefetch,
  69. device_type_prefetch)
  70. # 过滤
  71. if campaign_name:
  72. app_advertise_campaign_qs = app_advertise_campaign_qs.filter(campaign_name=campaign_name)
  73. if status:
  74. app_advertise_campaign_qs = app_advertise_campaign_qs.filter(status=status)
  75. if campaign_country:
  76. campaign_country_list = campaign_country.split(',')
  77. if "未知地区" in campaign_country_list:
  78. unknown_country = 1
  79. app_advertise_campaign_qs = app_advertise_campaign_qs.filter(
  80. Q(country__country_name__in=campaign_country_list) | Q(unknown_country=unknown_country)).distinct()
  81. app_advertise_campaign_qs = app_advertise_campaign_qs.filter(~Q(status=2))
  82. # 分页
  83. paginator = Paginator(app_advertise_campaign_qs.order_by('id'), pageSize)
  84. campaigns = paginator.page(pageNo)
  85. # 添加设备名和地区返回
  86. campaign_list = []
  87. for campaign in campaigns.object_list:
  88. if campaign.unknown_country == 0:
  89. countries = ",".join([country.country_name for country in campaign.country_list])
  90. else:
  91. country_list = campaign.country_list
  92. country_names = []
  93. for country in country_list:
  94. country_names.append(country.country_name)
  95. country_names.append("未知地区")
  96. countries = ",".join(country_names)
  97. s3_url, _, _ = self.s3_server()
  98. # 轮播图处理
  99. banner_campaign_list = campaign.banner_campaign
  100. for banner_campaign in banner_campaign_list:
  101. banner_campaign["image"] = s3_url + banner_campaign["image"]
  102. banner_campaign_dict = {str(index): banner_campaign_list for index, banner_campaign_list in
  103. enumerate(banner_campaign_list, start=1)}
  104. campaign_data = {
  105. 'id': campaign.id,
  106. 'image_url': s3_url + campaign.image_url,
  107. 'banner_campaign': banner_campaign_dict,
  108. 'campaign_name': campaign.campaign_name,
  109. 'campaign_url': campaign.campaign_url,
  110. 'campaign_type': campaign.campaign_type,
  111. 'status': campaign.status,
  112. 'campaign_start_date': campaign.campaign_start_date,
  113. 'campaign_end_date': campaign.campaign_end_date,
  114. 'campaign_show_stime': campaign.campaign_show_stime,
  115. 'campaign_show_etime': campaign.campaign_show_etime,
  116. 'app_bundle_type': campaign.app_bundle_type,
  117. 'countries': countries,
  118. 'device_types': ",".join([device.name for device in campaign.device_type_list]),
  119. }
  120. if campaign.image_url == "":
  121. del campaign_data['image_url']
  122. del campaign_data['campaign_url']
  123. campaign_list.append(campaign_data)
  124. data = {
  125. 'list': campaign_list,
  126. 'total': paginator.count,
  127. }
  128. return response.json(0, data)
  129. except Exception as e:
  130. print(e)
  131. return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
  132. def add_campaign(self, request, request_dict, response):
  133. """
  134. 添加新的广告活动
  135. @param request: 包含文件信息
  136. @param request_dict: 包含所有请求参数的字典
  137. @param response: 响应对象
  138. @return: 响应对象
  139. """
  140. try:
  141. campaign_name = request_dict.get('campaign_name', None)
  142. campaign_url = request_dict.get('campaign_url', "")
  143. status = request_dict.get('status', 2)
  144. campaign_start_time = request_dict.get('campaign_start_time', None)
  145. campaign_end_time = request_dict.get('campaign_end_time', None)
  146. campaign_show_stime = request_dict.get('campaign_show_stime', 0)
  147. campaign_show_etime = request_dict.get('campaign_show_etime', 86399)
  148. app_bundle_type = request_dict.get('app_bundle_type', None)
  149. poster_file = request.FILES.get('posterFile', None)
  150. banner_files = request.FILES.getlist('bannerFiles', None)
  151. banner_campaign_urls = json.loads(request_dict.get('banner_campaign_url', "[]"))
  152. device_type_names = json.loads(request_dict.get('device_type_list', "[]")) # 设备类型名称列表
  153. country_name_list = json.loads(request_dict.get('country_name_list', "[]")) # 地区列表
  154. required_fields = [campaign_name, campaign_start_time, campaign_end_time,
  155. app_bundle_type]
  156. list_fields = [device_type_names, country_name_list]
  157. # 检查基本字段是否为None
  158. if any(field is None for field in required_fields):
  159. return response.json(444)
  160. # 检查列表类型的字段是否为空
  161. if any(not field for field in list_fields):
  162. return response.json(444)
  163. # 确保至少提供了一个文件
  164. if not poster_file and not banner_files:
  165. return response.json(444)
  166. # 针对特殊地区的处理,表没设计好用这个处理挽救一下
  167. unknown_country = 0
  168. if "未知地区" in country_name_list:
  169. unknown_country = 1
  170. country_name_list.remove("未知地区")
  171. # 上传文件到S3
  172. banner_image_urls = self.upload_files_to_s3(banner_files,
  173. "BannerAdvertise") if banner_files is not None else []
  174. poster_image_url = self.upload_files_to_s3(poster_file,
  175. "OpenScreenAdvertise")[0] if poster_file is not None else ""
  176. campaign_type = []
  177. if poster_image_url != "":
  178. campaign_type.append(1)
  179. if banner_image_urls:
  180. campaign_type.append(2)
  181. banner_campaign = [{"image": image_url, "url": campaign_url}
  182. for image_url, campaign_url in zip(banner_image_urls, banner_campaign_urls)]
  183. else:
  184. banner_campaign = []
  185. create_time = int(time.time())
  186. update_time = int(time.time())
  187. # 创建 AppAdvertiseCampaign 实例
  188. new_campaign = AppAdvertiseCampaign.objects.create(
  189. image_url=poster_image_url,
  190. campaign_name=campaign_name,
  191. campaign_url=campaign_url,
  192. banner_campaign=banner_campaign,
  193. campaign_type=campaign_type,
  194. status=status,
  195. unknown_country=unknown_country,
  196. app_bundle_type=app_bundle_type,
  197. campaign_start_date=campaign_start_time,
  198. campaign_end_date=campaign_end_time,
  199. campaign_show_stime=campaign_show_stime,
  200. campaign_show_etime=campaign_show_etime,
  201. create_time=create_time,
  202. update_time=update_time,
  203. )
  204. # 根据名称查找 DeviceTypeModel 的实例并建立关系
  205. device_type_instances = DeviceTypeModel.objects.filter(name__in=device_type_names)
  206. for device_type_instance in device_type_instances:
  207. new_campaign.device_type.add(device_type_instance)
  208. # 根据 ID 关联 CountryModel 实例
  209. country_instances = CountryModel.objects.filter(country_name__in=country_name_list)
  210. for country_instance in country_instances:
  211. new_campaign.country.add(country_instance)
  212. return response.json(0)
  213. except Exception as e:
  214. print(e)
  215. return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
  216. def update_campaign(self, request, request_dict, response):
  217. """
  218. 更新广告活动
  219. @param request: 包含文件信息
  220. @param request_dict: 包含所有请求参数的字典
  221. @param response: 响应对象
  222. @return: 响应对象
  223. """
  224. try:
  225. campaign_id = request_dict.get('id', None)
  226. campaign_name = request_dict.get('campaign_name', None)
  227. campaign_url = request_dict.get('campaign_url', None)
  228. campaign_start_time = request_dict.get('campaign_start_time', None)
  229. campaign_end_time = request_dict.get('campaign_end_time', None)
  230. campaign_show_stime = request_dict.get('campaign_show_stime', None)
  231. campaign_show_etime = request_dict.get('campaign_show_etime', None)
  232. app_bundle_type = request_dict.get('app_bundle_type', None)
  233. device_type_names = json.loads(request_dict.get('device_type_list', "[]")) # 设备类型名称列表
  234. country_name_list = json.loads(request_dict.get('country_name_list', "[]")) # 地区列表
  235. poster_file = request.FILES.get('posterFile', None)
  236. # 更改轮播图广告图片
  237. sort_files = json.loads(request_dict.get('sort_files', "[]"))
  238. banner_files = request.FILES.getlist('bannerFiles', None)
  239. # 更改轮播图链接
  240. sort_urls = json.loads(request_dict.get('sort_url', "[]"))
  241. banner_urls = json.loads(request_dict.get('banner_urls', "[]"))
  242. # 删除轮播图广告
  243. sort_banner_del = json.loads(request_dict.get('sort_banner_del', "[]"))
  244. poster_del = request_dict.get('poster_del', None)
  245. if not campaign_id:
  246. return response.json(444)
  247. update_time = int(time.time())
  248. campaign = AppAdvertiseCampaign.objects.filter(pk=campaign_id).first()
  249. # 未知地区特殊处理
  250. if country_name_list is not None:
  251. if "未知地区" in country_name_list:
  252. campaign.unknown_country = 1
  253. country_name_list.remove("未知地区")
  254. else:
  255. campaign.unknown_country = 0
  256. # 开屏广告图片
  257. if poster_file is not None:
  258. self.del_file_to_s3(campaign.image_url)
  259. poster_image_url = self.upload_files_to_s3(poster_file,
  260. "OpenScreenAdvertise")[0]
  261. campaign.image_url = poster_image_url
  262. if 1 not in campaign.campaign_type:
  263. campaign.campaign_type.append(1)
  264. # 更改轮播广告图片
  265. if banner_files:
  266. for sort in sort_files:
  267. if sort <= len(campaign.banner_campaign):
  268. old_image = campaign.banner_campaign[sort - 1]["image"]
  269. self.del_file_to_s3(old_image)
  270. else:
  271. campaign.banner_campaign.append({})
  272. if sort not in sort_urls:
  273. return response.json(10, "图片需要和链接对应")
  274. banner_image_urls = self.upload_files_to_s3(banner_files, "BannerAdvertise")
  275. image_num = 0
  276. for sort in sort_files:
  277. campaign.banner_campaign[sort - 1]["image"] = banner_image_urls[image_num]
  278. image_num = image_num + 1
  279. if 2 not in campaign.campaign_type:
  280. campaign.campaign_type.append(2)
  281. # 更改轮播广告链接
  282. if banner_urls:
  283. url_num = 0
  284. for sort in sort_urls:
  285. if sort > len(campaign.banner_campaign):
  286. campaign.banner_campaign.append({})
  287. if sort not in sort_files:
  288. return response.json(10, "图片需要和链接对应")
  289. campaign.banner_campaign[sort - 1]["url"] = banner_urls[url_num]
  290. url_num = url_num + 1
  291. # 添加删除轮播图列表
  292. if sort_banner_del:
  293. sort_banner_del.sort(reverse=True)
  294. for sort in sort_banner_del:
  295. if sort <= len(campaign.banner_campaign):
  296. self.del_file_to_s3(campaign.banner_campaign[sort - 1]["image"])
  297. campaign.banner_campaign.pop(sort - 1)
  298. if not campaign.banner_campaign:
  299. campaign.campaign_type.remove(2)
  300. if poster_del is not None:
  301. campaign.campaign_url = ""
  302. self.del_file_to_s3(campaign.image_url)
  303. campaign.image_url = ""
  304. campaign.campaign_type.remove(1)
  305. if not campaign.campaign_type:
  306. campaign.status = 2
  307. # 常规字段
  308. if campaign_name is not None:
  309. campaign.campaign_name = campaign_name
  310. if campaign_url is not None:
  311. campaign.campaign_url = campaign_url
  312. if app_bundle_type is not None:
  313. campaign.app_bundle_type = app_bundle_type
  314. if campaign_start_time is not None:
  315. campaign.campaign_start_date = campaign_start_time
  316. if campaign_end_time is not None:
  317. campaign.campaign_end_date = campaign_end_time
  318. if campaign_show_stime is not None:
  319. campaign.campaign_show_stime = campaign_show_stime
  320. if campaign_show_etime is not None:
  321. campaign.campaign_show_etime = campaign_show_etime
  322. # 更新多对多字段 - 设备类型
  323. if device_type_names:
  324. device_types = DeviceTypeModel.objects.filter(name__in=device_type_names)
  325. campaign.device_type.set(device_types)
  326. # 更新多对多字段 - 国家/地区
  327. if country_name_list:
  328. countries = CountryModel.objects.filter(country_name__in=country_name_list)
  329. campaign.country.set(countries)
  330. campaign.update_time = update_time
  331. # 保存更新
  332. campaign.save()
  333. return response.json(0)
  334. except Exception as e:
  335. print(e)
  336. return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
  337. def delete_campaign(self, request_dict, response):
  338. """
  339. 删除广告活动
  340. @param request_dict: 包含所有请求参数的字典
  341. @param response: 响应对象
  342. @return: 响应对象
  343. """
  344. campaign_id = request_dict.get('id')
  345. if not campaign_id:
  346. return response.json(444)
  347. try:
  348. campaign = AppAdvertiseCampaign.objects.get(pk=campaign_id)
  349. if campaign.image_url != "":
  350. self.del_file_to_s3(campaign.image_url)
  351. if campaign.banner_campaign:
  352. banner_campaign_list = []
  353. for banner_campaign in campaign.banner_campaign:
  354. banner = banner_campaign["image"]
  355. banner_campaign_list.append(banner)
  356. self.del_file_to_s3(banner_campaign_list)
  357. # 清除多对多关系
  358. campaign.device_type.clear()
  359. campaign.country.clear()
  360. # 保留在广告表中
  361. campaign.status = 2
  362. campaign.update_time = int(time.time())
  363. campaign.save()
  364. return response.json(0)
  365. except Exception as e:
  366. print(e)
  367. return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
  368. def switch_campaign(self, request_dict, response):
  369. """
  370. 广告活动 开启/关闭
  371. @param request_dict: 包含所有请求参数的字典
  372. @param response: 响应对象
  373. @return: 响应对象
  374. """
  375. campaign_id = request_dict.get('id')
  376. status = request_dict.get('status')
  377. if not all([campaign_id, status]):
  378. return response.json(444)
  379. try:
  380. AppAdvertiseCampaign.objects.filter(pk=campaign_id).update(status=status, update_time=int(time.time()))
  381. return response.json(0)
  382. except Exception as e:
  383. print(e)
  384. return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
  385. def get_user_behavior_log(self, request_dict, response):
  386. campaign_ids = json.loads(request_dict.get('campaign_id', '[]'))
  387. start_time = request_dict.get('start_time', None)
  388. end_time = request_dict.get('end_time', None)
  389. if not all([start_time, end_time]):
  390. return response.json(444)
  391. try:
  392. open_screen_campaign_qs = OpenScreenCampaign.objects.filter(
  393. update_time__range=[int(start_time), int(end_time)])
  394. if campaign_ids:
  395. open_screen_campaign_qs = open_screen_campaign_qs.filter(
  396. campaign_id__in=campaign_ids, campaign_id__status__in=[0, 1],
  397. campaign_id__campaign_type__contains=[1]
  398. )
  399. open_screen_campaign_qs = (open_screen_campaign_qs.
  400. select_related('campaign_id').
  401. values('id', 'user_id', 'status', 'update_time', 'create_time',
  402. 'campaign_id', 'campaign_id__campaign_name', 'campaign_id__campaign_type',
  403. 'campaign_id__status',
  404. 'campaign_id__campaign_start_date', 'campaign_id__campaign_end_date',
  405. 'campaign_id__campaign_show_stime', 'campaign_id__campaign_show_etime'))
  406. if not open_screen_campaign_qs.exists():
  407. return response.json(0, {'list': []})
  408. campaigns_list = []
  409. for campaign in open_screen_campaign_qs:
  410. renamed_campaign = {
  411. 'id': campaign['id'],
  412. 'user_id': campaign['user_id'],
  413. 'status': campaign['status'],
  414. 'update_time': campaign['update_time'],
  415. 'create_time': campaign['create_time'],
  416. 'campaign_id': campaign['campaign_id'],
  417. 'campaign_name': campaign['campaign_id__campaign_name'],
  418. 'campaign_type': 1,
  419. 'campaign_status': campaign['campaign_id__status'],
  420. 'start_date': campaign['campaign_id__campaign_start_date'],
  421. 'end_date': campaign['campaign_id__campaign_end_date'],
  422. 'start_time': campaign['campaign_id__campaign_show_stime'],
  423. 'end_time': campaign['campaign_id__campaign_show_etime']
  424. }
  425. campaigns_list.append(renamed_campaign)
  426. return response.json(0, {'list': campaigns_list})
  427. except Exception as e:
  428. return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
  429. def get_country_list(self, response):
  430. try:
  431. if SERVER_TYPE == 'Ansjer.us_config.formal_settings':
  432. region_api = 'https://www.dvema.com/'
  433. elif SERVER_TYPE == 'Ansjer.eur_config.formal_settings':
  434. region_api = 'https://api.zositeche.com/'
  435. elif SERVER_TYPE == 'Ansjer.cn_config.formal_settings':
  436. region_api = 'https://www.zositechc.cn/'
  437. else:
  438. region_api = 'https://test.zositechc.cn/'
  439. country_qs = CountryModel.objects.filter(region__api=region_api).values('country_name')
  440. if not country_qs.exists():
  441. return response.json(173)
  442. country_list = []
  443. for country in country_qs:
  444. country_list.append(country['country_name'])
  445. return response.json(0, {'list': country_list})
  446. except Exception as e:
  447. return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
  448. @staticmethod
  449. def upload_files_to_s3(files, path_prefix):
  450. """
  451. 广告图片文件上传到S3存储桶
  452. @param files: 文件 request.FILES获取
  453. @param path_prefix: 存储路径
  454. @return image_urls: 列表
  455. """
  456. try:
  457. _, regin, AWS_SES_ACCESS_REGION = CampaignView.s3_server()
  458. # 确保files是一个列表,统一处理单个文件和多个文件
  459. if not isinstance(files, list):
  460. files = [files]
  461. image_urls = []
  462. bucket_name = "ansjerfilemanager"
  463. s3 = AmazonS3Util(AWS_ACCESS_KEY_ID[regin], AWS_SECRET_ACCESS_KEY[regin], AWS_SES_ACCESS_REGION)
  464. for file in files:
  465. timestamp = int(time.time())
  466. file_key = f'app/campaign/{path_prefix}/{timestamp}_{file.name}'
  467. s3.upload_file_obj(bucket_name, file_key, file,
  468. {'ContentType': file.content_type, 'ACL': 'public-read'})
  469. image_urls.append(f"{path_prefix}/{timestamp}_{file.name}")
  470. return image_urls
  471. except Exception as e:
  472. LOGGER.info('存储桶添加异常:error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
  473. return None
  474. @staticmethod
  475. def del_file_to_s3(path_list):
  476. """
  477. S3存储桶 删除文件
  478. @param path_list: 单一字符串或者列表
  479. @return
  480. """
  481. try:
  482. _, regin, AWS_SES_ACCESS_REGION = CampaignView.s3_server()
  483. if not isinstance(path_list, list):
  484. path_list = [path_list]
  485. for path in path_list:
  486. # 删除存储桶原来的图片
  487. s3 = AmazonS3Util(AWS_ACCESS_KEY_ID[regin], AWS_SECRET_ACCESS_KEY[regin], AWS_SES_ACCESS_REGION)
  488. bucket_name = 'ansjerfilemanager'
  489. s3.delete_obj(bucket_name, f"app/campaign/{path}")
  490. except Exception as e:
  491. LOGGER.info('存储桶删除异常:error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
  492. @staticmethod
  493. def s3_server():
  494. if SERVER_TYPE == 'Ansjer.cn_config.formal_settings' or SERVER_TYPE == 'Ansjer.cn_config.test_settings':
  495. s3_url = "https://ansjerfilemanager.s3.cn-northwest-1.amazonaws.com.cn/app/campaign/"
  496. regin = 0
  497. AWS_SES_ACCESS_REGION = "cn-northwest-1"
  498. else:
  499. s3_url = "https://ansjerfilemanager.s3.amazonaws.com/app/campaign/"
  500. regin = 1
  501. AWS_SES_ACCESS_REGION = 'us-east-1'
  502. return s3_url, regin, AWS_SES_ACCESS_REGION
  503. # ,#.
  504. # .[[[&[[; ,&&,
  505. # &# ,[;,&; [[[[[[:
  506. # [[ :[&,&[#;i[[,[,
  507. # ;#i [ L@$[&[#&[[ .[
  508. # i[[[[[[ @@$.#[#&$$$ [;
  509. # ,[,,,;;& i$$ [ @@$ &&
  510. # [i;,,,;[, [ $$# [[i:#[#
  511. # [,,,,,,#&. &[, &&[[&[[
  512. # [,,,,,,,&[[&i[[[#[ [&;,;[[&
  513. # [,,,,,,,,,&&[&;,,&[[&;[[[,,,,;[[
  514. # &;,,,,,,,,,,,,,,,;,#[[&,,,;,,;,[[#
  515. # i[,,,,,,,,,,,,,,,,,,,,,,;,;,,,,[[&:
  516. # [;,,,,,,,,,,,,,,,,,,,,,&,;,,,,#[[
  517. # [;,;,,,,,,,,,,,,,,,,,;[,;,,,,;[
  518. # ;[#;,,,,,,,,,,,,,,,,,i&,,,,,,i[
  519. # :&[i;,,,,,,,,,,,,,;,[&,;,,,,#[i
  520. # [[[[i,,,,,,,;,;&[&&&&,,,,,[[[
  521. # &;[[[[&[[&[&[&&&,,,&[,,,,[[[
  522. # :&i,;,ii##i;,,,;;,,;;,,;[[i
  523. # &[[&[[[,;,,,,,,,,,,,,,,,,[[&,
  524. # &[,,,;[[,,,,,,,,,,,,,,,,;[[&&[[
  525. # [,,,,[[,;,,,,,,,,,,,,,,,,,,,,;[[
  526. # [,,;;[;,,,,,,,,,,,,,,,,,,[[;,,,[
  527. # [i;#[[;,,,,,,,,,,,,,,,,;[[;,,,;[
  528. # &[,,&#,,,,,,,,,,,,,,,,,,[;;,,,[[
  529. # [[&&,;,,,,,,,,,,,,,,,,,[;;;[[[
  530. # [[,;,,,,,,,,,,,,,,,,,[#;#&
  531. # &[,,,,,,,,,,,,,,,,,,,,[[[&
  532. # [,,,,,,,,,,,,,,,,,,,,,,[[[
  533. # [,,,,,,,,,,,,,,,,,,;,,;[[:
  534. # &;,,,,,,,,,,,,,,,,,;,,,;[
  535. # 鳄鱼保佑
  536. # 代码无BUG!