<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*,java.io.*,com.letousky.connector.*,com.jingCaiBack.util.*,com.jingCaiBack.util.MathUtil
,com.jingCaiBack.dao.CoreDAO" pageEncoding="UTF-8"%>
<%
    String str = "1111";
    PrintWriter writer = response.getWriter();
    String grade=session.getAttribute("grade").toString();
	Message message = new Message();
	message.setOperaterCode("M0093");
	message.setOperaterNo(CommonUtil.DOSERIALNO());
	StringBuffer strBuffer = new StringBuffer();
	String uName = new String(request.getParameter("uName").getBytes(
			"ISO-8859-1"), "GBK");
	String pwd = new String(request.getParameter("pwd").getBytes(
			"ISO-8859-1"), "GBK");
	String clientid=request.getParameter("clientid");
	String bets=request.getParameter("bets");
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String apply_time =sdf.format(new Date());//申请时间
    SqlUtil sqlUtil=new SqlUtil();
    Object clientName=sqlUtil.getColumnNameById("USER_INFO","USERID",clientid,"USERNICKNAME");
    String apply_reason= new String((request.getParameter("apply_reason")==null?" ":request.getParameter("apply_reason")).getBytes("ISO-8859-1"), "GBK");  //申请原因
    if(!"0".equals(grade)){
    	CoreDAO coreDAO=new CoreDAO();
    	String apply_id=MathUtil.GetTableId("APPLYID",1,2);
    	String sqlStr="insert into  CHONGZHI_APPLY(APPLY_ID,CLIENT_USERID,CLIENT_USERNAME,APPLY_PERSON,APPLY_TIME,APPLY_BET,APPLY_STATE,APPLY_REASON)"+
    	" values('"+apply_id+"','"+clientid+"','"+clientName+"','"+uName+"',"+" to_date('"+apply_time+"','yyyy-mm-dd hh24:mi:ss'),'"+bets+"','0','"+apply_reason+"')";
    	writer.print("{\"json\":[{\"success\":\""+str+"\"}]}");//给出提示,充值申请已经提交 ,请等待...
    	Map sqlMap=new HashMap();
    	sqlMap.put("sql",sqlStr);
    	coreDAO.insert("Core.generalInsert",sqlMap);
    	return;
    }
    System.out.println("我到这里不执行了啊!!!!!!");
	strBuffer.append(uName).append("%23;");
	strBuffer.append(pwd).append("%23;");
	strBuffer.append(clientid).append("%23;");
	strBuffer.append(bets).append("%23;");
	strBuffer.append(126).append("%23;");
	strBuffer.append(request.getParameter("sourceid")).append("%23;");
	message.setBody(strBuffer.toString());
	String results = MessageAuxiliary.messageToMessage(message);
	
	
	if (results.indexOf("0000")!=-1)
	{
		str = "0000";//给出提示,充值申请成功
	}
	
	writer.print("{\"json\":[{\"success\":\""+str+"\"}]}");
%>
