Commit 87616b4a authored by 张永's avatar 张永

更新支付回调

parent 90acc23e
...@@ -183,11 +183,11 @@ public class OrderController { ...@@ -183,11 +183,11 @@ public class OrderController {
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"), @ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"), @ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
}) })
@RequestMapping(value = "/paySuccess",method=RequestMethod.GET) @RequestMapping(value = "/paySuccess",method=RequestMethod.POST)
public String paySuccess(BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, String sOutTradeNO) { public String paySuccess(String sSalesOrderID,BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, String sOutTradeNO,String PayTypeID,String PayType) {
try { try {
String[] ary = sOutTradeNO.split("_", 2); String[] ary = sOutTradeNO.split("_", 2);
List<Map<String, Object>> result = orderService.paySuccess(ary[0], nPayAmount, sOpenID, sTransTraceNO, sOutTradeNO, new Date()); List<Map<String, Object>> result = orderService.paySuccess(ary[0], nPayAmount, sOpenID, sTransTraceNO, new Date());
return Rjx.jsonOk().set("list", result).toJson(); return Rjx.jsonOk().set("list", result).toJson();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -252,7 +252,7 @@ public class OrderController { ...@@ -252,7 +252,7 @@ public class OrderController {
String sOutTradeNO = out_trade_no; String sOutTradeNO = out_trade_no;
Date date = DateUtil.parse(payEndTime, "yyyyMMddHHmmss"); Date date = DateUtil.parse(payEndTime, "yyyyMMddHHmmss");
BigDecimal nPayAmount = new BigDecimal(total_fee); BigDecimal nPayAmount = new BigDecimal(total_fee);
orderService.paySuccess(sSalesOrderID, nPayAmount, sOpenID, sTransTraceNO, sOutTradeNO, date); orderService.paySuccess(sOutTradeNO, nPayAmount, sOpenID, sTransTraceNO, date);
} }
result.put("return_code", "SUCCESS"); result.put("return_code", "SUCCESS");
result.put("return_msg", "OK"); result.put("return_msg", "OK");
......
...@@ -58,12 +58,12 @@ public class PayNotifyController { ...@@ -58,12 +58,12 @@ public class PayNotifyController {
xs.setClassLoader(WxPayResponse.class.getClassLoader()); xs.setClassLoader(WxPayResponse.class.getClassLoader());
xs.alias("xml", WxPayResponse.class); xs.alias("xml", WxPayResponse.class);
String xmlMsg = StringUtil.inputStream2String(in); String xmlMsg = StringUtil.inputStream2String(in);
logger.info("接收到回调信息 {}",xmlMsg); logger.info("从egoPay中接收到支付回调信息 {}",xmlMsg);
postData = (WxPayResponse) xs.fromXML(xmlMsg); postData = (WxPayResponse) xs.fromXML(xmlMsg);
List<Map<String, Object>> returnMap = orderService.payCallback(postData); List<Map<String, Object>> returnMap = orderService.payCallback(postData);
logger.info("处理回调信息结果 {}",GsonUtil.toJson(returnMap)); logger.info("从egoPay中接收到支付信息结果 {}",GsonUtil.toJson(returnMap));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -22,7 +22,7 @@ public interface OrderService { ...@@ -22,7 +22,7 @@ public interface OrderService {
public String getOrderDetail(String salesOrderId); public String getOrderDetail(String salesOrderId);
public List<Map<String, Object>> paySuccess(String sSalesOrderID, BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, String sOutTradeNO, Date dPayDateTime); public List<Map<String, Object>> paySuccess(String sOutTradeNO, BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, Date dPayDateTime);
public String getSubOrderDetail(String subOrderID); public String getSubOrderDetail(String subOrderID);
......
...@@ -327,11 +327,20 @@ public class OrderServiceImpl implements OrderService { ...@@ -327,11 +327,20 @@ public class OrderServiceImpl implements OrderService {
} }
@Transactional @Transactional
public List<Map<String, Object>> paySuccess(String sSalesOrderID, BigDecimal nPayAmount, String sOpenID, public List<Map<String, Object>> paySuccess(String sOutTradeNO, BigDecimal nPayAmount, String sOpenID,
String sTransTraceNO, String sOutTradeNO, Date dPayDateTime) { String sTransTraceNO, Date dPayDateTime) {
List<Map<String, Object>> returnMap = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> returnMap = new ArrayList<Map<String, Object>>();
Integer nIdx = jdbcTemplate String sSalesOrderID ="";
try {
String sSalesOrderIDSql = "select sSalesOrderID from tSalesOrderPay where sOutTradeNO = ? ";
sSalesOrderID = jdbcTemplate.queryForString(sSalesOrderIDSql, sOutTradeNO);
} catch (Exception e1) {
e1.printStackTrace();
}
/* Integer nIdx = jdbcTemplate
.queryForInt("select ISNULL(MAX(nIdx),0) from tSalesOrderPay where sSalesOrderID = ?", sSalesOrderID); .queryForInt("select ISNULL(MAX(nIdx),0) from tSalesOrderPay where sSalesOrderID = ?", sSalesOrderID);
nPayAmount = nPayAmount.multiply(new BigDecimal(0.01)).setScale(2, BigDecimal.ROUND_HALF_UP); nPayAmount = nPayAmount.multiply(new BigDecimal(0.01)).setScale(2, BigDecimal.ROUND_HALF_UP);
...@@ -352,7 +361,9 @@ public class OrderServiceImpl implements OrderService { ...@@ -352,7 +361,9 @@ public class OrderServiceImpl implements OrderService {
Sql sqlDesc = dialect.argsInsert("tSalesOrderPay", map); Sql sqlDesc = dialect.argsInsert("tSalesOrderPay", map);
String sql = "if not exists (select * from tSalesOrderPay where sTransTraceNO = '" + sTransTraceNO + "') " String sql = "if not exists (select * from tSalesOrderPay where sTransTraceNO = '" + sTransTraceNO + "') "
+ sqlDesc.getSql(); + sqlDesc.getSql();
jdbcTemplate.update(sql, sqlDesc.getArgs()); jdbcTemplate.update(sql, sqlDesc.getArgs());*/
if(StringUtil.isNotBlank(sSalesOrderID)) {
jdbcTemplate.update("UPDATE tSalesOrderPay SET sTransTraceNO = ? AND dPayDateTime = ? WHERE sOutTradeNO = ? ",sTransTraceNO,DateUtil.format(dPayDateTime, DateUtil.FMT_DATE_SECOND),sOutTradeNO);
jdbcTemplate.update("update tSalesOrder set nOrderStatus = nOrderStatus|32 where sSalesOrderID = ?", jdbcTemplate.update("update tSalesOrder set nOrderStatus = nOrderStatus|32 where sSalesOrderID = ?",
sSalesOrderID); sSalesOrderID);
try { try {
...@@ -361,6 +372,10 @@ public class OrderServiceImpl implements OrderService { ...@@ -361,6 +372,10 @@ public class OrderServiceImpl implements OrderService {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
}else {
logger.info("支付单号:"+sOutTradeNO +"未找到对应的订单号。");
}
return returnMap; return returnMap;
} }
...@@ -1097,20 +1112,7 @@ public class OrderServiceImpl implements OrderService { ...@@ -1097,20 +1112,7 @@ public class OrderServiceImpl implements OrderService {
String paydate = DateUtil.format(DateUtil.parse(PayDate, DateUtil.FMT_YYYYMMddHHMMSS), String paydate = DateUtil.format(DateUtil.parse(PayDate, DateUtil.FMT_YYYYMMddHHMMSS),
DateUtil.FMT_DATE_SECOND); DateUtil.FMT_DATE_SECOND);
logger.info("支付回调单号: {}", OutTradeNO); logger.info("支付回调单号: {}", OutTradeNO);
/*
* //补款后缀是_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)); }
*/
returnMap = this.doCallBack(OutTradeNO, TransactionID, PayCardNO, PayAmount, paydate, PayChannel, OpenID); returnMap = this.doCallBack(OutTradeNO, TransactionID, PayCardNO, PayAmount, paydate, PayChannel, OpenID);
} catch (Exception e) { } catch (Exception e) {
...@@ -1119,15 +1121,27 @@ public class OrderServiceImpl implements OrderService { ...@@ -1119,15 +1121,27 @@ public class OrderServiceImpl implements OrderService {
return returnMap; 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,DateUtil.parse(paydate, DateUtil.FMT_DATE_SECOND));
}
return returnMap;
}
/** /**
* 微企付的回调 PayTypeID=140 * 微企付的回调 PayTypeID=140
* <p>
* Title:
* </p>
* <p>
* Description:
* </p>
*
* @param req * @param req
* @return * @return
*/ */
...@@ -1246,25 +1260,6 @@ public class OrderServiceImpl implements OrderService { ...@@ -1246,25 +1260,6 @@ public class OrderServiceImpl implements OrderService {
return returnMap; 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
......
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