<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="inc/ex_stock/ex_sm_conn.asp"-->
<!--#include file="inc/ex_stock/ex_sm_const.asp"-->
<!--#include file="inc/ex_stock/ex_admin/ex_admin_index.asp"-->
<%
	if not exsm.stockadmin then
		exsm.errmess="您没有管理权限！请返回。"
		call exsm.endinfo("no")
	else
		dim trade_info
		trade_info=split(exsm.stockdata(10,0),",")
		select case request("action")
			case "upintervene"
				call upintervene()
			case else
				call main()
		end select
	end if
	sub main()
		dim stockid
		stockid=request("sid")
		if stockid="" or not isnumeric(stockid) then stockid=0
		if stockid<>0 then
			set rs=stock_conn.execute("select * from ex_stock where sid="&stockid&"")
			if rs.eof and rs.bof then
				exsm.errmess="没有找到该股票。"
				call exsm.endinfo("no")
				exit sub
			end if
		end if
		adminmenutop "社区干预"
		session("ex_sm")=0
%>
		<table class=tableborder1 cellspacing="1" cellpadding="3" align="center" border="0" style="width:100%">
			<tr>
				<th height="25">-=>  社 区 干 预  <=-</th>
			</tr>
			<form method="post" action="?action=upintervene">
			<tr>
				<td class="tablebody1"><u>操作理由</u>&nbsp;<input name="logtxt" size="70">&nbsp;*</td>
			</tr>
			<tr>
				<td class="tablebody1" height="28"><font color="#006633"><u>被调整股票名称</u></font>
				<select name="wholestock"><option value="whole">全部股票</option>
				<%dim guestlist
				if stockid<>0 then
					sql="select sid,company from ex_stock where sid="&stockid&""
				else
					sql="select sid,company from ex_stock order by sid"
				end if
				set rs=stock_conn.execute(sql)
				if rs.eof and rs.bof then
					response.write "<option value=""0"">没有股票</option>"
				else
					do while not rs.eof
						if rs(0)=cint(stockid) then
							response.write "<option value="""&rs(0)&""" style=""color: #ff0000"" selected>"&rs(1)&"</option>"
						else
							response.write "<option value="""&rs(0)&""">"&rs(1)&"</option>"
						end if
					rs.movenext
					loop
				end if%></select>，<font color="#006633"><u>干涉价格百分比</u></font> 
				<input name="intervenenum" size="10" value="0">&nbsp;%&nbsp;。</td>
			</tr>
			<tr>
				<td class="tablebody1"><u>调整说明</u>&nbsp;<input name="newstxt" size="70">&nbsp;<input type="checkbox" name="newson" value="yes">使用</td>
			</tr>
			<tr>
				<td class="tablebody1"><u>资产刷新</u>&nbsp;<input type="radio" name="reflashinfo" value="no" checked>不同步刷新&nbsp;<input type="radio" name="reflashinfo" value="yes">同步刷新用户资产（较消耗资源！）
			</tr>
			<tr>
				<td class="tablebody1"><u>管理说明</u><br>①如果调整的股票已经涨跌停价格将不会变化。<br>②<font color="red">调整方式：</font>以上调整将影响大盘，降低所有股票价格请填写负数。<br>③如果调整说明未使用系统将自动发布信息，不发布信息请选择使用后不填写信息。<br>④如果选择了“刷新用户资产信息”则在干预的同时同步刷新用户资产信息（较消耗资源！）。</td>
			</tr>
			<tr>
				<td class="tablebody2" align="center"><input type="submit" value="确定" name="b1">&nbsp;&nbsp;<input type="reset" value="重填" name="b2"></td>
			</tr>
			</form>
		</table>
<%
		adminmenubottom
		exsm.rootshowa
	end sub
	sub upintervene()
		dim intervenenum,wholestock,newson,newstxt
		dim tradeprice,closingprice,intindex,ii,stockname,newprice,zd,zangdierange,mycontent,color,logtxt
		logtxt=trim(replace(request.form("logtxt"),"'",""))
		wholestock=trim(request.form("wholestock"))
		intervenenum=trim(request.form("intervenenum"))
		newson=trim(request.form("newson"))
		newstxt=trim(request.form("newstxt"))
		newstxt=replace(newstxt,"'","''")
		if exsm.outsiderefer() then
			exsm.errmess="请不要从外部提交数据。"
			call exsm.endinfo("stop.gif")
			exit sub
		end if
		if exsm.repeatrefer() then
			exsm.errmess="您提交的数据已经保存，请不要重复提交。"
			call exsm.endinfo("stop.gif")
			exit sub
		end if
		if logtxt="" or exsm.syllable(logtxt)>250 then
			exsm.errmess="操作理由不能为空。"
			call exsm.endinfo("no")
			exit sub
		end if
		if intervenenum="" or not isnumeric(intervenenum) then
			exsm.errmess="涨跌幅度不能为空只能使用数字，请重新输入。"
			call exsm.endinfo("no")
			exit sub
		end if
		if intervenenum=0 then
			exsm.errmess="涨跌幅度不能为[0]请重新输入。"
			call exsm.endinfo("no")
			exit sub
		end if
		if int(intervenenum)>10 or int(intervenenum)<-10 then
			exsm.errmess="请控制上涨或降低的百分比在[10%]内。"
			call exsm.endinfo("no")
			exit sub
		end if
		if wholestock="whole" then
			intindex="order by sid"
		else
			intindex="where sid="&wholestock&" order by sid"
		end if
		sql="select tradeprice,closingprice,sid,company from ex_stock "&intindex&""
		set rs=stock_conn.execute(sql)
		if not rs.eof then
			stockname=rs(3)
			i=0:ii=0
			do while not rs.eof
				tradeprice=round(rs(0),2)
				closingprice=round(rs(1),2)
				if intervenenum>0 then
					newprice=round((intervenenum/100)*closingprice,2)
					zd=newprice/closingprice
					zangdierange=round(((tradeprice+newprice-closingprice)/closingprice),4)
					if zangdierange>round(trade_info(3)/100,2) then
						newprice=round(closingprice*(1+trade_info(3)/100)-tradeprice,2)
						zd=round(trade_info(3)/100,2)-round((tradeprice-closingprice)/closingprice,2)
					end if
					mycontent="社区干预，向市场投入巨额资金，上市公司["&rs(3)&"]股票价格上扬["&formatpercent(zd,2,-1)&"]"
					color=exsm.rndcolor
				else
					newprice=round((intervenenum/100)*closingprice,2)
					zd=newprice/closingprice
					zangdierange=round(((tradeprice+newprice-closingprice)/closingprice),4)
					if zangdierange<round(-trade_info(4)/100,2) then
						newprice=round(closingprice*(1+-trade_info(4)/100)-tradeprice,2)
						zd=round(-trade_info(4)/100,2)-round((tradeprice-closingprice)/closingprice,2)
					end if
					mycontent="经济发展过热，通货膨胀严重，上市公司["&rs(3)&"]股票价格下挫["&formatpercent(abs(zd),2,-1)&"]"
					color=exsm.rndcolor
				end if
				if round(newprice,2)<>0 and round(tradeprice+newprice,2)>=1 then
					i=i+1
					ii=ii+zd
					stock_conn.execute("update ex_stock set tradeprice=tradeprice+"&round(newprice,2)&",todaywave=todaywave+"&cdbl(zd)&",totalwave=totalwave+"&cdbl(zd)&" where sid="&rs(2)&"")
					if not newson="yes" then stock_conn.execute("insert into ex_news(content,color,addtime) values ('"&mycontent&"','"&color&"',"&sqlsmnowstring&")")
				end if
			rs.movenext
			loop
		end if
		if ii=0 then
			exsm.errmess="干预失败！可能是所选股票已经涨停或跌停。"
			call exsm.endinfo("no")
			exit sub
		end if
		if newson="yes" and not newstxt="" and not exsm.syllable(newstxt)>250 then
			mycontent=""&newstxt&""
			color=exsm.rndcolor
			stock_conn.execute("insert into ex_news(content,color,addtime) values ('"&mycontent&"','"&color&"',"&sqlsmnowstring&")")
		end if
		if request.form("reflashinfo")="yes" then call exsm.calculatefund(0,0)
		session("ex_sm")=1
		if wholestock="whole" then
			exsm.sucmess="社区干预成功，所有股票价格平均变动["&formatpercent(ii/i,2,-1)&"]。"
			logtxt="股票管理：所有股票价格平均变动["&formatpercent(ii/i,2,-1)&"] 操作理由："&logtxt&" "
		else
			exsm.sucmess="社区干预成功，股票["&stockname&"]价格变动["&formatpercent(ii/i,2,-1)&"]。"
			logtxt="股票管理：股票["&stockname&"]价格变动["&formatpercent(ii/i,2,-1)&"] 操作理由："&logtxt&" "
		end if
		call exsm.savelog(exsm.scriptname,logtxt,3)
		call exsm.excolexp()
		exsm.name="exsm_imitate_quotations"
		call exsm.getreload(1,0)
		exsm.delstockcahe("exsm_imitate_news")
		call exsm.endinfo("ok")
	end sub
%>