Bladeren bron

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

zouxuan 5 jaren geleden
bovenliggende
commit
65e1fc6fed

+ 50 - 0
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/config/PermissionCheckService.java

@@ -0,0 +1,50 @@
+package com.ym.mec.auth.config;
+
+import java.util.Collection;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.stereotype.Component;
+
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.common.security.SecurityUtils;
+
+@Component("pcs")
+public class PermissionCheckService {
+	
+	@Autowired
+	private SysUserFeignService sysUserFeignService;
+
+	public boolean hasPermissions(String... permissions) {
+		Authentication authentication = SecurityUtils.getAuthentication();
+		if (authentication == null) {
+			return false;
+		}
+
+		SysUser user = sysUserFeignService.queryUserInfo();
+		if(user.getIsSuperAdmin()){
+			return true;
+		}
+
+		Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
+
+		for (String perm : permissions) {
+			for (GrantedAuthority authority : authorities) {
+				if (StringUtils.equalsIgnoreCase(perm, authority.getAuthority())) {
+					return true;
+				}
+			}
+		}
+
+		return false;
+	}
+
+	public boolean hasRoles(String... roles) {
+
+		return hasPermissions(roles);
+	}
+
+}

+ 38 - 8
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -101,7 +101,7 @@ public class StudentOrderController extends BaseController {
         msg.setMsg("fail");
         Map<String, String> notifyMap = new HashMap<>();
         //if (rs) {
-            notifyMap = JSON.parseObject(msg.getResponseParameters(), Map.class);
+        notifyMap = JSON.parseObject(msg.getResponseParameters(), Map.class);
         //}
         //支付中订单存在,更新状态
         if (msg.getResponseType().equals("1") && notifyMap.size() > 0) {
@@ -132,8 +132,8 @@ public class StudentOrderController extends BaseController {
 
     @ApiOperation(value = "台牌支付")
     @PostMapping("/executePayment")
-    public Object executePayment(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, String sign) throws Exception {
-        String payChannel = PayChannelEnum.ALIPAY_QR.getCode();
+    public Object executePayment(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, String payChannel, String sign) throws Exception {
+        payChannel = PayChannelEnum.ALIPAY_QR.getCode();
 //        if (!new Pay().verifySign(amount, orderNo, notifyUrl, orderSubject, orderBody,sign)) {
 //            return failed("签名验证失败");
 //        }
@@ -169,10 +169,10 @@ public class StudentOrderController extends BaseController {
 
         RsqMsg rsqMsg = new RsqMsg(requestMap);
 
-       Msg queryRs = yqQueryService.orderQuery(rsqMsg);
+        Msg queryRs = yqQueryService.orderQuery(rsqMsg);
 
-       logger.info("查询易乾结果" +queryRs.toString());
-       //logger.info("查询易乾结果" + queryRs.toString());
+        logger.info("查询易乾结果" + queryRs.toString());
+        //logger.info("查询易乾结果" + queryRs.toString());
         if (queryRs.getCode().equals("88")) {
             //更新订单状态
             String[] statusArr = {"0", "1", "7"};
@@ -200,7 +200,7 @@ public class StudentOrderController extends BaseController {
 
         if (status.equals(DealStatusEnum.SUCCESS)) {
             order.setPayTime(new Date());
-        }else {
+        } else {
             order.setMemo(rpMap.get("remarks"));
         }
         order.setStatus(status);
@@ -226,7 +226,7 @@ public class StudentOrderController extends BaseController {
         beforeTime.add(Calendar.MINUTE, -30);// 30分钟之前的时间
         Date beforeDate = beforeTime.getTime();
 
-        List<StudentPaymentOrder> ordersOverTime = studentPaymentOrderService.findOrdersOverTime(orderNoList,DealStatusEnum.ING,beforeDate);
+        List<StudentPaymentOrder> ordersOverTime = studentPaymentOrderService.findOrdersOverTime(orderNoList, DealStatusEnum.ING, beforeDate);
         for (StudentPaymentOrder order : ordersOverTime) {
             order.setStatus(DealStatusEnum.FAilED);
             order.setMemo("超时未支付关闭");
@@ -241,5 +241,35 @@ public class StudentOrderController extends BaseController {
 
     }
 
+    @Scheduled(cron = "0/5 * * * * ?")
+    public void adaPayQuery() throws Exception {
+        List<StudentPaymentOrder> payingOrders = studentPaymentOrderService.findOrdersByStatus(DealStatusEnum.ING, "ADAPAY");
+
+        List<String> orderNoList = new ArrayList<String>();
+
+        for (StudentPaymentOrder payingOrder : payingOrders) {
+            if (payingOrder.getTransNo() == null) {
+                orderNoList.add(payingOrder.getOrderNo());
+                continue;
+            }
+            Payment payment = new Pay().queryPayment(payingOrder.getTransNo());
+            Map<String, String> rpMap = new HashMap<>();
+            rpMap.put("merOrderNo", payingOrder.getOrderNo());
+            rpMap.put("remarks", payment.getReason());
+            rpMap.put("orderNo", payment.getId());
+            rpMap.put("channelType", payment.getPayChannel());
+            if (payment.getStatus().equals("succeeded")) {
+                rpMap.put("tradeState", "1");
+            }
+            if (payment.getStatus().equals("failed")) {
+                rpMap.put("tradeState", "0");
+            }
+            if (payment.getStatus().equals("pending")) {
+                orderNoList.add(payingOrder.getOrderNo());
+            }
+        }
+        closeOrders(orderNoList);
+    }
+
 
 }

+ 32 - 42
mec-student/src/main/java/com/ym/mec/student/controller/SysMessageController.java

@@ -4,6 +4,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
 import java.io.IOException;
+import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -78,51 +79,40 @@ public class SysMessageController extends BaseController {
 		if (sysUser == null) {
 			return failed(HttpStatus.FORBIDDEN, "请登录");
 		}
-		return succeed(sysMessageService.queryCountOfUnread(MessageSendMode.PUSH, sysUser.getId()));
-	}
-
-	/*@ApiOperation(value = "发送短信验证码")
-	@PostMapping("/sendSmsCode")
-	public Object sendSmsCode(String sendCodeType, String mobileNo) {
-
-		SysUser sysUser;
+		Map<String, Integer> map = sysMessageService.queryCountOfUnread(MessageSendMode.PUSH, sysUser.getId());
 
-		if (StringUtils.isBlank(mobileNo)) {
-			sysUser = sysUserFeignService.queryUserInfo();
-		} else {
-			sysUser = sysUserFeignService.queryUserByMobile(mobileNo);
-		}
-		if (sysUser == null) {
-			return failed(HttpStatus.FORBIDDEN, "请登录");
+		if (map == null || map.size() == 0) {
+			return succeed();
 		}
-		Integer userId = sysUser.getId();
-
-		mobileNo = sysUser.getPhone();
+		return succeed(map);
+	}
 
-		MessageType messageType = MessageType.getMessageType(sendCodeType);
-		if (messageType == null) {
-			throw new BizException("消息类型参数错误");
-		}
-		if (StringUtils.isBlank(mobileNo) || !CommonValidator.isMobileNo(mobileNo)) {
-			throw new BizException("请输入正确的手机号");
-		}
-		sysMessageService.sendSecurityCode(MessageSender.YIMEI, userId, MessageSendMode.SMS, messageType, mobileNo);
-		return succeed();
-	}*/
-
-	/*@ApiOperation(value = "发送短信验证码")
-	@PostMapping("/noAuth/sendSmsCode")
-	public Object noAuthSendSmsCode(String sendCodeType, String mobileNo) {
-		MessageType messageType = MessageType.getMessageType(sendCodeType);
-		if (messageType == null) {
-			throw new BizException("消息类型参数错误");
-		}
-		if (StringUtils.isBlank(mobileNo) || !CommonValidator.isMobileNo(mobileNo)) {
-			throw new BizException("请输入正确的手机号");
-		}
-//		sysMessageService.sendSecurityCode(MessageSender.YIMEI, userId, MessageSendMode.SMS, messageType, mobileNo);
-		return succeed();
-	}*/
+	/*
+	 * @ApiOperation(value = "发送短信验证码")
+	 * 
+	 * @PostMapping("/sendSmsCode") public Object sendSmsCode(String sendCodeType, String mobileNo) {
+	 * 
+	 * SysUser sysUser;
+	 * 
+	 * if (StringUtils.isBlank(mobileNo)) { sysUser = sysUserFeignService.queryUserInfo(); } else { sysUser =
+	 * sysUserFeignService.queryUserByMobile(mobileNo); } if (sysUser == null) { return failed(HttpStatus.FORBIDDEN, "请登录"); } Integer userId =
+	 * sysUser.getId();
+	 * 
+	 * mobileNo = sysUser.getPhone();
+	 * 
+	 * MessageType messageType = MessageType.getMessageType(sendCodeType); if (messageType == null) { throw new BizException("消息类型参数错误"); } if
+	 * (StringUtils.isBlank(mobileNo) || !CommonValidator.isMobileNo(mobileNo)) { throw new BizException("请输入正确的手机号"); }
+	 * sysMessageService.sendSecurityCode(MessageSender.YIMEI, userId, MessageSendMode.SMS, messageType, mobileNo); return succeed(); }
+	 */
+
+	/*
+	 * @ApiOperation(value = "发送短信验证码")
+	 * 
+	 * @PostMapping("/noAuth/sendSmsCode") public Object noAuthSendSmsCode(String sendCodeType, String mobileNo) { MessageType messageType =
+	 * MessageType.getMessageType(sendCodeType); if (messageType == null) { throw new BizException("消息类型参数错误"); } if (StringUtils.isBlank(mobileNo) ||
+	 * !CommonValidator.isMobileNo(mobileNo)) { throw new BizException("请输入正确的手机号"); } // sysMessageService.sendSecurityCode(MessageSender.YIMEI,
+	 * userId, MessageSendMode.SMS, messageType, mobileNo); return succeed(); }
+	 */
 
 	@ApiOperation(value = "发送消息")
 	@PostMapping("/sendMessage")

+ 7 - 1
mec-teacher/src/main/java/com/ym/mec/teacher/controller/SysMessageController.java

@@ -4,6 +4,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
 import java.io.IOException;
+import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -78,7 +79,12 @@ public class SysMessageController extends BaseController {
 		if (sysUser == null) {
 			return failed("请重新登录");
 		}
-		return succeed(sysMessageService.queryCountOfUnread(MessageSendMode.PUSH, sysUser.getId()));
+		Map<String, Integer> map = sysMessageService.queryCountOfUnread(MessageSendMode.PUSH, sysUser.getId());
+
+		if (map == null || map.size() == 0) {
+			return succeed();
+		}
+		return succeed(map);
 	}
 /*
 	@ApiOperation(value = "发送短信验证码")