Преглед изворни кода

add 订单状态查询接口

周箭河 пре 5 година
родитељ
комит
0f8f5ed49d

+ 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","/examOrder/paymentResult")
-				.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);
+    }
 
 }

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

@@ -7,9 +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;
@@ -131,4 +133,41 @@ public class ExamOrderController extends BaseController {
         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;
+    }
+
+
 }