瀏覽代碼

无车优化,自有车接口返回

Administrator 1 年之前
父節點
當前提交
cce9c5064f

+ 51 - 0
src/main/java/com/jkcredit/invoice/controller/business/SelfCarController.java

@@ -4,10 +4,12 @@ import cn.afterturn.easypoi.excel.ExcelImportUtil;
 import cn.afterturn.easypoi.excel.entity.ImportParams;
 import cn.com.taiji.sdk.model.comm.protocol.tts.invoice.server.B2BInvoiceListModel;
 import cn.com.taiji.sdk.model.comm.protocol.tts.trade.service.CardTradeModel;
+import cn.com.taiji.sdk.model.comm.protocol.tts.trade.service.TradeApplyQueryResponse;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jkcredit.invoice.annotation.LoginRequired;
 import com.jkcredit.invoice.annotation.annotationdes.AuthenticationInterceptor;
+import com.jkcredit.invoice.mapper.binvoce.SelfCarApplMapper;
 import com.jkcredit.invoice.mapper.customer.CustomerCarRecMapper;
 import com.jkcredit.invoice.mapper.customer.CustomerRecMapper;
 import com.jkcredit.invoice.mapper.waybill.SellCarTradeMapper;
@@ -28,6 +30,7 @@ import com.jkcredit.invoice.service.selfcar.SelfCarApplyService;
 import com.jkcredit.invoice.service.selfcar.SelfCarBussService;
 import com.jkcredit.invoice.service.selfcar.SelfCarInvoiceService;
 import com.jkcredit.invoice.service.selfcar.SelfCarTradeService;
+import com.jkcredit.invoice.util.DateUtil;
 import com.jkcredit.invoice.util.RespR;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -514,6 +517,8 @@ public class SelfCarController {
                 RespR<List<B2BInvoiceListModel>> respR = selfCarCustServicel.getSelfCarInvoicesByTime(selfCarDueQueryVo, customerRec1);
                 if (respR.getCode() == 0) {
                     allSelfInvocies.addAll(respR.getData());
+                }else{
+                    throw new RuntimeException(respR.getMsg());
                 }
             });
             return new RespR(allSelfInvocies);
@@ -581,6 +586,52 @@ public class SelfCarController {
             return new RespR(false, e.getMessage());
         }
     }
+    /**
+     * 回复applyId
+     */
+    @GetMapping("/recoverApplyId")
+    public RespR recoverApplyId() {
+        try {
+            List<SelfCarTrade> selfCarTrades = sellCarTradeMapper.sellectAllNullApplid();
+            log.info("开始修复条数{}",selfCarTrades.size());
+            selfCarTrades.forEach(selfCarTrade->{
+                TradeApplyQueryInvVo tradeApplyQueryInvVo = new TradeApplyQueryInvVo();
+                tradeApplyQueryInvVo.setCompanyNum(selfCarTrade.getCompanyNum());
+                tradeApplyQueryInvVo.setTradeId(selfCarTrade.getTradeId());
+                tradeApplyQueryInvVo.setCardId(selfCarTrade.getCardId());
+                RespR<TradeApplyQueryResponse> respR =  selfCarCustService.getApplyQueryByTradeId(tradeApplyQueryInvVo);
+                if(respR.getCode() == 0){
+                    String applyId = respR.getData().getApplyId();
+                    if(!StringUtils.isEmpty(applyId)){
+                        SelfCarAppl selfCarAppl = selfCarApplMapper.selectByApplId(applyId);
+                        if(selfCarAppl != null){
+                            selfCarTrade.setApplId(selfCarAppl.getApplId());
+                            selfCarTrade.setAclTime(DateUtil.tTimeToDate(selfCarAppl.getApplTime()));
+                            log.info("开始修复{}",selfCarTrade);
+                            sellCarTradeMapper.updateByTradeId(selfCarTrade);
+                        }else {
+                            selfCarTrade.setApplId(applyId);
+                            selfCarTrade.setAclTime(DateUtil.tTimeToDate(selfCarAppl.getApplTime()));
+                            log.info("开始修复{}",selfCarTrade);
+                            sellCarTradeMapper.updateByTradeId(selfCarTrade);
+                        }
+
+                    }else{
+                        log.info("修复失败{}",11111111);
+                    }
+                }else {
+                    log.info("修复失败{}",respR.getMsg());
+                }
 
 
+            });
+            log.info("修复完成");
+            return null;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return new RespR(false, e.getMessage());
+        }
+    }
+    @Autowired
+    SelfCarApplMapper selfCarApplMapper;
 }

+ 2 - 1
src/main/java/com/jkcredit/invoice/credit/SimpleCoreFilter.java

@@ -200,7 +200,8 @@ public class SimpleCoreFilter implements Filter {
             "/user/updateUser",
             "/user/page",
             "/user/restPassword",
-            "/user/lock"
+            "/user/lock",
+            "/selfCar/recoverApplyId"
     };
     @Autowired
     CustomerService customerService;

+ 2 - 0
src/main/java/com/jkcredit/invoice/mapper/binvoce/SelfCarApplMapper.java

@@ -37,4 +37,6 @@ public interface SelfCarApplMapper extends BaseMapper<SelfCarAppl> {
      */
     @Override
     int insert(SelfCarAppl record);
+
+    SelfCarAppl selectByApplId(String appId);
 }

+ 5 - 0
src/main/java/com/jkcredit/invoice/mapper/waybill/SellCarTradeMapper.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jkcredit.invoice.model.entity.waybill.SelfCarTrade;
 import com.jkcredit.invoice.model.vo.CompanyVo;
+import com.jkcredit.invoice.service.lowerservice.vo.TradeRequestVo;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
@@ -75,6 +76,7 @@ public interface SellCarTradeMapper extends BaseMapper<SelfCarTrade> {
      * @return
      */
     List<SelfCarTrade> selectByStatus(@Param("status") String status, @Param("company") String company);
+    List<SelfCarTrade> selectNeedGetTrades();
 
     /**
      * 根据公司信息更新自有车交易列表
@@ -82,5 +84,8 @@ public interface SellCarTradeMapper extends BaseMapper<SelfCarTrade> {
      * @return
      */
     int upDateCompany(CompanyVo companyVo);
+    int deletebyEtcAndTime(TradeRequestVo tradeRequestVo);
+    List<SelfCarTrade> sellectAllNullApplid();
 
+    int updatebindStatus(@Param("bindStatus") int bindStatus,@Param("etcCard") String etcCard, @Param("companyNum") String companyNum);
 }

+ 12 - 0
src/main/java/com/jkcredit/invoice/model/entity/waybill/SelfCarTrade.java

@@ -62,6 +62,10 @@ public class SelfCarTrade {
      * 交易状态1-代开票 2-开票中 3-已开票
      */
     private Integer status;
+    /**
+     * 1 - 未解绑 2-解绑 就不再处理
+     */
+    private Integer bindStatus;
 
     /**
      * 申请Id
@@ -270,6 +274,14 @@ public class SelfCarTrade {
         this.tradeIds = tradeIds;
     }
 
+    public Integer getBindStatus() {
+        return bindStatus;
+    }
+
+    public void setBindStatus(Integer bindStatus) {
+        this.bindStatus = bindStatus;
+    }
+
     @Override
     public String toString() {
         return "SelfCarTrade{" +

+ 6 - 0
src/main/java/com/jkcredit/invoice/service/lowerservice/SelfCarCustService.java

@@ -42,6 +42,12 @@ public interface SelfCarCustService {
     RespR<List<B2BInvoiceQueryByApplyModel>> getSelfCarInvoicesByApplyIds(ApplQueryInvVo applQueryInvVo);
 
     /**
+     *  按申请id取发票
+     * @param applQueryInvVo
+     * @return
+     */
+    void getSelfCarInvoicesByApplyIdsDb(ApplQueryInvVo applQueryInvVo);
+    /**
      * 已开发票查询接口
      * @param selfCarDueQueryVo
      * @param customerRec

+ 78 - 22
src/main/java/com/jkcredit/invoice/service/lowerservice/impl/SelfCarCustServiceImpl.java

@@ -99,42 +99,62 @@ public class SelfCarCustServiceImpl implements SelfCarCustService {
         RespR<CardTradeResponse> resp = selfCarInterface.cardTrade(cardTradeRequest);
         if (resp.getCode() == 1) {
             log.info("获取交易失败SelfCarServiceLImpl.getTradeList{},msg{}", tradeRequestVo, resp.getMsg());
+            try{
+                if(tradeRequestVo.getTradeStatus() == 1 && resp.getMsg().contains("该卡号不在该企业下绑定")){
+                    int i = sellCarTradeMapper.deletebyEtcAndTime(tradeRequestVo);
+                    log.info("本次删除条数{},etcId{},reultNum",i,tradeRequestVo.getEtcId(),0);
+                }else{
+                    sellCarTradeMapper.updatebindStatus(2,tradeRequestVo.getEtcId(),customerRec.getCompanyNum());
+                    log.info("{}更新成功bindstatus",tradeRequestVo.getEtcId());
+                }
+            }catch (Exception e){
+                e.printStackTrace();
+                log.error("{}更新失败原因:{}",tradeRequestVo.getEtcId(),e.getMessage());
+            }
+
             return new RespR(false, resp.getMsg());
         } else {
             CardTradeResponse cardTradeResponse = resp.getData();
             List<CardTradeModel> result = cardTradeResponse.getResult();
             //对不存在的tradeId入表
             if (result != null && result.size() > 0) {
-                customerCarRecMapper.selectByEtcForLock(tradeRequestVo.getEtcId());
-                SelfCarTrade selfCarTrade;
-                for (CardTradeModel cardTradeModel : result) {
-                    List<SelfCarTrade> selfCarTrades = sellCarTradeMapper.selectByTradeId(cardTradeModel.getTradeId());
-                    if (selfCarTrades == null || selfCarTrades.size() <= 0) {
-                        selfCarTrade = new SelfCarTrade();
-                        selfCarTrade.setInterType(tradeRequestVo.getInterType());
-                        selfCarTrade.setCustomId(customerRec.getCustomerName());
-                        selfCarTrade.setCompanyName(customerRec.getCompanyName());
-                        selfCarTrade.setCompanyReferencenum(customerRec.getCompanyReferencenum());
-                        selfCarTrade.setCompanyNum(customerRec.getCompanyNum());
-                        selfCarTrade.setCardId(cardTradeModel.getCardId());
-                        selfCarTrade.setTradeId(cardTradeModel.getTradeId());
-                        selfCarTrade.setExTime(DateUtil.tTimeToDate(cardTradeModel.getExTime()));
-                        selfCarTrade.setFee(cardTradeModel.getFee());
-                        selfCarTrade.setStatus(tradeRequestVo.getTradeStatus());
-                        sellCarTradeMapper.insert(selfCarTrade);
-                    } else {
-                        selfCarTrade = selfCarTrades.get(0);
-                        if (!selfCarTrade.getStatus().equals(tradeRequestVo.getTradeStatus())) {
-                            selfCarTrade.setStatus(tradeRequestVo.getTradeStatus());
+                try {
+                    customerCarRecMapper.selectByEtcForLock(tradeRequestVo.getEtcId());
+                    SelfCarTrade selfCarTrade;
+                    for (CardTradeModel cardTradeModel : result) {
+                        List<SelfCarTrade> selfCarTrades = sellCarTradeMapper.selectByTradeId(cardTradeModel.getTradeId());
+                        if (selfCarTrades == null || selfCarTrades.size() <= 0) {
+                            selfCarTrade = new SelfCarTrade();
                             selfCarTrade.setInterType(tradeRequestVo.getInterType());
-                            sellCarTradeMapper.updateByTradeId(selfCarTrade);
+                            selfCarTrade.setCustomId(customerRec.getCustomerName());
+                            selfCarTrade.setCompanyName(customerRec.getCompanyName());
+                            selfCarTrade.setCompanyReferencenum(customerRec.getCompanyReferencenum());
+                            selfCarTrade.setCompanyNum(customerRec.getCompanyNum());
+                            selfCarTrade.setCardId(cardTradeModel.getCardId());
+                            selfCarTrade.setTradeId(cardTradeModel.getTradeId());
+                            selfCarTrade.setExTime(DateUtil.tTimeToDate(cardTradeModel.getExTime()));
+                            selfCarTrade.setFee(cardTradeModel.getFee());
+                            selfCarTrade.setStatus(tradeRequestVo.getTradeStatus());
+                            sellCarTradeMapper.insert(selfCarTrade);
+                        } else {
+                            selfCarTrade = selfCarTrades.get(0);
+                            if (!selfCarTrade.getStatus().equals(tradeRequestVo.getTradeStatus())) {
+                                selfCarTrade.setStatus(tradeRequestVo.getTradeStatus());
+                                selfCarTrade.setInterType(tradeRequestVo.getInterType());
+                                sellCarTradeMapper.updateByTradeId(selfCarTrade);
+                            }
                         }
                     }
+                }catch (Exception e){
+                    e.printStackTrace();
+                    log.error(e.getMessage());
                 }
+
             } else {
                 return new RespR(false, "未查得");
             }
 
+
             return new RespR(result);
 
         }
@@ -256,6 +276,42 @@ public class SelfCarCustServiceImpl implements SelfCarCustService {
     }
 
     @Override
+    public void getSelfCarInvoicesByApplyIdsDb(ApplQueryInvVo applQueryInvVo) {
+        log.info("申请开票开始SelfCarServiceLImpl.getSelfCarInvoicesByApplyIdsDb{}", applQueryInvVo);
+        B2BInvoiceQueryByApplyRequest applyRequest = new B2BInvoiceQueryByApplyRequest();
+        applyRequest.setCardId(applQueryInvVo.getEtcNum());
+        applyRequest.setCompanyNum(applQueryInvVo.getCompanyNum());
+        applyRequest.setApplyId(applQueryInvVo.getApplId());
+        RespR<B2BInvoiceQueryByApplyResponse> responseRespR = selfCarInterface.b2bContractQuery(applyRequest);
+        //返回相应的发票
+        if (responseRespR.getCode() == 1) {
+            log.info("申请开票失败SelfCarServiceLImpl.getSelfCarInvoicesByApplyIdsDb{},msg{}", applQueryInvVo, responseRespR.getMsg());
+        } else {
+            B2BInvoiceQueryByApplyResponse respData = responseRespR.getData();
+            List<B2BInvoiceQueryByApplyModel> dataResult = respData.getResult();
+            if (dataResult != null && dataResult.size() > 0) {
+                for (B2BInvoiceQueryByApplyModel listModel : dataResult) {
+                    SelfCarInvoice selfCarInvoice = new SelfCarInvoice();
+                    BeanUtils.copyProperties(listModel, selfCarInvoice);
+                    selfCarInvoice.setInvoiceMakeTime(DateUtil.tTimeToDate(selfCarInvoice.getInvoiceMakeTime()));
+                    selfCarInvoice.setExTime(DateUtil.tTimeToDate(selfCarInvoice.getExTime()));
+                    selfCarInvoice.setCustomerName(applQueryInvVo.getCustomerName());
+                    selfCarInvoice.setCompanyName(applQueryInvVo.getCompanyName());
+                    selfCarInvoice.setBuyerTaxpayerCode(applQueryInvVo.getCompanyReferencenum());
+                    selfCarInvoice.setBuyerName(applQueryInvVo.getCompanyName());
+                    selfCarInvoice.setCompanyNum(applQueryInvVo.getCompanyNum());
+                    selfCarInvoice.setEnStation(listModel.getEnStationName());
+                    selfCarInvoice.setExStation(listModel.getExStationName());
+                    List<SelfCarInvoice> selfCarInvoice1 = selfCarInvoiceMapper.selectByCodeAndNum(selfCarInvoice);
+                    if (selfCarInvoice1 == null || selfCarInvoice1.size() <= 0) {
+                        selfCarInvoiceMapper.insert(selfCarInvoice);
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
     public RespR<List<B2BInvoiceListModel>> getSelfCarInvoicesByTime(SelfCarDueQueryVo selfCarDueQueryVo, CustomerRec customerRec) {
         log.info("申请开票开始SelfCarServiceLImpl.getSelfCarInvoicesByTime{}", selfCarDueQueryVo);
         B2BInvoiceQueryRequest request = new B2BInvoiceQueryRequest();

+ 10 - 0
src/main/java/com/jkcredit/invoice/service/lowerservice/vo/ApplQueryInvVo.java

@@ -18,6 +18,8 @@ public class ApplQueryInvVo {
 
     private String companyNum;
 
+    private String companyReferencenum;
+
     /**
      * 申请id
      */
@@ -68,6 +70,14 @@ public class ApplQueryInvVo {
         this.companyNum = companyNum;
     }
 
+    public String getCompanyReferencenum() {
+        return companyReferencenum;
+    }
+
+    public void setCompanyReferencenum(String companyReferencenum) {
+        this.companyReferencenum = companyReferencenum;
+    }
+
     @Override
     public String toString() {
         return "ApplQueryInvVo{" +

+ 8 - 0
src/main/java/com/jkcredit/invoice/service/selfcar/SelfCarTradeService.java

@@ -36,4 +36,12 @@ public interface SelfCarTradeService {
      * @return
      */
     boolean updateTrades(List<SelfCarTrade> selfCarTrades);
+
+    /**
+     * 更新交易id状态
+     *
+     * @param selfCarTrades
+     * @return
+     */
+    boolean updateTradesDb(List<SelfCarTrade> selfCarTrades);
 }

+ 27 - 0
src/main/java/com/jkcredit/invoice/service/selfcar/impl/SelfCarTradeServiceImpl.java

@@ -10,6 +10,7 @@ import com.jkcredit.invoice.service.lowerservice.vo.TradeRequestVo;
 import com.jkcredit.invoice.service.selfcar.SelfCarTradeService;
 import com.jkcredit.invoice.util.DateUtil;
 import com.jkcredit.invoice.util.RespR;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -24,6 +25,7 @@ import java.util.Map;
  * @author mumuxigua
  */
 @Service
+@Slf4j
 public class SelfCarTradeServiceImpl extends ServiceImpl<SellCarTradeMapper, SelfCarTrade> implements SelfCarTradeService {
     @Autowired
     SellCarTradeMapper sellCarTradeMapper;
@@ -93,4 +95,29 @@ public class SelfCarTradeServiceImpl extends ServiceImpl<SellCarTradeMapper, Sel
         }
         return true;
     }
+
+    @Override
+    public boolean updateTradesDb(List<SelfCarTrade> selfCarTrades) {
+        selfCarTrades.forEach(selfCarTrade -> {
+            try{
+                if(selfCarTrade.getStatus() ==2){
+                    TradeRequestVo tradeRequestVo;
+                    tradeRequestVo = new TradeRequestVo();
+                    tradeRequestVo.setEtcId(selfCarTrade.getCardId());
+                    tradeRequestVo.setTradeStatus(3);
+                    tradeRequestVo.setStartTime(DateUtil.getDateAfterDays(selfCarTrade.getExTime().split(" ")[0], -1) + " 00:00:00");
+                    tradeRequestVo.setCustomerName(selfCarTrade.getCustomId());
+                    tradeRequestVo.setCompanyName(selfCarTrade.getCompanyName());
+                    tradeRequestVo.setEndTime(DateUtil.getDateAfterDays(selfCarTrade.getExTime().split(" ")[0], 1) + " 00:00:00");
+                    selfCarService.getTradeList(tradeRequestVo);
+                }
+            }catch (Exception e){
+                e.printStackTrace();
+                log.error("{}更新失败{}",selfCarTrade.getCardId(),e.getMessage());
+            }
+
+
+        });
+        return true;
+    }
 }

+ 31 - 37
src/main/java/com/jkcredit/invoice/task/ScheduledBillTask.java

@@ -9,11 +9,13 @@ import com.jkcredit.invoice.model.entity.waybill.NoCarWayBill;
 import com.jkcredit.invoice.model.entity.waybill.SelfCarTrade;
 import com.jkcredit.invoice.service.lowerservice.NoCarService;
 import com.jkcredit.invoice.service.lowerservice.SelfCarCustService;
+import com.jkcredit.invoice.service.lowerservice.vo.ApplQueryInvVo;
 import com.jkcredit.invoice.service.lowerservice.vo.SelfCarDueQueryVo;
 import com.jkcredit.invoice.service.manager.ParamService;
 import com.jkcredit.invoice.service.selfcar.SelfCarTradeService;
 import com.jkcredit.invoice.service.thead.ThreadPoolFactory;
 import com.jkcredit.invoice.util.DateUtil;
+import com.mchange.v1.identicator.IdHashSet;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -22,9 +24,7 @@ import org.springframework.stereotype.Component;
 import java.net.InetAddress;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.concurrent.ExecutorService;
 
 /**
@@ -154,6 +154,7 @@ public class ScheduledBillTask {
      * @Scheduled(cron = "0 0 23 * * ?", zone = "Asia/Shanghai")
      * @throws Exception
      */
+    @Scheduled(cron = "0 55 23 * * ?", zone = "Asia/Shanghai")
     public void getSefCarInvoice() throws Exception {
         InetAddress addr = InetAddress.getLocalHost();
         String ip = paramService.getParamsByParamName("CURR_SELF_IP").getParamValue();
@@ -166,43 +167,36 @@ public class ScheduledBillTask {
             log.info("bengjiqikaipao");
         }
         /**
-         * 1.查询所有的etc卡
-         * 2.按照etc卡号取最近两天的发票
+         * 1.交易id中所有待开票的etc卡号,和当天的开票完成的交易id
+         * 更新交易状态
          */
-        List<CustomerCarRec> lst = customerCarRecMapper.selectAllBindEtcNoGetInvoice();
-
-        lst.stream().forEach(customerCarRec -> {
+        List<SelfCarTrade> lst = sellCarTradeMapper.selectNeedGetTrades();
+        log.info("getSefCarInvoice处理条数{}",lst.size());
+        /**
+         * 开始取票 取票可以通过 申请id 进行取票
+         */
+        Map<String,ApplQueryInvVo> map = new HashMap<>();
+        lst.stream().forEach(selfCarTrade -> {
+            ApplQueryInvVo applQueryInvVo = new ApplQueryInvVo();
+            applQueryInvVo.setCompanyNum(selfCarTrade.getCompanyNum());
+            applQueryInvVo.setEtcNum(selfCarTrade.getCardId());
+            applQueryInvVo.setCompanyName(selfCarTrade.getCompanyName());
+            applQueryInvVo.setCustomerName(selfCarTrade.getCustomId());
+            applQueryInvVo.setCompanyReferencenum(selfCarTrade.getCompanyReferencenum());
+            applQueryInvVo.setApplId(selfCarTrade.getApplId());
+            map.put(selfCarTrade.getApplId(),applQueryInvVo);
+        });
+        for(Map.Entry<String,ApplQueryInvVo> entry:map.entrySet()){
+            ApplQueryInvVo applQueryInvVo  = entry.getValue();
             try {
-                SelfCarDueQueryVo selfCarDueQueryVo = new SelfCarDueQueryVo();
-                selfCarDueQueryVo.setCompanyName(customerCarRec.getCompanyName());
-                selfCarDueQueryVo.setCardId(customerCarRec.getEtcNum());
-                selfCarDueQueryVo.setCustomername(customerCarRec.getCustomerName());
-                DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-                String curr = dateFormat.format(new Date());
-                String befor = DateUtil.getDateAfterDays(curr, -7);
-                String after = DateUtil.getDateAfterDays(curr, +1);
-                selfCarDueQueryVo.setStartTime(befor + " 00:00:00");
-                selfCarDueQueryVo.setEndTime(after + "00:00:00");
-                //查询交易id
-                //根据etc卡查询所有的交易id
-                SelfCarTrade param = new SelfCarTrade();
-                param.setStatus(2);
-                param.setCardId(customerCarRec.getEtcNum());
-                List<SelfCarTrade> selfCarTrades = sellCarTradeMapper.selectByCardIdByStatus(param);
-                selfCarTradeService.updateTrades(selfCarTrades);
-                selfCarService.getSelfCarInvoicesByTime(selfCarDueQueryVo, null);
-            } catch (Exception e) {
+                selfCarService.getSelfCarInvoicesByApplyIdsDb(applQueryInvVo);
+            }catch (Exception e){
                 e.printStackTrace();
-                log.info(customerCarRec.getEtcNum());
+                log.error("{}处理取票失败,失败原因{}",applQueryInvVo.getEtcNum()+"#"+applQueryInvVo.getApplId(),e.getMessage());
             }
-        });
-      /*  try {
-            List<SelfCarAppl> selfCarAppls = selfCarApplMapper.selectAllNoRec();
-            selfCarAppls.forEach(selfCarAppl -> {
-                selfCarService.getSelfCarInvoicesByApplyIds(selfCarAppl);
-            });
-        }catch (Exception e){
-            e.printStackTrace();
-        }*/
+
+        }
+        selfCarTradeService.updateTradesDb(lst);
+        log.info("getSefCarInvoice处理完成");
     }
 }

+ 6 - 0
src/main/resources/mapper/invoice/SelfCarApplMapper.xml

@@ -32,6 +32,12 @@
         <include refid="baseSql" />
         from t_SelfCarAppl;
     </select>
+
+    <select id="selectByApplId" resultMap="BaseResultMap" parameterType="java.lang.String">
+        select
+        <include refid="baseSql" />
+        from t_SelfCarAppl where applId = #{applId,jdbcType=VARCHAR};
+    </select>
     <select id="selectAllNoRec" resultMap="BaseResultMap">
         select
         <include refid="baseSql" />

+ 33 - 3
src/main/resources/mapper/waybill/SellCarTradeMapper.xml

@@ -96,12 +96,12 @@
             applId,
             aclTime,
             companyName,
-            companyReferencenum,interType
+            companyReferencenum,interType,updateTime
         )
         values ( #{customId,jdbcType=VARCHAR}, #{companyNum,jdbcType=VARCHAR},
          #{cardId,jdbcType=VARCHAR}, #{tradeId,jdbcType=VARCHAR}, #{exTime,jdbcType=VARCHAR},
          #{fee,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{applId,jdbcType=VARCHAR},#{aclTime,jdbcType=VARCHAR},
-         #{companyName,jdbcType=VARCHAR},#{companyReferencenum,jdbcType=VARCHAR}, #{interType,jdbcType=INTEGER}
+         #{companyName,jdbcType=VARCHAR},#{companyReferencenum,jdbcType=VARCHAR}, #{interType,jdbcType=INTEGER},now()
         )
     </insert>
     <update id="updateByPrimaryKey" parameterType="com.jkcredit.invoice.model.entity.waybill.SelfCarTrade" >
@@ -133,7 +133,8 @@
         aclTime = #{aclTime,jdbcType=VARCHAR},
         companyName = #{companyName,jdbcType=VARCHAR},
         companyReferencenum = #{companyReferencenum,jdbcType=VARCHAR},
-        interType = #{interType,jdbcType=INTEGER}
+        interType = #{interType,jdbcType=INTEGER},
+        updateTime = now()
         where  tradeId = BINARY #{tradeId,jdbcType=INTEGER}
     </update>
 
@@ -162,8 +163,37 @@
         </if>
 
     </select>
+    <select id="selectNeedGetTrades" resultMap="BaseResultMap">
+        select
+        <include refid="baseSql" />
+        from t_SellCarTrade
+        where  status = 2 and bindStatus=1 and aclTime >'2023-03-16 00:00:00'
+        UNION ALL
+        select
+        <include refid="baseSql" />
+        from t_SellCarTrade
+        where  status = 3 and
+        updateTime >concat(curdate(),' 00:00:00')
+    </select>
     <update id="upDateCompany" parameterType="com.jkcredit.invoice.model.vo.CompanyVo">
         UPDATE t_SellCarTrade set companyName = #{newCompanyName} where companyName = #{oldCompanyName}
     </update>
+    <update id="updatebindStatus" parameterType="java.util.Map">
+        UPDATE t_SellCarTrade set bindStatus = #{bindStatus} where companyNum = #{companyNum} and cardId = #{etcCard}
+    </update>
+
+    <delete id="deletebyEtcAndTime" parameterType="com.jkcredit.invoice.service.lowerservice.vo.TradeRequestVo">
+        delete from t_SellCarTrade  where companyName = #{companyName,jdbcType=VARCHAR}
+        and customId = #{customerName,jdbcType=VARCHAR}
+        and cardId = #{etcId,jdbcType=VARCHAR}
+        and exTime BETWEEN #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
+        and status = #{tradeStatus,jdbcType=INTEGER}
+    </delete>
 
+    <select id="sellectAllNullApplid" resultMap="BaseResultMap">
+        select
+        <include refid="baseSql" />
+        from t_SellCarTrade t
+        where  t.status in(2,3) and  t.aclTime is null and t.id> 1870702
+    </select>
 </mapper>