Exemple #1
0
def task_send(info):
    """

    :param info:
    :return:
    """
    if info.i001_status not in [0, 2]:
        return

    sign = md5_sign(info)
    real_number = internal_2_normal(info.number)
    data = {
        'name': des_data(info.name),
        'phone': des_data(real_number),
        'channel': channel,
        'subchannel': subchannel,
        'customer_ip': info.ip,
        'sign': sign,
        'id_no': des_data(info.identification)
    }
    try:
        r = requests.get(url, data, timeout=5)
        ret = r.json()
        # print('rr', ret)
        ServiceEvent(info.number).ret_heiniu(ret)
        if ret['error_code'] is '0':
            info.i001_status = 3
        else:
            info.i001_status = 2
        info.save(update_fields=('i001_status', ))
        # print('ret i', info.i001_status)
        return info.i001_status

    except:
        raise HeiNiuError('heiniu', '黑牛接口错误')
Exemple #2
0
def handle_jsondata(data):
    if data.c001_status not in [0, 2]:
        return
    real_number = internal_2_normal(data.number)
    if data.amount_weilidai == 0:
        weilidai = 'N'
    else:
        weilidai = 'Y'

    data.c001_status = 1
    data.save(update_fields=('c001_status', ))
    ret = api_send(name=data.name,
                   mobile=real_number,
                   sex=data.sex,
                   birth=data.birth,
                   credit=data.credit_choice,
                   amount=data.amount,
                   policy=data.has_insurance,
                   weilidai=weilidai,
                   house=data.has_house,
                   car=data.has_car,
                   occupation=data.job,
                   salary=data.salary,
                   experience=data.seniority,
                   way=data.way,
                   fund=data.local_fund,
                   license=data.license,
                   customer_ip=data.ip)
    if ret:
        data.c001_status = 3
    else:
        data.c001_status = 2
    data.save(update_fields=('c001_status', ))
    return ret
Exemple #3
0
    def post(self, request):
        serializer = InterNumberSerializer(data=request.data)
        serializer.is_valid(raise_exception=True)
        data = serializer.validated_data

        token = request.token_data
        number = token['number']
        cm, created = CollectionsModel.objects.get_or_create(number=number,
                                                             defaults=data)
        url = API_MOBILE_HIT.format('hit_longfq', number)
        data['number'] = number
        r = requests.get(url, data)
        hit = r.json()['hit']
        ret = {'review': False}  # False 未通过审核
        if not hit:
            try:
                res = send_long_fen_qi(internal_2_normal(number), data['name'],
                                       data['identification'],
                                       str(data['amount']),
                                       str(data['period']))
                os = request.get_os()
                # print('res', res)
                if os == 'ios':
                    ret['url'] = res.get('ios')
                else:
                    ret['url'] = res.get('android')
                ret['review'] = True if ret['url'] else False
                cm.c004_status = 3
                cm.save(update_fields=['c004_status'])
            except:
                add_log_count('jiemisc_collects_longfenqi_send')
                traceback.print_exc()
                cm.c004_status = 2
                cm.save(update_fields=['c004_status'])
                raise ValidationError({'msg': '服务器暂时不可用,请稍后重试'})

        return Response(ret)
Exemple #4
0
def md5_sign(info):
    real_number = internal_2_normal(info.number)
    to_sign = info.identification + info.name + real_number + channel + "baoxian-$@"
    hash_md5 = hashlib.md5(to_sign.encode('utf-8'))
    sign = hash_md5.hexdigest()
    return sign
Exemple #5
0
def task_send(info):
    city_py = ''
    for cp in city_pinyin:
        if cp['city'] == info.city:
            city_py = cp['pinyin']

    if not city_py:
        return

    if info.c003_status not in [0, 2]:
        return

    time_str = datetime.now().strftime('%Y%m%d%H:%M:%S')
    real_number = internal_2_normal(info.number)

    if info.job == '自由职业':
        job_info = 8
    elif info.job == '企业员工':
        job_info = 4
    elif info.job == '个体户':
        job_info = 2
    else:
        return

    income_all = info.income_bank + info.income_month
    if income_all < 4000:
        income_i = 4000
    elif income_all < 5000:
        income_i = 4500
    elif income_all < 10000:
        income_i = 7500
    else:
        income_i = 10000

    if info.local_social_security == '是' and info.local_fund == '是':
        security = 2
    elif info.local_social_security == '是' and info.local_fund == '否':
        security = 4
    elif info.local_social_security == '否' and info.local_fund == '是':
        security = 8
    else:
        security = 1

    if info.has_creditcard == '是':
        creditcard = 1
    else:
        creditcard = 0

    if info.has_house == '有':
        house = 1
    else:
        house = 0

    if info.has_car == '有':
        car = 1
    else:
        car = 0

    info.c003_status = 1
    info.save(update_fields=('c003_status', ))
    ret = api_send(amount=info.amount,
                   number=real_number,
                   gender=info.gender,
                   name=info.name,
                   city_py=city_py,
                   time_str=time_str,
                   job_info=job_info,
                   income_i=income_i,
                   security=security,
                   creditcard=creditcard,
                   house=house,
                   car=car)

    if ret:
        info.c003_status = 3
    else:
        info.c003_status = 2
    info.save(update_fields=('c003_status', ))
    return info.c003_status