You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
4.2 KiB
95 lines
4.2 KiB
//package com.ynxbd.wx.servlet;
|
|
//
|
|
//import com.ynxbd.common.bean.ReservationBean4Local;
|
|
//import com.ynxbd.common.dao.DBDao;
|
|
//import com.ynxbd.api.bean.User;
|
|
//import com.ynxbd.api.utils.Global;
|
|
//import com.ynxbd.api.utils.StrUtil;
|
|
//import com.ynxbd.api.config.WeChatConfig;
|
|
//import org.apache.log4j.Logger;
|
|
//import org.apache.log4j.NDC;
|
|
//import weixin.popular.api.PayMchAPI;
|
|
//import weixin.popular.bean.paymch.Unifiedorder;
|
|
//import weixin.popular.bean.paymch.UnifiedorderResult;
|
|
//import weixin.popular.util.PayUtil;
|
|
//
|
|
//import javax.servlet.ServletException;
|
|
//import javax.servlet.http.HttpServlet;
|
|
//import javax.servlet.http.HttpServletRequest;
|
|
//import javax.servlet.http.HttpServletResponse;
|
|
//import java.io.IOException;
|
|
//import java.util.UUID;
|
|
//
|
|
///**
|
|
// * @author 张剑峰
|
|
// * @version v1.0.0
|
|
// * @Project: 微信公众号
|
|
// * @date 2017年7月7日上午10:43:48
|
|
// * @Copyright: 2017 云南新八达科技有限公司 All rights reserved.
|
|
// */
|
|
//public class RegPayMchJsServlet extends HttpServlet {
|
|
//
|
|
// private static final Logger logger = Logger.getLogger(RegPayMchJsServlet.class);
|
|
//
|
|
// @Override
|
|
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
// String remoteAddr = Global.getIpAddr(request);
|
|
// NDC.remove();
|
|
// NDC.push(remoteAddr);
|
|
//
|
|
// ReservationBean4Local reg = (ReservationBean4Local) request.getSession().getAttribute("reg");
|
|
// User user = (User) request.getSession().getAttribute("user");
|
|
// if (user == null || reg == null) {
|
|
// logger.info("支付信息session获取失败!");
|
|
// return;
|
|
// }
|
|
//
|
|
// String appID = WeChatConfig.getAppId();
|
|
// String mchKey = WeChatConfig.getMchKey();
|
|
//
|
|
// // payPackage 的商品信息
|
|
// String patientId = request.getParameter("id");
|
|
// String fee = request.getParameter("fee");
|
|
// double dbFee = Double.parseDouble(fee);
|
|
// dbFee = dbFee * 100;
|
|
// int intFee = (int) dbFee;
|
|
// // intFee = 1;
|
|
// fee = String.valueOf(intFee);
|
|
// Unifiedorder unifiedorder = new Unifiedorder();
|
|
// unifiedorder.setAppid(WeChatConfig.getAppId());
|
|
// unifiedorder.setMch_id(WeChatConfig.getMchId());
|
|
// unifiedorder.setNonce_str(UUID.randomUUID().toString().replace("-", ""));
|
|
// unifiedorder.setOpenid(user.getOpenid());
|
|
// unifiedorder.setBody("ID:" + patientId + " 挂号(" + reg.getReservationDate() + ")");
|
|
//
|
|
// // unifiedorder.setBody("pre-registration");
|
|
// unifiedorder.setOut_trade_no(StrUtil.genTradeNo());
|
|
// unifiedorder.setTotal_fee(fee);// 单位分
|
|
// unifiedorder.setSpbill_create_ip(request.getRemoteAddr());// IP
|
|
// unifiedorder.setNotify_url(WeChatConfig.getBaseURL() + "RegPayMchNotifyServlet");
|
|
// logger.info("挂号支付通知地址:" + WeChatConfig.getBaseURL() + "RegPayMchNotifyServlet");
|
|
//
|
|
// unifiedorder.setTrade_type("JSAPI");// JSAPI,NATIVE,APP,MWEB
|
|
//
|
|
// UnifiedorderResult unifiedorderResult = PayMchAPI.payUnifiedorder(unifiedorder, mchKey);
|
|
//
|
|
// // @since 2.8.5 API返回数据签名验证
|
|
// if (unifiedorderResult.getSign_status() != null && unifiedorderResult.getSign_status()) {
|
|
// String json = PayUtil.generateMchPayJsRequestJson(unifiedorderResult.getPrepay_id(), appID, mchKey);
|
|
// // 记录交易流水号
|
|
// reg.setTradeNo(unifiedorder.getOut_trade_no());
|
|
// DBDao dbDao = new DBDao();
|
|
// dbDao.updateReservationAfterUnified(reg);
|
|
// // 将json 传到jsp 页面
|
|
// request.setAttribute("json", json);
|
|
// request.setAttribute("tradeno", unifiedorder.getOut_trade_no());
|
|
// logger.info("统一下单返回的tradeno:" + unifiedorder.getOut_trade_no());
|
|
// request.getRequestDispatcher("reg-pay.jsp").forward(request, response);
|
|
// }
|
|
// }
|
|
//
|
|
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
// doPost(request, response);
|
|
// }
|
|
//
|
|
//}
|
|
|