|  | @@ -21,7 +21,9 @@ import io.swagger.annotations.ApiOperation;
 | 
	
		
			
				|  |  |  import org.apache.commons.lang.StringUtils;
 | 
	
		
			
				|  |  |  import org.slf4j.Logger;
 | 
	
		
			
				|  |  |  import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  | +import org.snaker.engine.core.OrderService;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | +import org.springframework.scheduling.annotation.EnableScheduling;
 | 
	
		
			
				|  |  |  import org.springframework.scheduling.annotation.Scheduled;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  import org.springframework.web.bind.annotation.*;
 | 
	
	
		
			
				|  | @@ -32,6 +34,7 @@ import java.util.*;
 | 
	
		
			
				|  |  |  @RequestMapping("studentOrder")
 | 
	
		
			
				|  |  |  @Api(tags = "订单回调")
 | 
	
		
			
				|  |  |  @RestController
 | 
	
		
			
				|  |  | +@EnableScheduling
 | 
	
		
			
				|  |  |  public class StudentOrderController extends BaseController {
 | 
	
		
			
				|  |  |      private static final Logger logger = LoggerFactory.getLogger(StudentOrderController.class);
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
	
		
			
				|  | @@ -46,45 +49,73 @@ public class StudentOrderController extends BaseController {
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private YqQueryService yqQueryService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    @PostMapping("/notify")
 | 
	
		
			
				|  |  | -    public String notify(@ModelAttribute NotifyMsg notifyMsg) {
 | 
	
		
			
				|  |  | -        //       ArrayList<SysAccount> sysAccounts = new ArrayList<>();
 | 
	
		
			
				|  |  | -//       Map<String,String[]> msg = request.getParameterMap();
 | 
	
		
			
				|  |  | -//        for (Map.Entry<String, String[]> stringObjectEntry : msg.entrySet()) {
 | 
	
		
			
				|  |  | -//            SysAccount sysAccount = new SysAccount();
 | 
	
		
			
				|  |  | -//            String KeyVal = "Key:" + stringObjectEntry.getKey() + " val:" + stringObjectEntry.getValue().toString();
 | 
	
		
			
				|  |  | -//            log.warn(KeyVal);
 | 
	
		
			
				|  |  | -//            sysAccount.setMerNo(stringObjectEntry.getKey());
 | 
	
		
			
				|  |  | -//            sysAccount.setChannel(request.getParameter(stringObjectEntry.getKey()));
 | 
	
		
			
				|  |  | -//            sysAccounts.add(sysAccount);
 | 
	
		
			
				|  |  | +//    @PostMapping("/notify")
 | 
	
		
			
				|  |  | +//    public String notify(@ModelAttribute NotifyMsg notifyMsg) {
 | 
	
		
			
				|  |  | +//        //       ArrayList<SysAccount> sysAccounts = new ArrayList<>();
 | 
	
		
			
				|  |  | +////       Map<String,String[]> msg = request.getParameterMap();
 | 
	
		
			
				|  |  | +////        for (Map.Entry<String, String[]> stringObjectEntry : msg.entrySet()) {
 | 
	
		
			
				|  |  | +////            SysAccount sysAccount = new SysAccount();
 | 
	
		
			
				|  |  | +////            String KeyVal = "Key:" + stringObjectEntry.getKey() + " val:" + stringObjectEntry.getValue().toString();
 | 
	
		
			
				|  |  | +////            log.warn(KeyVal);
 | 
	
		
			
				|  |  | +////            sysAccount.setMerNo(stringObjectEntry.getKey());
 | 
	
		
			
				|  |  | +////            sysAccount.setChannel(request.getParameter(stringObjectEntry.getKey()));
 | 
	
		
			
				|  |  | +////            sysAccounts.add(sysAccount);
 | 
	
		
			
				|  |  | +////        }
 | 
	
		
			
				|  |  | +//        //sysAccountDao.batchInsert(sysAccounts);
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//        // "SUCCESS";
 | 
	
		
			
				|  |  | +//        //
 | 
	
		
			
				|  |  | +//        //不是成功和失败的通知
 | 
	
		
			
				|  |  | +//        if (!notifyMsg.getStatus().equals("TRADE_SUCCESS") && !notifyMsg.getStatus().equals("TRADE_CLOSED")) {
 | 
	
		
			
				|  |  | +//            return "SUCCESS";
 | 
	
		
			
				|  |  |  //        }
 | 
	
		
			
				|  |  | -        //sysAccountDao.batchInsert(sysAccounts);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        // "SUCCESS";
 | 
	
		
			
				|  |  | -        //
 | 
	
		
			
				|  |  | -        //不是成功和失败的通知
 | 
	
		
			
				|  |  | -        if (!notifyMsg.getStatus().equals("TRADE_SUCCESS") && !notifyMsg.getStatus().equals("TRADE_CLOSED")) {
 | 
	
		
			
				|  |  | -            return "SUCCESS";
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        StudentPaymentOrder order = studentPaymentOrderService.findOrderByOrderNo(notifyMsg.getMerOrderId().substring(4));
 | 
	
		
			
				|  |  | -        if (order != null && !order.getStatus().equals(DealStatusEnum.ING)) { //订单状态不是在支付中
 | 
	
		
			
				|  |  | -            return "SUCCESS";
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        DealStatusEnum status = notifyMsg.getStatus().equals("TRADE_SUCCESS") ? DealStatusEnum.SUCCESS : DealStatusEnum.FAilED;
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//        StudentPaymentOrder order = studentPaymentOrderService.findOrderByOrderNo(notifyMsg.getMerOrderId().substring(4));
 | 
	
		
			
				|  |  | +//        if (order != null && !order.getStatus().equals(DealStatusEnum.ING)) { //订单状态不是在支付中
 | 
	
		
			
				|  |  | +//            return "SUCCESS";
 | 
	
		
			
				|  |  | +//        }
 | 
	
		
			
				|  |  | +//        DealStatusEnum status = notifyMsg.getStatus().equals("TRADE_SUCCESS") ? DealStatusEnum.SUCCESS : DealStatusEnum.FAilED;
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//        order.setStatus(status);
 | 
	
		
			
				|  |  | +//        order.setTransNo(notifyMsg.getSeqId());
 | 
	
		
			
				|  |  | +//        order.setPaymentBusinessChannel(notifyMsg.getTargetSys());
 | 
	
		
			
				|  |  | +//        order.setPayTime(notifyMsg.getPayTime());
 | 
	
		
			
				|  |  | +//        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);
 | 
	
		
			
				|  |  | +//        }
 | 
	
		
			
				|  |  | +//        return "SUCCESS";
 | 
	
		
			
				|  |  | +//    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        order.setStatus(status);
 | 
	
		
			
				|  |  | -        order.setTransNo(notifyMsg.getSeqId());
 | 
	
		
			
				|  |  | -        order.setPaymentBusinessChannel(notifyMsg.getTargetSys());
 | 
	
		
			
				|  |  | -        order.setPayTime(notifyMsg.getPayTime());
 | 
	
		
			
				|  |  | -        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);
 | 
	
		
			
				|  |  | +    @PostMapping("/notify")
 | 
	
		
			
				|  |  | +    public Msg notify(@ModelAttribute Msg msg) throws Exception {
 | 
	
		
			
				|  |  | +        logger.info(msg.toString());
 | 
	
		
			
				|  |  | +        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) {
 | 
	
		
			
				|  |  | +            String tradeState = msg.getCode().equals("88") ? "1" : "0";
 | 
	
		
			
				|  |  | +            notifyMap.put("tradeState", tradeState);
 | 
	
		
			
				|  |  | +            notifyMap.put("totalMoney", notifyMap.get("payAmount"));
 | 
	
		
			
				|  |  | +            notifyMap.put("merOrderNo", notifyMap.get("merMerOrderNo"));
 | 
	
		
			
				|  |  | +            this.updateOrder(notifyMap);
 | 
	
		
			
				|  |  | +            msg.setCode("000000");
 | 
	
		
			
				|  |  | +            msg.setMsg("success");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        return "SUCCESS";
 | 
	
		
			
				|  |  | +        return msg;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -109,11 +140,15 @@ public class StudentOrderController extends BaseController {
 | 
	
		
			
				|  |  |  //            return failed("签名验证失败");
 | 
	
		
			
				|  |  |  //        }
 | 
	
		
			
				|  |  |          Payment payment = new Pay().executePayment(amount, orderNo, payChannel, orderSubject, orderBody);
 | 
	
		
			
				|  |  | +        StudentPaymentOrder order = studentPaymentOrderService.findOrderByOrderNo(orderNo);
 | 
	
		
			
				|  |  | +        order.setTransNo(payment.getId());
 | 
	
		
			
				|  |  | +        studentPaymentOrderService.update(order);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          return succeed(payment);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    @Scheduled(cron = "0/5 * * * * ?")
 | 
	
		
			
				|  |  | +    //@Scheduled(cron = "0/5 * * * * ?")
 | 
	
		
			
				|  |  |      public void getOrderStatus() throws Exception {
 | 
	
		
			
				|  |  |          List<StudentPaymentOrder> payingOrders = studentPaymentOrderService.findOrdersByStatus(DealStatusEnum.ING, "YQPAY");
 | 
	
		
			
				|  |  |          String merOrderNos = ""; //
 | 
	
	
		
			
				|  | @@ -134,7 +169,9 @@ public class StudentOrderController extends BaseController {
 | 
	
		
			
				|  |  |          resultMap.put("merOrderNoList", merOrderNos);
 | 
	
		
			
				|  |  |          Map<String, Object> requestMap = YqPayUtil.getRequestMap(notifyUrl, resultMap);
 | 
	
		
			
				|  |  |          Msg queryRs = yqQueryService.orderQuery(requestMap);
 | 
	
		
			
				|  |  | -        logger.info("查询易乾结果" + queryRs.toString());
 | 
	
		
			
				|  |  | +        // = yqQueryService.orderQuery(requestMap);
 | 
	
		
			
				|  |  | +       logger.info("查询易乾结果" +queryRs.toString());
 | 
	
		
			
				|  |  | +       //logger.info("查询易乾结果" + queryRs.toString());
 | 
	
		
			
				|  |  |          if (queryRs.getCode().equals("88")) {
 | 
	
		
			
				|  |  |              //更新订单状态
 | 
	
		
			
				|  |  |              String[] statusArr = {"0", "1", "7"};
 |