Commit 54ad0368 authored by 张永's avatar 张永

增加微企付回调

parent bfe51b4a
...@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.egolm.common.DateUtil; import com.egolm.common.DateUtil;
import com.egolm.common.GsonUtil; import com.egolm.common.GsonUtil;
import com.egolm.common.HttpsUtil; import com.egolm.common.HttpsUtil;
...@@ -76,6 +77,8 @@ public class PayNotifyController { ...@@ -76,6 +77,8 @@ public class PayNotifyController {
public Object mepayCallback(@RequestBody String req, HttpServletResponse resp) { public Object mepayCallback(@RequestBody String req, HttpServletResponse resp) {
logger.info("接收到微企付回调通知接口: "+req); logger.info("接收到微企付回调通知接口: "+req);
List<Map<String, Object>> returnMap = orderService.mePayCallback(req);
logger.info("处理微企付回调信息结果 {}",GsonUtil.toJson(returnMap));
return "success"; return "success";
} }
......
...@@ -47,4 +47,6 @@ public interface OrderService { ...@@ -47,4 +47,6 @@ public interface OrderService {
public List<Map<String, Object>> createSettlePay(String settleNO, String payTypeID,String payType,String payAmount,String payCardNO) ; public List<Map<String, Object>> createSettlePay(String settleNO, String payTypeID,String payType,String payAmount,String payCardNO) ;
public List<Map<String, Object>> payCallback(WxPayResponse postData); public List<Map<String, Object>> payCallback(WxPayResponse postData);
public List<Map<String, Object>> mePayCallback(String req);
} }
...@@ -1163,7 +1163,7 @@ public class OrderServiceImpl implements OrderService { ...@@ -1163,7 +1163,7 @@ public class OrderServiceImpl implements OrderService {
String OpenID = postData.getOpenid(); String OpenID = postData.getOpenid();
String paydate = DateUtil.format(DateUtil.parse(PayDate,DateUtil.FMT_YYYYMMddHHMMSS),DateUtil.FMT_DATE_SECOND); String paydate = DateUtil.format(DateUtil.parse(PayDate,DateUtil.FMT_YYYYMMddHHMMSS),DateUtil.FMT_DATE_SECOND);
logger.info("支付回调单号: {}",OutTradeNO); logger.info("支付回调单号: {}",OutTradeNO);
//补款后缀是_D,结算单后缀是_S /*//补款后缀是_D,结算单后缀是_S
if(OutTradeNO.contains("_D")) { if(OutTradeNO.contains("_D")) {
String sql = "exec up_B2BSalesOrderDebtPayCallBack '"+OutTradeNO+"' ,'"+TransactionID+"' , '"+PayCardNO+"' , '"+PayAmount+"' , '"+paydate+"' , '"+PayChannel+"' "; String sql = "exec up_B2BSalesOrderDebtPayCallBack '"+OutTradeNO+"' ,'"+TransactionID+"' , '"+PayCardNO+"' , '"+PayAmount+"' , '"+paydate+"' , '"+PayChannel+"' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0); returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
...@@ -1173,13 +1173,103 @@ public class OrderServiceImpl implements OrderService { ...@@ -1173,13 +1173,103 @@ public class OrderServiceImpl implements OrderService {
}else {//普通订单 }else {//普通订单
String[] ary = OutTradeNO.split("_", 2); String[] ary = OutTradeNO.split("_", 2);
returnMap = this.paySuccess(ary[0], new BigDecimal(PayAmount), OpenID, TransactionID, OutTradeNO, DateUtil.parse(paydate, DateUtil.FMT_DATE_SECOND)); returnMap = this.paySuccess(ary[0], new BigDecimal(PayAmount), OpenID, TransactionID, OutTradeNO, DateUtil.parse(paydate, DateUtil.FMT_DATE_SECOND));
} }*/
this.doCallBack(OutTradeNO, TransactionID, PayCardNO, PayAmount, paydate, PayChannel, OpenID);
} catch (Exception e) { } catch (Exception e) {
logger.info("支付回调异常 ,{} ",e.getMessage()); logger.info("支付回调异常 ,{} ",e.getMessage());
} }
return returnMap; return returnMap;
} }
/**
* 微企付的回调 PayTypeID=140
* <p>Title: </p>
* <p>Description: </p>
* @param req
* @return
*/
public List<Map<String, Object>> mePayCallback(String req){
String PayTypeID = "140"; //微企付
List<Map<String, Object>> returnMap = new ArrayList<Map<String, Object>>();
JSONObject reqObj = JSONObject.parseObject(req);
if(reqObj.containsKey("callback_from")) { //mp支付预下单 自已定的回调,非微企付官方回调
String paymentId = reqObj.getString("paymentId");
String outPaymentId = reqObj.getString("outPaymentId");
//String payStatus = reqObj.getString("payStatus");
String PayCardNO = reqObj.getString("PayCardNO");
String PayAmount = reqObj.getString("PayAmount");
String sql = "exec up_B2BSalesOrderPayUpdate '"+outPaymentId+"' ,'"+paymentId+"' , '"+PayCardNO+"' , '"+PayAmount+"' , '"+PayTypeID+"' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
}else {
//https://businesspay.qq.com/p/doc/mse/api/server.html#%E6%94%AF%E4%BB%98%E7%BB%93%E6%9E%9C%E9%80%9A%E7%9F%A5-2
//https://businesspay.qq.com/p/doc/mse/api/server.html#%E9%80%80%E6%AC%BE%E7%BB%93%E6%9E%9C%E9%80%9A%E7%9F%A5
//mse_payment.succeeded 支付成功
//mse_payment.close 支付关单
// mse_payment.revoke 支付退票
String event_type = reqObj.getString("event_type"); //
JSONObject event_content = reqObj.getJSONObject("event_content");
String payment_id = event_content.getString("payment_id"); //微企付支付单号
String out_payment_id = event_content.getString("out_payment_id"); //付款方 ID
if(event_type.equals("mse_payment.succeeded") || event_type.equals("mse_payment.close") || event_type.equals("mse_payment.revoke")) {
//String openid = event_content.getString("purchaser_id");//个人付款时对应微企付用户openid
String status = event_content.getString("status");
String PayAmount = event_content.getString("amount");
String pay_succ_time = status.equals("SUCCEEDED")?event_content.getString("pay_succ_time"):"";
String StatusID ="";
String StatusName ="";
switch (status) {
case "SUCCEEDED":
StatusID = "1";
StatusName = "支付成功";
break;
case "CLOSED":
StatusID = "2";
StatusName = "支付关单";
break;
case "REVOKED":
StatusID = "3";
StatusName = "支付退票";
break;
default:
break;
}
String sql = "exec up_B2BSalesOrderPayCallBack '"+out_payment_id+"' ,'"+payment_id+"' , '"+PayAmount+"' , '"+pay_succ_time+"' , '"+PayTypeID+"' , '"+StatusID+"' , '"+StatusName+"' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
}else if (event_type.equals("mse_refund.succeeded")) { //退款成功
}
}
return returnMap;
}
public List<Map<String, Object>> doCallBack(String OutTradeNO,String TransactionID,String PayCardNO,String PayAmount,String paydate,String PayChannel,String OpenID){
List<Map<String, Object>> returnMap = new ArrayList<Map<String, Object>>();
//补款后缀是_D,结算单后缀是_S
if(OutTradeNO.contains("_D")) {
String sql = "exec up_B2BSalesOrderDebtPayCallBack '"+OutTradeNO+"' ,'"+TransactionID+"' , '"+PayCardNO+"' , '"+PayAmount+"' , '"+paydate+"' , '"+PayChannel+"' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
}else if (OutTradeNO.contains("_S")) {
String sql = "exec up_CreateSettlePayCallBack '"+OutTradeNO+"' ,'"+TransactionID+"' , '"+PayCardNO+"' , '"+PayAmount+"' , '"+paydate+"' , '"+PayChannel+"' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
}else {//普通订单
String[] ary = OutTradeNO.split("_", 2);
returnMap = this.paySuccess(ary[0], new BigDecimal(PayAmount), OpenID, TransactionID, OutTradeNO, DateUtil.parse(paydate, DateUtil.FMT_DATE_SECOND));
}
return returnMap;
}
//提交结算付款记录 //提交结算付款记录
@Override @Override
public List<Map<String, Object>> createSettlePay(String settleNO, String payTypeID, String payType, public List<Map<String, Object>> createSettlePay(String settleNO, String payTypeID, String payType,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment