|  | @@ -1,7 +1,7 @@
 | 
	
		
			
				|  |  |  package com.fs.store.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.math.BigDecimal;
 | 
	
		
			
				|  |  | -import java.util.Collections;
 | 
	
		
			
				|  |  | +import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  |  import java.util.Date;
 | 
	
		
			
				|  |  |  import java.util.List;
 | 
	
		
			
				|  |  |  import java.util.Map;
 | 
	
	
		
			
				|  | @@ -18,7 +18,10 @@ import com.fs.common.utils.DateUtils;
 | 
	
		
			
				|  |  |  import com.fs.company.domain.CompanyUser;
 | 
	
		
			
				|  |  |  import com.fs.company.service.ICompanyService;
 | 
	
		
			
				|  |  |  import com.fs.company.service.ICompanyUserService;
 | 
	
		
			
				|  |  | +import com.fs.huifuPay.domain.HuiFuQueryOrderResult;
 | 
	
		
			
				|  |  |  import com.fs.huifuPay.dto.*;
 | 
	
		
			
				|  |  | +import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayQueryRequest;
 | 
	
		
			
				|  |  | +import com.fs.huifuPay.service.HuiFuService;
 | 
	
		
			
				|  |  |  import com.fs.pay.pay.util.PayUtil;
 | 
	
		
			
				|  |  |  import com.fs.store.domain.*;
 | 
	
		
			
				|  |  |  import com.fs.store.service.IFsStoreOrderService;
 | 
	
	
		
			
				|  | @@ -316,10 +319,44 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService
 | 
	
		
			
				|  |  |      public void paymentSync() {
 | 
	
		
			
				|  |  |          List<FsStorePayment> fsStorePayments = fsStorePaymentMapper.queryPendingDelayState();
 | 
	
		
			
				|  |  |          for (FsStorePayment fsStorePayment : fsStorePayments) {
 | 
	
		
			
				|  |  | -            queryYb(fsStorePayment);
 | 
	
		
			
				|  |  | +            try{
 | 
	
		
			
				|  |  | +                queryHf(fsStorePayment);
 | 
	
		
			
				|  |  | +            }catch (Exception e){
 | 
	
		
			
				|  |  | +                logger.error("同步支付状态异常,订单号: {}",fsStorePayment.getOrderId(),e);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private HuiFuService huiFuService;
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public boolean queryHf(FsStorePayment fsStorePayment) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        V2TradePaymentScanpayQueryRequest request = new V2TradePaymentScanpayQueryRequest();
 | 
	
		
			
				|  |  | +        request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(fsStorePayment.getCreateTime()));
 | 
	
		
			
				|  |  | +        request.setOrgHfSeqId(fsStorePayment.getTradeNo());
 | 
	
		
			
				|  |  | +        HuiFuQueryOrderResult huiFuQueryOrderResult;
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            huiFuQueryOrderResult = huiFuService.queryOrder(request);
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            throw new RuntimeException(e);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        logger.info("汇付返回"+huiFuQueryOrderResult);
 | 
	
		
			
				|  |  | +        if ("00000000".equals(huiFuQueryOrderResult.getResp_code())) {
 | 
	
		
			
				|  |  | +            if (huiFuQueryOrderResult.getTrans_stat().equals("S")) {
 | 
	
		
			
				|  |  | +                // 如果查询支付成功 更新订单状态
 | 
	
		
			
				|  |  | +                String bankTrxId = huiFuQueryOrderResult.getOut_trans_id();
 | 
	
		
			
				|  |  | +                String bankOrderId = huiFuQueryOrderResult.getParty_order_id();
 | 
	
		
			
				|  |  | +                orderService.payConfirm(1,fsStorePayment.getOrderId(), fsStorePayment.getPayCode(),
 | 
	
		
			
				|  |  | +                        fsStorePayment.getTradeNo(),bankTrxId, bankOrderId);
 | 
	
		
			
				|  |  | +                return true;
 | 
	
		
			
				|  |  | +            } else if(huiFuQueryOrderResult.getTrans_stat().equals("F")){
 | 
	
		
			
				|  |  | +                fsStorePayment.setStatus(-2);
 | 
	
		
			
				|  |  | +                this.updateFsStorePayment(fsStorePayment);
 | 
	
		
			
				|  |  | +                return false;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return false;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      @Async
 | 
	
		
			
				|  |  |      public void delayQueryTzbk(FsStorePayment fsStorePayment){
 |