|
@@ -1,8 +1,14 @@
|
|
|
package com.keao.edu.user.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.keao.edu.common.dal.BaseDAO;
|
|
|
import com.keao.edu.common.exception.BizException;
|
|
|
import com.keao.edu.common.service.impl.BaseServiceImpl;
|
|
|
+import com.keao.edu.thirdparty.adapay.Payment;
|
|
|
+import com.keao.edu.thirdparty.yqpay.Msg;
|
|
|
+import com.keao.edu.thirdparty.yqpay.RsqMsg;
|
|
|
+import com.keao.edu.thirdparty.yqpay.YqPayFeignService;
|
|
|
+import com.keao.edu.thirdparty.yqpay.YqPayUtil;
|
|
|
import com.keao.edu.user.dao.ExamRegistrationPaymentDao;
|
|
|
import com.keao.edu.user.entity.ExamRegistration;
|
|
|
import com.keao.edu.user.entity.ExamRegistrationPayment;
|
|
@@ -13,7 +19,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class ExamRegistrationPaymentServiceImpl extends BaseServiceImpl<Long, ExamRegistrationPayment> implements ExamRegistrationPaymentService {
|
|
@@ -22,6 +29,8 @@ public class ExamRegistrationPaymentServiceImpl extends BaseServiceImpl<Long, Ex
|
|
|
private ExamRegistrationPaymentDao examRegistrationPaymentDao;
|
|
|
@Autowired
|
|
|
private ExamRegistrationService examRegistrationService;
|
|
|
+ @Autowired
|
|
|
+ private YqPayFeignService yqPayFeignService;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, ExamRegistrationPayment> getDAO() {
|
|
@@ -58,4 +67,136 @@ public class ExamRegistrationPaymentServiceImpl extends BaseServiceImpl<Long, Ex
|
|
|
}
|
|
|
return examRegistrationPayment;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void queryOrderStatus() throws Exception {
|
|
|
+ //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 adaPayQuery() throws Exception {
|
|
|
+// List<ExamRegistrationPayment> orders = examRegistrationPaymentDao.getOrdersByStatus("ING", "ADAPAY");
|
|
|
+// if (orders.size() == 0) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<String> orderNoList = new ArrayList<String>();
|
|
|
+//
|
|
|
+// for (ExamRegistrationPayment order : orders) {
|
|
|
+// if (order.getTransNo() == null) {
|
|
|
+// orderNoList.add(order.getOrderNo());
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// Map<String, Object> payment = Payment.queryPayment(order.getTransNo());
|
|
|
+// Map<String, String> rpMap = new HashMap<>();
|
|
|
+// rpMap.put("merOrderNo", order.getOrderNo());
|
|
|
+// rpMap.put("orderNo", (String) payment.get("id"));
|
|
|
+// rpMap.put("channelType", (String) payment.get("pay_channel"));
|
|
|
+// String status = (String) payment.get("status");
|
|
|
+// if (payment.containsKey("error_msg")) {
|
|
|
+// rpMap.put("remarks", (String) payment.get("error_msg"));
|
|
|
+// }
|
|
|
+// if (status.equals("succeeded")) {
|
|
|
+// rpMap.put("tradeState", "1");
|
|
|
+// }
|
|
|
+// if (status.equals("failed")) {
|
|
|
+// rpMap.put("tradeState", "0");
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (rpMap.containsKey("tradeState")) {
|
|
|
+// try {
|
|
|
+// updateOrder(rpMap); //更新订单
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (status.equals("pending")) {
|
|
|
+// orderNoList.add(order.getOrderNo());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// closeOrders(orderNoList);
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// private void closeOrders(List<String> orderNoList) throws Exception {
|
|
|
+// if (orderNoList.size() == 0) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// Calendar beforeTime = Calendar.getInstance();
|
|
|
+// beforeTime.add(Calendar.MINUTE, -30);// 30分钟之前的时间
|
|
|
+// Date beforeDate = beforeTime.getTime();
|
|
|
+//
|
|
|
+// List<StudentPaymentOrder> ordersOverTime = findOrdersOverTime(orderNoList, DealStatusEnum.ING, beforeDate);
|
|
|
+// for (StudentPaymentOrder order : ordersOverTime) {
|
|
|
+// try {
|
|
|
+// order.setStatus(DealStatusEnum.FAILED);
|
|
|
+// order.setMemo("超时未支付关闭");
|
|
|
+// if (order.getType().equals(OrderTypeEnum.APPLY)) { //报名订单
|
|
|
+// studentRegistrationService.updateApplyOrder(order);
|
|
|
+// } else if (order.getType().equals(OrderTypeEnum.SMALL_CLASS_TO_BUY)) {
|
|
|
+// vipGroupService.orderCallback(order);
|
|
|
+// } else if (order.getType().equals(OrderTypeEnum.RENEW)) {
|
|
|
+// musicGroupService.renewForCallback(order);
|
|
|
+// } else if (order.getType().equals(OrderTypeEnum.SPORADIC) || order.getType().equals(OrderTypeEnum.LUCK)) {
|
|
|
+// sporadicChargeInfoService.renewForCallback(order);
|
|
|
+// } else if (order.getType().equals(OrderTypeEnum.PRACTICE_GROUP_BUY) || order.getType().equals(OrderTypeEnum.PRACTICE_GROUP_RENEW)) {
|
|
|
+// practiceGroupService.orderCallback(order);
|
|
|
+// } else if (order.getType().equals(OrderTypeEnum.REPAIR)) {
|
|
|
+// studentRepairService.orderCallback(order);
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
}
|