Commit eaa473a6 authored by Allen Chen's avatar Allen Chen

commit

parent daf19865
...@@ -94,14 +94,9 @@ public class PddOpenController { ...@@ -94,14 +94,9 @@ public class PddOpenController {
if (StringUtils.isEmpty(pdd_sign)) { if (StringUtils.isEmpty(pdd_sign)) {
log.error("pdd_sign is empty"); log.error("pdd_sign is empty");
} }
log.info("pdd_sign:{}", pdd_sign);
// log.info("PDD orderCreate, type={}", requestParam.getType());
// log.info("target_client_id = {}, client_id = {}, request_id={}, sign={}, timestamp = {}, type={}",
// requestParam.getTarget_client_id(), requestParam.getClient_id(), requestParam.getRequest_id(), requestParam.getSign(), requestParam.getTimestamp(), requestParam.getType()
// );
String body = getStringFromRequest(request); String body = getStringFromRequest(request);
log.info("requestString = {}", body);
try {
if (PddSignTool.verifySignFromBody(body, "a5aba84483d8387030899f01276b06a194942470", pdd_sign)) { if (PddSignTool.verifySignFromBody(body, "a5aba84483d8387030899f01276b06a194942470", pdd_sign)) {
log.info("验签成功"); log.info("验签成功");
} }
...@@ -110,21 +105,18 @@ public class PddOpenController { ...@@ -110,21 +105,18 @@ public class PddOpenController {
PddServiceConsoOrderCreateRequest createParam = JSON.parseObject(body, PddServiceConsoOrderCreateRequest.class); PddServiceConsoOrderCreateRequest createParam = JSON.parseObject(body, PddServiceConsoOrderCreateRequest.class);
OrderCreate(createParam); OrderCreate(createParam);
log.info("pdd service conso.order.create 集运单创建接口"); log.info("pdd service conso.order.create 集运单创建接口");
// todo 不需特殊回复,但是code区分状态码
} }
break; break;
case "pdd.service.conso.outbound.notice": { case "pdd.service.conso.outbound.notice": {
PddServiceConsoOutboundNoticeRequest noticeParam = JSON.parseObject(body, PddServiceConsoOutboundNoticeRequest.class); PddServiceConsoOutboundNoticeRequest noticeParam = JSON.parseObject(body, PddServiceConsoOutboundNoticeRequest.class);
OutboundNotice(noticeParam); OutboundNotice(noticeParam);
log.info("pdd.service.conso.outbound.notice 出库通知"); log.info("pdd.service.conso.outbound.notice 出库通知");
// todo 不需特殊回复,但是code区分状态码
} }
break; break;
case "pdd.service.conso.order.update": { case "pdd.service.conso.order.update": {
PddServiceConsoOrderUpdateRequest updateRequest = JSON.parseObject(body, PddServiceConsoOrderUpdateRequest.class); PddServiceConsoOrderUpdateRequest updateRequest = JSON.parseObject(body, PddServiceConsoOrderUpdateRequest.class);
OrderUpdate(updateRequest); OrderUpdate(updateRequest);
log.info("pdd.service.conso.order.update 集运单更新"); log.info("pdd.service.conso.order.update 集运单更新");
// todo 不需特殊回复,但是code区分状态码
} }
break; break;
case "pdd.service.conso.reverse.notify": { case "pdd.service.conso.reverse.notify": {
...@@ -138,7 +130,6 @@ public class PddOpenController { ...@@ -138,7 +130,6 @@ public class PddOpenController {
PddServiceConsoFeeQueryRequest queryRequest = JSON.parseObject(body, PddServiceConsoFeeQueryRequest.class); PddServiceConsoFeeQueryRequest queryRequest = JSON.parseObject(body, PddServiceConsoFeeQueryRequest.class);
FeeQuery(queryRequest); FeeQuery(queryRequest);
log.info("pdd.service.conso.fee.query 集运费用查询"); log.info("pdd.service.conso.fee.query 集运费用查询");
// todo 回复 PddServiceConsoFeeQueryResponse
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("success", true); jsonObject.put("success", true);
jsonObject.put("freightFee", 1200); jsonObject.put("freightFee", 1200);
...@@ -200,6 +191,10 @@ public class PddOpenController { ...@@ -200,6 +191,10 @@ public class PddOpenController {
// return JsonResponse.generateCommonFailedResponse(999, "UNKNOWN API"); // return JsonResponse.generateCommonFailedResponse(999, "UNKNOWN API");
} }
} }
} catch (Exception e) {
e.printStackTrace();
}
log.info("request_body = {}", JSON.toJSON(requestParam)); log.info("request_body = {}", JSON.toJSON(requestParam));
return JsonResponse.generateOpenCommonSuccessResponse(); return JsonResponse.generateOpenCommonSuccessResponse();
} }
......
...@@ -51,5 +51,29 @@ public class CollectMailDetailEntity { ...@@ -51,5 +51,29 @@ public class CollectMailDetailEntity {
@TableField(value = "consoWarehouseCode") @TableField(value = "consoWarehouseCode")
private String consoWarehouseCode; private String consoWarehouseCode;
/**
* 状态 长
*/
@TableField(value = "length")
private Integer length;
/**
* 状态 宽
*/
@TableField(value = "width")
private Integer width;
/**
* 状态 高
*/
@TableField(value = "height")
private Integer height;
/**
* 状态 重
*/
@TableField(value = "weight")
private Integer weight;
} }
...@@ -51,5 +51,29 @@ public class CollectOutMailDetailEntity { ...@@ -51,5 +51,29 @@ public class CollectOutMailDetailEntity {
@TableField(value = "consoWarehouseCode") @TableField(value = "consoWarehouseCode")
private String consoWarehouseCode; private String consoWarehouseCode;
/**
* 状态 长
*/
@TableField(value = "length")
private Integer length;
/**
* 状态 宽
*/
@TableField(value = "width")
private Integer width;
/**
* 状态 高
*/
@TableField(value = "height")
private Integer height;
/**
* 状态 重
*/
@TableField(value = "weight")
private Integer weight;
} }
...@@ -43,4 +43,28 @@ public class LogOrderMailDetailEntity { ...@@ -43,4 +43,28 @@ public class LogOrderMailDetailEntity {
@TableField(value = "mailNo") @TableField(value = "mailNo")
private String mailNo; private String mailNo;
/**
* 状态 长
*/
@TableField(value = "length")
private Integer length;
/**
* 状态 宽
*/
@TableField(value = "width")
private Integer width;
/**
* 状态 高
*/
@TableField(value = "height")
private Integer height;
/**
* 状态 重
*/
@TableField(value = "weight")
private Integer weight;
} }
package org.ta.pddserver.utils; package org.ta.pddserver.utils;
import lombok.Data;
public class PddJYPriceTool { public class PddJYPriceTool {
public static int 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) {
if (international) { if (international) {
// 国际件 // 国际件
return 0; int exchange = 1;
// return PddOverseaPriceTool.FreightCostCalculation(type, length, width, height, weight); return PddOverseaPriceTool.FreightCostCalculation(type, length, width, height, weight, exchange);
} else { } else {
// 国内件 属于退件 // 国内件 属于退件
return PddNationalPriceTool.FreightCostCalculation(length, width, height, weight); return PddNationalPriceTool.FreightCostCalculation(length, width, height, weight);
} }
} }
@Data
public static class FeeResult{
int weight;
int rentFee;
int freightFee;
}
} }
...@@ -33,11 +33,10 @@ public class PddNationalPriceTool { ...@@ -33,11 +33,10 @@ public class PddNationalPriceTool {
/* /*
* 根据类型、重量(g) 计算运费 * 根据类型、重量(g) 计算运费
* */ * */
public static int FreightCostCalculation(int length, int width, int height, int weight) { public static PddJYPriceTool.FeeResult FreightCostCalculation(int length, int width, int height, int weight) {
PddJYPriceTool.FeeResult result = new PddJYPriceTool.FeeResult();
int price = initalPrice; int price = initalPrice;
if (weight < initialWeight) { if (weight > initialWeight) {
return price;
}
int pw = weight - initialWeight; int pw = weight - initialWeight;
int pc = pw / excessWeight; int pc = pw / excessWeight;
if (pw % excessWeight != 0) { if (pw % excessWeight != 0) {
...@@ -45,6 +44,10 @@ public class PddNationalPriceTool { ...@@ -45,6 +44,10 @@ public class PddNationalPriceTool {
} }
price = price + pc * excessPrice; price = price + pc * excessPrice;
log.info("续重数量:{}", pc); log.info("续重数量:{}", pc);
return price; }
result.setRentFee(0);
result.setFreightFee(price);
result.setWeight(weight);
return result;
} }
} }
package org.ta.pddserver.utils; package org.ta.pddserver.utils;
import java.util.HashMap;
import java.util.Map;
public class PddOverseaPriceTool { public class PddOverseaPriceTool {
//首重重量 // 首重重量
private static int initialWeight = 1000; private static int initialWeight = 1000;
//上限重量 // 基础上限重量
private static int maxWeight = 20000; private static int baseMaxWeight = 20000;
// 最大重量
private static int maxWeight = 300000;
// 普货首重价格 // 普货首重价格
private static int gInitalPrice = 1850; private static int gInitalPrice = 1850;
//特货首重价格 // 特货首重价格
private static int sInitalPrice = 2800; private static int sInitalPrice = 2800;
//超重计费标准 //超重计费标准
...@@ -22,56 +21,72 @@ public class PddOverseaPriceTool { ...@@ -22,56 +21,72 @@ public class PddOverseaPriceTool {
//超重价格 //超重价格
private static int excessPrice = 175; private static int excessPrice = 175;
//标椎边长度 //标椎边长度
private static int standard = 100; private static int baseSingleLength = 100;
//标准三边之和 //标准三边之和
private static int maxStandard = 160; private static int baseSumLength = 160;
//最大单边长度
private static int maxSingleLength = 250;
//最大三边之和
private static int maxSumLength = 250;
/* /*
* 根据类型、重量(g) 计算运费 * 根据类型、重量(g) 计算运费
* */ * */
public static Map 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) {
Map map = new HashMap();
int price = 0;
boolean key = true;
int excess = 0;
int max = length + width + height; int max = length + width + height;
if (length > maxSingleLength || width > maxSingleLength || height > maxSingleLength || max > maxSumLength) {
//三边各超100或者和超160
return null;
}
if (weight > maxWeight) {
//超重无法计算
return null;
}
PddJYPriceTool.FeeResult result = new PddJYPriceTool.FeeResult();
int price = 0;
if (exchange == 2) {
// 改派
price = 2400;
}
if (exchange == 3) {
price = 1200;
}
//判断边长是否符合标准 int compWeight = weight;
if (length > standard || width > standard || height > standard || max > maxStandard) { if (weight > baseMaxWeight || length > baseSingleLength || width > baseSingleLength || height > baseSingleLength || max > baseSumLength) {
//三边各超100或者和超160 //三边各超100或者和超160
key = false; int newWeight = length * width * height / 6000 + 1;
} else { compWeight = Math.max(compWeight, newWeight);
}
result.setWeight(compWeight);
int excess = 0;
// 判断重量是否超重 // 判断重量是否超重
if (weight > maxWeight) {
//超重无法计算
key = false;
} else {
//分析重量 //分析重量
if (weight > initialWeight) { if (compWeight > initialWeight) {
//计算超出重量 //计算超出重量
weight = weight - initialWeight; compWeight = compWeight - initialWeight;
excess = excessPrice * ((int) Math.ceil(weight / excessWeight)); excess = excessPrice * ((int) Math.ceil(compWeight / excessWeight));
}
} }
if (key) {
//计算价格 //计算价格
if (type.equals("NORMAL")) { if (type.equals("NORMAL")) {
//普货 //普货
price = gInitalPrice + excess; price = price + gInitalPrice + excess;
} else { } else {
price = sInitalPrice + excess; price = price + sInitalPrice + excess;
}
}
} }
map.put("price", price); result.setRentFee(0);
map.put("key", key); result.setFreightFee(price);
return map; return 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