|
|
|
@ -177,7 +177,7 @@ public class OrderInfoServiceImpl implements OrderInfoService { |
|
|
|
|
@Resource |
|
|
|
|
private GsClientMapper gsClientMapper; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
@Resource |
|
|
|
|
private BuyerMapper buyerMapper; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
@ -2117,12 +2117,15 @@ public class OrderInfoServiceImpl implements OrderInfoService { |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public R checkInvoiceSync(String operation,String nsrsbh,String params){ |
|
|
|
|
// TODO 过滤一层系统来源
|
|
|
|
|
List<OrderProcessInfo> orderProcessInfos = null; |
|
|
|
|
Map<String, List<OrderProcessInfo>> collect = null; |
|
|
|
|
switch (operation){ |
|
|
|
|
case "0": |
|
|
|
|
//根据报账单号查询未开发票数,且有效 param:发票请求流水号集合
|
|
|
|
|
List<OrderProcessInfo> orderProcessInfos = orderProcessInfoMapper.queryOrderProcessInfoByBzdhs(Arrays.asList(params), Arrays.asList(nsrsbh)); |
|
|
|
|
//根据报账单号查询未开发票数,且有效 param:发票请求流水号集合,是否需要添加来源校验
|
|
|
|
|
orderProcessInfos = orderProcessInfoMapper.queryOrderProcessInfoByBzdhs(Arrays.asList(params), Arrays.asList(nsrsbh)); |
|
|
|
|
//按照报账单分组统计
|
|
|
|
|
Map<String, List<OrderProcessInfo>> collect = orderProcessInfos.stream().collect(Collectors.groupingBy(t -> t.getBzdh())); |
|
|
|
|
collect = orderProcessInfos.stream().collect(Collectors.groupingBy(t -> t.getBzdh())); |
|
|
|
|
Map<String, List<String>> collect1 = Arrays.stream(params.split(",")).collect(Collectors.groupingBy(t -> t)); |
|
|
|
|
StringBuffer sb = new StringBuffer(); |
|
|
|
|
for (String s : collect1.keySet()) { |
|
|
|
@ -2130,17 +2133,92 @@ public class OrderInfoServiceImpl implements OrderInfoService { |
|
|
|
|
sb.append("报账单号:").append(s).append("存在多笔未开订单,"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(StringUtils.isNotBlank(sb.toString())){ |
|
|
|
|
return R.error(sb.toString()); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case "1": |
|
|
|
|
//根据报账单号查询未作废发票数,且有效 param:发票请求流水号集合
|
|
|
|
|
//根据根据发票流水号查询报账单号,报账单号查询未作废发票数,且有效 param:发票请求流水号集合
|
|
|
|
|
//1、根据流水号查询报账单号对应的流水号,如果查为1条,则过滤跳过,如果存在多条且有未开具提示
|
|
|
|
|
// 2、如果存在多条且有未作废的提示,如果存在已冲红提示
|
|
|
|
|
//AND ( oii.zf_bz = '0' OR oii.ch_bz = '0' )
|
|
|
|
|
List<String> paramList = Arrays.asList(params); |
|
|
|
|
orderProcessInfos = orderProcessInfoMapper.selectOrderProcessByFpqqlshs(paramList, Arrays.asList(nsrsbh)); |
|
|
|
|
collect = orderProcessInfos.stream().collect(Collectors.groupingBy(t -> t.getBzdh())); |
|
|
|
|
StringBuffer sb1 = new StringBuffer(); |
|
|
|
|
List<String> fpqqlsh = new ArrayList<>(); |
|
|
|
|
for (String s : collect.keySet()) { |
|
|
|
|
List<OrderProcessInfo> orderProcessInfos1 = collect.get(s); |
|
|
|
|
if(orderProcessInfos1.size() > 1){ |
|
|
|
|
//如果全部开具成功再添加否则返回报错信息
|
|
|
|
|
List<String> collect2 = orderProcessInfos1.stream() |
|
|
|
|
.filter(t -> OrderInfoEnum.ORDER_STATUS_5.getKey().equals(t.getDdzt()) || OrderInfoEnum.ORDER_STATUS_7.getKey().equals(t.getDdzt())) |
|
|
|
|
.map(t -> t.getFpqqlsh()).collect(Collectors.toList()); |
|
|
|
|
if(!collect2.isEmpty()){ |
|
|
|
|
fpqqlsh.addAll(collect2); |
|
|
|
|
}else{ |
|
|
|
|
sb1.append("本次作废存在商旅发票,,存在未开具成功结算单:" + collect2.stream().collect(Collectors.joining(",")));//结算单号
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//直接return ,存在未开具情况不查作废情况了
|
|
|
|
|
if(StringUtils.isNotBlank(sb1.toString())){ |
|
|
|
|
return R.error(sb1.toString()); |
|
|
|
|
} |
|
|
|
|
if(!fpqqlsh.isEmpty()){ |
|
|
|
|
List<OrderInvoiceInfo> invoiceInfos = orderInvoiceInfoMapper.selectInvoiceInfoByFpqqlshs(fpqqlsh); |
|
|
|
|
List<String> collect2 = invoiceInfos.stream().filter(t -> !paramList.contains(t.getFpqqlsh())).map(t -> t.getFphm()).collect(Collectors.toList()); |
|
|
|
|
if(!collect2.isEmpty()){ |
|
|
|
|
return R.error("本次作废存在商旅发票,以下发票号码未作废:"+collect2.stream().collect(Collectors.joining(","))+",请注意"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case "2": |
|
|
|
|
//根据信息表编号查询到原发票号码的报账单 查询此报账单号是否存在多笔发票 param:信息表编号集合
|
|
|
|
|
//通过原发票号码 查询报账单号,查到对应流水号,在通过流水号查找 另外一张发票的状态
|
|
|
|
|
/** |
|
|
|
|
* 原发票号码 查询order_invoice_info 表,在联查 order_process_info 查报账单号,再通过报账单号反查 发票请求流水号 |
|
|
|
|
* 查到流水号,在查红字冲红 |
|
|
|
|
*/ |
|
|
|
|
List<String> list = Arrays.asList(params); |
|
|
|
|
List<String> yFpdmHm = list.stream().map(t->{ |
|
|
|
|
String[] split = t.split("-"); |
|
|
|
|
return "('" + split[0] + "','" + split[1] + "')"; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
orderProcessInfos = orderProcessInfoMapper.selectOrderProcessByYFpdmHm(yFpdmHm, Arrays.asList(nsrsbh)); |
|
|
|
|
collect = orderProcessInfos.stream().collect(Collectors.groupingBy(t -> t.getBzdh())); |
|
|
|
|
StringBuffer sb2 = new StringBuffer(); |
|
|
|
|
List<String> yfpqqlsh = new ArrayList<>(); |
|
|
|
|
for (String s : collect.keySet()) { |
|
|
|
|
List<OrderProcessInfo> orderProcessInfos1 = collect.get(s); |
|
|
|
|
if(orderProcessInfos1.size() > 1){ |
|
|
|
|
//如果全部开具成功再添加否则返回报错信息
|
|
|
|
|
List<String> collect2 = orderProcessInfos1.stream() |
|
|
|
|
.filter(t -> OrderInfoEnum.ORDER_STATUS_5.getKey().equals(t.getDdzt()) || OrderInfoEnum.ORDER_STATUS_7.getKey().equals(t.getDdzt())) |
|
|
|
|
.map(t -> t.getFpqqlsh()).collect(Collectors.toList()); |
|
|
|
|
if(!collect2.isEmpty()){ |
|
|
|
|
yfpqqlsh.addAll(collect2); |
|
|
|
|
}else{ |
|
|
|
|
sb2.append("本次冲红存在商旅发票,,存在未开具成功结算单:" + collect2.stream().collect(Collectors.joining(",")));//结算单号
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//直接return ,存在未开具情况不查作废情况了
|
|
|
|
|
if(StringUtils.isNotBlank(sb2.toString())){ |
|
|
|
|
return R.error(sb2.toString()); |
|
|
|
|
} |
|
|
|
|
if(!yfpqqlsh.isEmpty()){ |
|
|
|
|
List<OrderInvoiceInfo> invoiceInfos = orderInvoiceInfoMapper.selectInvoiceInfoByFpqqlshs(yfpqqlsh); |
|
|
|
|
List<String> collect2 = invoiceInfos.stream().filter(t -> !list.contains(t.getFpdm() + "-" + t.getFphm())).map(t -> t.getFphm()).collect(Collectors.toList()); |
|
|
|
|
if(!collect2.isEmpty()){ |
|
|
|
|
return R.error("本次冲红存在商旅发票,以下发票号码未冲红:"+collect2.stream().collect(Collectors.joining(","))+",请注意"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return R.ok(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|