|
|
@@ -332,7 +332,7 @@ public class OrderController extends BladeController {
|
|
|
public R listOrderStatisticAnalysis(Order order, Query query)
|
|
|
{
|
|
|
Page<OrderStatisticAnalysisVO> iPage = new Page(query.getCurrent(),query.getSize());
|
|
|
- IPage<OrderStatisticAnalysisVO> orderStatisticAnalysisVOIPage = orderService.listOrderStatisticAnalysis(iPage, AuthUtil.getTenantId(), order.getOrderNo());
|
|
|
+ IPage<OrderStatisticAnalysisVO> orderStatisticAnalysisVOIPage = orderService.listOrderStatisticAnalysis(iPage, AuthUtil.getTenantId(), order.getOrderNo(),order.getStartTime(),order.getEndTime());
|
|
|
List<OrderStatisticAnalysisVO> records = orderStatisticAnalysisVOIPage.getRecords();
|
|
|
if(CollectionUtils.isNotEmpty(records))
|
|
|
{
|
|
|
@@ -355,6 +355,15 @@ public class OrderController extends BladeController {
|
|
|
e.setSaleCorpName(corpsDescClientCorpMessage.getData().getCname());
|
|
|
}
|
|
|
}
|
|
|
+ //业务员名称
|
|
|
+ if(e.getCreateUser()!=null)
|
|
|
+ {
|
|
|
+ R<User> info = userClient.userInfoById(e.getCreateUser());
|
|
|
+ if(info.isSuccess())
|
|
|
+ {
|
|
|
+ e.setCreateUserName(info.getData().getRealName());
|
|
|
+ }
|
|
|
+ }
|
|
|
//采购主表id
|
|
|
Long orderId = e.getOrderId();
|
|
|
LambdaQueryWrapper<Order> orderLambdaQueryWrapper=new LambdaQueryWrapper<>();
|
|
|
@@ -369,37 +378,56 @@ public class OrderController extends BladeController {
|
|
|
//调用-费用微服务-获取费用设置详情
|
|
|
R<FeesDesc> customDuty = feesDescClient.getFeesByName("关税");
|
|
|
Long customDutyId=null;
|
|
|
- if(customDuty.isSuccess())
|
|
|
+ if(customDuty.isSuccess()&&customDuty.getData()!=null)
|
|
|
{
|
|
|
customDutyId=customDuty.getData().getId();
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw new SecurityException("请检查是否配置关税费用项目");
|
|
|
+ }
|
|
|
|
|
|
Long quotaId=null;
|
|
|
R<FeesDesc> quota = feesDescClient.getFeesByName("配额");
|
|
|
- if(quota.isSuccess())
|
|
|
+ if(quota.isSuccess()&&customDuty.getData()!=null)
|
|
|
{
|
|
|
quotaId=quota.getData().getId();
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw new SecurityException("请检查是否配置配额费用项目");
|
|
|
+ }
|
|
|
|
|
|
Long gstId=null;
|
|
|
R<FeesDesc> GST = feesDescClient.getFeesByName("增值税");
|
|
|
- if(GST.isSuccess())
|
|
|
+ if(GST.isSuccess()&&GST.getData()!=null)
|
|
|
{
|
|
|
gstId=GST.getData().getId();
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw new SecurityException("请检查是否配置增值税费用项目");
|
|
|
+ }
|
|
|
|
|
|
- Long deliverId=null;
|
|
|
+ Long deliverId=null;
|
|
|
R<FeesDesc> deliver = feesDescClient.getFeesByName("物流费");
|
|
|
- if(deliver.isSuccess())
|
|
|
+ if(deliver.isSuccess()&&deliver.getData()!=null)
|
|
|
{
|
|
|
deliverId=deliver.getData().getId();
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw new SecurityException("请检查是否配置物流费用项目");
|
|
|
+ }
|
|
|
|
|
|
//获取关税账单明细
|
|
|
Acc customDutyAcc=new Acc();
|
|
|
customDutyAcc.setSrcType(2);
|
|
|
customDutyAcc.setSrcFeesId(customDutyId);
|
|
|
customDutyAcc.setSrcParentId(orderId);
|
|
|
+ //只有 itemType=采购 && billType=申请 才是付钱
|
|
|
+ customDutyAcc.setItemType("采购");
|
|
|
+ customDutyAcc.setBillType("申请");
|
|
|
R<List<Acc>> accListByCondition = iFinanceClient.getAccListByCondition(customDutyAcc);
|
|
|
//关税
|
|
|
BigDecimal customDutyMoney=BigDecimal.ZERO;
|
|
|
@@ -425,6 +453,9 @@ public class OrderController extends BladeController {
|
|
|
quotaAcc.setSrcType(2);
|
|
|
quotaAcc.setSrcFeesId(quotaId);
|
|
|
quotaAcc.setSrcParentId(orderId);
|
|
|
+ //只有 itemType=采购 && billType=申请 才是付钱
|
|
|
+ quotaAcc.setItemType("采购");
|
|
|
+ quotaAcc.setBillType("申请");
|
|
|
R<List<Acc>> accListByCondition2 = iFinanceClient.getAccListByCondition(quotaAcc);
|
|
|
//配额
|
|
|
BigDecimal quotaMoney=BigDecimal.ZERO;
|
|
|
@@ -448,6 +479,9 @@ public class OrderController extends BladeController {
|
|
|
gstAcc.setSrcType(2);
|
|
|
gstAcc.setSrcFeesId(gstId);
|
|
|
gstAcc.setSrcParentId(orderId);
|
|
|
+ //只有 itemType=采购 && billType=申请 才是付钱
|
|
|
+ gstAcc.setItemType("采购");
|
|
|
+ gstAcc.setBillType("申请");
|
|
|
R<List<Acc>> accListByCondition3 = iFinanceClient.getAccListByCondition(gstAcc);
|
|
|
//增值税
|
|
|
BigDecimal gstMoney=BigDecimal.ZERO;
|
|
|
@@ -472,6 +506,9 @@ public class OrderController extends BladeController {
|
|
|
itemAcc.setSrcType(1);
|
|
|
itemAcc.setSrcFeesId(null);
|
|
|
itemAcc.setSrcParentId(orderId);
|
|
|
+ //只有 itemType=采购 && billType=申请 才是付钱
|
|
|
+ itemAcc.setItemType("采购");
|
|
|
+ itemAcc.setBillType("申请");
|
|
|
R<List<Acc>> accListByCondition4 = iFinanceClient.getAccListByCondition(itemAcc);
|
|
|
//货款
|
|
|
BigDecimal itemMoney=BigDecimal.ZERO;
|
|
|
@@ -488,6 +525,7 @@ public class OrderController extends BladeController {
|
|
|
itemMoney=BigDecimal.ZERO;
|
|
|
}
|
|
|
}
|
|
|
+ itemMoney.setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
e.setItemMoney(itemMoney);
|
|
|
//销售主表信息
|
|
|
LambdaQueryWrapper<Order> saleOrderWrapper=new LambdaQueryWrapper<>();
|
|
|
@@ -495,17 +533,18 @@ public class OrderController extends BladeController {
|
|
|
Order serviceOne = orderService.getOne(saleOrderWrapper);
|
|
|
|
|
|
//成本单价=(货款+关税+配额)/发票重量---精确小数点2位
|
|
|
- BigDecimal unitPrice=((itemMoney.add(quotaMoney)).add(customDutyMoney)).divide(service.getInvoiceWeight(),2,BigDecimal.ROUND_DOWN);
|
|
|
+ BigDecimal unitPrice=((itemMoney.add(quotaMoney)).add(customDutyMoney)).divide(service.getInvoiceWeight(),2,BigDecimal.ROUND_HALF_UP);
|
|
|
e.setUnitPrice(unitPrice);
|
|
|
if(serviceOne.getExchangeRate()==null)
|
|
|
{
|
|
|
throw new SecurityException("销售订单:"+serviceOne.getOrderNo()+",汇率未填,无法完成统计");
|
|
|
}
|
|
|
//开票金额= 销售订单明细总价*销售订单主表的汇率
|
|
|
- BigDecimal InvoiceAmount=e.getAmount().multiply(serviceOne.getExchangeRate());
|
|
|
+ BigDecimal InvoiceAmount=e.getAmount().multiply(serviceOne.getExchangeRate()).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
e.setInvoiceAmount(InvoiceAmount);
|
|
|
+ e.setExchangeRate(serviceOne.getExchangeRate());
|
|
|
//成本金额=提货数量*成本价格
|
|
|
- BigDecimal costAmount=e.getSaleBillWeight().multiply(unitPrice);
|
|
|
+ BigDecimal costAmount=e.getSaleBillWeight().multiply(unitPrice).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
e.setCostAmount(costAmount);
|
|
|
//物流费用
|
|
|
Acc deliverAcc=new Acc();
|
|
|
@@ -531,7 +570,7 @@ public class OrderController extends BladeController {
|
|
|
}
|
|
|
e.setDeliverMoney(deliverMoney);
|
|
|
//利润=开票金额-成本金额-物流费用
|
|
|
- BigDecimal profit=(InvoiceAmount.subtract(costAmount)).subtract(deliverMoney);
|
|
|
+ BigDecimal profit=(InvoiceAmount.subtract(costAmount)).subtract(deliverMoney).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
e.setProfit(profit);
|
|
|
});
|
|
|
}
|