|
@@ -2,7 +2,10 @@ package com.llisoft.pay.service;
|
|
|
|
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.llisoft.pay.dao.AppDao;
|
|
import com.llisoft.pay.dao.AppDao;
|
|
@@ -10,10 +13,13 @@ import com.llisoft.pay.dao.ItemDao;
|
|
import com.llisoft.pay.dao.OrderDao;
|
|
import com.llisoft.pay.dao.OrderDao;
|
|
import com.llisoft.pay.entity.App;
|
|
import com.llisoft.pay.entity.App;
|
|
import com.llisoft.pay.entity.Order;
|
|
import com.llisoft.pay.entity.Order;
|
|
|
|
+import com.llisoft.pay.util.HttpUtil;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class AppService {
|
|
public class AppService {
|
|
|
|
|
|
|
|
+ private static Logger logger = LoggerFactory.getLogger(AppService.class);
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private AppDao appDao;
|
|
private AppDao appDao;
|
|
@Autowired
|
|
@Autowired
|
|
@@ -37,23 +43,16 @@ public class AppService {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 获取异步通知地址
|
|
|
|
|
|
+ * 发送异步通知
|
|
* @param appId
|
|
* @param appId
|
|
- * @param orderNum
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public String notifyUrl(int appId, String orderNum) {
|
|
|
|
- return packUrl(appDao.select(appId).getNotifyUrl(), orderNum);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取同步通知地址
|
|
|
|
- * @param appId
|
|
|
|
- * @param orderNum
|
|
|
|
- * @return
|
|
|
|
|
|
+ * @param body
|
|
*/
|
|
*/
|
|
- public String returnUrl(int appId, String orderNum) {
|
|
|
|
- return packUrl(appDao.select(appId).getReturnUrl(), orderNum);
|
|
|
|
|
|
+ @Async
|
|
|
|
+ public void notify(int appId, String orderNum, String body) {
|
|
|
|
+ String notifyUrl = this.packUrl(appDao.select(appId).getNotifyUrl(), orderNum);
|
|
|
|
+ logger.debug("异步通知: 请求地址: {}, 参数: {}", notifyUrl, body);
|
|
|
|
+ String result = HttpUtil.postJson(notifyUrl, body);
|
|
|
|
+ logger.debug("异步通知: 返回信息: {}", result);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|