Beispiel #1
0
def admin_order_status_edit():
    """
    后台订单列表状态数据编辑
    :return:
    """

    if request.method == 'POST':
        updated_at = int(time.time())
        order_id = request.form['order_id']
        status = request.form['status']

        try:

            update_sql = "update repair_order set status = {status},updated_at={updated_at} where id={order_id}". \
                format(status=status, order_id=order_id, updated_at=updated_at)

            db_session.execute(update_sql)
            db_session.commit()
        except Exception:
            print(traceback.format_exc())
            db_session.rollback()
            db_session.close()
            return jsonify({'success': False, 'msg': 'save date error'})

        db_session.close()
        return jsonify({'success': True, 'msg': 'update ok'})
Beispiel #2
0
def submit_types():
    """
    我要报修
    :return:
    """
    if request.method == 'POST':
        type_name = request.form['typename']
        created_at = int(time.time())
        updated_at = int(time.time())

        try:

            insert_address_sql = "insert into types (type_name,created_at,updated_at) " \
                                 "values ('{type_name}',{created_at},{updated_at})". \
                format(type_name=type_name, created_at=created_at, updated_at=updated_at)

            db_session.execute(insert_address_sql)

            db_session.commit()
        except Exception:
            print(traceback.format_exc())
            db_session.rollback()
            db_session.close()
            return jsonify({'success': False, 'msg': 'save date error'})

        db_session.close()
        return jsonify({'success': True, 'msg': 'save ok'})
Beispiel #3
0
def get_types_category():
    """
    获取子类
    :return:
    """
    records = list()
    if request.method == 'POST':
        data = request.get_data()
        json_data_dict = json.loads(data.decode("utf-8"))

        type_id = json_data_dict.get('type_id', '')

    try:

        insert_address_sql = "SELECT * FROM types_category where type_id={type_id}".format(
            type_id=type_id)
        res = db_session.execute(insert_address_sql).fetchall()
        for temp in res:
            records.append(dict(temp))

    except Exception:
        print(traceback.format_exc())
        db_session.rollback()
        db_session.close()
        return jsonify({'success': False, 'msg': 'search error'})

    db_session.close()
    return jsonify({'success': True, 'list': records})
Beispiel #4
0
def get_repair_order():
    """
    获取子类
    :return:
    """
    records = list()
    if request.method == 'POST':
        data = request.get_data()
        json_data_dict = json.loads(data.decode("utf-8"))

        status = json_data_dict.get('status', '')
        wx_code = json_data_dict.get('wx_code', '')

    try:

        query_sql = "SELECT * FROM repair_order where status in ({status}) and wx_code='{wx_code}' order by id desc".format(
            status=status, wx_code=wx_code)
        res = db_session.execute(query_sql).fetchall()
        for temp in res:
            temp = dict(temp)
            temp['price'] = str(temp['price'])
            temp['pay_price'] = str(temp['pay_price'])
            temp['created_at'] = timestamp_to_date(temp['created_at'])
            temp['updated_at'] = timestamp_to_date(temp['updated_at'])

            records.append(temp)

    except Exception:
        print(traceback.format_exc())
        db_session.rollback()
        db_session.close()
        return jsonify({'success': False, 'msg': 'search error'})

    db_session.close()
    return jsonify({'success': True, 'list': records})
Beispiel #5
0
def bind_address():
    """
    绑定地址
    :return:
    """

    if request.method == 'POST':
        username = request.form['username']
        address = request.form['address']
        mobile = request.form['mobile']
        created_at = int(time.time())
        updated_at = int(time.time())

        try:

            insert_address_sql = "insert into address (username,address,mobile,created_at,updated_at) " \
                                 "values ('{username}','{address}','{mobile}',{created_at},{updated_at})". \
                format(username=username, address=address, mobile=mobile, created_at=created_at, updated_at=updated_at)

            db_session.execute(insert_address_sql)

            db_session.commit()
        except Exception:
            print(traceback.format_exc())
            db_session.rollback()
            db_session.close()
            return jsonify({'success': False, 'msg': 'save date error'})

        db_session.close()
        return jsonify({'success': True, 'msg': 'save ok'})
Beispiel #6
0
def member_types_update():
    """
    修改会员类型
    :return:
    """
    if request.method == 'POST':
        member_id = request.form['member_id']
        member_title = request.form['title']
        member_price = request.form['price']
        member_limit = request.form['limit']
        number = request.form['number']
        member_describe = request.form['describe']
        member_details = request.form.get('details', '')
        updated_at = int(time.time())

        try:

            updated_sql = "update member_types set member_title='{member_title}',member_price={member_price}, " \
                          "member_limit='{member_limit}',member_describe='{member_describe}',number={number}," \
                          "member_details='{member_details}',updated_at={updated_at} " \
                          "where id={id}" \
                .format(id=member_id, member_title=member_title, member_price=member_price, member_limit=member_limit,
                        member_describe=member_describe, member_details=member_details, updated_at=updated_at,
                        number=number)

            db_session.execute(updated_sql)
            db_session.commit()
        except Exception:
            print(traceback.format_exc())
            db_session.rollback()
            db_session.close()
            return jsonify({'success': False, 'msg': 'modify date error'})

        db_session.close()
        return jsonify({'success': True, 'msg': 'save ok'})
Beispiel #7
0
def notice_weixin_payment():
    """
    微信回调订单是否支付状态
    :return:
    """
    if request.method == 'POST':
        data = request.get_data()
        json_data_dict = json.loads(data.decode("utf-8"))

        # 微信金额保存均已整型保存
        # 比较订单金额以及支付金额是否一致
        total_fee = json_data_dict.get('total_fee', 0)
        total_fee = total_fee / 100
        total_fee = Decimal(total_fee).quantize(Decimal("0.00"))

        settlement_total_fee = json_data_dict.get('settlement_total_fee', 0)
        settlement_total_fee = settlement_total_fee / 100
        settlement_total_fee = Decimal(settlement_total_fee).quantize(
            Decimal("0.00"))

        # 支付状态为0
        pay_type = 0
        if settlement_total_fee == total_fee:
            # 支付完成
            pay_type = 1
        elif settlement_total_fee < total_fee:
            # 未支付完
            pay_type = 2

        # 商家订单号
        out_trade_no = json_data_dict.get('out_trade_no', 0)

        #  微信订单号
        transaction_id = json_data_dict.get('transaction_id', 0)

        # 下单时间
        time_end = json_data_dict.get('time_end', 0)
    else:
        return jsonify({'return_code': 'FAIL'})

    # 验证签名 todo...

    try:
        # 修改订单数据
        update_sql = "update repair_order set pay_type={pay_type}, transaction_id={transaction_id}, " \
                     "pay_price = {settlement_total_fee} ,time_end ={time_end} where sn={sn} ". \
            format(pay_type=pay_type, transaction_id=transaction_id, settlement_total_fee=settlement_total_fee,
                   time_end=time_end, sn=out_trade_no)

        db_session.execute(update_sql)
        db_session.commit()
        db_session.close()
        return jsonify({'return_code': 'SUCCESS'})
    except Exception:
        db_session.rollback()
        db_session.close()
        return jsonify({'return_code': 'FAIL'})
Beispiel #8
0
def service_types_edit():
    """
    服务类型编辑
    :return:
    """
    service_types_id = request.args.get("id")

    query_sql = "SELECT t1.id,t1.type_id,t1.category_name,t2.type_name,t1.price,t1.created_at,t1.updated_at " \
                "FROM types_category t1 LEFT JOIN types t2 ON t2.id=t1.type_id where t1.id ={service_types_id} ". \
        format(service_types_id=service_types_id)
    record = db_session.execute(query_sql).first()

    query_type_sql = "select * from types"
    type_records = list()
    res = db_session.execute(query_type_sql).fetchall()
    for temp in res:
        temp = dict(temp)
        type_records.append(temp)

    if request.method == 'POST':
        type_id = request.form['type_id']
        category_name = request.form['category_name']
        price = request.form['price']

        try:

            update_sql = "update types_category set price={price},category_name='{category_name}',type_id={type_id} " \
                         "where id={id}". \
                format(type_id=type_id, price=price, category_name=category_name, id=service_types_id)
            db_session.execute(update_sql)
            db_session.commit()
            db_session.close()

            return jsonify({'success': True, 'msg': 'modify success'})
        except Exception:
            print(traceback.format_exc())
            db_session.rollback()
            db_session.close()
            return jsonify({'success': False, 'msg': 'modify delete'})

    db_session.close()
    return render_template('service_types_edit.html',
                           service_types_id=service_types_id,
                           type_records=type_records,
                           record=record)
Beispiel #9
0
def add_order():
    """
    我要报修
    :return:
    """
    if request.method == 'POST':
        data = request.get_data()
        json_data_dict = json.loads(data.decode("utf-8"))

        province_code = json_data_dict.get('provinceCode', '')
        city_code = json_data_dict.get('cityCode', '')
        name = json_data_dict.get('name', '')
        mobile = json_data_dict.get('mobile', '')
        address = json_data_dict.get('address', '')
        type = json_data_dict.get('type', '')
        types_category = json_data_dict.get('typesCategory', '')
        price = json_data_dict.get('price', '')
        wx_code = json_data_dict.get('wx_code', '')

        created_at = int(time.time())
        updated_at = int(time.time())

        try:

            insert_address_sql = "insert into repair_order (" \
                                 "province_code,city_code,name,mobile,address,type,category_name," \
                                 "price,created_at,updated_at,wx_code) " \
                                 "values ('{province_code}','{city_code}','{name}','{mobile}','{address}','{type}'," \
                                 "'{category_name}',{price},{created_at},{updated_at},'{wx_code}')". \
                format(province_code=province_code, city_code=city_code, name=name, mobile=mobile, address=address,
                       type=type, category_name=types_category, price=price,
                       created_at=created_at, updated_at=updated_at, wx_code=wx_code)

            db_session.execute(insert_address_sql)

            db_session.commit()
        except Exception:
            print(traceback.format_exc())
            db_session.rollback()
            db_session.close()
            return jsonify({'success': False, 'msg': 'save date error'})
        db_session.close()
        return jsonify({'success': True, 'msg': 'save ok'})
Beispiel #10
0
def add_member():
    """
    购买会员
    :return:
    """
    if request.method == 'POST':

        data = request.get_data()
        json_data_dict = json.loads(data.decode("utf-8"))

        username = json_data_dict.get('name', '')
        address = json_data_dict.get('address', '')
        mobile = json_data_dict.get('mobile', '')
        wx_code = json_data_dict.get('wxCode', '')
        warranty_time = json_data_dict.get('warrantyTime', '')
        is_member = json_data_dict.get('isMember', '')
        member_grade = json_data_dict.get('memberGrade', '')

        created_at = int(time.time())
        updated_at = int(time.time())

        try:

            insert_address_sql = "insert into member " \
                                 "(username,address,mobile,created_at," \
                                 "updated_at,wx_code,warranty_time,is_member,member_grade) " \
                                 "values (" \
                                 "'{username}','{address}','{mobile}',{created_at},{updated_at},'{wx_code}'," \
                                 "'{warranty_time}','{is_member}','{member_grade}')". \
                format(
                username=username, address=address, mobile=mobile, created_at=created_at, updated_at=updated_at,
                wx_code=wx_code, warranty_time=warranty_time, is_member=is_member, member_grade=member_grade)

            db_session.execute(insert_address_sql)
            db_session.commit()

        except Exception:
            print(traceback.format_exc())
            db_session.rollback()
            db_session.close()
            return jsonify({'success': False, 'msg': 'save date error'})
        db_session.close()
        return jsonify({'success': True, 'msg': 'save ok'})
Beispiel #11
0
def get_orders():
    """
    我要报修
    :return:
    """

    records = list()
    try:

        insert_address_sql = "SELECT * FROM repair_order"
        res = db_session.execute(insert_address_sql).fetchall()

        for temp in res:
            records.append(dict(temp))

    except Exception:
        print(traceback.format_exc())
        db_session.rollback()
        db_session.close()
        return jsonify({'success': False, 'msg': 'search error'})
    db_session.close()
    return jsonify({'success': True, 'list': records})
Beispiel #12
0
def service_types_del():
    """
    删除
    :return:
    """
    if request.method == 'POST':
        types_category_id = request.form['id']

        try:
            delete_sql = "delete from types_category where id={id}".format(
                id=types_category_id)
            db_session.execute(delete_sql)

            db_session.commit()
        except Exception:
            print(traceback.format_exc())
            db_session.rollback()
            db_session.close()
            return jsonify({'success': False, 'msg': 'delete data error'})

        db_session.close()
        return jsonify({'success': True, 'msg': 'delete success'})
Beispiel #13
0
def delete_types():
    """
    我要报修
    :return:
    """
    if request.method == 'POST':
        types_id = request.form['id']

        try:

            insert_address_sql = "delete from types where id={id}".format(
                id=types_id)
            db_session.execute(insert_address_sql)
            db_session.commit()
        except Exception:
            print(traceback.format_exc())
            db_session.rollback()
            db_session.close()
            return jsonify({'success': False, 'msg': 'delete date error'})

        db_session.close()
        return jsonify({'success': True, 'msg': 'delete ok'})
Beispiel #14
0
def get_member_types():
    """
    后台类型列表
    :return:
    """

    records = list()
    try:

        query_address_sql = "SELECT * FROM member_types "
        res = db_session.execute(query_address_sql).fetchall()

        for temp in res:
            records.append(dict(temp))

    except Exception:
        print(traceback.format_exc())
        db_session.rollback()
        db_session.close()
        return jsonify({'success': False, 'msg': 'search error'})
    db_session.close()
    return jsonify({'success': True, 'list': records})
Beispiel #15
0
def delete_order():
    """
    我要报修
    :return:
    """
    if request.method == 'POST':
        repair_order = request.form['id']

        try:

            delete_sql = "delete from repair_order where id={id}".format(
                id=repair_order)
            db_session.execute(delete_sql)

            db_session.commit()
        except Exception:
            print(traceback.format_exc())
            db_session.rollback()
            db_session.close()
            return jsonify({'success': False, 'msg': 'delete data error'})

        db_session.close()
        return jsonify({'success': True, 'msg': 'delete ok'})
Beispiel #16
0
def get_member_wxcode_update():
    """
    :return:
    """
    wx_code = request.args.get('wx_code')
    query_sql = "SELECT * FROM member where is_member='是' " \
                "and wx_code='{wx_code}' and warranty_time >= 1".format(wx_code=wx_code)
    res = db_session.execute(query_sql).first()

    if res is None:
        db_session.close()
        return jsonify({'success': False, 'is_member': False})

    res = dict(res)

    update_sql = ""
    if int(res['warranty_time']) > 1:
        update_sql = "update member set warranty_time = {warranty_time} where id = {id}".\
            format(id=res['id'], warranty_time=(int(res['warranty_time']) - 1))

    if int(res['warranty_time']) == 1:
        update_sql = "update member set is_member = '否',warranty_time = {warranty_time} " \
                     "where id = {id}".\
            format(id=res['id'], warranty_time=(int(res['warranty_time']) - 1))
        # update_sql = "update member set is_member = '否' ,warranty_time = {warranty_time} " \
        #              "where wx_code='{wx_code}'".format(wx_code=wx_code,warranty_time=(int(res['warranty_time']) -1))

    try:
        db_session.execute(update_sql)
        db_session.commit()
        db_session.close()
        return jsonify({'success': True})
    except Exception:
        print(traceback.format_exc())
        db_session.rollback()
        db_session.close()
        return jsonify({'success': False})
Beispiel #17
0
def submit_member_types():
    """
    提交会员类型
    :return:get-member-wxcode-update
    """
    if request.method == 'POST':
        member_title = request.form['title']
        member_price = request.form['price']
        member_limit = request.form['limit']
        number = request.form['number']
        member_describe = request.form['describe']
        member_details = request.form.get('details', '')
        created_at = int(time.time())
        updated_at = int(time.time())

        try:

            insert_address_sql = "insert into member_types (member_title,member_price,member_limit," \
                                 "member_describe,number,member_details,created_at,updated_at) " \
                                 "values ('{member_title}','{member_price}','{member_limit}','{member_describe}',{number}," \
                                 "'{member_details}',{created_at},{updated_at})". \
                format(member_title=member_title, member_price=member_price, member_limit=member_limit,
                       member_describe=member_describe, member_details=member_details, created_at=created_at,
                       number=number,
                       updated_at=updated_at)

            db_session.execute(insert_address_sql)
            db_session.commit()
        except Exception:
            print(traceback.format_exc())
            db_session.rollback()
            db_session.close()
            return jsonify({'success': False, 'msg': 'save date error'})

        db_session.close()
        return jsonify({'success': True, 'msg': 'save ok'})