main
parent
0c2cf15e60
commit
ce73b42552
|
|
@ -319,6 +319,89 @@ public class PayController extends BaseController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/aliPayCallback")
|
||||||
|
public void aliPayCallback(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
/*log.info("=======>>>开始获取支付宝支付返回信息");
|
||||||
|
//获取支付宝POST过来反馈信息,将异步通知中收到的待验证所有参数都存放到map中
|
||||||
|
Map< String , String > params = new HashMap < String , String > ();
|
||||||
|
Map requestParams = request.getParameterMap();
|
||||||
|
for(Iterator iter = requestParams.keySet().iterator();iter.hasNext();){
|
||||||
|
String name = (String)iter.next();
|
||||||
|
String[] values = (String [])requestParams.get(name);
|
||||||
|
String valueStr = "";
|
||||||
|
for(int i = 0;i < values.length;i ++ ){
|
||||||
|
valueStr = (i==values.length-1)?valueStr + values [i]:valueStr + values[i] + ",";
|
||||||
|
}
|
||||||
|
//乱码解决,这段代码在出现乱码时使用。
|
||||||
|
//valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
|
||||||
|
params.put (name,valueStr);
|
||||||
|
}
|
||||||
|
//调用SDK验证签名
|
||||||
|
//公钥验签示例代码
|
||||||
|
boolean signVerified = AlipaySignature.rsaCheckV1(params, ALIPAY_PUBLIC_KEY, CHARSET,sign_type) ;
|
||||||
|
//公钥证书验签示例代码
|
||||||
|
// boolean flag = AlipaySignature.rsaCertCheckV1(params,alipayPublicCertPath,"UTF-8","RSA2");
|
||||||
|
|
||||||
|
if (signVerified){
|
||||||
|
// TODO 验签成功后
|
||||||
|
//按照支付结果异步通知中的描述,对支付结果中的业务内容进行1\2\3\4二次校验,校验成功后在response中返回success
|
||||||
|
} else {
|
||||||
|
// TODO 验签失败则记录异常日志,并在response中返回fail.
|
||||||
|
}*/
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
InputStream in;
|
||||||
|
try {
|
||||||
|
in = request.getInputStream();
|
||||||
|
InputStreamReader reader = new InputStreamReader(in);
|
||||||
|
BufferedReader br = new BufferedReader(reader);
|
||||||
|
String s = "";
|
||||||
|
while ((s = br.readLine()) != null) {
|
||||||
|
sb.append(s);
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
reader.close();
|
||||||
|
in.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.info("获取返回信息失败");
|
||||||
|
}
|
||||||
|
log.info("微信返回来的字符串" + sb.toString());
|
||||||
|
WeChatPayResult wexinResult = getResultByXml(sb.toString());
|
||||||
|
PrintWriter out;
|
||||||
|
try {
|
||||||
|
out = response.getWriter();
|
||||||
|
if (!("SUCCESS".equals(wexinResult.getResultCode()))) {
|
||||||
|
out.println("fail");
|
||||||
|
}
|
||||||
|
|
||||||
|
String outTradeNo = wexinResult.getOutTradeNo();
|
||||||
|
AppOrder appOrder = appOrderMapper.selectOneByOutTradeNo(outTradeNo);
|
||||||
|
|
||||||
|
AppOrder entity = new AppOrder();
|
||||||
|
entity.setId(appOrder.getId());
|
||||||
|
entity.setTradeNo(wexinResult.getTransactionId());
|
||||||
|
entity.setPayStatus(2);
|
||||||
|
entity.setPayTime(new Date());
|
||||||
|
appOrderMapper.updateAppOrder(entity);
|
||||||
|
|
||||||
|
AppOrderPay miniOrderWechatPay = new AppOrderPay();
|
||||||
|
miniOrderWechatPay.setAppid(wexinResult.getAppid());
|
||||||
|
miniOrderWechatPay.setNoncestr(wexinResult.getNonceStr());
|
||||||
|
miniOrderWechatPay.setOuttradeno(wexinResult.getOutTradeNo());
|
||||||
|
miniOrderWechatPay.setResultcode(wexinResult.getResultCode());
|
||||||
|
miniOrderWechatPay.setTimeend(wexinResult.getTimeEnd());
|
||||||
|
miniOrderWechatPay.setTotalfee(wexinResult.getTotalFee());
|
||||||
|
miniOrderWechatPay.setTransactionid(wexinResult.getTransactionId());
|
||||||
|
appOrderPayMapper.insertAppOrderPay(miniOrderWechatPay);
|
||||||
|
|
||||||
|
//修改用户信息
|
||||||
|
updateUser(appOrder);
|
||||||
|
out.println("success");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("异常订单:" + wexinResult.toString());
|
||||||
|
log.info("========>PrintWriter fail");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "/test")
|
@RequestMapping(value = "/test")
|
||||||
public AjaxResult test(){
|
public AjaxResult test(){
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,8 @@ public class AppUserDynamicVo extends AppUserDynamic
|
||||||
// 是否会员;0是1否
|
// 是否会员;0是1否
|
||||||
private int isMember;
|
private int isMember;
|
||||||
|
|
||||||
|
private String cityName;
|
||||||
|
|
||||||
// 话题
|
// 话题
|
||||||
private List<AppTopic> appTopicList = new ArrayList<>();
|
private List<AppTopic> appTopicList = new ArrayList<>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,16 @@ package com.ruoyi.app.service;
|
||||||
import com.alipay.api.AlipayApiException;
|
import com.alipay.api.AlipayApiException;
|
||||||
import com.alipay.api.AlipayClient;
|
import com.alipay.api.AlipayClient;
|
||||||
import com.alipay.api.DefaultAlipayClient;
|
import com.alipay.api.DefaultAlipayClient;
|
||||||
|
import com.alipay.api.internal.util.AlipaySignature;
|
||||||
import com.alipay.api.request.AlipayTradeCreateRequest;
|
import com.alipay.api.request.AlipayTradeCreateRequest;
|
||||||
import com.alipay.api.request.AlipayTradePagePayRequest;
|
import com.alipay.api.request.AlipayTradePagePayRequest;
|
||||||
import com.alipay.api.response.AlipayTradeCreateResponse;
|
import com.alipay.api.response.AlipayTradeCreateResponse;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class AlipayService {
|
public class AlipayService {
|
||||||
|
|
||||||
|
|
@ -55,4 +60,34 @@ public class AlipayService {
|
||||||
// 发起支付请求并获取支付结果
|
// 发起支付请求并获取支付结果
|
||||||
return alipayClient.sdkExecute(alipayRequest);
|
return alipayClient.sdkExecute(alipayRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://api.xx.com/receive_notify.htm?gmt_payment=2015-06-11 22:33:59¬ify_id=42af7baacd1d3746cf7b56752b91edcj34&seller_email=testyufabu07@alipay.com¬ify_type=trade_status_sync&sign=kPbQIjX+xQc8F0/A6/AocELIjhhZnGbcBN6G4MM/HmfWL4ZiHM6fWl5NQhzXJusaklZ1LFuMo+lHQUELAYeugH8LYFvxnNajOvZhuxNFbN2LhF0l/KL8ANtj8oyPM4NN7Qft2kWJTDJUpQOzCzNnV9hDxh5AaT9FPqRS6ZKxnzM=&trade_no=2015061121001004400068549373&out_trade_no=21repl2ac2eOutTradeNo322&gmt_create=2015-06-11 22:33:46&seller_id=2088211521646673¬ify_time=2015-06-11 22:34:03&subject=FACE_TO_FACE_PAYMENT_PRECREATE中文&trade_status=TRADE_SUCCESS&sign_type=RSA2
|
||||||
|
public void handleCallback(HttpServletRequest request) {
|
||||||
|
// 获取支付宝POST过来的数据
|
||||||
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
|
Map<String, String[]> requestParams = request.getParameterMap();
|
||||||
|
for (String key : requestParams.keySet()) {
|
||||||
|
params.put(key, request.getParameter(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证签名
|
||||||
|
boolean signVerified = false;
|
||||||
|
try {
|
||||||
|
signVerified = AlipaySignature.rsaCheckV1(params, ALIPAY_PUBLIC_KEY, "UTF-8", "RSA2");
|
||||||
|
} catch (AlipayApiException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (signVerified) {
|
||||||
|
// 验证成功,处理业务逻辑
|
||||||
|
String tradeStatus = params.get("trade_status");
|
||||||
|
if ("TRADE_SUCCESS".equals(tradeStatus)) {
|
||||||
|
// 订单支付成功,更新你的系统状态
|
||||||
|
// TODO: 更新系统订单状态
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 验证失败
|
||||||
|
// TODO: 记录日志,可能的安全问题
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -50,16 +50,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
u.start_time as "startTime",
|
u.start_time as "startTime",
|
||||||
u.end_time as "endTime",
|
u.end_time as "endTime",
|
||||||
u.is_member as "isMember",
|
u.is_member as "isMember",
|
||||||
a.create_time as "createTime"
|
a.create_time as "createTime",
|
||||||
|
t.name as "cityName"
|
||||||
from app_user_dynamic a
|
from app_user_dynamic a
|
||||||
left join app_user u on u.id = a.user_id
|
left join app_user u on u.id = a.user_id
|
||||||
|
left join app_town t on t.id = a.address
|
||||||
<where>
|
<where>
|
||||||
<if test="userId != null "> and user_id = #{userId}</if>
|
<if test="userId != null "> and user_id = #{userId}</if>
|
||||||
<if test="username != null "> and username like concat('%',#{username},'%')</if>
|
<if test="username != null "> and username like concat('%',#{username},'%')</if>
|
||||||
<if test="content != null and content != ''"> and content = #{content}</if>
|
<if test="content != null and content != ''"> and content = #{content}</if>
|
||||||
<if test="videoUrl != null and videoUrl != ''"> and video_url = #{videoUrl}</if>
|
<if test="videoUrl != null and videoUrl != ''"> and video_url = #{videoUrl}</if>
|
||||||
<if test="topicId != null "> and topic_id like concat('%',#{topicId},'%')</if>
|
<if test="topicId != null "> and topic_id like concat('%',#{topicId},'%')</if>
|
||||||
<if test="address != null and address != ''"> and address like concat('%',#{address},'%')</if>
|
<if test="address != null and address != ''"> and address = #{address}</if>
|
||||||
<if test="privacyStatus != null "> and privacy_status = #{privacyStatus}</if>
|
<if test="privacyStatus != null "> and privacy_status = #{privacyStatus}</if>
|
||||||
<if test="updateBy != null and updateBy != ''"> and updateBy = #{updateBy}</if>
|
<if test="updateBy != null and updateBy != ''"> and updateBy = #{updateBy}</if>
|
||||||
<if test="isTop != null "> and is_top = #{isTop}</if>
|
<if test="isTop != null "> and is_top = #{isTop}</if>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue