Commit 7493a769 authored by 张永's avatar 张永

V1.1.7.6

parent baadc1bc
......@@ -209,7 +209,7 @@
</executions>
<configuration>
<repository>dockerhub.linkfern.com/b2c/shopapi</repository>
<tag>V1.1.7.5</tag>
<tag>V1.1.7.6</tag>
<buildArgs>
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
......
......@@ -208,7 +208,7 @@ public class OrderController {
public String paySuccess(String sSalesOrderID,BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, String sOutTradeNO,String PayTypeID) {
try {
String[] ary = sOutTradeNO.split("_", 2);
List<Map<String, Object>> result = orderService.paySuccess(ary[0], nPayAmount, sOpenID, sTransTraceNO, new Date(),PayTypeID);
List<Map<String, Object>> result = orderService.paySuccess(ary[0], nPayAmount, sOpenID, sTransTraceNO, new Date(),PayTypeID,"");
return Rjx.jsonOk().set("list", result).toJson();
} catch (Exception e) {
e.printStackTrace();
......
......@@ -14,6 +14,7 @@ import org.json.XML;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
......@@ -21,6 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.egolm.common.DateUtil;
import com.egolm.common.FileUtil;
import com.egolm.common.GsonUtil;
import com.egolm.common.HttpsUtil;
import com.egolm.common.StringUtil;
......@@ -44,6 +46,9 @@ public class PayNotifyController {
@Autowired
private OrderService orderService;
@Value("${pay.callback.path}")
private String callBackFilePath;
@ApiIgnore
@ApiOperation("支付回调通知接口")
@RequestMapping(value = "/callback", method = RequestMethod.POST)
......@@ -62,9 +67,9 @@ public class PayNotifyController {
String xmlMsg = StringUtil.inputStream2String(in);
logger.info("从egoPay中接收到支付回调信息 {}",xmlMsg);
postData = (WxPayResponse) xs.fromXML(xmlMsg);
List<Map<String, Object>> returnMap = orderService.payCallback(postData);
postData = (WxPayResponse) xs.fromXML(xmlMsg);
List<Map<String, Object>> returnMap = orderService.payCallback(postData,xmlMsg,callBackFilePath);
logger.info("从egoPay中接收到支付信息结果 {}",GsonUtil.toJson(returnMap));
} catch (Exception e) {
......@@ -79,7 +84,7 @@ public class PayNotifyController {
public Object mepayCallback(@RequestBody String req, HttpServletResponse resp) {
logger.info("从egoPay中接收到微企付回调通知接口: "+req);
List<Map<String, Object>> returnMap = orderService.mePayCallback(req);
List<Map<String, Object>> returnMap = orderService.mePayCallback(req,callBackFilePath);
logger.info("从egoPay中接收处理微企付回调信息结果 {}",GsonUtil.toJson(returnMap));
return "success";
......@@ -90,7 +95,7 @@ public class PayNotifyController {
@RequestMapping(value = "/mybankCallback", method = RequestMethod.POST)
public Object mybankCallback(@RequestBody String req, HttpServletResponse resp) {
logger.info("从egoPay中接收网商银行回调通知接口 {}",req);
List<Map<String, Object>> returnMap = orderService.myBankCallback(req);
List<Map<String, Object>> returnMap = orderService.myBankCallback(req,callBackFilePath);
logger.info("处理从egoPay中接收网商银行回调通知结果 {}",GsonUtil.toJson(returnMap));
return "success";
......
......@@ -22,7 +22,7 @@ public interface OrderService {
public String getOrderDetail(String salesOrderId,String agentID);
public List<Map<String, Object>> paySuccess(String sOutTradeNO, BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, Date dPayDateTime,String PayTypeID);
public List<Map<String, Object>> paySuccess(String sOutTradeNO, BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, Date dPayDateTime,String PayTypeID,String callBackFilePath);
public String getSubOrderDetail(String subOrderID,String agentID);
......@@ -46,9 +46,9 @@ public interface OrderService {
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,String xmlMsg,String callBackFilePath);
public List<Map<String, Object>> mePayCallback(String req);
public List<Map<String, Object>> mePayCallback(String req,String callBackFilePath);
public List<Map<String, Object>> myBankCallback(String req);
public List<Map<String, Object>> myBankCallback(String req,String callBackFilePath);
}
package com.egolm.shop.api.service.impl;
import java.io.File;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
......@@ -24,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject;
import com.egolm.common.DateUtil;
import com.egolm.common.FileUtil;
import com.egolm.common.GsonUtil;
import com.egolm.common.HttpsUtil;
import com.egolm.common.StringUtil;
......@@ -412,54 +414,63 @@ public class OrderServiceImpl implements OrderService {
@Transactional
public List<Map<String, Object>> paySuccess(String sOutTradeNO, BigDecimal nPayAmount, String sOpenID,
String sTransTraceNO, Date dPayDateTime,String PayTypeID) {
String sTransTraceNO, Date dPayDateTime,String PayTypeID,String callBackFilePath) {
List<Map<String, Object>> returnMap = new ArrayList<Map<String,Object>>();
for(int i =1;i<=3;i++) {
//for(int i =1;i<=3;i++) {
String sql = "exec up_B2BSalesOrderPayCallBack '" + sOutTradeNO + "' ,'" + sTransTraceNO + "' , '" + nPayAmount
+ "' , '" + DateUtil.format(dPayDateTime, DateUtil.FMT_DATE_SECOND) + "' , '" + PayTypeID + "' ,0,'' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
String returnStr = GsonUtil.toJson(returnMap);
logger.info("回调第 "+i+"次,结果:"+returnStr);
logger.info("回调支付单号: "+sOutTradeNO+",结果:"+returnStr);
//需求 #16796
//{"Status":99,"ErrorMsg":"订单:[S2024032620001460] 拆单异常!请联系系统管理员!\nUp_Ego_SplitOrderPayinfo\n订单:[S2024032620001460] 拆单异常!请联系系统管理员!\nUp_Ego_SplitOrderPayinfo\nTransaction (Process ID 72) was deadlocked on lock resources with another process and has been ","IsPush":0,"SalesOrderID":"S2024032620001460"}
if(returnStr.contains("Process")) { //事物锁,重试
this.paySuccess(sOutTradeNO, nPayAmount, sOpenID, sTransTraceNO, dPayDateTime, PayTypeID);
/*if(returnStr.contains("Process")) { //事物锁,重试
this.paySuccess(sOutTradeNO, nPayAmount, sOpenID, sTransTraceNO, dPayDateTime, PayTypeID,callBackFilePath);
}else {
break;
}
}
}*/
//}
this.pushOrderToSdongPo(returnMap);
this.pushOrderToSdongPo(returnMap,sOutTradeNO,PayTypeID,callBackFilePath);
return returnMap;
}
//推送订单到蔬东波
public void pushOrderToSdongPo(List<Map<String, Object>> returnMap) {
public void pushOrderToSdongPo(List<Map<String, Object>> returnMap,String sOutTradeNO,String PayTypeID,String callBackFilePath) {
try {
if(returnMap.size() >0 ) {
Map<String,Object> orderMap = returnMap.get(0);
logger.info("推送蔬东坡-------"+GsonUtil.toJson(orderMap));
logger.info("检查是否要推送蔬东坡-------"+GsonUtil.toJson(orderMap));
String Status = orderMap.get("Status")+"";
String salesOrderID = orderMap.get("SalesOrderID")+"";
String IsPush = orderMap.get("IsPush")+"";
if(IsPush.equals("1") && Status.equals("0")) {
String ssql = "select * FROM tSystemCtrl WHERE sCode = 'OrderToSudongPoUrl' ";
Map<String,Object> setMap = jdbcTemplate.queryForMap(ssql);
String url = setMap.get("sValue1")+"";
if(StringUtil.isNotBlank(url)) {
String result = HttpsUtil.doGet(url+"?salesOrderID="+salesOrderID);
logger.info("推送到蔬东坡的订单 :{},结果:{} ",salesOrderID,result);
}else {
logger.info("推送到蔬东坡的订单地址未配置 ");
if(Status.equals("99")) { //需求 #16796
String ErrorMsg = orderMap.get("ErrorMsg")+"";
String sql = "update tSalesOrderPay set sErrorMsg = ? where sSalesOrderID = ? ";
jdbcTemplate.update(sql, ErrorMsg,salesOrderID);
logger.info("支付对应的订单号:{},支付单号:{} ,已回写错误 信息:{} ",salesOrderID,sOutTradeNO,ErrorMsg);
}else {
if(IsPush.equals("1") && Status.equals("0")) {
String ssql = "select * FROM tSystemCtrl WHERE sCode = 'OrderToSudongPoUrl' ";
Map<String,Object> setMap = jdbcTemplate.queryForMap(ssql);
String url = setMap.get("sValue1")+"";
if(StringUtil.isNotBlank(url)) {
String result = HttpsUtil.doGet(url+"?salesOrderID="+salesOrderID);
logger.info("推送到蔬东坡的订单 :{},结果:{} ",salesOrderID,result);
}else {
logger.info("推送到蔬东坡的订单地址未配置 ");
}
}
}
this.delPayFile(sOutTradeNO, PayTypeID, callBackFilePath);
}
}else {
logger.info("支付单号{},返回的过程处理结果为空 {}-------",sOutTradeNO, GsonUtil.toJson(returnMap));
}
} catch (Exception e) {
logger.info("推送到蔬东坡的订单 异常 ",e);
......@@ -1241,7 +1252,7 @@ public class OrderServiceImpl implements OrderService {
}
// 回调标记已补款
public List<Map<String, Object>> payCallback(WxPayResponse postData) {
public List<Map<String, Object>> payCallback(WxPayResponse postData,String xmlMsg,String callBackFilePath) {
List<Map<String, Object>> returnMap = new ArrayList<Map<String, Object>>();
try {
......@@ -1256,7 +1267,9 @@ public class OrderServiceImpl implements OrderService {
DateUtil.FMT_DATE_SECOND);
logger.info("支付回调单号: {}", OutTradeNO);
returnMap = this.doCallBack(OutTradeNO, TransactionID, PayCardNO, PayAmount, paydate, PayChannel, OpenID);
returnMap = this.doCallBack(OutTradeNO, TransactionID, PayCardNO, PayAmount, paydate, PayChannel, OpenID,callBackFilePath,xmlMsg);
} catch (Exception e) {
logger.info("支付回调异常 ,{} ", e);
......@@ -1265,7 +1278,7 @@ public class OrderServiceImpl implements OrderService {
}
public List<Map<String, Object>> doCallBack(String OutTradeNO, String TransactionID, String PayCardNO,
String PayAmount, String paydate, String PayChannel, String OpenID) {
String PayAmount, String paydate, String PayChannel, String OpenID,String callBackFilePath,String xmlMsg) {
List<Map<String, Object>> returnMap = new ArrayList<Map<String, Object>>();
// 补款后缀是_D,结算单后缀是_S
if (OutTradeNO.contains("_D")) {
......@@ -1278,7 +1291,8 @@ public class OrderServiceImpl implements OrderService {
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),"120");
this.createPayFile(ary[0], PayChannel, callBackFilePath, xmlMsg);
returnMap = this.paySuccess(ary[0], new BigDecimal(PayAmount), OpenID, TransactionID,DateUtil.parse(paydate, DateUtil.FMT_DATE_SECOND),PayChannel,callBackFilePath);
}
return returnMap;
}
......@@ -1288,7 +1302,7 @@ public class OrderServiceImpl implements OrderService {
* @param req
* @return
*/
public List<Map<String, Object>> mePayCallback(String req) {
public List<Map<String, Object>> mePayCallback(String req,String callBackFilePath) {
String PayTypeID = "140"; // 微企付
List<Map<String, Object>> returnMap = new ArrayList<Map<String, Object>>();
JSONObject reqObj = JSONObject.parseObject(req);
......@@ -1344,12 +1358,13 @@ public class OrderServiceImpl implements OrderService {
break;
}
this.createPayFile(out_payment_id, PayTypeID, callBackFilePath, req);
String sql = "exec up_B2BSalesOrderPayCallBack '" + out_payment_id + "' ,'" + payment_id + "' , '"
+ PayAmount + "' , '" + pay_succ_time + "' , '" + PayTypeID + "' , '" + StatusID + "' , '"
+ StatusName + "' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
this.pushOrderToSdongPo(returnMap);
this.pushOrderToSdongPo(returnMap,out_payment_id, PayTypeID, callBackFilePath);
} else if (event_type.equals("refund.succeeded")) { // 退款成功
// up_B2BCancelOrderBizPayCallBack
......@@ -1363,6 +1378,8 @@ public class OrderServiceImpl implements OrderService {
String sql = "exec up_B2BCancelOrderBizPayAsyncCallBack '" + out_payment_id + "' ,'" + payment_id + "','"
+ refund_id + "' , '" + refund_amount + "' , '" + succeeded_time + "' , '" + PayTypeID
+ "' , '0' , '退款成功' ";
this.createPayFile(out_payment_id, PayTypeID, callBackFilePath, req);
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
} else {
logger.info("微企付退款回调-退款状态不成功 ,{} ", req);
......@@ -1374,7 +1391,7 @@ public class OrderServiceImpl implements OrderService {
}
// 网商银行回调
public List<Map<String, Object>> myBankCallback(String req) {
public List<Map<String, Object>> myBankCallback(String req,String callBackFilePath) {
String PayTypeID = "150"; // 网商银行
List<Map<String, Object>> returnMap = new ArrayList<Map<String, Object>>();
JSONObject reqObj = JSONObject.parseObject(req);
......@@ -1396,11 +1413,15 @@ public class OrderServiceImpl implements OrderService {
String OrderNo = reqObj.getString("OrderNo"); // 网商订单号
String TotalAmount = reqObj.getString("TotalAmount"); //
String pay_succ_time = DateUtil.format(new Date(),DateUtil.FMT_DATE_SECOND);
this.createPayFile(OutTradeNo, PayTypeID, callBackFilePath, req);
String sql = "exec up_B2BSalesOrderPayCallBack '" + OutTradeNo + "' ,'" + OrderNo + "' , '"
+ TotalAmount + "' , '" + pay_succ_time + "' , '" + PayTypeID + "' , '1' , '支付成功' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
this.pushOrderToSdongPo(returnMap);
this.pushOrderToSdongPo(returnMap,OutTradeNo, PayTypeID, callBackFilePath);
}
if (from_type.equals("REFUND")) {
String OutRefundNo = reqObj.getString("OutRefundNo"); // 退款交易号
......@@ -1411,7 +1432,8 @@ public class OrderServiceImpl implements OrderService {
DateUtil.FMT_DATE_SECOND); // YYYYMMDDhhmmss
String RefundAmount = reqObj.getString("RefundAmount"); // 退款金额。币种同原 交易
String sql = "exec up_B2BCancelOrderBizPayAsyncCallBack '" + OutRefundNo + "' ,'" + RelateOrderNo + "','"
+ RefundOrderNo + "' , '" + RefundAmount + "' , '" + succeeded_time + "' , '" + PayTypeID
+ "' , '0' , '退款成功' ";
......@@ -1450,7 +1472,26 @@ public class OrderServiceImpl implements OrderService {
}
return map;
}
//创建回调失败数据
private void createPayFile(String OutTradeNO,String PayTypeID,String callBackFilePath,String contexts) {
if(StringUtil.isNotBlank(callBackFilePath)) {
String name = callBackFilePath+OutTradeNO+"_"+PayTypeID+".txt";
FileUtil.stringToFile(name, contexts);
}
}
private void delPayFile(String OutTradeNO,String PayTypeID,String callBackFilePath) {
if(StringUtil.isNotBlank(callBackFilePath)) {
String name = callBackFilePath+OutTradeNO+"_"+PayTypeID+".txt";
if(!FileUtil.isNotExists(name)){
File file = new File(name);
file.delete();
}
}
}
public static void main(String[] args) {
String aa = "20230421121212";
String a1 = DateUtil.format(DateUtil.parse(aa, DateUtil.FMT_YYYYMMddHHMMSS), DateUtil.FMT_DATE_SECOND);
......
......@@ -7,7 +7,7 @@ server.session.timeout=90000
server.tomcat.uri-encoding=utf-8
server.shop.name=shop
server.isSign=true
server.isSign=false
server.md5key=90f49d4bb0216c10816c7dec6bf28c89
spring.http.multipart.maxFileSize=5MB
......@@ -58,7 +58,7 @@ spring.datasource.filters=stat,log4j
#读库
readonly.datasource.username=ERP
readonly.datasource.password=qiyang@2013
readonly.datasource.url=jdbc:sqlserver://10.10.0.22:1433;instanceName=SQLSERVER;DatabaseName=SHOPDB;allowMultiQueries=true
readonly.datasource.url=jdbc:sqlserver://10.10.0.22:1433;instanceName=SQLSERVER;DatabaseName=B2BDB;allowMultiQueries=true
readonly.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
#验证连接的有效性
readonly.datasource.test-while-idle=true
......@@ -138,3 +138,4 @@ qiyewx.msg.redirect.appid=wxa573a87e45933b56
qiyewx.msg.timer=1/5 * * * * ?
pay.callback.path=D:/data/erp/callback/
\ No newline at end of file
......@@ -24,6 +24,8 @@
</head>
<body>
<div id="app">
<el-divider content-position="left">V1.1.7.6 2024-5-6</el-divider>
<p class="title">1.支付回调失败状态为99的,刚写文件,需求 #16796</p>
<el-divider content-position="left">V1.1.7.5 2024-4-23</el-divider>
<p class="title">1.增加接口签名验证及开关</p>
<p class="title">2.需求 #16555、需求 #16563 需求 #16542,需求 #16595</p>
......
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