Exemple #1
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')
Exemple #2
0
 def get (self):
     #print self.request.query_arguments      
     #self.get_body_arguments('abc')\
     get = data_format( self.request.query_arguments )
     if notify_verify (get):
         tn = self.get_query_argument('out_trade_no')
         trade_no = self.get_query_argument('trade_no')
         trade_status = self.get_query_argument('trade_status')
         #获取订单状态
         log = logmodel(self)
         info = log.log_info( 'log_alipay', tn )
         if info and info['ispay'] == 0:
             #修改状态并且生成完整订单
             try:
                 nowtime = int(time.time())
                 #更改记录信息
                 log.success_alipay( tn, nowtime, trade_no )
                 #存储订单记录
                 log.save_order( tn, info['user_id'], info['amount'], nowtime, 'alipay', '用户中心' )
                 #更改钱数
                 log.change_purse( info['balance']+info['amount'], info['user_id'] )
                 log.commit_submit()
                 self.render("home/welcome.html",oid=tn,amount=info['amount'])
             except:
                 self.finish("fail")
         elif info and info['ispay'] == 1:
             self.render("home/welcome.html",oid=tn,amount=info['amount'])
         else:
             self.finish("fail")
     else:
         #错误或者黑客攻击
         #log=Log(operation='err_return_'+trade_status+'_'+trade_no)
         #log.save()
         self.finish("fail")
Exemple #3
0
 def post (self):
     post = data_format( self.request.body_arguments )
     log = logmodel(self)
     #清除过期单据
     log.expire_alipay()
     if notify_verify (post):
         #商户网站订单号
         tn = self.get_body_argument('out_trade_no')
         #支付宝单号
         trade_no = self.get_body_argument('trade_no')
         #返回支付状态
         trade_status = self.get_body_argument('trade_status')
         #返回状态判断
         if trade_status == 'TRADE_SUCCESS' or trade_status == 'TRADE_FINISHED':
             log = logmodel(self)
             info = log.log_info( 'log_alipay', tn )
             if info and info['ispay'] == 0:
                 #修改状态并且生成完整订单
                 try:
                     nowtime = int(time.time())
                     log.success_alipay( tn, nowtime, trade_no )
                     log.save_order( tn, info['user_id'], info['amount'], nowtime, 'alipay', '用户中心' )
                     #更改钱数
                     log.change_purse( info['balance']+info['amount'], info['user_id'] )
                     log.commit_submit()
                     self.finish("success")
                 except:
                     return self.finish("fail")
             elif info and info['ispay'] == 1:
                 self.finish("success")
             else:
                 self.finish("fail")
         else:
             #写入日志
             #log=Log(operation='notify2_'+trade_status+'_'+trade_no)
             #log.save()
             print 'fail'
             self.finish("fail")
     else:
         #黑客攻击
         #log=Log(operation='hack_notify_'+trade_status+'_'+trade_no+'_'+'out_trade_no')
         #log.save()
         self.finish ("fail")
Exemple #4
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) ) )
Exemple #5
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 ) )