示例#1
0
def updateuserstate(request):
    result = {}
    if request.method == "POST":
        userid = request.POST.get("userid", None)  # 读取get数据,None为默认值
        qunid = request.POST.get("qunid", None)  # 读取get数据,None为默认值
        userstate = request.POST.get("userstate", None)  # 读取get数据,None为默认值

    if request.method == "GET":
        userid = request.GET.get("userid", None)  # 读取get数据,None为默认值
        qunid = request.GET.get("qunid", None)  # 读取get数据,None为默认值
        userstate = request.GET.get("userstate", None)  # 读取get数据,None为默认值

    print("修改用户在群组中的状态接口参数:用户id", userid, "用户状态", userstate)

    user_receive = UserDAO.getUserInfoId(userid)
    user_receive.state = userstate
    UserDAO.updateUserInfo(user_receive)
    qun = QunDAO.getqunInfoqunid(qunid)

    userqun = Userqun()
    userqun.userid = userid
    userqun.qunid = qunid
    userqun = UserqunDAO.getuserqunInfouserqun(userqun)

    if (not userqun or not qun):
        result["data"] = ""
        result["respcode"] = ResultCode.FAIL
        result["errorcode"] = ResultCode.FAIL
        result["message"] = "修改失败"
        print('修改失败')
        return JsonResponse(result)

    userqun.userstate = userstate
    UserqunDAO.updateuserqun(userqun)

    # 如果升级为群主
    if (userstate == ResultCode.USERQUN_QUNZHU):
        # 查找原群主关系组
        userqun.userid = qun.userid
        userqun.qunid = qunid
        userqun = UserqunDAO.getuserqunInfouserqun(userqun)
        userqun.userstate = ResultCode.USERQUN_FUZHU
        UserqunDAO.updateuserqun(userqun)
        # 修改群信息
        qun.userid = userid
        QunDAO.updatequnInfoqun(qun)

    result["data"] = ""
    result["respcode"] = ResultCode.SUCCESS
    result["errorcode"] = ""
    result["message"] = "修改成功"
    print('修改成功')

    return JsonResponse(result)
示例#2
0
def setjiage(request):
    result={}
    if request.method == "POST":
        key = request.POST.get("key", None)  # 读取post数据,None为默认值
        jiage = float(request.POST.get("jiage", None))  # 读取post数据,None为默认值

        print("修改价格:", request.POST)

    if request.method == "GET":
        key = request.GET.get("key", None)  # 读取get数据,None为默认值
        jiage = float(request.GET.get("jiage", None))  # 读取get数据,None为默认值

        print("修改价格:", request.GET)

    try:
        qun = QunDAO.getqunInfoqunid(999)
        try:
            jsonobj=json.loads(qun.gonggao.replace('\'','"'))   # python中json转换不支持单引号,所以需要将所有单引号换成双引号

        except Exception as e:
            print('公告转化为json出错:',e)
            jsonobj={}

        if(key in jsonobj):   #如果价格为0,就删除
            jsonobj.pop(key)
        if(jiage>0):
            jsonobj[key] = str(jiage)  #添加修改值

        qun.gonggao = str(jsonobj)

        QunDAO.updatequnInfoqun(qun)

        #清除从公告中加载的数据
        allname.clear()
        allqiye.clear()
        allchanpin.clear()
        allbank.clear()
        alljiage.clear()

        result["data"]= "0"
        result["respcode"]= ResultCode.SUCCESS
        result["errorcode"]= ""
        result["message"]= "修改价格成功"
        print('修改价格成功')

    except Exception as e:
        print('设置价格出错',e)
        result["data"]="0"
        result["respcode"]=ResultCode.FAIL
        result["errorcode"]= ResultCode.FAIL
        result["message"]= "修改价格失败"
        print('修改价格失败')

    return JsonResponse(result)
示例#3
0
def wordfun(msg,qun,user):
    Content = msg.content
    # 如果在设置价格
    if "control:" in Content:
        Content=Content.replace("control:", "")
        try:
            jsonobj= json.loads(qun.gonggao.replace('\'','\"'))
        except Exception as e:
            print('json转化出错',e)
            jsonobj = {}

        key_value=Content.split(":")   #使用冒号进行分割,key_value[0]为商品,key_value[1]为价格
        if(key_value[1]=="0" and key_value[0] in jsonobj):   #如果价格为0,就删除
            jsonobj.pop(key_value[0])
        else:
            jsonobj[key_value[0]]= float(key_value[1])  #添加修改值

        qun.gonggao= str(jsonobj)
        QunDAO.updatequnInfoqun(qun)

        #清除从公告中加载的数据
        allname.clear()
        allqiye.clear()
        allchanpin.clear()
        allbank.clear()
        alljiage.clear()

        respContent="配置修改成功"
        return respContent


    #设置已上传
    elif "ysc" in Content:
        Content=Content.replace("ysc", "")  #后面的认为是券码
        diary = DiaryDAO.selectDiaryforSerial(Content)  #根据券码查询日志
        diary.type = "1"   #1为已上传
        DiaryDAO.updatediary(diary)
        respContent="设置已上传成功:"+diary.content
        return respContent

    #设置出售中
    elif "csz" in Content:
        Content=Content.replace("csz", "")  #后面的认为是券码
        diary = DiaryDAO.selectDiaryforSerial(Content)  #根据券码查询日志
        diary.type = "2"    #2为出售中
        DiaryDAO.updatediary(diary)
        respContent="设置出售中成功:"+diary.content
        return respContent

    #设置已汇款
    elif "yhk" in Content:
        Content=Content.replace("yhk", "")  #后面的认为是券码
        diary = DiaryDAO.selectDiaryforSerial(Content)  #根据券码查询日志
        diary.type = "3"   #3为已汇款
        DiaryDAO.updatediary(diary)
        respContent="设置已汇款成功:"+diary.content
        return respContent

    #设置纠纷
    elif "jf" in Content:
        Content=Content.replace("jf", "")  #后面的认为是券码
        diary = DiaryDAO.selectDiaryforSerial(Content)  #根据券码查询日志
        diary.type = "4"  #4为纠纷
        DiaryDAO.updatediary(diary)
        respContent="设置纠纷成功:"+diary.content
        return respContent

    # 输入券码通知信息
    else:
        try:
            respContent = getinfo(Content,qun,user,None)  #根据文字生成响应文本
        except Exception as e:
            print('根据短信获取票券出错', e)
            respContent = tosetting(user)   #返回进入账户中心的信息

    return respContent
示例#4
0
def deldealinfomore(request):
    result = {}
    if request.method == "POST":
        deal = request.POST.get("deal", 0)  # 读取post数据,None为默认值
        userid_source = request.POST.get("userid_source",
                                         0)  # 读取post数据,None为默认值
        diaryid_source = request.POST.get("diaryid_source",
                                          0)  # 读取post数据,None为默认值
        qunid_source = request.POST.get("qunid_source", 0)  # 读取post数据,None为默认值
        userid_destination = request.POST.get("userid_destination",
                                              0)  # 读取post数据,None为默认值
        diaryid_destination = request.POST.get("diaryid_destination",
                                               0)  # 读取post数据,None为默认值
        qunid_destination = request.POST.get("qunid_destination",
                                             0)  # 读取post数据,None为默认值
    if request.method == "GET":
        deal = request.GET.get("deal", 0)  # 读取get数据,None为默认值
        userid_source = request.GET.get("userid_source", 0)  # 读取get数据,None为默认值
        diaryid_source = request.GET.get("diaryid_source",
                                         0)  # 读取get数据,None为默认值
        qunid_source = request.GET.get("qunid_source", 0)  # 读取get数据,None为默认值
        userid_destination = request.GET.get("userid_destination",
                                             0)  # 读取get数据,None为默认值
        diaryid_destination = request.GET.get("diaryid_destination",
                                              0)  # 读取get数据,None为默认值
        qunid_destination = request.GET.get("qunid_destination",
                                            0)  # 读取get数据,None为默认值

    print("删除更多操作接口参数:deal", deal)
    more = More()
    more.deal = deal
    more.userid_source = userid_source
    more.userid_destination = userid_destination
    more.diaryid_source = diaryid_source
    more.diaryid_destination = diaryid_destination
    more.qunid_source = qunid_source
    more.qunid_destination = qunid_destination
    more = MoreDAO.selectmoreInfomore(more)

    if (more):
        MoreDAO.deldealInfoid(more.id)
        result["data"] = ""
        result["respcode"] = ResultCode.SUCCESS
        result["errorcode"] = ResultCode.SUCCESS
        result["message"] = "删除处理成功"

        #如果是日志点赞则添加到日志属性中去
        if (more.diaryid_destination):
            diary = DiaryDAO.selectDiary(more.diaryid_destination)
            if (diary):
                if (more.deal == ResultCode.DIARY_ZAN):
                    diary.zannum = diary.zannum - 1
                    DiaryDAO.updatediary(diary)
                elif (more.deal == ResultCode.DIARY_SHOUCANG):
                    diary.shoucangnum = diary.shoucangnum - 1
                    DiaryDAO.updatediary(diary)

                elif (more.deal == ResultCode.DIARY_TUIJIAN):
                    diary.tuijiannum = diary.tuijiannum - 1
                    DiaryDAO.updatediary(diary)

        #如果是群组点赞  则添加到群属性中
        elif (more.qunid_destination()):
            qun = QunDAO.getqunInfoqunid(more.qunid_destination)
            if (qun):
                if (more.deal == ResultCode.QUN_ZAN):
                    qun.zannum = qun.zannum - 1
                    QunDAO.updatequnInfoqun(qun)

                elif (more.deal == ResultCode.QUN_SHOUCANG):
                    qun.shoucangnum = qun.shoucangnum - 1
                    QunDAO.updatequnInfoqun(qun)
                elif (more.deal == ResultCode.QUN_TUIJIAN):
                    qun.tuijiannum = qun.tuijiannum - 1
                    QunDAO.updatequnInfoqun(qun)

        #如果是用户点赞  则添加到用户属性中
        elif (more.userid_destination):
            user = UserDAO.getUserInfoId(more.userid_destination)
            if (user):
                if (more.deal == ResultCode.USER_ZAN):
                    user.zannum = user.zannum - 1
                    UserDAO.updateUserInfo(user)
                if (more.deal == ResultCode.USER_SHOUCANG):
                    user.shoucangnum = user.shoucangnum - 1
                    UserDAO.updateUserInfo(user)
                if (more.deal == ResultCode.USER_TUIJIAN):
                    user.tuijiannum = user.tuijiannum - 1
                    UserDAO.updateUserInfo(user)

    return JsonResponse(result)
示例#5
0
def deldeal(request):
    result = {}
    if request.method == "POST":
        id = request.POST.get("id", None)  # 读取post数据,None为默认值
    if request.method == "GET":
        id = request.GET.get("id", None)  # 读取get数据,None为默认值

    print("删除更多操作接口参数:操作id", id)
    more = MoreDAO.selectdealInfoid(id)
    try:
        MoreDAO.deldealInfoid(id)
        result["data"] = ""
        result["respcode"] = ResultCode.SUCCESS
        result["errorcode"] = ResultCode.SUCCESS
        result["message"] = "删除处理成功"

        #如果是日志点赞则添加到日志属性中去
        if (more.diaryid_destination):
            diary = DiaryDAO.selectDiary(more.diaryid_destination)
            if (diary):
                if (more.deal == ResultCode.DIARY_ZAN):
                    diary.zannum = diary.zannum - 1
                    DiaryDAO.updatediary(diary)
                elif (more.deal == ResultCode.DIARY_SHOUCANG):
                    diary.shoucangnum = diary.shoucangnum - 1
                    DiaryDAO.updatediary(diary)

                elif (more.deal == ResultCode.DIARY_TUIJIAN):
                    diary.tuijiannum = diary.tuijiannum - 1
                    DiaryDAO.updatediary(diary)
        #如果是群组点赞  则添加到群属性中
        elif (more.qunid_destination):
            qun = QunDAO.getqunInfoqunid(more.qunid_destination)
            if (qun):
                if (more.deal == ResultCode.QUN_ZAN):
                    qun.zannum = qun.zannum - 1
                    QunDAO.updatequnInfoqun(qun)
                elif (more.deal == ResultCode.QUN_SHOUCANG):
                    qun.shoucangnum = qun.shoucangnum - 1
                    QunDAO.updatequnInfoqun(qun)
                elif (more.deal == ResultCode.QUN_TUIJIAN):
                    qun.tuijiannum = qun.tuijiannum - 1
                    QunDAO.updatequnInfoqun(qun)

        #如果是用户点赞  则添加到用户属性中
        elif (more.userid_destination):
            user = UserDAO.getUserInfoId(more.userid_destination)
            if (user):
                if (more.deal == ResultCode.USER_ZAN):
                    user.zannum = user.zannum - 1
                    UserDAO.updateUserInfo(user)
                if (more.deal == ResultCode.USER_SHOUCANG):
                    user.shoucangnum = user.shoucangnum - 1
                    UserDAO.updateUserInfo(user)
                if (more.deal == ResultCode.USER_TUIJIAN):
                    user.tuijiannum = user.tuijiannum - 1
                    UserDAO.updateUserInfo(user)

    except Exception as e:
        result["data"] = ""
        result["respcode"] = ResultCode.FAIL
        result["errorcode"] = ResultCode.FAIL
        result["message"] = "删除处理成功"
    return JsonResponse(result)
示例#6
0
def adddeal(request):

    result = {}

    if request.method == "POST":
        deal = request.POST.get("deal", None)  # 读取post数据,None为默认值
        userid_source = request.POST.get("userid_source",
                                         0)  # 读取post数据,None为默认值
        diaryid_source = request.POST.get("diaryid_source",
                                          0)  # 读取post数据,None为默认值
        qunid_source = request.POST.get("qunid_source", 0)  # 读取post数据,None为默认值
        userid_destination = request.POST.get("userid_destination",
                                              0)  # 读取post数据,None为默认值
        diaryid_destination = request.POST.get("diaryid_destination",
                                               0)  # 读取post数据,None为默认值
        qunid_destination = request.POST.get("qunid_destination",
                                             0)  # 读取post数据,None为默认值
    if request.method == "GET":
        deal = request.GET.get("deal", None)  # 读取get数据,None为默认值
        userid_source = request.GET.get("userid_source", 0)  # 读取get数据,None为默认值
        diaryid_source = request.GET.get("diaryid_source",
                                         0)  # 读取get数据,None为默认值
        qunid_source = request.GET.get("qunid_source", 0)  # 读取get数据,None为默认值
        userid_destination = request.GET.get("userid_destination",
                                             0)  # 读取get数据,None为默认值
        diaryid_destination = request.GET.get("diaryid_destination",
                                              0)  # 读取get数据,None为默认值
        qunid_destination = request.GET.get("qunid_destination",
                                            0)  # 读取get数据,None为默认值

    print("添加更多操作接口参数:操作类型", deal, "源用户id", userid_source, "源日志id:",
          diaryid_source, "目的用户id:", userid_destination, "目的日志id:",
          diaryid_destination, "源群id:", qunid_source, "目的群id:",
          qunid_destination)

    if (userid_source == userid_destination):
        result["data"] = ""
        result["respcode"] = ResultCode.FAIL
        result["errorcode"] = ResultCode.FAIL
        result["message"] = "添加处理失败"
        return JsonResponse(result)

    more = More()
    more.deal = deal
    more.userid_source = userid_source
    more.userid_destination = userid_destination
    more.diaryid_source = diaryid_source
    more.diaryid_destination = diaryid_destination
    more.qunid_source = qunid_source
    more.qunid_destination = qunid_destination
    more1 = MoreDAO.selectmoreInfomore(more)
    if (more1):
        result["data"] = model_to_dict(more1)
        result["respcode"] = ResultCode.SUCCESS
        result["errorcode"] = ResultCode.SUCCESS
        result["message"] = "添加处理成功"

    else:
        try:
            MoreDAO.adddeal(more)
            more = MoreDAO.selectmoreInfomore(more)
            result["data"] = model_to_dict(more)
            result["respcode"] = ResultCode.SUCCESS
            result["errorcode"] = ResultCode.SUCCESS
            result["message"] = "添加处理成功"

            #如果是日志点赞则添加到日志属性中去
            if (diaryid_destination != 0):
                diary = DiaryDAO.selectDiary(diaryid_destination)
                if (diary):
                    if (deal == ResultCode.DIARY_ZAN):
                        diary.zannum = diary.zannum + 1
                        DiaryDAO.updatediary(diary)
                    elif (deal == ResultCode.DIARY_SHOUCANG):
                        diary.shoucangnum = diary.shoucangnum + 1
                        DiaryDAO.updatediary(diary)
                    elif (deal == ResultCode.DIARY_TUIJIAN):
                        diary.tuijiannum = diary.tuijiannum + 1
                        DiaryDAO.updatediary(diary)
            #如果是群组点赞  则添加到群属性中
            elif (qunid_destination != 0):
                qun = QunDAO.getqunInfoqunid(qunid_destination)
                if (qun):
                    if (deal == ResultCode.QUN_ZAN):
                        qun.zannum = qun.zannum + 1
                        QunDAO.updatequnInfoqun(qun)

                    elif (deal == ResultCode.QUN_SHOUCANG):
                        qun.shoucangnum = qun.shoucangnum + 1
                        QunDAO.updatequnInfoqun(qun)
                    elif (deal == ResultCode.QUN_TUIJIAN):
                        qun.tuijiannum = qun.tuijiannum + 1
                        QunDAO.updatequnInfoqun(qun)

            #如果是用户点赞  则添加到用户属性中
            elif (userid_destination != 0):
                user = UserDAO.getUserInfoId(userid_destination)
                if (user):
                    if (deal == ResultCode.USER_ZAN):
                        user.zannum = user.zannum + 1
                        UserDAO.updateUserInfo(user)
                    if (deal == ResultCode.USER_SHOUCANG):
                        user.shoucangnum = user.shoucangnum + 1
                        UserDAO.updateUserInfo(user)
                    if (deal == ResultCode.USER_TUIJIAN):
                        user.tuijiannum = user.tuijiannum + 1
                        UserDAO.updateUserInfo(user)

        except Exception as e:
            result["data"] = ""
            result["respcode"] = ResultCode.FAIL
            result["errorcode"] = ResultCode.FAIL
            result["message"] = "添加处理失败"

    return JsonResponse(result)