express refactor
This commit is contained in:
6
pom.xml
6
pom.xml
@@ -99,6 +99,12 @@
|
||||
<version>1.1.2-offical</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.kuaidi100-api</groupId>
|
||||
<artifactId>sdk</artifactId>
|
||||
<version>1.0.12</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -1,213 +0,0 @@
|
||||
package com.peanut.common.Interface;
|
||||
|
||||
|
||||
import com.peanut.common.utils.HttpClientUtils;
|
||||
import com.peanut.common.utils.KdUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @技术QQ群: 可登录官网https://www.kdniao.com/右侧查看技术群号
|
||||
* @see: https://kdniao.com/api-eorder
|
||||
* @copyright: 深圳市快金数据技术服务有限公司
|
||||
* ID和Key请到官网申请:https://kdniao.com/reg
|
||||
* <p>
|
||||
* <p>
|
||||
* 电子面单接口
|
||||
* 此接口用于向快递/快运公司下发订单并获取快递单号,返回电子面单html模板,通知快递员上门取件。该功能支持情况需查看技术文档。
|
||||
* 正式地址:https://api.kdniao.com/api/EOrderService
|
||||
* <p>
|
||||
* <p>
|
||||
* 系统级参数
|
||||
* RequestData String R 请求内容为JSON格式 详情可参考接口技术文档:https://www.kdniao.com/documents
|
||||
* EBusinessID String R 用户ID
|
||||
* RequestType String R 请求接口指令
|
||||
* DataSign String R 数据内容签名,加密方法为:把(请求内容(未编码)+ApiKey)进行MD5加密--32位小写,然后Base64编码,最后进行URL(utf-8)编码
|
||||
* DataType String R DataType=2,请求、返回数据类型均为JSON格式
|
||||
* <p>
|
||||
* 应用级参数
|
||||
* R-必填(Required),O-可选(Optional),C-报文中该参数在一定条件下可选(Conditional)
|
||||
* Callback String(50) O 用户自定义回传字段
|
||||
* CustomerName String(50) C 电子面单客户号,需要下载《快递鸟电子面单客户号参数对照表.xlsx》,参考对应字段传值 https://www.kdniao.com/documents
|
||||
* CustomerPwd String(50) C 同上
|
||||
* SendSite String(50) C 同上
|
||||
* SendStaff String(50) C 同上
|
||||
* MonthCode String(20) C 同上
|
||||
* CustomArea String(500) O 商家自定义区域,需查看技术文档说明
|
||||
* WareHouseID String(30) C 发货仓编码(ShipperCode为JD或JDKY时必填)
|
||||
* TransType Int(2) O 京东(ShipperCode为JD或JDKY)的产品类型,需查看技术文档说明
|
||||
* ShipperCode String(10) R 快递公司编码详细编码参考《快递鸟接口支持快递公司编码.xlsx》 https://www.kdniao.com/documents
|
||||
* LogisticCode String(30) O 快递单号(仅宅急送可用)
|
||||
* OrderCode String(30) R 订单编号(自定义,不可重复)
|
||||
* ThrOrderCode String(50) C 京东商城的订单号(ShipperCode为JD且ExpType为1时必填)
|
||||
* PayType Int(1) R 运费支付方式:1-现付,2-到付,3-月结
|
||||
* ExpType String(2) R 详细快递类型参考《快递公司快递业务类型.xlsx》 https://www.kdniao.com/documents
|
||||
* IsReturnSignBill Int(1) O 是否要求签回单 0-不要求,1-要求
|
||||
* Receiver.Company String(30) O 收件人公司
|
||||
* Receiver.Name String(30) R 收件人
|
||||
* Receiver.Tel String(20) R 电话(电话与手机,必填一个)
|
||||
* Receiver.Mobile String(20) R 手机(电话与手机,必填一个)
|
||||
* Receiver.PostCode String(10) C 收件地邮编(ShipperCode为EMS、YZPY、YZBK时必填)
|
||||
* Receiver.ProvinceName String(20) R 收件省(如广东省,不要缺少“省”;如是直辖市,请直接传北京、上海等;如是自治区,请直接传广西壮族自治区等)
|
||||
* Receiver.CityName String(20) R 收件市(如深圳市,不要缺少“市;如是市辖区,请直接传北京市、上海市等”)
|
||||
* Receiver.ExpAreaName String(20) R 收件区/县(如福田区,不要缺少“区”或“县”)
|
||||
* Receiver.Address String(100) R 收件人详细地址(不用传省市区)
|
||||
* Sender.Company String(30) O 发件人公司
|
||||
* Sender.Name String(30) R 发件人
|
||||
* Sender.Tel String(20) R 电话(电话与手机,必填一个)
|
||||
* Sender.Mobile String(20) R 手机(电话与手机,必填一个)
|
||||
* Sender.PostCode String(10) C 发件地邮编(ShipperCode为EMS、YZPY、YZBK时必填)
|
||||
* Sender.ProvinceName String(20) R 发件省(如广东省,不要缺少“省”;如是直辖市,请直接传北京、上海等;如是自治区,请直接传广西壮族自治区等)
|
||||
* Sender.CityName String(20) R 发件市(如深圳市,不要缺少“市;如是市辖区,请直接传北京市、上海市等”)
|
||||
* Sender.ExpAreaName String(20) R 发件区/县(如福田区,不要缺少“区”或“县”)
|
||||
* Sender.Address String(100) R 发件人详细地址(不用传省市区)
|
||||
* IsNotice Int(1) O 是否通知快递员上门揽件 0-通知,1-不通知,不填则默认为1
|
||||
* StartDate String(32) O 上门揽件时间段,格式:YYYY-MM-DD HH24:MM:SS
|
||||
* EndDate String(32) O 上门揽件时间段,格式:YYYY-MM-DD HH24:MM:SS
|
||||
* Weight Double(10,3) C 包裹总重量kg 1、当为快运的订单时必填;2、ShipperCode为JD时必填;
|
||||
* Quantity Int(2) R 包裹数(最多支持300件)一个包裹对应一个运单号,如果是大于1个包裹,返回则按照子母件的方式返回母运单号和子运单号
|
||||
* Volume Double(20,3) C 包裹总体积m3 1、当为快运的订单时必填;2、ShipperCode为JD时必填;
|
||||
* Remark String(60) O 备注
|
||||
* AddService.Name String(20) C 增值服务名称(数组形式,可以有多个增值服务)
|
||||
* AddService.Value String(30) C 增值服务值
|
||||
* AddService.CustomerID String(30) O 客户标识
|
||||
* Commodity.GoodsName String(100) R 商品名称(数组形式)
|
||||
* IsReturnPrintTemplate String(1) O 是否返回电子面单模板:0-不需要,1-需要
|
||||
* IsSendMessage Int(1) O 是否订阅短信:0-不需要,1-需要
|
||||
* IsSubscribe String(1) O 是否订阅轨迹推送 0-不订阅,1-订阅,不填默认为1
|
||||
* TemplateSize String(10) O 模板规格,需查看技术文档说明
|
||||
* PackingType Int(2) C 包装类型(快运字段),需查看技术文档说明
|
||||
* DeliveryMethod Int(1) C 送货方式/派送类型/配送方式(快运字段),需查看技术文档说明
|
||||
* CurrencyCode String(10) C 货物单价的币种:CNY: 人民币 HKD: 港币 NTD: 新台币 MOP: 澳门元 (ShipperCode为SF且收件地址为港澳台地区,必填)
|
||||
* Dutiable.DeclaredValue Number(15,3) C 申报价值:订单货物总声明价值,包含子母件,精确到小数点后3位 (ShipperCode为SF且收件地址为港澳台地区,必填)
|
||||
*/
|
||||
|
||||
public class KdApiEOrder {
|
||||
|
||||
//用户ID,快递鸟提供,注意保管,不要泄漏
|
||||
private static String EBusinessID = "1788532";//即用户ID
|
||||
// private static String EBusinessID="test1788532";//即用户ID
|
||||
//API key,快递鸟提供,注意保管,不要泄漏
|
||||
private static String ApiKey = "f4342e6c-5cfa-458f-997b-f973eb29eb1d";//即API key
|
||||
// private static String ApiKey="34f033ae-9c73-4b9a-899e-943a65fd86bf";//即API key
|
||||
|
||||
|
||||
// 电子面单
|
||||
private static String OnlineReqURL = "https://api.kdniao.com/api/EOrderService";
|
||||
|
||||
|
||||
// 取消电子面单
|
||||
|
||||
private static String ReqURL = "https://api.kdniao.com/api/EOrderService";
|
||||
|
||||
|
||||
// 物流信息跟踪
|
||||
private String TrackReqURL = "https://api.kdniao.com/api/dist";
|
||||
// private static String TrackReqURL="http://sandboxapi.kdniao.com:8080/kdniaosandbox/gateway/exterfaceInvoke.json";
|
||||
|
||||
// 即时查询物流信息
|
||||
private static String QueryReqURL = "https://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx";
|
||||
|
||||
/**
|
||||
* 电子面单取消接口
|
||||
* 此接口用于取消“电子面单接口”下单成功的订单,回收快递单号。
|
||||
* <p>
|
||||
* 应用级参数
|
||||
* R-必填(Required),O-可选(Optional),C-报文中该参数在一定条件下可选(Conditional)
|
||||
* ShipperCode String(10) R 快递公司编码
|
||||
* OrderCode String(30) R 订单编号
|
||||
* ExpNo String(30) R 快递单号
|
||||
* CustomerName String(50) R 电子面单客户号
|
||||
* CustomerPwd String(30) R 电子面单密码(顺丰不需要)
|
||||
*/
|
||||
@RequestMapping("/cancel")
|
||||
public static String cancelOrderByJson(@RequestParam Map<String, Object> param) throws Exception {
|
||||
|
||||
// 组装应用级参数
|
||||
String RequestData = "{" +
|
||||
"'ShipperCode':" + param.get("ShipperCode") + "," +
|
||||
"'OrderCode': " + param.get("orderSn") + "," +
|
||||
"'ExpNo': '" + param.get("ExpNo") + "'," +
|
||||
"}";
|
||||
// 组装系统级参数
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("RequestData", KdUtils.urlEncoder(RequestData, "UTF-8"));
|
||||
params.put("EBusinessID", EBusinessID);
|
||||
params.put("RequestType", "1147");
|
||||
String dataSign = KdUtils.encrypt(RequestData, ApiKey, "UTF-8");
|
||||
params.put("DataSign", KdUtils.urlEncoder(dataSign, "UTF-8"));
|
||||
params.put("DataType", "2");
|
||||
// 以form表单形式提交post请求,post请求体中包含了应用级参数和系统级参数
|
||||
String result = HttpClientUtils.kdSendPost(ReqURL, params);
|
||||
|
||||
//根据公司业务处理返回的信息......
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 即时查询接口(增值版)
|
||||
* 此接口用于向快递公司实时查询物流轨迹信息。
|
||||
* <p>
|
||||
* 应用级参数
|
||||
* R-必填(Required),O-可选(Optional),C-报文中该参数在一定条件下可选(Conditional)
|
||||
* OrderCode String(30) O 订单编号
|
||||
* CustomerName String(50) C ShipperCode为SF时必填,对应寄件人/收件人手机号后四位;ShipperCode为其他快递时,可不填或保留字段,不可传值
|
||||
* ShipperCode String(10) R 快递公司编码 详细编码参考《快递鸟接口支持快递公司编码.xlsx》
|
||||
* LogisticCode String(30) R 快递单号
|
||||
*/
|
||||
@RequestMapping("/queryOrder")
|
||||
public static String queryOrderOnlineByJson(@RequestParam Map<String, Object> param) throws Exception {
|
||||
// 组装应用级参数
|
||||
String RequestData = "{" +
|
||||
"'ShipperCode': '" + param.get("ShipperCode") + "'," +
|
||||
"'LogisticCode': '" + param.get("LogisticCode") + "'," +
|
||||
"}";
|
||||
// 组装系统级参数
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("RequestData", KdUtils.urlEncoder(RequestData, "UTF-8"));
|
||||
params.put("EBusinessID", EBusinessID);
|
||||
params.put("RequestType", "8001");//在途监控即时查询接口指令8001/地图版即时查询接口指令8003
|
||||
String dataSign = KdUtils.encrypt(RequestData, ApiKey, "UTF-8");
|
||||
params.put("DataSign", KdUtils.urlEncoder(dataSign, "UTF-8"));
|
||||
params.put("DataType", "2");
|
||||
// 以form表单形式提交post请求,post请求体中包含了应用级参数和系统级参数
|
||||
String result = HttpClientUtils.kdSendPost(QueryReqURL, params);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 物流跟踪接口(增值版)
|
||||
* 此接口用于向快递鸟订阅物流轨迹信息。
|
||||
* <p>
|
||||
* 应用级参数
|
||||
* R-必填(Required),O-可选(Optional),C-报文中该参数在一定条件下可选(Conditional)
|
||||
* Callback String(50) O 用户自定义回传字段
|
||||
* ShipperCode String(10) R 快递公司编码 详细编码参考《快递鸟接口支持快递公司编码.xlsx》
|
||||
* LogisticCode String(30) R 快递单号
|
||||
* CustomerName String(50) C ShipperCode为SF时必填,对应寄件人/收件人手机号后四位;ShipperCode为其他快递时,可不填或保留字段,不可传值
|
||||
*/
|
||||
@RequestMapping("/track")
|
||||
public String trackOrderByJson(@RequestParam Map<String, Object> param) throws Exception {
|
||||
// 组装应用级参数
|
||||
String RequestData = "{" +
|
||||
"'Callback':'OrderCode'," +
|
||||
"'ShipperCode':'" + param.get("ShipperCode") + "'," +
|
||||
"'LogisticCode':'" + param.get("LogisticCode") + "'," +
|
||||
"}";
|
||||
// 组装系统级参数
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("RequestData", KdUtils.urlEncoder(RequestData, "UTF-8"));
|
||||
params.put("EBusinessID", EBusinessID);
|
||||
params.put("RequestType", "8008");//在途监控订阅接口指令8008/地图版订阅接口指令8005
|
||||
String dataSign = KdUtils.encrypt(RequestData, ApiKey, "UTF-8");
|
||||
params.put("DataSign", KdUtils.urlEncoder(dataSign, "UTF-8"));
|
||||
params.put("DataType", "2");
|
||||
// 以form表单形式提交post请求,post请求体中包含了应用级参数和系统级参数
|
||||
String result = HttpClientUtils.kdSendPost(TrackReqURL, params);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.peanut.modules.book.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.peanut.modules.book.entity.ExpressOrder;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface ExpressOrderDao extends BaseMapper<ExpressOrder> {
|
||||
int insertNewExpressOrder(ExpressOrder expressOrder);
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public class ExpressOrder {
|
||||
/**
|
||||
* 总重量
|
||||
*/
|
||||
private BigDecimal totalWeight;
|
||||
private int totalWeight;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
||||
@@ -167,4 +167,6 @@ public class ShopProductEntity implements Serializable {
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<String> shoproudLabels;
|
||||
|
||||
private int expressOrderId;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.peanut.modules.book.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.BuyOrderEntity;
|
||||
|
||||
import java.util.List;
|
||||
@@ -24,9 +22,6 @@ public interface BuyOrderService extends IService<BuyOrderEntity> {
|
||||
//更新订单状态
|
||||
void updateOrderStatus(Integer userId, String orderSn, String type);
|
||||
|
||||
// 及时查询
|
||||
JSONObject queryFMS(String shipperCode, String expNo);
|
||||
|
||||
// 查询勾选的订单是否有可合并
|
||||
List checkOrder(Integer[] orderIds);
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.peanut.modules.book.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.book.entity.ExpressOrder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public interface ExpressOrderService extends IService<ExpressOrder> {
|
||||
/**
|
||||
* 新增快递订单信息
|
||||
*
|
||||
* @param expressOrder 快递订单
|
||||
* @return object - id
|
||||
*/
|
||||
int insertNewExpressOrder(ExpressOrder expressOrder);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,23 +1,18 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.Interface.KdApiEOrder;
|
||||
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.book.dao.BuyOrderDao;
|
||||
import com.peanut.modules.book.dao.BuyOrderDetailDao;
|
||||
import com.peanut.modules.book.dao.ShopProductDao;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.vo.ProductVo;
|
||||
import com.peanut.modules.book.vo.UserOrderVo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -25,7 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
@@ -38,15 +32,8 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
@Autowired
|
||||
private BuyOrderDetailService buyOrderDetailService;
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
|
||||
@Resource
|
||||
private BuyOrderDao buyOrderDao;
|
||||
@Resource
|
||||
private BuyOrderDetailDao buyOrderDetailDao;
|
||||
|
||||
@Autowired
|
||||
private ShopProductDao shopProductDao;
|
||||
|
||||
@@ -56,9 +43,15 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
@Autowired
|
||||
private ExpressFeeService expressFeeService;
|
||||
|
||||
@Autowired
|
||||
private ExpressOrderService expressOrderService;
|
||||
|
||||
|
||||
protected Logger logger = LoggerFactory.getLogger(BuyOrderServiceImpl.class);
|
||||
|
||||
public BuyOrderServiceImpl() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) throws Exception {
|
||||
|
||||
@@ -130,45 +123,6 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
updateById(orderEntity);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 及时查询快递信息
|
||||
*
|
||||
* @param shipperCode 快递公司编码
|
||||
* @param expNo 快递单号
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public JSONObject queryFMS(String shipperCode, String expNo) {
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("ShipperCode", shipperCode);
|
||||
param.put("LogisticCode", expNo);
|
||||
try {
|
||||
if (!expNo.equals(1)) {
|
||||
String rntStr = KdApiEOrder.queryOrderOnlineByJson(param);
|
||||
JSONObject jsonObject = JSONObject.parseObject(rntStr);
|
||||
if ("true".equals(jsonObject.getString("Success"))) {
|
||||
return jsonObject;
|
||||
}
|
||||
} else {
|
||||
String rntStr = KdApiEOrder.queryOrderOnlineByJson(param);
|
||||
JSONObject jsonObject = JSONObject.parseObject(rntStr);
|
||||
if ("true".equals(jsonObject.getString("Success"))) {
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
|
||||
String rntStr = KdApiEOrder.queryOrderOnlineByJson(param);
|
||||
JSONObject jsonObject = JSONObject.parseObject(rntStr);
|
||||
if ("true".equals(jsonObject.getString("Success"))) {
|
||||
return jsonObject;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询勾选的订单是否有可合并
|
||||
*
|
||||
@@ -301,136 +255,14 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrderEntity
|
||||
UserAddress address = userAddressService.getById(userAddressId);
|
||||
// 计算快递费用
|
||||
BigDecimal expressFee = expressFeeService.calculateExpressFee(expressCompanyCode, totalWeight, address.getRegionCode());
|
||||
// 打印面单
|
||||
ExpressOrder expressOrder = new ExpressOrder();
|
||||
expressOrder.setExpressFee(expressFee);
|
||||
expressOrder.setCreateTime(new Date());
|
||||
expressOrder.setTotalWeight(totalWeight);
|
||||
// 生成快递面单
|
||||
|
||||
}
|
||||
int expressOrderId = expressOrderService.insertNewExpressOrder(expressOrder);
|
||||
|
||||
|
||||
public static String getRandom(int len) {
|
||||
Random r = new Random();
|
||||
StringBuilder rs = new StringBuilder();
|
||||
for (int i = 0; i < len; i++) {
|
||||
rs.append(r.nextInt(10));
|
||||
}
|
||||
return rs.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 计算仪器,预售快递费用
|
||||
*
|
||||
* @param productList
|
||||
* @return
|
||||
*/
|
||||
public int getTransPrice(List<ProductVo> productList) {
|
||||
|
||||
// 首重
|
||||
int amount = 0;
|
||||
// 续重
|
||||
int continuousWeight = 0;
|
||||
// 费用
|
||||
int fare = 0;
|
||||
for (ProductVo p : productList) {
|
||||
String prov = p.getArea().substring(0, p.getArea().indexOf("_"));
|
||||
float weight = p.getNum() * p.getWeight();
|
||||
// 韵达计费规则
|
||||
if ("YD".equals(p.getKdCode())) {
|
||||
// 如果ID等于71 说明是天津发天津
|
||||
if ("71".equals(prov)) {
|
||||
amount = 6;
|
||||
continuousWeight = 3;
|
||||
}
|
||||
// 首重十元 续重四元
|
||||
String tenStr[] = {"70", "73", "75", "76", "77", "79", "81", "82", "83", "84", "85", "86", "87", "88", "91", "92", "96", "80", "78"};
|
||||
boolean tenBoolean = Arrays.asList(tenStr).contains(prov);
|
||||
if (tenBoolean) {
|
||||
amount = 10;
|
||||
continuousWeight = 4;
|
||||
}
|
||||
// 首重十二元
|
||||
String twelveStr[] = {"74", "89", "90", "93", "94", "97", "98", "99"};
|
||||
boolean twelveBoolean = Arrays.asList(twelveStr).contains(prov);
|
||||
if (twelveBoolean) {
|
||||
amount = 12;
|
||||
continuousWeight = 5;
|
||||
// 甘肃 97,青海 98,内蒙古 74 ,海南90 续重 6元
|
||||
if (prov.equals("97") || prov.equals("98") || prov.equals("74") || prov.equals("90")) {
|
||||
continuousWeight = 6;
|
||||
}
|
||||
}
|
||||
// 首重二十元,续重二十元
|
||||
if ("100".equals(prov)) {
|
||||
amount = 20;
|
||||
continuousWeight = 20;
|
||||
}
|
||||
|
||||
if (weight <= 1000) {
|
||||
fare += amount;
|
||||
} else {
|
||||
fare += (int) (amount + (continuousWeight * Math.floor(weight / 1000)));
|
||||
}
|
||||
}
|
||||
}
|
||||
return fare;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 计算快递费用
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
public int getTransPrice(Map<String, Object> param) {
|
||||
|
||||
int fare = 0;
|
||||
String KDCode = param.get("kdCode").toString();
|
||||
String area = param.get("area").toString();
|
||||
String prov = area.substring(0, area.indexOf("_"));
|
||||
float weight = (float) param.get("weight");
|
||||
// 韵达计费规则
|
||||
if ("YD".equals(KDCode)) {
|
||||
// 如果ID等于71 说明是天津发天津
|
||||
int amount = 0;
|
||||
int continuousWeight = 0;
|
||||
if ("71".equals(prov)) {
|
||||
amount = 6;
|
||||
continuousWeight = 3;
|
||||
}
|
||||
// 首重十元 续重四元
|
||||
String tenStr[] = {"70", "73", "75", "76", "77", "79", "81", "82", "83", "84", "85", "86", "87", "88", "91", "92", "96", "80", "78"};
|
||||
boolean tenBoolean = Arrays.asList(tenStr).contains(prov);
|
||||
if (tenBoolean) {
|
||||
amount = 10;
|
||||
continuousWeight = 4;
|
||||
}
|
||||
// 首重十二元
|
||||
String twelveStr[] = {"74", "89", "90", "93", "94", "97", "98", "99"};
|
||||
boolean twelveBoolean = Arrays.asList(twelveStr).contains(prov);
|
||||
if (twelveBoolean) {
|
||||
amount = 12;
|
||||
continuousWeight = 5;
|
||||
// 甘肃 97,青海 98,内蒙古 74 ,海南90 续重 6元
|
||||
if (prov.equals("97") || prov.equals("98") || prov.equals("74") || prov.equals("90")) {
|
||||
continuousWeight = 6;
|
||||
}
|
||||
}
|
||||
// 首重二十元,续重二十元
|
||||
if ("100".equals(prov)) {
|
||||
amount = 20;
|
||||
continuousWeight = 20;
|
||||
}
|
||||
// 如果重量等于0 说明是包邮
|
||||
if (weight == 0) {
|
||||
return 0;
|
||||
} else if (weight <= 1000) {
|
||||
return amount;
|
||||
} else {
|
||||
return (int) (amount + (continuousWeight * Math.floor(weight / 1000)));
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.book.dao.ExpressOrderDao;
|
||||
import com.peanut.modules.book.entity.ExpressOrder;
|
||||
import com.peanut.modules.book.service.ExpressOrderService;
|
||||
import com.peanut.modules.book.vo.ExpressOrderRequestVo;
|
||||
import com.peanut.modules.book.vo.ExpressUserInfoVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Description: 快递订单 Service 实现
|
||||
* @Author: Cauchy
|
||||
* @CreateTime: 2023/10/16
|
||||
*/
|
||||
@Service
|
||||
public class ExpressOrderServiceImpl extends ServiceImpl<ExpressOrderDao, ExpressOrder> implements ExpressOrderService {
|
||||
@Autowired
|
||||
private ExpressOrderDao expressOrderDao;
|
||||
|
||||
@Override
|
||||
public int insertNewExpressOrder(ExpressOrder expressOrder) {
|
||||
expressOrderDao.insertNewExpressOrder(expressOrder);
|
||||
return expressOrder.getId();
|
||||
}
|
||||
|
||||
public void createExpressOrder() throws Exception {
|
||||
ExpressUserInfoVo receiver = new ExpressUserInfoVo();
|
||||
receiver.setName("张三");
|
||||
receiver.setMobile("12345678910");
|
||||
receiver.setPrintAddr("广东省深圳市南山区科技南十二路");
|
||||
|
||||
ExpressUserInfoVo sender = new ExpressUserInfoVo();
|
||||
sender.setName("李四");
|
||||
sender.setMobile("12345678910");
|
||||
sender.setPrintAddr("北京市海淀区xxx路");
|
||||
|
||||
ExpressOrderRequestVo request = new ExpressOrderRequestVo();
|
||||
request.setKuaidicom(CompanyConstant.ZJS);
|
||||
request.setCount(1);
|
||||
request.setSiid(siid);
|
||||
request.setTempId("60f6c17c7c223700131d8bc3");
|
||||
request.setSendMan(sender);
|
||||
request.setRecMan(receiver);
|
||||
request.setPrintType(PrintType.CLOUD);
|
||||
|
||||
String param = new Gson().toJson(request);
|
||||
String t = System.currentTimeMillis() + "";
|
||||
|
||||
PrintReq printReq = new PrintReq();
|
||||
printReq.setT(t);
|
||||
printReq.setKey(key);
|
||||
printReq.setSign(SignUtils.printSign(param, t, key, secret));
|
||||
printReq.setMethod(ApiInfoConstant.ORDER);
|
||||
printReq.setParam(param);
|
||||
|
||||
IBaseClient baseClient = new LabelV2();
|
||||
System.out.println(baseClient.execute(printReq));
|
||||
}
|
||||
|
||||
public void testPrintOld() throws Exception {
|
||||
RepeatPrintReq repeatPrintReq = new RepeatPrintReq();
|
||||
|
||||
repeatPrintReq.setTaskId("027B34AD22DE4F299643A13642B70D5F");
|
||||
|
||||
String param = new Gson().toJson(repeatPrintReq);
|
||||
String t = System.currentTimeMillis() + "";
|
||||
|
||||
PrintReq printReq = new PrintReq();
|
||||
printReq.setT(t);
|
||||
printReq.setKey(key);
|
||||
printReq.setSign(SignUtils.printSign(param, t, key, secret));
|
||||
printReq.setMethod(ApiInfoConstant.CLOUD_PRINT_OLD_METHOD);
|
||||
printReq.setParam(param);
|
||||
|
||||
IBaseClient baseClient = new LabelV2();
|
||||
System.out.println(baseClient.execute(printReq));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.peanut.modules.book.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 货品 Value Object
|
||||
* @Author: Cauchy
|
||||
* @CreateTime: 2023/10/16
|
||||
*/
|
||||
@Data
|
||||
public class ExpressCommodityVo {
|
||||
private String GoodsName;
|
||||
private String GoodsCode;
|
||||
private int Goodsquantity;
|
||||
private double GoodsPrice;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.peanut.modules.book.vo;
|
||||
|
||||
import com.kuaidi100.sdk.contant.PrintType;
|
||||
import com.kuaidi100.sdk.request.ManInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 快递请求 Value Object
|
||||
* @Author: Cauchy
|
||||
* @CreateTime: 2023/10/16
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class ExpressOrderRequestVo {
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
private String OrderCode;
|
||||
/**
|
||||
* 快递公司编码
|
||||
*/
|
||||
private String ShipperCode;
|
||||
/**
|
||||
* 支付类型 1 - 现付 2 - 到付 3 - 月结 4 - 第三方付
|
||||
*/
|
||||
private int payType;
|
||||
/**
|
||||
* 快递公司业务类型
|
||||
*/
|
||||
private int ExpType;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.peanut.modules.book.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 快递收/发件人 Value Object
|
||||
* @Author: Cauchy
|
||||
* @CreateTime: 2023/10/16
|
||||
*/
|
||||
@Data
|
||||
public class ExpressUserInfoVo {
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String Name;
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String Mobile;
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
private String ProvinceName;
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
private String cityName;
|
||||
/**
|
||||
* 区
|
||||
*/
|
||||
private String ExpAreaName;
|
||||
/**
|
||||
* 详细地址
|
||||
*/
|
||||
private String Address;
|
||||
}
|
||||
10
src/main/resources/mapper/book/ExpressOrderDao.xml
Normal file
10
src/main/resources/mapper/book/ExpressOrderDao.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.peanut.modules.book.dao.ExpressOrderDao">
|
||||
<insert id="insertNewExpressOrder" keyProperty="id" parameterType="com.peanut.modules.book.entity.ExpressFee"
|
||||
useGeneratedKeys="true">
|
||||
insert into express_order(user_id, user_address_id, express_fee, create_time, total_weight)
|
||||
values (#{userId}, #{userAddressId}, #{expressFee}, #{createTime}, #{totalWeight})
|
||||
</insert>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user