|
@@ -52,15 +52,15 @@ class UnicomComboView(View):
|
|
return HttpResponse('SUCCESS')
|
|
return HttpResponse('SUCCESS')
|
|
elif operation == 'device-queue-monitoring':
|
|
elif operation == 'device-queue-monitoring':
|
|
return self.device_queue_monitoring_push(request_dict, request)
|
|
return self.device_queue_monitoring_push(request_dict, request)
|
|
- elif operation == 'device-status-change':
|
|
|
|
|
|
+ elif operation == 'device-status-change': # SIM卡修改状态,异步通知接口
|
|
return self.device_status_change_push(request_dict, request)
|
|
return self.device_status_change_push(request_dict, request)
|
|
- elif operation == 'device-bind':
|
|
|
|
|
|
+ elif operation == 'device-bind': # 服务器保存设备的ICCID
|
|
return self.device_add(request_dict, response)
|
|
return self.device_add(request_dict, response)
|
|
- elif operation == 'device-status':
|
|
|
|
|
|
+ elif operation == 'device-status': # PC调用解绑SIM卡用户
|
|
return self.update_device_status(request_dict, response)
|
|
return self.update_device_status(request_dict, response)
|
|
- elif operation == 'update-card':
|
|
|
|
|
|
+ elif operation == 'update-card': # 更新SIM类型
|
|
return self.update_device_card_type(request_dict, response)
|
|
return self.update_device_card_type(request_dict, response)
|
|
- elif operation == 'xxx-sign':
|
|
|
|
|
|
+ elif operation == 'xxx-sign': # 获取签名用于测试
|
|
return self.get_test_sign(request_dict, response)
|
|
return self.get_test_sign(request_dict, response)
|
|
else:
|
|
else:
|
|
token = TokenObject(request.META.get('HTTP_AUTHORIZATION'))
|
|
token = TokenObject(request.META.get('HTTP_AUTHORIZATION'))
|
|
@@ -69,16 +69,18 @@ class UnicomComboView(View):
|
|
if token.code != 0:
|
|
if token.code != 0:
|
|
return response.json(token.code)
|
|
return response.json(token.code)
|
|
user_id = token.userID
|
|
user_id = token.userID
|
|
- if operation == 'combo-save':
|
|
|
|
|
|
+ if operation == 'combo-save': # 创建套餐
|
|
return self.save_unicom_combo(request_dict, response)
|
|
return self.save_unicom_combo(request_dict, response)
|
|
- elif operation == 'combo-pay':
|
|
|
|
|
|
+ elif operation == 'combo-pay': # 套餐支付
|
|
return self.buy_unicom_combo(user_id, request_dict, request, response)
|
|
return self.buy_unicom_combo(user_id, request_dict, request, response)
|
|
- elif operation == 'combo-list':
|
|
|
|
|
|
+ elif operation == 'combo-list': # 获取套餐列表
|
|
return self.query_package_list(response)
|
|
return self.query_package_list(response)
|
|
- elif operation == 'get-device-info':
|
|
|
|
|
|
+ elif operation == 'get-device-info': # 获取SIM卡信息
|
|
return self.get_device_info(request_dict, response)
|
|
return self.get_device_info(request_dict, response)
|
|
- elif operation == 'user-combo-query':
|
|
|
|
|
|
+ elif operation == 'user-combo-query': # 用户套餐信息查询
|
|
return self.user_combo_query(user_id, request_dict, response)
|
|
return self.user_combo_query(user_id, request_dict, response)
|
|
|
|
+ else:
|
|
|
|
+ return response.json(0)
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
def user_combo_query(cls, user_id, request_dict, response):
|
|
def user_combo_query(cls, user_id, request_dict, response):
|
|
@@ -96,9 +98,9 @@ class UnicomComboView(View):
|
|
unicom_device_info_qs = UnicomDeviceInfo.objects.filter(iccid=iccid)
|
|
unicom_device_info_qs = UnicomDeviceInfo.objects.filter(iccid=iccid)
|
|
if not unicom_device_info_qs.exists():
|
|
if not unicom_device_info_qs.exists():
|
|
return response.json(173)
|
|
return response.json(173)
|
|
- now_time = int(time.time())
|
|
|
|
- if not unicom_device_info_qs[0].user_id:
|
|
|
|
- unicom_device_info_qs.update(user_id=user_id, updated_time=now_time)
|
|
|
|
|
|
+ if not unicom_device_info_qs[0].user_id: # 用户SIM卡未绑定用户则进行自动绑定
|
|
|
|
+ serial_no = unicom_device_info_qs[0].serial_no
|
|
|
|
+ cls.experience_order_4G(iccid, serial_no, user_id) # 生成4G体验订单
|
|
unicom_api = UnicomObjeect()
|
|
unicom_api = UnicomObjeect()
|
|
combo_order_qs = UnicomComboOrderInfo.objects.filter(iccid=iccid, status=1, is_del=False) \
|
|
combo_order_qs = UnicomComboOrderInfo.objects.filter(iccid=iccid, status=1, is_del=False) \
|
|
.values('iccid', 'status', 'combo__status', 'combo__combo_name', 'combo__combo_type',
|
|
.values('iccid', 'status', 'combo__status', 'combo__combo_name', 'combo__combo_type',
|
|
@@ -141,10 +143,51 @@ class UnicomComboView(View):
|
|
cls.update_combo_order_sort(iccid)
|
|
cls.update_combo_order_sort(iccid)
|
|
return response.json(0, flow_details)
|
|
return response.json(0, flow_details)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- print(e.args)
|
|
|
|
- ex = traceback.format_exc()
|
|
|
|
- print(ex)
|
|
|
|
- return response.json(177, ex)
|
|
|
|
|
|
+ logging.info('异常错误,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
+ return response.json(177, e)
|
|
|
|
+
|
|
|
|
+ @classmethod
|
|
|
|
+ def experience_order_4G(cls, icc_id, serial_no, user_id):
|
|
|
|
+ """
|
|
|
|
+ 保存订单信息
|
|
|
|
+ @param icc_id: SIM卡20位iccid
|
|
|
|
+ @param serial_no: 序列号
|
|
|
|
+ @param user_id: userID
|
|
|
|
+ @return: True | False
|
|
|
|
+ """
|
|
|
|
+ try:
|
|
|
|
+ while transaction.atomic():
|
|
|
|
+ n_time = int(time.time())
|
|
|
|
+ # 获取套餐信息
|
|
|
|
+ combo_info_qs = UnicomCombo.objects.filter(combo_type=1, status=0, is_del=False) \
|
|
|
|
+ .values('id', 'combo_name', 'price', 'virtual_price', 'remark').order_by('sort')
|
|
|
|
+ if not combo_info_qs.exists():
|
|
|
|
+ return False
|
|
|
|
+ combo_info_vo = combo_info_qs[0]
|
|
|
|
+ # 获取套餐订单信息
|
|
|
|
+ combo_order_qs = UnicomComboOrderInfo.objects.filter(iccid=icc_id, combo_id=combo_info_vo['id'])
|
|
|
|
+ if not combo_order_qs.exists():
|
|
|
|
+ return False
|
|
|
|
+ c_time = combo_order_qs[0].created_time
|
|
|
|
+ # 根据序列号获取UID
|
|
|
|
+ uid = CommonService.query_uid_with_serial(serial_no)
|
|
|
|
+ order_id = CommonService.createOrderID()
|
|
|
|
+ rank_id, ai_rank_id = cls.get_cloud_or_ai_combo() # 生成订单必须添加该字段
|
|
|
|
+ order_dict = {'orderID': order_id, 'UID': uid, 'rank_id': rank_id, 'ai_rank_id': ai_rank_id,
|
|
|
|
+ 'userID_id': user_id, 'desc': combo_info_vo['combo_name'], 'payType': 10,
|
|
|
|
+ 'payTime': c_time, 'price': combo_info_vo['price'], 'addTime': c_time,
|
|
|
|
+ 'updTime': c_time, 'status': 1,
|
|
|
|
+ 'unify_combo_id': str(combo_info_vo['id']), 'order_type': 2,
|
|
|
|
+ 'store_meal_name': combo_info_vo['combo_name']
|
|
|
|
+ }
|
|
|
|
+ Order_Model.objects.create(**order_dict)
|
|
|
|
+ combo_order_qs.update(order_id=order_id)
|
|
|
|
+ UnicomDeviceInfo.objects.filter(iccid=icc_id).update(user_id=user_id, updated_time=n_time)
|
|
|
|
+ return True
|
|
|
|
+ except Exception as e:
|
|
|
|
+ print('生成4G体验订单异常,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
+ logging.info('生成4G体验订单异常,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
+ return False
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
def get_combo_order_list(cls, iccid):
|
|
def get_combo_order_list(cls, iccid):
|