Beispiel #1
0
def check_code():
    phone = request.args.get('phone')       #获取手机号
    if len(phone) == 11:
        res = eval(send_msg(phone))  # 发送验证码
        if res['Code'] == 'OK':
            api_logger.info("验证码已发送")
            code = r.get('MT'+phone).decode()
            return jsonify({'code': 200, 'msg': '验证码发送成功','data':code})
        else:
            api_logger.warning("手机号错误")
            return jsonify({'code': 207, 'msg': '2手机号错误请填写正确的手机号'})
    api_logger.warning("手机号错误")
    return jsonify({'code': 207, 'msg': '1请填写正确的手机号'})
Beispiel #2
0
def check_sms(u_phone, msg_code):
    res = None
    try:
        r_msg_code = r.get('msg' + u_phone)
        if not r_msg_code:
            return {'code': 203, 'msg': '短信验证码不存在,或已过期'}
        r_msg_code = r_msg_code.decode()
        if r_msg_code != msg_code:
            return {'code': 204, 'msg': '短信验证码输入错误'}
    except Exception as e:
        api_logger.error(e)
        res = {'code': 202, 'msg': '数据库查询失败'}
    return res
Beispiel #3
0
def check_sms(u_phone, msg_code):
    res = None
    try:
        r_msg_code = r.get('MT' + u_phone).decode()
        print(r_msg_code,'xxxxxxxxxxxxxxxx')
        if not r_msg_code:
            res = {'code': 207, 'msg': '短信验证码已过期'}
        if r_msg_code != msg_code:
            res = {'code': 207, 'msg': '短信验证码输入错误'}
    except Exception as e:
        res = {'code': 380, 'msg': '数据库查询失败 %s' % e}

    return res
Beispiel #4
0
def is_ok():
    args = eval(request.get_data())
    user_id = args.get("user_id")
    shop_id = args.get("shop_id")
    order_num = args.get("order_num")
    if r.exists(order_num):
        print(r.get(order_num).decode())
        user = userdao.get_profile(user_id)
        u_burse = user.get("u_burse_balance")
        total = float(r.get(order_num).decode())
        if u_burse < total:
            return jsonify({
                "code": 207,
                "msg": "您的余额不足,请先充值"
            })
        dic = {
            "order_detail_shop_id": shop_id,
            "order_detail_tel":  user.get("u_tel"),
            "order_detail_addr": "abc",
            "order_detail_time": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
            "order_price": total,
            "order_num": order_num
        }
        sql = "update users set u_burse_balance = %s where id = %s"
        userdao.query(sql, u_burse - total, user_id)
        dao.update("order_status", 1, "order_num", order_num)
        OrderDetailDao().save(**dic)
        r.delete(order_num)
        return jsonify({
            "code": 200,
            "msg": "ok"
        })
    else:
        return jsonify({
            "code": 207,
            "msg": "该订单已失效"
        })
Beispiel #5
0
def forget_password():
    r_data = request.get_json()
    if r_data:
        phone = r_data['phone']       #获取手机号
        if phone:
            if not UserDao().check_phone(phone):
                res = eval(send_msg(phone).decode())    #发送验证码
                if res['Code'] == 'OK':
                    code = r.get('MT'+phone)
                    return jsonify({'code':200,'msg':'验证码发送成功','data':code})
                else:
                    return jsonify({'code':207,'msg':'手机号错误请填写正确的手机号'})
            else:
                return jsonify({'code':207,'msg':'该手机号还没有注册,请前去注册'})
    return jsonify({'code':207,'msg':'请填写正确的手机号'})
Beispiel #6
0
def get_token_user_id(token):
    # 通过token获取user_id
    if check_token(token):
        return r.get(token).decode()
Beispiel #7
0
            # 将key写入到DB中
            return jsonify({
                'code': 200,
                'msg': '上传文件成功',
                'file_key': key
            })
        else:
            return jsonify({
                'code': 201,
                'msg': '图片格式只支持png或jpeg'
            })

    return jsonify({
        'code': 100,
        'msg': 'POST请求参数必须有img和token'
    })

# 头像获取
@blue.route('/img_url/<string:key>', methods=('GET', ))
def get_img_url(key):
    img_type = int(request.args.get('type', 0))

    img_url = oss.get_url(key) if img_type == 0 else oss.get_small_url(key)
    return jsonify({
        'url': img_url
    })
"""

if __name__ == '__main__':
    print(r.get('f48553a82cea428ca5a48660317bc2c2'))