//package com.fs.company.controller.company;
//
//import com.fs.hisStore.domain.FsStorePaymentScrm;
//import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
//import com.fs.huifuPay.domain.HuiFuQueryOrderResult;
//import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayQueryRequest;
//import com.fs.huifuPay.service.HuiFuService;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.StringUtils;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.text.ParseException;
//import java.text.SimpleDateFormat;
//import java.util.Date;
//import java.util.List;
//
///**
// * @author MixLiu
// * @date 2025/12/8 下午4:22)
// */
//
//@RestController
//@RequestMapping("/mixLiu/test")
//@Slf4j
//public class MixLiuTestController {
//
//
//    @Autowired
//    FsStorePaymentScrmMapper fsStorePaymentScrmMapper;
//
//    org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());
//
//    @Autowired
//    HuiFuService huiFuService;
//
//    @GetMapping("/testMix")
//    public void test(){
//        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
//        //查询状态还是待支付的订单
//        List<FsStorePaymentScrm> waitPayOrder = fsStorePaymentScrmMapper.getWatiPayOrder();
//
//        for (FsStorePaymentScrm payItem : waitPayOrder) {
//            if(StringUtils.isBlank(payItem.getTradeNo())){
//                continue;
//            }
//            V2TradePaymentScanpayQueryRequest request = new V2TradePaymentScanpayQueryRequest();
//            request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payItem.getCreateTime()));
//            request.setOrgHfSeqId(payItem.getTradeNo());
////            request.setAppid(fsStorePayment.getAppid());
//            HuiFuQueryOrderResult queryOrderResult = null;
//            try {
//                queryOrderResult = huiFuService.queryOrder(request);
//            } catch (Exception e) {
//                throw new RuntimeException(e);
//            }
//            logger.info("校验汇付返回：" + payItem.getPayCode() + ":" + queryOrderResult);
//            if ("00000000".equals(queryOrderResult.getResp_code())) {
//                //更新支付状态
//                if (queryOrderResult.getTrans_stat().equals("S")) {
//                    logger.info("支付单已支付:" + payItem.getPayCode() + ":" + request);
//                    try {
//                        Date payTime = formatter.parse(queryOrderResult.getEnd_time());
//                        FsStorePaymentScrm payUpdate = new FsStorePaymentScrm();
//                        payUpdate.setPaymentId(payItem.getPaymentId());
//                        payUpdate.setPayTime(payTime);
//                        payUpdate.setStatus(1);
//                        payUpdate.setTradeNo(queryOrderResult.getOrg_hf_seq_id());
//                        payUpdate.setBankSerialNo(queryOrderResult.getParty_order_id());
//                        payUpdate.setBankTransactionId(queryOrderResult.getOut_trans_id());
//                        fsStorePaymentScrmMapper.updateFsStorePayment(payUpdate);
//                        log.info("更新成功 payment:{}",payItem );
//                    } catch (ParseException e) {
//                        log.error("更新失败 payment:{}",payItem ,e);
//                    }
//                }else{
//                    logger.info("支付单未支付:" + payItem.getPayCode() + ":" + request);
//                }
//            }
//        }
//    }
//
//
//}
