禁用除新订单服务号广播外的所有 Celery/Beat 任务,仅保留 dingdan_guangbo
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -61,8 +61,22 @@ ensure_redis_loaded()
|
||||
@receiver(pre_save, sender='dingdan.Dingdan')
|
||||
def handle_order_status_8(sender, instance, **kwargs):
|
||||
"""
|
||||
订单状态变为8时,提交定时任务
|
||||
订单状态变为8时,提交定时任务(已禁用:仅保留新订单广播)
|
||||
"""
|
||||
if getattr(settings, 'CELERY_ONLY_ORDER_BROADCAST', True):
|
||||
if instance.pk is None:
|
||||
return
|
||||
try:
|
||||
from dingdan.models import Dingdan
|
||||
old = Dingdan.objects.filter(pk=instance.pk).values_list('zhuangtai', flat=True).first()
|
||||
if old == 8 and instance.zhuangtai != 8:
|
||||
instance.status_8_time = None
|
||||
instance.pending_dispatch = False
|
||||
instance.auto_task_id = ''
|
||||
except Exception as e:
|
||||
logger.error(f"信号处理失败: {e}")
|
||||
return
|
||||
|
||||
# 跳过新增的订单
|
||||
if instance.pk is None:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user