Browse Source

Merge branch 'master' of http://git.dayaedu.com/yonge/edu-saas

zouxuan 5 years ago
parent
commit
fb280e7c1f
14 changed files with 349 additions and 99 deletions
  1. 20 19
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/config/ResourceServerConfig.java
  2. 48 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamOrderController.java
  3. 8 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamRegistrationController.java
  4. 8 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamRegistrationPaymentDao.java
  5. 23 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/entity/ExamRegistration.java
  6. 15 3
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/entity/ExamRegistrationPayment.java
  7. 40 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/enums/TransStatusEnum.java
  8. 12 2
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamRegistrationPaymentService.java
  9. 8 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamRegistrationService.java
  10. 23 16
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/NotifyCallback.java
  11. 86 54
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamRegistrationPaymentServiceImpl.java
  12. 44 3
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamRegistrationServiceImpl.java
  13. 8 2
      edu-user/edu-user-server/src/main/resources/config/mybatis/ExamRegistrationMapper.xml
  14. 6 0
      edu-user/edu-user-server/src/main/resources/config/mybatis/ExamRegistrationPaymentMapper.xml

+ 20 - 19
edu-user/edu-user-server/src/main/java/com/keao/edu/user/config/ResourceServerConfig.java

@@ -16,24 +16,25 @@ import com.keao.edu.common.security.BaseAuthenticationEntryPoint;
 @EnableGlobalMethodSecurity(prePostEnabled = true)
 public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
 
-	@Autowired
-	private BaseAccessDeniedHandler baseAccessDeniedHandler;
-
-	@Autowired
-	private BaseAuthenticationEntryPoint baseAuthenticationEntryPoint;
-
-	@Override
-	public void configure(HttpSecurity http) throws Exception {
-		http.authorizeRequests()
-				.antMatchers("/v2/api-docs", "/su/**","/student/apply","/examRegistration/ocr")
-				.permitAll()
-				.anyRequest().authenticated().and().csrf().disable().exceptionHandling().accessDeniedHandler(baseAccessDeniedHandler)
-				.authenticationEntryPoint(baseAuthenticationEntryPoint).and();
-	}
-
-	@Override
-	public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
-		resources.authenticationEntryPoint(baseAuthenticationEntryPoint).accessDeniedHandler(baseAccessDeniedHandler);
-	}
+    @Autowired
+    private BaseAccessDeniedHandler baseAccessDeniedHandler;
+
+    @Autowired
+    private BaseAuthenticationEntryPoint baseAuthenticationEntryPoint;
+
+    @Override
+    public void configure(HttpSecurity http) throws Exception {
+        http.authorizeRequests()
+                .antMatchers("/v2/api-docs", "/su/**", "/student/apply", "/examRegistration/ocr", "/examOrder/paymentResult",
+                        "/examOrder/notify")
+                .permitAll()
+                .anyRequest().authenticated().and().csrf().disable().exceptionHandling().accessDeniedHandler(baseAccessDeniedHandler)
+                .authenticationEntryPoint(baseAuthenticationEntryPoint).and();
+    }
+
+    @Override
+    public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
+        resources.authenticationEntryPoint(baseAuthenticationEntryPoint).accessDeniedHandler(baseAccessDeniedHandler);
+    }
 
 }

+ 48 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamOrderController.java

@@ -7,8 +7,11 @@ import com.keao.edu.common.controller.BaseController;
 import com.keao.edu.common.entity.HttpResponseResult;
 import com.keao.edu.thirdparty.adapay.ConfigInit;
 import com.keao.edu.thirdparty.adapay.Payment;
+import com.keao.edu.thirdparty.yqpay.Msg;
+import com.keao.edu.user.dto.StudentExamPaymentDto;
 import com.keao.edu.user.entity.ExamRegistrationPayment;
 import com.keao.edu.user.entity.ExamSong;
+import com.keao.edu.user.enums.TransStatusEnum;
 import com.keao.edu.user.service.ExamRegistrationPaymentService;
 import com.keao.edu.user.service.ExamRegistrationService;
 import com.keao.edu.util.date.DateUtil;
@@ -122,4 +125,49 @@ public class ExamOrderController extends BaseController {
     }
 
 
+    @ApiOperation(value = "/获取订单状态及订单信息")
+    @GetMapping(value = "/paymentResult")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "orderNo", value = "订单编号", required = true, dataType = "String")})
+    public HttpResponseResult<StudentExamPaymentDto> getExamOrderInfo(String orderNo) {
+        return succeed(examRegistrationPaymentService.getExamOrderInfo(orderNo));
+    }
+
+    @PostMapping("/notify")
+    public Msg notify(@ModelAttribute Msg msg) throws Exception {
+        Map<String, Object> rqMap = new LinkedHashMap<String, Object>();
+        rqMap.put("code", msg.getCode());
+        rqMap.put("msg", msg.getMsg());
+        rqMap.put("responseType", msg.getResponseType());
+        rqMap.put("responseParameters", msg.getResponseParameters());
+        rqMap.put("sign", msg.getSign());
+        //boolean rs = YqPayUtil.verify(rqMap);
+        msg.setMsg("fail");
+        Map<String, String> notifyMap = new HashMap<>();
+        //if (rs) {
+        notifyMap = JSON.parseObject(msg.getResponseParameters(), Map.class);
+        //}
+        //支付中订单存在,更新状态
+        if (msg.getResponseType().equals("1") && notifyMap.size() > 0) {
+            TransStatusEnum status = msg.getCode().equals("88") ? TransStatusEnum.SUCCESS : TransStatusEnum.FAILED;
+            String channelType = notifyMap.get("channelType").equals("1") ? "WXPay" : (notifyMap.get("channelType").equals("2") ? "Alipay" : "quickPay");
+
+            String memo = notifyMap.get("remarks");
+            String orderNo = notifyMap.get("merMerOrderNo");
+            String transNo = notifyMap.get("orderNo");
+
+            notifyMap.put("channelType", channelType);
+            notifyMap.put("memo", memo);
+            notifyMap.put("transStatus", status.getCode());
+            notifyMap.put("orderNo", orderNo);
+            notifyMap.put("transNo", transNo);
+
+            examRegistrationPaymentService.updateOrder(notifyMap);
+            msg.setCode("000000");
+            msg.setMsg("success");
+        }
+        return msg;
+    }
+
+
 }

+ 8 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamRegistrationController.java

@@ -116,4 +116,12 @@ public class ExamRegistrationController extends BaseController {
         return succeed(examRegistrationService.getExamRegistration(examRegistrationId));
     }
 
+    @ApiOperation(value = "重新支付")
+    @PostMapping(value = "repay")
+    @PreAuthorize("@pcs.hasPermissions('examRegistration/add')")
+    public HttpResponseResult repay(@RequestParam String orderNo) throws Exception {
+        SysUser student = sysUserFeignService.queryUserInfo();
+        return succeed(examRegistrationService.repay(student.getId(), orderNo));
+    }
+
 }

+ 8 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamRegistrationPaymentDao.java

@@ -1,6 +1,7 @@
 package com.keao.edu.user.dao;
 
 import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.user.dto.StudentExamPaymentDto;
 import com.keao.edu.user.entity.ExamRegistrationPayment;
 import org.apache.ibatis.annotations.Param;
 
@@ -33,4 +34,11 @@ public interface ExamRegistrationPaymentDao extends BaseDAO<Long, ExamRegistrati
      * @return
      */
     List<ExamRegistrationPayment> getOrdersByStatus(@Param("status") String status, @Param("payType") String payType);
+
+    /**
+     * 获取报名订单信息
+     * @param orderNo
+     * @return
+     */
+    StudentExamPaymentDto getOrderInfo(@Param("orderNo") String orderNo);
 }

+ 23 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/entity/ExamRegistration.java

@@ -56,6 +56,12 @@ public class ExamRegistration {
 	
 	@ApiModelProperty(value = "上次报考证书")
 	private String lastExamCertificateUrl;
+
+	@ApiModelProperty(value = "上次乐理级别")
+	private Integer lastMusicTheoryLevel;
+
+	@ApiModelProperty(value = "上次乐理证书")
+	private String lastMusicTheoryCertificateUrl;
 	
 	@ApiModelProperty(value = "指导老师姓名")
 	private String adviserName;
@@ -283,8 +289,25 @@ public class ExamRegistration {
 		this.theoryLevelFee = theoryLevelFee;
 	}
 
+	public Integer getLastMusicTheoryLevel() {
+		return lastMusicTheoryLevel;
+	}
+
+	public void setLastMusicTheoryLevel(Integer lastMusicTheoryLevel) {
+		this.lastMusicTheoryLevel = lastMusicTheoryLevel;
+	}
+
+	public String getLastMusicTheoryCertificateUrl() {
+		return lastMusicTheoryCertificateUrl;
+	}
+
+	public void setLastMusicTheoryCertificateUrl(String lastMusicTheoryCertificateUrl) {
+		this.lastMusicTheoryCertificateUrl = lastMusicTheoryCertificateUrl;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);
 	}
+
 }

+ 15 - 3
edu-user/edu-user-server/src/main/java/com/keao/edu/user/entity/ExamRegistrationPayment.java

@@ -1,5 +1,6 @@
 package com.keao.edu.user.entity;
 
+import com.keao.edu.user.enums.TransStatusEnum;
 import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
@@ -38,11 +39,14 @@ public class ExamRegistrationPayment {
 	private java.math.BigDecimal transAmount;
 
 	@ApiModelProperty(value = "交易状态")
-	private String transStatus;
+	private TransStatusEnum transStatus;
 
 	@ApiModelProperty(value = "交易成功时间")
 	private java.util.Date transSuccessedTime;
 
+	@ApiModelProperty(value = "备注")
+	private String memo;
+
 	private java.util.Date createTime;
 
 	private java.util.Date updateTime;
@@ -113,11 +117,11 @@ public class ExamRegistrationPayment {
 		return this.transAmount;
 	}
 			
-	public void setTransStatus(String transStatus){
+	public void setTransStatus(TransStatusEnum transStatus){
 		this.transStatus = transStatus;
 	}
 	
-	public String getTransStatus(){
+	public TransStatusEnum getTransStatus(){
 		return this.transStatus;
 	}
 			
@@ -168,6 +172,14 @@ public class ExamRegistrationPayment {
 	public void setPayChannel(String payChannel) {
 		this.payChannel = payChannel;
 	}
+
+	public String getMemo() {
+		return memo;
+	}
+
+	public void setMemo(String memo) {
+		this.memo = memo;
+	}
 			
 	@Override
 	public String toString() {

+ 40 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/enums/TransStatusEnum.java

@@ -0,0 +1,40 @@
+package com.keao.edu.user.enums;
+
+import com.keao.edu.common.enums.BaseEnum;
+
+/**
+ * 支付状态
+ */
+public enum TransStatusEnum implements BaseEnum<String, TransStatusEnum> {
+    ING("ING", "交易中"),
+    SUCCESS("SUCCESS", "交易成功"),
+    FAILED("FAILED", "交易失败"),
+    CLOSE("REFUND", "交易关闭"),
+    REFUND("REFUND", "交易退款");
+
+    private String code;
+
+    private String msg;
+
+    TransStatusEnum(String code, String msg) {
+        this.code = code;
+        this.msg = msg;
+    }
+
+    @Override
+    public String getCode() {
+        return this.code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+}

+ 12 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamRegistrationPaymentService.java

@@ -1,9 +1,11 @@
 package com.keao.edu.user.service;
 
 import com.keao.edu.common.service.BaseService;
+import com.keao.edu.user.dto.StudentExamPaymentDto;
 import com.keao.edu.user.entity.ExamRegistrationPayment;
 
 import java.util.List;
+import java.util.Map;
 
 public interface ExamRegistrationPaymentService extends BaseService<Long, ExamRegistrationPayment> {
 
@@ -24,13 +26,21 @@ public interface ExamRegistrationPaymentService extends BaseService<Long, ExamRe
      */
     ExamRegistrationPayment getByOrderNo(String OrderNo);
 
+
+    /**
+     * 获取订单信息
+     * @param orderNo
+     * @return
+     */
+    StudentExamPaymentDto getExamOrderInfo(String orderNo);
+
     /**
      * 更新订单信息
      *
-     * @param examRegistrationPayment
+     * @param rpMap
      * @return
      */
-    ExamRegistrationPayment updateOrder(ExamRegistrationPayment examRegistrationPayment);
+    ExamRegistrationPayment updateOrder(Map<String,String> rpMap);
 
 
     /**

+ 8 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamRegistrationService.java

@@ -55,4 +55,12 @@ public interface ExamRegistrationService extends BaseService<Long, ExamRegistrat
     * @return
     */
    ExamRegistrationDto getExamRegistration(Integer examRegistrationId);
+
+   /**
+    * 重新支付
+    * @param userId
+    * @param orderNo
+    * @return
+    */
+   Map<String,Object> repay(Integer userId,String orderNo) throws Exception;
 }

+ 23 - 16
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/NotifyCallback.java

@@ -5,11 +5,13 @@ import com.alibaba.fastjson.JSONObject;
 import com.huifu.adapay.notify.MQTTCallbackHandler;
 import com.keao.edu.thirdparty.adapay.ConfigInit;
 import com.keao.edu.user.entity.ExamRegistrationPayment;
+import com.keao.edu.user.enums.TransStatusEnum;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.PostConstruct;
-import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 
 @Service
@@ -41,14 +43,15 @@ public class NotifyCallback implements MQTTCallbackHandler {
         }
         String orderNo = dataObj.getString("order_no");
         ExamRegistrationPayment order = notifyCallback.examRegistrationPaymentService.getByOrderNo(orderNo);
-        if (order == null || !order.getTransStatus().equals("ING")) {
+        if (order == null || !order.getTransStatus().equals(TransStatusEnum.ING)) {
             return;
         }
-        order.setPayChannel(dataObj.getString("pay_channel"));
-        order.setTransStatus("SUCCESS");
-        order.setUpdateTime(new Date());
-        order.setTransSuccessedTime(new Date());
-        notifyCallback.examRegistrationPaymentService.updateOrder(order);
+        Map<String,String> rpMap = new HashMap<>();
+        rpMap.put("channelType", dataObj.getString("pay_channel"));
+        rpMap.put("transStatus","SUCCESS");
+        rpMap.put("orderNo",orderNo);
+        rpMap.put("transNo",order.getTransNo());
+        notifyCallback.examRegistrationPaymentService.updateOrder(rpMap);
     }
 
     /**
@@ -69,10 +72,12 @@ public class NotifyCallback implements MQTTCallbackHandler {
         if (order == null || !order.getTransStatus().equals("ING")) {
             return;
         }
-        order.setPayChannel(dataObj.getString("pay_channel"));
-        order.setTransStatus("FAILED");
-        order.setUpdateTime(new Date());
-        notifyCallback.examRegistrationPaymentService.updateOrder(order);
+        Map<String,String> rpMap = new HashMap<>();
+        rpMap.put("channelType", dataObj.getString("pay_channel"));
+        rpMap.put("transStatus","FAILED");
+        rpMap.put("orderNo",orderNo);
+        rpMap.put("transNo",order.getTransNo());
+        notifyCallback.examRegistrationPaymentService.updateOrder(rpMap);
     }
 
 
@@ -91,13 +96,15 @@ public class NotifyCallback implements MQTTCallbackHandler {
         }
         String orderNo = dataObj.getString("order_no");
         ExamRegistrationPayment order = notifyCallback.examRegistrationPaymentService.getByOrderNo(orderNo);
-        if (order == null || !order.getTransStatus().equals("ING")) {
+        if (order == null || !order.getTransStatus().equals(TransStatusEnum.ING)) {
             return;
         }
-        order.setPayChannel(dataObj.getString("pay_channel"));
-        order.setTransStatus("FAILED");
-        order.setUpdateTime(new Date());
-        notifyCallback.examRegistrationPaymentService.updateOrder(order);
+        Map<String,String> rpMap = new HashMap<>();
+        rpMap.put("channelType", dataObj.getString("pay_channel"));
+        rpMap.put("transStatus","FAILED");
+        rpMap.put("orderNo",orderNo);
+        rpMap.put("transNo",order.getTransNo());
+        notifyCallback.examRegistrationPaymentService.updateOrder(rpMap);
     }
 
     /**

+ 86 - 54
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamRegistrationPaymentServiceImpl.java

@@ -10,9 +10,11 @@ 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.dto.StudentExamPaymentDto;
 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;
@@ -48,77 +50,107 @@ public class ExamRegistrationPaymentServiceImpl extends BaseServiceImpl<Long, Ex
     }
 
     @Override
+    public StudentExamPaymentDto getExamOrderInfo(String orderNo) {
+        return examRegistrationPaymentDao.getOrderInfo(orderNo);
+    }
+
+    @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) {

+ 44 - 3
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamRegistrationServiceImpl.java

@@ -13,6 +13,7 @@ import com.keao.edu.user.dto.ExamRegistrationStatisticsDto;
 import com.keao.edu.user.entity.*;
 import com.keao.edu.user.enums.ExamStatusEnum;
 import com.keao.edu.user.enums.StudentRegistrationStatusEnum;
+import com.keao.edu.user.enums.TransStatusEnum;
 import com.keao.edu.user.page.ExamRecordQueryInfo;
 import com.keao.edu.user.page.ExamRegistrationQueryInfo;
 import com.keao.edu.user.service.ExamRegistrationPaymentService;
@@ -77,17 +78,19 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
         BigDecimal amount = examSubjectSong.getRegistrationFee();
         //乐理考试级别
         ExamMusicTheory examMusicTheory = null;
+        BigDecimal theoryLevelFee = BigDecimal.ZERO;
         if (examRegistration.getExamMusicTheoryId() != null) {
             examMusicTheory = examMusicTheoryDao.get(examRegistration.getExamMusicTheoryId());
         }
         if (examMusicTheory != null) {
+            theoryLevelFee = examMusicTheory.getFee();
             examRegistration.setExamMusicTheoryLevel(examMusicTheory.getLevel());
-            amount.add(examMusicTheory.getFee());
+            amount.add(theoryLevelFee);
         }
 
         examRegistration.setStatus(StudentRegistrationStatusEnum.PAY_WAIT);
         examRegistration.setLevelFee(examSubjectSong.getRegistrationFee());
-        examRegistration.setTheoryLevelFee(examMusicTheory.getFee());
+        examRegistration.setTheoryLevelFee(theoryLevelFee);
         examRegistrationDao.insert(examRegistration);
 
         ExamRegistrationPayment examRegistrationPayment = new ExamRegistrationPayment();
@@ -97,7 +100,7 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
         examRegistrationPayment.setExaminationBasicId(examRegistration.getExaminationBasicId());
         examRegistrationPayment.setOrderNo(orderNo);
         examRegistrationPayment.setTransAmount(amount);
-        examRegistrationPayment.setTransStatus("ING");
+        examRegistrationPayment.setTransStatus(TransStatusEnum.ING);
         examRegistrationPayment.setCreateTime(nowDate);
         examRegistrationPayment.setUpdateTime(nowDate);
         examRegistrationPaymentService.insert(examRegistrationPayment);
@@ -216,4 +219,42 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
     public ExamRegistrationDto getExamRegistration(Integer examRegistrationId) {
         return examRegistrationDao.getExamRegistration(examRegistrationId);
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Map<String, Object> repay(Integer userId, String orderNo) throws Exception {
+        ExamRegistrationPayment order = examRegistrationPaymentService.getByOrderNo(orderNo);
+        if (!order.getTransStatus().equals(TransStatusEnum.ING)) {
+            throw new BizException("订单不是待支付状态,请重新报名");
+        }
+        Date nowDate = new Date();
+        order.setTransStatus(TransStatusEnum.CLOSE);
+        order.setCreateTime(nowDate);
+        order.setUpdateTime(nowDate);
+        examRegistrationPaymentService.update(order);
+
+        orderNo = idGeneratorService.generatorId("payment") + "";
+
+        order.setId(null);
+        order.setOrderNo(orderNo);
+        examRegistrationPaymentService.insert(order);
+
+        ExaminationBasic examinationBasic = examinationBasicDao.get(order.getExaminationBasicId().longValue());
+        if (examinationBasic == null || !examinationBasic.getStatus().equals(ExamStatusEnum.APPLYING)) {
+            throw new BizException("项目不在报名中,请核对");
+        }
+        String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
+        Map<String, Object> payMap = payService.getPayMap(
+                order.getTransAmount(),
+                orderNo,
+                baseApiUrl + "/api-user/examOrder/notify",
+                baseApiUrl + "/api-user/examOrder/paymentResult?orderNo=" + orderNo,
+                examinationBasic.getName(),
+                examinationBasic.getName()
+        );
+        order.setTransNo((String) payMap.get("routingMerNos"));
+        order.setPayType((String) payMap.get("type"));
+        examRegistrationPaymentService.update(order);
+        return payMap;
+    }
 }

+ 8 - 2
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamRegistrationMapper.xml

@@ -43,8 +43,14 @@
 
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.keao.edu.user.entity.ExamRegistration" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		INSERT INTO exam_registration (id_,examination_basic_id_,student_id_,organ_id_,subject_id_,level_,song_json_,last_exam_level_,last_exam_certificate_url_,adviser_name_,adviser_phone_,card_no_,status_,memo_,create_time_,update_time_,tenant_id_)
-		VALUES(#{id},#{examinationBasicId},#{studentId},#{organId},#{subjectId},#{level},#{songJson},#{lastExamLevel},#{lastExamCertificateUrl},#{adviserName},#{adviserPhone},#{cardNo},#{status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{memo},NOW(), NOW(),#{tenantId})
+		INSERT INTO  exam_registration (examination_basic_id_, student_id_, organ_id_,subject_id_, level_, level_fee_,
+		song_json_, last_exam_level_, last_exam_certificate_url_,exam_music_theory_level_, theory_level_fee_,
+		last_music_theory_level_,last_music_theory_certificate_url_, adviser_name_,adviser_phone_, card_no_, status_,
+		create_time_, update_time_, tenant_id_,memo_)
+		VALUES (#{examinationBasicId}, #{studentId}, #{organId}, #{subjectId}, #{level}, #{levelFee}, #{songJson},
+		#{lastExamLevel}, #{lastExamCertificateUrl}, #{examMusicTheoryLevel}, #{theoryLevelFee}, #{lastMusicTheoryLevel},
+		#{lastMusicTheoryCertificateUrl}, #{adviserName}, #{adviserPhone}, #{cardNo}, #{status},#{createTime},
+		#{updateTime}, #{tenantId}, #{memo})
 	</insert>
 
 	<!-- 根据主键查询一条记录 -->

+ 6 - 0
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamRegistrationPaymentMapper.xml

@@ -135,4 +135,10 @@
     <select id="getOrdersByStatus" resultMap="ExamRegistrationPayment">
         SELECT * FROM exam_registration_payment WHERE pay_type_ = #{payType} AND trans_status_ = #{status}
     </select>
+
+    <select id="getOrderInfo" resultMap="com.keao.edu.user.dao.StudentDao.queryApplyListMap">
+        SELECT * FROM exam_registration_payment erp
+        LEFT JOIN exam_registration er ON er.id_ = erp.exam_registration_id_
+        WHERE order_no_ = #{orderNo}
+    </select>
 </mapper>