|
@@ -19,7 +19,8 @@ from django.http import HttpResponse, JsonResponse
|
|
|
from django.views.generic.base import View
|
|
|
|
|
|
from Model.models import UnicomDeviceInfo, UnicomCombo, Pay_Type, Order_Model, Store_Meal, AiStoreMeal, \
|
|
|
- UnicomComboOrderInfo, UnicomComboExperienceHistory, UnicomDeviceStatusChangePush, SysMsgModel, UnicomFlowPush
|
|
|
+ UnicomComboOrderInfo, UnicomComboExperienceHistory, UnicomDeviceStatusChangePush, SysMsgModel, UnicomFlowPush, \
|
|
|
+ LogModel
|
|
|
from Object.RedisObject import RedisObject
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
@@ -59,8 +60,8 @@ class UnicomComboView(View):
|
|
|
return self.device_status_change_push(request_dict, request)
|
|
|
elif operation == 'device-bind': # 服务器保存设备的ICCID
|
|
|
return self.device_add(request_dict, response)
|
|
|
- elif operation == 'device-status': # PC调用解绑SIM卡用户,清除套餐数据
|
|
|
- return self.update_device_status(request_dict, response)
|
|
|
+ elif operation == 'device-status': # PC调用解绑SIM卡用户,清除流量套餐数据
|
|
|
+ return self.update_device_status(request, request_dict, response)
|
|
|
elif operation == 'update-card': # 更新SIM类型
|
|
|
return self.update_device_card_type(request_dict, response)
|
|
|
elif operation == 'xxx-sign': # 获取签名用于测试
|
|
@@ -245,7 +246,7 @@ class UnicomComboView(View):
|
|
|
expire_qs.update(sort=100)
|
|
|
|
|
|
@classmethod
|
|
|
- def update_device_status(cls, request_dict, response):
|
|
|
+ def update_device_status(cls, request, request_dict, response):
|
|
|
"""
|
|
|
重置SIM卡绑定状态修改为测试完成,以及重置流量,删除订单信息、删除系统消息
|
|
|
"""
|
|
@@ -291,6 +292,9 @@ class UnicomComboView(View):
|
|
|
Order_Model.objects.filter(orderID__in=order_list).delete()
|
|
|
redis.set_data(key, iccid, 60 * 30) # 缓存当前SIM卡,记录为半个小时内无法赠送免费流量套餐。
|
|
|
UnicomObjeect().change_device_to_activate(iccid)
|
|
|
+ describe = '重置4G流量序列号{},iccid:{}'.format(serial_no, iccid)
|
|
|
+ ip = CommonService.get_ip_address(request)
|
|
|
+ cls.create_operation_log('unicom/api/device-status', ip, request_dict, describe)
|
|
|
return response.json(0)
|
|
|
except Exception as e:
|
|
|
print(e.args)
|
|
@@ -914,3 +918,31 @@ class UnicomComboView(View):
|
|
|
continue
|
|
|
cls.experience_order_4G(item['iccid'], u_device_qs[0]['serial_no'], u_device_qs[0]['user_id'], False)
|
|
|
return response.json(0)
|
|
|
+
|
|
|
+ @classmethod
|
|
|
+ def create_operation_log(cls, url, ip, request_dict, describe):
|
|
|
+ """
|
|
|
+ 创建操作日志
|
|
|
+ @param url: 请求路径
|
|
|
+ @param describe: 描述
|
|
|
+ @param ip: 当前IP
|
|
|
+ @param request_dict: 请求参数
|
|
|
+ @return: True | False
|
|
|
+ """
|
|
|
+ try:
|
|
|
+ # 记录操作日志
|
|
|
+ content = json.loads(json.dumps(request_dict))
|
|
|
+ log = {
|
|
|
+ 'ip': ip,
|
|
|
+ 'user_id': 1,
|
|
|
+ 'status': 200,
|
|
|
+ 'time': int(time.time()),
|
|
|
+ 'content': json.dumps(content),
|
|
|
+ 'url': url,
|
|
|
+ 'operation': describe,
|
|
|
+ }
|
|
|
+ LogModel.objects.create(**log)
|
|
|
+ return True
|
|
|
+ except Exception as e:
|
|
|
+ print('日志异常,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+ return False
|