|
@@ -1,13 +1,16 @@
|
|
|
package com.jpsoft.prices.modules.base.controller;
|
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.prices.modules.base.dto.InvoiceInfoDTO;
|
|
|
import com.jpsoft.prices.modules.base.dto.InvoiceQuotesDTO;
|
|
|
import com.jpsoft.prices.modules.base.entity.Company;
|
|
|
import com.jpsoft.prices.modules.base.entity.Invoice;
|
|
|
import com.jpsoft.prices.modules.base.entity.InvoiceInfo;
|
|
|
+import com.jpsoft.prices.modules.base.entity.Standard;
|
|
|
import com.jpsoft.prices.modules.base.service.CompanyService;
|
|
|
import com.jpsoft.prices.modules.base.service.InvoiceInfoService;
|
|
|
import com.jpsoft.prices.modules.base.service.InvoiceService;
|
|
|
+import com.jpsoft.prices.modules.base.service.StandardService;
|
|
|
import com.jpsoft.prices.modules.common.dto.MessageResult;
|
|
|
import com.jpsoft.prices.modules.common.dto.Sort;
|
|
|
import com.jpsoft.prices.modules.common.utils.PojoUtils;
|
|
@@ -16,12 +19,16 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
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;
|
|
|
+
|
|
|
@RestController
|
|
|
@RequestMapping("/base/invoiceQuotes")
|
|
|
@Api(description = "invoiceQuotes")
|
|
@@ -34,10 +41,12 @@ public class InvoiceQuotesController {
|
|
|
private InvoiceService invoiceService;
|
|
|
@Autowired
|
|
|
private InvoiceInfoService invoiceInfoService;
|
|
|
+ @Autowired
|
|
|
+ private StandardService standardService;
|
|
|
|
|
|
@ApiOperation(value="基于物流公司的报价单比对")
|
|
|
@RequestMapping(value = "quotesList",method = RequestMethod.POST)
|
|
|
- public MessageResult<List> quotesList(String invoiceId){
|
|
|
+ public MessageResult<List> quotesList(String invoiceId) {
|
|
|
MessageResult<List> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
@@ -54,17 +63,93 @@ public class InvoiceQuotesController {
|
|
|
List<InvoiceQuotesDTO> list = new ArrayList<>();
|
|
|
Page<Company> page = companyService.pageSearch(searchParams, 1, 100, false, sortList);
|
|
|
for (Company company : page.getResult()) {
|
|
|
+ InvoiceQuotesDTO dto = new InvoiceQuotesDTO();
|
|
|
+
|
|
|
+ List<InvoiceInfoDTO> infoDTOS = new ArrayList<>();
|
|
|
+ BigDecimal transportFee = new BigDecimal(0);
|
|
|
+ BigDecimal deliveryFee = new BigDecimal(0);
|
|
|
+ BigDecimal storageFee = new BigDecimal(0);
|
|
|
+ BigDecimal insureFee = new BigDecimal(0);
|
|
|
+ BigDecimal taxFee = new BigDecimal(0);
|
|
|
+ BigDecimal totalFee = new BigDecimal(0);
|
|
|
List<InvoiceInfo> infoList = invoiceInfoService.findByInvoice(invoiceId);
|
|
|
+ for(InvoiceInfo info : infoList) {
|
|
|
+ InvoiceInfoDTO infoDTO = new InvoiceInfoDTO();
|
|
|
+ BeanUtils.copyProperties(info,infoDTO);
|
|
|
+
|
|
|
+ Standard standard = new Standard();
|
|
|
+// if(info.getType().contains("石英棒")) {
|
|
|
+// standard = standardService.getStandard(company.getId(), invoice.getDestinationId(), "托盘");
|
|
|
+// transportFee = transportFee.add(piecePlan(standard,info));
|
|
|
+// deliveryFee = standard.getDeliveryFee();
|
|
|
+// storageFee = standard.getStorageFee();
|
|
|
+// insureFee = transportFee.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);
|
|
|
+
|
|
|
+ transportFee = transportFee.add(tempFee);
|
|
|
+ deliveryFee = standard.getDeliveryFee();
|
|
|
+ storageFee = standard.getStorageFee();
|
|
|
+ insureFee = transportFee.multiply(standard.getInsureFee());
|
|
|
+ taxFee = transportFee.multiply(standard.getTaxFee());
|
|
|
+ totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee);
|
|
|
+
|
|
|
+ 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米及以上)");
|
|
|
+ BigDecimal tempFee = piecePlan(standard,info);
|
|
|
+
|
|
|
+ transportFee = transportFee.add(tempFee);
|
|
|
+ deliveryFee = standard.getDeliveryFee();
|
|
|
+ storageFee = standard.getStorageFee();
|
|
|
+ insureFee = transportFee.multiply(standard.getInsureFee());
|
|
|
+ taxFee = transportFee.multiply(standard.getTaxFee());
|
|
|
+ totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee);
|
|
|
+
|
|
|
+ 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米以下)");
|
|
|
+ BigDecimal tempFee = piecePlan(standard,info);
|
|
|
+
|
|
|
+ transportFee = transportFee.add(tempFee);
|
|
|
+ deliveryFee = standard.getDeliveryFee();
|
|
|
+ storageFee = standard.getStorageFee();
|
|
|
+ insureFee = transportFee.multiply(standard.getInsureFee());
|
|
|
+ taxFee = transportFee.multiply(standard.getTaxFee());
|
|
|
+ totalFee = transportFee.add(deliveryFee).add(storageFee).add(insureFee).add(taxFee);
|
|
|
+
|
|
|
+ infoDTO.setUnitName(standard.getUnitName());
|
|
|
+ infoDTO.setUnitPrice(standard.getUnitPrice());
|
|
|
+ infoDTO.setAmount(tempFee);
|
|
|
+ infoDTOS.add(infoDTO);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- InvoiceQuotesDTO dto = new InvoiceQuotesDTO();
|
|
|
dto.setCompanyName(company.getName());
|
|
|
dto.setNumbers(infoList.size());
|
|
|
- dto.setTransportFee(new BigDecimal(0));
|
|
|
- dto.setDeliveryFee(new BigDecimal(0));
|
|
|
- dto.setStorageFee(new BigDecimal(0));
|
|
|
- dto.setInsureFee(new BigDecimal(0));
|
|
|
- dto.setTaxFee(new BigDecimal(0));
|
|
|
- dto.setTotalFee(new BigDecimal(0));
|
|
|
+ dto.setTransportFee(transportFee);
|
|
|
+ dto.setDeliveryFee(deliveryFee);
|
|
|
+ dto.setStorageFee(storageFee);
|
|
|
+ dto.setInsureFee(insureFee);
|
|
|
+ dto.setTaxFee(taxFee);
|
|
|
+ dto.setTotalFee(totalFee);
|
|
|
+ dto.setInfoDTOS(infoDTOS);
|
|
|
list.add(dto);
|
|
|
}
|
|
|
|