|
@@ -101,6 +101,8 @@ class CloudStorageView(View):
|
|
|
return self.do_sign_play_m3u8(request_dict, response)
|
|
|
elif operation == 'payOK':
|
|
|
return self.do_pay_ok(request_dict)
|
|
|
+ elif operation == 'vodMsgEnd':
|
|
|
+ return self.do_vod_msg_end(request_dict)
|
|
|
else:
|
|
|
token = request_dict.get('token', None)
|
|
|
# 设备主键uid
|
|
@@ -785,7 +787,7 @@ class CloudStorageView(View):
|
|
|
|
|
|
order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id)
|
|
|
sys_msg_text_list = ['成功购买云存', 'Successful purchase of cloud storage']
|
|
|
- do_vod_msg_Notice(request, UID, channel, userid, lang, sys_msg_text_list)
|
|
|
+ self.do_vod_msg_Notice(UID, channel, userid, lang, sys_msg_text_list)
|
|
|
red_url = "{SERVER_DOMAIN}web/paid2/success.html".format(SERVER_DOMAIN=SERVER_DOMAIN)
|
|
|
return HttpResponseRedirect(red_url)
|
|
|
return response.json(0, signature)
|
|
@@ -861,7 +863,7 @@ class CloudStorageView(View):
|
|
|
dvq.update(**dvq_set_update_dict)
|
|
|
order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id)
|
|
|
sys_msg_text_list = ['成功购买云存','Successful purchase of cloud storage']
|
|
|
- do_vod_msg_Notice(request_dict, UID, channel, userid, lang, sys_msg_text_list)
|
|
|
+ self.do_vod_msg_Notice(UID, channel, userid, lang, sys_msg_text_list)
|
|
|
|
|
|
# return response.json(0)
|
|
|
red_url = "{SERVER_DOMAIN}web/paid2/success.html".format(SERVER_DOMAIN=SERVER_DOMAIN)
|
|
@@ -939,7 +941,7 @@ class CloudStorageView(View):
|
|
|
dvq.update(**dvq_set_update_dict)
|
|
|
order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id)
|
|
|
sys_msg_text_list = ['成功购买云存', 'Successful purchase of cloud storage']
|
|
|
- do_vod_msg_Notice(request, UID, channel, userid, lang, sys_msg_text_list)
|
|
|
+ self.do_vod_msg_Notice(UID, channel, userid, lang, sys_msg_text_list)
|
|
|
return HttpResponse(pay.xml_to_dict({'return_code': 'SUCCESS', 'return_msg': 'OK'}))
|
|
|
|
|
|
else:
|
|
@@ -1292,6 +1294,203 @@ class CloudStorageView(View):
|
|
|
return response.json(0)
|
|
|
return response.json(444)
|
|
|
|
|
|
+ # 云存操作系统消息
|
|
|
+ def do_vod_msg_Notice(self, uid, channel, userID, lang, sys_msg_text_list):
|
|
|
+ logger = logging.getLogger('log')
|
|
|
+ logger.info('进来了')
|
|
|
+ # user = Device_User.objects.get(userID = userID)
|
|
|
+ # lang = user.language;
|
|
|
+ if lang == 'cn':
|
|
|
+ sys_msg_text = sys_msg_text_list[0]
|
|
|
+ else:
|
|
|
+ sys_msg_text = sys_msg_text_list[1]
|
|
|
+ nowTime = int(time.time())
|
|
|
+ create_data = {'userID_id': userID, 'msg': sys_msg_text, 'addTime': nowTime,
|
|
|
+ 'updTime': nowTime, 'uid': uid, 'eventType': 0}
|
|
|
+ SysMsgModel.objects.create(**create_data)
|
|
|
+ self.pushApp(nowTime, uid, channel, sys_msg_text)
|
|
|
+
|
|
|
+ logger.info('出去了')
|
|
|
+
|
|
|
+ # 云存到期续费提醒 提前1天
|
|
|
+ def do_vod_msg_end(self):
|
|
|
+ response = ResponseObject()
|
|
|
+ now_time = int(time.time())
|
|
|
+
|
|
|
+ list = UID_Bucket.objects.filter(Q(endTime__lte=(now_time - 3600 * 24)) & Q(endTime__gt=now_time)).values('id',
|
|
|
+ 'uid',
|
|
|
+ 'bucket__area','channel')
|
|
|
+
|
|
|
+ uq_list = []
|
|
|
+ ids = []
|
|
|
+ for ub in list:
|
|
|
+ ids.append(ub['id'])
|
|
|
+
|
|
|
+ oqlist = Order_Model.objects.filter(uid_bucket_id__in=ids).values('userID_id', 'uid_bucket_id')
|
|
|
+
|
|
|
+ for ub in list:
|
|
|
+ for oo in oqlist:
|
|
|
+ if ub['id'] == oo['uid_bucket_id']:
|
|
|
+ if ub['bucket__area'] == 'cn':
|
|
|
+ sys_msg_text = "云存即将过期,请您注意!"
|
|
|
+ else:
|
|
|
+ sys_msg_text = "Cloud storage is about to expire, please pay attention!"
|
|
|
+ uq_list.append(SysMsgModel(
|
|
|
+ userID_id=oo['userID_id'],
|
|
|
+ addTime=now_time,
|
|
|
+ updTime=now_time,
|
|
|
+ uid=ub['uid'],
|
|
|
+ eventType=0,
|
|
|
+ msg=sys_msg_text,
|
|
|
+ status=0
|
|
|
+ ))
|
|
|
+ self.pushApp(now_time, ub['uid'], ub['channel'], sys_msg_text)
|
|
|
+
|
|
|
+ SysMsgModel.objects.bulk_create(uq_list)
|
|
|
+
|
|
|
+
|
|
|
+ return response.json(0)
|
|
|
+
|
|
|
+ def pushApp(self, nowTime, uid, channel, sys_msg_text):
|
|
|
+ n_time = nowTime
|
|
|
+
|
|
|
+ kwag_args = {
|
|
|
+ 'uid': uid,
|
|
|
+ 'channel': channel,
|
|
|
+ 'event_type': 0,
|
|
|
+ 'n_time': n_time
|
|
|
+ }
|
|
|
+
|
|
|
+ # 从数据库查询出来
|
|
|
+ uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid, uid_set__detect_status=1). \
|
|
|
+ values('token_val', 'app_type', 'appBundleId', 'm_code',
|
|
|
+ 'push_type', 'userID_id', 'userID__NickName',
|
|
|
+ 'lang', 'm_code', 'tz', 'uid_set__nickname', 'uid_set__detect_interval', 'uid_set__detect_group',
|
|
|
+ 'uid_set__channel')
|
|
|
+ print(uid_push_qs)
|
|
|
+ # 新建一个list接收数据
|
|
|
+ redis_list = []
|
|
|
+ # 把数据库数据追加进redis_list
|
|
|
+ for qs in uid_push_qs:
|
|
|
+ redis_list.append(qs)
|
|
|
+
|
|
|
+ nickname = redis_list[0]['uid_set__nickname']
|
|
|
+
|
|
|
+ for up in redis_list:
|
|
|
+ push_type = up['push_type']
|
|
|
+ appBundleId = up['appBundleId']
|
|
|
+ token_val = up['token_val']
|
|
|
+ lang = up['lang']
|
|
|
+ tz = up['tz']
|
|
|
+ if tz is None or tz == '':
|
|
|
+ tz = 0
|
|
|
+
|
|
|
+ package_title_config = {
|
|
|
+ 'com.ansjer.customizedd_a': 'DVS',
|
|
|
+ 'com.ansjer.zccloud_a': 'ZosiSmart',
|
|
|
+ 'com.ansjer.zccloud_ab': '周视',
|
|
|
+ 'com.ansjer.adcloud_a': 'ADCloud',
|
|
|
+ 'com.ansjer.adcloud_ab': 'ADCloud',
|
|
|
+ 'com.ansjer.accloud_a': 'ACCloud',
|
|
|
+ 'com.ansjer.loocamccloud_a': 'Loocam',
|
|
|
+ 'com.ansjer.loocamdcloud_a': 'Anlapus',
|
|
|
+ 'com.ansjer.customizedb_a': 'COCOONHD',
|
|
|
+ 'com.ansjer.customizeda_a': 'Guardian365',
|
|
|
+ 'com.ansjer.customizedc_a': 'PatrolSecure',
|
|
|
+ }
|
|
|
+ if appBundleId in package_title_config.keys():
|
|
|
+ msg_title = package_title_config[appBundleId] + '(' + nickname + ')'
|
|
|
+ else:
|
|
|
+ msg_title = nickname
|
|
|
+
|
|
|
+ # 发送内容
|
|
|
+ msg_text = sys_msg_text
|
|
|
+ kwag_args['appBundleId'] = appBundleId
|
|
|
+ kwag_args['token_val'] = token_val
|
|
|
+ kwag_args['msg_title'] = msg_title
|
|
|
+ kwag_args['msg_text'] = msg_text
|
|
|
+ push_server_status = 0
|
|
|
+ # 推送
|
|
|
+ if push_type == 0: # ios apns
|
|
|
+
|
|
|
+ try:
|
|
|
+ cli = apns2.APNSClient(mode=APNS_MODE,
|
|
|
+ client_cert=os.path.join(BASE_DIR,
|
|
|
+ APNS_CONFIG[appBundleId]['pem_path']))
|
|
|
+
|
|
|
+ push_data = {"alert": "Motion ", "event_time": n_time, "event_type": 0, "msg": "",
|
|
|
+ "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1",
|
|
|
+ "channel": channel}
|
|
|
+ alert = apns2.PayloadAlert(body=msg_text, title=msg_title)
|
|
|
+ payload = apns2.Payload(alert=alert, custom=push_data)
|
|
|
+
|
|
|
+ # return uid, channel, appBundleId, str(token_val), event_type, n_time, msg_title,msg_text
|
|
|
+ n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
|
|
|
+ res = cli.push(n=n, device_token=token_val, topic=appBundleId)
|
|
|
+ print(res.status_code)
|
|
|
+ if res.status_code == 200:
|
|
|
+ return res.status_code
|
|
|
+ else:
|
|
|
+ print('apns push fail')
|
|
|
+ print(res.reason)
|
|
|
+ return res.status_code
|
|
|
+ except (ValueError, ArithmeticError):
|
|
|
+ return 'The program has a numeric format exception, one of the arithmetic exceptions'
|
|
|
+ except Exception as e:
|
|
|
+ print(repr(e))
|
|
|
+ return repr(e)
|
|
|
+
|
|
|
+ elif push_type == 1: # android gcm
|
|
|
+ try:
|
|
|
+ FCM_CONFIG = {
|
|
|
+ 'com.ansjer.zccloud_a': 'AAAAb9YP3rk:APA91bHu8u-CTpcd0g6lKPo0WNVqCi8jZub1cPPbSAY9AucT1HxlF65ZDUko9iG8q2ch17bwu9YWHpK1xI1gHSRXCslLvZlXEmHZC0AG3JKg15XuUvlFKACIajUFV-pOeGRT8tM6-31I',
|
|
|
+ 'com.ansjer.loocamccloud_a': 'AAAAb9YP3rk:APA91bFCgd-kbVmpK4EVpfdHH_PJZQCYTkOGnTZdIuBWEz2r7aMRsJYHOH3sB-rwcbaRWgnufTyjX9nGQxb6KxQbWVk4ah_H-M3IqGh6Mb60WQQAuR33V6g_Jes5pGL6ViuIxGHqVMaR',
|
|
|
+ 'com.ansjer.loocamdcloud_a': 'AAAAb9YP3rk:APA91bGw2I2KMD4i-5T7nZO_wB8kuAOuqgyqe5rxmY-W5qkpYEx9IL2IfmC_qf6B_xOyjIDDSjckvMo-RauN__SEoxvAkis7042GRkoKpw7cjZ_H8lC-d50PC0GclPzccrOGFusyKbFY',
|
|
|
+ 'com.ansjer.customizedb_a': 'AAAAb9YP3rk:APA91bE7kI4vcm-9h_CJNFlOZfc-xwP4Btn6AnjOrwoKV6fgYN7fdarkO76sYxVZiAbDnxsFfOJyP7vQfwyan6mdjuyD5iHdt_XgO22VqniC0vA1V4GJiCS8Tp7LxIX8JVKZl9I_Powt',
|
|
|
+ 'com.ansjer.customizeda_a': 'AAAAb9YP3rk:APA91bF0HzizVWDc6dKzobY9fsaKDK4veqkOZehDXshVXs8pEEvNWjR_YWbhP60wsRYCHCal8fWN5cECVOWNMMzDsfU88Ty2AUl8S5FtZsmeDTkoGntQOswBr8Ln7Fm_LAp1VqTf9CpM',
|
|
|
+ 'com.ansjer.customizedd_a': 'AAAAb9YP3rk:APA91bHkxOozJWBrlv3eNT0PgwosYENI9aM4Zuzd418cX-iKkpa1zFNC5MkNDKApx1KH4fhmAfaJ6IMRZ0nj5GIxCpstDYCaZWwgC7-etqfSxG5JAq8LOwJx0o_1tUZqwjIic8ztsg0o',
|
|
|
+ 'com.ansjer.adcloud_a': 'AAAAb9YP3rk:APA91bFm06w8b9OKQ0gz0iaWFuRqRIkvgAz6z7Gp3dBU_X-LNGJQd1hc1QR2W7QzBglF8SHtERA45a2lbdLRa5qv7hxfd6W_sJLBK7dA8jklsOQBvy505oUzTwMKWy4TwH-exps9KrhO',
|
|
|
+ 'com.ansjer.accloud_a': 'AAAAb9YP3rk:APA91bFm06w8b9OKQ0gz0iaWFuRqRIkvgAz6z7Gp3dBU_X-LNGJQd1hc1QR2W7QzBglF8SHtERA45a2lbdLRa5qv7hxfd6W_sJLBK7dA8jklsOQBvy505oUzTwMKWy4TwH-exps9KrhO',
|
|
|
+ 'com.ansjer.zccloud_ab': 'AAAAb9YP3rk:APA91bHu8u-CTpcd0g6lKPo0WNVqCi8jZub1cPPbSAY9AucT1HxlF65ZDUko9iG8q2ch17bwu9YWHpK1xI1gHSRXCslLvZlXEmHZC0AG3JKg15XuUvlFKACIajUFV-pOeGRT8tM6-31I',
|
|
|
+ }
|
|
|
+ serverKey = FCM_CONFIG[appBundleId]
|
|
|
+ except Exception as e:
|
|
|
+ return 'serverKey abnormal'
|
|
|
+ push_service = FCMNotification(api_key=serverKey)
|
|
|
+ data = {"alert": "Motion ", "event_time": n_time, "event_type": 0, "msg": "",
|
|
|
+ "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel}
|
|
|
+ result = push_service.notify_single_device(registration_id=token_val, message_title=msg_title,
|
|
|
+ message_body=msg_text, data_message=data,
|
|
|
+ extra_kwargs={
|
|
|
+ 'default_vibrate_timings': True,
|
|
|
+ 'default_sound': True,
|
|
|
+ 'default_light_settings': True
|
|
|
+ })
|
|
|
+ print('fcm push ing')
|
|
|
+ print(result)
|
|
|
+ return result
|
|
|
+ elif push_type == 2: # android jpush
|
|
|
+ print('do_jpush')
|
|
|
+ app_key = JPUSH_CONFIG[appBundleId]['Key']
|
|
|
+ master_secret = JPUSH_CONFIG[appBundleId]['Secret']
|
|
|
+ # 此处换成各自的app_key和master_secre
|
|
|
+ _jpush = jpush.JPush(app_key, master_secret)
|
|
|
+ push = _jpush.create_push()
|
|
|
+ # if you set the logging level to "DEBUG",it will show the debug logging.
|
|
|
+ # _jpush.set_logging("DEBUG")
|
|
|
+ # push.audience = jpush.all_
|
|
|
+ push.audience = jpush.registration_id(token_val)
|
|
|
+ push_data = {"alert": "Motion ", "event_time": n_time, "event_type": 0, "msg": "",
|
|
|
+ "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel}
|
|
|
+ android = jpush.android(alert=msg_text, priority=1, style=1, alert_type=7,
|
|
|
+ big_text=msg_text, title=msg_title,
|
|
|
+ extras=push_data)
|
|
|
+ push.notification = jpush.notification(android=android)
|
|
|
+ push.platform = jpush.all_
|
|
|
+ res = push.send()
|
|
|
+ print(res)
|
|
|
+ return res.status_code
|
|
|
+
|
|
|
|
|
|
|
|
|
# 删除过期云存播放列表
|
|
@@ -1331,193 +1530,4 @@ def deleteExpiredUidBucket(request):
|
|
|
expired_uid_bucket = UID_Bucket.objects.filter(endTime__lte=now_time)
|
|
|
id_list = expired_uid_bucket.values_list("id", flat=True)
|
|
|
UID_Bucket.objects.filter(id__in=list(id_list)).delete() # 删除过期云存关联套餐, 后续是否考虑用软删除
|
|
|
- return response.json(0)
|
|
|
-
|
|
|
-# 云存操作系统消息
|
|
|
-def do_vod_msg_Notice(request, uid , channel, userID , lang, sys_msg_text_list):
|
|
|
- logger = logging.getLogger('log')
|
|
|
- logger.info('进来了')
|
|
|
- # user = Device_User.objects.get(userID = userID)
|
|
|
- # lang = user.language;
|
|
|
- if lang == 'cn':
|
|
|
- sys_msg_text = sys_msg_text_list[0]
|
|
|
- else:
|
|
|
- sys_msg_text = sys_msg_text_list[1]
|
|
|
- nowTime = int(time.time())
|
|
|
- create_data = {'userID_id': userID, 'msg': sys_msg_text, 'addTime': nowTime,
|
|
|
- 'updTime': nowTime, 'uid': uid, 'eventType': 0}
|
|
|
- SysMsgModel.objects.create(**create_data)
|
|
|
-
|
|
|
- n_time = nowTime
|
|
|
-
|
|
|
- kwag_args = {
|
|
|
- 'uid': uid,
|
|
|
- 'channel': channel,
|
|
|
- 'event_type': 0,
|
|
|
- 'n_time': n_time
|
|
|
- }
|
|
|
-
|
|
|
- # 从数据库查询出来
|
|
|
- uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid, uid_set__detect_status=1). \
|
|
|
- values('token_val', 'app_type', 'appBundleId', 'm_code',
|
|
|
- 'push_type', 'userID_id', 'userID__NickName',
|
|
|
- 'lang', 'm_code', 'tz', 'uid_set__nickname', 'uid_set__detect_interval', 'uid_set__detect_group',
|
|
|
- 'uid_set__channel')
|
|
|
- print(uid_push_qs)
|
|
|
- # 新建一个list接收数据
|
|
|
- redis_list = []
|
|
|
- # 把数据库数据追加进redis_list
|
|
|
- for qs in uid_push_qs:
|
|
|
- redis_list.append(qs)
|
|
|
-
|
|
|
- nickname = redis_list[0]['uid_set__nickname']
|
|
|
-
|
|
|
- for up in redis_list:
|
|
|
- push_type = up['push_type']
|
|
|
- appBundleId = up['appBundleId']
|
|
|
- token_val = up['token_val']
|
|
|
- lang = up['lang']
|
|
|
- tz = up['tz']
|
|
|
- if tz is None or tz == '':
|
|
|
- tz = 0
|
|
|
-
|
|
|
- package_title_config = {
|
|
|
- 'com.ansjer.customizedd_a': 'DVS',
|
|
|
- 'com.ansjer.zccloud_a': 'ZosiSmart',
|
|
|
- 'com.ansjer.zccloud_ab': '周视',
|
|
|
- 'com.ansjer.adcloud_a': 'ADCloud',
|
|
|
- 'com.ansjer.adcloud_ab': 'ADCloud',
|
|
|
- 'com.ansjer.accloud_a': 'ACCloud',
|
|
|
- 'com.ansjer.loocamccloud_a': 'Loocam',
|
|
|
- 'com.ansjer.loocamdcloud_a': 'Anlapus',
|
|
|
- 'com.ansjer.customizedb_a': 'COCOONHD',
|
|
|
- 'com.ansjer.customizeda_a': 'Guardian365',
|
|
|
- 'com.ansjer.customizedc_a': 'PatrolSecure',
|
|
|
- }
|
|
|
- if appBundleId in package_title_config.keys():
|
|
|
- msg_title = package_title_config[appBundleId] + '(' + nickname + ')'
|
|
|
- else:
|
|
|
- msg_title = nickname
|
|
|
-
|
|
|
- # 发送内容
|
|
|
- msg_text = sys_msg_text
|
|
|
- kwag_args['appBundleId'] = appBundleId
|
|
|
- kwag_args['token_val'] = token_val
|
|
|
- kwag_args['msg_title'] = msg_title
|
|
|
- kwag_args['msg_text'] = msg_text
|
|
|
- push_server_status = 0
|
|
|
- # 推送
|
|
|
- if push_type == 0: # ios apns
|
|
|
-
|
|
|
- try:
|
|
|
- cli = apns2.APNSClient(mode=APNS_MODE,
|
|
|
- client_cert=os.path.join(BASE_DIR,
|
|
|
- APNS_CONFIG[appBundleId]['pem_path']))
|
|
|
-
|
|
|
- push_data = {"alert": "Motion ", "event_time": n_time, "event_type": 0, "msg": "",
|
|
|
- "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel}
|
|
|
- alert = apns2.PayloadAlert(body=msg_text, title=msg_title)
|
|
|
- payload = apns2.Payload(alert=alert, custom=push_data)
|
|
|
-
|
|
|
- # return uid, channel, appBundleId, str(token_val), event_type, n_time, msg_title,msg_text
|
|
|
- n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
|
|
|
- res = cli.push(n=n, device_token=token_val, topic=appBundleId)
|
|
|
- print(res.status_code)
|
|
|
- if res.status_code == 200:
|
|
|
- return res.status_code
|
|
|
- else:
|
|
|
- print('apns push fail')
|
|
|
- print(res.reason)
|
|
|
- return res.status_code
|
|
|
- except (ValueError, ArithmeticError):
|
|
|
- return 'The program has a numeric format exception, one of the arithmetic exceptions'
|
|
|
- except Exception as e:
|
|
|
- print(repr(e))
|
|
|
- return repr(e)
|
|
|
-
|
|
|
- elif push_type == 1: # android gcm
|
|
|
- try:
|
|
|
- FCM_CONFIG = {
|
|
|
- 'com.ansjer.zccloud_a': 'AAAAb9YP3rk:APA91bHu8u-CTpcd0g6lKPo0WNVqCi8jZub1cPPbSAY9AucT1HxlF65ZDUko9iG8q2ch17bwu9YWHpK1xI1gHSRXCslLvZlXEmHZC0AG3JKg15XuUvlFKACIajUFV-pOeGRT8tM6-31I',
|
|
|
- 'com.ansjer.loocamccloud_a': 'AAAAb9YP3rk:APA91bFCgd-kbVmpK4EVpfdHH_PJZQCYTkOGnTZdIuBWEz2r7aMRsJYHOH3sB-rwcbaRWgnufTyjX9nGQxb6KxQbWVk4ah_H-M3IqGh6Mb60WQQAuR33V6g_Jes5pGL6ViuIxGHqVMaR',
|
|
|
- 'com.ansjer.loocamdcloud_a': 'AAAAb9YP3rk:APA91bGw2I2KMD4i-5T7nZO_wB8kuAOuqgyqe5rxmY-W5qkpYEx9IL2IfmC_qf6B_xOyjIDDSjckvMo-RauN__SEoxvAkis7042GRkoKpw7cjZ_H8lC-d50PC0GclPzccrOGFusyKbFY',
|
|
|
- 'com.ansjer.customizedb_a': 'AAAAb9YP3rk:APA91bE7kI4vcm-9h_CJNFlOZfc-xwP4Btn6AnjOrwoKV6fgYN7fdarkO76sYxVZiAbDnxsFfOJyP7vQfwyan6mdjuyD5iHdt_XgO22VqniC0vA1V4GJiCS8Tp7LxIX8JVKZl9I_Powt',
|
|
|
- 'com.ansjer.customizeda_a': 'AAAAb9YP3rk:APA91bF0HzizVWDc6dKzobY9fsaKDK4veqkOZehDXshVXs8pEEvNWjR_YWbhP60wsRYCHCal8fWN5cECVOWNMMzDsfU88Ty2AUl8S5FtZsmeDTkoGntQOswBr8Ln7Fm_LAp1VqTf9CpM',
|
|
|
- 'com.ansjer.customizedd_a': 'AAAAb9YP3rk:APA91bHkxOozJWBrlv3eNT0PgwosYENI9aM4Zuzd418cX-iKkpa1zFNC5MkNDKApx1KH4fhmAfaJ6IMRZ0nj5GIxCpstDYCaZWwgC7-etqfSxG5JAq8LOwJx0o_1tUZqwjIic8ztsg0o',
|
|
|
- 'com.ansjer.adcloud_a': 'AAAAb9YP3rk:APA91bFm06w8b9OKQ0gz0iaWFuRqRIkvgAz6z7Gp3dBU_X-LNGJQd1hc1QR2W7QzBglF8SHtERA45a2lbdLRa5qv7hxfd6W_sJLBK7dA8jklsOQBvy505oUzTwMKWy4TwH-exps9KrhO',
|
|
|
- 'com.ansjer.accloud_a': 'AAAAb9YP3rk:APA91bFm06w8b9OKQ0gz0iaWFuRqRIkvgAz6z7Gp3dBU_X-LNGJQd1hc1QR2W7QzBglF8SHtERA45a2lbdLRa5qv7hxfd6W_sJLBK7dA8jklsOQBvy505oUzTwMKWy4TwH-exps9KrhO',
|
|
|
- 'com.ansjer.zccloud_ab': 'AAAAb9YP3rk:APA91bHu8u-CTpcd0g6lKPo0WNVqCi8jZub1cPPbSAY9AucT1HxlF65ZDUko9iG8q2ch17bwu9YWHpK1xI1gHSRXCslLvZlXEmHZC0AG3JKg15XuUvlFKACIajUFV-pOeGRT8tM6-31I',
|
|
|
- }
|
|
|
- serverKey = FCM_CONFIG[appBundleId]
|
|
|
- except Exception as e:
|
|
|
- return 'serverKey abnormal'
|
|
|
- push_service = FCMNotification(api_key=serverKey)
|
|
|
- data = {"alert": "Motion ", "event_time": n_time, "event_type": 0, "msg": "",
|
|
|
- "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel}
|
|
|
- result = push_service.notify_single_device(registration_id=token_val, message_title=msg_title,
|
|
|
- message_body=msg_text, data_message=data,
|
|
|
- extra_kwargs={
|
|
|
- 'default_vibrate_timings': True,
|
|
|
- 'default_sound': True,
|
|
|
- 'default_light_settings': True
|
|
|
- })
|
|
|
- print('fcm push ing')
|
|
|
- print(result)
|
|
|
- return result
|
|
|
- elif push_type == 2: # android jpush
|
|
|
- print('do_jpush')
|
|
|
- app_key = JPUSH_CONFIG[appBundleId]['Key']
|
|
|
- master_secret = JPUSH_CONFIG[appBundleId]['Secret']
|
|
|
- # 此处换成各自的app_key和master_secre
|
|
|
- _jpush = jpush.JPush(app_key, master_secret)
|
|
|
- push = _jpush.create_push()
|
|
|
- # if you set the logging level to "DEBUG",it will show the debug logging.
|
|
|
- # _jpush.set_logging("DEBUG")
|
|
|
- # push.audience = jpush.all_
|
|
|
- push.audience = jpush.registration_id(token_val)
|
|
|
- push_data = {"alert": "Motion ", "event_time": n_time, "event_type": 0, "msg": "",
|
|
|
- "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel}
|
|
|
- android = jpush.android(alert=msg_text, priority=1, style=1, alert_type=7,
|
|
|
- big_text=msg_text, title=msg_title,
|
|
|
- extras=push_data)
|
|
|
- push.notification = jpush.notification(android=android)
|
|
|
- push.platform = jpush.all_
|
|
|
- res = push.send()
|
|
|
- print(res)
|
|
|
- return res.status_code
|
|
|
- logger.info('出去了')
|
|
|
-
|
|
|
-# 云存到期续费提醒 提前1天
|
|
|
-def do_vod_msg_end(request):
|
|
|
- response = ResponseObject()
|
|
|
- now_time = int(time.time())
|
|
|
-
|
|
|
- list = UID_Bucket.objects.filter(Q(endTime__lte=(now_time - 3600 * 24)) & Q(endTime__gt=now_time)).values('id', 'uid', 'bucket__area')
|
|
|
-
|
|
|
- uq_list = []
|
|
|
- ids = []
|
|
|
- for ub in list:
|
|
|
- ids.append(ub['id'])
|
|
|
-
|
|
|
- oqlist = Order_Model.objects.filter(uid_bucket_id__in=ids).values('userID_id', 'uid_bucket_id')
|
|
|
-
|
|
|
- for ub in list:
|
|
|
- for oo in oqlist:
|
|
|
- if ub['id'] == oo['uid_bucket_id']:
|
|
|
- if ub['bucket__area'] == 'cn':
|
|
|
- sys_msg_text = "云存即将过期,请您注意!"
|
|
|
- else:
|
|
|
- sys_msg_text = "Cloud storage is about to expire, please pay attention!"
|
|
|
- uq_list.append(SysMsgModel(
|
|
|
- userID_id=oo['userID_id'],
|
|
|
- addTime=now_time,
|
|
|
- updTime=now_time,
|
|
|
- uid=ub['uid'],
|
|
|
- eventType=0,
|
|
|
- msg=sys_msg_text,
|
|
|
- status=0
|
|
|
- ))
|
|
|
-
|
|
|
- SysMsgModel.objects.bulk_create(uq_list)
|
|
|
-
|
|
|
return response.json(0)
|