Przeglądaj źródła

跨越物流完成

jzkai 2 lat temu
rodzic
commit
77dfbbc54e

+ 2 - 0
common/src/main/java/com/jpsoft/prices/modules/base/dto/InvoiceQuotesDTO.java

@@ -26,6 +26,8 @@ public class InvoiceQuotesDTO {
     private BigDecimal insureFee;
     @ApiModelProperty(value = "税费")
     private BigDecimal taxFee;
+    @ApiModelProperty(value = "回单费")
+    private BigDecimal receiptFee;
     @ApiModelProperty(value = "合计")
     private BigDecimal totalFee;
 

+ 8 - 0
common/src/main/java/com/jpsoft/prices/modules/base/entity/Standard.java

@@ -37,8 +37,12 @@ public class Standard {
     private String unitName;
         @ApiModelProperty(value = "起步价")
     private BigDecimal startingPrice;
+        @ApiModelProperty(value = "保底价")
+    private BigDecimal guaranteedPrice;
         @ApiModelProperty(value = "浮动价")
     private BigDecimal floatingPrice;
+        @ApiModelProperty(value = "折扣率")
+    private BigDecimal discount;
         @ApiModelProperty(value = "送货费")
     private BigDecimal deliveryFee;
         @ApiModelProperty(value = "进仓费")
@@ -47,6 +51,10 @@ public class Standard {
     private BigDecimal insureFee;
         @ApiModelProperty(value = "税费")
     private BigDecimal taxFee;
+        @ApiModelProperty(value = "回单费")
+    private BigDecimal receiptFee;
+        @ApiModelProperty(value = "抛重系数")
+    private Integer volumeMetric;
         @ApiModelProperty(value = "是否删除")
     private Boolean delFlag;
         @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")

+ 23 - 3
common/src/main/resources/mapper/base/Standard.xml

@@ -13,11 +13,15 @@
 		<result property="unitPrice" column="unit_price" />
 		<result property="unitName" column="unit_name" />
 		<result property="startingPrice" column="starting_price" />
+		<result property="guaranteedPrice" column="guaranteed_price" />
 		<result property="floatingPrice" column="floating_price" />
+		<result property="discount" column="discount_" />
 		<result property="deliveryFee" column="delivery_fee" />
 		<result property="storageFee" column="storage_fee" />
 		<result property="insureFee" column="insure_fee" />
 		<result property="taxFee" column="tax_fee" />
+		<result property="receiptFee" column="receipt_fee" />
+		<result property="volumeMetric" column="volume_metric" />
 		<result property="delFlag" column="del_flag" />
 		<result property="createTime" column="create_time" />
 		<result property="createBy" column="create_by" />
@@ -36,7 +40,7 @@
 	-->
 	<![CDATA[
 		insert into base_standard
-	    (id_,company_id,destination_id,logic_id,name_,first_weight,unit_price,unit_name,starting_price,floating_price,delivery_fee,storage_fee,insure_fee,tax_fee,del_flag,create_time,create_by,update_time,update_by)
+	    (id_,company_id,destination_id,logic_id,name_,first_weight,unit_price,unit_name,starting_price,guaranteed_price,floating_price,discount_,delivery_fee,storage_fee,insure_fee,tax_fee,receipt_fee,volume_metric,del_flag,create_time,create_by,update_time,update_by)
 		values
 		(
 #{id,jdbcType=VARCHAR}
@@ -48,11 +52,15 @@
 ,#{unitPrice,jdbcType= NUMERIC }
 ,#{unitName,jdbcType=VARCHAR}
 ,#{startingPrice,jdbcType= NUMERIC }
+,#{guaranteedPrice,jdbcType= NUMERIC }
 ,#{floatingPrice,jdbcType= NUMERIC }
+,#{discount,jdbcType= NUMERIC }
 ,#{deliveryFee,jdbcType= NUMERIC }
 ,#{storageFee,jdbcType= NUMERIC }
 ,#{insureFee,jdbcType= NUMERIC }
 ,#{taxFee,jdbcType= NUMERIC }
+,#{receiptFee,jdbcType= NUMERIC }
+,#{volumeMetric,jdbcType= NUMERIC }
 ,#{delFlag,jdbcType= NUMERIC }
 ,#{createTime,jdbcType= TIMESTAMP }
 ,#{createBy,jdbcType=VARCHAR}
@@ -90,9 +98,15 @@
 		</if>
 				<if test="startingPrice!=null">
 		starting_price=#{startingPrice,jdbcType= NUMERIC },
+		</if>
+				<if test="guaranteedPrice!=null">
+		guaranteed_price=#{guaranteedPrice,jdbcType= NUMERIC },
 		</if>
 				<if test="floatingPrice!=null">
 		floating_price=#{floatingPrice,jdbcType= NUMERIC },
+		</if>
+				<if test="discount!=null">
+		discount_=#{discount,jdbcType= NUMERIC },
 		</if>
 				<if test="deliveryFee!=null">
 		delivery_fee=#{deliveryFee,jdbcType= NUMERIC },
@@ -105,6 +119,12 @@
 		</if>
 				<if test="taxFee!=null">
 		tax_fee=#{taxFee,jdbcType= NUMERIC },
+		</if>
+				<if test="receiptFee!=null">
+		receipt_fee=#{receiptFee,jdbcType= NUMERIC },
+		</if>
+				<if test="volumeMetric!=null">
+		volume_metric=#{volumeMetric,jdbcType= NUMERIC },
 		</if>
 				<if test="delFlag!=null">
 		del_flag=#{delFlag,jdbcType= NUMERIC },
@@ -126,7 +146,7 @@
 	</update>
 	<select id="get" parameterType="string" resultMap="StandardMap">
 		select 
-id_,company_id,destination_id,logic_id,name_,first_weight,unit_price,unit_name,starting_price,floating_price,delivery_fee,storage_fee,insure_fee,tax_fee,del_flag,create_time,create_by,update_time,update_by		from base_standard where id_=#{0}
+id_,company_id,destination_id,logic_id,name_,first_weight,unit_price,unit_name,starting_price,guaranteed_price,floating_price,discount_,delivery_fee,storage_fee,insure_fee,tax_fee,receipt_fee,del_flag,create_time,create_by,update_time,update_by		from base_standard where id_=#{0}
 	</select>
 	<select id="exist" parameterType="string" resultType="int">
 		select count(*) from base_standard where id_=#{0}
@@ -165,6 +185,6 @@ id_,company_id,destination_id,logic_id,name_,first_weight,unit_price,unit_name,s
 		WHERE del_flag = 0
 		AND company_id = #{companyId}
 		AND destination_id = #{destinationId}
-		AND unit_name LIKE CONCAT('%',#{unitName},'%')
+		AND unit_name LIKE CONCAT('%',#{unitName})
 	</select>
 </mapper>

+ 179 - 31
web/src/main/java/com/jpsoft/prices/modules/base/controller/InvoiceQuotesController.java

@@ -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);

+ 27 - 1
web/src/main/java/com/jpsoft/prices/modules/common/controller/PlansController.java

@@ -25,11 +25,37 @@ public class PlansController {
     /**
      * 计重方案
      */
-    public static BigDecimal weightPlan(Standard standard, InvoiceInfo invoiceInfo){
+    public static BigDecimal weightPlanA(Standard standard, InvoiceInfo invoiceInfo){
         BigDecimal val = new BigDecimal(0);
 
         val = standard.getUnitPrice().multiply(invoiceInfo.getGrossWeight()).divide(new BigDecimal(1000));
 
         return val;
     }
+
+    /**
+     * 计重方案(首重、起步价、保底价)
+     */
+    public static BigDecimal weightPlanB(Standard standard, BigDecimal weight, Integer volume){
+        BigDecimal val = new BigDecimal(0);
+
+        BigDecimal tempWeight = new BigDecimal(0);
+        tempWeight = new BigDecimal(volume / standard.getVolumeMetric()).setScale(1, BigDecimal.ROUND_HALF_UP);
+        if (tempWeight.compareTo(weight) > 0) {
+            weight = tempWeight;
+        }
+
+        if(weight.compareTo(new BigDecimal(0)) > 0 && (new BigDecimal(1)).compareTo(weight) >= 0){
+            val = standard.getStartingPrice();
+        }
+        else {
+            val = standard.getStartingPrice().add(standard.getUnitPrice().multiply(weight.subtract(standard.getFirstWeight()))).multiply(standard.getDiscount());
+        }
+
+        if(standard.getGuaranteedPrice().compareTo(val) >= 0){
+            val = standard.getGuaranteedPrice();
+        }
+
+        return val;
+    }
 }