|
|
|
@ -4,9 +4,11 @@ import cn.hutool.core.date.DateUtil; |
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
import cn.hutool.core.util.RandomUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
|
import com.alibaba.nacos.common.utils.CollectionUtils; |
|
|
|
|
import com.dxhy.base.constant.OrderSeparationException; |
|
|
|
|
import com.dxhy.base.constant.TaxSeparateConfig; |
|
|
|
|
import com.dxhy.base.utils.OrderMergeUtil; |
|
|
|
|
import com.dxhy.base.utils.PriceTaxSeparationUtilNew; |
|
|
|
|
import com.dxhy.common.generatepdf.util.EwmUtil; |
|
|
|
|
import com.dxhy.order.baseservice.config.BaseServiceConfig; |
|
|
|
@ -1808,6 +1810,7 @@ public class OrderInfoServiceImpl implements OrderInfoService { |
|
|
|
|
//根据订单id查询明细数据
|
|
|
|
|
List<OrderItemInfo> orderItemInfos = orderItemInfoMapper.selectAllByOrderId(Arrays.asList(orderInfoId), null); |
|
|
|
|
List<OrderItemInfo> orderItemInfoList = new ArrayList<>(); |
|
|
|
|
Boolean oilMark = true; |
|
|
|
|
for (OrderItemInfo orderItemInfo : orderItemInfos) { |
|
|
|
|
// if(StringUtils.isNotBlank(orderItemInfo.getSpbm())){
|
|
|
|
|
// continue;
|
|
|
|
@ -1825,15 +1828,89 @@ public class OrderInfoServiceImpl implements OrderInfoService { |
|
|
|
|
orderItemInfo.setZnfm(ConfigureConstant.STRING_0); |
|
|
|
|
orderItemInfo.setXmsl(null); |
|
|
|
|
orderItemInfo.setXmdj(null); |
|
|
|
|
if(StringUtils.isBlank(commodityCodeEntity.getCpy())|| "N".equals(commodityCodeEntity.getCpy())){ |
|
|
|
|
oilMark = false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
orderItemInfoList.add(orderItemInfo); |
|
|
|
|
} |
|
|
|
|
if(oilMark){ |
|
|
|
|
//更新order_info 清单标志为4
|
|
|
|
|
OrderInfo orderInfo = new OrderInfo(); |
|
|
|
|
orderInfo.setId(orderInfoId); |
|
|
|
|
orderInfo.setQdBz("4"); |
|
|
|
|
orderMapper.updateOrderInfoByOrderId(orderInfo,null); |
|
|
|
|
} |
|
|
|
|
if(!orderItemInfoList.isEmpty()){ |
|
|
|
|
orderItemInfoMapper.updateOrderItemId(orderItemInfoList); |
|
|
|
|
} |
|
|
|
|
return R.ok(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R mergeOrderItem(String entId, String orderInfoId,List<String> itemList){ |
|
|
|
|
|
|
|
|
|
List<OrderItemInfo> orderItemInfos = orderItemInfoMapper.selectAllByOrderId(Arrays.asList(orderInfoId), null); |
|
|
|
|
if(ObjectUtil.isNull(orderItemInfos)){ |
|
|
|
|
return R.error("根据订单号未查询到明细行信息"); |
|
|
|
|
} |
|
|
|
|
List<OrderItemInfo> collect = orderItemInfos.stream().filter(t -> itemList.contains(t.getId()) && StringUtils.isNotBlank(t.getSpbm())).collect(Collectors.toList()); |
|
|
|
|
if(ObjectUtil.isNull(orderItemInfos)){ |
|
|
|
|
return R.error("税收编码为空的不允许合并,请先更新税收编码"); |
|
|
|
|
} |
|
|
|
|
Map<String, List<OrderItemInfo>> collect1 = collect.stream().collect(Collectors.groupingBy(t -> t.getFphxz() + t.getXmmc() + t.getXmdw() + t.getGgxh() + t.getSl() + t.getSpbm())); |
|
|
|
|
List<OrderItemInfo> orderItemInfoList = new ArrayList<>(); |
|
|
|
|
List<String> deleteItem = new ArrayList<>(); |
|
|
|
|
for (List<OrderItemInfo> value : collect1.values()) { |
|
|
|
|
if(value.size() == 1){continue;} |
|
|
|
|
BigDecimal xmsl = new BigDecimal("0"); |
|
|
|
|
BigDecimal xmje = new BigDecimal("0"); |
|
|
|
|
BigDecimal se = new BigDecimal("0"); |
|
|
|
|
for (OrderItemInfo orderItemInfo : value) { |
|
|
|
|
xmsl.add(new BigDecimal(orderItemInfo.getXmsl())); |
|
|
|
|
xmje.add(new BigDecimal(orderItemInfo.getXmje())); |
|
|
|
|
se.add(new BigDecimal(orderItemInfo.getSe())); |
|
|
|
|
} |
|
|
|
|
OrderItemInfo orderItemInfo = value.get(0); |
|
|
|
|
orderItemInfo.setXmsl(xmsl.toString()); |
|
|
|
|
orderItemInfo.setXmje(xmje.toString()); |
|
|
|
|
//重算单价
|
|
|
|
|
orderItemInfo.setXmdj(xmje.divide(xmsl,8,RoundingMode.HALF_UP).toString()); |
|
|
|
|
//重算税额
|
|
|
|
|
String hsbz = orderItemInfo.getHsbz(); |
|
|
|
|
BigDecimal taxRate = new BigDecimal(orderItemInfo.getSl()); |
|
|
|
|
BigDecimal taxAmout = new BigDecimal(orderItemInfo.getSl()); |
|
|
|
|
if (OrderInfoEnum.HSBZ_1.getKey().equals(hsbz)) { |
|
|
|
|
taxAmout = xmje.divide(new BigDecimal("1").add(taxRate),0).multiply(taxRate).setScale(2,RoundingMode.HALF_UP); |
|
|
|
|
} else if (OrderInfoEnum.HSBZ_0.getKey().equals(hsbz)) { |
|
|
|
|
taxAmout = xmje.multiply(taxRate).setScale(2,RoundingMode.HALF_UP); |
|
|
|
|
} |
|
|
|
|
orderItemInfo.setCreateTime(new Date()); |
|
|
|
|
if(se.multiply(taxAmout).abs().longValue() <= 0.06){ |
|
|
|
|
orderItemInfoList.add(orderItemInfo); |
|
|
|
|
deleteItem.addAll(value.stream().map(t->t.getId()).collect(Collectors.toList())); |
|
|
|
|
}else{ |
|
|
|
|
log.info("订单id:{}合并明细超过0.06暂时不合并",orderInfoId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// OrderInfo orderInfo = new OrderInfo();
|
|
|
|
|
// orderInfo.setId(orderInfoId);
|
|
|
|
|
// orderInfo.setHjse();
|
|
|
|
|
// orderInfo.setHjbhsje();
|
|
|
|
|
// orderInfo.setUpdateTime(new Date());
|
|
|
|
|
// orderMapper.updateOrderInfoByOrderId(orderInfo,null);
|
|
|
|
|
// OrderProcessInfo orderProcessInfo = new OrderProcessInfo();
|
|
|
|
|
// orderProcessInfo.setOrderInfoId(orderInfoId);
|
|
|
|
|
//
|
|
|
|
|
// orderProcessInfo.setHjbhsje();
|
|
|
|
|
// orderProcessInfo.setKpse();
|
|
|
|
|
// orderProcessService.updateOrderProcessInfoByProcessId(orderProcessInfo,null);
|
|
|
|
|
orderItemInfoMapper.deleteItemByItemId(deleteItem); |
|
|
|
|
orderItemInfoMapper.insertOrderItemByList(orderItemInfoList); |
|
|
|
|
//更新清单标志
|
|
|
|
|
return R.ok(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void completeCommodityMessageBySpid(OrderItemInfo item, CommodityCodeEntity commodity) { |
|
|
|
|
//商品编码
|
|
|
|
|
item.setSpbm(commodity.getSpbm()); |
|
|
|
@ -1851,7 +1928,6 @@ public class OrderInfoServiceImpl implements OrderInfoService { |
|
|
|
|
//增值税特殊管理
|
|
|
|
|
item.setZzstsgl(commodity.getZzstsgl()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果项目名称为空,使用底层返回数据进行补全,如果不为空,并且需要补全,则进行补全
|
|
|
|
|
String spmc = item.getXmmc(); |
|
|
|
|
StringBuilder stringBuilder = new StringBuilder(); |
|
|
|
@ -1862,7 +1938,11 @@ public class OrderInfoServiceImpl implements OrderInfoService { |
|
|
|
|
spmc = stringBuilder.append("*").append(commodity.getSpjc()).append("*").append(commodity.getXmmc()).toString(); |
|
|
|
|
} |
|
|
|
|
} else if (StringUtil.checkStr(spmc, commodity.getSpjc())) { |
|
|
|
|
spmc = stringBuilder.append("*").append(commodity.getSpjc()).append("*").append(commodity.getXmmc()).toString(); |
|
|
|
|
if(StrUtil.isNotBlank(commodity.getInvoiceName())){ |
|
|
|
|
spmc = stringBuilder.append("*").append(commodity.getSpjc()).append("*").append(commodity.getInvoiceName()).toString(); |
|
|
|
|
}else { |
|
|
|
|
spmc = stringBuilder.append("*").append(commodity.getSpjc()).append("*").append(commodity.getXmmc()).toString(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
item.setXmmc(spmc); |
|
|
|
|
|
|
|
|
|