|
|
@@ -381,21 +381,15 @@ public class OrderController extends BladeController {
|
|
|
{
|
|
|
customDutyId=customDuty.getData().getId();
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- throw new SecurityException("请检查是否配置关税费用项目");
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
Long quotaId=null;
|
|
|
R<FeesDesc> quota = feesDescClient.getFeesByName("配额");
|
|
|
- if(quota.isSuccess()&&customDuty.getData()!=null)
|
|
|
+ if(quota.isSuccess()&"a.getData()!=null)
|
|
|
{
|
|
|
quotaId=quota.getData().getId();
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- throw new SecurityException("请检查是否配置配额费用项目");
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
Long gstId=null;
|
|
|
R<FeesDesc> GST = feesDescClient.getFeesByName("增值税");
|
|
|
@@ -403,10 +397,7 @@ public class OrderController extends BladeController {
|
|
|
{
|
|
|
gstId=GST.getData().getId();
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- throw new SecurityException("请检查是否配置增值税费用项目");
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
Long deliverId=null;
|
|
|
R<FeesDesc> deliver = feesDescClient.getFeesByName("物流费");
|
|
|
@@ -414,25 +405,25 @@ public class OrderController extends BladeController {
|
|
|
{
|
|
|
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;
|
|
|
- if(accListByCondition.isSuccess())
|
|
|
+ if(customDutyId!=null)
|
|
|
{
|
|
|
- List<Acc> customDutyList = accListByCondition.getData();
|
|
|
+ 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);
|
|
|
+
|
|
|
+ if(accListByCondition.isSuccess())
|
|
|
+ {
|
|
|
+ List<Acc> customDutyList = accListByCondition.getData();
|
|
|
//关税
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(customDutyList))
|
|
|
@@ -444,23 +435,27 @@ public class OrderController extends BladeController {
|
|
|
customDutyMoney=BigDecimal.ZERO;
|
|
|
}
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
e.setCustomDutyMoney(customDutyMoney);
|
|
|
|
|
|
//获取配额账单明细
|
|
|
- Acc quotaAcc=new Acc();
|
|
|
- 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;
|
|
|
- if(accListByCondition2.isSuccess())
|
|
|
+ if(quotaId!=null)
|
|
|
{
|
|
|
- List<Acc> quotaList = accListByCondition2.getData();
|
|
|
+ Acc quotaAcc=new Acc();
|
|
|
+ quotaAcc.setSrcType(2);
|
|
|
+ quotaAcc.setSrcFeesId(quotaId);
|
|
|
+ quotaAcc.setSrcParentId(orderId);
|
|
|
+ //只有 itemType=采购 && billType=申请 才是付钱
|
|
|
+ quotaAcc.setItemType("采购");
|
|
|
+ quotaAcc.setBillType("申请");
|
|
|
+ R<List<Acc>> accListByCondition2 = iFinanceClient.getAccListByCondition(quotaAcc);
|
|
|
+
|
|
|
+ if(accListByCondition2.isSuccess())
|
|
|
+ {
|
|
|
+ List<Acc> quotaList = accListByCondition2.getData();
|
|
|
//配额
|
|
|
if(CollectionUtils.isNotEmpty(quotaList))
|
|
|
{
|
|
|
@@ -471,22 +466,27 @@ public class OrderController extends BladeController {
|
|
|
quotaMoney=BigDecimal.ZERO;
|
|
|
}
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
e.setQuotaMoney(quotaMoney);
|
|
|
//获取增值税账单明细
|
|
|
- Acc gstAcc=new Acc();
|
|
|
- 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;
|
|
|
- if(accListByCondition3.isSuccess())
|
|
|
+ if(gstId!=null)
|
|
|
{
|
|
|
- List<Acc> gstList = accListByCondition3.getData();
|
|
|
+ Acc gstAcc=new Acc();
|
|
|
+ gstAcc.setSrcType(2);
|
|
|
+ gstAcc.setSrcFeesId(gstId);
|
|
|
+ gstAcc.setSrcParentId(orderId);
|
|
|
+ //只有 itemType=采购 && billType=申请 才是付钱
|
|
|
+ gstAcc.setItemType("采购");
|
|
|
+ gstAcc.setBillType("申请");
|
|
|
+ R<List<Acc>> accListByCondition3 = iFinanceClient.getAccListByCondition(gstAcc);
|
|
|
+
|
|
|
+ if(accListByCondition3.isSuccess())
|
|
|
+ {
|
|
|
+ List<Acc> gstList = accListByCondition3.getData();
|
|
|
|
|
|
//增值税
|
|
|
if(CollectionUtils.isNotEmpty(gstList))
|
|
|
@@ -498,6 +498,7 @@ public class OrderController extends BladeController {
|
|
|
gstMoney=BigDecimal.ZERO;
|
|
|
}
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
e.setGstMoney(gstMoney);
|
|
|
//获取货款账单明细
|
|
|
@@ -546,30 +547,35 @@ public class OrderController extends BladeController {
|
|
|
BigDecimal costAmount=e.getSaleBillWeight().multiply(unitPrice).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
e.setCostAmount(costAmount);
|
|
|
//物流费用
|
|
|
- Acc deliverAcc=new Acc();
|
|
|
- deliverAcc.setSrcType(2);
|
|
|
- deliverAcc.setSrcFeesId(deliverId);
|
|
|
- deliverAcc.setSrcParentId(e.getOrderSaleId());
|
|
|
- //只有 itemType=采购 && billType=申请 才是付钱
|
|
|
- deliverAcc.setItemType("采购");
|
|
|
- deliverAcc.setBillType("申请");
|
|
|
- R<List<Acc>> accListByCondition5 = iFinanceClient.getAccListByCondition(gstAcc);
|
|
|
BigDecimal deliverMoney=BigDecimal.ZERO;
|
|
|
- if(accListByCondition5.isSuccess())
|
|
|
+ if(deliverId!=null)
|
|
|
{
|
|
|
- List<Acc> deliverMoneyList = accListByCondition5.getData();
|
|
|
- //关税
|
|
|
+ Acc deliverAcc=new Acc();
|
|
|
+ deliverAcc.setSrcType(2);
|
|
|
+ deliverAcc.setSrcFeesId(deliverId);
|
|
|
+ deliverAcc.setSrcParentId(e.getOrderSaleId());
|
|
|
+ //只有 itemType=采购 && billType=申请 才是付钱
|
|
|
+ deliverAcc.setItemType("采购");
|
|
|
+ deliverAcc.setBillType("申请");
|
|
|
+ R<List<Acc>> accListByCondition5 = iFinanceClient.getAccListByCondition(deliverAcc);
|
|
|
|
|
|
- if(CollectionUtils.isNotEmpty(deliverMoneyList))
|
|
|
+ if(accListByCondition5.isSuccess())
|
|
|
{
|
|
|
- deliverMoney=deliverMoneyList.stream().reduce(BigDecimal.ZERO,(x,y) ->{ return x.add(y.getAmount().multiply(y.getExchangeRate())); },BigDecimal::add);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- deliverMoney=BigDecimal.ZERO;
|
|
|
- }
|
|
|
+ List<Acc> deliverMoneyList = accListByCondition5.getData();
|
|
|
+ //关税
|
|
|
|
|
|
+ if(CollectionUtils.isNotEmpty(deliverMoneyList))
|
|
|
+ {
|
|
|
+ deliverMoney=deliverMoneyList.stream().reduce(BigDecimal.ZERO,(x,y) ->{ return x.add(y.getAmount().multiply(y.getExchangeRate())); },BigDecimal::add);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ deliverMoney=BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
e.setDeliverMoney(deliverMoney);
|
|
|
//利润=开票金额-成本金额-物流费用
|
|
|
BigDecimal profit=(InvoiceAmount.subtract(costAmount)).subtract(deliverMoney).setScale(2,BigDecimal.ROUND_HALF_UP);
|