def act_user(request): ''' 踢过球的人列表 :param request: :return: ''' if request.method == 'GET': try: openid = request.GET.get('openid') my_id = QyMember.objects.get(openid=openid).id objs = QyActor_activities.objects.filter(member_id=my_id) act_list = [] for obj in objs: act_list.append(obj.activity_id) ac_list = [] obj = QyActivity.objects.filter(pk__in=act_list,activity_state=2) for ob in obj: ac_list.append(ob.id) obs = QyActor_activities.objects.filter(activity_id__in=ac_list) meb_list = [] for ob in obs: if ob.member_id is not my_id: meb_list.append(ob.member_id) obj = QyMember.objects.filter(pk__in=meb_list).distinct() pag = mypage(request.GET.get('page'), obj) serializer = Member_feedback(pag['page_list'], many=True) return JSONResponse(0,serializer.data) except: return JSONResponse(1007)
def select_member_list(request): ''' 根据条件获取指定用户列表 :param request: :return: ''' if request.method == 'POST': try: phone_num = json.loads(request.body).get('phoneNum') nick_name = json.loads(request.body).get('nickName') page = json.loads(request.body).get('page') if nick_name: user_list = QyMember.objects.filter( nickname__contains=nick_name) elif phone_num: user_list = [] # 查询手机号不为空的用户 for x in QyMember.objects.filter(phonenum__isnull=False): if str(x.phonenum).__contains__(str(phone_num)): user_list.append(x) else: user_list = QyMember.objects.all() pag = mypage(page, user_list) serializer = MemberSerializer(pag['page_list'], many=True) return JSONResponse(0, serializer.data, pag['page_sum'], pag['page_count']) except: return JSONResponse(1000) else: return JSONResponse(1054)
def myParticipatingActivity(request): ''' 首页 我已报名的且未过期或已取消的活动详情 :param request:openid,sort,address :return: ''' if request.method == 'GET': try: openid = request.GET.get('openid') sort = request.GET.get('sort') member_id = QyMember.objects.get(openid=openid).id # 我组织的活动 my_objs = QyActivity.objects.filter(originator_id=member_id) act_id = [] for x in my_objs: act_id.append(x.id) # 我参加的活动 objs = QyActor_activities.objects.filter(member_id=member_id) objs_act = [] for y in objs: objs_act.append(y.activity_id) # 取并集 act = list(set(act_id).union(set(objs_act))) # 筛选其中没有过期的活动 activities_id = [] for x in act: obj = QyActivity.objects.filter(pk=x,activity_state__lte=1) if obj: activities_id.append(obj[0].id) # 对筛选过的活动排序 if sort == '3': address = request.GET.get('address') activities = QyActivity.objects.filter( pk__in=activities_id, address_detailed__contains=address) else: activities = QyActivity.objects.filter( pk__in=activities_id).order_by(my_sort(sort)) # 分页 pag = mypage(request.GET.get('page'), activities) # 序列化 serializer = Act_info(pag['page_list'],many=True) return JSONResponse(0,serializer.data) except Exception as e: return JSONResponse(1007)
def select_recharge_record(request): ''' 根据条件获取指定充值/提现列表 :param request: :return: ''' if request.method == 'POST': try: state = json.loads(request.body).get('pay_state') phone_num = json.loads(request.body).get('phoneNum') nick_name = json.loads(request.body).get('nickName') pay_type = json.loads(request.body).get('pay_type') if state and (not nick_name) and (not phone_num): recharge_list = QyPay.objects.filter( pay_state=state, pay_type=pay_type).order_by('-id') elif nick_name and (not state) and (not phone_num): member_list = QyMember.objects.filter( nickname__contains=nick_name) recharge_list = Pay_ergodic(member_list, pay_type) elif phone_num and (not nick_name) and (not state): member_list = [] for x in QyMember.objects.filter(phonenum__isnull=False): if str(x.phonenum).__contains__(str(phone_num)): member_list.append(x) recharge_list = Pay_ergodic(member_list, pay_type) elif state and nick_name: member_list = QyMember.objects.filter( nickname__contains=nick_name) recharge_list = Pay_ergodic(member_list, pay_type, state) elif state and phone_num: member_list = [] for x in QyMember.objects.filter(phonenum__isnull=False): if str(x.phonenum).__contains__(str(phone_num)): member_list.append(x) recharge_list = Pay_ergodic(member_list, pay_type, state) else: recharge_list = QyPay.objects.filter( pay_type=pay_type).order_by('-id') # 进行分页 pag = mypage(json.loads(request.body).get('page'), recharge_list) serializer = PaySerializer(pag['page_list'], many=True) return JSONResponse(0, serializer.data, pag['page_sum'], pag['page_count']) except: return JSONResponse(1000) else: return JSONResponse(1054)
def getFeedbackAll(request): ''' 按条件查询所有的反馈意见 :param request: :return: ''' if request.method == 'GET': try: phone = request.GET.get('phone') nickname = request.GET.get('nickname') state = request.GET.get('state') if nickname or phone: member_id = [] if phone and nickname: member = QyMember.objects.filter(phonenum=phone, nickname=nickname) for x in member: member_id.append(x.id) elif phone and (not nickname): member = QyMember.objects.filter(phonenum__icontains=phone) for y in member: member_id.append(y.id) elif nickname and (not phone): member = QyMember.objects.filter( nickname__icontains=nickname) for z in member: member_id.append(z.id) # print(member_id) objs = QyFeedback.objects.filter( member_id__in=member_id).order_by('-add_time') elif state: objs = QyFeedback.objects.filter( Feedback_state=int(state)).order_by('-add_time') else: objs = QyFeedback.objects.all().order_by('-add_time') pag = mypage(request.GET.get('page'), objs) serializer = Feedback(pag['page_list'], many=True) return JSONResponse(0, serializer.data, pag['page_sum'], pag['page_count']) except Exception as e: return JSONResponse(1054)
def Transaction_details(request): ''' 获取当前用户所有交易明细 :param request: :return: ''' if request.method == 'GET': try: openid = request.GET.get('openid') member_id = QyMember.objects.get(openid=openid).id pay = QyPay.objects.filter(member_id=member_id).order_by('-id') pag = mypage(request.GET.get('page'), pay) serializer = PaySerializer(pag['page_list'], many=True) return JSONResponse(0, serializer.data, pag['page_sum'], pag['page_count']) except: return JSONResponse(1000) else: return JSONResponse(1054)
def adminAll(request): ''' 获取所有后台用户 :param request: :return: ''' if request.method == 'GET': try: username = request.GET.get('username') if username: objs = User.objects.filter(username__icontains=username) if not objs: return JSONResponse(2000) else: objs = User.objects.all() page = mypage(request.GET.get('page'), objs) s = Admin_user(page['page_list'], many=True) return JSONResponse(0, s.data, page['page_sum'], page['page_count']) except: return JSONResponse(1054)
def get_recharge_record(request): ''' 获取当前用户所有充值/提现记录 :param request: :return: ''' if request.method == 'GET': try: member_id = QyMember.objects.get( openid=request.GET.get('openid')).id obj = QyPay.objects.filter( member_id=member_id, pay_type=request.GET.get('pay_type')).order_by('-id') # 进行分页 pag = mypage(request.GET.get('page'), obj) serializer = PaySerializer(pag['page_list'], many=True) return JSONResponse(0, serializer.data, pag['page_sum'], pag['page_count']) except: return JSONResponse(1000) else: return JSONResponse(1054)
def getMessageAll(request): ''' 所有与指定活动相关的留言及回复 :param request: :return: ''' if request.method == 'GET': try: page = request.GET.get('page') activity_id = request.GET.get('activity') objs = QyMessage.objects.filter(activity=activity_id) p = mypage(page, objs) obj = p['page_list'] total = p['page_sum'] serializer = MessageSerializers(obj, many=True) return JSONResponse(0, serializer.data, total) except Exception as e: return JSONResponse(1001) else: return JSONResponse(1054)
def Activity_org_list(request): ''' 获取我曾经组织过的活动列表 :param request: :return: ''' if request.method == 'GET': try: originator_id = QyMember.objects.get( openid=request.GET.get('openid')).id obj = QyActivity.objects.filter( originator_id=originator_id, activity_state=2 ).order_by('-id') # 进行分页 pag = mypage(request.GET.get('page'), obj) serializer = Act_info(pag['page_list'], many=True) return JSONResponse(0,serializer.data,pag['page_sum']) except: return JSONResponse(1007) else: return JSONResponse(1054)
def myApplication(request): ''' 查询'本人'发出的申请信息 :param request: :return: ''' if request.method == 'GET': try: page = request.GET.get('page') openid = request.GET.get('applicant_openid') id = QyMember.objects.get(openid=openid).id objs = QyNews.objects.filter(applicant_id=int(id)) p = mypage(page, objs) obj = p.get('page_list') total = p.get('page_sum') serializer = News_getRespondent(obj, many=True) return JSONResponse(0, serializer.data, total) except: return JSONResponse(1007) else: return JSONResponse(1054)
def Activity_my_list(request): ''' 获得我参加过的所有活动列表 :param request:openid :return: ''' if request.method == 'GET': try: member_id = QyMember.objects.get( openid=request.GET.get('openid')).id objs = QyActor_activities.objects.filter( member_id=member_id,reg_state=1) objs_act = [] for y in objs: objs_act.append(y.activity_id) obj = QyActivity.objects.filter( pk__in=objs_act,activity_state=2) pag = mypage(request.GET.get('page'), obj) serializer = Act_info(pag['page_list'],many=True) return JSONResponse(0,serializer.data,pag['page_sum']) except Exception as q: return JSONResponse(1007) else: return JSONResponse(1054)
def my_historical_act(request): ''' 我的历史活动 :param request: openid :return: ''' if request.method == 'GET': try: openid = request.GET.get('openid') member_id = QyMember.objects.get(openid=openid).id # 我组织的活动 my_objs = QyActivity.objects.filter(originator_id=member_id) act_id = [] for x in my_objs: act_id.append(x.id) # 我参加的活动 objs = QyActor_activities.objects.filter(member_id=member_id) objs_act = [] for y in objs: objs_act.append(y.activity_id) # 取并集 act = list(set(act_id).union(set(objs_act))) # 我的历史活动 activities = QyActivity.objects.filter( pk__in=act,activity_state=2).order_by('-id') # 分页 pag = mypage(request.GET.get('page'), activities) # 序列化 serializer = Act_info(pag['page_list'],many=True) return JSONResponse(0,serializer.data) except Exception as e: return JSONResponse(1007)
def Activity_filter(request): ''' 筛选活动 :param request: :return: ''' if request.method == 'GET': try: address_detailed = request.GET.get('address_detailed') formater = request.GET.get('formater') type = request.GET.get('type') org_nickname = request.GET.get('org_nickname') if address_detailed and (not formater) and (not type): obj = QyActivity.objects.filter( address_detailed__contains=address_detailed, activity_state__lte=2).order_by('-id') elif org_nickname and (not formater) and (not type): originator_id = [] originator = QyMember.objects.filter( nickname__contains=request.GET.get('org_nickname')) for ori in originator: originator_id.append(ori.id) obj = QyActivity.objects.filter( originator_id__in=originator_id, activity_state__lte=2).order_by('-id') elif formater and (not address_detailed) \ and (not type) and (not org_nickname): obj = QyActivity.objects.filter( formater=formater,activity_state__lte=2).order_by('-id') elif type and (not formater) and (not address_detailed) \ and (not org_nickname): obj = QyActivity.objects.filter( type=type,activity_state__lte=2).order_by('-id') elif address_detailed and formater and (not type): obj = QyActivity.objects.filter( address_detailed__contains=address_detailed, formater=formater,activity_state__lte=2).order_by('-id') elif address_detailed and type and (not formater): obj = QyActivity.objects.filter( address_detailed__contains=address_detailed, type=type,activity_state__lte=2).order_by('-id') elif org_nickname and formater and (not type): originator_id = [] originator = QyMember.objects.filter( nickname__contains=request.GET.get('org_nickname')) for ori in originator: originator_id.append(ori.id) obj = QyActivity.objects.filter( originator_id__in=originator_id,formater=formater, activity_state__lte=2).order_by('-id') elif org_nickname and type and (not formater): originator_id = [] originator = QyMember.objects.filter( nickname__contains=request.GET.get('org_nickname')) for ori in originator: originator_id.append(ori.id) obj = QyActivity.objects.filter( originator_id__in=originator_id,type=type, activity_state__lte=2).order_by('-id') elif formater and type and (not address_detailed) \ and (not org_nickname): obj = QyActivity.objects.filter( formater=formater,type=type, activity_state__lte=2).order_by('-id') elif formater and type and address_detailed: obj = QyActivity.objects.filter( address_detailed__contains=address_detailed, formater=formater,type=type, activity_state__lte=2).order_by('-id') elif formater and type and org_nickname: originator_id = [] originator = QyMember.objects.filter( nickname__contains=request.GET.get('org_nickname')) for ori in originator: originator_id.append(ori.id) obj = QyActivity.objects.filter( originator_id__in=originator_id, type=type,formater=formater, activity_state__lte=2).order_by('-id') else: obj = QyActivity.objects.filter( activity_state__lte=2).order_by('-id') # 进行分页 pag = mypage(request.GET.get('page'), obj) serializer = Act_info(pag['page_list'], many=True) return JSONResponse(0, serializer.data, pag['page_sum'], pag['page_count']) except: return JSONResponse(1007)
def recommend_activity(request): ''' 推荐的活动列表 :param request: :return: ''' if request.method == 'GET': try: openid = request.GET.get('openid') my_id = QyMember.objects.get(openid=openid).id # 查询 所有不是本人举办的且状态为可参加的活动 objs_notOriginator = QyActivity.objects.filter( activity_state=1).exclude(originator_id=my_id) notOriginator = [] for x in objs_notOriginator: notOriginator.append(x.id) # 获取其中 本人没有参与的活动 notActor = [] for y in notOriginator: actor_activity = QyActor_activities.objects.filter( activity_id=y, member_id=my_id) if not actor_activity: notActor.append(y) # 获取其中 活动状态为可参加的 并排序 sort = request.GET.get('sort') address = request.GET.get('address') activity_time = request.GET.get('activity_time') formater = request.GET.get('formater') # 地点 if sort == '3': objs = QyActivity.objects.filter( pk__in=notActor, activity_state=1, address_detailed__contains=address ) # 时间 elif sort == '1': objs = QyActivity.objects.filter( pk__in=notActor, activity_state=1, activity_time__gte=time_stamp(activity_time).get('star'), activity_time__lte=time_stamp(activity_time).get('end') ) # 赛制 elif sort == '2': objs = QyActivity.objects.filter( pk__in=notActor, activity_state=1, formater = formater ) else: objs = QyActivity.objects.filter( pk__in=notActor, activity_state=1 ).order_by(my_sort(sort)) # 判断活动类别是 散踢(可见)/队内(与origin为好友可见) objs_actor = [] for obj in objs: if obj.type == 0: objs_actor.append(obj) elif obj.type == 1: friend = QyGroup.objects.filter( member_a_id=obj.originator_id, member_b_id=my_id) if friend: objs_actor.append(obj) else: pass else: pass pag = mypage(request.GET.get('page'), objs_actor) serializer = Act_info(pag['page_list'], many=True) return JSONResponse(0,serializer.data) except Exception as e: return JSONResponse(1007) else: return JSONResponse(1054)