|
@@ -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);
|
|
|
}
|
|
|
}
|
|
|
}
|