# -*- coding: utf-8 -*- # !/usr/bin/env python import logging from apps.web.merchant.models import MerchantSourceInfo from apps.web.merchant.utils import MerchantApplyProxy from apps.web.merchant.constant import MerchantStatus logger = logging.getLogger(__name__) def query_merchant_status(): """ 申请开通京东的产品 """ # 查询出所有 审核中的商户 merchantIds = MerchantSourceInfo.objects.filter(status__in=[ int(MerchantStatus.WAITING), ] ).only("status", "id") for _m in merchantIds: _mer = MerchantSourceInfo.objects.get(id=_m.id) try: MerchantApplyProxy(_mer).query_merchant_audit() except Exception as e: logger.exception("[tasks_query_merchant_status_query_merchant_audit], merchantId = _{}, error = {}".format(_m, e)) # 查询出状态为 confirm(有可能程序中断的) merchantIds = MerchantSourceInfo.objects.filter(status__in=[ int(MerchantStatus.CONFIRM), ] ).only("status", "id") for _m in merchantIds: _mer = MerchantSourceInfo.objects.get(id=_m.id) proxy = MerchantApplyProxy(_mer) try: proxy.submit_auth() except Exception as e: logger.exception("[tasks_query_merchant_status_submit_auth], merchantId = _{}, error = {}".format(_m, e)) # 查询出说有提交了资料的 进行查询 merchantIds = MerchantSourceInfo.objects.filter(status__in=[ int(MerchantStatus.AUTH_WAITING), ] ).only("status", "id") for _m in merchantIds: _mer = MerchantSourceInfo.objects.get(id=_m.id) proxy = MerchantApplyProxy(_mer) try: proxy.query_auth_audit() except Exception as e: logger.exception("[tasks_query_merchant_status_submit_auth], merchantId = _{}, error = {}".format(_m, e))