|
@@ -17,12 +17,11 @@ from Model.models import UnicomDeviceInfo, Order_Model, UnicomComboExperienceHis
|
|
|
from Object.Enums.WXOperatorEnum import WXOperatorEnum
|
|
|
from Object.Enums.WXStartTypeEnum import WXStartTypeEnum
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
-from Object.TokenObject import TokenObject
|
|
|
from Object.WXTechObject import WXTechObject
|
|
|
from Service.CommonService import CommonService
|
|
|
|
|
|
LOGGER = logging.getLogger('info')
|
|
|
-# 五兴科技 套餐编码 1G 15天流量包
|
|
|
+# 五兴科技电信套餐编码 1G-15天流量包
|
|
|
COMBO_ID = 'DX-DX-FDX-JCB-1G-15天-4DX-ASJ-YTC-AT-2022123020221230144615'
|
|
|
|
|
|
|
|
@@ -53,11 +52,12 @@ class WXTechController(View):
|
|
|
return self.validation(put, request, operation)
|
|
|
|
|
|
def validation(self, request_dict, request, operation):
|
|
|
- token = TokenObject(request.META.get('HTTP_AUTHORIZATION'))
|
|
|
- lang = request_dict.get('lang', token.lang)
|
|
|
- response = ResponseObject(lang)
|
|
|
- if token.code != 0:
|
|
|
- return response.json(token.code)
|
|
|
+ if operation == 'deleteCardPackage':
|
|
|
+ return self.delete_card_package(request_dict, ResponseObject('cn'))
|
|
|
+ token_code, user_id, response = CommonService \
|
|
|
+ .verify_token_get_user_id(request_dict, request)
|
|
|
+ if token_code != 0:
|
|
|
+ return response.json(token_code)
|
|
|
if operation == 'getCardsInfo':
|
|
|
return self.get_cards_info(request_dict, response)
|
|
|
elif operation == 'getExperiencePackage':
|
|
@@ -91,7 +91,7 @@ class WXTechController(View):
|
|
|
"""
|
|
|
try:
|
|
|
LOGGER.info('*****WXTechController.get_experience_package:params'.format(request_dict))
|
|
|
- serial_no = request_dict.get('serial_no', None)
|
|
|
+ serial_no = request_dict.get('serialNo', None)
|
|
|
if not serial_no:
|
|
|
return response.json(444)
|
|
|
# 查询是否注册iccid
|
|
@@ -123,7 +123,7 @@ class WXTechController(View):
|
|
|
"""
|
|
|
try:
|
|
|
LOGGER.info('*****WXTechController.create_order_package:params:{}'.format(request_dict))
|
|
|
- serial_no = request_dict.get('serial_no', None)
|
|
|
+ serial_no = request_dict.get('serialNo', None)
|
|
|
operator = request_dict.get('operator', None)
|
|
|
if not all([operator, serial_no]):
|
|
|
return response.json(444)
|
|
@@ -182,3 +182,31 @@ class WXTechController(View):
|
|
|
'trade_no': trade_no}
|
|
|
Order_Model.objects.create(**order_dict)
|
|
|
return True
|
|
|
+
|
|
|
+ @classmethod
|
|
|
+ def delete_card_package(cls, request_dict, response):
|
|
|
+ """
|
|
|
+ PC工具清空卡片的所有套餐订购记录
|
|
|
+ """
|
|
|
+ try:
|
|
|
+ LOGGER.info('*****WXTechController.delete_card_package:params:{}'.format(request_dict))
|
|
|
+ sign = request_dict.get('sign', None)
|
|
|
+ serial_no = request_dict.get('serialNo', None)
|
|
|
+ time_stamp = request_dict.get('timeStamp', None)
|
|
|
+ if not CommonService.check_time_stamp_token(sign, time_stamp):
|
|
|
+ return response.json(13)
|
|
|
+ # 查询是否注册iccid
|
|
|
+ unicom_device_qs = UnicomDeviceInfo.objects.filter(serial_no=serial_no) \
|
|
|
+ .values('serial_no', 'user_id', 'iccid')
|
|
|
+ if not unicom_device_qs.exists():
|
|
|
+ return response.json(173)
|
|
|
+ data = {'iccids': unicom_device_qs[0]['iccid'], 'operator': WXOperatorEnum.TELECOM.value}
|
|
|
+ wx_tech = WXTechObject()
|
|
|
+ res = wx_tech.delete_card_package(**data)
|
|
|
+ if res['code'] == '0':
|
|
|
+ return response.json(0)
|
|
|
+ return response.json(177)
|
|
|
+ except Exception as e:
|
|
|
+ LOGGER.info('*****WXTechController.delete_card_package:errLine:{}, errMsg:{}'
|
|
|
+ .format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+ return response.json(500, repr(e))
|