Commit 4bf8e9f6 authored by Allen Chen's avatar Allen Chen

comit

parent 0003a184
...@@ -138,14 +138,22 @@ public class PddOpenController { ...@@ -138,14 +138,22 @@ public class PddOpenController {
int freightFee = 0; int freightFee = 0;
int rentFee = 0; int rentFee = 0;
int weight = 0; int weight = 0;
log.info("订单数量 = {}", list.size());
LogOrderEntity logOrderEntity = null;
LogOrderMailDetailEntity mailDetailEntity = null;
for (PddServiceConsoFeeQueryRequest.MailDetail mailDetail : list) { for (PddServiceConsoFeeQueryRequest.MailDetail mailDetail : list) {
LogOrderMailDetailEntity mailDetailEntity = orderMailDetailImpl.getByMailNo(mailDetail.getMailNo()); mailDetailEntity = orderMailDetailImpl.getByMailNo(mailDetail.getMailNo());
if (logOrderEntity == null) {
logOrderEntity = orderImpl.getByOrderCode(mailDetailEntity.getLogisticsOrderCode());
}
PddJYPriceTool.FeeResult result = PddJYPriceTool.getTotalFee(queryRequest.getGoodsType(), PddJYPriceTool.FeeResult result = PddJYPriceTool.getTotalFee(queryRequest.getGoodsType(),
mailDetailEntity.getLength(), mailDetailEntity.getLength(),
mailDetailEntity.getWidth(), mailDetailEntity.getWidth(),
mailDetailEntity.getHeight(), mailDetailEntity.getHeight(),
mailDetailEntity.getWeight(), mailDetailEntity.getWeight(),
"SENDTORECEVER".equals(queryRequest.getSegmentCode()) "SENDTORECEVER".equals(queryRequest.getSegmentCode()),
mailDetailEntity.getEnterTime()
); );
if (result == null) { if (result == null) {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
...@@ -158,6 +166,17 @@ public class PddOpenController { ...@@ -158,6 +166,17 @@ public class PddOpenController {
rentFee += result.getRentFee(); rentFee += result.getRentFee();
weight += result.getWeight(); weight += result.getWeight();
} }
if (logOrderEntity.getStatus() < 50) {
PddJYPriceTool.FeeResult result = PddJYPriceTool.getTotalFee(queryRequest.getGoodsType(),
mailDetailEntity.getLength(),
mailDetailEntity.getWidth(),
mailDetailEntity.getHeight(),
weight,
"SENDTORECEVER".equals(queryRequest.getSegmentCode()),
mailDetailEntity.getEnterTime()
);
freightFee = result.getFreightFee();
}
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("success", true); jsonObject.put("success", true);
......
...@@ -67,4 +67,7 @@ public class LogOrderMailDetailEntity { ...@@ -67,4 +67,7 @@ public class LogOrderMailDetailEntity {
@TableField(value = "weight") @TableField(value = "weight")
private Integer weight; private Integer weight;
@TableField(value = "enterTime")
private String enterTime;
} }
package org.ta.pddserver.utils; package org.ta.pddserver.utils;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class PddJYPriceTool { public class PddJYPriceTool {
public static FeeResult getTotalFee(String type, int length, int width, int height, int weight, boolean international) { public static FeeResult getTotalFee(String type, int length, int width, int height, int weight, boolean international,String enterTime) {
log.info("length = {}, width = {}, height={}, weight = {}", length, width, height, weight);
if (international) { if (international) {
// 国际件 // 国际件
int exchange = 1; int exchange = 1;
return PddOverseaPriceTool.FreightCostCalculation(type, length, width, height, weight, exchange); return PddOverseaPriceTool.FreightCostCalculation(type, length, width, height, weight, exchange, enterTime);
} else { } else {
// 国内件 属于退件 // 国内件 属于退件
return PddNationalPriceTool.FreightCostCalculation(length, width, height, weight); return PddNationalPriceTool.FreightCostCalculation(length, width, height, weight, enterTime);
} }
} }
......
...@@ -2,6 +2,10 @@ package org.ta.pddserver.utils; ...@@ -2,6 +2,10 @@ package org.ta.pddserver.utils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -33,7 +37,7 @@ public class PddNationalPriceTool { ...@@ -33,7 +37,7 @@ public class PddNationalPriceTool {
/* /*
* 根据类型、重量(g) 计算运费 * 根据类型、重量(g) 计算运费
* */ * */
public static PddJYPriceTool.FeeResult FreightCostCalculation(int length, int width, int height, int weight) { public static PddJYPriceTool.FeeResult FreightCostCalculation(int length, int width, int height, int weight, String enterTime) {
PddJYPriceTool.FeeResult result = new PddJYPriceTool.FeeResult(); PddJYPriceTool.FeeResult result = new PddJYPriceTool.FeeResult();
int price = initalPrice; int price = initalPrice;
if (weight > initialWeight) { if (weight > initialWeight) {
...@@ -45,7 +49,26 @@ public class PddNationalPriceTool { ...@@ -45,7 +49,26 @@ public class PddNationalPriceTool {
price = price + pc * excessPrice; price = price + pc * excessPrice;
log.info("续重数量:{}", pc); log.info("续重数量:{}", pc);
} }
result.setRentFee(0); int rent = 0;
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date1 = sdf.parse(enterTime);
Date date2 = new Date();
// 将Date转换为LocalDate
LocalDate localDate1 = date1.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate localDate2 = date2.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
// 计算两个日期之间的天数差异
long daysBetween = Math.abs(java.time.temporal.ChronoUnit.DAYS.between(localDate2, localDate1));
if (daysBetween > 180) {
rent = (int)daysBetween - 180;
}
} catch (Exception e) {
e.printStackTrace();
}
result.setRentFee(rent * 100);
result.setFreightFee(price); result.setFreightFee(price);
result.setWeight(weight); result.setWeight(weight);
return result; return result;
......
package org.ta.pddserver.utils; package org.ta.pddserver.utils;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
public class PddOverseaPriceTool { public class PddOverseaPriceTool {
// 首重重量 // 首重重量
...@@ -37,7 +42,7 @@ public class PddOverseaPriceTool { ...@@ -37,7 +42,7 @@ public class PddOverseaPriceTool {
/* /*
* 根据类型、重量(g) 计算运费 * 根据类型、重量(g) 计算运费
* */ * */
public static PddJYPriceTool.FeeResult FreightCostCalculation(String type, int length, int width, int height, int weight, int exchange) { public static PddJYPriceTool.FeeResult FreightCostCalculation(String type, int length, int width, int height, int weight, int exchange,String enterTime) {
int max = length + width + height; int max = length + width + height;
if (length > maxSingleLength || width > maxSingleLength || height > maxSingleLength || max > maxSumLength) { if (length > maxSingleLength || width > maxSingleLength || height > maxSingleLength || max > maxSumLength) {
...@@ -74,7 +79,7 @@ public class PddOverseaPriceTool { ...@@ -74,7 +79,7 @@ public class PddOverseaPriceTool {
if (compWeight > initialWeight) { if (compWeight > initialWeight) {
//计算超出重量 //计算超出重量
compWeight = compWeight - initialWeight; compWeight = compWeight - initialWeight;
excess = excessPrice * ((int) Math.ceil(compWeight / excessWeight)); excess = excessPrice * ((int) Math.ceil(1.0 * compWeight / excessWeight));
} }
//计算价格 //计算价格
...@@ -85,7 +90,27 @@ public class PddOverseaPriceTool { ...@@ -85,7 +90,27 @@ public class PddOverseaPriceTool {
} else { } else {
price = price + sInitalPrice + excess; price = price + sInitalPrice + excess;
} }
result.setRentFee(0);
int rent = 0;
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date1 = sdf.parse(enterTime);
Date date2 = new Date();
// 将Date转换为LocalDate
LocalDate localDate1 = date1.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate localDate2 = date2.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
// 计算两个日期之间的天数差异
long daysBetween = Math.abs(java.time.temporal.ChronoUnit.DAYS.between(localDate2, localDate1));
if (daysBetween > 180) {
rent = (int)daysBetween - 180;
}
} catch (Exception e) {
e.printStackTrace();
}
result.setRentFee(rent * 100);
result.setFreightFee(price); result.setFreightFee(price);
return result; return result;
} }
......
...@@ -8,6 +8,7 @@ import org.ta.pddserver.model.enums.OrderProblemType; ...@@ -8,6 +8,7 @@ import org.ta.pddserver.model.enums.OrderProblemType;
import org.ta.pddserver.model.pddjy.request.*; import org.ta.pddserver.model.pddjy.request.*;
import org.ta.pddserver.model.pddjy.response.PddServiceConsoDerelictionResponse; import org.ta.pddserver.model.pddjy.response.PddServiceConsoDerelictionResponse;
import org.ta.pddserver.utils.PddHttpTool; import org.ta.pddserver.utils.PddHttpTool;
import org.ta.pddserver.utils.PddJYPriceTool;
import org.ta.pddserver.utils.PddSignTool; import org.ta.pddserver.utils.PddSignTool;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
...@@ -91,8 +92,8 @@ public class CommonTest { ...@@ -91,8 +92,8 @@ public class CommonTest {
*/ */
@Test @Test
public void receive() { public void receive() {
String LogisticsOrderCode = "PC25102914698518937718059"; String LogisticsOrderCode = "PC25110314221207142437527";
String mailNo = "TT3713660160898"; String mailNo = "TT773010635902734";
String expressCode = "STO"; String expressCode = "STO";
String action = "warehouse_sign"; String action = "warehouse_sign";
PddServiceConsoFirstBizActionNotifyRequest notifyRequest = new PddServiceConsoFirstBizActionNotifyRequest(); PddServiceConsoFirstBizActionNotifyRequest notifyRequest = new PddServiceConsoFirstBizActionNotifyRequest();
...@@ -193,8 +194,9 @@ public class CommonTest { ...@@ -193,8 +194,9 @@ public class CommonTest {
@Test @Test
public void inBound() { public void inBound() {
String LogisticsOrderCode = "PC25102914698518937718059"; String LogisticsOrderCode = "PC25110314221207142437527";
String mailNo = "TT3713660160898"; String mailNo = "TT773010635902734";
// String mailNo = "773608936457954";
String expressCode = "STO"; String expressCode = "STO";
PddServiceConsoInboundRequest notifyRequest = new PddServiceConsoInboundRequest(); PddServiceConsoInboundRequest notifyRequest = new PddServiceConsoInboundRequest();
...@@ -203,11 +205,12 @@ public class CommonTest { ...@@ -203,11 +205,12 @@ public class CommonTest {
notifyRequest.setProviderCode(PROVIDER_CODE); notifyRequest.setProviderCode(PROVIDER_CODE);
notifyRequest.setLogisticsOrderCode(LogisticsOrderCode); notifyRequest.setLogisticsOrderCode(LogisticsOrderCode);
notifyRequest.setExecuteTime(getNowString()); notifyRequest.setExecuteTime(getNowString());
// notifyRequest.setExecuteTime("2025-05-04 00:00:00");
notifyRequest.setTimeZone("UTC+8"); notifyRequest.setTimeZone("UTC+8");
notifyRequest.setStatus("FULL_INBOUND"); notifyRequest.setStatus("FULL_INBOUND");
// notifyRequest.setStatus("PART_INBOUND"); // notifyRequest.setStatus("PART_INBOUND");
notifyRequest.setPackageQuantity(1L); notifyRequest.setPackageQuantity(3L);
notifyRequest.setPackageInfo(new PddServiceConsoInboundRequest.PackageInfo()); notifyRequest.setPackageInfo(new PddServiceConsoInboundRequest.PackageInfo());
notifyRequest.getPackageInfo().setMailNo(mailNo); notifyRequest.getPackageInfo().setMailNo(mailNo);
...@@ -215,8 +218,8 @@ public class CommonTest { ...@@ -215,8 +218,8 @@ public class CommonTest {
notifyRequest.getPackageInfo().setLength(30L); notifyRequest.getPackageInfo().setLength(30L);
notifyRequest.getPackageInfo().setWidth(30L); notifyRequest.getPackageInfo().setWidth(30L);
notifyRequest.getPackageInfo().setHeight(30L); notifyRequest.getPackageInfo().setHeight(30L);
notifyRequest.getPackageInfo().setWeight(300L); notifyRequest.getPackageInfo().setWeight(400L);
notifyRequest.getPackageInfo().setActualWeight(300L); notifyRequest.getPackageInfo().setActualWeight(400L);
notifyRequest.getPackageInfo().setGoodsType("NORMAL"); notifyRequest.getPackageInfo().setGoodsType("NORMAL");
notifyRequest.setResult(new PddServiceConsoInboundRequest.Result()); notifyRequest.setResult(new PddServiceConsoInboundRequest.Result());
...@@ -243,8 +246,8 @@ public class CommonTest { ...@@ -243,8 +246,8 @@ public class CommonTest {
*/ */
@Test @Test
public void beginPick() { public void beginPick() {
String LogisticsOrderCode = "PP25102913743895347818059"; String LogisticsOrderCode = "PP25110308781194855037527";
String mailNo = "773833357957029"; String mailNo = "773554917225751";
String expressCode = "STO"; String expressCode = "STO";
String action = "begin_pick"; String action = "begin_pick";
PddServiceConsoCoBizActionNotifyRequest notifyRequest = new PddServiceConsoCoBizActionNotifyRequest(); PddServiceConsoCoBizActionNotifyRequest notifyRequest = new PddServiceConsoCoBizActionNotifyRequest();
...@@ -293,8 +296,8 @@ public class CommonTest { ...@@ -293,8 +296,8 @@ public class CommonTest {
*/ */
@Test @Test
public void finishPick() { public void finishPick() {
String LogisticsOrderCode = "PP25102913743895347818059"; String LogisticsOrderCode = "PP25110308781194855037527";
String mailNo = "773833357957029"; String mailNo = "773554917225751";
String expressCode = "STO"; String expressCode = "STO";
String action = "finish_pick"; String action = "finish_pick";
PddServiceConsoCoBizActionNotifyRequest notifyRequest = new PddServiceConsoCoBizActionNotifyRequest(); PddServiceConsoCoBizActionNotifyRequest notifyRequest = new PddServiceConsoCoBizActionNotifyRequest();
...@@ -321,11 +324,11 @@ public class CommonTest { ...@@ -321,11 +324,11 @@ public class CommonTest {
notifyRequest.setPackageInfos(new ArrayList<>()); notifyRequest.setPackageInfos(new ArrayList<>());
PddServiceConsoCoBizActionNotifyRequest.PackageInfo packageInfo = new PddServiceConsoCoBizActionNotifyRequest.PackageInfo(); PddServiceConsoCoBizActionNotifyRequest.PackageInfo packageInfo = new PddServiceConsoCoBizActionNotifyRequest.PackageInfo();
notifyRequest.getPackageInfos().add(packageInfo); notifyRequest.getPackageInfos().add(packageInfo);
packageInfo.setWeight(280L); packageInfo.setWeight(1000L);
packageInfo.setWidth(28L); packageInfo.setWidth(40L);
packageInfo.setHeight(28L); packageInfo.setLength(30L);
packageInfo.setLength(28L); packageInfo.setHeight(20L);
packageInfo.setActualWeight(280L); packageInfo.setActualWeight(1000L);
packageInfo.setConsoType("SEA"); packageInfo.setConsoType("SEA");
packageInfo.setGoodsType("NORMAL"); packageInfo.setGoodsType("NORMAL");
} }
...@@ -355,9 +358,9 @@ public class CommonTest { ...@@ -355,9 +358,9 @@ public class CommonTest {
@Test @Test
public void outBound() { public void outBound() {
String mailNo = "773467488920323"; String mailNo = "BK-773448654218243";
String expressCode = "STO"; String expressCode = "KR_JD";
String orderCode = "PP25102914698518937618059"; String orderCode = "PP25110314698518937737527";
// String segmentCode = "RETURNSELLER"; // String segmentCode = "RETURNSELLER";
String segmentCode = "SENDTORECEVER"; String segmentCode = "SENDTORECEVER";
...@@ -375,10 +378,10 @@ public class CommonTest { ...@@ -375,10 +378,10 @@ public class CommonTest {
packageInfo.setOutboundMailNo(mailNo); packageInfo.setOutboundMailNo(mailNo);
packageInfo.setExpressCode(expressCode); packageInfo.setExpressCode(expressCode);
packageInfo.setPackageType("2"); packageInfo.setPackageType("2");
packageInfo.setLength(28L); packageInfo.setLength(30L);
packageInfo.setWidth(28L); packageInfo.setWidth(30L);
packageInfo.setHeight(28L); packageInfo.setHeight(20L);
packageInfo.setWeight(280L); packageInfo.setWeight(1000L);
notifyRequest.setSenderDetail(new PddServiceConsoOutboundRequest.SenderDetail()); notifyRequest.setSenderDetail(new PddServiceConsoOutboundRequest.SenderDetail());
notifyRequest.getSenderDetail().setName("海际集货仓"); notifyRequest.getSenderDetail().setName("海际集货仓");
...@@ -390,13 +393,13 @@ public class CommonTest { ...@@ -390,13 +393,13 @@ public class CommonTest {
notifyRequest.getSenderDetail().setDetailAddress("山东省临沂市兰山区横九路与纵十路交汇兰山财金智慧云仓五期二层二号仓"); notifyRequest.getSenderDetail().setDetailAddress("山东省临沂市兰山区横九路与纵十路交汇兰山财金智慧云仓五期二层二号仓");
notifyRequest.setReceiverDetail(new PddServiceConsoOutboundRequest.ReceiverDetail()); notifyRequest.setReceiverDetail(new PddServiceConsoOutboundRequest.ReceiverDetail());
notifyRequest.getReceiverDetail().setName("nanjiexi"); notifyRequest.getReceiverDetail().setName("김명상");
notifyRequest.getReceiverDetail().setTelePhone("01099999999"); notifyRequest.getReceiverDetail().setTelePhone("01012345678");
notifyRequest.getReceiverDetail().setCountry("KR"); notifyRequest.getReceiverDetail().setCountry("KR");
notifyRequest.getReceiverDetail().setProvince("서울특별시"); notifyRequest.getReceiverDetail().setProvince("서울특별시");
notifyRequest.getReceiverDetail().setCity("강북구"); notifyRequest.getReceiverDetail().setCity("강북구");
notifyRequest.getReceiverDetail().setDistrict("우이동"); notifyRequest.getReceiverDetail().setDistrict("강북구");
notifyRequest.getReceiverDetail().setDetailAddress("서울특별시测试地址"); notifyRequest.getReceiverDetail().setDetailAddress("护照1号");
notifyRequest.setResult(new PddServiceConsoOutboundRequest.Result()); notifyRequest.setResult(new PddServiceConsoOutboundRequest.Result());
notifyRequest.getResult().setCode(0); notifyRequest.getResult().setCode(0);
...@@ -425,8 +428,8 @@ public class CommonTest { ...@@ -425,8 +428,8 @@ public class CommonTest {
*/ */
@Test @Test
public void finishUnpack() { public void finishUnpack() {
String LogisticsOrderCode = "PP25102914698518937618059"; String LogisticsOrderCode = "PP25110314698518937737527";
String mailNo = "773467488920323"; String mailNo = "773448654218243";
String expressCode = "STO"; String expressCode = "STO";
String action = "finish_unpack"; String action = "finish_unpack";
PddServiceConsoCoBizActionNotifyRequest notifyRequest = new PddServiceConsoCoBizActionNotifyRequest(); PddServiceConsoCoBizActionNotifyRequest notifyRequest = new PddServiceConsoCoBizActionNotifyRequest();
...@@ -453,13 +456,13 @@ public class CommonTest { ...@@ -453,13 +456,13 @@ public class CommonTest {
notifyRequest.setPackageInfos(new ArrayList<>()); notifyRequest.setPackageInfos(new ArrayList<>());
PddServiceConsoCoBizActionNotifyRequest.PackageInfo packageInfo = new PddServiceConsoCoBizActionNotifyRequest.PackageInfo(); PddServiceConsoCoBizActionNotifyRequest.PackageInfo packageInfo = new PddServiceConsoCoBizActionNotifyRequest.PackageInfo();
notifyRequest.getPackageInfos().add(packageInfo); notifyRequest.getPackageInfos().add(packageInfo);
packageInfo.setWeight(280L); packageInfo.setWeight(1000L);
packageInfo.setWidth(28L); packageInfo.setWidth(30L);
packageInfo.setHeight(28L); packageInfo.setHeight(30L);
packageInfo.setLength(28L); packageInfo.setLength(20L);
packageInfo.setActualWeight(280L); packageInfo.setActualWeight(1000L);
packageInfo.setConsoType("SEA"); packageInfo.setConsoType("SEA");
packageInfo.setGoodsType("NORMAL"); packageInfo.setGoodsType("SPECIAL");
} }
notifyRequest.setResult(notifyResult); notifyRequest.setResult(notifyResult);
...@@ -485,9 +488,9 @@ public class CommonTest { ...@@ -485,9 +488,9 @@ public class CommonTest {
*/ */
@Test @Test
public void dereliction() { public void dereliction() {
String mailNo = "TT3713660160898"; String mailNo = "TT773010635902734";
String expressCode = "STO"; String expressCode = "STO";
String dereRecogCode = "51029HYX06800"; String dereRecogCode = "51103HHF52832";
PddServiceConsoDerelictionRequest notifyRequest = new PddServiceConsoDerelictionRequest(); PddServiceConsoDerelictionRequest notifyRequest = new PddServiceConsoDerelictionRequest();
notifyRequest.setProviderCode(PROVIDER_CODE); notifyRequest.setProviderCode(PROVIDER_CODE);
notifyRequest.setExecuteTime(getNowString()); notifyRequest.setExecuteTime(getNowString());
...@@ -553,4 +556,18 @@ public class CommonTest { ...@@ -553,4 +556,18 @@ public class CommonTest {
} }
@Test
public void testFee() {
PddJYPriceTool.FeeResult result = PddJYPriceTool.getTotalFee("NORMAL",
30,
30,
30,
1300,
true,
"2025-11-03"
);
log.info("result:{}", JSON.toJSONString(result));
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment