|
@@ -13,6 +13,7 @@ import com.keao.edu.user.dao.ExamRegistrationPaymentDao;
|
|
|
import com.keao.edu.user.entity.ExamRegistration;
|
|
|
import com.keao.edu.user.entity.ExamRegistrationPayment;
|
|
|
import com.keao.edu.user.enums.StudentRegistrationStatusEnum;
|
|
|
+import com.keao.edu.user.enums.TransStatusEnum;
|
|
|
import com.keao.edu.user.service.ExamRegistrationPaymentService;
|
|
|
import com.keao.edu.user.service.ExamRegistrationService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -49,76 +50,101 @@ public class ExamRegistrationPaymentServiceImpl extends BaseServiceImpl<Long, Ex
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public ExamRegistrationPayment updateOrder(ExamRegistrationPayment examRegistrationPayment) {
|
|
|
- if (examRegistrationPaymentDao.update(examRegistrationPayment) <= 0) {
|
|
|
+ public ExamRegistrationPayment updateOrder(Map<String,String> rpMap) {
|
|
|
+ ExamRegistrationPayment order = examRegistrationPaymentDao.getByOrderNo(rpMap.get("orderNo"));
|
|
|
+ if (order == null || !order.getTransStatus().equals(TransStatusEnum.ING)) {
|
|
|
+ return order;
|
|
|
+ }
|
|
|
+ TransStatusEnum status = rpMap.get("transStatus").equals("SUCCESS") ? TransStatusEnum.SUCCESS : TransStatusEnum.FAILED;
|
|
|
+
|
|
|
+
|
|
|
+ if (status.equals(TransStatusEnum.SUCCESS)) {
|
|
|
+ order.setTransSuccessedTime(new Date());
|
|
|
+ } else {
|
|
|
+ order.setMemo(rpMap.get("memo"));
|
|
|
+ }
|
|
|
+ order.setTransStatus(status);
|
|
|
+ order.setTransNo(rpMap.get("transNo"));
|
|
|
+ order.setPayChannel(rpMap.get("channelType"));
|
|
|
+
|
|
|
+ if (examRegistrationPaymentDao.update(order) <= 0) {
|
|
|
throw new BizException("订单更新失败");
|
|
|
}
|
|
|
- ExamRegistration examRegistration = examRegistrationService.get(examRegistrationPayment.getId());
|
|
|
+ ExamRegistration examRegistration = examRegistrationService.get(order.getExamRegistrationId());
|
|
|
if (!examRegistration.getStatus().equals(StudentRegistrationStatusEnum.PAY_WAIT)) {
|
|
|
- return examRegistrationPayment;
|
|
|
+ return order;
|
|
|
}
|
|
|
- if (!examRegistrationPayment.getTransStatus().equals("SUCCESS")) {
|
|
|
- return examRegistrationPayment;
|
|
|
+ if (!order.getTransStatus().equals(TransStatusEnum.SUCCESS)) {
|
|
|
+ return order;
|
|
|
}
|
|
|
examRegistration.setStatus(StudentRegistrationStatusEnum.AUDIT_WAIT);
|
|
|
examRegistration.setUpdateTime(new Date());
|
|
|
if (examRegistrationService.update(examRegistration) <= 0) {
|
|
|
throw new BizException("报名状态更新失败");
|
|
|
}
|
|
|
- return examRegistrationPayment;
|
|
|
+ return order;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void queryOrderStatus() throws Exception {
|
|
|
- //yqPayQuery();
|
|
|
+ yqPayQuery();
|
|
|
//adaPayQuery();
|
|
|
}
|
|
|
-//
|
|
|
-//
|
|
|
-// private void yqPayQuery() throws Exception {
|
|
|
-// List<ExamRegistrationPayment> orders = examRegistrationPaymentDao.getOrdersByStatus("ING", "YQPAY");
|
|
|
-// if (orders.size() == 0) {
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// List<String> orderNoList = orders.stream().map(ExamRegistrationPayment::getOrderNo).collect(Collectors.toList());
|
|
|
-// String merOrderNos = orders.stream().map(ExamRegistrationPayment::getOrderNo).collect(Collectors.joining(","));
|
|
|
-//
|
|
|
-// String notifyUrl = ""; //回调地址
|
|
|
-// Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
|
-// resultMap.put("merOrderNoList", merOrderNos);
|
|
|
-// Map<String, Object> requestMap = YqPayUtil.getRequestMap(notifyUrl, resultMap);
|
|
|
-//
|
|
|
-// RsqMsg rsqMsg = new RsqMsg(requestMap);
|
|
|
-//
|
|
|
-// Msg queryRs = yqPayFeignService.orderQuery(rsqMsg);
|
|
|
-//
|
|
|
-// if (queryRs.getCode().equals("88")) {
|
|
|
-// //更新订单状态
|
|
|
-// String[] statusArr = {"0", "1", "7"};
|
|
|
-// String responseParameters = queryRs.getResponseParameters();
|
|
|
-// List<Map<String, String>> responseList = JSON.parseObject(responseParameters, List.class);
|
|
|
-// for (Map<String, String> response : responseList) {
|
|
|
-// Map<String, String> rpMap = response;
|
|
|
-// String channelType = rpMap.get("channelType").equals("1") ? "WXPay" : (rpMap.get("channelType").equals("2") ? "Alipay" : "quickPay");
|
|
|
-// rpMap.put("channelType", channelType);
|
|
|
-//
|
|
|
-// if (orderNoList.contains(rpMap.get("merOrderNo"))) {
|
|
|
-// orderNoList.remove(rpMap.get("merOrderNo"));
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (Arrays.asList(statusArr).contains(rpMap.get("tradeState"))) {
|
|
|
-// try {
|
|
|
-// updateOrder(rpMap); //更新订单
|
|
|
-// } catch (Exception e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// closeOrders(orderNoList); //关闭订单
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
+
|
|
|
+
|
|
|
+ private void yqPayQuery() throws Exception {
|
|
|
+ List<ExamRegistrationPayment> orders = examRegistrationPaymentDao.getOrdersByStatus("ING", "YQPAY");
|
|
|
+ if (orders.size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<String> orderNoList = orders.stream().map(ExamRegistrationPayment::getOrderNo).collect(Collectors.toList());
|
|
|
+ String merOrderNos = orders.stream().map(ExamRegistrationPayment::getOrderNo).collect(Collectors.joining(","));
|
|
|
+
|
|
|
+ String notifyUrl = ""; //回调地址
|
|
|
+ Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
|
+ resultMap.put("merOrderNoList", merOrderNos);
|
|
|
+ Map<String, Object> requestMap = YqPayUtil.getRequestMap(notifyUrl, resultMap);
|
|
|
+
|
|
|
+ RsqMsg rsqMsg = new RsqMsg(requestMap);
|
|
|
+
|
|
|
+ Msg queryRs = yqPayFeignService.orderQuery(rsqMsg);
|
|
|
+
|
|
|
+ if (queryRs.getCode().equals("88")) {
|
|
|
+ //更新订单状态
|
|
|
+ String[] statusArr = {"0", "1", "7"};
|
|
|
+ String responseParameters = queryRs.getResponseParameters();
|
|
|
+ List<Map<String, String>> responseList = JSON.parseObject(responseParameters, List.class);
|
|
|
+ for (Map<String, String> response : responseList) {
|
|
|
+ Map<String, String> rpMap = response;
|
|
|
+ String channelType = rpMap.get("channelType").equals("1") ? "WXPay" : (rpMap.get("channelType").equals("2") ? "Alipay" : "quickPay");
|
|
|
+ TransStatusEnum status = rpMap.get("tradeState").equals("1") ? TransStatusEnum.SUCCESS : TransStatusEnum.FAILED;
|
|
|
+ String memo = rpMap.get("remarks");
|
|
|
+ String orderNo = rpMap.get("merOrderNo");
|
|
|
+ String transNo = rpMap.get("orderNo");
|
|
|
+
|
|
|
+ rpMap.put("channelType", channelType);
|
|
|
+ rpMap.put("memo",memo);
|
|
|
+ rpMap.put("transStatus",status.getCode());
|
|
|
+ rpMap.put("orderNo",orderNo);
|
|
|
+ rpMap.put("transNo",transNo);
|
|
|
+
|
|
|
+ if (orderNoList.contains(orderNo)) {
|
|
|
+ orderNoList.remove(orderNo);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Arrays.asList(statusArr).contains(rpMap.get("tradeState"))) {
|
|
|
+ try {
|
|
|
+ updateOrder(rpMap); //更新订单
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //closeOrders(orderNoList); //关闭订单
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// private void adaPayQuery() throws Exception {
|
|
|
// List<ExamRegistrationPayment> orders = examRegistrationPaymentDao.getOrdersByStatus("ING", "ADAPAY");
|
|
|
// if (orders.size() == 0) {
|