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.1 KiB
95 lines
4.1 KiB
2 years ago
|
//package com.ynxbd.wx.servlet.remove;
|
||
|
//
|
||
|
//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.slf4j.Logger;
|
||
|
//import org.slf4j.LoggerFactory;
|
||
|
//import org.slf4j.MDC;
|
||
|
//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 PayMchJsServlet extends HttpServlet {
|
||
|
//
|
||
|
// private final Logger log = LoggerFactory.getLogger(PayMchJsServlet.class);
|
||
|
//
|
||
|
// @Override
|
||
|
// protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||
|
// MDC.remove("ip");
|
||
|
// MDC.put("ip", Global.getIpAddr(request));
|
||
|
//
|
||
|
// ReservationBean4Local reservation = (ReservationBean4Local) request.getSession().getAttribute("reservation");
|
||
|
// User user = (User) request.getSession().getAttribute("user");
|
||
|
// if (user == null || reservation == null) {
|
||
|
// log.info("支付信息session获取失败!");
|
||
|
// return;
|
||
|
// }
|
||
|
//
|
||
|
// String appID = WeChatConfig.getAppId();
|
||
|
// String mchID = WeChatConfig.getMchId();
|
||
|
// 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;
|
||
|
// fee = String.valueOf(intFee);
|
||
|
// Unifiedorder unifiedorder = new Unifiedorder();
|
||
|
// unifiedorder.setAppid(appID);
|
||
|
// unifiedorder.setMch_id(mchID);
|
||
|
// unifiedorder.setNonce_str(UUID.randomUUID().toString().replace("-", ""));
|
||
|
// unifiedorder.setOpenid(user.getOpenid());
|
||
|
// unifiedorder.setBody("ID:" + patientId + " 预约挂号(" + reservation.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() + "PayMchNotifyServlet");
|
||
|
// 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);
|
||
|
// // 记录交易流水号
|
||
|
// reservation.setTradeNo(unifiedorder.getOut_trade_no());
|
||
|
// DBDao dbDao = new DBDao();
|
||
|
// dbDao.updateReservationAfterUnified(reservation);
|
||
|
// // 将json 传到jsp 页面
|
||
|
// request.setAttribute("json", json);
|
||
|
// request.setAttribute("tradeno", unifiedorder.getOut_trade_no());
|
||
|
// log.info(String.format("挂号支付返回的tradeno=%s, json=%s", unifiedorder.getOut_trade_no(), json));
|
||
|
//
|
||
|
// request.getRequestDispatcher("reservation-pay.jsp").forward(request, response);
|
||
|
// }
|
||
|
// }
|
||
|
//
|
||
|
// protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||
|
// doPost(request, response);
|
||
|
// }
|
||
|
//
|
||
|
//}
|