|
@@ -17,11 +17,13 @@ from django.views.generic.base import View
|
|
|
|
|
|
from Ansjer.config import PAYPAL_CRD
|
|
from Ansjer.config import PAYPAL_CRD
|
|
from Controller.Cron.CronTaskController import CronUpdateDataView
|
|
from Controller.Cron.CronTaskController import CronUpdateDataView
|
|
|
|
+from Controller.UnicomCombo.UnicomComboTaskController import UnicomComboTaskView
|
|
from Model.models import VodBucketModel, CDKcontextModel, Store_Meal, Order_Model, \
|
|
from Model.models import VodBucketModel, CDKcontextModel, Store_Meal, Order_Model, \
|
|
UID_Bucket, ExperienceContextModel, Lang, CloudLogModel, UidSetModel, Unused_Uid_Meal, \
|
|
UID_Bucket, ExperienceContextModel, Lang, CloudLogModel, UidSetModel, Unused_Uid_Meal, \
|
|
Device_Info, DeviceTypeModel, UnicomComboOrderInfo, AiService
|
|
Device_Info, DeviceTypeModel, UnicomComboOrderInfo, AiService
|
|
from Object.ResponseObject import ResponseObject
|
|
from Object.ResponseObject import ResponseObject
|
|
from Object.TokenObject import TokenObject
|
|
from Object.TokenObject import TokenObject
|
|
|
|
+from Object.UnicomObject import UnicomObjeect
|
|
from Service.CommonService import CommonService
|
|
from Service.CommonService import CommonService
|
|
|
|
|
|
|
|
|
|
@@ -1596,13 +1598,28 @@ class serveManagement(View):
|
|
# return response.json(10059) # 未使用套餐类型重复
|
|
# return response.json(10059) # 未使用套餐类型重复
|
|
# 联通4G套餐
|
|
# 联通4G套餐
|
|
if orderType == '2' and payType != '10':
|
|
if orderType == '2' and payType != '10':
|
|
- return response.json(10059)
|
|
|
|
- # unicom_combo_order_info_qs = UnicomComboOrderInfo.objects.filter(order_id=orderID & ~Q(status=2)).values(
|
|
|
|
- # 'expire_time')
|
|
|
|
- # if not unicom_combo_order_info_qs.exists():
|
|
|
|
- # return response.json(173)
|
|
|
|
- # unicom_combo_order_info_qs.update(expire_time=nowTime)
|
|
|
|
- # return response.json(0)
|
|
|
|
|
|
+ now_time = int(time.time())
|
|
|
|
+ combo_info_qs = UnicomComboOrderInfo.objects.filter(~Q(status=2), order_id=orderID)
|
|
|
|
+ if not combo_info_qs.exists():
|
|
|
|
+ return response.json(10059)
|
|
|
|
+ iccid = combo_info_qs.first().iccid
|
|
|
|
+ combo_info_qs.update(status=2, updated_time=now_time)
|
|
|
|
+ combo_info_qs = UnicomComboOrderInfo.objects.filter(status=1)
|
|
|
|
+ if combo_info_qs:
|
|
|
|
+ return response.json(10059)
|
|
|
|
+ unicom_api = UnicomObjeect()
|
|
|
|
+ usage_flow = unicom_api.get_flow_usage_total(iccid)
|
|
|
|
+ today = datetime.datetime.today()
|
|
|
|
+ year = today.year
|
|
|
|
+ month = today.month
|
|
|
|
+ task_view = UnicomComboTaskView()
|
|
|
|
+ result = task_view.query_unused_combo_and_activate(iccid, year, month, usage_flow)
|
|
|
|
+ if not result:
|
|
|
|
+ # 停用设备
|
|
|
|
+ unicom_api.change_device_to_disable(iccid)
|
|
|
|
+ else:
|
|
|
|
+ unicom_api.change_device_to_activate(iccid)
|
|
|
|
+ return response.json(0)
|
|
return response.json(173)
|
|
return response.json(173)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
print(e)
|
|
print(e)
|