|
@@ -129,7 +129,7 @@ class UnicomComboView(View):
|
|
|
flow_details['usableFlow'] = 0 if flow == 0 else flow
|
|
|
flow_details['usableFlow'] = \
|
|
|
flow_details['flowTotal'] if flow_details['usableFlow'] > flow_details['flowTotal'] else \
|
|
|
- flow_details['usableFlow']
|
|
|
+ flow_details['usableFlow']
|
|
|
flow_details['usableFlow'] = Decimal(flow_details['usableFlow']).quantize(Decimal('0.00'))
|
|
|
flow_details.pop('flowTotalUsage')
|
|
|
cls.update_combo_order_sort(iccid)
|
|
@@ -707,10 +707,17 @@ class UnicomComboView(View):
|
|
|
|
|
|
elif unicom_combo['expiration_type'] == 0:
|
|
|
days = unicom_combo['expiration_days']
|
|
|
- zero_today, end_time = cls.get_data_time(days)
|
|
|
- combo_order_data['activation_time'] = now_time
|
|
|
- combo_order_data['expire_time'] = end_time
|
|
|
- # 联通业务逻辑
|
|
|
+ if activate_type == 1:
|
|
|
+ combo_order_data['next_month_activate'] = True
|
|
|
+ start_time, end_time = cls.get_times(days)
|
|
|
+ combo_order_data['activation_time'] = start_time
|
|
|
+ combo_order_data['expire_time'] = end_time
|
|
|
+ combo_order_data['status'] = 0
|
|
|
+ else:
|
|
|
+ zero_today, end_time = cls.get_data_time(days)
|
|
|
+ combo_order_data['activation_time'] = now_time
|
|
|
+ combo_order_data['expire_time'] = end_time
|
|
|
+ # 调用联通API查询物联卡是否已激活,未激活则修改为激活状态
|
|
|
unicom_api = UnicomObjeect()
|
|
|
if status == 1:
|
|
|
unicom_api.change_device_to_activate(iccid)
|
|
@@ -754,6 +761,19 @@ class UnicomComboView(View):
|
|
|
'%Y-%m-%d')
|
|
|
return zero_today, end_time
|
|
|
|
|
|
+ @staticmethod
|
|
|
+ def get_times(days_after):
|
|
|
+ """
|
|
|
+ 获取下月开始时间与指定天数后结束时间
|
|
|
+ @return:
|
|
|
+ """
|
|
|
+ next_start_time, end_time = UnicomComboView.get_next_month_data_time()
|
|
|
+ after_time = LocalDateTimeUtil.get_after_days_timestamp(next_start_time, days_after)
|
|
|
+ time_array = time.localtime(after_time)
|
|
|
+ start_time, end_time = LocalDateTimeUtil.get_start_and_end_time(time.strftime("%Y-%m-%d", time_array),
|
|
|
+ '%Y-%m-%d')
|
|
|
+ return next_start_time, end_time
|
|
|
+
|
|
|
@staticmethod
|
|
|
def get_month_start_and_end_time():
|
|
|
"""
|