servlet里面拿到common.property的属性

---------------------common.property文件-----------------------

kongxc_wx_dinghuo_orderSendMusic=http://music.163.com/#/song?id=27867140

--------------------servlet-------------------------

 

import java.util.Properties;

public class WeiXinNotify extends HttpServlet{
protected Logger logger = LoggerFactory.getLogger(getClass());
private SystemLogManager logManager;
private CoursesOrdersManager coursesOrdersManager;
private CoursesOrdersDetailsManager coursesOrdersDetailsManager;
private MemberBaseInfoManager memberBaseInfoManager;
private SchoolManager schoolManager;
private MealTimeManager mealTimeManager;
private static InputStream kongxc_orderSend_musicStream;
private Properties props = new Properties();
private static String kongxc_wx_diancan_orderServlet;



@Override
public void init() throws ServletException {
super.init();
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
logManager = wac.getBean("systemLogManager", SystemLogManager.class);
coursesOrdersManager = (CoursesOrdersManager) wac.getBean("coursesOrdersManager", CoursesOrdersManager.class);
coursesOrdersDetailsManager = (CoursesOrdersDetailsManager) wac.getBean("coursesOrdersDetailsManager", CoursesOrdersDetailsManager.class);
memberBaseInfoManager = (MemberBaseInfoManager) wac.getBean("memberBaseInfoManager", MemberBaseInfoManager.class);
schoolManager = (SchoolManager) wac.getBean("schoolManager", SchoolManager.class);
mealTimeManager = (MealTimeManager) wac.getBean("mealTimeManager", MealTimeManager.class);
try {
kongxc_orderSend_musicStream = wac.getResource("/WEB-INF/conf/common.properties").getInputStream();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
doPost(req, resp);
}

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
System.out.println("-------开始------");
BufferedReader br = new BufferedReader(new InputStreamReader(req.getInputStream(),"UTF-8"));
String line="";
StringBuffer buffer = new StringBuffer(1024);
while((line=br.readLine())!=null){
buffer.append(line);
}
String reXml=URLDecoder.decode(buffer.toString(), "utf-8");
System.out.println("-----------支付成功----------"+reXml);
try {
Map<String, Object> map = XMLParser.getMapFromXML(reXml);
String return_code = (String) map.get("return_code");
if (return_code.equalsIgnoreCase("SUCCESS")) {
String out_trade_no = (String) map.get("out_trade_no");
CoursesOrders orders = coursesOrdersManager.findByProperty("orderCode", out_trade_no);
if (orders!=null && orders.getStatus().equals(CoursesOrderStatus.WZF)) {
orders.setIsDelete("0");
orders.setPayTime(Calendar.getInstance());
orders.setStatus(CoursesOrderStatus.YZF);
coursesOrdersManager.updateStatus(orders);
MemberBaseInfo memberBaseInfo = memberBaseInfoManager.findById(orders.getMemberId());
CoursesOrdersDetailsModel detailModel = new CoursesOrdersDetailsModel();
detailModel.setOrderId(orders.getId());
detailModel.setIsEffective(false);
detailModel.setCreator(orders.getMemberId());
System.out.println("detailModel---------"+detailModel);
List<CoursesOrdersDetails> detailList = coursesOrdersDetailsManager.queryList(detailModel);
System.out.println("detailList==========="+detailList);
String str ="";
for (CoursesOrdersDetails cod : detailList) {
cod.setOrderId(orders);
cod.setIsEffective(true);
cod.setLastChanged(Calendar.getInstance());
coursesOrdersDetailsManager.update(cod);
MealTimeModel mealTimeModel =new MealTimeModel();
mealTimeModel.setCode(cod.getMealcode());
mealTimeModel.setMealType(cod.getLb());
System.out.println("mealTimeModel-----------"+mealTimeModel);
List<MealTime> mealTimeList = mealTimeManager.listQuList(mealTimeModel);
System.out.println("mealTimeList ---------------" +mealTimeList);
if(mealTimeList != null && mealTimeList.size()>0){
cod.setQucanStartTime(TimeTools.calendar2String(mealTimeList.get(0).getqCstartTime(), "HH:mm:ss"));
cod.setQucanEndTime(TimeTools.calendar2String(mealTimeList.get(0).getqCendTime(), "HH:mm:ss"));
}
str += cod.getCourseId().getNameCh() + ",";
}
System.out.println("detailList----------detailList------------"+detailList);
String detailListStr= str.substring(0,str.length()-1);
//订单详情推送
System.out.println("+++++++++++++");


//获取access_token
String requestUrl = Configure.requestUrl.replace("APPID", Configure.appID);
requestUrl = requestUrl.replace("APPSECRET", Configure.appsecret);
// JSONObject jsonObject = NetTools.httpsRequest(requestUrl, "GET", null);
// System.out.println("jsonObject--------"+jsonObject);
// System.out.println("jsonObject--------"+jsonObject);
// System.out.println("jsonObject--------"+jsonObject);
// String access_token = (String) jsonObject.get("access_token");
String access_token = AccessTokenInfo.accessToken.getAccessToken();
System.out.println("accessToken---------"+access_token);


OrderSend orderSend =new OrderSend();
System.out.println("access_token----------------"+access_token);
System.out.println("memberBaseInfo----------------"+memberBaseInfo);
System.out.println("orders----------------"+orders);
System.out.println("detailList----------------"+detailList);


props.load(kongxc_orderSend_musicStream);
System.out.println("kongxc_diancanUrl_urlStream-----------------"+kongxc_orderSend_musicStream);
kongxc_wx_diancan_orderServlet= props.getProperty("kongxc_wx_diancan_orderServlet");
System.out.println("kongxc_wx_diancan_orderServlet-----"+kongxc_wx_diancan_orderServlet);
System.out.println("kongxc_wx_diancan_orderServlet-----"+kongxc_wx_diancan_orderServlet);
System.out.println("kongxc_wx_diancan_orderServlet-----"+kongxc_wx_diancan_orderServlet);
kongxc_wx_diancan_orderServlet += "?openid="+memberBaseInfo.getOpenid();
String orderSendServlet = Configure.orderSendServlet + "?openid="+memberBaseInfo.getOpenid();
System.out.println("2222-----kongxc_wx_diancan_orderServlet-----"+orderSendServlet);

orderSend.zhiFuMethod(access_token,memberBaseInfo,orders,detailList,detailListStr,orderSendServlet);


System.out.println("-------操作成功--------------");
resp.getWriter().print("<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>");
}
}
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (ManagerException e) {
e.printStackTrace();
}

}

@Override
public void destroy() {
super.destroy();
}
}

 

posted @ 2017-09-07 14:03  baby孔祥超  阅读(194)  评论(0编辑  收藏  举报