Ejemplo n.º 1
0
	def change_order_status(self,orderNum,new_status):
		"""修改订单状态   default0   has_pay:1  not_pay:2    new_status(true,false) """
		order_info = self.find_data(['pay_status','uid','credits'],get_some=False,orderNum=orderNum)
		order_status = order_info['pay_status']
		if not order_status: #只有订单状态没有发生任何改变才会修改订单状态
		    change_into = 2 if new_status == 'false' else 1
		    self.update_db({'pay_status':change_into},orderNum=orderNum)
		    if new_status == 'false':  #如果回调的数据是失败的,那么返回用户积分
		        UsersModel.get_instance().change_user_point(order_info['uid'],order_info['credits']) #返还用户积分(如果失败)
		return True
Ejemplo n.º 2
0
 def change_order_status(self, orderNum, new_status):
     """修改订单状态   default0   has_pay:1  not_pay:2    new_status(true,false) """
     order_info = self.find_data(['pay_status', 'uid', 'credits'],
                                 get_some=False,
                                 orderNum=orderNum)
     order_status = order_info['pay_status']
     if not order_status:  #只有订单状态没有发生任何改变才会修改订单状态
         change_into = 2 if new_status == 'false' else 1
         self.update_db({'pay_status': change_into}, orderNum=orderNum)
         if new_status == 'false':  #如果回调的数据是失败的,那么返回用户积分
             UsersModel.get_instance().change_user_point(
                 order_info['uid'], order_info['credits'])  #返还用户积分(如果失败)
     return True
Ejemplo n.º 3
0
 def get_interact(self, comm_id, page):
     """直接根据团队id获取这个互动  这块还是先查到这条数据的id 再查找多条数据"""
     # return [rows for rows in self.m_c.find({search_key:int(id)})]
     page = int(page)
     per_page = 10
     interact_info = self.m_c.find({
         'comm_id': comm_id
     }, {
         'content': 1,
         'time': 1,
         '_id': 0,
         'uid': 1
     }).skip(per_page * page).limit(per_page).sort([('time', -1)])
     interact_list = []
     current_time = PublicFunc.get_current_stamp()
     index = page * per_page
     for info in interact_info:
         index += 1
         info['time'] = PublicFunc.time_format_span(info['time'],
                                                    current_time)
         info['index'] = index
         if not info['uid']:
             info['avatar'] = 'http://101.200.214.68/Uploads/head.png'
             info['nickname'] = '游客'
         else:
             user_info = UsersModel.get_instance().get_import_user_info(
                 info['uid'], ['avatar', 'username'])
             info['avatar'] = user_info['avatar']
             info['nickname'] = user_info['username']
         del info['uid']
         interact_list.append(info)
     return interact_list
Ejemplo n.º 4
0
 def get_community_rank(self, comm_id, page):
     """
 	function: 获取圈子排名
 	author: yinshuai 
 	input param:
 	        comm_id 跑团主键id
 	        page 分页
 	return: 
 	        跑团用户排名数据
 	"""
     page = int(page)
     per_page = 10
     # comm_run_list = self.m_c.find({"_id":ObjectId(comm_id)},{'uid':1,'distance':1,'_id':0}).sort([('distance',-1)]).skip(page*per_page).limit(per_page)
     # comm_info = self.m_c.find({"_id":ObjectId(comm_id)},{'_id':0,'gid':0,'comm_name':0,'comm_member':{"$slice":[0,3]}})
     # comm_info = self.m_c.find_one({"_id":ObjectId(comm_id)},{"$or":[{'comm_member':1},{'comm_member':{"$slice":[0,3]}}]})
     comm_info = self.m_c.find_one({"_id": ObjectId(comm_id)}, {
         'comm_member': {
             "$slice": [per_page * page, per_page]
         },
         'gid': 1
     })
     comm_member = comm_info['comm_member']
     for member_info in comm_member:
         user_info = UsersModel.get_instance().get_import_user_info(
             member_info['uid'], ['avatar', 'nickname'])
         member_info['avatar'] = user_info['avatar']
         if not 'distance' in member_info: member_info['distance'] = 0
         member_info['nickname'] = user_info['nickname'] if user_info[
             'nickname'] else '小跑男'
     return comm_member
Ejemplo n.º 5
0
 def __get_group_user_info_via_uid_list(self, uid_list):
     group_user_info_list = []
     for uid in uid_list:
         group_user_info_list.append(
             UsersModel.get_instance().get_import_user_info(
                 uid, ['avatar', 'point', 'nickname', 'uid']))
     return group_user_info_list
Ejemplo n.º 6
0
 def __get_group_user_info_via_uid_list(self,uid_list):
 	info_return = [] 
 	for uid in uid_list:
         user_info = UsersModel.get_instance().get_import_user_info(uid,['nickname','point','uid','avatar'])
 		# info_return.append(UsersModel.get_instance().get_import_user_info(uid,['username','point','uid','avatar'])) 
         user_info['username'] = user_info['nickname'] if user_info['nickname'] else options.default_nick_name
         user_info['uid'] = uid
         info_return.append(user_info)
 	return info_return
Ejemplo n.º 7
0
 def __get_group_user_info_via_uid_list(self, uid_list):
     info_return = []
     for uid in uid_list:
         user_info = UsersModel.get_instance().get_import_user_info(
             uid, ['nickname', 'point', 'uid', 'avatar'])
         # info_return.append(UsersModel.get_instance().get_import_user_info(uid,['username','point','uid','avatar']))
         user_info['username'] = user_info['nickname'] if user_info[
             'nickname'] else options.default_nick_name
         user_info['uid'] = uid
         info_return.append(user_info)
     return info_return
Ejemplo n.º 8
0
	def get_reward_list(self,page):
		page = int(page)
		per_page = 30
		reward_list = self.find_data(['description','timestamp','id','uid'],get_some=(page*5,per_page)) #aaaaaaa
		current_time = PublicFunc.get_current_stamp()
		for index,reward in enumerate(reward_list):
			user_info = UsersModel.get_instance().get_import_user_info(reward['uid'],['avatar','nickname'])
			reward_list[index]['nickname'] = '小跑男' if not user_info['nickname']  else user_info['nickname']  
			reward_list[index]['avatar'] = user_info['avatar']
			reward_list[index]['time'] = PublicFunc.time_format_span(str(reward['timestamp'])[:-3],current_time) 
			del reward_list[index]['timestamp']
		return reward_list
Ejemplo n.º 9
0
 def get_reward_list(self, page):
     page = int(page)
     per_page = 30
     reward_list = self.find_data(['description', 'timestamp', 'id', 'uid'],
                                  get_some=(page * 5, per_page))  #aaaaaaa
     current_time = PublicFunc.get_current_stamp()
     for index, reward in enumerate(reward_list):
         user_info = UsersModel.get_instance().get_import_user_info(
             reward['uid'], ['avatar', 'nickname'])
         reward_list[index]['nickname'] = '小跑男' if not user_info[
             'nickname'] else user_info['nickname']
         reward_list[index]['avatar'] = user_info['avatar']
         reward_list[index]['time'] = PublicFunc.time_format_span(
             str(reward['timestamp'])[:-3], current_time)
         del reward_list[index]['timestamp']
     return reward_list
Ejemplo n.º 10
0
 def get_recent_run_man_single(self,eid):
 	"""获取最近运动的用户 针对于仅仅有一个项目的"""
 	recent_man_list = []
 	show_num = 6 
 	jump = 0 
 	while len(recent_man_list) < show_num:
 		user_run_list = self.find_data(['uid','step_count'],get_some=(jump,show_num),order=' id desc ',status=0)
 		if not user_run_list: break
 		jump += show_num
 		for user_run in user_run_list:
 			user_info = UsersModel.get_instance().get_import_user_info(user_run['uid'],['avatar','username','nickname'])
 			user_run['nickname'] = user_info['nickname'] if user_info['nickname'] else '小跑男'
 			user_run['avatar'] = user_info['avatar']
 			recent_man_list.append(user_run)
 			if len(recent_man_list) == show_num: break
 		if len(recent_man_list) == show_num: break
 	return recent_man_list
Ejemplo n.º 11
0
	def get_note_list(self,code,page):
		"""
		function:获取帖子列表
             置顶的排在前面,第二顺序为发布时间,时间越晚越靠前
		"""
		note_per_page = int(options.note_per_page)
		page = int(page)
		if code:
			note_list = list(self.m_c.find({'status':0,'code':code},{'content':0,'status':0}).sort([('up',-1),('time',-1)]).skip(note_per_page*page).limit(note_per_page))
		else:
			note_list = list(self.m_c.find({'status':0},{'content':0,'status':0}).sort([('up',-1),('time',-1)]).skip(note_per_page*page).limit(note_per_page))
		current_time = PublicFunc.get_current_stamp()
		for note in note_list:
			note['time'] = PublicFunc.time_format_span(note['time'],current_time)
			user_info = UsersModel.get_instance().get_import_user_info(note['uid'],['nickname','avatar'])
			note['avatar'] = user_info['avatar'] 
			note['nickname'] = user_info['nickname'] if user_info['nickname'] else options.default_nick_name
			note['is_up'] = 1 if int(note['up']) else 0 
			del note['up']
			note['note_id'] = str(note['_id'])
			del note['_id']
		return note_list
Ejemplo n.º 12
0
 def get_community_rank(self,comm_id,page):
 	"""
 	function: 获取圈子排名
 	author: yinshuai 
 	input param:
 	        comm_id 跑团主键id
 	        page 分页
 	return: 
 	        跑团用户排名数据
 	"""
 	page = int(page)
 	per_page = 10
 	# comm_run_list = self.m_c.find({"_id":ObjectId(comm_id)},{'uid':1,'distance':1,'_id':0}).sort([('distance',-1)]).skip(page*per_page).limit(per_page)
 	# comm_info = self.m_c.find({"_id":ObjectId(comm_id)},{'_id':0,'gid':0,'comm_name':0,'comm_member':{"$slice":[0,3]}})
 	# comm_info = self.m_c.find_one({"_id":ObjectId(comm_id)},{"$or":[{'comm_member':1},{'comm_member':{"$slice":[0,3]}}]})
 	comm_info = self.m_c.find_one({"_id":ObjectId(comm_id)},{'comm_member':{"$slice":[per_page*page,per_page]},'gid':1})
     comm_member = comm_info['comm_member']
 	for member_info in comm_member:
 		user_info = UsersModel.get_instance().get_import_user_info(member_info['uid'],['avatar','nickname'])
 		member_info['avatar'] = user_info['avatar']
     	if not 'distance' in member_info: member_info['distance'] = 0
 		member_info['nickname'] = user_info['nickname'] if user_info['nickname'] else '小跑男'
 	return comm_member
Ejemplo n.º 13
0
 def get_interact(self,comm_id,page):
 	"""直接根据团队id获取这个互动  这块还是先查到这条数据的id 再查找多条数据"""
 	# return [rows for rows in self.m_c.find({search_key:int(id)})]
 	page = int(page)
 	per_page = 10 
 	interact_info = self.m_c.find({'comm_id':comm_id},{'content':1,'time':1,'_id':0,'uid':1}).skip(per_page*page).limit(per_page).sort([('time',-1)])
 	interact_list = [] 
 	current_time = PublicFunc.get_current_stamp()
 	index = page * per_page
 	for info in interact_info:
 		index += 1 
 		info['time'] = PublicFunc.time_format_span(info['time'],current_time)
 		info['index'] = index
 		if not info['uid']:
 			info['avatar'] = 'http://101.200.214.68/Uploads/head.png'
 			info['nickname'] = '游客'
 		else:
 			user_info = UsersModel.get_instance().get_import_user_info(info['uid'],['avatar','username'])
 			info['avatar'] = user_info['avatar']
 			info['nickname'] = user_info['username']
 		del info['uid']
 		interact_list.append(info)
 	return interact_list
Ejemplo n.º 14
0
    def __init__(self):
	    DbBase.__init__(self)
	    self.usersmodel = UsersModel.get_instance()
Ejemplo n.º 15
0
    def __get_group_user_info_via_uid_list(self,uid_list):
		group_user_info_list = []
		for uid in uid_list:
			group_user_info_list.append(UsersModel.get_instance().get_import_user_info(uid,['avatar','point','nickname','uid']))
		return group_user_info_list