瀏覽代碼

Merge remote-tracking branch 'origin/master'

mashengyi 3 年之前
父節點
當前提交
a17e610853

+ 21 - 2
src/main/java/com/jkcredit/invoice/controller/localBussiness/SelfCarController.java

@@ -6,13 +6,16 @@ import cn.com.taiji.sdk.model.comm.protocol.tts.trade.service.CardTradeModel;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jkcredit.invoice.annotation.LoginRequired;
+import com.jkcredit.invoice.mapper.customer.CustomerRecMapper;
 import com.jkcredit.invoice.model.entity.Calculate.SelfCarCalculateInfor;
 import com.jkcredit.invoice.model.entity.customer.CustomerCarRec;
+import com.jkcredit.invoice.model.entity.customer.CustomerRec;
 import com.jkcredit.invoice.model.entity.invoice.BillInvoice;
 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.customer.CustomerService;
 import com.jkcredit.invoice.service.lowerService.SelfCarServiceL;
 import com.jkcredit.invoice.service.lowerService.vo.*;
 import com.jkcredit.invoice.service.selfCar.SelfCarInvoiceService;
@@ -44,6 +47,9 @@ public class SelfCarController {
     SelfCarInvoiceService selfCarInvoiceService;
     @Autowired
     SelfCarCalculateInfoService selfCarCalculateInfoService;
+
+    @Autowired
+    CustomerService customerService;
     /**
      * 解绑etc卡
      * @param etcNum    参数集
@@ -84,7 +90,7 @@ public class SelfCarController {
     /**
      * 分页查询自有车交易信息
      *
-     * @param selfCarTrades    参数集
+     * @param     参数集
      * @return 交易信息
      */
     @PostMapping("/updateTrades")
@@ -293,6 +299,8 @@ public class SelfCarController {
         }
 
     }
+    @Autowired
+    CustomerRecMapper customerRecMapper;
     /**
      * 查询已经开票信息
      *
@@ -304,11 +312,22 @@ public class SelfCarController {
     @LoginRequired
     public RespR findSelfcarInvoiceByTime(@RequestBody  SelfcarInvoiceByTimeVo selfcarInvoiceByTimeVo) {
         try {
+
+            if(!customerService.checkMoneyEnough(selfcarInvoiceByTimeVo.getCustomerName())){
+                return new RespR(false,"余额不足");
+            }
             //通过车牌号查询所有的Etc卡号
             List<CustomerCarRec> customerCarRecs = selfCarService.getEtcsByCarNum(selfcarInvoiceByTimeVo.getCarNum());
             if(customerCarRecs == null || customerCarRecs.size()<=0){
                 return new RespR(false,"请输入有绑定ETC卡号的车牌");
             }
+            CustomerRec customerRec = new CustomerRec();
+            customerRec.setCustomerName(selfcarInvoiceByTimeVo.getCustomerName());
+            customerRec.setCompanyName(selfcarInvoiceByTimeVo.getCompanyName());
+            CustomerRec customerRec1 = customerRecMapper.selectByCustomerNameAndCompany(customerRec);
+            if(customerRec == null || customerRec.getRecStatus().intValue() !=1 ){
+                return new RespR(false,"客户未备案");
+            }
             List<B2BInvoiceListModel>  allSelfInvocies = new ArrayList<>();
             customerCarRecs.forEach(customerCarRec -> {
                 SelfCarDueQueryVo selfCarDueQueryVo = new SelfCarDueQueryVo();
@@ -317,7 +336,7 @@ public class SelfCarController {
                 selfCarDueQueryVo.setStartTime(selfcarInvoiceByTimeVo.getStartTime());
                 selfCarDueQueryVo.setEndTime(selfcarInvoiceByTimeVo.getEndTime());
                 selfCarDueQueryVo.setCardId(customerCarRec.getEtcNum());
-                RespR<List<B2BInvoiceListModel>> respR = selfCarServicel.getSelfCarInvoicesByTime(selfCarDueQueryVo);
+                RespR<List<B2BInvoiceListModel>> respR = selfCarServicel.getSelfCarInvoicesByTime(selfCarDueQueryVo,customerRec1);
                 if(respR.getCode() == 0){
                     allSelfInvocies.addAll(respR.getData());
                 }

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

@@ -74,7 +74,7 @@ public class SelfCarServiceController {
     @ApiOperation(value="已开发票查询", notes="已开发票查询")
     //@LoginRequired
     public RespR getSelfCarInvoicesByTime(@RequestBody SelfCarDueQueryVo selfCarDueQueryVo){
-        return selfCarService.getSelfCarInvoicesByTime(selfCarDueQueryVo);
+        return selfCarService.getSelfCarInvoicesByTime(selfCarDueQueryVo,null);
     }
     /**
      * @param invoicePackageVo

+ 1 - 1
src/main/java/com/jkcredit/invoice/credit/custInterface/SelfCarInterServiceImpl.java

@@ -637,7 +637,7 @@ public class SelfCarInterServiceImpl implements SelfCarInterService {
             selfCarDueQueryVo.setStartTime(startInvoiceMakeTime);
             selfCarDueQueryVo.setEndTime(endInvoiceMakeTime);
 
-            RespR rs = selfCarService.getSelfCarInvoicesByTime(selfCarDueQueryVo);
+            RespR rs = selfCarService.getSelfCarInvoicesByTime(selfCarDueQueryVo,customerRec1);
             long costtimeend = System.currentTimeMillis();
             log.info("[-SelfCarInterServiceImpl.getSelfCarInvoicesByTime-] result is "
                     + rs.toString() + ", request is " + data + " ,costtime="

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

@@ -5,6 +5,7 @@ import cn.com.taiji.sdk.model.comm.protocol.tts.invoice.server.B2bInvoicePackage
 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.customer.CustomerRec;
 import com.jkcredit.invoice.model.entity.invoice.SelfCarAppl;
 import com.jkcredit.invoice.model.entity.invoice.SelfCarInvoice;
 import com.jkcredit.invoice.model.entity.waybill.SelfCarTrade;
@@ -45,7 +46,8 @@ public interface SelfCarServiceL {
     /**
      *已开发票查询接口
      */
-    RespR<List<B2BInvoiceListModel>> getSelfCarInvoicesByTime(SelfCarDueQueryVo selfCarDueQueryVo);
+    RespR<List<B2BInvoiceListModel>> getSelfCarInvoicesByTime(SelfCarDueQueryVo selfCarDueQueryVo, CustomerRec customerRec);
+
 
     RespR<List<B2bInvoicePackageModel>>  getInvoicePackge(InvoicePackageVo invoicePackageVo);
     /**

+ 12 - 25
src/main/java/com/jkcredit/invoice/service/lowerService/impl/SelfCarServiceLImpl.java

@@ -29,6 +29,8 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
 import java.util.ArrayList;
 import java.util.List;
 @Service
@@ -133,6 +135,7 @@ public class SelfCarServiceLImpl implements SelfCarServiceL {
     }
 
     @Override
+    @Transactional
     public RespR<String> applInvoice(InvoiceApplVo invoiceApplVo) {
         log.info("申请开票开始SelfCarServiceLImpl.applInvoice{}",invoiceApplVo);
         if(!customerService.checkMoneyEnough(invoiceApplVo.getCustomerName())){
@@ -188,7 +191,7 @@ public class SelfCarServiceLImpl implements SelfCarServiceL {
             selfCarAppl.setInvoiceTaxAmount(b2BInvoiceApplyResponse.getInvoiceTaxAmount());
             selfCarAppl.setInterType(invoiceApplVo.getInterType());
             selfCarApplMapper.insert(selfCarAppl);
-
+            double needFee = 0;
             //更新交易id申请开票时间,并将转态改为开票中
             for(String tradeId : tradeIds){
                 SelfCarTrade selfCarTrade =  sellCarTradeMapper.selectByTradeId(tradeId);
@@ -208,12 +211,14 @@ public class SelfCarServiceLImpl implements SelfCarServiceL {
                 carCalculateInfor.setCompanyReferencenum(customerRec.getCompanyReferencenum());
                 carCalculateInfor.setEtcNum(selfCarTrade.getCardId());
                 if(calculateInforMapper.selectByEtcAndTime(carCalculateInfor) == null){
-                    customer.setInvoiceTime(DateUtil.getCurrentDateStr());
-                    customer.setAccountBalance(MathUtil.sub(customer.getAccountBalance(),carCalculateInfor.getFee()));
-                    customerMapper.updateByPrimaryKeySelective(customer);
+                    needFee = MathUtil.add(needFee,carCalculateInfor.getFee());
                     calculateInforMapper.insert(carCalculateInfor);
                 }
             }
+            //客户统一扣费
+            customer.setInvoiceTime(DateUtil.getCurrentDateStr());
+            customer.setAccountBalance(MathUtil.sub(customer.getAccountBalance(),needFee));
+            customerMapper.updateByPrimaryKeySelective(customer);
             //SelfCarTrade selfCarTrade =  sellCarTradeMapper.selectByTradeId(cardTradeModel.getTradeId());
             return new RespR(respR.getData());
         }
@@ -313,26 +318,8 @@ public class SelfCarServiceLImpl implements SelfCarServiceL {
         }
     }
     @Override
-    public RespR<List<B2BInvoiceListModel>> getSelfCarInvoicesByTime(SelfCarDueQueryVo selfCarDueQueryVo) {
+    public RespR<List<B2BInvoiceListModel>> getSelfCarInvoicesByTime(SelfCarDueQueryVo selfCarDueQueryVo,CustomerRec customerRec) {
         log.info("申请开票开始SelfCarServiceLImpl.getSelfCarInvoicesByTime{}",selfCarDueQueryVo);
-        if(!customerService.checkMoneyEnough(selfCarDueQueryVo.getCustomername())){
-            return new RespR(false,"余额不足");
-        }
-        Customer customer = customerMapper.selectByCustomerName(selfCarDueQueryVo.getCustomername());
-        if(customer == null || customer.getAccstatus().intValue() == 1){
-            return new RespR(false,"客户已经停用");
-        }
-        CustomerRec customerRec = new CustomerRec();
-        customerRec.setCustomerName(selfCarDueQueryVo.getCustomername());
-        customerRec.setCompanyName(selfCarDueQueryVo.getCompanyName());
-        customerRec = customerRecMapper.selectByCustomerNameAndCompany(customerRec);
-        if(customerRec == null || customerRec.getRecStatus().intValue() !=1 ){
-            return new RespR(false,"客户未备案");
-        }
-        CustomerCarRec customerCarRec = customerCarRecMapper.selectByETC(selfCarDueQueryVo.getCardId());
-        if(customerCarRec == null  || customerCarRec.getRecStatus() != 1){
-            return new RespR(false,"业务校验错误:该卡号不在该企业下绑定!\\n:803");
-        }
         B2BInvoiceQueryRequest b2BInvoiceQueryRequest = new B2BInvoiceQueryRequest();
         b2BInvoiceQueryRequest.setCompanyNum(customerRec.getCompanyNum());
         b2BInvoiceQueryRequest.setCardId(selfCarDueQueryVo.getCardId());
@@ -352,11 +339,11 @@ public class SelfCarServiceLImpl implements SelfCarServiceL {
                     BeanUtils.copyProperties(b2BInvoiceListModel,selfCarInvoice);
                     selfCarInvoice.setInvoiceMakeTime(DateUtil.tTimeToDate(selfCarInvoice.getInvoiceMakeTime()));
                     selfCarInvoice.setExTime(DateUtil.tTimeToDate(selfCarInvoice.getExTime()));
-                    selfCarInvoice.setCustomerName(customer.getCustomerName());
+                    selfCarInvoice.setCustomerName(selfCarDueQueryVo.getCustomername());
                     selfCarInvoice.setCompanyName(customerRec.getCompanyName());
                     selfCarInvoice.setBuyerTaxpayerCode(customerRec.getCompanyReferencenum());
                     selfCarInvoice.setBuyerName(customerRec.getCompanyName());
-                    selfCarInvoice.setCompanyNum(customerCarRec.getCompanyNum());
+                    selfCarInvoice.setCompanyNum(customerRec.getCompanyNum());
                     selfCarInvoice.setEnStation(b2BInvoiceListModel.getEnStationName());
                     selfCarInvoice.setExStation(b2BInvoiceListModel.getExStationName());
                     SelfCarInvoice selfCarInvoice1 = selfCarInvoiceMapper.selectByCodeAndNum(selfCarInvoice);

+ 0 - 1
src/main/java/com/jkcredit/invoice/service/nocar/impl/NoCarBillWayServiceImpl.java

@@ -106,7 +106,6 @@ public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper,NoCa
                     }
                     noCarWayBill.setCompanyName(customerRec.getCompanyName());
                     noCarWayBill.setCompanyNum(customerRec.getCompanyNum());
-                    insertOrUpdateBill(noCarWayBill,noCarWayBillDb);
                     if(DateUtil.getDistanceHours(noCarWayBill.getStartTime(),new Date())<-72){
                         noCarWaybillMapperImprt.updateBillway(-2,"失败,运单开始时间超72小时#",noCarWayBill);
                         noCarWayBill.setBillwayStatus(-2);

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

@@ -112,7 +112,7 @@ public class ScheduledBillTask {
         }
     }
 
-   @Scheduled(cron = "0 0 23 * * ?", zone = "Asia/Shanghai")
+   //@Scheduled(cron = "0 0 23 * * ?", zone = "Asia/Shanghai")
     public void getSefCarInvoice() throws Exception{
        InetAddress addr = InetAddress.getLocalHost();
        String ip  = paramService.getParamsByParamName("CURR_SELF_IP").getParamValue();
@@ -138,7 +138,7 @@ public class ScheduledBillTask {
               selfCarDueQueryVo.setCustomername(customerCarRec.getCustomerName());
               DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
               String curr = dateFormat.format(new Date());
-              String befor = DateUtil.getDateAfterDays(curr,-1);
+              String befor = DateUtil.getDateAfterDays(curr,-7);
               String after = DateUtil.getDateAfterDays(curr,+1);
               selfCarDueQueryVo.setStartTime(befor+" 00:00:00");
               selfCarDueQueryVo.setEndTime(after+"00:00:00");
@@ -148,8 +148,8 @@ public class ScheduledBillTask {
               param.setStatus(2);
               param.setCardId(customerCarRec.getEtcNum());
               List<SelfCarTrade> selfCarTrades = sellCarTradeMapper.selectByCardIdByStatus(param);
-              selfCarService.getSelfCarInvoicesByTime(selfCarDueQueryVo);
               selfCarTradeService.updateTrades(selfCarTrades);
+              selfCarService.getSelfCarInvoicesByTime(selfCarDueQueryVo,null);
           }catch (Exception e){
               e.printStackTrace();
               log.info(customerCarRec.getEtcNum());