Exemplo n.º 1
0
def quit_team():
    ApiResponse = api_response.ApiResponse()
    userId = request_helper.current_user_mush_login()["Id"]

    TeamId = request.form.get("TeamId", type=str, default=None)
    if TeamId is None or TeamId == '':
        raise custom_error.CustomFlaskErr(status_code=500, message="团队id不能为空")
    is_team_admin = mysql.get_object(team_sql.is_team_admin, (TeamId, userId))
    if (is_team_admin["total"] > 0):  # 是团队管理员,解散团队
        sql_list = [
            team_sql.disband_team1, team_sql.disband_team2,
            team_sql.update_planner_statistics_null,
            team_sql.delete_team_notice_admin
        ]
        args_list = [(userId, TeamId, userId), (userId, TeamId), (userId),
                     (TeamId)]
        resultInt = mysql.operate__many(sql_list, args_list)
    else:
        sql_list = [
            team_sql.quit_team, team_sql.update_planner_statistics_null,
            team_sql.delete_team_notice
        ]
        args_list = [(userId, TeamId, userId), (userId), (userId, TeamId)]
        resultInt = mysql.operate__many(sql_list, args_list)
    if resultInt <= 0:
        raise custom_error.CustomFlaskErr(status_code=500, message="退出团队失败")
    ApiResponse.message = "成功"
    ApiResponse.status = 200
    return api_response.response_return(ApiResponse)
Exemplo n.º 2
0
def update_demand_status():
    userId = request_back_helper.current_user_mush_login()["UserId"]

    ApiResponse = api_response.ApiResponse()
    id = request.form.get("id", type=str, default=None)
    IsUndertake = request.form.get("IsUndertake", type=int, default=-1)
    IsTop = request.form.get("IsTop", type=int, default=-1)

    if id is None:
        raise custom_error.CustomFlaskErr(status_code=500, message="参数不正确")
    if IsUndertake == -1:
        raise custom_error.CustomFlaskErr(status_code=500, message="参数不正确")
    if IsTop==-1 :
        raise custom_error.CustomFlaskErr(status_code=500, message="参数不正确")


    if IsUndertake==2:
        sql_list = [demand_service_sql.update_demand_status,
                    demand_service_sql.update_demand_undertake_status]
        args_list = [(IsTop, IsUndertake, userId,id),
                     ( userId,id),]
        mysql.operate__many(sql_list,args_list)
    else :
        mysql.operate_object(demand_service_sql.update_demand_status,(IsTop, IsUndertake, userId,id))

    ApiResponse = api_response.ApiResponse()
    ApiResponse.message = "成功"
    ApiResponse.status = 200
    return api_response.response_return(ApiResponse)
Exemplo n.º 3
0
def agree_join_team():
    ApiResponse = api_response.ApiResponse()
    userId = request_helper.current_user_mush_login()["Id"]

    NoticeId = request.form.get("NoticeId", type=str, default=None)
    if NoticeId is None or NoticeId == '':
        raise custom_error.CustomFlaskErr(status_code=500,
                                          message="团队通知id不能为空")

    exists_team = mysql.get_object(team_sql.exists_team_peoper_bynoticeid,
                                   (NoticeId))

    if exists_team is not None and exists_team["IsAdmin"] != 1:
        raise custom_error.CustomFlaskErr(status_code=500, message="您不是团队管理员")
    if exists_team is None or exists_team["Status"] != 1:
        raise custom_error.CustomFlaskErr(status_code=500,
                                          message="您没有需要审核的团队消息")
    sql_list = [
        team_sql.insert_team_member, team_sql.update_team_admin_notice,
        team_sql.update_team_notice, team_sql.update_planner_statistics
    ]
    args_list = [(exists_team["TeamId"], exists_team["duUserId"], userId),
                 (userId, NoticeId), (userId, exists_team["UnionId"]),
                 (exists_team["TeamId"], userId, exists_team["duUserId"])]
    resultInt = mysql.operate__many(sql_list, args_list)
    if resultInt <= 0:
        raise custom_error.CustomFlaskErr(status_code=500, message="审批失败")
    ApiResponse.message = "成功"
    ApiResponse.status = 200
    return api_response.response_return(ApiResponse)
Exemplo n.º 4
0
def updateuserinfobyupgrade():
    ApiResponse = api_response.ApiResponse()
    Name = request.form.get("Name", type=str, default=None)
    if Name == None or Name == "":
        raise custom_error.CustomFlaskErr(status_code=500, message="真实姓名不能为空")

    Address = request.form.get("Address", type=str, default=None)
    IDCard = request.form.get("IDCard", type=str, default=None)
    if IDCard == None or IDCard == "":
        raise custom_error.CustomFlaskErr(status_code=500, message="个人证件不能为空")
    IDCardJust = request.form.get("IDCardJust", type=str, default=None)
    IDCardBack = request.form.get("IDCardBack", type=str, default=None)

    ChatNo = request.form.get("ChatNo", type=str, default=None)

    user = request_helper.current_user_mush_login()
    nicheng = user['Name']
    if nicheng is None:
        nicheng = Name

    sql_list = [user_info_sql.update_user_info_by_upgrade]
    args_list = [(Name, Address, IDCard, IDCardJust, IDCardBack, user["Id"],
                  ChatNo, nicheng, user["Id"])]

    data_result = mysql.operate__many(sql_list, args_list)

    if data_result != None and data_result > 0:
        ApiResponse.message = "修改成功"
        ApiResponse.status = 200
        return api_response.response_return(ApiResponse)

    raise custom_error.CustomFlaskErr(status_code=500, message="修改失败")
Exemplo n.º 5
0
def upgrade_user():
    ApiResponse = api_response.ApiResponse()
    Sex = request.form.get("Sex", type=int, default=0)
    if Sex == 0:
        raise custom_error.CustomFlaskErr(status_code=500, message="性别不能为空")
    Name = request.form.get("Name", type=str, default=None)
    if Name == None:
        raise custom_error.CustomFlaskErr(status_code=500, message="真实姓名不能为空")
    Address = request.form.get("Address", type=str, default=None)
    if Address == None:
        raise custom_error.CustomFlaskErr(status_code=500, message="地址不能为空")
    ServiceId = request.form.get("ServiceId", type=str, default=None)
    if ServiceId == None or ServiceId == "":
        raise custom_error.CustomFlaskErr(status_code=500, message="服务不能为空")
    ServiceAreaId = request.form.get("ServiceAreaId", type=str, default=None)
    if ServiceAreaId == None or ServiceAreaId == "":
        raise custom_error.CustomFlaskErr(status_code=500, message="服务区域不能为空")
    Email = request.form.get("Email", type=str, default=None)
    if Email == None:
        raise custom_error.CustomFlaskErr(status_code=500, message="邮箱不能为空")
    Experience = request.form.get("Experience", type=str, default=None)
    if Experience == None:
        raise custom_error.CustomFlaskErr(status_code=500, message="资历不能为空")
    IDCard = request.form.get("IDCard", type=str, default=None)
    if IDCard == None:
        raise custom_error.CustomFlaskErr(status_code=500, message="身份证不能为空")
    IDCardPic = request.form.get("IDCardPic", type=str, default=None)
    if IDCardPic == None:
        raise custom_error.CustomFlaskErr(status_code=500, message="身份证正面不能为空")
    IDCardBackPic = request.form.get("IDCardBackPic", type=str, default=None)
    if IDCardBackPic == None:
        raise custom_error.CustomFlaskErr(status_code=500, message="身份证反面不能为空")

    userId = request_helper.current_user_mush_login()["Id"]

    nicheng = request_helper.current_user_mush_login()["Name"]
    if nicheng is None:
        nicheng = Name

    data_exists = mysql.get_list(user_upgrade.select_exists_upgrade, (userId))

    if len(data_exists):
        raise custom_error.CustomFlaskErr(status_code=500,
                                          message="你已经存在申请过注册规划师")

    argData = [(userId, Sex, Name, Address, ServiceId, ServiceAreaId, Email,
                Experience, IDCardPic, userId, IDCardBackPic, IDCard),
               (nicheng, userId)]

    argSql = (user_upgrade.insert_upgrade_user,
              user_upgrade.update_user_info_name)

    data_register = mysql.operate__many(argSql, argData)

    if data_register > 0:
        ApiResponse.message = "申请成功"
        ApiResponse.status = 200
        return api_response.response_return(ApiResponse)
    raise custom_error.CustomFlaskErr(status_code=500, message="申请失败")
Exemplo n.º 6
0
def update_upgrade_user():
    UserId = request_back_helper.current_user_mush_login()["UserId"]
    Id = request.form.get("Id", type=str, default=None)
    Status = request.form.get("Status", type=int, default=-1)

    if Id is None or Id == "":
        raise custom_error.CustomFlaskErr(status_code=500, message="参数id不能为空")
    if Status == -1:
        raise custom_error.CustomFlaskErr(status_code=500, message="参数状态不能为空")
    #查询规划师升级数据
    upgradeInfo = mysql.get_object(upgrade_user_sql.get_upgrade_info_by_id,
                                   (Id))

    if upgradeInfo is None:
        raise custom_error.CustomFlaskErr(status_code=500, message="该审核数据不存在")
    if upgradeInfo["Status"] != 0:
        raise custom_error.CustomFlaskErr(status_code=500,
                                          message="该审核数据已处理,请勿重复操作")
    # 审核不通过
    if Status == 2:
        success = mysql.operate_object(upgrade_user_sql.update_upgrade_status,
                                       (Status, UserId, Id))
        if success <= 0:
            raise custom_error.CustomFlaskErr(status_code=500, message="审核失败")
    # 审核通过
    if Status == 1:
        idCard = " "  #判断IDCard是否不存在
        if 'IDCard' in upgradeInfo and upgradeInfo["IDCard"] is not None:
            idCard = upgradeInfo["IDCard"]
        sql_list = [
            upgrade_user_sql.update_upgrade_status,
            upgrade_user_sql.update_user_type,
            upgrade_user_sql.update_user_info,
            upgrade_user_sql.insert_planner_statistics
        ]
        args_list = [
            (Status, UserId, Id), (UserId, upgradeInfo["UserId"]),
            (upgradeInfo["Name"], upgradeInfo["Sex"], upgradeInfo["Address"],
             upgradeInfo["Experience"], upgradeInfo["Email"], idCard,
             upgradeInfo["IDCardPic"], upgradeInfo["IDCardBackPic"],
             upgradeInfo["ServiceAreaId"], upgradeInfo["ServiceId"], UserId,
             upgradeInfo["UserId"]),
            (upgradeInfo["UserId"], UserId, UserId, upgradeInfo["UserId"],
             upgradeInfo["UserId"])
        ]
        success = mysql.operate__many(sql_list, args_list)
        if success <= 0:
            raise custom_error.CustomFlaskErr(status_code=500, message="审核失败")

    ApiResponse = api_response.ApiResponse()
    ApiResponse.message = "成功"
    ApiResponse.status = 200
    return api_response.response_return(ApiResponse)
Exemplo n.º 7
0
def collection():
    ApiResponse = api_response.ApiResponse()
    user = request_helper.current_user_mush_login()
    demandServiceId = request.form.get("demandServiceId",
                                       type=str,
                                       default=None)
    sql_list = (demand_service_sql.demand_service_collection,
                demand_service_sql.add_demand_service_count)
    args = [(user["Id"], demandServiceId), (demandServiceId)]
    if any(user) and demandServiceId != None and demandServiceId != "":
        count = mysql.operate__many(sql_list, args)
    ApiResponse.message = "收藏成功"
    ApiResponse.status = 200
    return api_response.response_return(ApiResponse)
Exemplo n.º 8
0
def update_order_status():
    ApiResponse = api_response.ApiResponse()
    userId = request_back_helper.current_user_mush_login()["UserId"]

    OrderId = request.form.get("OrderId", type=str, default=None)
    if OrderId is None:
        raise custom_error.CustomFlaskErr(status_code=500, message="订单id不不能为空")
    StartStatus = request.form.get("StartStatus", type=int, default=0)
    if StartStatus == 0:
        raise custom_error.CustomFlaskErr(status_code=500, message="开始状态不能为空")
    EndStatus = request.form.get("EndStatus", type=int, default=0)
    if EndStatus == 0:
        raise custom_error.CustomFlaskErr(status_code=500, message="结束状态不能为空")
    print(EndStatus)
    sql_list = [order_sql.update_order_status,
                order_sql.update_planner_statistics,
                order_sql.insert_order_flowing]
    args_list = [(EndStatus, userId, OrderId, StartStatus),
                 (userId,OrderId,StartStatus, EndStatus),
                 (OrderId, userId, StartStatus, EndStatus, userId)]
    mysql.operate__many(sql_list, args_list)
    ApiResponse.message = "成功"
    ApiResponse.status = 200
    return api_response.response_return(ApiResponse)
Exemplo n.º 9
0
def register():
    ApiResponse = api_response.ApiResponse()
    Account = request.form.get("Account", type=str, default=None)
    Password = request.form.get("Password", type=str, default=None)
    VCode = request.form.get("VCode", type=str, default=None)
    if Account == None:
        raise custom_error.CustomFlaskErr(status_code=500, message="账号不能为空")
    if Password == None:
        raise custom_error.CustomFlaskErr(status_code=500, message="密码不能为空")
    if VCode == None:
        raise custom_error.CustomFlaskErr(status_code=500, message="验证码不能为空")

    data_exists = mysql.get_list(user_sql.select_exists_user, (Account))
    if len(data_exists):
        raise custom_error.CustomFlaskErr(status_code=500, message="账号已经存在")

    vocde_exists = mysql.get_object(verification_code_sql.select_verification_lastcode, (Account, 1))
    if vocde_exists == None:
        raise custom_error.CustomFlaskErr(status_code=500, message="验证码已失效")
    if vocde_exists["VCode"] != VCode:
        raise custom_error.CustomFlaskErr(status_code=500, message="验证码不正确")
    # 设置验证码已读
    mysql.operate_object(verification_code_sql.update_verificatioin_vcode, (vocde_exists["Id"]))

    guid = str(uuid.uuid1())
    sql_list = [user_sql.insert_user, user_sql.insert_userinfo]
    args_list = [(guid, Account, Password, Account), (guid)]

    data_register = mysql.operate__many(sql_list, args_list)
    if data_register > 0:
        # region 设置登陆信息,直接跳转到首页
        guid = str(uuid.uuid1())
        ip = request.remote_addr
        count = mysql.operate_object(user_sql.update_user_token, (guid, ip, Account, Password))
        user = mysql.get_object(user_sql.select_user_login_info, (guid))
        session["user"] = user
        data = {"token": guid, "datetime": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), "user": user}

        ApiResponse.message = "注册成功"
        ApiResponse.status = 200
        ApiResponse.data = data
        return api_response.response_return(ApiResponse)
    # date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    raise custom_error.CustomFlaskErr(status_code=500, message="注册失败")
Exemplo n.º 10
0
def join_team():
    ApiResponse = api_response.ApiResponse()
    userId = request_helper.current_user_mush_login()["Id"]
    user_info = mysql.get_object(user_sql.select_user_by_id, (userId))
    if user_info is None or user_info["UserType"] == 1:
        raise custom_error.CustomFlaskErr(status_code=500, message="你还不是规划师")

    TeamId = request.form.get("TeamId", type=str, default=None)
    if TeamId is None or TeamId == '':
        raise custom_error.CustomFlaskErr(status_code=500, message="团队id不能为空")

    exists_team = mysql.get_object(team_sql.exists_team_peoper, (userId))

    if exists_team is not None and exists_team["Status"] == 1:
        raise custom_error.CustomFlaskErr(status_code=500,
                                          message="您已经申请过加入该团队,请耐心等待审核")
    if exists_team is not None and exists_team["Status"] == 2:
        raise custom_error.CustomFlaskErr(status_code=500, message="您已经是团队成员")

    team_detail = mysql.get_object(team_sql.select_team_adminid, (TeamId))

    if team_detail is None:
        raise custom_error.CustomFlaskErr(status_code=500,
                                          message="您所申请的团队不存在")

    guid = str(uuid.uuid1())
    sql_list = [team_sql.insert_team_notice, team_sql.insert_team_notice]
    args_list = [(userId, TeamId, "您正在申请加入 " + team_detail["Name"] + " 团队", 1,
                  2, userId, guid),
                 (team_detail["AdminUserId"], TeamId,
                  "用户 " + request_helper.current_user_mush_login()["Name"] +
                  " 正在申请加入团队", 1, 1, userId, guid)]

    data_register = mysql.operate__many(sql_list, args_list)
    ApiResponse.message = "成功"
    ApiResponse.status = 200
    return api_response.response_return(ApiResponse)