Beispiel #1
0
def divide_the_customer_work(handle_info_to_task, count):
    SalecountNum_str = getConstantsVale('smsNum')
    if SalecountNum_str is None:
        SalecountNum_str = 250
    SalecountNum = int(SalecountNum_str)
    # -----------------work_two------------------------
    SalecountNum_two_str = getConstantsVale('smsNewNum')
    if SalecountNum_two_str is None:
        SalecountNum_two_str = 250
    SalecountNum_two = int(SalecountNum_two_str)
    SalecountNum_three_str = getConstantsVale('smsRemoteNum')
    if SalecountNum_three_str is None:
        SalecountNum_three_str = 250
    SalecountNum_three = int(SalecountNum_three_str)
    # -----------------work_two------------------------
    saleUser, date_from, date_to, date_from_two, date_to_two = handle_info_to_task
    handleCity = getHandleCityList()
    filterCity = getFilterCityList()
    # 根据城市分配
    frcDatas = FormRegionCity.objects.all()
    if frcDatas.exists():
        for frcData in frcDatas:
            if frcData.name in handleCity:
                work_two(frcData, saleUser, date_from, date_to, date_from_two,
                         date_to_two, SalecountNum_two, count)
            elif frcData.name == '远程':
                work_three(filterCity, saleUser, date_from, date_to,
                           date_from_two, date_to_two, SalecountNum_three,
                           count)
            else:
                work_one(frcData, saleUser, date_from, date_to, date_from_two,
                         date_to_two, SalecountNum, count)
def get_normal_sale_time():
    handleMonth = getConstantsVale('handleMonth')
    if handleMonth is None:
        handleMonth = 7
    date_from = getConstantsVale('dateForm')
    if date_from is None:
        date_from = '2017-01-01 00:00:00'
    date_to = get_today()
    date_from_two = date_from
    date_to_two = str(
        true_month_handle(datetime.datetime.now(), int(handleMonth)))
    return date_from, date_to, date_from_two, date_to_two
Beispiel #3
0
def get_sale_info_to_task():
    date_from = getConstantsVale('dateForm')
    if date_from is None:
        date_from = '2017-01-01 00:00:00'
    date_to = get_today()
    handleMonth = getConstantsVale('handleMonth')
    if handleMonth is None:
        handleMonth = 7
    date_from_two = str(
        true_month_handle(datetime.datetime.now(), int(handleMonth)))
    date_to_two = get_today()
    saleUser = get_sale()
    return saleUser, date_from, date_to, date_from_two, date_to_two
def divide_sem_slae_work_new():
    date_from = getConstantsVale('dateForm')
    if date_from is None:
        date_from = '2017-01-01 00:00:00'
    date_to = get_before_oneweek()
    sem_info_num_str = getConstantsVale('smsNum')
    if sem_info_num_str is None:
        sem_info_num_str = str(250)
    sem_info_num = int(sem_info_num_str)
    dict = {}
    sem_sales = get_sale()
    citys = FormRegionCity.objects.all()
    if citys.exists():
        for city in citys:
            sem_sale_id = []
            if sem_sales.exists():
                for sem_sale in sem_sales:
                    if sem_sale.city.name == city.name:
                        sem_sale_id.append(sem_sale.id)
            if len(sem_sale_id) > 0:
                result_list = []
                num = len(sem_sale_id)
                limitNum = num * sem_info_num
                sem_datas = FormCustomer.objects.filter(
                    Q(sem_status=0),
                    Q(aike_status=0),
                    Q(create_time__range=(date_from, date_to))
                    | Q(create_time__isnull=True),
                    city__icontains=city.name,
                ).values('randid').order_by('level', '-randid',
                                            'create_time')[0:limitNum]
                # print(sem_datas.query)
                if sem_datas.exists():
                    sem_data_list = []
                    for sem_data in sem_datas:
                        sem_data_list.append(sem_data)
                    result_list = averageAssing(sem_data_list, num)
                if len(result_list) > 0:
                    count = 0
                    for id in sem_sale_id:
                        user = UserProfile.objects.get(id=id)
                        if not user is None:
                            dict[str(id) + user.username] = result_list[count]
                            count = count + 1
    return dict
Beispiel #5
0
def update_sem_level():
    print(
        "============================SEM:开始更新level标签================================"
    )
    date_from = getConstantsVale('dateForm')
    if date_from is None:
        date_from = '2017-01-01 00:00:00'
    date_to = get_before_oneweek()
    SEMInfoNum_str = getConstantsVale('smsNum')
    if SEMInfoNum_str is None:
        SEMInfoNum_str = str(250)
    SEMInfoNum = int(SEMInfoNum_str)

    sem_sale = get_sale()

    # 根据城市分配
    frcDatas = FormRegionCity.objects.all()
    if frcDatas.exists():
        for city in frcDatas:
            if sem_sale.exists():
                for sem in sem_sale:
                    sem_sale_id = []
                    if (sem.city == city):
                        sem_sale_id.append(sem.id)
                    if len(sem_sale_id) > 0:
                        num = len(sem_sale_id)
                        limitNum = num * SEMInfoNum
                        q = FormCustomer.objects.filter(
                            Q(sem_status=0),
                            Q(aike_status=0),
                            Q(create_time__range=(date_from, date_to))
                            | Q(create_time__isnull=True),
                            city=city).order_by('level', '-randid',
                                                'create_time')[0:limitNum]
                        # print(q.query)
                        if q.exists():
                            for qs in q:
                                u_l = FormCustomer.objects.get(id=qs.id)
                                u_l.level = u_l.level + 1
                                u_l.update_time = datetime.datetime.now()
                                u_l.save()
    print(
        "============================更新SEM的level标签结束================================"
    )
def getFilterCityList():
    filterCityStr = getConstantsVale('filterCity')
    filterCity = []
    if filterCityStr is None:
        filterCity = ['广州', '佛山', '深圳']
    else:
        for filter_city in filterCityStr.split(','):
            if filter_city:
                filterCity.append(filter_city)
    return filterCity
def getHandleCityList():
    handleCityStr = getConstantsVale('handleCity')
    handleCity = []
    if handleCityStr is None:
        handleCity = ['广州', '佛山']
    else:
        for handle_city in handleCityStr.split(','):
            if handle_city:
                handleCity.append(handle_city)
    return handleCity
Beispiel #8
0
def update_seo_level():
    # ORDER BY  level asc,create_date desc,rand_id desc limit 250
    print(
        "============================开始更新level标签================================"
    )
    SEOInfoNum_str = getConstantsVale('seoNum')
    if SEOInfoNum_str is None:
        SEOInfoNum_str = str(250)
    SEOInfoNum = int(SEOInfoNum_str)

    seo_sale = get_seo_sale()

    # 根据城市分配
    frcDatas = FormRegionCity.objects.all()
    if frcDatas.exists():
        for city in frcDatas:
            if seo_sale.exists():
                for seo in seo_sale:
                    seo_sale_id = []
                    if (seo.city == city):
                        seo_sale_id.append(seo.id)
                    if len(seo_sale_id) > 0:
                        num = len(seo_sale_id)
                        limitNum = num * SEOInfoNum
                        update_city = city.name
                        q = SEOCustomer.objects.filter(
                            Q(seo_status=0),
                            Q(aike_status=0),
                            Q(mobile_phone__isnull=False),
                            prefecture_level_city__icontains=update_city
                        ).order_by('level', '-create_date',
                                   '-rand_id')[0:limitNum]
                        # print(q.query)
                        if q.exists():
                            for qs in q:
                                u_l = SEOCustomer.objects.get(id=qs.id)
                                u_l.level = u_l.level + 1
                                u_l.update_date = datetime.datetime.now()
                                u_l.save()
    # 将无效资料的手机号置空
    SEOCustomer.objects.filter(seo_flag=0).update(mobile_phone=None)
    print(
        "============================更新level标签结束================================"
    )
def get_real_data_three(user_id, city_name, handle_time):
    check_time = str(get_today())
    BW = BackUpWork.objects.filter(user_id=user_id, create_time=check_time)
    if BW.exists():
        randid_list = []
        bw = BW[0]
        yy = FormCustomer.objects.raw(bw.sql_str)
        for y in yy:
            randid_list.append(y.randid)
        return randid_list
    else:
        date_from, date_to, date_from_two, date_to_two = handle_time
        SalecountNum_three_str = getConstantsVale('smsRemoteNum')
        if SalecountNum_three_str is None:
            SalecountNum_three_str = 250
        sem_info_num = int(SalecountNum_three_str)
        now_time = str(get_today())
        user_work = customerUser.objects.filter(user_id=user_id,
                                                create_time=now_time)
        randid_list = []
        city_list = getFilterCityList()
        need_city = Utils.getDutyArea(city_list)
        yesterdayRandIdList_two = getYesterdayRandIdList(user_id)
        if user_work.exists():
            q_randid = user_work[0].customer_id
            q_randid_list_data = FormCustomer.objects.filter(
                Q(randid__gte=q_randid),
                ~Q(randid__in=yesterdayRandIdList_two),
                Q(city__in=need_city),
                Q(discover_time__range=(date_from_two, date_to_two)),
                Q(create_time__range=(date_from, date_to))
                | Q(create_time__isnull=True),
                sem_status=0,
                aike_status=0).order_by('randid')[0:sem_info_num]
            # print(q_randid_list_data.query)
            if q_randid_list_data.exists():
                for qd in q_randid_list_data:
                    randid_list.append(qd.randid)
        return randid_list
Beispiel #10
0
def divide_seo_slae_work():
    seo_info_num_str = getConstantsVale('seoNum')
    if seo_info_num_str is None:
        seo_info_num_str = str(250)
    seo_info_num = int(seo_info_num_str)
    dict = {}
    seo_sales = get_seo_sale()
    citys = FormRegionCity.objects.all()
    if citys.exists():
        for city in citys:
            seo_sale_id = []
            if seo_sales.exists():
                for seo_sale in seo_sales:
                    if seo_sale.city.name == city.name:
                        seo_sale_id.append(seo_sale.id)
            if len(seo_sale_id) > 0:
                result_list = []
                num = len(seo_sale_id)
                limitNum = num * seo_info_num
                seo_datas = SEOCustomer.objects.filter(Q(seo_status=0), Q(aike_status=0),
                                                       Q(mobile_phone__isnull=False),
                                                       prefecture_level_city__icontains=city.name).values('rand_id'). \
                                order_by('level',
                                         '-create_date',
                                         '-rand_id'
                                         )[0:limitNum]
                if seo_datas.exists():
                    seo_data_list = []
                    for seo_data in seo_datas:
                        seo_data_list.append(seo_data)
                    result_list = averageAssing(seo_data_list, num)
                if len(result_list) > 0:
                    count = 0
                    for id in seo_sale_id:
                        user = UserProfile.objects.get(id=id)
                        if not user is None:
                            dict[str(id) + user.username] = result_list[count]
                            count = count + 1
    return dict
Beispiel #11
0
def getYesterdayRandIdList(user_id):
    dayNum = getConstantsVale('dayNum')
    if dayNum is None:
        dayNum = str(1)
    day_list = get_more_day_before(dayNum=int(dayNum))
    q = Q()
    q.connector = 'OR'
    for day in day_list:
        q.children.append(('create_time', str(day)))
    # create_time = str(get_yesterday())
    # BW = BackUpWork.objects.filter(user_id=user_id, create_time=create_time)
    BW = BackUpWork.objects.filter(q, user_id=user_id)
    # print(BW.query)
    randid_list = []
    if BW.exists():
        # bw = BW[0]
        for bw in BW:
            yy = FormCustomer.objects.raw(bw.sql_str)
            for y in yy:
                randid_list.append(y.randid)
    else:
        randid_list.append(999999)
    return randid_list
Beispiel #12
0
def get_real_data(user_id, city_name, handle_time):
    check_time = str(get_today())
    BW = BackUpWork.objects.filter(user_id=user_id, create_time=check_time)
    if BW.exists():
        randid_list = []
        bw = BW[0]
        yy = FormCustomer.objects.raw(bw.sql_str)
        for y in yy:
            randid_list.append(y.randid)
        return randid_list
    else:
        sem_info_num_str = getConstantsVale('smsNum')
        if sem_info_num_str is None:
            sem_info_num_str = str(250)
        sem_info_num = int(sem_info_num_str)
        date_from, date_to, date_from_two, date_to_two = handle_time
        now_time = str(get_today())
        user_work = customerUser.objects.filter(user_id=user_id,
                                                create_time=now_time)
        randid_list_yes = getYesterdayRandIdList(user_id)
        randid_list = []
        if user_work.exists():
            q_randid = user_work[0].customer_id
            q_randid_list_data = FormCustomer.objects.filter(
                Q(randid__gte=q_randid),
                ~Q(randid__in=randid_list_yes),
                Q(city=city_name),
                Q(discover_time__range=(date_from_two, date_to_two)),
                Q(create_time__range=(date_from, date_to))
                | Q(create_time__isnull=True),
                sem_status=0,
                aike_status=0).order_by('randid')[0:sem_info_num]
            # print(q_randid_list_data.query)
            if q_randid_list_data.exists():
                for qd in q_randid_list_data:
                    randid_list.append(qd.randid)
        return randid_list