Exemplo n.º 1
0
	def post(self):
		act = self.get_argument('act','')
		sellername = self.get_argument('sellername','')
		phone = self.get_argument('phone','')
		appid = self.get_argument('appid','')
		oldkey = self.get_argument('oldkey','')
		appkey = self.get_argument('appkey','')
		status = self.get_argument('status','')
		duty = self.get_argument('duty','')
		id = self.get_argument('id','')
		card = cardmodel(self)
		if act == 'add':
			appkey = hashlib.sha1( appkey ).hexdigest()
			res = card.addseller(sellername,phone,appid,appkey,status,duty)
		elif act == 'edit':
			sellerinfo = card.sellerinfo( id )
			sett = ''
			if oldkey and appkey:
				#有修改密码
				if hashlib.sha1( oldkey ).hexdigest() == sellerinfo['appkey']:
					#密码验证通过
					appkey = hashlib.sha1( appkey ).hexdigest()
					sett += "appkey='%s'," %appkey
				else:
					self.prompt( 1, apimsg.notice(201), 'javascript:history.go(-1)' )
					return
			sett += "sellername='%s',phone='%s',appid='%s',status=%s,duty='%s'" %(sellername,phone,appid,status,duty)
			where = "id=%s" %id
			res = card.editseller( sett, where )
		if res:
			self.prompt( 1, apimsg.notice(305), '/admin/card_seller' )
		else:
			self.prompt( 0, apimsg.notice(307), 'javascript:history.go(-1)' )
Exemplo n.º 2
0
 def get(self):
     session = self.get_secure_cookie('session')
     card = cardmodel(self)
     username = card.getusername( session )
     user = usermodel(self)
     uinfo = user.userinfo(username)
     money = self.get_argument('money','0')
     bank = self.get_argument('bank','alipay') 
     log = logmodel(self)
     if money.isdigit():
         if int(money) > 0: 
             #订单号
             oid = log.build_alipay(2)
             #订单名称
             subject = u'充值'+str( money )+u'元'
             #描述
             body = subject
             #充钱
             total_fee = money
             #写入临时订单表
             try:
                 log.save_alipay( oid, uinfo['id'], total_fee, username+subject, int(time.time()) )
                 log.commit_submit()
                 self.redirect( create_direct_pay_by_user( oid, subject, body, bank, total_fee ) )
             except:
                 self.finish('2')
         else:
             self.finish('1')
     else:
         self.finish('0')
Exemplo n.º 3
0
	def get(self):
		id = self.get_argument('id','')
		page = self.get_argument('page',1)
		start = self.get_argument('start','')
		end = self.get_argument('end','')
		if id:
			where = "WHERE seller = %s" %id
			if start:
				st = time.mktime(time.strptime(start,'%Y-%m-%d'))
				where += " AND acttime >= %s" %int(st)
			if end:
				en = time.mktime(time.strptime(end,'%Y-%m-%d'))
				where += " AND acttime <= %s" %int(en)
		else:
			self.prompt( 0, apimsg.notice(400), 'javascript:history.go(-1)' )
			return
		card = cardmodel(self)
		rlist = card.seller_records( where, page, 15 )
		if rlist:
			page_bar = card.page_bar(1)
			pinfo = card.page_bar(2)
		else:
			page_bar = None
			pinfo = {'this_page':1,'all_page':0,'per_page':15}
		search = {'start':start,'end':end,'id':id}
		self.render("admin/seller_records.html", rlist=rlist, search=search,page_bar=page_bar,pinfo=pinfo )
Exemplo n.º 4
0
	def post(self):
		cardno = self.get_argument('cardno','')
		cardid = self.get_argument('cardid','')
		cardtype = self.get_argument('cardtype','')
		phone = self.get_argument('phone','')
		nickname = self.get_argument('nickname','')
		password = self.get_argument('password','')
		valid = validate()
		valid.Add( cardno,'识别码', ['NoEmpty','Isdigit'] )
		valid.Add( cardtype,'分类', ['NoEmpty','Isdigit'] )
		valid.Add( cardid,'卡id', ['NoEmpty','Isdigit'] )
		valid.Add( phone,'手机', ['NoEmpty','Isdigit'],11,11 )
		if not valid._CheckMate():
			self.finish( self.respone_data( 0, apimsg.notice(400) ) )
			return
		user = usermodel(self)
		userid = user.carduser(cardno,cardtype,cardid)
		if userid:
			onlyphone = user.only_phone( phone, userid['user_id'] )
			if not onlyphone:
				self.finish( self.respone_data( 0, apimsg.notice(228) ) )
				return
			res = user.uinfo_edit(nickname=nickname,phone=phone,mail='',sex=1,id=userid['user_id'])
			if password:
				card = cardmodel(self)
				card.editinfo('pwd',self.md5(password),userid['user_id'])
			if res:
				self.finish( self.respone_data( 1 ) )
			else:
				self.finish( self.respone_data( 0, apimsg.notice(307) ) )
		else:
			self.finish( self.respone_data( 0, apimsg.notice(222) ) )
Exemplo n.º 5
0
	def get(self):
		card = cardmodel(self)
		type_list = card.card_type()
		if not type_list:
			type_list = []
		pinfo = {}
		self.finish( self.respone_list( type_list, pinfo ) )
Exemplo n.º 6
0
	def post(self):
		cardtype = self.get_argument('cardtype','')
		cardno = self.get_argument('cardno','')
		nickname = self.get_argument('nickname','')
		phone = self.get_argument('phone','')
		balance = self.get_argument('balance','')
		valid = validate()
		valid.Add( cardtype,'分类', ['NoEmpty','Isdigit'] )
		valid.Add( cardno,'识别码', ['NoEmpty','Isdigit'] )
		valid.Add( phone,'手机', ['NoEmpty','Isdigit'],11,11 )
		if not valid._CheckMate():
			self.finish( self.respone_data( 0, valid._Message() ) )
			return
		user = usermodel(self)
		username = user.used_name()
		res = user.register(username=username,password=username,cardno=cardno,cardtype=cardtype)
		id = user.get_insert_id()
		if res and id:
			#更改电话
			user.editinfo('phone',phone,username)
			if nickname:
				user.editinfo('nickname',nickname,username)
			card = cardmodel(self)
			where = "where c.user_id = %s" %id
			info = card.card_infomation( where ) 
			#新卡充值
			ser.purse_edit( id=id, balance=balance )
			#返回数据
			self.finish( self.respone_data( 1, info ) )
		else:
			self.finish( self.respone_data( 0, apimsg.notice(307) ) )
Exemplo n.º 7
0
	def get(self):
		cardtype = self.get_argument('cardtype','')
		page = self.get_argument('page','1')
		per_page = self.get_argument('per_page','10')
		where = ' where u.status < 2 '
		valid = validate()
		valid.Add( page,'当前页', ['NoEmpty','Isdigit'] )
		valid.Add( per_page,'每页显示', ['NoEmpty','Isdigit'] )
		if not valid._CheckMate():
			self.finish( self.respone_data( 0, '分页参数异常' ) )
			return
		if cardtype:
			valid.Add( cardtype,'分类', ['Isdigit'] )
			if not valid._CheckMate():
				self.finish( self.respone_data( 0, valid._Message() ) )
				return
			where += " AND c.cardtype = %d" %int(cardtype)
		card = cardmodel(self)
		clist = card.card_list( where, int(page), int(per_page) )
		if clist:
			pinfo = card.page_bar(2)
		else:
			clist = []
			pinfo = {'this_page':1,'all_page':0,'all_num':0,'per_page':per_page}
		self.finish( self.respone_list( clist, pinfo ) )
Exemplo n.º 8
0
	def get(self):
		id = self.get_argument('id','')
		card = cardmodel(self)
		res = card.delete_seller( id )
		if res == 1:
			self.prompt( 1, apimsg.notice(305), self.request.headers['Referer'] )
		else:
			self.prompt( 0, apimsg.notice(307), 'javascript:history.go(-1)', res )
Exemplo n.º 9
0
 def post(self):
     card = cardmodel(self)
     session = self.get_secure_cookie('session')
     username = card.getusername( session )
     user = usermodel(self)
     key = self.get_argument('key','')
     val = self.get_argument('val','')
     res = user.editinfo(key,val,username)
     if res == 1:
         self.write('1')
     else:
         self.write( res )
Exemplo n.º 10
0
	def post(self):
		id = self.get_argument('id','')
		if id:
			duty = self.get_argument('duty','')
			card = cardmodel(self)
			res = card.change_duty( duty, id )
			if res:
				self.finish('1')
			else:
				self.finish('0')
		else:
			self.finish('2')
Exemplo n.º 11
0
 def post(self):
     card = self.get_argument('card','')
     pwd = self.get_argument('pwd','')
     valid = validate()
     valid.Add( card,'卡号', ['NoEmpty'] )
     valid.Add( pwd,'密码', ['NoEmpty'] )
     if not valid._CheckMate():
         #跳转去相关页面
         self.finish('3')
         return
     ca = cardmodel(self)
     res = ca.cardlogin(card,pwd)
     self.finish(res)
Exemplo n.º 12
0
	def post(self):
		id = self.get_argument('id','')
		number = self.get_argument('no',5)
		if id:
			card = cardmodel(self)
			sett = "ascno = %s" %number
			where = "id = %s" %id
			res = card.change_type( sett, where )
			if res:
				self.finish('1')
			else:
				self.finish('0')
		else:
			self.finish('2')
Exemplo n.º 13
0
	def post(self):
		cardno = self.get_argument('cardno','')
		if cardno:
			card = cardmodel(self)
			#验证是否录入过
			cardinfo = card.show_card( cardno )
			if not cardinfo:
				#未录入则新加入
				cardinfo = card.blank_card( cardno )
			if cardinfo:
				self.finish(self.respone_data( 1, cardinfo))
			else:
				self.finish(self.respone_data( 0, apimsg.notice(307)))
		else:
			self.finish(self.respone_data( 0, apimsg.notice(400)))
Exemplo n.º 14
0
 def get(self):
     session = self.get_secure_cookie('session')
     card = cardmodel(self)
     username = card.getusername( session )
     user = usermodel(self)
     #用户信息
     uinfo = user.userinfo(username)
     oid = self.get_argument('oid','')
     if id:
         charge = chargemodel(self)
         detail = charge.order_info(oid)
         #验证自己的订单以及
         if detail and detail['user_id'] == int(uinfo['id']):
             self.finish( json.dumps(detail) )
             return
     self.finish( '0' )
Exemplo n.º 15
0
 def get(self):
     session = self.get_secure_cookie('session')
     card = cardmodel(self)
     username = card.getusername( session )
     user = usermodel(self)
     uinfo = user.userinfo(username)
     purse = user.userpurse(uinfo['id'])
     uinfo['balance'] = purse['balance'] if purse else 0
     wechat = user.user_wechat(uinfo['id'])
     if wechat and wechat['openid']:
         uinfo['wechat'] = 1
     else:
         uinfo['wechat'] = 0
     card = user.cardinfo(uinfo['id'])
     recharge = user.charge_count( uinfo['id'] )
     self.render("home/usercenter.html",info=uinfo,card=card,charge=recharge)
Exemplo n.º 16
0
	def post(self):
		cardno = self.get_argument('cardno','')
		cardid = self.get_argument('cardid','')
		cardtype = self.get_argument('cardtype','')
		nickname = self.get_argument('nickname','')
		phone = self.get_argument('phone','')
		password = self.get_argument('password','')
		balance = self.get_argument('balance','')
		valid = validate()
		valid.Add( cardtype,'分类', ['NoEmpty','Isdigit'] )
		valid.Add( cardno,'识别码', ['NoEmpty','Isdigit'] )
		valid.Add( cardid,'卡id', ['NoEmpty','Isdigit'] )
		valid.Add( phone,'手机', ['NoEmpty','Isdigit'],11,11 )
		valid.Add( nickname,'用户名', ['NoEmpty'] )
		valid.Add( balance,'充值金额', ['NoEmpty','Isdigit'] )
		if not valid._CheckMate():
			self.finish( self.respone_data( 0, apimsg.notice(400) ) )
			return
		user = usermodel(self)
		#唯一电话验证
		onlyphone = user.only_phone( phone )
		if not onlyphone:
			self.finish( self.respone_data( 0, apimsg.notice(228) ) )
			return
		#当前商家信息
		session = self.get_secure_cookie('seller')
		card = cardmodel(self)
		sid = card.get_seller_id( session )
		seller = card.sellerinfo( sid )
		#随机用户名
		username = user.used_name()
		#订单号
		oid = user.build_order()
		#注册新用户,同时绑定当前卡号
		res = user.bind_card(username=username,password=username,cardno=cardno,cardid=cardid,cardtype=cardtype)
		id = user.get_insert_id()
		if res == 1 and id:
			log = logmodel(self)
			#更改相关参数,以及写入日志
			final = log.newcard_infomation( username=username,phone=phone,nickname=nickname,balance=balance,sellerid=sid,sellername=seller['sellername'],password=password,user_id=id,oid=oid )
			if final == 1:
				self.finish( self.respone_data( 1 ) )
			else:
				self.finish( self.respone_data( 0, final ) )
		else:
			self.finish( self.respone_data( 0, res ) )
Exemplo n.º 17
0
 def post(self):
     page = self.get_argument('page',1)
     session = self.get_secure_cookie('session')
     card = cardmodel(self)
     username = card.getusername( session )
     user = usermodel(self)
     uinfo = user.userinfo(username)
     charge = chargemodel(self)
     where = {'o.user_id =':int(uinfo['id']),'o.finish >':0}
     clist = charge.chargelist(where,int(page),10)
     if clist:
         #页面信息
         pinfo = charge.page_bar(2)
         reback = {'clist':clist,'pinfo':pinfo}
         self.finish( json.dumps(reback) )
     else:
         self.finish('0')
Exemplo n.º 18
0
	def post(self):
		username = self.get_argument('username','')
		password = self.get_argument('password','')
		valid = validate()
		valid.Add( username,'用户名', ['NoEmpty'] )
		valid.Add( password,'密码', ['NoEmpty'] )
		if not valid._CheckMate():
			#跳转去相关页面
			self.finish('0')
			return 
		elif not self.health_param(username):
			#用户名格式异常
			self.finish('2')
			return 
		card = cardmodel(self)
		res = card.sellerlogin( username,password )
		self.finish(res)
Exemplo n.º 19
0
	def post(self):
		cardno = self.get_argument('cardno','')
		cardid = self.get_argument('cardid','')
		cardtype = self.get_argument('cardtype','')
		money = self.get_argument('money',0)
		valid = validate()
		valid.Add( cardno,'识别码', ['NoEmpty','Isdigit'] )
		valid.Add( cardtype,'分类', ['NoEmpty','Isdigit'] )
		valid.Add( cardid,'卡id', ['NoEmpty','Isdigit'] )
		valid.Add( money,'钱数', ['NoEmpty','Isdigit'] )
		if not valid._CheckMate():
			self.finish( self.respone_data( 0, valid._Message() ) )
			return
		#当前商家信息
		session = self.get_secure_cookie('seller')
		card = cardmodel(self)
		sid = card.get_seller_id( session )
		seller = card.sellerinfo( sid )
		#用户信息
		user = usermodel(self)
		userid = user.carduser(cardno,cardtype,cardid)
		if userid:
			uid = userid['user_id']
			uinfo = user.trueinfo( '', uid )
			charge = chargemodel(self)
			balance = charge.getpackage( uid )
			#金额计算
			fakemoney = int(money)*100
			newmoney = ( float(balance)*100+fakemoney ) / 100
			#当前时间
			nowtime = int(time.time())
			#订单号
			oid = user.build_order()
			#描述组合
			descript = seller['sellername']+u'用户'+uinfo['username']+'('+uinfo['nickname']+u')充值'+money
			log = logmodel(self)
			try:
				log.change_purse( newmoney, uid )
				log.save_order( oid, uid, money, nowtime, 'point', seller['sellername'] )
				log.save_payments( oid, sid, money, uid, descript, nowtime )
				log.commit_submit()
				self.finish( self.respone_data( 1 ) )
			except:
				self.finish( self.respone_data( 0, apimsg.notice(307) ) )
		else:
			self.finish( self.respone_data( 0, apimsg.notice(222) ) )
Exemplo n.º 20
0
	def get(self):
		page = self.get_argument('page',1)
		sellername = self.get_argument('sellername','')
		phone = self.get_argument('phone','')
		where = ' where 1=1 '
		if sellername:
			where += " AND sellername like '%%"+sellername+"%%'"
		if phone:
			where += " AND phone = '%s'" %phone
		card = cardmodel(self)
		slist = card.getsellers(where,page,15)
		if slist:
			page_bar = card.page_bar(1)
			pinfo = card.page_bar(2)
		else:
			page_bar = None
			pinfo = {'this_page':1,'all_page':0,'per_page':20}
		search = {'sellername':sellername,'phone':phone}
		self.render("admin/sellerlist.html", slist=slist, search=search,page_bar=page_bar,pinfo=pinfo )
Exemplo n.º 21
0
	def get(self):
		cardno = self.get_argument('cardno','')
		cardnumber = self.get_argument('cardnumber','')
		where = ' where u.status < 2 '
		valid = validate()
		valid.Add( cardno,'识别码', ['NoEmpty','Isdigit'] )
		valid.Add( cardnumber,'卡号', ['NoEmpty','Isdigit','IsAccessLen'], 12, 12 )
		if not valid._CheckMate():
			self.finish( self.respone_data( 0, valid._Message() ) )
			return
		#识别码
		where += " AND c.cardno = %d" %int(cardno)
		cardtype = int(cardnumber[0:4])
		cardid = int(cardnumber[4:])
		#卡号
		where += " AND c.cardtype = %d AND c.cardid = %d" %(cardtype,cardid)
		card = cardmodel(self)
		info = card.card_infomation( where ) 
		self.finish( self.respone_data( 1, info ) )
Exemplo n.º 22
0
	def post(self):
		cardtype = self.get_argument('cardtype','')
		cardno = self.get_argument('cardno','')
		if cardno and cardtype:
			card = cardmodel(self)
			#识别码唯一
			ck = card.only_cardno(cardno)
			if ck:
				user = usermodel(self)
				username = user.used_name()
				res = user.register(username=username,password=username,cardno=cardno,cardtype=cardtype)
				id = user.get_insert_id()
				info = user.cardinfo( id )
				if res:
					self.prompt( 1, apimsg.notice(306), '/admin/cardlist', '卡号:'+'%04d%08d'%(info['cardtype'],info['cardid']) )
				else:
					self.prompt( 0, apimsg.notice(307), 'javascript:history.go(-1)' )
			else:
				self.prompt( 0, apimsg.notice(220), 'javascript:history.go(-1)' )
		else:
			self.prompt( 0, apimsg.notice(400), 'javascript:history.go(-1)' )
Exemplo n.º 23
0
	def get(self):
		cardno = self.get_argument('cardno','')
		cardid = self.get_argument('cardid','')
		cardtype = self.get_argument('cardtype','')
		valid = validate()
		valid.Add( cardno,'识别码', ['NoEmpty','Isdigit'] )
		valid.Add( cardid,'卡号', ['NoEmpty','Isdigit'] )
		valid.Add( cardtype,'卡分类', ['NoEmpty','Isdigit'] )
		if not valid._CheckMate():
			self.finish( self.respone_data( 0, valid._Message() ) )
			return
		#识别码
		where = " WHERE c.cardno = %d" %int(cardno)
		#卡号
		where += " AND c.cardtype = %d AND c.cardid = %d" %(int(cardtype),int(cardid))
		card = cardmodel(self)
		info = card.card_infomation( where ) 
		if info:
			self.finish( self.respone_data( 1, info ) )
		else:
			self.finish( self.respone_data( 2, apimsg.notice(222) ) )
Exemplo n.º 24
0
	def post(self):
		act = self.get_argument('act','')
		cardtype = self.get_argument('cardtype','')
		typename = self.get_argument('typename','')
		ascno = self.get_argument('ascno','')
		id = self.get_argument('id','')
		card = cardmodel(self)
		only = card.only_cardtype( cardtype, id )
		if only:
			if act == 'add':
				res = card.addtype(cardtype,typename,ascno)
			elif act == 'edit':
				sett = "cardtype=%s,typename='%s',ascno=%s" %(int(cardtype),typename,int(ascno))
				where = "id=%s" %id
				res = card.change_type( sett, where )
			if res:
				self.prompt( 1, apimsg.notice(305), '/admin/card_type' )
			else:
				self.prompt( 0, apimsg.notice(307), 'javascript:history.go(-1)' )
		else:
			self.prompt( 0, apimsg.notice(307), 'javascript:history.go(-1)', apimsg.notice(221) )
Exemplo n.º 25
0
	def get(self):
		cardno = self.get_argument('cardno','')
		cardtype = self.get_argument('cardtype','')
		cardnumber = self.get_argument('cardnumber','')
		page = self.get_argument('page',1)
		where = ' where u.status < 2 '
		if cardno:
			where += " AND c.cardno = '"+cardno+"'"
		if cardtype:
			where += " AND c.cardtype like '"+str(int(cardtype))+"%%'"
		if cardnumber:
			cardtype = int(cardnumber[0:4])
			cardid = int(cardnumber[4:])
			where += " AND c.cardtype = '"+str(cardtype)+"' AND c.cardid = '"+str(cardid)+"'"
		card = cardmodel(self)
		clist = card.card_list( where, page, 20 )
		if clist:
			page_bar = card.page_bar(1)
			pinfo = card.page_bar(2)
		else:
			page_bar = None
			pinfo = {'this_page':1,'all_page':0,'per_page':20}
		search = {'cardno':cardno,'cardnumber':cardnumber,'cardtype':cardtype}
		self.render("admin/cardlist.html", clist=clist, search=search,page_bar=page_bar,pinfo=pinfo )
Exemplo n.º 26
0
	def get(self):
		card = cardmodel(self)
		type_list = card.card_type()
		self.render("admin/cardtype.html", type_list=type_list )
Exemplo n.º 27
0
	def get(self):
		id = self.get_argument('id','')
		card = cardmodel(self)
		info = card.sellerinfo( id )
		self.render("admin/sellerinfo.html",info=info,act='edit')
Exemplo n.º 28
0
	def post(self):
		id = self.get_argument('id','')
		value = self.get_argument('val','1')
		card = cardmodel(self)
		res = card.change_sell_status( id, value )
		self.finish( res )