zhangdongming 3 жил өмнө
parent
commit
7c8eca2682

+ 8 - 4
Controller/UnicomCombo/UnicomComboController.py

@@ -476,7 +476,11 @@ class UnicomComboView(View):
                 if unicom_combo_qs.exists():
                 if unicom_combo_qs.exists():
                     unicom_combo = unicom_combo_qs.first()
                     unicom_combo = unicom_combo_qs.first()
                     now_time = int(time.time())
                     now_time = int(time.time())
-                    combo_order_data = {'iccid': iccid, 'status': 0, 'combo_id': int(combo_id),
+                    combo_order_qs = UnicomComboOrderInfo.objects.filter(status=1, iccid=iccid)
+                    status = 0
+                    if not combo_order_qs.exists():
+                        status = 1
+                    combo_order_data = {'iccid': iccid, 'status': status, 'combo_id': int(combo_id),
                                         'updated_time': now_time,
                                         'updated_time': now_time,
                                         'created_time': now_time}
                                         'created_time': now_time}
                     if order_id:
                     if order_id:
@@ -489,18 +493,18 @@ class UnicomComboView(View):
                             next_start_time, end_time = cls.get_next_month_data_time()
                             next_start_time, end_time = cls.get_next_month_data_time()
                             combo_order_data['activation_time'] = next_start_time
                             combo_order_data['activation_time'] = next_start_time
                             combo_order_data['expire_time'] = end_time
                             combo_order_data['expire_time'] = end_time
+                            combo_order_data['status'] = 0
                         else:
                         else:
+                            zero_today, last_today = LocalDateTimeUtil.get_today_date(True)
                             start_time, month_end_time = cls.get_month_start_and_end_time()
                             start_time, month_end_time = cls.get_month_start_and_end_time()
-                            combo_order_data['activation_time'] = start_time
+                            combo_order_data['activation_time'] = zero_today
                             combo_order_data['expire_time'] = month_end_time
                             combo_order_data['expire_time'] = month_end_time
-                            combo_order_data['status'] = 1
 
 
                     elif unicom_combo['expiration_type'] == 0:
                     elif unicom_combo['expiration_type'] == 0:
                         days = unicom_combo['expiration_days']
                         days = unicom_combo['expiration_days']
                         zero_today, end_time = cls.get_data_time(days)
                         zero_today, end_time = cls.get_data_time(days)
                         combo_order_data['activation_time'] = zero_today
                         combo_order_data['activation_time'] = zero_today
                         combo_order_data['expire_time'] = end_time
                         combo_order_data['expire_time'] = end_time
-                        combo_order_data['status'] = 1
                     UnicomComboOrderInfo.objects.create(**combo_order_data)
                     UnicomComboOrderInfo.objects.create(**combo_order_data)
                     logger.info('保存信息success')
                     logger.info('保存信息success')
                 return True
                 return True