コード例 #1
0
def mobile_code(request, phone):
    import re
    from Autotest_platform.helper.connectMySql import SqL

    patt = re.compile('^1[3-8]\d{9}$')
    ver = patt.findall(str(phone))
    if not ver:
        return JsonResponse.AbnormalCheck('手机号输入不符合规则,请重新输入!')
    sql = SqL(job=True)
    try:
        msg = sql.execute_sql(
            'select app_sign, mobile, params from sms_message where mobile= "{}" order by id desc limit 1;'
            .format(phone),
            num=2)
        msg_list = msg.split(',')
        log.info('返回值:{}'.format(msg_list))
        data = {
            "商户": msg_list[0],
            "手机号": msg_list[1],
            "短信内容": msg_list[2],
        }
        if msg:
            return JsonResponse.OK(data=data)
    except Exception as e:
        return JsonResponse.ServerError('手机号:{} 查询验证码失败!{}'.format(phone, e))
コード例 #2
0
def set_balance(request, phone):
    import re
    from Autotest_platform.helper.connectMySql import SqL

    patt = re.compile('^1[3-8]\d{9}$')
    ver = patt.findall(str(phone))
    if not ver:
        return JsonResponse.AbnormalCheck('手机号输入不符合规则,请重新输入!')
    balance = request.GET.get('balance', '')
    patt1 = re.compile('^\d{3,9}$')
    ver1 = patt1.findall(str(balance))
    if not ver1:
        return JsonResponse.AbnormalCheck('输入的余额不符合规则,请重新输入!')
    sql = SqL()
    try:
        easy_agent_id = sql.execute_sql(
            'SELECT easy_agent_id FROM easy_agent WHERE phone = "{}";'.format(
                phone))
        msg = sql.execute_sql(
            'update easy_agent_account set balance= "{}" where easy_agent_id = "{}";'
            .format(balance, easy_agent_id))
        log.info('返回值:{}, {}'.format(easy_agent_id, msg))
        if not msg:
            return JsonResponse.OK(
                data='用户:{} 设置余额:{} 成功!'.format(phone, balance))
    except Exception as e:
        return JsonResponse.ServerError('用户:{} 设置余额出现错误!{}'.format(phone, e))
コード例 #3
0
def team_apply(request, tid):
    if request.method == 'POST':
        apply_id = request.POST.get('apply_id')
        tu = get_model(TeamUsers, get=False, id=apply_id)
        tu.update(status=1)
        return JsonResponse.OK()
    tu = TeamUsers.objects.filter(team_id=tid).filter(status=0)
    return render(request, 'team/apply.html', {'join': tu, 'tid': tid})
コード例 #4
0
def team_go(request):
    if request.method == 'POST':
        tid = request.POST.get('tid')
        user_id = request.session['user_id']
        t = TeamUsers.objects.filter(team_id=tid).filter(user_id=user_id)
        status = 0
        if len(t) == 1:
            status = t[0].status
        return JsonResponse.AbnormalCheck('要先加入团队才能进入撒~~~',
                                          data={'status': status})
コード例 #5
0
def change_password(request):
    '''
    修改密码
    :param request:
    :return:
    '''
    if request.method == 'POST':
        new_password = request.POST.get('new_password', '')
        user = request.POST.get('user', '')

        msg = change_info_logic(new_password)
        if msg != 'ok':
            log.error('change password error:{}'.format(msg))
            return JsonResponse({'msg': msg})
        else:
            user = User.objects.get(username=user)
            user.set_password(new_password)
            user.save()
            log.info('用户:{} 修改密码为 {}'.format(user, new_password))
            return JsonResponse({'msg': 'success'})
コード例 #6
0
def team_join(request):
    if request.method == 'GET':
        return render(request, 'team/apply.html')
    else:
        tid = request.POST.get('tid', '')
        super_id = get_model(Team, id=tid).creator_id
        user_id = request.session.get('user_id', 0)
        if user_id == 0:
            return JsonResponse.AbnormalCheck('登录过期了呢,请重新登录~~~')
        if super_id != user_id:
            status = 0
            tus = TeamUsers.objects.filter(team_id=tid).filter(user_id=user_id)
            if tus:
                for t in tus:
                    status = t.status
                if status == 0:
                    return JsonResponse.AbnormalCheck('申请已提交,等待管理员审核中~~~')
                else:
                    return JsonResponse.OK('申请已通过,赶快进入体验吧~~~')
            else:
                tu = TeamUsers()
                tu.team = get_model(Team, id=tid)
                tu.user = get_model(User, id=user_id)
                try:
                    tu.save()
                except Exception as e:
                    return JsonResponse.AbnormalCheck('申请失败!{}'.format(e))
                return JsonResponse.OK('申请成功,等待管理员审核中~~~')
        else:
            return JsonResponse.SkipLink()
コード例 #7
0
def delete_customer(request, phone):
    import re
    from Autotest_platform.helper.connectMySql import SqL

    patt = re.compile('^1[3-8]\d{9}$')
    ver = patt.findall(str(phone))
    if not ver:
        return JsonResponse.AbnormalCheck('手机号输入不符合规则,请重新输入!')
    patt_c = re.compile('\d{1,4}')
    channel_id = request.GET.get('channel_id', 1)
    ver_c = patt_c.findall(str(channel_id))
    if not ver_c:
        return JsonResponse.AbnormalCheck('channel_id 输入不符合规则,请重新输入!')
    sql = SqL(job=True)
    sql_ = SqL()
    try:
        customer_id = sql.execute_sql(
            'SELECT id FROM customer WHERE phone = "{}" AND channel_id = "{}";'
            .format(phone, channel_id))
        msg1 = sql.execute_sql(
            'DELETE FROM wechat_user WHERE customer_id = "{}";'.format(
                customer_id))
        msg2 = sql.execute_sql(
            'DELETE FROM account WHERE customer_id = "{}";'.format(
                customer_id))
        msg3 = sql.execute_sql(
            'DELETE FROM customer_vip_info WHERE customer_id = "{}";'.format(
                customer_id))
        msg4 = sql.execute_sql(
            'DELETE FROM customer_attachment_info WHERE customer_id = "{}";'.
            format(customer_id))
        msg5 = sql.execute_sql(
            'DELETE FROM customer WHERE id = "{}";'.format(customer_id))
        msg6 = sql.execute_sql(
            'DELETE FROM balance_account WHERE account = "{}" AND channel_id = "{}";'
            .format(phone, channel_id))

        easy_agent_id = sql_.execute_sql(
            'SELECT easy_agent_id FROM easy_agent WHERE phone = "{}";'.format(
                phone))
        msg7 = sql_.execute_sql(
            'DELETE FROM easy_agent_account WHERE easy_agent_id  = "{}";'.
            format(easy_agent_id))
        msg8 = sql_.execute_sql(
            'DELETE FROM easy_agent WHERE easy_agent_id  = "{}";'.format(
                easy_agent_id))
        msg9 = sql_.execute_sql(
            'update customer_vip_info set vip_type_id = 1 where customer_id = "{}";'
            .format(customer_id))

        log.info(
            '返回值:customer_id ==》 {}, {}, {}, {}, {},{}, {}, {}, {}'.format(
                customer_id, msg1, msg2, msg3, msg4, msg5, msg6, msg7, msg8,
                msg9))
        if not msg1 and not msg2 and not msg3 and not msg4 and not msg5 and not msg6 and not msg7 and not msg8:
            return JsonResponse.OK(
                data='渠道:{} 删除用户:{} 成功!'.format(channel_id, phone))
        else:
            return JsonResponse.ServerError(msg1 + msg2 + msg3 + msg4 + msg5 +
                                            msg6 + msg7 + msg8)
    except Exception as e:
        return JsonResponse.ServerError('删除用户出现错误:{}'.format(e))