|  | @@ -1,14 +1,22 @@
 | 
	
		
			
				|  |  |  package com.yonge.cooleshow.portal.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.common.entity.HttpResponseResult;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.enums.PayChannelEnum;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.enums.PayStatusEnum;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.mbg.mapper.UserOrderPaymentMapper;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.mbg.model.UserOrderPayment;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.portal.service.UserOrderPaymentService;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.sdk.req.OrderCloseReq;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.sdk.res.OrderCloseRes;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.service.PaymentService;
 | 
	
		
			
				|  |  | +import com.yonge.toolset.utils.string.StringUtil;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | +import org.springframework.util.CollectionUtils;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import java.util.Date;
 | 
	
		
			
				|  |  |  import java.util.List;
 | 
	
		
			
				|  |  | +import java.util.Map;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * Description
 | 
	
	
		
			
				|  | @@ -22,6 +30,9 @@ public class UserOrderPaymentServiceImpl implements UserOrderPaymentService {
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private UserOrderPaymentMapper userOrderPaymentMapper;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private PaymentService adapayPaymentService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public UserOrderPayment getByTranNo(String orderNo) {
 | 
	
		
			
				|  |  |          return userOrderPaymentMapper.selectByTranNo(orderNo);
 | 
	
	
		
			
				|  | @@ -51,4 +62,33 @@ public class UserOrderPaymentServiceImpl implements UserOrderPaymentService {
 | 
	
		
			
				|  |  |      public List<UserOrderPayment> getByOrderNo(String orderSn) {
 | 
	
		
			
				|  |  |          return userOrderPaymentMapper.selectByOrderNo(orderSn);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public void closePayment(String orderSn, String message) {
 | 
	
		
			
				|  |  | +        List<UserOrderPayment> userOrderPaymentList = userOrderPaymentMapper.selectByOrderNoAndStatusPaying(orderSn);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isEmpty(userOrderPaymentList))
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        for (UserOrderPayment orderPayment : userOrderPaymentList) {
 | 
	
		
			
				|  |  | +            //更新付款单
 | 
	
		
			
				|  |  | +            orderPayment.setStatus(PayStatusEnum.failed.getCode());
 | 
	
		
			
				|  |  | +            orderPayment.setPayFailMsg(StringUtil.isEmpty(message) ? "交易取消" : message);
 | 
	
		
			
				|  |  | +            orderPayment.setUpdateTime(new Date());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            //发送支付关单请求
 | 
	
		
			
				|  |  | +            if (!StringUtil.isEmpty(orderPayment.getTransNo())) {
 | 
	
		
			
				|  |  | +                OrderCloseReq orderCloseReq = new OrderCloseReq();
 | 
	
		
			
				|  |  | +                orderCloseReq.setPaymentId(orderPayment.getTransNo());
 | 
	
		
			
				|  |  | +                orderCloseReq.setReason(message);
 | 
	
		
			
				|  |  | +                OrderCloseRes closeRes = adapayPaymentService.orderClose(orderCloseReq);
 | 
	
		
			
				|  |  | +                if (!closeRes.isStatus()) {
 | 
	
		
			
				|  |  | +                    orderPayment.setCloseStatus(PayStatusEnum.failed.getCode());
 | 
	
		
			
				|  |  | +                    orderPayment.setCloseFailMsg(closeRes.getFailMsg());
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    orderPayment.setCloseStatus(PayStatusEnum.pending.getCode());
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            userOrderPaymentMapper.updateByPrimaryKeySelective(orderPayment);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |