Browse Source

后端代码提交

mashengyi 3 years ago
parent
commit
abcf4aedd7
17 changed files with 469 additions and 118 deletions
  1. 1 1
      src/main/java/com/jkcredit/invoice/controller/localBussiness/NoCarController.java
  2. 133 0
      src/main/java/com/jkcredit/invoice/controller/localBussiness/SelfCarController.java
  3. 24 2
      src/main/java/com/jkcredit/invoice/controller/service/SelfCarServiceController.java
  4. 2 0
      src/main/java/com/jkcredit/invoice/mapper/customer/CustomerCarRecMapper.java
  5. 11 1
      src/main/java/com/jkcredit/invoice/service/lowerService/SelfCarServiceL.java
  6. 106 103
      src/main/java/com/jkcredit/invoice/service/lowerService/impl/SelfCarServiceLImpl.java
  7. 1 0
      src/main/java/com/jkcredit/invoice/service/lowerService/vo/EtcBindVo.java
  8. 14 5
      src/main/java/com/jkcredit/invoice/service/lowerService/vo/EtcQueryVo.java
  9. 42 0
      src/main/java/com/jkcredit/invoice/service/lowerService/vo/InvoicePackageVo.java
  10. 49 0
      src/main/java/com/jkcredit/invoice/service/lowerService/vo/SelfcarInvoiceByTimeVo.java
  11. 58 0
      src/main/java/com/jkcredit/invoice/service/lowerService/vo/TradeRequestCarNumVo.java
  12. 3 0
      src/main/java/com/jkcredit/invoice/service/lowerService/vo/TradeRequestVo.java
  13. 5 0
      src/main/java/com/jkcredit/invoice/service/selfCar/SelfCarService.java
  14. 5 0
      src/main/java/com/jkcredit/invoice/service/selfCar/impl/SelfCarServiceImpl.java
  15. 10 1
      src/main/resources/mapper/customer/CustomerCarRecMapper.xml
  16. 3 3
      src/main/resources/mapper/customer/CustomerRecMapper.xml
  17. 2 2
      src/main/resources/mapper/invoice/SelfCarInvoiceMapper.xml

+ 1 - 1
src/main/java/com/jkcredit/invoice/controller/localBussiness/NoCarController.java

@@ -51,7 +51,7 @@ public class NoCarController {
      * @return 用户集合
      */
     @PostMapping("/findCarRec")
-    @ApiOperation(value="分页查询无车备案信息", notes="分页查询无车备案信息")
+    @ApiOperation(value="分页查询无车/自有车备案信息", notes="分页查询无车/自有车备案信息")
     @LoginRequired
     public RespR getCustomersByPage(Page page, CustomerCarRec customerCarRec) {
         try {

+ 133 - 0
src/main/java/com/jkcredit/invoice/controller/localBussiness/SelfCarController.java

@@ -1,24 +1,37 @@
 package com.jkcredit.invoice.controller.localBussiness;
+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 com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jkcredit.invoice.annotation.LoginRequired;
 import com.jkcredit.invoice.model.entity.Calculate.NoCarCalculateInfor;
 import com.jkcredit.invoice.model.entity.Calculate.SelfCarCalculateInfor;
+import com.jkcredit.invoice.model.entity.customer.CustomerCarRec;
 import com.jkcredit.invoice.model.entity.invoice.SelfCarInvoice;
 import com.jkcredit.invoice.model.entity.waybill.NoCarWayBill;
 import com.jkcredit.invoice.model.entity.waybill.SelfCarTrade;
 import com.jkcredit.invoice.service.CalculateInfor.SelfCarCalculateInfoService;
+import com.jkcredit.invoice.service.lowerService.SelfCarServiceL;
+import com.jkcredit.invoice.service.lowerService.vo.*;
 import com.jkcredit.invoice.service.selfCar.SelfCarInvoiceService;
 import com.jkcredit.invoice.service.selfCar.SelfCarService;
 import com.jkcredit.invoice.service.selfCar.SelfCarTradeService;
+import com.jkcredit.invoice.service.upService.SelfCarInterface;
 import com.jkcredit.invoice.util.RespR;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
 @Api(tags = "自有车操作")
 @RestController
 @RequestMapping(value = {"/selfCar"})
@@ -26,6 +39,8 @@ public class SelfCarController {
     @Autowired
     SelfCarService selfCarService;
     @Autowired
+    SelfCarServiceL selfCarServicel;
+    @Autowired
     SelfCarTradeService selfCarTradeService;
     @Autowired
     SelfCarInvoiceService selfCarInvoiceService;
@@ -150,5 +165,123 @@ public class SelfCarController {
             return new RespR(false,e.getMessage());
         }
     }
+    /**
+     * @param tradeRequestCarNumVo
+     * @return
+     */
+    @PostMapping("/getTradeList")
+    @ApiOperation(value="获取需要开票的交易Id列表", notes="获取需要开票的交易Id列表")
+    @LoginRequired
+    public RespR getTradeList(@RequestBody TradeRequestCarNumVo tradeRequestCarNumVo){
+        //通过车牌号查询所有的Etc卡号
+        List<CustomerCarRec> customerCarRecs = selfCarService.getEtcsByCarNum(tradeRequestCarNumVo.getCarNum());
+        if(customerCarRecs == null || customerCarRecs.size()<=0){
+            return new RespR(false,"请输入有绑定ETC卡号的车牌");
+        }
+        //合并展示
+        List<CardTradeModel> cardTradeModels = new ArrayList<>();
+        customerCarRecs.forEach(customerCarRec -> {
+            TradeRequestVo tradeRequestVo = new TradeRequestVo();
+            tradeRequestVo.setCompanyName(tradeRequestCarNumVo.getCompanyName());
+            tradeRequestVo.setCustomerName(tradeRequestCarNumVo.getCustomerName());
+            DateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:MM:ss");
+            tradeRequestVo.setStartTime(format.format(new Date(Long.parseLong(tradeRequestCarNumVo.getStartTime()))));
+            tradeRequestVo.setEndTime(format.format(new Date(Long.parseLong(tradeRequestCarNumVo.getEndTime()))));
+            tradeRequestVo.setTradeStatus(1);
+            tradeRequestVo.setEtcId(customerCarRec.getEtcNum());
+            RespR<List<CardTradeModel>> respRbefore = selfCarServicel.getTradeList(tradeRequestVo);
+            if(respRbefore.getCode() == 0){
+                cardTradeModels.addAll(respRbefore.getData());
+            }
+        });
+        return new RespR(cardTradeModels);
+    }
+    /**
+     * @param tradeRequestCarNumVo
+     * @return
+     */
+    @PostMapping("/applTradeList")
+    @ApiOperation(value="根据车牌号进行开票操作", notes="根据车牌号进行开票操作")
+    @LoginRequired
+    public RespR applTradeList(@RequestBody TradeRequestCarNumVo tradeRequestCarNumVo){
+        //通过车牌号查询所有的Etc卡号
+        List<CustomerCarRec> customerCarRecs = selfCarService.getEtcsByCarNum(tradeRequestCarNumVo.getCarNum());
+        if(customerCarRecs == null || customerCarRecs.size()<=0){
+            return new RespR(false,"请输入有绑定ETC卡号的车牌");
+        }
+        StringBuffer stringBuffer = new StringBuffer();
+        customerCarRecs.forEach(customerCarRec -> {
+            TradeRequestVo tradeRequestVo = new TradeRequestVo();
+            tradeRequestVo.setCompanyName(tradeRequestCarNumVo.getCompanyName());
+            tradeRequestVo.setCustomerName(tradeRequestCarNumVo.getCustomerName());
+            DateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:MM:ss");
+            tradeRequestVo.setStartTime(format.format(new Date(Long.parseLong(tradeRequestCarNumVo.getStartTime()))));
+            tradeRequestVo.setEndTime(format.format(new Date(Long.parseLong(tradeRequestCarNumVo.getEndTime()))));
+            tradeRequestVo.setTradeStatus(1);
+            tradeRequestVo.setEtcId(customerCarRec.getEtcNum());
+            RespR<List<CardTradeModel>> respRbefore = selfCarServicel.getTradeList(tradeRequestVo);
+            if(respRbefore.getCode() == 0){
+                if(respRbefore.getData()!=null && respRbefore.getData().size()>0){
+                    //进行开票申请
+                    InvoiceApplVo invoiceApplVo = new InvoiceApplVo();
+                    invoiceApplVo.setCompanyName(tradeRequestCarNumVo.getCompanyName());
+                    invoiceApplVo.setCustomerName(tradeRequestCarNumVo.getCustomerName());
+                    invoiceApplVo.setCardId(customerCarRec.getEtcNum());
+                    invoiceApplVo.setTradeIds(new ArrayList<String>());
+                    respRbefore.getData().forEach(cardTradeModel -> {
+                        invoiceApplVo.getTradeIds().add(cardTradeModel.getTradeId());
+                    });
+                    RespR respR = selfCarServicel.applInvoice(invoiceApplVo);
+                    if(respR.getCode() == 1){
+                        stringBuffer.append(customerCarRec.getEtcNum()+"开票申请失败原因:"+respRbefore.getMsg()+"#");
+                    }
+
+                }
+            }else {
+                stringBuffer.append(customerCarRec.getEtcNum()+"开票申请失败原因:"+respRbefore.getMsg()+"#");
+            }
+        });
+        if(StringUtils.isEmpty(stringBuffer.toString())){
+            return new RespR(true);
+        }else{
+            return new RespR(false,stringBuffer.toString());
+        }
+
+    }
+    /**
+     * 查询已经开票信息
+     *
+     * @param
+     * @return
+     */
+    @PostMapping("/findSelfcarInvoiceByTime")
+    @ApiOperation(value="通过时间,车牌号查询开票信息", notes="通过时间,车牌号查询开票信息")
+    @LoginRequired
+    public RespR findSelfcarInvoiceByTime(@RequestBody  SelfcarInvoiceByTimeVo selfcarInvoiceByTimeVo) {
+        try {
+            //通过车牌号查询所有的Etc卡号
+            List<CustomerCarRec> customerCarRecs = selfCarService.getEtcsByCarNum(selfcarInvoiceByTimeVo.getCarNum());
+            if(customerCarRecs == null || customerCarRecs.size()<=0){
+                return new RespR(false,"请输入有绑定ETC卡号的车牌");
+            }
+            List<B2BInvoiceListModel>  allSelfInvocies = new ArrayList<>();
+            customerCarRecs.forEach(customerCarRec -> {
+                SelfCarDueQueryVo selfCarDueQueryVo = new SelfCarDueQueryVo();
+                selfCarDueQueryVo.setCustomername(selfcarInvoiceByTimeVo.getCustomerName());
+                selfCarDueQueryVo.setCompanyName(selfcarInvoiceByTimeVo.getCompanyName());
+                selfCarDueQueryVo.setStartTime(selfcarInvoiceByTimeVo.getStartTime());
+                selfCarDueQueryVo.setEndTime(selfcarInvoiceByTimeVo.getEndTime());
+                selfCarDueQueryVo.setCardId(customerCarRec.getEtcNum());
+                RespR<List<B2BInvoiceListModel>> respR = selfCarServicel.getSelfCarInvoicesByTime(selfCarDueQueryVo);
+                if(respR.getCode() == 0){
+                    allSelfInvocies.addAll(respR.getData());
+                }
+            });
+           return new RespR(allSelfInvocies);
+        }catch (Exception e){
+            e.printStackTrace();
+            return new RespR(false,e.getMessage());
+        }
+    }
 
 }

+ 24 - 2
src/main/java/com/jkcredit/invoice/controller/service/SelfCarServiceController.java

@@ -76,7 +76,16 @@ public class SelfCarServiceController {
     public RespR getSelfCarInvoicesByTime(@RequestBody SelfCarDueQueryVo selfCarDueQueryVo){
         return selfCarService.getSelfCarInvoicesByTime(selfCarDueQueryVo);
     }
-
+    /**
+     * @param invoicePackageVo
+     * @return
+     */
+    @PostMapping("/getSelfCarInvoicePackage")
+    @ApiOperation(value="发票打包下载", notes="发票打包下载")
+    //@LoginRequired
+    public RespR getSelfCarInvoicePackage(@RequestBody InvoicePackageVo invoicePackageVo){
+        return selfCarService.getInvoicePackge(invoicePackageVo);
+    }
     /**
      * @param ApplQueryInvVo
      * @return
@@ -92,11 +101,24 @@ public class SelfCarServiceController {
      * @return
      */
     @PostMapping("/customerETCQuery")
-    @ApiOperation(value="", notes="ETC查询")
+    @ApiOperation(value="", notes="ETC绑定列表查询")
     //@LoginRequired
     public RespR customerETCQuery(@RequestBody EtcQueryVo etcQueryVo){
         return selfCarService.getEtcInfo(etcQueryVo);
     }
+
+
+
+    /**
+     * @param etcBindVo
+     * @return
+     */
+    @PostMapping("/queryEtcInfo")
+    @ApiOperation(value="", notes="备案ETC查询")
+    public RespR customerQueryEtcInfo(@RequestBody EtcBindVo etcBindVo){
+        return selfCarService.queryEtcInfo(etcBindVo);
+    }
+
     /**
      * @param etcBindVo
      * @return

+ 2 - 0
src/main/java/com/jkcredit/invoice/mapper/customer/CustomerCarRecMapper.java

@@ -21,6 +21,8 @@ public interface CustomerCarRecMapper extends BaseMapper<CustomerCarRec> {
 
     CustomerCarRec selectByETC(String etcNum);
     CustomerCarRec selectByCarNum(String carNum);
+    List<CustomerCarRec> selectBySelfCarNum(String carNum);
+
     int updateByPrimaryKeySelective(CustomerCarRec record);
 
     int updateByPrimaryKey(CustomerCarRec record);

+ 11 - 1
src/main/java/com/jkcredit/invoice/service/lowerService/SelfCarServiceL.java

@@ -1,6 +1,9 @@
 package com.jkcredit.invoice.service.lowerService;
 
+import cn.com.taiji.sdk.model.comm.protocol.tts.invoice.server.B2BInvoiceListModel;
+import cn.com.taiji.sdk.model.comm.protocol.tts.invoice.server.B2bInvoicePackageModel;
 import cn.com.taiji.sdk.model.comm.protocol.tts.trade.service.CardTradeModel;
+import com.jkcredit.invoice.model.entity.B2bInvoicePackage;
 import com.jkcredit.invoice.model.entity.customer.CustomerCarRec;
 import com.jkcredit.invoice.model.entity.invoice.SelfCarAppl;
 import com.jkcredit.invoice.model.entity.invoice.SelfCarInvoice;
@@ -37,8 +40,9 @@ public interface SelfCarServiceL {
     /**
      *已开发票查询接口
      */
-    RespR<List<SelfCarInvoice>> getSelfCarInvoicesByTime(SelfCarDueQueryVo selfCarDueQueryVo);
+    RespR<List<B2BInvoiceListModel>> getSelfCarInvoicesByTime(SelfCarDueQueryVo selfCarDueQueryVo);
 
+    RespR<List<B2bInvoicePackageModel>>  getInvoicePackge(InvoicePackageVo invoicePackageVo);
     /**
      * 根据车牌获取ETC卡信息
      * @param etcQueryVo
@@ -47,6 +51,12 @@ public interface SelfCarServiceL {
     RespR getEtcInfo(EtcQueryVo etcQueryVo);
 
     /**
+     * etc备案查询
+     * @param etcBindVo
+     * @return
+     */
+    RespR queryEtcInfo(EtcBindVo etcBindVo);
+    /**
      * ETC备案
      * @param
      * @return

+ 106 - 103
src/main/java/com/jkcredit/invoice/service/lowerService/impl/SelfCarServiceLImpl.java

@@ -13,6 +13,7 @@ import com.jkcredit.invoice.mapper.customer.CustomerCarRecMapper;
 import com.jkcredit.invoice.mapper.customer.CustomerMapper;
 import com.jkcredit.invoice.mapper.customer.CustomerRecMapper;
 import com.jkcredit.invoice.mapper.waybill.SellCarTradeMapper;
+import com.jkcredit.invoice.model.entity.B2bInvoicePackage;
 import com.jkcredit.invoice.model.entity.Calculate.SelfCarCalculateInfor;
 import com.jkcredit.invoice.model.entity.customer.Customer;
 import com.jkcredit.invoice.model.entity.customer.CustomerCarRec;
@@ -163,13 +164,26 @@ public class SelfCarServiceLImpl implements SelfCarServiceL {
             selfCarApplMapper.insert(selfCarAppl);
 
             //更新交易id申请开票时间,并将转态改为开票中
-            tradeIds.forEach(tradeId->{
+            for(String tradeId : tradeIds){
                 SelfCarTrade selfCarTrade =  sellCarTradeMapper.selectByTradeId(tradeId);
                 selfCarTrade.setStatus(2);
                 selfCarTrade.setAclTime(DateUtil.getCurrentDateStr());
                 selfCarTrade.setApplId(b2BInvoiceApplyResponse.getApplyId());
                 sellCarTradeMapper.updateByTradeId(selfCarTrade);
-            });
+                //计费
+                SelfCarCalculateInfor carCalculateInfor = new SelfCarCalculateInfor();
+                carCalculateInfor.setCustomId(customerRec.getCustomerName());
+                carCalculateInfor.setCompanyNum(customerRec.getCompanyNum());
+                carCalculateInfor.setCalTime(StringUtils.substring(selfCarTrade.getExTime(),0,7));
+                carCalculateInfor.setFee(customer.getFee());
+                carCalculateInfor.setCompanyReferencenum(customerRec.getCompanyReferencenum());
+                carCalculateInfor.setEtcNum(selfCarTrade.getCardId());
+                if(calculateInforMapper.selectByEtcAndTime(carCalculateInfor) == null){
+                    customer.setAccountBalance(MathUtil.sub(customer.getAccountBalance(),carCalculateInfor.getFee()));
+                    customerMapper.updateByPrimaryKeySelective(customer);
+                    calculateInforMapper.insert(carCalculateInfor);
+                }
+            }
             //SelfCarTrade selfCarTrade =  sellCarTradeMapper.selectByTradeId(cardTradeModel.getTradeId());
             return new RespR<>(b2BInvoiceApplyResponse.getApplyId());
         }
@@ -177,7 +191,6 @@ public class SelfCarServiceLImpl implements SelfCarServiceL {
     }
 
     @Override
-    @Transactional
     public RespR<List<SelfCarInvoice>> getSelfCarInvoicesByApplyIds(ApplQueryInvVo applQueryInvVo) {
         B2BInvoiceQueryByApplyRequest b2BInvoiceQueryRequest = new B2BInvoiceQueryByApplyRequest();
         Customer customer = customerMapper.selectByCustomerName(applQueryInvVo.getCustomerName());
@@ -210,20 +223,12 @@ public class SelfCarServiceLImpl implements SelfCarServiceL {
                 selfCarInvoice.setExTime(DateUtil.tTimeToDate(selfCarInvoice.getExTime()));
                 if(selfCarInvoiceMapper.selectByTradeAndInvoiceMakeTime(selfCarInvoice)==null || selfCarInvoiceMapper.selectByTradeAndInvoiceMakeTime(selfCarInvoice).size()==0){
                     selfCarInvoiceMapper.insert(selfCarInvoice);
+                    //更新为开票完成
+                    SelfCarTrade selfCarTrade =  sellCarTradeMapper.selectByTradeId(selfCarInvoice.getTradeId());
+                    selfCarTrade.setStatus(3);
+                    sellCarTradeMapper.updateByTradeId(selfCarTrade);
                 }
-                //计费
-                SelfCarCalculateInfor carCalculateInfor = new SelfCarCalculateInfor();
-                carCalculateInfor.setCustomId(customerRec.getCustomerName());
-                carCalculateInfor.setCompanyNum(customerRec.getCompanyNum());
-                carCalculateInfor.setCalTime(StringUtils.substring(b2BInvoiceQueryByApplyModel.getExTime(),0,7));
-                carCalculateInfor.setFee(customer.getFee());
-                carCalculateInfor.setCompanyReferencenum(customerRec.getCompanyReferencenum());
-                carCalculateInfor.setEtcNum(b2BInvoiceQueryByApplyModel.getCardId());
-                if(calculateInforMapper.selectByEtcAndTime(carCalculateInfor) == null){
-                    customer.setAccountBalance(MathUtil.sub(customer.getAccountBalance(),carCalculateInfor.getFee()));
-                    customerMapper.updateByPrimaryKeySelective(customer);
-                    calculateInforMapper.insert(carCalculateInfor);
-                }
+
             }
             //返回相应的发票
             return new RespR(b2BInvoiceQueryByApplyModels);
@@ -231,7 +236,7 @@ public class SelfCarServiceLImpl implements SelfCarServiceL {
     }
 
     @Override
-    public RespR<List<SelfCarInvoice>> getSelfCarInvoicesByTime(SelfCarDueQueryVo selfCarDueQueryVo) {
+    public RespR<List<B2BInvoiceListModel>> getSelfCarInvoicesByTime(SelfCarDueQueryVo selfCarDueQueryVo) {
         Customer customer = customerMapper.selectByCustomerName(selfCarDueQueryVo.getCustomername());
         if(customer == null || customer.getAccstatus().intValue() == 1){
             return new RespR(false,"客户已经停用");
@@ -259,7 +264,6 @@ public class SelfCarServiceLImpl implements SelfCarServiceL {
         }else{
             B2BInvoiceQueryResponse b2BInvoiceQueryResponse = responseRespR.getData();
             List<B2BInvoiceListModel> b2BInvoiceListModels = b2BInvoiceQueryResponse.getResult();
-            List<SelfCarInvoice> selfCarInvoices = new ArrayList<>();
             if(b2BInvoiceListModels!=null && b2BInvoiceListModels.size()>0){
                 for(B2BInvoiceListModel b2BInvoiceListModel:b2BInvoiceListModels){
                     SelfCarInvoice selfCarInvoice = new SelfCarInvoice();
@@ -268,22 +272,11 @@ public class SelfCarServiceLImpl implements SelfCarServiceL {
                     selfCarInvoice.setExTime(DateUtil.dateFormate(selfCarInvoice.getExTime()));
                     if(selfCarInvoiceMapper.selectByTradeAndInvoiceMakeTime(selfCarInvoice)==null || selfCarInvoiceMapper.selectByTradeAndInvoiceMakeTime(selfCarInvoice).size()==0){
                         selfCarInvoiceMapper.insert(selfCarInvoice);
+                        //更新为开票完成
+                        SelfCarTrade selfCarTrade =  sellCarTradeMapper.selectByTradeId(selfCarInvoice.getTradeId());
+                        selfCarTrade.setStatus(3);
+                        sellCarTradeMapper.updateByTradeId(selfCarTrade);
                     }
-
-                    //计费
-                    SelfCarCalculateInfor carCalculateInfor = new SelfCarCalculateInfor();
-                    carCalculateInfor.setCustomId(customerRec.getCustomerName());
-                    carCalculateInfor.setCompanyNum(customerRec.getCompanyNum());
-                    carCalculateInfor.setCalTime(StringUtils.substring(b2BInvoiceListModel.getExTime(),0,7));
-                    carCalculateInfor.setFee(customer.getFee());
-                    carCalculateInfor.setEtcNum(b2BInvoiceListModel.getCardId());
-                    carCalculateInfor.setCompanyReferencenum(customerRec.getCompanyReferencenum());
-                    if(calculateInforMapper.selectByEtcAndTime(carCalculateInfor) == null){
-                        customer.setAccountBalance(MathUtil.sub(customer.getAccountBalance(),carCalculateInfor.getFee()));
-                        customerMapper.updateByPrimaryKeySelective(customer);
-                        calculateInforMapper.insert(carCalculateInfor);
-                    }
-                    selfCarInvoices.add(selfCarInvoice);
                 }
             }
             return new RespR(b2BInvoiceListModels);
@@ -291,10 +284,32 @@ public class SelfCarServiceLImpl implements SelfCarServiceL {
     }
 
     @Override
-    public RespR getEtcInfo(EtcQueryVo etcQueryVo) {
-        if(etcQueryVo.getCarList()==null || etcQueryVo.getCarList().size()<=0){
-            return new RespR(false,"车辆信息为空");
+    public RespR<List<B2bInvoicePackageModel>> getInvoicePackge(InvoicePackageVo invoicePackageVo) {
+        Customer customer = customerMapper.selectByCustomerName(invoicePackageVo.getCustomerName());
+        if(customer == null || customer.getAccstatus().intValue() == 1){
+            return new RespR(false,"客户已经停用");
+        }
+        CustomerRec customerRec = new CustomerRec();
+        customerRec.setCustomerName(invoicePackageVo.getCustomerName());
+        customerRec.setCompanyName(invoicePackageVo.getCompanyName());
+        customerRec = customerRecMapper.selectByCustomerNameAndCompany(customerRec);
+        if(customerRec == null || customerRec.getRecStatus().intValue() !=1 ){
+            return new RespR(false,"客户未备案");
+        }
+
+        B2bInvoicePackageRequest b2bInvoicePackageRequest = new B2bInvoicePackageRequest();
+        b2bInvoicePackageRequest.setCompanyNum(customerRec.getCompanyNum());
+        b2bInvoicePackageRequest.setMakeMonth(invoicePackageVo.getMonth());
+        RespR<B2bInvoicePackageResponse> b2bInvoicePackageResponseRespR = selfCarInterface.b2bInvoicePackage(b2bInvoicePackageRequest);
+        if(b2bInvoicePackageResponseRespR.getCode() == 1){
+            return new RespR(false,b2bInvoicePackageResponseRespR.getMsg());
+        }else{
+            return new RespR(b2bInvoicePackageResponseRespR.getData().getResult());
         }
+    }
+
+    @Override
+    public RespR getEtcInfo(EtcQueryVo etcQueryVo) {
         Customer customer = customerMapper.selectByCustomerName(etcQueryVo.getCustomerName());
         if(customer == null || customer.getAccstatus().intValue() == 1){
             return new RespR(false,"客户已经停用");
@@ -306,10 +321,37 @@ public class SelfCarServiceLImpl implements SelfCarServiceL {
         if(customerRec == null || customerRec.getRecStatus().intValue() !=1 ){
             return new RespR(false,"客户未备案");
         }
+        CardBindQueryListToBRequest cardQueryCardToBRequest = new CardBindQueryListToBRequest();
+        cardQueryCardToBRequest.setCompanyNum(customerRec.getCompanyNum());
+        cardQueryCardToBRequest.setPlateNum(etcQueryVo.getPlateNum());
+        RespR<CardBindQueryListToBResponse> respR = selfCarInterface.cardBindQueryListToB(cardQueryCardToBRequest);
+        if(respR.getCode() == 1){
+            return new RespR(false,respR.getMsg());
+        }
+        return new RespR(respR.getData().getResult());
+    }
+    public RespR queryEtcInfo(EtcBindVo etcBindVo){
+        StringBuffer res = new StringBuffer();
+        if(etcBindVo== null || etcBindVo.getCards() ==null || etcBindVo.getCards().size()<=0){
+            return new RespR(false,"无备案Etc");
+        }
+        Customer customer = customerMapper.selectByCustomerName(etcBindVo.getCustomerName());
+        if(customer == null || customer.getAccstatus()!=0){
+            res.append("#客户:"+etcBindVo.getCustomerName()+"不存在或状态异常");
+            return new RespR(false,res.toString());
+        }
+        CustomerRec customerRecP = new CustomerRec();
+        customerRecP.setCustomerName(etcBindVo.getCustomerName());
+        customerRecP.setCompanyName(etcBindVo.getCompanyName());
+        CustomerRec customerRec = customerRecMapper.selectByCustomerNameAndCompany(customerRecP);
+        if(customerRec == null || customerRec.getRecStatus()!=1){
+            res.append("#客户:"+etcBindVo.getCustomerName()+"企业:"+etcBindVo.getCompanyName()+"请先备案");
+            return new RespR(false,res.toString());
+        }
         CardQueryCardToBRequest cardQueryCardToBRequest = new CardQueryCardToBRequest();
         cardQueryCardToBRequest.setCompanyNum(customerRec.getCompanyNum());
         List<CardQueryCardToBModel> cardQueryCardToBModels = new ArrayList<>();
-        etcQueryVo.getCarList().forEach(carVo -> {
+        etcBindVo.getCards().forEach(carVo -> {
             CardQueryCardToBModel cardQueryCardToBModel = new CardQueryCardToBModel();
             cardQueryCardToBModel.setPlateNum(carVo.getNum());
             cardQueryCardToBModel.setPlateColor(carVo.getColor());
@@ -320,9 +362,12 @@ public class SelfCarServiceLImpl implements SelfCarServiceL {
         if(respR.getCode() == 1){
             return new RespR(false,respR.getMsg());
         }
+        if(respR.getData().getResult() == null){
+            return new RespR(false,"没有etc卡");
+        }
         return new RespR(respR.getData().getResult());
-    }
 
+    }
     @Override
     public RespR customerEtcRec(EtcBindVo etcBindVo) {
         if(etcBindVo== null || etcBindVo.getCards() ==null || etcBindVo.getCards().size()<=0){
@@ -347,65 +392,20 @@ public class SelfCarServiceLImpl implements SelfCarServiceL {
     public RespR recEtc(EtcBindVo etcBindVo,CustomerRec customerRec){
         CardQueryCardToBRequest cardQueryCardToBRequest = new CardQueryCardToBRequest();
         cardQueryCardToBRequest.setCompanyNum(customerRec.getCompanyNum());
-        List<CardQueryCardToBModel> cardQueryCardToBModels = new ArrayList<>();
-        etcBindVo.getCards().forEach(carVo -> {
-            CardQueryCardToBModel cardQueryCardToBModel = new CardQueryCardToBModel();
-            cardQueryCardToBModel.setPlateNum(carVo.getNum());
-            cardQueryCardToBModel.setPlateColor(carVo.getColor());
-            cardQueryCardToBModels.add(cardQueryCardToBModel);
-        });
-        cardQueryCardToBRequest.setVehicleList(cardQueryCardToBModels);
-        RespR<CardQueryCardToBResponse> respR = selfCarInterface.cardQueryCardToB(cardQueryCardToBRequest);
-        if(respR.getCode() == 1){
-            return new RespR(false,respR.getMsg());
-        }
-        if(respR.getData().getResult() == null){
-            return new RespR("成功");
-        }
-        List<CustomerCarRec> customerCarRecs = new ArrayList<>();
         List<CardBindingToBModel> cardBindingToBModels = new ArrayList<>();
-        for(int i=0;i<respR.getData().getResult().size();i++){
-            CardQueryCardResultToBModel cardQueryCardResultToBModel = respR.getData().getResult().get(i);
-            CarVo carVo = etcBindVo.getCards().get(i);
-            CustomerCarRec customerCarRec = new CustomerCarRec();
-            customerCarRec.setBusinessType(CommonConstants.BUSSINESS_TYPE_SELFCAR);
-            customerCarRec.setCompanyName(customerRec.getCompanyName());
-            customerCarRec.setCustomerName(customerRec.getCustomerName());
-            customerCarRec.setCompanyNum(customerRec.getCompanyNum());
-            customerCarRec.setCustPhone(etcBindVo.getMobile());
-            customerCarRec.setRecStatus(CommonConstants.REC_STATUS_WAIT);
-            customerCarRec.setCarNum(carVo.getNum());
-            customerCarRec.setEtcNum(carVo.getEtcNum());
-            customerCarRec.setCarColor(carVo.getColor()+"");
-            customerCarRecs.add(customerCarRec);
+        etcBindVo.getCards().forEach(carVo -> {
             CardBindingToBModel cardBindingToBModel = new CardBindingToBModel();
-            cardBindingToBModel.setCardId(cardQueryCardResultToBModel.getId());
+            cardBindingToBModel.setCardId(carVo.getEtcNum());
             cardBindingToBModels.add(cardBindingToBModel);
-        }
+        });
         CardBindingToBRequest cardBindingToBRequest = new CardBindingToBRequest();
         cardBindingToBRequest.setMobile(etcBindVo.getMobile());
         cardBindingToBRequest.setCompanyNum(customerRec.getCompanyNum());
         cardBindingToBRequest.setCardIdList(cardBindingToBModels);
         RespR<CardBindingToBResponse> respR1 = selfCarInterface.cardBindingToB(cardBindingToBRequest);
         if(respR1.getCode() == 1){
-            /**
-             * etc入库
-             */
-            customerCarRecs.forEach(customerCarRec -> {
-                customerCarRec.setRecStatus(CommonConstants.REC_STATUS_FAIL);
-                customerCarRec.setFailTime(DateUtil.getCurrentDateStr());
-                customerCarRec.setFailReason(respR1.getMsg());
-                updateETCRec(customerCarRec);
-            });
-            return new RespR(false,"注册失败:"+respR.getMsg());
+            return new RespR(false,"注册失败:"+respR1.getMsg());
         }else{
-            /**
-             * etc入库
-             */
-            customerCarRecs.forEach(customerCarRec -> {
-                customerCarRec.setRecStatus(CommonConstants.REC_STATUS_WAIT);
-                updateETCRec(customerCarRec);
-            });
             return new RespR("已经发送绑定请求,请发送收到的验证码");
         }
     }
@@ -440,23 +440,26 @@ public class SelfCarServiceLImpl implements SelfCarServiceL {
         cardValidCodeToBRequest.setMobile(etcValidVo.getMobile());
         cardValidCodeToBRequest.setValidCode(etcValidVo.getValidCode());
         RespR<CardValidCodeToBResponse> respR = selfCarInterface.cardValidCodeToB(cardValidCodeToBRequest);
-        CustomerCarRec customerCarRec;
         if(respR.getCode() == 1){
-            customerCarRec = new CustomerCarRec();
-            customerCarRec.setRecStatus(CommonConstants.REC_STATUS_FAIL);
-            customerCarRec.setFailReason(respR.getMsg());
-            customerCarRec.setFailTime(DateUtil.getCurrentDateStr());
-            customerCarRec.setCompanyNum(customerRec.getCompanyNum());
-            customerCarRec.setCustPhone(etcValidVo.getMobile());
-            customerCarRecMapper.updateWaitETCStatus(customerCarRec);
-            return new RespR(false,"验证失败");
+            return new RespR(false,"验证失败:"+respR.getMsg());
         }else{
-            customerCarRec = new CustomerCarRec();
-            customerCarRec.setRecStatus(CommonConstants.REC_STATUS_SUC);
-            customerCarRec.setSuccTime(DateUtil.getCurrentDateStr());
-            customerCarRec.setCompanyNum(customerRec.getCompanyNum());
-            customerCarRec.setCustPhone(etcValidVo.getMobile());
-            customerCarRecMapper.updateWaitETCStatus(customerCarRec);
+            /**
+             * 绑定的etc卡入库
+             */
+            respR.getData().getResult().forEach(cardValidCodeToBModel -> {
+                CustomerCarRec customerCarRec = new CustomerCarRec();
+                customerCarRec.setBusinessType(CommonConstants.BUSSINESS_TYPE_SELFCAR);
+                customerCarRec.setCompanyName(customerRec.getCompanyName());
+                customerCarRec.setCustomerName(customerRec.getCustomerName());
+                customerCarRec.setCompanyNum(customerRec.getCompanyNum());
+                customerCarRec.setCarNum(cardValidCodeToBModel.getPlateNum());
+                customerCarRec.setEtcNum(cardValidCodeToBModel.getEtcCardId());
+                customerCarRec.setCarColor(cardValidCodeToBModel.getPlateColor()+"");
+                customerCarRec.setRecStatus(CommonConstants.REC_STATUS_SUC);
+                customerCarRec.setSuccTime(DateUtil.getCurrentDateStr());
+                customerCarRec.setCustPhone(etcValidVo.getMobile());
+                updateETCRec(customerCarRec);
+            });
             return new RespR(false,"校验成功");
         }
     }
@@ -482,7 +485,7 @@ public class SelfCarServiceLImpl implements SelfCarServiceL {
                         res.append(customerCarRec.getEtcNum()+","+customerCarRec.getCarNum()+"解绑失败;"+"#");
                     }else{
                         customerCarRec.setRecStatus(2);
-                        customerCarRecMapper.updateByPrimaryKeySelective(customerCarRec);
+                        customerCarRecMapper.updateETCByPrimaryKeySelective(customerCarRec);
                     }
                 }
             }

+ 1 - 0
src/main/java/com/jkcredit/invoice/service/lowerService/vo/EtcBindVo.java

@@ -21,6 +21,7 @@ public class EtcBindVo {
      */
     private String customerName;
 
+
     /**
      * etc卡号
      */

+ 14 - 5
src/main/java/com/jkcredit/invoice/service/lowerService/vo/EtcQueryVo.java

@@ -10,8 +10,17 @@ public class EtcQueryVo {
      * 用户名
      */
     private String customerName;
+
+    /**
+     * 企业名称
+     */
     private String companyName;
-    private List<CarVo> carList;
+
+    /**
+     * 车牌号
+     */
+    private String plateNum;
+
 
     public String getCustomerName() {
         return customerName;
@@ -29,11 +38,11 @@ public class EtcQueryVo {
         this.companyName = companyName;
     }
 
-    public List<CarVo> getCarList() {
-        return carList;
+    public String getPlateNum() {
+        return plateNum;
     }
 
-    public void setCarList(List<CarVo> carList) {
-        this.carList = carList;
+    public void setPlateNum(String plateNum) {
+        this.plateNum = plateNum;
     }
 }

+ 42 - 0
src/main/java/com/jkcredit/invoice/service/lowerService/vo/InvoicePackageVo.java

@@ -0,0 +1,42 @@
+package com.jkcredit.invoice.service.lowerService.vo;
+
+/**
+ * 发票打包下载请求VO
+ */
+public class InvoicePackageVo {
+    /**
+     *
+     */
+    private String customerName;
+
+    private String companyName;
+
+    /**
+     * 查询月份
+     */
+    private String month;
+
+    public String getCustomerName() {
+        return customerName;
+    }
+
+    public void setCustomerName(String customerName) {
+        this.customerName = customerName;
+    }
+
+    public String getCompanyName() {
+        return companyName;
+    }
+
+    public void setCompanyName(String companyName) {
+        this.companyName = companyName;
+    }
+
+    public String getMonth() {
+        return month;
+    }
+
+    public void setMonth(String month) {
+        this.month = month;
+    }
+}

+ 49 - 0
src/main/java/com/jkcredit/invoice/service/lowerService/vo/SelfcarInvoiceByTimeVo.java

@@ -0,0 +1,49 @@
+package com.jkcredit.invoice.service.lowerService.vo;
+
+public class SelfcarInvoiceByTimeVo {
+    private String startTime;
+    private String endTime;
+    private String companyName;
+    private String customerName;
+    private String carNum;
+
+    public String getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(String startTime) {
+        this.startTime = startTime;
+    }
+
+    public String getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(String endTime) {
+        this.endTime = endTime;
+    }
+
+    public String getCompanyName() {
+        return companyName;
+    }
+
+    public void setCompanyName(String companyName) {
+        this.companyName = companyName;
+    }
+
+    public String getCustomerName() {
+        return customerName;
+    }
+
+    public void setCustomerName(String customerName) {
+        this.customerName = customerName;
+    }
+
+    public String getCarNum() {
+        return carNum;
+    }
+
+    public void setCarNum(String carNum) {
+        this.carNum = carNum;
+    }
+}

+ 58 - 0
src/main/java/com/jkcredit/invoice/service/lowerService/vo/TradeRequestCarNumVo.java

@@ -0,0 +1,58 @@
+package com.jkcredit.invoice.service.lowerService.vo;
+
+public class TradeRequestCarNumVo {
+    private String startTime;
+    private String endTime;
+    private String companyName;
+    private String customerName;
+    private String carNum;
+    private Integer tradeStatus;
+
+    public String getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(String startTime) {
+        this.startTime = startTime;
+    }
+
+    public String getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(String endTime) {
+        this.endTime = endTime;
+    }
+
+    public String getCompanyName() {
+        return companyName;
+    }
+
+    public void setCompanyName(String companyName) {
+        this.companyName = companyName;
+    }
+
+    public String getCustomerName() {
+        return customerName;
+    }
+
+    public void setCustomerName(String customerName) {
+        this.customerName = customerName;
+    }
+
+    public String getCarNum() {
+        return carNum;
+    }
+
+    public void setCarNum(String carNum) {
+        this.carNum = carNum;
+    }
+
+    public Integer getTradeStatus() {
+        return tradeStatus;
+    }
+
+    public void setTradeStatus(Integer tradeStatus) {
+        this.tradeStatus = tradeStatus;
+    }
+}

+ 3 - 0
src/main/java/com/jkcredit/invoice/service/lowerService/vo/TradeRequestVo.java

@@ -6,6 +6,9 @@ public class TradeRequestVo {
     private String companyName;
     private String customerName;
     private String etcId;
+    /*待开票	1
+    开票中	2
+    已开票	3*/
     private Integer tradeStatus;
 
     public String getStartTime() {

+ 5 - 0
src/main/java/com/jkcredit/invoice/service/selfCar/SelfCarService.java

@@ -1,7 +1,10 @@
 package com.jkcredit.invoice.service.selfCar;
 
+import com.jkcredit.invoice.model.entity.customer.CustomerCarRec;
 import com.jkcredit.invoice.util.RespR;
 
+import java.util.List;
+
 /**
  * 自有车操作接口
  */
@@ -12,4 +15,6 @@ public interface SelfCarService {
      * @return
      */
     RespR selfCarUnBind(String cardId);
+
+    List<CustomerCarRec> getEtcsByCarNum(String carNum);
 }

+ 5 - 0
src/main/java/com/jkcredit/invoice/service/selfCar/impl/SelfCarServiceImpl.java

@@ -27,4 +27,9 @@ public class SelfCarServiceImpl implements SelfCarService{
         customerCarRecs.add(customerCarRec);
         return  selfCarService.customerCarUnRec(customerCarRecs);
     }
+
+    @Override
+    public List<CustomerCarRec> getEtcsByCarNum(String carNum) {
+        return customerCarRecMapper.selectBySelfCarNum(carNum);
+    }
 }

+ 10 - 1
src/main/resources/mapper/customer/CustomerCarRecMapper.xml

@@ -25,8 +25,11 @@
     <include refid="Base_Column_List" />
     from  t_customer_carRec
     <where>
+      <if test="query.customerName != null">
+        customer_name = #{query.customerName,jdbcType=VARCHAR}
+      </if>
       <if test="query.carNum != null and query.carNum != ''">
-        and car_num LIKE CONCAT('%',#{query.carNum},'%')
+        and car_num = #{query.carNum}
       </if>
       <if test="query.companyName != null and query.companyName != ''">
         and company_name LIKE CONCAT('%',#{query.companyName},'%')
@@ -57,6 +60,12 @@
     from t_customer_carRec
     where car_num = #{customerName,jdbcType=VARCHAR} and bussiness_type=2
   </select>
+  <select id="selectBySelfCarNum" parameterType="java.lang.String" resultMap="BaseResultMap">
+    select
+    <include refid="Base_Column_List" />
+    from t_customer_carRec
+    where car_num = #{customerName,jdbcType=VARCHAR} and bussiness_type=0 and rec_status = 1
+  </select>
   <select id="selectByETC" parameterType="java.lang.String" resultMap="BaseResultMap">
     select
     <include refid="Base_Column_List" />

+ 3 - 3
src/main/resources/mapper/customer/CustomerRecMapper.xml

@@ -46,13 +46,13 @@
       AND  customerName LIKE CONCAT('%',#{customerRec.customerName},'%')
     </if>
     <if test="customerRec.companyLeaderPhone != null and customerRec.companyLeaderPhone != ''">
-      and companyLeaderPhone = #{customerRec.companyLeaderPhone}
+      and company_leader_Phone = #{customerRec.companyLeaderPhone}
     </if>
     <if test="customerRec.companyReferencenum != null and customerRec.companyReferencenum != ''">
-      and companyReferencenum = #{customerRec.companyReferencenum}
+      and company_referenceNum = #{customerRec.companyReferencenum}
     </if>
     <if test="customerRec.companyName != null and customerRec.companyName != ''">
-      and companyName = #{customerRec.companyName}
+      and company_name = #{customerRec.companyName}
     </if>
     </where>
   </select>

+ 2 - 2
src/main/resources/mapper/invoice/SelfCarInvoiceMapper.xml

@@ -151,10 +151,10 @@
         from t_SelfCarInvoice
         where tradeId = #{tradeId,jdbcType=VARCHAR}
     </select>
-    <select id="selectByTradeAndInvoiceMakeTime" resultMap="BaseResultMap" parameterType="java.lang.String" >
+    <select id="selectByTradeAndInvoiceMakeTime" resultMap="BaseResultMap" parameterType="com.jkcredit.invoice.model.entity.invoice.SelfCarInvoice" >
         select
         <include refid="baseSql" />
         from t_SelfCarInvoice
-        where tradeId = #{tradeId,jdbcType=VARCHAR} and invoiceMakeTime = #{invoiceMakeTime,jdbcType=VARCHAR}
+        where tradeId = #{tradeId,jdbcType=VARCHAR} and invoiceMakeTime = #{invoiceMakeTime,jdbcType=VARCHAR} and invoiceUrl= #{invoiceUrl,jdbcType=VARCHAR}
     </select>
 </mapper>