|  | @@ -2,6 +2,7 @@ package com.ym.mec.biz.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
	
		
			
				|  |  | +import com.sun.istack.internal.NotNull;
 | 
	
		
			
				|  |  |  import com.ym.mec.auth.api.client.SysUserFeignService;
 | 
	
		
			
				|  |  |  import com.ym.mec.auth.api.entity.SysUser;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dao.*;
 | 
	
	
		
			
				|  | @@ -308,44 +309,56 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
 | 
	
		
			
				|  |  |              if (DateUtil.minutesBetween(payingOrder.getCreateTime(), date) < 10) {
 | 
	
		
			
				|  |  |                  continue;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            
 | 
	
		
			
				|  |  | -            hfMerchantConfig = payConfigMap.get(payingOrder.getTenantId());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            updateOrderStatus(date, payConfigMap, payingOrder,true);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        closeOrders(orderNoList);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    @Transactional
 | 
	
		
			
				|  |  | +    public Boolean updateOrderStatus(Date date,  Map<Integer, HfMerchantConfig> payConfigMap, StudentPaymentOrder payingOrder, Boolean checkTime) throws Exception {
 | 
	
		
			
				|  |  | +        if (payConfigMap == null) {
 | 
	
		
			
				|  |  | +            throw new BizException("payConfigMap 不能为空");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        HfMerchantConfig hfMerchantConfig;
 | 
	
		
			
				|  |  | +        hfMerchantConfig = payConfigMap.get(payingOrder.getTenantId());
 | 
	
		
			
				|  |  | +        if(hfMerchantConfig == null){
 | 
	
		
			
				|  |  | +            hfMerchantConfig = hfMerchantConfigService.queryByTenantId(payingOrder.getTenantId());
 | 
	
		
			
				|  |  |              if(hfMerchantConfig == null){
 | 
	
		
			
				|  |  | -            	hfMerchantConfig = hfMerchantConfigService.queryByTenantId(payingOrder.getTenantId());
 | 
	
		
			
				|  |  | -                if(hfMerchantConfig == null){
 | 
	
		
			
				|  |  | -                	throw new BizException("机构[{}]汇付商户信息找不到", payingOrder.getTenantId());
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            	payConfigMap.put(payingOrder.getTenantId(), hfMerchantConfig);
 | 
	
		
			
				|  |  | +                throw new BizException("机构[{}]汇付商户信息找不到", payingOrder.getTenantId());
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            
 | 
	
		
			
				|  |  | -            Map<String, Object> payment = Payment.queryPayment(payingOrder.getTransNo(), hfMerchantConfig.getMerKey());
 | 
	
		
			
				|  |  | -            LOGGER.info("订单[{}]交易主动查询接口返回:{}", payingOrder.getTransNo(), payment);
 | 
	
		
			
				|  |  | +            payConfigMap.put(payingOrder.getTenantId(), hfMerchantConfig);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            Map<String, String> rpMap = new HashMap<>();
 | 
	
		
			
				|  |  | -            rpMap.put("merOrderNo", payingOrder.getOrderNo());
 | 
	
		
			
				|  |  | -            rpMap.put("orderNo", payingOrder.getTransNo());
 | 
	
		
			
				|  |  | -            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");
 | 
	
		
			
				|  |  | -            } else if (status.equals("failed") || (DateUtil.minutesBetween(DateUtil.addHours(payingOrder.getUpdateTime(), 2), date) > 0)) {
 | 
	
		
			
				|  |  | -                rpMap.put("tradeState", "0");
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +        Map<String, Object> payment = Payment.queryPayment(payingOrder.getTransNo(), hfMerchantConfig.getMerKey());
 | 
	
		
			
				|  |  | +        LOGGER.info("订单[{}]交易主动查询接口返回:{}", payingOrder.getTransNo(), payment);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            if (status.equals("succeeded") ||
 | 
	
		
			
				|  |  | -                    (status.equals("failed") || payingOrder.getCreateTime().before(DateUtil.addMinutes(new Date(), -35)))) {
 | 
	
		
			
				|  |  | -                try {
 | 
	
		
			
				|  |  | -                    updateOrder(rpMap); //更新订单
 | 
	
		
			
				|  |  | -                } catch (Exception e) {
 | 
	
		
			
				|  |  | -                    e.printStackTrace();
 | 
	
		
			
				|  |  | -                    continue;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | +        Map<String, String> rpMap = new HashMap<>();
 | 
	
		
			
				|  |  | +        rpMap.put("merOrderNo", payingOrder.getOrderNo());
 | 
	
		
			
				|  |  | +        rpMap.put("orderNo", payingOrder.getTransNo());
 | 
	
		
			
				|  |  | +        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");
 | 
	
		
			
				|  |  | +        } else if (status.equals("failed") || !checkTime
 | 
	
		
			
				|  |  | +                || (DateUtil.minutesBetween(DateUtil.addHours(payingOrder.getUpdateTime(), 2),date) > 0)) {
 | 
	
		
			
				|  |  | +            rpMap.put("tradeState", "0");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (status.equals("succeeded") ||
 | 
	
		
			
				|  |  | +                (status.equals("failed") || !checkTime || payingOrder.getCreateTime().before(DateUtil.addMinutes(new Date(), -35)))) {
 | 
	
		
			
				|  |  | +            try {
 | 
	
		
			
				|  |  | +                updateOrder(rpMap); //更新订单
 | 
	
		
			
				|  |  | +            } catch (Exception e) {
 | 
	
		
			
				|  |  | +                e.printStackTrace();
 | 
	
		
			
				|  |  | +                return false;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        closeOrders(orderNoList);
 | 
	
		
			
				|  |  | +        return true;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Transactional(rollbackFor = Exception.class)
 | 
	
	
		
			
				|  | @@ -1023,7 +1036,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
 | 
	
		
			
				|  |  |          Date date = new Date();
 | 
	
		
			
				|  |  |          StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(model.getCouponIdList(), model.getAmount(),false);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        studentPaymentOrder.setGroupType(GroupType.GOODS_SELL);
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setGroupType(GroupType.MALL_SELL);
 | 
	
		
			
				|  |  |          studentPaymentOrder.setUserId(model.getUserId());
 | 
	
		
			
				|  |  |          studentPaymentOrder.setType(OrderTypeEnum.MALL_BUY);
 | 
	
		
			
				|  |  |          studentPaymentOrder.setOrderNo(model.getOrderNo());
 | 
	
	
		
			
				|  | @@ -1047,7 +1060,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
 | 
	
		
			
				|  |  |                  "商品销售",
 | 
	
		
			
				|  |  |                  "商品销售",
 | 
	
		
			
				|  |  |                  student.getOrganId(),
 | 
	
		
			
				|  |  | -                "renew"
 | 
	
		
			
				|  |  | +                "mall_buy"
 | 
	
		
			
				|  |  |          );
 | 
	
		
			
				|  |  |          studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
 | 
	
		
			
				|  |  |          studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
 |