mirror of
https://gitee.com/elegant_wings/dbd-meeting.git
synced 2025-06-21 22:59:36 +08:00
Merge branch 'shoot-hand' of https://gitee.com/elegant_wings/dbd-meeting into shoot-hand
This commit is contained in:
commit
8ed02a61ec
@ -17,6 +17,7 @@ import com.ics.admin.service.IRepairAddressFloorService;
|
|||||||
import org.wf.jwtp.annotation.RequiresPermissions;
|
import org.wf.jwtp.annotation.RequiresPermissions;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 地点楼层
|
* 地点楼层
|
||||||
@ -67,6 +68,11 @@ public class RepairAddressFloorController extends BaseController {
|
|||||||
@RequiresPermissions("floor:floor:add")
|
@RequiresPermissions("floor:floor:add")
|
||||||
@PostMapping("save")
|
@PostMapping("save")
|
||||||
public R addSave(@RequestBody RepairAddressFloor repairAddressFloor) {
|
public R addSave(@RequestBody RepairAddressFloor repairAddressFloor) {
|
||||||
|
IcsCustomerStaff staff = new IcsCustomerStaff();
|
||||||
|
staff.setId(repairAddressFloor.getAdminId());
|
||||||
|
staff.setDataType("9");
|
||||||
|
customerStaffService.updateIcsCustomerStaff(staff);
|
||||||
|
|
||||||
return toAjax(repairAddressFloorService.insertRepairAddressFloor(repairAddressFloor));
|
return toAjax(repairAddressFloorService.insertRepairAddressFloor(repairAddressFloor));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,6 +82,21 @@ public class RepairAddressFloorController extends BaseController {
|
|||||||
@RequiresPermissions("floor:floor:edit")
|
@RequiresPermissions("floor:floor:edit")
|
||||||
@PostMapping("update")
|
@PostMapping("update")
|
||||||
public R editSave(@RequestBody RepairAddressFloor repairAddressFloor) {
|
public R editSave(@RequestBody RepairAddressFloor repairAddressFloor) {
|
||||||
|
Long id = repairAddressFloor.getId();
|
||||||
|
RepairAddressFloor addressFloor = repairAddressFloorService.selectRepairAddressFloorById(id);
|
||||||
|
if (addressFloor != null) {
|
||||||
|
Long adminId = addressFloor.getAdminId();
|
||||||
|
if (!Objects.equals(repairAddressFloor.getAdminId(), adminId)) {
|
||||||
|
IcsCustomerStaff staff = customerStaffService.selectIcsCustomerStaffById(repairAddressFloor.getAdminId());
|
||||||
|
if (staff != null)
|
||||||
|
staff.setDataType("9");
|
||||||
|
customerStaffService.updateIcsCustomerStaff(staff);
|
||||||
|
IcsCustomerStaff staff1 = customerStaffService.selectIcsCustomerStaffById(adminId);
|
||||||
|
staff1.setDataType("1");
|
||||||
|
customerStaffService.updateIcsCustomerStaff(staff1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return toAjax(repairAddressFloorService.updateRepairAddressFloor(repairAddressFloor));
|
return toAjax(repairAddressFloorService.updateRepairAddressFloor(repairAddressFloor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import com.ics.common.core.domain.IcsCustomerStaff;
|
|||||||
import com.ics.common.core.domain.R;
|
import com.ics.common.core.domain.R;
|
||||||
import com.ics.common.core.page.PageDomain;
|
import com.ics.common.core.page.PageDomain;
|
||||||
import com.ics.common.core.page.TableSupport;
|
import com.ics.common.core.page.TableSupport;
|
||||||
import com.ics.controller.mobile.pay.wx.WxPayCommon;
|
//import com.ics.controller.mobile.pay.wx.WxPayCommon;
|
||||||
import com.ics.controller.mobile.pay.wx.constant.WxNotifyConstants;
|
import com.ics.controller.mobile.pay.wx.constant.WxNotifyConstants;
|
||||||
import com.ics.controller.mobile.pay.wx.dto.WxChatBasePayDto;
|
import com.ics.controller.mobile.pay.wx.dto.WxChatBasePayDto;
|
||||||
import com.ics.controller.mobile.pay.wx.dto.WxChatPayDto;
|
import com.ics.controller.mobile.pay.wx.dto.WxChatPayDto;
|
||||||
@ -75,8 +75,8 @@ public class ApiRoomContentController extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IRoomEquipmentService roomEquipmentService;
|
private IRoomEquipmentService roomEquipmentService;
|
||||||
|
|
||||||
@Autowired
|
// @Autowired
|
||||||
WxPayCommon wxPayCommon;
|
// WxPayCommon wxPayCommon;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IUserEquipmentService userEquipmentService;
|
private IUserEquipmentService userEquipmentService;
|
||||||
@ -260,8 +260,8 @@ public class ApiRoomContentController extends BaseController {
|
|||||||
wxChatBasePayDto.setPrice(price);
|
wxChatBasePayDto.setPrice(price);
|
||||||
wxChatBasePayDto.setNotify(WxNotifyConstants.CASE_PAY_NOTIFY);
|
wxChatBasePayDto.setNotify(WxNotifyConstants.CASE_PAY_NOTIFY);
|
||||||
wxChatBasePayDto.setOpenId(customerStaff.getOpenid());
|
wxChatBasePayDto.setOpenId(customerStaff.getOpenid());
|
||||||
String prepayId = wxPayCommon.wxJsApiPay(wxChatBasePayDto);
|
// String prepayId = wxPayCommon.wxJsApiPay(wxChatBasePayDto);
|
||||||
reservation.setPrepayId(prepayId);
|
// reservation.setPrepayId(prepayId);
|
||||||
reservation.setStauts(Reservation.Status.TO_BE_PAID);
|
reservation.setStauts(Reservation.Status.TO_BE_PAID);
|
||||||
Long userId = reservation.getUserId();
|
Long userId = reservation.getUserId();
|
||||||
|
|
||||||
|
@ -1,160 +1,160 @@
|
|||||||
package com.ics.controller.mobile.meeting;
|
//package com.ics.controller.mobile.meeting;
|
||||||
|
//
|
||||||
import cn.hutool.core.lang.Assert;
|
//import cn.hutool.core.lang.Assert;
|
||||||
import com.google.gson.Gson;
|
//import com.google.gson.Gson;
|
||||||
import com.ics.admin.domain.meeting.Reservation;
|
//import com.ics.admin.domain.meeting.Reservation;
|
||||||
import com.ics.admin.service.meeting.IReservationService;
|
//import com.ics.admin.service.meeting.IReservationService;
|
||||||
import com.ics.controller.mobile.pay.wx.WxPayCallbackUtil;
|
//import com.ics.controller.mobile.pay.wx.WxPayCallbackUtil;
|
||||||
import com.ics.controller.mobile.pay.wx.WxPayCommon;
|
//import com.ics.controller.mobile.pay.wx.WxPayCommon;
|
||||||
import com.ics.controller.mobile.pay.wx.dto.WxChatBasePayDto;
|
//import com.ics.controller.mobile.pay.wx.dto.WxChatBasePayDto;
|
||||||
import com.ics.controller.mobile.pay.wx.dto.WxChatPayDto;
|
//import com.ics.controller.mobile.pay.wx.dto.WxChatPayDto;
|
||||||
import com.ics.admin.service.meeting.ICustomerTicketService;
|
//import com.ics.admin.service.meeting.ICustomerTicketService;
|
||||||
import com.ics.common.core.controller.BaseController;
|
//import com.ics.common.core.controller.BaseController;
|
||||||
import com.ics.common.core.domain.R;
|
//import com.ics.common.core.domain.R;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
//import org.springframework.web.bind.annotation.*;
|
||||||
|
//
|
||||||
import javax.servlet.http.HttpServletRequest;
|
//import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
//import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.Date;
|
//import java.util.Date;
|
||||||
import java.util.HashMap;
|
//import java.util.HashMap;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 微信支付
|
// * 微信支付
|
||||||
*/
|
// */
|
||||||
@RestController
|
//@RestController
|
||||||
@RequestMapping("/meeting/wxPay")
|
//@RequestMapping("/meeting/wxPay")
|
||||||
public class WxPayController extends BaseController {
|
//public class WxPayController extends BaseController {
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
ICustomerTicketService customerTicketService;
|
// ICustomerTicketService customerTicketService;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
WxPayCommon wxPayCommon;
|
// WxPayCommon wxPayCommon;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
WxPayCallbackUtil wxPayCallbackUtil;
|
// WxPayCallbackUtil wxPayCallbackUtil;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private IReservationService reservationService;
|
// private IReservationService reservationService;
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 下载
|
// * 下载
|
||||||
*/
|
// */
|
||||||
@PostMapping("paySign")
|
// @PostMapping("paySign")
|
||||||
public R paySign(@RequestBody Reservation reservation) {
|
// public R paySign(@RequestBody Reservation reservation) {
|
||||||
// String prepayId = wxPayCommon.wxJsApiPay(wxChatBasePayDto);
|
//// String prepayId = wxPayCommon.wxJsApiPay(wxChatBasePayDto);
|
||||||
WxChatPayDto wxChatPayDto = wxPayCommon.wxPayCall(reservation.getPrepayId());
|
// WxChatPayDto wxChatPayDto = wxPayCommon.wxPayCall(reservation.getPrepayId());
|
||||||
return R.data(wxChatPayDto);
|
// return R.data(wxChatPayDto);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 订单支付后回调
|
// * 订单支付后回调
|
||||||
*/
|
// */
|
||||||
@PostMapping("orderCallBack")
|
// @PostMapping("orderCallBack")
|
||||||
public HashMap orderCallBack(HttpServletRequest request, HttpServletResponse response) {
|
// public HashMap orderCallBack(HttpServletRequest request, HttpServletResponse response) {
|
||||||
HashMap<String, String> returnParam = new HashMap<>();
|
// HashMap<String, String> returnParam = new HashMap<>();
|
||||||
try {
|
// try {
|
||||||
Map<String, String> parseParam = wxPayCallbackUtil.wxChatPayCallback(request, response);
|
// Map<String, String> parseParam = wxPayCallbackUtil.wxChatPayCallback(request, response);
|
||||||
// 交易状态
|
// // 交易状态
|
||||||
// SUCCESS:支付成功
|
// // SUCCESS:支付成功
|
||||||
// REFUND:转入退款
|
// // REFUND:转入退款
|
||||||
// NOTPAY:未支付
|
// // NOTPAY:未支付
|
||||||
// CLOSED:已关闭
|
// // CLOSED:已关闭
|
||||||
// REVOKED:已撤销(付款码支付)
|
// // REVOKED:已撤销(付款码支付)
|
||||||
// USERPAYING:用户支付中(付款码支付)
|
// // USERPAYING:用户支付中(付款码支付)
|
||||||
// PAYERROR:支付失败(其他原因,如银行返回失败)
|
// // PAYERROR:支付失败(其他原因,如银行返回失败)
|
||||||
String trade_state = parseParam.get("trade_state");
|
// String trade_state = parseParam.get("trade_state");
|
||||||
// 商户订单号
|
// // 商户订单号
|
||||||
String out_trade_no = parseParam.get("out_trade_no");
|
// String out_trade_no = parseParam.get("out_trade_no");
|
||||||
// 微信订单号
|
// // 微信订单号
|
||||||
String transaction_id = parseParam.get("transaction_id");
|
// String transaction_id = parseParam.get("transaction_id");
|
||||||
//
|
// //
|
||||||
//支付成功
|
// //支付成功
|
||||||
if (trade_state.equals("SUCCESS")){
|
// if (trade_state.equals("SUCCESS")){
|
||||||
//编写支付成功后逻辑
|
// //编写支付成功后逻辑
|
||||||
System.out.println("订单支付后回调");
|
// System.out.println("订单支付后回调");
|
||||||
Gson gson = new Gson();
|
// Gson gson = new Gson();
|
||||||
System.out.println(gson.toJson(parseParam));
|
// System.out.println(gson.toJson(parseParam));
|
||||||
Reservation reservation = reservationService.selectByOrderNumber(out_trade_no);
|
// Reservation reservation = reservationService.selectByOrderNumber(out_trade_no);
|
||||||
Assert.isTrue(reservation != null, "订单不存在");
|
// Assert.isTrue(reservation != null, "订单不存在");
|
||||||
if (reservation.getStauts().equals(Reservation.Status.TO_BE_PAID)){
|
// if (reservation.getStauts().equals(Reservation.Status.TO_BE_PAID)){
|
||||||
reservation.setStauts(Reservation.Status.APPOINTMENT);
|
// reservation.setStauts(Reservation.Status.APPOINTMENT);
|
||||||
reservation.setOrderTime(new Date());
|
// reservation.setOrderTime(new Date());
|
||||||
int i = reservationService.updateReservation(reservation);
|
// int i = reservationService.updateReservation(reservation);
|
||||||
Assert.isTrue(i == 1, "更新失败");
|
// Assert.isTrue(i == 1, "更新失败");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
//响应微信
|
// //响应微信
|
||||||
returnParam.put("code", "SUCCESS");
|
// returnParam.put("code", "SUCCESS");
|
||||||
returnParam.put("message", "成功");
|
// returnParam.put("message", "成功");
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
return returnParam;
|
// return returnParam;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 商户订单号查询订单
|
// * 商户订单号查询订单
|
||||||
*/
|
// */
|
||||||
@PostMapping("wxMerchantOrderQuery")
|
// @PostMapping("wxMerchantOrderQuery")
|
||||||
public HashMap wxMerchantOrderQuery(@RequestBody Map<String , String> paramMap) {
|
// public HashMap wxMerchantOrderQuery(@RequestBody Map<String , String> paramMap) {
|
||||||
HashMap<String, String> resultMap = wxPayCommon.wxMerchantOrderQuery(paramMap.get("outTradeNo"));
|
// HashMap<String, String> resultMap = wxPayCommon.wxMerchantOrderQuery(paramMap.get("outTradeNo"));
|
||||||
|
//
|
||||||
HashMap<Object, Object> map = new HashMap<>();
|
// HashMap<Object, Object> map = new HashMap<>();
|
||||||
// 商户订单号
|
// // 商户订单号
|
||||||
String out_trade_no = resultMap.get("out_trade_no");
|
// String out_trade_no = resultMap.get("out_trade_no");
|
||||||
// 微信支付订单号
|
// // 微信支付订单号
|
||||||
String transaction_id = resultMap.get("transaction_id");
|
// String transaction_id = resultMap.get("transaction_id");
|
||||||
Reservation reservation = reservationService.selectByOrderNumber(out_trade_no);
|
// Reservation reservation = reservationService.selectByOrderNumber(out_trade_no);
|
||||||
|
//
|
||||||
// 交易状态
|
// // 交易状态
|
||||||
// * SUCCESS:支付成功
|
// // * SUCCESS:支付成功
|
||||||
// * REFUND:转入退款
|
// // * REFUND:转入退款
|
||||||
// * NOTPAY:未支付
|
// // * NOTPAY:未支付
|
||||||
// * CLOSED:已关闭
|
// // * CLOSED:已关闭
|
||||||
// * REVOKED:已撤销(仅付款码支付会返回)
|
// // * REVOKED:已撤销(仅付款码支付会返回)
|
||||||
// * USERPAYING:用户支付中(仅付款码支付会返回)
|
// // * USERPAYING:用户支付中(仅付款码支付会返回)
|
||||||
// * PAYERROR:支付失败(仅付款码支付会返回)
|
// // * PAYERROR:支付失败(仅付款码支付会返回)
|
||||||
String trade_state = resultMap.get("trade_state");
|
// String trade_state = resultMap.get("trade_state");
|
||||||
if (trade_state.equals("SUCCESS")){
|
// if (trade_state.equals("SUCCESS")){
|
||||||
//更新数据库
|
// //更新数据库
|
||||||
Assert.isTrue(reservation != null, "订单不存在");
|
// Assert.isTrue(reservation != null, "订单不存在");
|
||||||
reservation.setStauts(Reservation.Status.APPOINTMENT);
|
// reservation.setStauts(Reservation.Status.APPOINTMENT);
|
||||||
reservation.setOrderTime(new Date());
|
// reservation.setOrderTime(new Date());
|
||||||
int i = reservationService.updateReservation(reservation);
|
// int i = reservationService.updateReservation(reservation);
|
||||||
Assert.isTrue(i == 1, "更新失败");
|
// Assert.isTrue(i == 1, "更新失败");
|
||||||
map.put("code", 200);
|
// map.put("code", 200);
|
||||||
map.put("msg", "支付成功");
|
// map.put("msg", "支付成功");
|
||||||
}else if (trade_state.equals("REFUND")){
|
// }else if (trade_state.equals("REFUND")){
|
||||||
map.put("code", 500);
|
// map.put("code", 500);
|
||||||
map.put("msg", "转入退款");
|
// map.put("msg", "转入退款");
|
||||||
}else if (trade_state.equals("NOTPAY")){
|
// }else if (trade_state.equals("NOTPAY")){
|
||||||
map.put("code", 500);
|
// map.put("code", 500);
|
||||||
map.put("msg", "未支付");
|
// map.put("msg", "未支付");
|
||||||
}else if (trade_state.equals("CLOSED")){
|
// }else if (trade_state.equals("CLOSED")){
|
||||||
map.put("code", 500);
|
// map.put("code", 500);
|
||||||
map.put("msg", "已关闭");
|
// map.put("msg", "已关闭");
|
||||||
}else if (trade_state.equals("REVOKED")){
|
// }else if (trade_state.equals("REVOKED")){
|
||||||
map.put("code", 500);
|
// map.put("code", 500);
|
||||||
map.put("msg", "已撤销");
|
// map.put("msg", "已撤销");
|
||||||
}else if (trade_state.equals("USERPAYING")){
|
// }else if (trade_state.equals("USERPAYING")){
|
||||||
map.put("code", 500);
|
// map.put("code", 500);
|
||||||
map.put("msg", "用户支付中");
|
// map.put("msg", "用户支付中");
|
||||||
}else if (trade_state.equals("PAYERROR")){
|
// }else if (trade_state.equals("PAYERROR")){
|
||||||
map.put("code", 500);
|
// map.put("code", 500);
|
||||||
map.put("msg", "支付失败");
|
// map.put("msg", "支付失败");
|
||||||
}else {
|
// }else {
|
||||||
map.put("code", 500);
|
// map.put("code", 500);
|
||||||
map.put("msg", "支付失败");
|
// map.put("msg", "支付失败");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return map;
|
// return map;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
@ -1,157 +1,157 @@
|
|||||||
package com.ics.controller.mobile.pay.wx;
|
//package com.ics.controller.mobile.pay.wx;
|
||||||
|
//
|
||||||
import com.alibaba.fastjson.JSONObject;
|
//import com.alibaba.fastjson.JSONObject;
|
||||||
import com.wechat.pay.contrib.apache.httpclient.util.AesUtil;
|
//import com.wechat.pay.contrib.apache.httpclient.util.AesUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
|
//
|
||||||
import javax.servlet.ServletInputStream;
|
//import javax.servlet.ServletInputStream;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
//import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
//import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.BufferedReader;
|
//import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
//import java.io.InputStreamReader;
|
||||||
import java.io.UnsupportedEncodingException;
|
//import java.io.UnsupportedEncodingException;
|
||||||
import java.security.GeneralSecurityException;
|
//import java.security.GeneralSecurityException;
|
||||||
import java.util.HashMap;
|
//import java.util.HashMap;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
//import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
//import java.util.stream.Stream;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 微信支付回调工具类
|
// * 微信支付回调工具类
|
||||||
*/
|
// */
|
||||||
@Component
|
//@Component
|
||||||
public class WxPayCallbackUtil {
|
//public class WxPayCallbackUtil {
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
WxPayConfig wxPayConfig;
|
// WxPayConfig wxPayConfig;
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 获取回调数据
|
// * 获取回调数据
|
||||||
* @param request
|
// * @param request
|
||||||
* @param response
|
// * @param response
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
public Map<String, String> wxChatPayCallback(HttpServletRequest request, HttpServletResponse response) {
|
// public Map<String, String> wxChatPayCallback(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
//
|
||||||
//获取报文
|
// //获取报文
|
||||||
String body = getRequestBody(request);
|
// String body = getRequestBody(request);
|
||||||
|
//
|
||||||
//随机串
|
// //随机串
|
||||||
String nonceStr = request.getHeader("Wechatpay-Nonce");
|
// String nonceStr = request.getHeader("Wechatpay-Nonce");
|
||||||
|
//
|
||||||
//微信传递过来的签名
|
// //微信传递过来的签名
|
||||||
String signature = request.getHeader("Wechatpay-Signature");
|
// String signature = request.getHeader("Wechatpay-Signature");
|
||||||
|
//
|
||||||
//证书序列号(微信平台)
|
// //证书序列号(微信平台)
|
||||||
String serialNo = request.getHeader("Wechatpay-Serial");
|
// String serialNo = request.getHeader("Wechatpay-Serial");
|
||||||
|
//
|
||||||
//时间戳
|
// //时间戳
|
||||||
String timestamp = request.getHeader("Wechatpay-Timestamp");
|
// String timestamp = request.getHeader("Wechatpay-Timestamp");
|
||||||
|
//
|
||||||
//构造签名串 应答时间戳\n,应答随机串\n,应答报文主体\n
|
// //构造签名串 应答时间戳\n,应答随机串\n,应答报文主体\n
|
||||||
String signStr = Stream.of(timestamp, nonceStr, body).collect(Collectors.joining("\n", "", "\n"));
|
// String signStr = Stream.of(timestamp, nonceStr, body).collect(Collectors.joining("\n", "", "\n"));
|
||||||
|
//
|
||||||
Map<String, String> map = new HashMap<>(2);
|
// Map<String, String> map = new HashMap<>(2);
|
||||||
try {
|
// try {
|
||||||
//验证签名是否通过
|
// //验证签名是否通过
|
||||||
boolean result = verifiedSign(serialNo, signStr, signature);
|
// boolean result = verifiedSign(serialNo, signStr, signature);
|
||||||
if(result){
|
// if(result){
|
||||||
//解密数据
|
// //解密数据
|
||||||
String plainBody = decryptBody(body);
|
// String plainBody = decryptBody(body);
|
||||||
return convertWechatPayMsgToMap(plainBody);
|
// return convertWechatPayMsgToMap(plainBody);
|
||||||
}
|
// }
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
return map;
|
// return map;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 转换body为map
|
// * 转换body为map
|
||||||
* @param plainBody
|
// * @param plainBody
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
public Map<String,String> convertWechatPayMsgToMap(String plainBody){
|
// public Map<String,String> convertWechatPayMsgToMap(String plainBody){
|
||||||
|
//
|
||||||
Map<String,String> paramsMap = new HashMap<>(2);
|
// Map<String,String> paramsMap = new HashMap<>(2);
|
||||||
|
//
|
||||||
JSONObject jsonObject = JSONObject.parseObject(plainBody);
|
// JSONObject jsonObject = JSONObject.parseObject(plainBody);
|
||||||
|
//
|
||||||
//商户订单号
|
// //商户订单号
|
||||||
paramsMap.put("out_trade_no",jsonObject.getString("out_trade_no"));
|
// paramsMap.put("out_trade_no",jsonObject.getString("out_trade_no"));
|
||||||
//交易状态
|
// //交易状态
|
||||||
paramsMap.put("trade_state",jsonObject.getString("trade_state"));
|
// paramsMap.put("trade_state",jsonObject.getString("trade_state"));
|
||||||
// 微信订单号
|
// // 微信订单号
|
||||||
paramsMap.put("transaction_id",jsonObject.getString("transaction_id"));
|
// paramsMap.put("transaction_id",jsonObject.getString("transaction_id"));
|
||||||
|
//
|
||||||
//附加数据
|
// //附加数据
|
||||||
paramsMap.put("attach",jsonObject.getString("attach"));
|
// paramsMap.put("attach",jsonObject.getString("attach"));
|
||||||
if (jsonObject.getJSONObject("attach") != null && !jsonObject.getJSONObject("attach").equals("")){
|
// if (jsonObject.getJSONObject("attach") != null && !jsonObject.getJSONObject("attach").equals("")){
|
||||||
paramsMap.put("account_no",jsonObject.getJSONObject("attach").getString("accountNo"));
|
// paramsMap.put("account_no",jsonObject.getJSONObject("attach").getString("accountNo"));
|
||||||
}
|
// }
|
||||||
return paramsMap;
|
// return paramsMap;
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 解密body的密文
|
// * 解密body的密文
|
||||||
*
|
// *
|
||||||
* "resource": {
|
// * "resource": {
|
||||||
* "original_type": "transaction",
|
// * "original_type": "transaction",
|
||||||
* "algorithm": "AEAD_AES_256_GCM",
|
// * "algorithm": "AEAD_AES_256_GCM",
|
||||||
* "ciphertext": "",
|
// * "ciphertext": "",
|
||||||
* "associated_data": "",
|
// * "associated_data": "",
|
||||||
* "nonce": ""
|
// * "nonce": ""
|
||||||
* }
|
// * }
|
||||||
*
|
// *
|
||||||
* @param body
|
// * @param body
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
public String decryptBody(String body) throws UnsupportedEncodingException, GeneralSecurityException {
|
// public String decryptBody(String body) throws UnsupportedEncodingException, GeneralSecurityException {
|
||||||
AesUtil aesUtil = new AesUtil(wxPayConfig.getKey().getBytes("utf-8"));
|
// AesUtil aesUtil = new AesUtil(wxPayConfig.getKey().getBytes("utf-8"));
|
||||||
JSONObject object = JSONObject.parseObject(body);
|
// JSONObject object = JSONObject.parseObject(body);
|
||||||
JSONObject resource = object.getJSONObject("resource");
|
// JSONObject resource = object.getJSONObject("resource");
|
||||||
String ciphertext = resource.getString("ciphertext");
|
// String ciphertext = resource.getString("ciphertext");
|
||||||
String associatedData = resource.getString("associated_data");
|
// String associatedData = resource.getString("associated_data");
|
||||||
String nonce = resource.getString("nonce");
|
// String nonce = resource.getString("nonce");
|
||||||
return aesUtil.decryptToString(associatedData.getBytes("utf-8"),nonce.getBytes("utf-8"),ciphertext);
|
// return aesUtil.decryptToString(associatedData.getBytes("utf-8"),nonce.getBytes("utf-8"),ciphertext);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 验证签名
|
// * 验证签名
|
||||||
*
|
// *
|
||||||
* @param serialNo 微信平台-证书序列号
|
// * @param serialNo 微信平台-证书序列号
|
||||||
* @param signStr 自己组装的签名串
|
// * @param signStr 自己组装的签名串
|
||||||
* @param signature 微信返回的签名
|
// * @param signature 微信返回的签名
|
||||||
* @return
|
// * @return
|
||||||
* @throws UnsupportedEncodingException
|
// * @throws UnsupportedEncodingException
|
||||||
*/
|
// */
|
||||||
public boolean verifiedSign(String serialNo, String signStr, String signature) throws UnsupportedEncodingException {
|
// public boolean verifiedSign(String serialNo, String signStr, String signature) throws UnsupportedEncodingException {
|
||||||
return wxPayConfig.getVerifier().verify(serialNo, signStr.getBytes("utf-8"), signature);
|
// return wxPayConfig.getVerifier().verify(serialNo, signStr.getBytes("utf-8"), signature);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 读取请求数据流
|
// * 读取请求数据流
|
||||||
*
|
// *
|
||||||
* @param request
|
// * @param request
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
public String getRequestBody(HttpServletRequest request) {
|
// public String getRequestBody(HttpServletRequest request) {
|
||||||
StringBuffer sb = new StringBuffer();
|
// StringBuffer sb = new StringBuffer();
|
||||||
try (ServletInputStream inputStream = request.getInputStream();
|
// try (ServletInputStream inputStream = request.getInputStream();
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
// BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||||
) {
|
// ) {
|
||||||
String line;
|
// String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
// while ((line = reader.readLine()) != null) {
|
||||||
sb.append(line);
|
// sb.append(line);
|
||||||
}
|
// }
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
return sb.toString();
|
// return sb.toString();
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
@ -1,253 +1,253 @@
|
|||||||
package com.ics.controller.mobile.pay.wx;
|
//package com.ics.controller.mobile.pay.wx;
|
||||||
|
//
|
||||||
import com.google.gson.Gson;
|
//import com.google.gson.Gson;
|
||||||
import com.ics.controller.mobile.pay.wx.constant.WxApiConstants;
|
//import com.ics.controller.mobile.pay.wx.constant.WxApiConstants;
|
||||||
import com.ics.controller.mobile.pay.wx.dto.WxChatBasePayDto;
|
//import com.ics.controller.mobile.pay.wx.dto.WxChatBasePayDto;
|
||||||
import com.ics.controller.mobile.pay.wx.dto.WxChatPayDto;
|
//import com.ics.controller.mobile.pay.wx.dto.WxChatPayDto;
|
||||||
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
|
//import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
//import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
//import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
//import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
//import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.http.entity.StringEntity;
|
//import org.apache.http.entity.StringEntity;
|
||||||
import org.apache.http.util.EntityUtils;
|
//import org.apache.http.util.EntityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
|
//
|
||||||
import java.io.FileInputStream;
|
//import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
//import java.math.BigDecimal;
|
||||||
import java.security.Signature;
|
//import java.security.Signature;
|
||||||
import java.util.Base64;
|
//import java.util.Base64;
|
||||||
import java.util.HashMap;
|
//import java.util.HashMap;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
import java.util.UUID;
|
//import java.util.UUID;
|
||||||
|
//
|
||||||
@Component
|
//@Component
|
||||||
public class WxPayCommon {
|
//public class WxPayCommon {
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
WxPayConfig wxPayConfig;
|
// WxPayConfig wxPayConfig;
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 封装基础通用请求数据
|
// * 封装基础通用请求数据
|
||||||
*
|
// *
|
||||||
* @param basePayData 微信支付基础请求数据
|
// * @param basePayData 微信支付基础请求数据
|
||||||
* @return 封装后的map对象
|
// * @return 封装后的map对象
|
||||||
*/
|
// */
|
||||||
public Map<String, Object> getBasePayParams(WxChatBasePayDto basePayData) {
|
// public Map<String, Object> getBasePayParams(WxChatBasePayDto basePayData) {
|
||||||
Map<String, Object> paramsMap = new HashMap<>();
|
// Map<String, Object> paramsMap = new HashMap<>();
|
||||||
paramsMap.put("appid", wxPayConfig.getAppid());
|
// paramsMap.put("appid", wxPayConfig.getAppid());
|
||||||
paramsMap.put("mchid", wxPayConfig.getMchId());
|
// paramsMap.put("mchid", wxPayConfig.getMchId());
|
||||||
// 如果商品名称过长则截取
|
// // 如果商品名称过长则截取
|
||||||
String title = basePayData.getDescription().length() > 120 ? basePayData.getDescription().substring(0, 120) : basePayData.getDescription();
|
// String title = basePayData.getDescription().length() > 120 ? basePayData.getDescription().substring(0, 120) : basePayData.getDescription();
|
||||||
paramsMap.put("description", title);
|
// paramsMap.put("description", title);
|
||||||
paramsMap.put("out_trade_no", basePayData.getOrderId());
|
// paramsMap.put("out_trade_no", basePayData.getOrderId());
|
||||||
paramsMap.put("notify_url", wxPayConfig.getNotifyDomain().concat(basePayData.getNotify()));
|
// paramsMap.put("notify_url", wxPayConfig.getNotifyDomain().concat(basePayData.getNotify()));
|
||||||
Map<String, Integer> amountMap = new HashMap<>();
|
// Map<String, Integer> amountMap = new HashMap<>();
|
||||||
amountMap.put("total", basePayData.getPrice().multiply(new BigDecimal("100")).intValue());
|
// amountMap.put("total", basePayData.getPrice().multiply(new BigDecimal("100")).intValue());
|
||||||
paramsMap.put("amount", amountMap);
|
// paramsMap.put("amount", amountMap);
|
||||||
return paramsMap;
|
// return paramsMap;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 获取请求对象(Post请求)
|
// * 获取请求对象(Post请求)
|
||||||
*
|
// *
|
||||||
* @param paramsMap 请求参数
|
// * @param paramsMap 请求参数
|
||||||
* @return Post请求对象
|
// * @return Post请求对象
|
||||||
*/
|
// */
|
||||||
public HttpPost getHttpPost(String url, Map<String, Object> paramsMap) {
|
// public HttpPost getHttpPost(String url, Map<String, Object> paramsMap) {
|
||||||
// 1.设置请求地址
|
// // 1.设置请求地址
|
||||||
HttpPost httpPost = new HttpPost(wxPayConfig.getDomain().concat(url));
|
// HttpPost httpPost = new HttpPost(wxPayConfig.getDomain().concat(url));
|
||||||
|
//
|
||||||
// 2.设置请求数据
|
// // 2.设置请求数据
|
||||||
Gson gson = new Gson();
|
// Gson gson = new Gson();
|
||||||
String jsonParams = gson.toJson(paramsMap);
|
// String jsonParams = gson.toJson(paramsMap);
|
||||||
|
//
|
||||||
// 3.设置请求信息
|
// // 3.设置请求信息
|
||||||
StringEntity entity = new StringEntity(jsonParams, "utf-8");
|
// StringEntity entity = new StringEntity(jsonParams, "utf-8");
|
||||||
entity.setContentType("application/json");
|
// entity.setContentType("application/json");
|
||||||
httpPost.setEntity(entity);
|
// httpPost.setEntity(entity);
|
||||||
httpPost.setHeader("Accept", "application/json");
|
// httpPost.setHeader("Accept", "application/json");
|
||||||
return httpPost;
|
// return httpPost;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 获取请求对象(Get请求)
|
// * 获取请求对象(Get请求)
|
||||||
*
|
// *
|
||||||
* @return Get请求
|
// * @return Get请求
|
||||||
*/
|
// */
|
||||||
public HttpGet getHttpGet(String url) {
|
// public HttpGet getHttpGet(String url) {
|
||||||
// 1.设置请求地址
|
// // 1.设置请求地址
|
||||||
HttpGet httpGet = new HttpGet(wxPayConfig.getDomain().concat(url));
|
// HttpGet httpGet = new HttpGet(wxPayConfig.getDomain().concat(url));
|
||||||
// 3.设置请求信息
|
// // 3.设置请求信息
|
||||||
httpGet.setHeader("Accept", "application/json");
|
// httpGet.setHeader("Accept", "application/json");
|
||||||
return httpGet;
|
// return httpGet;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 解析响应数据
|
// * 解析响应数据
|
||||||
*
|
// *
|
||||||
* @param response 发送请求成功后,返回的数据
|
// * @param response 发送请求成功后,返回的数据
|
||||||
* @return 微信返回的参数
|
// * @return 微信返回的参数
|
||||||
*/
|
// */
|
||||||
public HashMap<String, String> resolverResponse(CloseableHttpResponse response) {
|
// public HashMap<String, String> resolverResponse(CloseableHttpResponse response) {
|
||||||
try {
|
// try {
|
||||||
// 1.获取请求码
|
// // 1.获取请求码
|
||||||
int statusCode = response.getStatusLine().getStatusCode();
|
// int statusCode = response.getStatusLine().getStatusCode();
|
||||||
// 2.获取返回值 String 格式
|
// // 2.获取返回值 String 格式
|
||||||
final String bodyAsString = EntityUtils.toString(response.getEntity());
|
// final String bodyAsString = EntityUtils.toString(response.getEntity());
|
||||||
|
//
|
||||||
Gson gson = new Gson();
|
// Gson gson = new Gson();
|
||||||
if (statusCode == 200) {
|
// if (statusCode == 200) {
|
||||||
// 3.如果请求成功则解析成Map对象返回
|
// // 3.如果请求成功则解析成Map对象返回
|
||||||
HashMap<String, String> resultMap = gson.fromJson(bodyAsString, HashMap.class);
|
// HashMap<String, String> resultMap = gson.fromJson(bodyAsString, HashMap.class);
|
||||||
return resultMap;
|
// return resultMap;
|
||||||
} else {
|
// } else {
|
||||||
if (StringUtils.isNoneBlank(bodyAsString)) {
|
// if (StringUtils.isNoneBlank(bodyAsString)) {
|
||||||
System.out.println("微信支付请求失败,提示信息:{}" + bodyAsString);
|
// System.out.println("微信支付请求失败,提示信息:{}" + bodyAsString);
|
||||||
// 4.请求码显示失败,则尝试获取提示信息
|
// // 4.请求码显示失败,则尝试获取提示信息
|
||||||
HashMap<String, String> resultMap = gson.fromJson(bodyAsString, HashMap.class);
|
// HashMap<String, String> resultMap = gson.fromJson(bodyAsString, HashMap.class);
|
||||||
throw new RuntimeException(resultMap.get("message"));
|
// throw new RuntimeException(resultMap.get("message"));
|
||||||
}
|
// }
|
||||||
System.out.println("微信支付请求失败,未查询到原因,提示信息:{}" + response.toString());
|
// System.out.println("微信支付请求失败,未查询到原因,提示信息:{}" + response.toString());
|
||||||
// 其他异常,微信也没有返回数据,这就需要具体排查了
|
// // 其他异常,微信也没有返回数据,这就需要具体排查了
|
||||||
throw new IOException("request failed");
|
// throw new IOException("request failed");
|
||||||
}
|
// }
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
throw new RuntimeException(e.getMessage());
|
// throw new RuntimeException(e.getMessage());
|
||||||
} finally {
|
// } finally {
|
||||||
try {
|
// try {
|
||||||
response.close();
|
// response.close();
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 获取签名
|
// * 获取签名
|
||||||
*
|
// *
|
||||||
* @param nonceStr 随机数
|
// * @param nonceStr 随机数
|
||||||
* @param appId 微信公众号或者小程序等的appid
|
// * @param appId 微信公众号或者小程序等的appid
|
||||||
* @param prepay_id 预支付交易会话ID
|
// * @param prepay_id 预支付交易会话ID
|
||||||
* @param timestamp 时间戳 10位
|
// * @param timestamp 时间戳 10位
|
||||||
* @return String 新签名
|
// * @return String 新签名
|
||||||
*/
|
// */
|
||||||
String getSign(String nonceStr, String appId, String prepay_id, long timestamp) {
|
// String getSign(String nonceStr, String appId, String prepay_id, long timestamp) {
|
||||||
|
//
|
||||||
//从下往上依次生成
|
// //从下往上依次生成
|
||||||
String message = buildMessage(appId, timestamp, nonceStr, prepay_id);
|
// String message = buildMessage(appId, timestamp, nonceStr, prepay_id);
|
||||||
//签名
|
// //签名
|
||||||
try {
|
// try {
|
||||||
return sign(message.getBytes("utf-8"));
|
// return sign(message.getBytes("utf-8"));
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
throw new RuntimeException("签名异常,请检查参数或商户私钥");
|
// throw new RuntimeException("签名异常,请检查参数或商户私钥");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
String sign(byte[] message) {
|
// String sign(byte[] message) {
|
||||||
try {
|
// try {
|
||||||
//签名方式
|
// //签名方式
|
||||||
Signature sign = Signature.getInstance("SHA256withRSA");
|
// Signature sign = Signature.getInstance("SHA256withRSA");
|
||||||
//私钥,通过MyPrivateKey来获取,这是个静态类可以接调用方法 ,需要的是_key.pem文件的绝对路径配上文件名
|
// //私钥,通过MyPrivateKey来获取,这是个静态类可以接调用方法 ,需要的是_key.pem文件的绝对路径配上文件名
|
||||||
sign.initSign(PemUtil.loadPrivateKey(new FileInputStream(wxPayConfig.getPrivateKeyPath())));
|
// sign.initSign(PemUtil.loadPrivateKey(new FileInputStream(wxPayConfig.getPrivateKeyPath())));
|
||||||
sign.update(message);
|
// sign.update(message);
|
||||||
return Base64.getEncoder().encodeToString(sign.sign());
|
// return Base64.getEncoder().encodeToString(sign.sign());
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
throw new RuntimeException("签名异常,请检查参数或商户私钥");
|
// throw new RuntimeException("签名异常,请检查参数或商户私钥");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 按照前端签名文档规范进行排序,\n是换行
|
// * 按照前端签名文档规范进行排序,\n是换行
|
||||||
*
|
// *
|
||||||
* @param nonceStr 随机数
|
// * @param nonceStr 随机数
|
||||||
* @param appId 微信公众号或者小程序等的appid
|
// * @param appId 微信公众号或者小程序等的appid
|
||||||
* @param prepay_id 预支付交易会话ID
|
// * @param prepay_id 预支付交易会话ID
|
||||||
* @param timestamp 时间戳 10位
|
// * @param timestamp 时间戳 10位
|
||||||
* @return String 新签名
|
// * @return String 新签名
|
||||||
*/
|
// */
|
||||||
String buildMessage(String appId, long timestamp, String nonceStr, String prepay_id) {
|
// String buildMessage(String appId, long timestamp, String nonceStr, String prepay_id) {
|
||||||
return appId + "\n"
|
// return appId + "\n"
|
||||||
+ timestamp + "\n"
|
// + timestamp + "\n"
|
||||||
+ nonceStr + "\n"
|
// + nonceStr + "\n"
|
||||||
+ prepay_id + "\n";
|
// + prepay_id + "\n";
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 创建微信支付订单-jsapi方式
|
// * 创建微信支付订单-jsapi方式
|
||||||
*
|
// *
|
||||||
* @param basePayData 基础请求信息,商品标题、商家订单id、订单价格
|
// * @param basePayData 基础请求信息,商品标题、商家订单id、订单价格
|
||||||
* @return 微信支付二维码地址
|
// * @return 微信支付二维码地址
|
||||||
*/
|
// */
|
||||||
public String wxJsApiPay(WxChatBasePayDto basePayData) {
|
// public String wxJsApiPay(WxChatBasePayDto basePayData) {
|
||||||
// 1.获取请求参数的Map格式
|
// // 1.获取请求参数的Map格式
|
||||||
Map<String, Object> paramsMap = getBasePayParams(basePayData);
|
// Map<String, Object> paramsMap = getBasePayParams(basePayData);
|
||||||
// 1.1 添加支付者信息
|
// // 1.1 添加支付者信息
|
||||||
Map<String, String> payerMap = new HashMap();
|
// Map<String, String> payerMap = new HashMap();
|
||||||
payerMap.put("openid", basePayData.getOpenId());
|
// payerMap.put("openid", basePayData.getOpenId());
|
||||||
paramsMap.put("payer", payerMap);
|
// paramsMap.put("payer", payerMap);
|
||||||
|
//
|
||||||
// 2.获取请求对象
|
// // 2.获取请求对象
|
||||||
HttpPost httpPost = getHttpPost(WxApiConstants.JSAPI_PAY, paramsMap);
|
// HttpPost httpPost = getHttpPost(WxApiConstants.JSAPI_PAY, paramsMap);
|
||||||
|
//
|
||||||
// 3.完成签名并执行请求
|
// // 3.完成签名并执行请求
|
||||||
CloseableHttpResponse response = null;
|
// CloseableHttpResponse response = null;
|
||||||
try {
|
// try {
|
||||||
response = wxPayConfig.getWxPayClient().execute(httpPost);
|
// response = wxPayConfig.getWxPayClient().execute(httpPost);
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
throw new RuntimeException("微信支付请求失败");
|
// throw new RuntimeException("微信支付请求失败");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 4.解析response对象
|
// // 4.解析response对象
|
||||||
HashMap<String, String> resultMap = resolverResponse(response);
|
// HashMap<String, String> resultMap = resolverResponse(response);
|
||||||
if (resultMap != null) {
|
// if (resultMap != null) {
|
||||||
// 【预支付交易会话标识】 预支付交易会话标识。用于后续接口调用中使用,该值有效期为2小时
|
// // 【预支付交易会话标识】 预支付交易会话标识。用于后续接口调用中使用,该值有效期为2小时
|
||||||
return resultMap.get("prepay_id");
|
// return resultMap.get("prepay_id");
|
||||||
}
|
// }
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 微信用户调用微信支付
|
// * 微信用户调用微信支付
|
||||||
*/
|
// */
|
||||||
public WxChatPayDto wxPayCall(String prepayId) {
|
// public WxChatPayDto wxPayCall(String prepayId) {
|
||||||
WxChatPayDto wxChatPayDto = new WxChatPayDto();
|
// WxChatPayDto wxChatPayDto = new WxChatPayDto();
|
||||||
wxChatPayDto.setAppid(wxPayConfig.getAppid());
|
// wxChatPayDto.setAppid(wxPayConfig.getAppid());
|
||||||
wxChatPayDto.setTimeStamp(String.valueOf(System.currentTimeMillis() / 1000));
|
// wxChatPayDto.setTimeStamp(String.valueOf(System.currentTimeMillis() / 1000));
|
||||||
wxChatPayDto.setNonceStr(UUID.randomUUID().toString().replaceAll("-", ""));
|
// wxChatPayDto.setNonceStr(UUID.randomUUID().toString().replaceAll("-", ""));
|
||||||
wxChatPayDto.setPrepayId("prepay_id=" + prepayId);
|
// wxChatPayDto.setPrepayId("prepay_id=" + prepayId);
|
||||||
wxChatPayDto.setSignType("RSA");
|
// wxChatPayDto.setSignType("RSA");
|
||||||
wxChatPayDto.setPaySign(getSign(wxChatPayDto.getNonceStr(), wxChatPayDto.getAppid(), wxChatPayDto.getPrepayId(), Long.parseLong(wxChatPayDto.getTimeStamp())));
|
// wxChatPayDto.setPaySign(getSign(wxChatPayDto.getNonceStr(), wxChatPayDto.getAppid(), wxChatPayDto.getPrepayId(), Long.parseLong(wxChatPayDto.getTimeStamp())));
|
||||||
|
//
|
||||||
return wxChatPayDto;
|
// return wxChatPayDto;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 商户订单号查询订单
|
// * 商户订单号查询订单
|
||||||
*/
|
// */
|
||||||
public HashMap<String, String> wxMerchantOrderQuery(String outTradeNo) {
|
// public HashMap<String, String> wxMerchantOrderQuery(String outTradeNo) {
|
||||||
// 创建请求
|
// // 创建请求
|
||||||
HttpGet httpGet = getHttpGet(WxApiConstants.MERCHANT_ORDER_NUMBER_QUERY + "/" + outTradeNo + "?mchid=" + wxPayConfig.getMchId());
|
// HttpGet httpGet = getHttpGet(WxApiConstants.MERCHANT_ORDER_NUMBER_QUERY + "/" + outTradeNo + "?mchid=" + wxPayConfig.getMchId());
|
||||||
// 完成签名并执行请求
|
// // 完成签名并执行请求
|
||||||
CloseableHttpResponse response = null;
|
// CloseableHttpResponse response = null;
|
||||||
try {
|
// try {
|
||||||
response = wxPayConfig.getWxPayClient().execute(httpGet);
|
// response = wxPayConfig.getWxPayClient().execute(httpGet);
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
throw new RuntimeException("商户订单号查询订单请求失败");
|
// throw new RuntimeException("商户订单号查询订单请求失败");
|
||||||
}
|
// }
|
||||||
// 解析response对象
|
// // 解析response对象
|
||||||
HashMap<String, String> resultMap = resolverResponse(response);
|
// HashMap<String, String> resultMap = resolverResponse(response);
|
||||||
return resultMap;
|
// return resultMap;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
@ -19,9 +19,9 @@ import java.io.FileNotFoundException;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.PrivateKey;
|
import java.security.PrivateKey;
|
||||||
|
|
||||||
@Configuration
|
//@Configuration
|
||||||
@PropertySource("classpath:application.yml") //读取配置文件
|
//@PropertySource("classpath:application.yml") //读取配置文件
|
||||||
@ConfigurationProperties(prefix = "weixin") //读取wxpay节点
|
//@ConfigurationProperties(prefix = "weixin") //读取wxpay节点
|
||||||
@Data
|
@Data
|
||||||
/**
|
/**
|
||||||
* 微信支付静态常量类
|
* 微信支付静态常量类
|
||||||
@ -83,7 +83,7 @@ public class WxPayConfig {
|
|||||||
/**
|
/**
|
||||||
* 获取签名验证器
|
* 获取签名验证器
|
||||||
*/
|
*/
|
||||||
@Bean
|
// @Bean
|
||||||
public Verifier getVerifier() {
|
public Verifier getVerifier() {
|
||||||
// 获取商户私钥
|
// 获取商户私钥
|
||||||
final PrivateKey privateKey = getPrivateKey(privateKeyPath);
|
final PrivateKey privateKey = getPrivateKey(privateKeyPath);
|
||||||
@ -116,7 +116,7 @@ public class WxPayConfig {
|
|||||||
* 获取微信支付的远程请求对象
|
* 获取微信支付的远程请求对象
|
||||||
* @return Http请求对象
|
* @return Http请求对象
|
||||||
*/
|
*/
|
||||||
@Bean
|
// @Bean
|
||||||
public CloseableHttpClient getWxPayClient() {
|
public CloseableHttpClient getWxPayClient() {
|
||||||
|
|
||||||
// 获取签名验证器
|
// 获取签名验证器
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
spring:
|
spring:
|
||||||
redis:
|
redis:
|
||||||
database: 1
|
database: 1
|
||||||
host: 127.0.0.1
|
host: 222.184.49.22
|
||||||
port: 6379
|
port: 6379
|
||||||
password: 123456
|
password: 123456
|
||||||
timeout: 6000ms # 连接超时时长(毫秒)
|
timeout: 6000ms # 连接超时时长(毫秒)
|
||||||
@ -17,9 +17,9 @@ spring:
|
|||||||
druid:
|
druid:
|
||||||
# 主库数据源
|
# 主库数据源
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/dbd-meeting?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
url: jdbc:mysql://222.184.49.22:3306/shoot-hand?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||||
username: root
|
username: root
|
||||||
password: Boyue1!Z
|
password: boyue1!Z
|
||||||
# 从库数据源
|
# 从库数据源
|
||||||
slave:
|
slave:
|
||||||
#从数据源开关/默认关闭
|
#从数据源开关/默认关闭
|
||||||
@ -65,12 +65,12 @@ spring:
|
|||||||
multi-statement-allow: true
|
multi-statement-allow: true
|
||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
location: /usr/local/uploadPath/
|
location: /file/uploadPath/
|
||||||
|
|
||||||
# 本地文件上传路径
|
# 本地文件上传路径
|
||||||
dfs:
|
dfs:
|
||||||
path: /usr/local/uploadPath/
|
path: /file/uploadPath/
|
||||||
domain: https://www.chuangzhikj.com//saas-ics
|
domain: https://company.haxy.com.cn:4443/shoot-hand
|
||||||
# domain: http://39.165.217.47:81/saas-ics/
|
# domain: http://39.165.217.47:81/saas-ics/
|
||||||
# domain: https://www.xxxx.com/
|
# domain: https://www.xxxx.com/
|
||||||
# 公众号配置(必填)
|
# 公众号配置(必填)
|
||||||
@ -88,7 +88,7 @@ wx:
|
|||||||
key-prefix: wa # 相关redis前缀配置: wa(默认)
|
key-prefix: wa # 相关redis前缀配置: wa(默认)
|
||||||
redis:
|
redis:
|
||||||
host: localhost
|
host: localhost
|
||||||
# password: vdcity2015
|
# password: vdcity2015
|
||||||
port: 6379
|
port: 6379
|
||||||
# http客户端配置
|
# http客户端配置
|
||||||
http-client-type: HttpClient # http客户端类型: HttpClient(默认), OkHttp, JoddHttp
|
http-client-type: HttpClient # http客户端类型: HttpClient(默认), OkHttp, JoddHttp
|
||||||
|
Loading…
x
Reference in New Issue
Block a user