<!--#include virtual="/inc/conn.asp"-->
<%


if SafeRequest("act")="tongji" then


today=now() '平台账务统计
yearno=Year(today)	 '当年计时 2013
monthno=Year(today)&Right("0" & Month(today),2)   '当月计时 201311	
todayno=Year(today)&Right("0" & Month(today),2)&Right("0" & Day(today),2) '当日计时 20131125	
yyearno=Year(DateAdd("yyyy",-1,today)) '去年计时2012
ymonthno=Year(DateAdd("m",-1,today))&Right("0" & Month(DateAdd("m",-1,today)),2)  '上月计时201210	
ytodayno=Year(DateAdd("d",-1,today))&Right("0" & Month(DateAdd("d",-1,today)),2)&Right("0" & Day(DateAdd("d",-1,today)),2) '昨日计时20121124

set rst=server.CreateObject("adodb.recordset")
set rsj=server.CreateObject("adodb.recordset")
set rsd=server.CreateObject("adodb.recordset")
set rsxs=server.CreateObject("adodb.recordset")

'往日统计
n=1

for daynum=1 to 1

	wrinoda=DateAdd("d",-n,now()) '往日大写
	wrino=Year(DateAdd("d",-n,today))&Right("0" & Month(DateAdd("d",-n,today)),2)&Right("0" & Day(DateAdd("d",-n,today)),2)
	'统计订单金额 笔数
	ddin=0  '订单金额
	ddinb=0  '订单笔数
	fandian=0
	banksum=0
	bankj=0
	cardsum=0
	cardj=0
	alipaysum=0
	alipayj=0
	tenpaysum=0
	tenpayj=0
	ayptsaoj=0          '微信金额
	ayptsaob=0          '微信笔数
	ayptsaol=0          '微信利润
	wapalib=0
	wapalij=0
	waptenb=0
	waptenj=0
	qqsaob=0
	qqsaoj=0
	
	wapweib=0
	wapweij=0
	wapqqb=0
	wapqqj=0
	
	'wrino="20160128"
	'wrinoda="2016-1-28 23:31:00"

	sqlt="select top 1 * from aypttj where aypttjuid=0 and aypttjjl='"&wrino&"' and aypttjzq=3"  
	rst.open sqlt,conn,1,3
	if rst.bof and rst.eof then

					'订单统计 开始***************************************************************************************************
					For sum=0 To 5 '订单库数量  总数量-1 如增加库 需修改updata\tongji下的相应文件  case "A"
					if sum=0 then ddku="aydingdan"
					if sum=1 then ddku="aydingdan01"
					if sum=2 then ddku="aydingdan02"
					if sum=3 then ddku="aydingdan03"
					if sum=4 then ddku="aydingdan04"
					if sum=5 then ddku="aydingdan05"
							sqld="select * from "&ddku&" where datediff(day,aydingdansj,'"&wrinoda&"')=0 and aydingdanzt=1" 
							rsd.open sqld,conn,1,1
							if not(rsd.bof and rsd.eof) then
							do while not rsd.eof
						
								'rsxs.open "select ayxsuid,ayxsjin,ayxsdate from ayxiaoshou where ayxsuid='"&rsd("aydingdanuser")&"' and datediff(day,ayxsdate,'"&wrinoda&"')=0",conn,1,3
								'if not(rsxs.bof and rsxs.eof) then
								'rsxs("ayxsjin")=ccur(rsxs("ayxsjin"))+ccur(rsd("aydingdanzj"))
								'rsxs.update
								'else
								'rsxs.addnew
								'rsxs("ayxsuid")=rsd("aydingdanuser")
								'rsxs("ayxsdate")=wrinoda
								'rsxs("ayxsjin")=rsd("aydingdanzj")
								'rsxs.update
								'end if
								'rsxs.close
							
								ddinb=ddinb+1
								ddin=ccur(ddin)+ccur(rsd("aydingdanzj"))
									if rsd("ayddzffangshi")=0 then  '0网银
										banksum=banksum+1
										bankj=bankj+ccur(rsd("aydingdanzj"))
									end if
									if rsd("ayddzffangshi")=1 then  '充值卡
										cardsum=cardsum+1
										cardj=cardj+ccur(rsd("aydingdanzj"))
									end if
									if rsd("ayddzffangshi")=2 then  '2支付宝
										alipaysum=alipaysum+1
										alipayj=alipayj+ccur(rsd("aydingdanzj"))
									end if
									if rsd("ayddzffangshi")=3 then  '3财付通
										tenpaysum=tenpaysum+1
										tenpayj=tenpayj+ccur(rsd("aydingdanzj"))
									end if
									if rsd("ayddzffangshi")=4 then  '4扫码
										ayptsaob=ayptsaob+1
										ayptsaoj=ayptsaoj+ccur(rsd("aydingdanzj"))
									end if
									if rsd("ayddzffangshi")=5 then  'qq扫码
										qqsaob=qqsaob+1
										qqsaoj=qqsaoj+ccur(rsd("aydingdanzj"))
									end if
									if rsd("ayddzffangshi")=10 then  '10WAP支付宝
										wapalib=wapalib+1
										wapalij=wapalij+ccur(rsd("aydingdanzj"))
									end if
									if rsd("ayddzffangshi")=12 then  '12WAP财付通
										waptenb=waptenb+1
										waptenj=waptenj+ccur(rsd("aydingdanzj"))
									end if
									if rsd("ayddzffangshi")=13 then  '13WAP微信
										wapweib=wapweib+1
										wapweij=wapweij+ccur(rsd("aydingdanzj"))
									end if
									if rsd("ayddzffangshi")=14 then  '13WAP qq
										wapqqb=wapqqb+1
										wapqqj=wapqqj+ccur(rsd("aydingdanzj"))
									end if
							rsd.movenext  
							loop
							end if
							rsd.close
					next
					'订单统计 结束***************************************************************************************************



					'财务统计 开始***************************************************************************************************
					num=0
					minje=0
					chonglirunsum=0
					chongzhij=0
					andian=0
					fandianj=0
					diankalirunsum=0
					diankalirun=0
					jishilirunsum=0
					jishilirun=0
					jiajilirunsum=0
					jiajilirun=0
					aotolirunsum=0
					aotolirun=0
					shoulirunsum=0
					shoukuanj=0
					shoulirun=0
					banklirun=0
					alipaylirun=0
					tenpaylirun=0
					ayptsaol=0
					wapalil=0
					waptenl=0
					chonglirun=0 '充值利润 不统计 *
					qqsaol=0
					
					wapweil=0
					wapqql=0
					xiaofeij=0
					
					For sum=0 To 5 '订单库数量  总数量-1 如增加库 需修改updata\tongji下的相应文件  case "A"
					if sum=0 then cwku="aycaiwu"
					if sum=1 then cwku="aycaiwu01"
					if sum=2 then cwku="aycaiwu02"
					if sum=3 then cwku="aycaiwu03"
					if sum=4 then cwku="aycaiwu04"
					if sum=5 then cwku="aycaiwu05"
							sqlj="select * from "&cwku&" where datediff(day,aycaiwudate,'"&wrinoda&"')=0 and aycaiwuzt=1 and (aycaiwuleibie=0 or aycaiwuleibie=3 or aycaiwuleibie=5 or aycaiwuleibie=8 or aycaiwuleibie=10 or aycaiwuleibie=12 or aycaiwuleibie=14 or aycaiwuleibie=15 or aycaiwuleibie=16 or aycaiwuleibie=17 or aycaiwuleibie=18)" 
							rsj.open sqlj,conn,1,1
							if not(rsj.bof and rsj.eof) then
							do while not rsj.eof
						
								minje=ccur(minje)+ccur(rsj("aycwfsjin"))        '发生金额
									if rsj("aycaiwuleibie")=5 then  		 '消费 购买套餐等
									xiaofeij=xiaofeij+ccur(rsj("aycwfsjin"))
									end if
									'充值金额
									if rsj("aycaiwuleibie")=3 then 
									chonglirunsum=chonglirunsum+1    
									chongzhij=chongzhij+ccur(rsj("aycwfsjin"))       
									end if
									'引荐返点
									if rsj("aycaiwuleibie")=8 then 
									fandian=fandian+1                       
									fandianj=fandianj+ccur(rsj("aycwfsjin"))
									end if
									'点卡余额利润
									if rsj("aycaiwuleibie")=10 then 
									diankalirunsum=diankalirunsum+1
									diankalirun=ccur(diankalirun)+ccur(rsj("aycaiwujine"))
									end if
									'即时到账利润
									if rsj("aycaiwuleibie")=14 then 
									jishilirunsum=jishilirunsum+1
									jishilirun=ccur(jishilirun)+ccur(rsj("aycaiwujine"))
									end if
									'加急手续费利润
									if rsj("aycaiwuleibie")=15 then 
									jiajilirunsum=jiajilirunsum+1
									jiajilirun=ccur(jiajilirun)+ccur(rsj("aycaiwujine"))
									end if
									'自动结算手续费利润
									if rsj("aycaiwuleibie")=16 then 
									aotolirunsum=aotolirunsum+1
									aotolirun=ccur(aotolirun)+ccur(rsj("aycaiwujine"))
									end if
									'收款手续费利润
									if rsj("aycaiwuleibie")=17 then 
									jin=""
									shoulirunsum=shoulirunsum+1
										jin=replace(trim(rsj("aycaiwubody")),"收款"," ")   '总收款金额
										jin=replace(trim(jin),"元"," ")
										jin=trim(jin)
										shoulirun=ccur(shoulirun)+rsj("apicheng")/100*ccur(jin)
										shoukuanj=ccur(shoukuanj)+ccur(jin)
									end if
									
									'接口利润
									if rsj("aycaiwuzhifu")=0 then  '0网银
										if rsj("apicheng")<>"" and rsj("aycwfsjin")<>"" then 
											if ccur(rsj("aycwfsjin"))<1 then
											banklirun=ccur(banklirun)++0.1
											else
											banklirun=ccur(banklirun)+rsj("apicheng")/100*rsj("aycwfsjin")
											end if
										end if
									end if
									if rsj("aycaiwuzhifu")=2 then  '2支付宝
										if rsj("apicheng")<>"" and rsj("aycwfsjin")<>"" then 
											if ccur(rsj("aycwfsjin"))<1 then
											banklirun=ccur(banklirun)++0.1
											else
											alipaylirun=ccur(alipaylirun)+rsj("apicheng")/100*rsj("aycwfsjin")
											end if
										end if
									end if
									if rsj("aycaiwuzhifu")=3 then  '3财付通
										if rsj("apicheng")<>"" and rsj("aycwfsjin")<>"" then 
											if ccur(rsj("aycwfsjin"))<1 then
											banklirun=ccur(banklirun)++0.1
											else
											tenpaylirun=ccur(tenpaylirun)+rsj("apicheng")/100*rsj("aycwfsjin")
											end if
										end if
									end if
									if rsj("aycaiwuzhifu")=4 then  '4扫码
										if rsj("apicheng")<>"" and rsj("aycwfsjin")<>"" then 
											if ccur(rsj("aycwfsjin"))<1 then
											banklirun=ccur(banklirun)++0.1
											else
											ayptsaol=ccur(ayptsaol)+rsj("apicheng")/100*rsj("aycwfsjin")
											end if
										end if
									end if
									if rsj("aycaiwuzhifu")=5 then  'qq扫码
										if rsj("apicheng")<>"" and rsj("aycwfsjin")<>"" then 
											if ccur(rsj("aycwfsjin"))<1 then
											banklirun=ccur(banklirun)++0.1
											else
											qqsaol=ccur(qqsaol)+rsj("apicheng")/100*rsj("aycwfsjin")
											end if
										end if
									end if
									if rsj("aycaiwuzhifu")=10 then  'WAP支付宝	
										if rsj("apicheng")<>"" and rsj("aycwfsjin")<>"" then 
											if ccur(rsj("aycwfsjin"))<1 then
											banklirun=ccur(banklirun)++0.1
											else
											wapalil=ccur(wapalil)+rsj("apicheng")/100*rsj("aycwfsjin")
											end if
										end if
									end if
									if rsj("aycaiwuzhifu")=12 then  'WAP财付通	
										if rsj("apicheng")<>"" and rsj("aycwfsjin")<>"" then 
											if ccur(rsj("aycwfsjin"))<1 then
											banklirun=ccur(banklirun)++0.1
											else
											waptenl=ccur(waptenl)+rsj("apicheng")/100*rsj("aycwfsjin")
											end if
										end if
									end if
									if rsj("aycaiwuzhifu")=13 then  'WAP微信	
										if rsj("apicheng")<>"" and rsj("aycwfsjin")<>"" then 
											if ccur(rsj("aycwfsjin"))<1 then
											banklirun=ccur(banklirun)++0.1
											else
											wapweil=ccur(wapweil)+rsj("apicheng")/100*rsj("aycwfsjin")
											end if
										end if
									end if
									if rsj("aycaiwuzhifu")=14 then  'WAP qq	
										if rsj("apicheng")<>"" and rsj("aycwfsjin")<>"" then 
											if ccur(rsj("aycwfsjin"))<1 then
											banklirun=ccur(banklirun)++0.1
											else
											wapqql=ccur(wapqql)+rsj("apicheng")/100*rsj("aycwfsjin")
											end if
										end if
									end if
						
							rsj.movenext  
							loop
							end if
							rsj.close
					next
					'财务统计 结束***************************************************************************************************


	
	'总利润
	zlirun=0
	'zlirun=ccur(zlirun)+ccur(chonglirun)  '充值利润 *
	zlirun=ccur(zlirun)+ccur(diankalirun)  '点卡余额返回利润
	zlirun=ccur(zlirun)+ccur(jishilirun)   '秒结利润
	zlirun=ccur(zlirun)+ccur(jiajilirun)   '加急利润
	zlirun=ccur(zlirun)+ccur(aotolirun)    '自动结算利润
	zlirun=ccur(zlirun)+ccur(shoulirun)    '收款利润
	zlirun=ccur(zlirun)+ccur(banklirun)    '网银接口利润
	zlirun=ccur(zlirun)+ccur(alipaylirun)  '支付宝接口利润
	zlirun=ccur(zlirun)+ccur(tenpaylirun)  '财付通接口利润
	zlirun=ccur(zlirun)+ccur(ayptsaol)     '微信接口利润
	zlirun=ccur(zlirun)+ccur(wapalil)      '支付宝WAP接口利润
	zlirun=ccur(zlirun)+ccur(waptenl)      '财付通WAP接口利润
	zlirun=ccur(zlirun)+ccur(qqsaol)       'qq扫码利润
	
	zlirun=ccur(zlirun)+ccur(wapweil) 
	zlirun=ccur(zlirun)+ccur(wapqql) 
	zlirun=ccur(zlirun)+ccur(xiaofeij) 
	
	ddzongj=ccur(ddin)+ccur(chongzhij)+ccur(shoukuanj)
	rst.addnew
	rst("aypttjjl")=wrino 			'周期记录  年2013   月201301  日20130101
	rst("ayptdate")=wrinoda 		'统计日期
	rst("ayptcjbs")=ddinb 			'成交笔数  默认0
	rst("ayptcjje")=ddzongj         '成交金额
	'rst("ayptcjjs")=minjelast   	'结算金额
	rst("ayptcjlr")=zlirun      	'成交利润  默认0
	rst("ayptbank")=banksum   		'网银笔数 默认0
	rst("ayptbankj")=bankj  		'网银金额 默认0
	rst("banklirun")=banklirun      '网银利润
	rst("ayptcard")=cardsum 		'充值卡笔数 默认0 
	rst("ayptcardj")=cardj  		'充值卡金额 默认0
	rst("ayptalipay")=alipaysum  	'支付宝笔数 默认0
	rst("ayptalipayj")=alipayj 		'支付宝金额 默认0
	rst("alipaylirun")=alipaylirun  '支付宝利润
	rst("aypttenpay")=tenpaysum     '财付通笔数 默认0
	rst("aypttenpayj")=tenpayj      '财付通金额 默认0
	rst("tenpaylirun")=tenpaylirun  '财付通利润
	rst("ayfandian")=fandian        '返点笔数
	rst("ayfandianj")=fandianj      '返点金额 
	rst("chongzhij")=chongzhij      '充值金额
	rst("chonglirun")=chonglirun    '充值利润
	rst("chongzhib")=chonglirunsum  '充值笔数
	rst("diankalirun")=diankalirun  	  '点卡余额利润
	rst("diankalirunsum")=diankalirunsum  '点卡余额笔数
	rst("jishilirun")=jishilirun     	  '即时到账利润
	rst("jishilirunsum")=jishilirunsum    '即时到账笔数
	rst("jiajilirun")=jiajilirun    	  '加急手续费
	rst("jiajilirunsum")=jiajilirunsum    '加急手续费笔数
	rst("aotolirun")=aotolirun     		  '自动结算
	rst("aotolirunsum")=aotolirunsum      '自动结算笔数
	rst("shoukuanj")=shoukuanj            '收款金额
	rst("shoulirun")=shoulirun            '收款利润
	rst("shoulirunsum")=shoulirunsum      '收款笔数
	rst("ayptsaoj")=ayptsaoj    '微信金额
	rst("ayptsaob")=ayptsaob    '微信笔数
	rst("ayptsaol")=ayptsaol    '微信利润
	rst("wapalib")=wapalib		'支付WAP笔数
	rst("wapalij")=wapalij      '支付宝WAP金额
	rst("wapalil")=wapalil      '支付宝WAP利润
	rst("waptenb")=waptenb      '财付通WAP笔数
	rst("waptenj")=waptenj      '财付通WAP金额
	rst("waptenl")=waptenl      '财付通WAP利润
	rst("qqsaob")=qqsaob      'qq扫码笔数
	rst("qqsaoj")=qqsaoj      'qq扫码金额
	rst("qqsaol")=qqsaol      'qq扫码利润
	
	rst("wapweib")=wapweib      'wap 微信笔数
	rst("wapweij")=wapweij      'wap 微信金额
	rst("wapweil")=wapweil      'wap 微信利润
	rst("wapqqb")=wapqqb      'wap qq笔数
	rst("wapqqj")=wapqqj      'wap qq金额
	rst("wapqql")=wapqql      'wap qq利润
	rst("xiaofeij")=xiaofeij      'wap qq利润
	rst.update
	end if
	rst.close


n=n+1
next















'****************************************************************************************************

	ayptcjlr=0
	paybank=0
	payalipay=0
	paytenpay=0
	paycard=0
	paybankj=0
	payalipayj=0
	paytenpayj=0
	paycardj=0
	fandian=0
	fandianj=0
	chongzhij=0
	chonglirun=0
	chongzhib=0
	diankalirun=0
	diankalirunsum=0
	jishilirun=0
	jishilirunsum=0
	jiajilirun=0
	jiajilirunsum=0
	aotolirun=0
	aotolirunsum=0
	shoukuanj=0
	shoulirun=0
	shoulirunsum=0
	banklirun=0
	alipaylirun=0
	tenpaylirun=0
	ayptsaoj=0          '微信金额
	ayptsaob=0          '微信笔数
	ayptsaol=0          '微信利润
	minje=0
	minjelast=0
	num=0

	wapalib=0
	wapalij=0
	waptenb=0
	waptenj=0
	wapalil=0
	waptenl=0
	
	qqsaob=0
	qqsaoj=0
	qqsaol=0
		
	wapweib=0 
	wapweij=0
	wapweil=0
	wapqqb=0
	wapqqj=0
	wapqql=0
	xiaofeij=0
	
'上月统计
sqlt="select top 1 * from aypttj where aypttjuid=0 and aypttjjl='"&ymonthno&"' and aypttjzq=2"  
rst.open sqlt,conn,1,3
if rst.bof and rst.eof then

	sqlj="select * from aypttj where aypttjzq=3 and aypttjuid=0 and datediff(month,ayptdate,'"&now()&"')=1" 
	rsj.open sqlj,conn,1,3

	if not(rsj.bof and rsj.eof) then
	do while not rsj.eof

		'response.Write rsj("aycaiwudate")&"<br>"
		num=num+ccur(rsj("ayptcjbs"))   
		minje=ccur(minje)+ccur(rsj("ayptcjje"))
		'minjelast=ccur(minjelast)+ccur(rsj("ayptcjjs"))
		paybank=paybank+ccur(rsj("ayptbank"))
		paybankj=paybankj+ccur(rsj("ayptbankj"))
		paycard=paycard+ccur(rsj("ayptcard"))
		paycardj=paycardj+ccur(rsj("ayptcardj"))
		payalipay=payalipay+ccur(rsj("ayptalipay"))
		payalipayj=payalipayj+ccur(rsj("ayptalipayj"))
		paytenpay=paytenpay+ccur(rsj("aypttenpay"))
		paytenpayj=paytenpayj+ccur(rsj("aypttenpayj"))
		fandian=fandian+ccur(rsj("ayfandian"))
		fandianj=fandianj+ccur(rsj("ayfandianj"))
		ayptcjlr=ccur(ayptcjlr)+ccur(rsj("ayptcjlr"))
		
		chongzhij=ccur(chongzhij)+ccur(rsj("chongzhij"))
		chonglirun=ccur(chonglirun)+ccur(rsj("chonglirun"))
		chongzhib=ccur(chongzhib)+ccur(rsj("chongzhib"))
		diankalirun=ccur(diankalirun)+ccur(rsj("diankalirun"))
		diankalirunsum=ccur(diankalirunsum)+ccur(rsj("diankalirunsum"))
		jishilirun=ccur(jishilirun)+ccur(rsj("jishilirun"))
		jishilirunsum=ccur(jishilirunsum)+ccur(rsj("jishilirunsum"))
		jiajilirun=ccur(jiajilirun)+ccur(rsj("jiajilirun"))
		jiajilirunsum=ccur(jiajilirunsum)+ccur(rsj("jiajilirunsum"))
		aotolirun=ccur(aotolirun)+ccur(rsj("aotolirun"))
		aotolirunsum=ccur(aotolirunsum)+ccur(rsj("aotolirunsum"))
		shoukuanj=ccur(shoukuanj)+ccur(rsj("shoukuanj"))
		shoulirun=ccur(shoulirun)+ccur(rsj("shoulirun"))
		shoulirunsum=ccur(shoulirunsum)+ccur(rsj("shoulirunsum"))
		banklirun=ccur(banklirun)+ccur(rsj("banklirun"))
		alipaylirun=ccur(alipaylirun)+ccur(rsj("alipaylirun"))
		tenpaylirun=ccur(tenpaylirun)+ccur(rsj("tenpaylirun"))
		ayptsaoj=ccur(ayptsaoj)+ccur(rsj("ayptsaoj"))
		ayptsaob=ccur(ayptsaob)+ccur(rsj("ayptsaob"))
		ayptsaol=ccur(ayptsaol)+ccur(rsj("ayptsaol"))

		wapalib=ccur(wapalib)+ccur(rsj("wapalib"))
		wapalij=ccur(wapalij)+ccur(rsj("wapalij"))
		waptenb=ccur(waptenb)+ccur(rsj("waptenb"))
		waptenj=ccur(waptenj)+ccur(rsj("waptenj"))
		wapalil=ccur(wapalil)+ccur(rsj("wapalil"))
		waptenl=ccur(waptenl)+ccur(rsj("waptenl"))
		
		qqsaob=ccur(qqsaob)+ccur(rsj("qqsaob"))
		qqsaoj=ccur(qqsaoj)+ccur(rsj("qqsaoj"))
		qqsaol=ccur(qqsaol)+ccur(rsj("qqsaol"))
		
		wapweib=ccur(wapweib)+ccur(rsj("wapweib"))
		wapweij=ccur(wapweij)+ccur(rsj("wapweij"))
		wapweil=ccur(wapweil)+ccur(rsj("wapweil"))
		wapqqb=ccur(wapqqb)+ccur(rsj("wapqqb"))
		wapqqj=ccur(wapqqj)+ccur(rsj("wapqqj"))
		wapqql=ccur(wapqql)+ccur(rsj("wapqql"))
		xiaofeij=ccur(xiaofeij)+ccur(rsj("xiaofeij"))
		


	rsj.movenext  
	loop
	end if
	rsj.close

rst.addnew
rst("aypttjzq")=2       					'  统计周期  1年 2月 3日 默认3
rst("aypttjjl")=ymonthno 				'周期记录  年2013   月201301  日20130101
rst("ayptdate")=DateAdd("m",-1,now()) '统计日期
rst("ayptcjbs")=clng(num) 			'成交笔数  默认0
rst("ayptcjje")=minje  				 '成交金额
'rst("ayptcjjs")=minjelast   		'结算金额
rst("ayptcjlr")=ayptcjlr 'ccur(minje)-ccur(minjelast)  '成交利润  默认0
rst("ayptbank")=paybank   '网银笔数 默认0
rst("ayptbankj")=paybankj  '网银金额 默认0
rst("ayptcard")=paycard  '充值卡笔数 默认0
rst("ayptcardj")=paycardj  '充值卡金额 默认0
rst("ayptalipay")=payalipay  '支付宝笔数 默认0
rst("ayptalipayj")=payalipayj  '支付宝金额 默认0
rst("aypttenpay")=paytenpay  '财付通笔数 默认0
rst("aypttenpayj")=paytenpayj  '财付通金额 默认0
rst("ayfandian")=fandian  
rst("ayfandianj")=fandianj 

rst("chongzhij")=chongzhij 
rst("chonglirun")=chonglirun 
rst("chongzhib")=chongzhib 
rst("diankalirun")=diankalirun 
rst("diankalirunsum")=diankalirunsum 
rst("jishilirun")=jishilirun 
rst("jishilirunsum")=jishilirunsum 
rst("jiajilirun")=jiajilirun 
rst("jiajilirunsum")=jiajilirunsum 
rst("aotolirun")=aotolirun
rst("aotolirunsum")=aotolirunsum 
rst("shoukuanj")=shoukuanj 
rst("shoulirun")=shoulirun 
rst("shoulirunsum")=shoulirunsum 
rst("banklirun")=banklirun 
rst("alipaylirun")=alipaylirun 
rst("tenpaylirun")=tenpaylirun
rst("ayptsaoj")=ayptsaoj
rst("ayptsaob")=ayptsaob 
rst("ayptsaol")=ayptsaol 

rst("wapalib")=wapalib 
rst("wapalij")=wapalij 
rst("waptenb")=waptenb 
rst("waptenj")=waptenj
rst("wapalil")=wapalil
rst("waptenl")=waptenl

rst("qqsaob")=qqsaob 
rst("qqsaoj")=qqsaoj
rst("qqsaol")=qqsaol

rst("wapweib")=wapweib
rst("wapweij")=wapweij
rst("wapweil")=wapweil

rst("wapqqb")=wapqqb
rst("wapqqj")=wapqqj
rst("wapqql")=wapqql
rst("xiaofeij")=xiaofeij

rst.update

end if
rst.close



'****************************************************************************************************
	ayptcjlr=0
	paybank=0
	payalipay=0
	paytenpay=0
	paycard=0
	paybankj=0
	payalipayj=0
	paytenpayj=0
	paycardj=0
	fandian=0
	fandianj=0
	chongzhij=0
	chonglirun=0
	chongzhib=0
	diankalirun=0
	diankalirunsum=0
	jishilirun=0
	jishilirunsum=0
	jiajilirun=0
	jiajilirunsum=0
	aotolirun=0
	aotolirunsum=0
	shoukuanj=0
	shoulirun=0
	shoulirunsum=0
	banklirun=0
	alipaylirun=0
	tenpaylirun=0
	ayptsaoj=0          '微信金额
	ayptsaob=0          '微信笔数
	ayptsaol=0          '微信利润
	minje=0
	minjelast=0
	num=0
	wapalib=0
	wapalij=0
	waptenb=0
	waptenj=0
	wapalil=0
	waptenl=0
	qqsaob=0
	qqsaoj=0
	qqsaol=0

	wapweib=0 
	wapweij=0
	wapweil=0
	wapqqb=0
	wapqqj=0
	wapqql=0
	xiaofeij=0
	
'上一年统计
sqlt="select top 1 * from aypttj where aypttjuid=0 and aypttjjl='"&yyearno&"' and aypttjzq=1"  
rst.open sqlt,conn,1,3
if rst.bof and rst.eof then

	sqlj="select * from aypttj where aypttjzq=2 and aypttjuid=0 and datediff(yyyy,ayptdate,'"&now()&"')=1" 
	rsj.open sqlj,conn,1,3


	if not(rsj.bof and rsj.eof) then
	do while not rsj.eof

		'response.Write rsj("aycaiwudate")&"<br>"
		num=num+ccur(rsj("ayptcjbs"))   
		minje=ccur(minje)+ccur(rsj("ayptcjje"))
		'minjelast=ccur(minjelast)+ccur(rsj("ayptcjjs"))
		paybank=paybank+ccur(rsj("ayptbank"))
		paybankj=paybankj+ccur(rsj("ayptbankj"))
		paycard=paycard+ccur(rsj("ayptcard"))
		paycardj=paycardj+ccur(rsj("ayptcardj"))
		payalipay=payalipay+ccur(rsj("ayptalipay"))
		payalipayj=payalipayj+ccur(rsj("ayptalipayj"))
		paytenpay=paytenpay+ccur(rsj("aypttenpay"))
		paytenpayj=paytenpayj+ccur(rsj("aypttenpayj"))
		fandian=fandian+ccur(rsj("ayfandian"))
		fandianj=fandianj+ccur(rsj("ayfandianj"))
		ayptcjlr=ccur(ayptcjlr)+ccur(rsj("ayptcjlr"))
		
		chongzhij=ccur(chongzhij)+ccur(rsj("chongzhij"))
		chonglirun=ccur(chonglirun)+ccur(rsj("chonglirun"))
		chongzhib=ccur(chongzhib)+ccur(rsj("chongzhib"))
		diankalirun=ccur(diankalirun)+ccur(rsj("diankalirun"))
		diankalirunsum=ccur(diankalirunsum)+ccur(rsj("diankalirunsum"))
		jishilirun=ccur(jishilirun)+ccur(rsj("jishilirun"))
		jishilirunsum=ccur(jishilirunsum)+ccur(rsj("jishilirunsum"))
		jiajilirun=ccur(jiajilirun)+ccur(rsj("jiajilirun"))
		jiajilirunsum=ccur(jiajilirunsum)+ccur(rsj("jiajilirunsum"))
		aotolirun=ccur(aotolirun)+ccur(rsj("aotolirun"))
		aotolirunsum=ccur(aotolirunsum)+ccur(rsj("aotolirunsum"))
		shoukuanj=ccur(shoukuanj)+ccur(rsj("shoukuanj"))
		shoulirun=ccur(shoulirun)+ccur(rsj("shoulirun"))
		shoulirunsum=ccur(shoulirunsum)+ccur(rsj("shoulirunsum"))
		banklirun=ccur(banklirun)+ccur(rsj("banklirun"))
		alipaylirun=ccur(alipaylirun)+ccur(rsj("alipaylirun"))
		tenpaylirun=ccur(tenpaylirun)+ccur(rsj("tenpaylirun"))
		ayptsaoj=ccur(ayptsaoj)+ccur(rsj("ayptsaoj"))
		ayptsaob=ccur(ayptsaob)+ccur(rsj("ayptsaob"))
		ayptsaol=ccur(ayptsaol)+ccur(rsj("ayptsaol"))
		
		wapalib=ccur(wapalib)+ccur(rsj("wapalib"))
		wapalij=ccur(wapalij)+ccur(rsj("wapalij"))
		waptenb=ccur(waptenb)+ccur(rsj("waptenb"))
		waptenj=ccur(waptenj)+ccur(rsj("waptenj"))
		wapalil=ccur(wapalil)+ccur(rsj("wapalil"))
		waptenl=ccur(waptenl)+ccur(rsj("waptenl"))
		qqsaob=ccur(qqsaob)+ccur(rsj("qqsaob"))
		qqsaoj=ccur(qqsaoj)+ccur(rsj("qqsaoj"))
		qqsaol=ccur(qqsaol)+ccur(rsj("qqsaol"))
		
		wapweib=ccur(wapweib)+ccur(rsj("wapweib"))
		wapweij=ccur(wapweij)+ccur(rsj("wapweij"))
		wapweil=ccur(wapweil)+ccur(rsj("wapweil"))
		wapqqb=ccur(wapqqb)+ccur(rsj("wapqqb"))
		wapqqj=ccur(wapqqj)+ccur(rsj("wapqqj"))
		wapqql=ccur(wapqql)+ccur(rsj("wapqql"))
		xiaofeij=ccur(xiaofeij)+ccur(rsj("xiaofeij"))
		
	rsj.movenext  
	loop
	end if
	rsj.close
	

rst.addnew
rst("aypttjzq")=1       					'  统计周期  1年 2月 3日 默认3
rst("aypttjjl")=yyearno 				'周期记录  年2013   月201301  日20130101
rst("ayptdate")=DateAdd("yyyy",-1,now()) '统计日期
rst("ayptcjbs")=clng(num) 			'成交笔数  默认0
rst("ayptcjje")=minje 				 '成交金额
'rst("ayptcjjs")=minjelast   		'结算金额
rst("ayptcjlr")=ayptcjlr   'ccur(minje)-ccur(minjelast)  '成交利润  默认0
rst("ayptbank")=paybank   '网银笔数 默认0
rst("ayptbankj")=paybankj  '网银金额 默认0
rst("ayptcard")=paycard  '充值卡笔数 默认0
rst("ayptcardj")=paycardj  '充值卡金额 默认0
rst("ayptalipay")=payalipay  '支付宝笔数 默认0
rst("ayptalipayj")=payalipayj  '支付宝金额 默认0
rst("aypttenpay")=paytenpay  '财付通笔数 默认0
rst("aypttenpayj")=paytenpayj  '财付通金额 默认0
rst("ayfandian")=fandian
rst("ayfandianj")=fandianj
rst("chongzhij")=chongzhij 
rst("chonglirun")=chonglirun 
rst("chongzhib")=chongzhib 
rst("diankalirun")=diankalirun 
rst("diankalirunsum")=diankalirunsum 
rst("jishilirun")=jishilirun
rst("jishilirunsum")=jishilirunsum 
rst("jiajilirun")=jiajilirun
rst("jiajilirunsum")=jiajilirunsum 
rst("aotolirun")=aotolirun
rst("aotolirunsum")=aotolirunsum 
rst("shoukuanj")=shoukuanj 
rst("shoulirun")=shoulirun 
rst("shoulirunsum")=shoulirunsum 
rst("banklirun")=banklirun
rst("alipaylirun")=alipaylirun
rst("tenpaylirun")=tenpaylirun 
rst("ayptsaoj")=ayptsaoj
rst("ayptsaob")=ayptsaob
rst("ayptsaol")=ayptsaol

rst("wapalib")=wapalib 
rst("wapalij")=wapalij
rst("waptenb")=waptenb 
rst("waptenj")=waptenj
rst("wapalil")=wapalil
rst("waptenl")=waptenl
rst("qqsaob")=qqsaob 
rst("qqsaoj")=qqsaoj
rst("qqsaol")=qqsaol

rst("wapweib")=wapweib
rst("wapweij")=wapweij
rst("wapweil")=wapweil

rst("wapqqb")=wapqqb
rst("wapqqj")=wapqqj
rst("wapqql")=wapqql
rst("xiaofeij")=xiaofeij


rst.update

end if
rst.close



response.Write "ok"
end if
%>
