|
@@ -21,6 +21,7 @@ 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, \
|
|
|
LogModel
|
|
|
+from Object.EIoTClubObject import EIoTClubObject
|
|
|
from Object.RedisObject import RedisObject
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
@@ -384,13 +385,6 @@ class UnicomComboView(View):
|
|
|
# 待完善代码 根据uid与用户id验证系统设备mdcmd
|
|
|
unicom_device_qs = UnicomDeviceInfo.objects.filter(iccid=iccid)
|
|
|
if unicom_device_qs.exists():
|
|
|
- # if unicom_device_qs.first().status == 1:
|
|
|
- # key = 'ASJ:UNICOM:RESET:{}'.format(serial_no)
|
|
|
- # reset_cache = redis.get_data(key)
|
|
|
- # if reset_cache:
|
|
|
- # logger.info('--->三十分后再次访问接口生效赠送流量套餐')
|
|
|
- # return response.json(0, 'Thirty minutes later to visit again take effect')
|
|
|
- # cls.user_activate_flow(iccid)
|
|
|
if unicom_device_qs.first().serial_no != serial_no:
|
|
|
unicom_device_qs.update(main_card=sim, updated_time=n_time, serial_no=serial_no)
|
|
|
cls.create_operation_log('unicom/api/device-bind',
|
|
@@ -403,7 +397,12 @@ class UnicomComboView(View):
|
|
|
unicom_obj = UnicomObjeect()
|
|
|
params = {'iccid': iccid, 'serial_no': serial_no, 'updated_time': n_time,
|
|
|
'created_time': n_time, 'main_card': sim}
|
|
|
- if cls.check_iccid(iccid):
|
|
|
+ if cls.is_dingxin_iot(iccid): # 鼎芯物联卡
|
|
|
+ params['card_type'] = 5 # 国际
|
|
|
+ params['status'] = 2
|
|
|
+ UnicomDeviceInfo.objects.create(**params)
|
|
|
+ return response.json(0)
|
|
|
+ if cls.check_iccid(iccid): # 五兴物联卡
|
|
|
params['card_type'] = 1
|
|
|
params['status'] = 2
|
|
|
UnicomDeviceInfo.objects.create(**params)
|
|
@@ -429,6 +428,21 @@ class UnicomComboView(View):
|
|
|
logger.info('--->设备调用4G注册接口异常:{}'.format(ex))
|
|
|
return response.json(177, repr(e))
|
|
|
|
|
|
+ @classmethod
|
|
|
+ def is_dingxin_iot(cls, iccid):
|
|
|
+ """
|
|
|
+ 根据iccid判断是否鼎芯国际卡
|
|
|
+ """
|
|
|
+ try:
|
|
|
+ dx_iot = EIoTClubObject()
|
|
|
+ params = {'iccid': iccid}
|
|
|
+ result = dx_iot.get_cards_info('v3', **params)
|
|
|
+ assert result['code'] == '200'
|
|
|
+ return True
|
|
|
+ except Exception as e:
|
|
|
+ print(repr(e))
|
|
|
+ return False
|
|
|
+
|
|
|
@classmethod
|
|
|
def check_iccid(cls, iccid):
|
|
|
"""
|