|
@@ -26,8 +26,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
|
|
|
-import static com.jpsoft.prices.modules.common.controller.PlansController.piecePlan;
|
|
|
-import static com.jpsoft.prices.modules.common.controller.PlansController.weightPlan;
|
|
|
+import static com.jpsoft.prices.modules.common.controller.PlansController.*;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/base/invoiceQuotes")
|
|
@@ -71,7 +70,10 @@ public class InvoiceQuotesController {
|
|
|
BigDecimal storageFee = new BigDecimal(0);
|
|
|
BigDecimal insureFee = new BigDecimal(0);
|
|
|
BigDecimal taxFee = new BigDecimal(0);
|
|
|
+ BigDecimal receiptFee = new BigDecimal(0);
|
|
|
BigDecimal totalFee = new BigDecimal(0);
|
|
|
+
|
|
|
+ //单项计费及详情
|
|
|
List<InvoiceInfo> infoList = invoiceInfoService.findByInvoice(invoiceId);
|
|
|
for(InvoiceInfo info : infoList) {
|
|
|
InvoiceInfoDTO infoDTO = new InvoiceInfoDTO();
|
|
@@ -83,61 +85,206 @@ public class InvoiceQuotesController {
|
|
|
// transportFee = transportFee.add(piecePlan(standard,info));
|
|
|
// deliveryFee = standard.getDeliveryFee();
|
|
|
// storageFee = standard.getStorageFee();
|
|
|
-// insureFee = transportFee.multiply(standard.getInsureFee());
|
|
|
+// insureFee = new BigDecimal(invoice.getGoodsValue()).multiply(standard.getInsureFee());
|
|
|
// taxFee = transportFee.multiply(standard.getTaxFee());
|
|
|
// totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee);
|
|
|
// continue;
|
|
|
// }
|
|
|
if(info.getGrossWeight().compareTo(new BigDecimal(1000)) >= 0) {
|
|
|
standard = standardService.getStandard(company.getId(), invoice.getDestinationId(), "重量");
|
|
|
- BigDecimal tempFee = weightPlan(standard,info);
|
|
|
+ if(standard != null) {
|
|
|
+ BigDecimal tempFee = weightPlanA(standard, info);
|
|
|
+
|
|
|
+ transportFee = transportFee.add(tempFee);
|
|
|
+ deliveryFee = standard.getDeliveryFee();
|
|
|
+ storageFee = standard.getStorageFee();
|
|
|
+ insureFee = new BigDecimal(invoice.getGoodsValue()).multiply(standard.getInsureFee());
|
|
|
+ taxFee = transportFee.multiply(standard.getTaxFee());
|
|
|
+ receiptFee = standard.getReceiptFee();
|
|
|
+ totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee).add(receiptFee);
|
|
|
+
|
|
|
+ infoDTO.setUnitName(standard.getUnitName());
|
|
|
+ infoDTO.setUnitPrice(standard.getUnitPrice());
|
|
|
+ infoDTO.setAmount(tempFee);
|
|
|
+ infoDTOS.add(infoDTO);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(info.getBoxLength() >= 1000 || info.getBoxWidth() >= 1000 ||info.getBoxHight() >= 1000) {
|
|
|
+ standard = standardService.getStandard(company.getId(), invoice.getDestinationId(), "木箱(1米及以上)");
|
|
|
+ if(standard != null) {
|
|
|
+ BigDecimal tempFee = piecePlan(standard, info);
|
|
|
+
|
|
|
+ transportFee = transportFee.add(tempFee);
|
|
|
+ deliveryFee = standard.getDeliveryFee();
|
|
|
+ storageFee = standard.getStorageFee();
|
|
|
+ insureFee = new BigDecimal(invoice.getGoodsValue()).multiply(standard.getInsureFee());
|
|
|
+ taxFee = transportFee.multiply(standard.getTaxFee());
|
|
|
+ receiptFee = standard.getReceiptFee();
|
|
|
+ totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee).add(receiptFee);
|
|
|
+
|
|
|
+ infoDTO.setUnitName(standard.getUnitName());
|
|
|
+ infoDTO.setUnitPrice(standard.getUnitPrice());
|
|
|
+ infoDTO.setAmount(tempFee);
|
|
|
+ infoDTOS.add(infoDTO);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(info.getBoxLength() < 1000 && info.getBoxWidth() < 1000 && info.getBoxHight() < 1000) {
|
|
|
+ standard = standardService.getStandard(company.getId(), invoice.getDestinationId(), "木箱(1米以下)");
|
|
|
+ if(standard != null) {
|
|
|
+ BigDecimal tempFee = piecePlan(standard, info);
|
|
|
+
|
|
|
+ transportFee = transportFee.add(tempFee);
|
|
|
+ deliveryFee = standard.getDeliveryFee();
|
|
|
+ storageFee = standard.getStorageFee();
|
|
|
+ insureFee = new BigDecimal(invoice.getGoodsValue()).multiply(standard.getInsureFee());
|
|
|
+ taxFee = transportFee.multiply(standard.getTaxFee());
|
|
|
+ receiptFee = standard.getReceiptFee();
|
|
|
+ totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee).add(receiptFee);
|
|
|
+
|
|
|
+ infoDTO.setUnitName(standard.getUnitName());
|
|
|
+ infoDTO.setUnitPrice(standard.getUnitPrice());
|
|
|
+ infoDTO.setAmount(tempFee);
|
|
|
+ infoDTOS.add(infoDTO);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //整体计费
|
|
|
+ String str = company.getName();
|
|
|
+ BigDecimal totalWeight = new BigDecimal(0);
|
|
|
+ Integer totalVolume = 0;
|
|
|
+ for(InvoiceInfo info : infoList) {
|
|
|
+ totalWeight = totalWeight.add(info.getGrossWeight());
|
|
|
+ totalVolume = totalVolume + info.getBoxLength() * info.getBoxWidth() * info.getBoxHight();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(totalWeight.compareTo(new BigDecimal(0)) > 0 && (new BigDecimal(1)).compareTo(totalWeight) >= 0) {
|
|
|
+ Standard standard = standardService.getStandard(company.getId(), invoice.getDestinationId(), "重量〖0,1】");
|
|
|
+ if(standard != null) {
|
|
|
+ BigDecimal tempFee = weightPlanB(standard, totalWeight, totalVolume);
|
|
|
|
|
|
transportFee = transportFee.add(tempFee);
|
|
|
deliveryFee = standard.getDeliveryFee();
|
|
|
storageFee = standard.getStorageFee();
|
|
|
- insureFee = transportFee.multiply(standard.getInsureFee());
|
|
|
+ insureFee = new BigDecimal(invoice.getGoodsValue()).multiply(standard.getInsureFee());
|
|
|
taxFee = transportFee.multiply(standard.getTaxFee());
|
|
|
- totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee);
|
|
|
+ receiptFee = standard.getReceiptFee();
|
|
|
+ totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee).add(receiptFee);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(totalWeight.compareTo(new BigDecimal(1)) > 0 && (new BigDecimal(50)).compareTo(totalWeight) >= 0) {
|
|
|
+ Standard standard = standardService.getStandard(company.getId(), invoice.getDestinationId(), "重量〖1,50】");
|
|
|
+ if(standard != null) {
|
|
|
+ BigDecimal tempFee = weightPlanB(standard, totalWeight, totalVolume);
|
|
|
|
|
|
- infoDTO.setUnitName(standard.getUnitName());
|
|
|
- infoDTO.setUnitPrice(standard.getUnitPrice());
|
|
|
- infoDTO.setAmount(tempFee);
|
|
|
- infoDTOS.add(infoDTO);
|
|
|
- continue;
|
|
|
+ transportFee = transportFee.add(tempFee);
|
|
|
+ deliveryFee = standard.getDeliveryFee();
|
|
|
+ storageFee = standard.getStorageFee();
|
|
|
+ insureFee = new BigDecimal(invoice.getGoodsValue()).multiply(standard.getInsureFee());
|
|
|
+ taxFee = transportFee.multiply(standard.getTaxFee());
|
|
|
+ receiptFee = standard.getReceiptFee();
|
|
|
+ totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee).add(receiptFee);
|
|
|
}
|
|
|
- if(info.getBoxLength() >= 1000 || info.getBoxWidth() >= 1000 ||info.getBoxHight() >= 1000) {
|
|
|
- standard = standardService.getStandard(company.getId(), invoice.getDestinationId(), "木箱(1米及以上)");
|
|
|
- BigDecimal tempFee = piecePlan(standard,info);
|
|
|
+ }
|
|
|
+ if(totalWeight.compareTo(new BigDecimal(50)) > 0 && (new BigDecimal(100)).compareTo(totalWeight) >= 0) {
|
|
|
+ Standard standard = standardService.getStandard(company.getId(), invoice.getDestinationId(), "重量〖50,100】");
|
|
|
+ if(standard != null) {
|
|
|
+ BigDecimal tempFee = weightPlanB(standard, totalWeight, totalVolume);
|
|
|
+
|
|
|
+ transportFee = transportFee.add(tempFee);
|
|
|
+ deliveryFee = standard.getDeliveryFee();
|
|
|
+ storageFee = standard.getStorageFee();
|
|
|
+ insureFee = new BigDecimal(invoice.getGoodsValue()).multiply(standard.getInsureFee());
|
|
|
+ taxFee = transportFee.multiply(standard.getTaxFee());
|
|
|
+ receiptFee = standard.getReceiptFee();
|
|
|
+ totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee).add(receiptFee);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(totalWeight.compareTo(new BigDecimal(100)) > 0 && (new BigDecimal(200)).compareTo(totalWeight) >= 0) {
|
|
|
+ Standard standard = standardService.getStandard(company.getId(), invoice.getDestinationId(), "重量〖100,200】");
|
|
|
+ if(standard != null) {
|
|
|
+ BigDecimal tempFee = weightPlanB(standard, totalWeight, totalVolume);
|
|
|
|
|
|
transportFee = transportFee.add(tempFee);
|
|
|
deliveryFee = standard.getDeliveryFee();
|
|
|
storageFee = standard.getStorageFee();
|
|
|
- insureFee = transportFee.multiply(standard.getInsureFee());
|
|
|
+ insureFee = new BigDecimal(invoice.getGoodsValue()).multiply(standard.getInsureFee());
|
|
|
taxFee = transportFee.multiply(standard.getTaxFee());
|
|
|
- totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee);
|
|
|
+ receiptFee = standard.getReceiptFee();
|
|
|
+ totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee).add(receiptFee);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(totalWeight.compareTo(new BigDecimal(200)) > 0 && (new BigDecimal(300)).compareTo(totalWeight) >= 0) {
|
|
|
+ Standard standard = standardService.getStandard(company.getId(), invoice.getDestinationId(), "重量〖200,300】");
|
|
|
+ if(standard != null) {
|
|
|
+ BigDecimal tempFee = weightPlanB(standard, totalWeight, totalVolume);
|
|
|
|
|
|
- infoDTO.setUnitName(standard.getUnitName());
|
|
|
- infoDTO.setUnitPrice(standard.getUnitPrice());
|
|
|
- infoDTO.setAmount(tempFee);
|
|
|
- infoDTOS.add(infoDTO);
|
|
|
- continue;
|
|
|
+ transportFee = transportFee.add(tempFee);
|
|
|
+ deliveryFee = standard.getDeliveryFee();
|
|
|
+ storageFee = standard.getStorageFee();
|
|
|
+ insureFee = new BigDecimal(invoice.getGoodsValue()).multiply(standard.getInsureFee());
|
|
|
+ taxFee = transportFee.multiply(standard.getTaxFee());
|
|
|
+ receiptFee = standard.getReceiptFee();
|
|
|
+ totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee).add(receiptFee);
|
|
|
}
|
|
|
- if(info.getBoxLength() < 1000 && info.getBoxWidth() < 1000 && info.getBoxHight() < 1000) {
|
|
|
- standard = standardService.getStandard(company.getId(), invoice.getDestinationId(), "木箱(1米以下)");
|
|
|
- BigDecimal tempFee = piecePlan(standard,info);
|
|
|
+ }
|
|
|
+ if(totalWeight.compareTo(new BigDecimal(300)) > 0 && (new BigDecimal(500)).compareTo(totalWeight) >= 0) {
|
|
|
+ Standard standard = standardService.getStandard(company.getId(), invoice.getDestinationId(), "重量〖300,500】");
|
|
|
+ if(standard != null) {
|
|
|
+ BigDecimal tempFee = weightPlanB(standard, totalWeight, totalVolume);
|
|
|
+
|
|
|
+ transportFee = transportFee.add(tempFee);
|
|
|
+ deliveryFee = standard.getDeliveryFee();
|
|
|
+ storageFee = standard.getStorageFee();
|
|
|
+ insureFee = new BigDecimal(invoice.getGoodsValue()).multiply(standard.getInsureFee());
|
|
|
+ taxFee = transportFee.multiply(standard.getTaxFee());
|
|
|
+ receiptFee = standard.getReceiptFee();
|
|
|
+ totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee).add(receiptFee);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(totalWeight.compareTo(new BigDecimal(500)) > 0 && (new BigDecimal(1000)).compareTo(totalWeight) >= 0) {
|
|
|
+ Standard standard = standardService.getStandard(company.getId(), invoice.getDestinationId(), "重量〖500,1000】");
|
|
|
+ if(standard != null) {
|
|
|
+ BigDecimal tempFee = weightPlanB(standard, totalWeight, totalVolume);
|
|
|
+
|
|
|
+ transportFee = transportFee.add(tempFee);
|
|
|
+ deliveryFee = standard.getDeliveryFee();
|
|
|
+ storageFee = standard.getStorageFee();
|
|
|
+ insureFee = new BigDecimal(invoice.getGoodsValue()).multiply(standard.getInsureFee());
|
|
|
+ taxFee = transportFee.multiply(standard.getTaxFee());
|
|
|
+ receiptFee = standard.getReceiptFee();
|
|
|
+ totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee).add(receiptFee);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(totalWeight.compareTo(new BigDecimal(1000)) > 0 && (new BigDecimal(2000)).compareTo(totalWeight) >= 0) {
|
|
|
+ Standard standard = standardService.getStandard(company.getId(), invoice.getDestinationId(), "重量〖1000,2000】");
|
|
|
+ if(standard != null) {
|
|
|
+ BigDecimal tempFee = weightPlanB(standard, totalWeight, totalVolume);
|
|
|
|
|
|
transportFee = transportFee.add(tempFee);
|
|
|
deliveryFee = standard.getDeliveryFee();
|
|
|
storageFee = standard.getStorageFee();
|
|
|
- insureFee = transportFee.multiply(standard.getInsureFee());
|
|
|
+ insureFee = new BigDecimal(invoice.getGoodsValue()).multiply(standard.getInsureFee());
|
|
|
taxFee = transportFee.multiply(standard.getTaxFee());
|
|
|
- totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee);
|
|
|
+ receiptFee = standard.getReceiptFee();
|
|
|
+ totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee).add(receiptFee);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(totalWeight.compareTo(new BigDecimal(2000)) > 0) {
|
|
|
+ Standard standard = standardService.getStandard(company.getId(), invoice.getDestinationId(), "重量〖2000,∞】");
|
|
|
+ if(standard != null) {
|
|
|
+ BigDecimal tempFee = weightPlanB(standard, totalWeight, totalVolume);
|
|
|
|
|
|
- infoDTO.setUnitName(standard.getUnitName());
|
|
|
- infoDTO.setUnitPrice(standard.getUnitPrice());
|
|
|
- infoDTO.setAmount(tempFee);
|
|
|
- infoDTOS.add(infoDTO);
|
|
|
- continue;
|
|
|
+ transportFee = transportFee.add(tempFee);
|
|
|
+ deliveryFee = standard.getDeliveryFee();
|
|
|
+ storageFee = standard.getStorageFee();
|
|
|
+ insureFee = new BigDecimal(invoice.getGoodsValue()).multiply(standard.getInsureFee());
|
|
|
+ taxFee = transportFee.multiply(standard.getTaxFee());
|
|
|
+ receiptFee = standard.getReceiptFee();
|
|
|
+ totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee).add(receiptFee);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -148,6 +295,7 @@ public class InvoiceQuotesController {
|
|
|
dto.setStorageFee(storageFee);
|
|
|
dto.setInsureFee(insureFee);
|
|
|
dto.setTaxFee(taxFee);
|
|
|
+ dto.setReceiptFee(receiptFee);
|
|
|
dto.setTotalFee(totalFee);
|
|
|
dto.setInfoDTOS(infoDTOS);
|
|
|
list.add(dto);
|