v3.0.0 springboot3+jdk17版本
This commit is contained in:
1 parent
3aa2c942dc
commit
b3ee447f8e
3676 files changed
+64366
-370384
No files matched your search
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>yshop-module-express</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>yshop-module-express-api</module>
|
||||
<module>yshop-module-express-biz</module>
|
||||
</modules>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>
|
||||
express 模块
|
||||
</description>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yshop-module-express</artifactId>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>yshop-module-express-api</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>
|
||||
pay 模块 API,暴露给其它模块调用
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 参数校验 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- DB 相关 -->
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-spring-boot-starter-mybatis</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package co.yixiang.yshop.module.express.enums;
|
||||
|
||||
import co.yixiang.yshop.framework.common.exception.ErrorCode;
|
||||
|
||||
public interface ErrorCodeConstants {
|
||||
// ========== 快递公司 1008008000 ==========
|
||||
ErrorCode EXPRESS_NOT_EXISTS = new ErrorCode(1008008000, "快递公司不存在");
|
||||
// ========== 电子面单 ==========
|
||||
ErrorCode ELECTRONICS_ORDER_NOT_EXISTS = new ErrorCode(1008009000, "电子面单不存在");
|
||||
}
|
||||
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
package co.yixiang.yshop.module.express.kdniao.enums;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* <p> 物流公司-对应编码-枚举 </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2023/7/219
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum KdniaoLogisticsCodeEnum {
|
||||
|
||||
/**
|
||||
* 申通
|
||||
*/
|
||||
STO("STO", "申通"),
|
||||
/**
|
||||
* 中通
|
||||
*/
|
||||
ZTO("ZTO", "中通"),
|
||||
/**
|
||||
* 圆通
|
||||
*/
|
||||
YTO("YTO", "圆通"),
|
||||
/**
|
||||
* 韵达
|
||||
*/
|
||||
YD("YD", "韵达"),
|
||||
/**
|
||||
* 顺丰
|
||||
*/
|
||||
SF("SF", "顺丰");
|
||||
|
||||
/**
|
||||
* 物流编码
|
||||
*/
|
||||
private final String code;
|
||||
/**
|
||||
* 物流名
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
|
||||
private static final List<KdniaoLogisticsCodeEnum> LIST = new ArrayList();
|
||||
|
||||
static {
|
||||
LIST.addAll(Arrays.asList(KdniaoLogisticsCodeEnum.values()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据值查找相应枚举
|
||||
*/
|
||||
@SneakyThrows(Exception.class)
|
||||
public static KdniaoLogisticsCodeEnum getEnumByName(String name) {
|
||||
for (KdniaoLogisticsCodeEnum itemEnum : LIST) {
|
||||
if (itemEnum.getName().equals(name)) {
|
||||
return itemEnum;
|
||||
}
|
||||
}
|
||||
throw new Exception("暂无此物流编码信息,请联系系统管理员!");
|
||||
}
|
||||
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
package co.yixiang.yshop.module.express.kdniao.enums;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* <p> 物流状态枚举 </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2023/7/219
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum KdniaoLogisticsStatusEnum {
|
||||
|
||||
/**
|
||||
* 暂无轨迹信息
|
||||
*/
|
||||
NO_TRACE(0, "暂无轨迹信息"),
|
||||
/**
|
||||
* 已揽收
|
||||
*/
|
||||
HAVE_PAID(1, "已揽收"),
|
||||
/**
|
||||
* 已揽收 -----------------------------------------------------------------------------
|
||||
*/
|
||||
ON_THE_WAY(2, "在途中"),
|
||||
/**
|
||||
* 到达派件城市
|
||||
*/
|
||||
ARRIVE_AT_THE_DISPATCH_CITY(201, "到达派件城市"),
|
||||
/**
|
||||
* 派件中
|
||||
*/
|
||||
IN_THE_DELIVERY(202, "派件中"),
|
||||
/**
|
||||
* 已放入快递柜或驿站
|
||||
*/
|
||||
HAS_STORED(211, "已放入快递柜或驿站"),
|
||||
/**
|
||||
* 签收 -----------------------------------------------------------------------------
|
||||
*/
|
||||
SIGN(3, "签收"),
|
||||
/**
|
||||
* 正常签收
|
||||
*/
|
||||
SIGN_NORMAL(301, "正常签收"),
|
||||
/**
|
||||
* 派件异常后最终签收
|
||||
*/
|
||||
SIGN_ABNORMAL(302, "派件异常后最终签收"),
|
||||
/**
|
||||
* 代收签收
|
||||
*/
|
||||
SIGN_COLLECTION(304, "代收签收"),
|
||||
/**
|
||||
* 快递柜或驿站签收
|
||||
*/
|
||||
SIGN_STORED(311, "快递柜或驿站签收"),
|
||||
/**
|
||||
* 问题件 -----------------------------------------------------------------------------
|
||||
*/
|
||||
PROBLEM_SHIPMENT(4, "问题件"),
|
||||
/**
|
||||
* 发货无信息
|
||||
*/
|
||||
DELIVERY_NO_INFO(401, "发货无信息"),
|
||||
/**
|
||||
* 超时未签收
|
||||
*/
|
||||
NO_SIGN_OVER_TIME(402, "超时未签收"),
|
||||
/**
|
||||
* 超时未更新
|
||||
*/
|
||||
NOT_UPDATED_DUE_TO_TIMEOUT(403, "超时未更新"),
|
||||
/**
|
||||
* 拒收(退件)
|
||||
*/
|
||||
REJECTION(404, "拒收(退件)"),
|
||||
/**
|
||||
* 派件异常
|
||||
*/
|
||||
SEND_A_ABNORMAL(405, "派件异常"),
|
||||
/**
|
||||
* 退货签收
|
||||
*/
|
||||
RETURN_TO_SIGN_FOR(406, "退货签收"),
|
||||
/**
|
||||
* 退货未签收
|
||||
*/
|
||||
RETURN_NOT_SIGNED_FOR(407, "退货未签收"),
|
||||
/**
|
||||
* 快递柜或驿站超时未取
|
||||
*/
|
||||
STORED_OVER_TIME(412, "快递柜或驿站超时未取"),
|
||||
/**
|
||||
* -
|
||||
*/
|
||||
DEFAULT(0, "-");
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private final Integer status;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private final String desc;
|
||||
|
||||
private static final List<KdniaoLogisticsStatusEnum> LIST = new ArrayList();
|
||||
|
||||
static {
|
||||
LIST.addAll(Arrays.asList(KdniaoLogisticsStatusEnum.values()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据物流状态查找相应枚举
|
||||
*/
|
||||
public static KdniaoLogisticsStatusEnum getEnum(Integer status) {
|
||||
for (KdniaoLogisticsStatusEnum itemEnum : LIST) {
|
||||
if (itemEnum.getStatus().equals(status)) {
|
||||
return itemEnum;
|
||||
}
|
||||
}
|
||||
return KdniaoLogisticsStatusEnum.DEFAULT;
|
||||
}
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package co.yixiang.yshop.module.express.kdniao.model.dto;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 快递鸟-物流-查询base参数
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2023/7/21
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
//快递鸟-物流-查询base参数
|
||||
public class KdniaoApiBaseDTO {
|
||||
|
||||
//用户ID
|
||||
private String eBusinessID;
|
||||
|
||||
//API key
|
||||
private String apiKey;
|
||||
|
||||
//请求url
|
||||
//https://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx
|
||||
private String reqURL;
|
||||
|
||||
private Boolean isFree;
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package co.yixiang.yshop.module.express.kdniao.model.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 快递鸟-物流-查询参数
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2023/7/21
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
//快递鸟-物流-查询参数
|
||||
public class KdniaoApiDTO extends KdniaoApiBaseDTO {
|
||||
|
||||
//快递公司编码 ZTO
|
||||
private String shipperCode;
|
||||
|
||||
//快递单号
|
||||
private String logisticCode;
|
||||
|
||||
//是否收费 true=免费 false 收费
|
||||
private Boolean isFree;
|
||||
|
||||
}
|
||||
+193
@@ -0,0 +1,193 @@
|
||||
package co.yixiang.yshop.module.express.kdniao.model.dto;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 电子面单 DTO
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class KdniaoElectronicsOrderDTO extends KdniaoApiBaseDTO {
|
||||
|
||||
//用户
|
||||
private Long memberID;
|
||||
|
||||
//订单编号
|
||||
private String orderCode;
|
||||
|
||||
//快递公司编码
|
||||
private String shipperCode;
|
||||
|
||||
//快递单号
|
||||
private String logisticCode;
|
||||
|
||||
//其他费用
|
||||
private Double otherCost;
|
||||
|
||||
/**
|
||||
* 运费支付方式:1=现付,2=到付,3=月结,4=第三方付(仅SF支持)
|
||||
*/
|
||||
private Integer paytype;
|
||||
/**
|
||||
* 线下网点客户号
|
||||
*/
|
||||
private String customerName;
|
||||
/**
|
||||
* 线下网点密码
|
||||
*/
|
||||
private String customerPwd;
|
||||
/**
|
||||
* 网点名称
|
||||
*/
|
||||
private String sendSite;
|
||||
/**
|
||||
* 网点快递员
|
||||
*/
|
||||
private String sendStaff;
|
||||
|
||||
//快递运费
|
||||
private Double cost;
|
||||
/**
|
||||
* 月结编号
|
||||
*/
|
||||
private String monthCode;
|
||||
/**
|
||||
* 是否通知揽件:0=通知揽件,1=不通知揽件
|
||||
*/
|
||||
private Integer isNotice;
|
||||
/**
|
||||
* 是否返回电子面单模板:0=不返回,1=返回
|
||||
*/
|
||||
private Integer isReturnTemp;
|
||||
/**
|
||||
* 是否需要短信提醒:0=否,1=是
|
||||
*/
|
||||
private Integer isSendMessage;
|
||||
/**
|
||||
* 模板尺寸
|
||||
*/
|
||||
private String templateSize;
|
||||
/**
|
||||
* 签回单操作要求(如:签名、盖章、身份证复印件等)
|
||||
*/
|
||||
private String operateRequire;
|
||||
|
||||
/**
|
||||
* 上门揽件开始时间
|
||||
*/
|
||||
private Integer startDate;
|
||||
/**
|
||||
* 上门揽件结束时间
|
||||
*/
|
||||
private Integer endDate;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 快递类型:1=标准快件
|
||||
*/
|
||||
private Integer expType;
|
||||
/**
|
||||
* 是否要签回单:0=否,1=是
|
||||
*/
|
||||
private Integer isReturnSignBill;
|
||||
/**
|
||||
* 发件人公司
|
||||
*/
|
||||
private String company;
|
||||
/**
|
||||
* 发件人省
|
||||
*/
|
||||
private String provinceName;
|
||||
/**
|
||||
* 发件人市
|
||||
*/
|
||||
private String cityName;
|
||||
/**
|
||||
* 发件人区
|
||||
*/
|
||||
private String expAreaName;
|
||||
/**
|
||||
* 发件人详细地址
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 发件人姓名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 发件人电话
|
||||
*/
|
||||
private String tel;
|
||||
/**
|
||||
* 发件人手机号码
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 发件地邮编
|
||||
*/
|
||||
private String postCode;
|
||||
|
||||
|
||||
/**
|
||||
* 收件人公司
|
||||
*/
|
||||
private String receiverCompany;
|
||||
/**
|
||||
* 收件人省
|
||||
*/
|
||||
private String receiverProvinceName;
|
||||
/**
|
||||
* 收件人市
|
||||
*/
|
||||
private String receiverCityName;
|
||||
/**
|
||||
* 收件人区
|
||||
*/
|
||||
private String receiverExpAreaName;
|
||||
/**
|
||||
* 收件人详细地址
|
||||
*/
|
||||
private String receiverAddress;
|
||||
/**
|
||||
* 收件人姓名
|
||||
*/
|
||||
private String receiverName;
|
||||
/**
|
||||
* 收件人电话
|
||||
*/
|
||||
private String receiverTel;
|
||||
/**
|
||||
* 收件人手机号码
|
||||
*/
|
||||
private String receiverMobile;
|
||||
/**
|
||||
* 收件地邮编
|
||||
*/
|
||||
private String receiverPostCode;
|
||||
|
||||
/**
|
||||
* 重量
|
||||
*/
|
||||
private Double weight;
|
||||
|
||||
/**
|
||||
* 重量
|
||||
*/
|
||||
private Integer quantity;
|
||||
|
||||
/**
|
||||
* 体积
|
||||
*
|
||||
*/
|
||||
private Double volume;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package co.yixiang.yshop.module.express.kdniao.model.dto;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
|
||||
/**
|
||||
* 电子面单 DTO
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class KdniaoElectronicsOrderGoodsDTO {
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String goodsName;
|
||||
|
||||
/**
|
||||
* 商品编号
|
||||
*/
|
||||
private String goodsCode;
|
||||
/**
|
||||
* 商品件数
|
||||
*/
|
||||
private Integer goodsQuantity;
|
||||
/**
|
||||
* 商品价格
|
||||
*/
|
||||
private Double goodsPrice;
|
||||
/**
|
||||
* 商品重量kg
|
||||
*/
|
||||
private Double goodsWeight;
|
||||
/**
|
||||
* 商品描述
|
||||
*/
|
||||
private String GoodsDesc;
|
||||
/**
|
||||
* 商品体积m³
|
||||
*/
|
||||
private Double GoodsVol;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
package co.yixiang.yshop.module.express.kdniao.model.vo;
|
||||
|
||||
|
||||
import co.yixiang.yshop.module.express.kdniao.enums.KdniaoLogisticsStatusEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 快递鸟-物流-响应参数
|
||||
* </p>
|
||||
* @author hupeng
|
||||
* @date 2023/7/21
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class KdniaoApiVO {
|
||||
|
||||
/**
|
||||
* {@link KdniaoLogisticsStatusEnum }
|
||||
* 增值物流状态:
|
||||
* 0-暂无轨迹信息
|
||||
* 1-已揽收
|
||||
* 2-在途中
|
||||
* 201-到达派件城市, 202-派件中, 211-已放入快递柜或驿站,
|
||||
* 3-已签收
|
||||
* 301-正常签收, 302-派件异常后最终签收, 304-代收签收, 311-快递柜或驿站签收,
|
||||
* 4-问题件
|
||||
* 401-发货无信息, 402-超时未签收, 403-超时未更新, 404-拒收(退件), 405-派件异常, 406-退货签收, 407-退货未签收, 412-快递柜或驿站超时未取
|
||||
*/
|
||||
|
||||
//增值物流状态
|
||||
private Integer StateEx;
|
||||
|
||||
//增值物流状态名称
|
||||
private String statusExName;
|
||||
|
||||
//快递单号
|
||||
private String LogisticCode;
|
||||
|
||||
//快递公司编码
|
||||
private String ShipperCode;
|
||||
|
||||
|
||||
//失败原因
|
||||
private String Reason;
|
||||
|
||||
|
||||
//事件轨迹集
|
||||
private List<TraceItem> Traces;
|
||||
|
||||
/**
|
||||
* {@link KdniaoLogisticsStatusEnum }
|
||||
*/
|
||||
//物流状态:0-暂无轨迹信息,1-已揽收,2-在途中,3-签收,4-问题件
|
||||
private Integer State;
|
||||
|
||||
//状态名称
|
||||
private String statusName;
|
||||
|
||||
//用户ID
|
||||
private String EBusinessID;
|
||||
|
||||
//送货人
|
||||
private String DeliveryMan;
|
||||
|
||||
|
||||
//送货人电话号码
|
||||
private String DeliveryManTel;
|
||||
|
||||
//成功与否 true/false
|
||||
private String Success;
|
||||
|
||||
|
||||
//所在城市
|
||||
private String Location;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
//事件轨迹集
|
||||
public static class TraceItem {
|
||||
/**
|
||||
* {@link KdniaoLogisticsStatusEnum }
|
||||
*/
|
||||
//当前状态(同StateEx)
|
||||
private Integer Action;
|
||||
|
||||
//状态名称
|
||||
private String actionName;
|
||||
|
||||
//描述
|
||||
private String AcceptStation;
|
||||
|
||||
//时间
|
||||
private String AcceptTime;
|
||||
|
||||
//所在城市
|
||||
private String Location;
|
||||
}
|
||||
|
||||
|
||||
public void handleData() {
|
||||
this.statusName = KdniaoLogisticsStatusEnum.getEnum(this.State).getDesc();
|
||||
this.statusExName = KdniaoLogisticsStatusEnum.getEnum(this.StateEx).getDesc();
|
||||
if (CollectionUtils.isEmpty(this.Traces)) {
|
||||
this.Traces = new ArrayList();
|
||||
}
|
||||
this.Traces.forEach(item -> item.actionName = KdniaoLogisticsStatusEnum.getEnum(item.Action).getDesc());
|
||||
}
|
||||
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
package co.yixiang.yshop.module.express.kdniao.model.vo;
|
||||
|
||||
import co.yixiang.yshop.module.express.kdniao.enums.KdniaoLogisticsCodeEnum;
|
||||
import co.yixiang.yshop.module.express.kdniao.enums.KdniaoLogisticsStatusEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p> 快递鸟-物流-参数 </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2023/7/21
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class KdniaoLogisticsVO {
|
||||
|
||||
/**
|
||||
* {@link KdniaoLogisticsCodeEnum }
|
||||
*/
|
||||
//快递公司编码
|
||||
private String logisticsCode;
|
||||
|
||||
//快递单号
|
||||
private String logisticsNo;
|
||||
|
||||
//事件轨迹集
|
||||
private List<TraceItem> traceList;
|
||||
|
||||
//送货人名称
|
||||
private String delivererName;
|
||||
|
||||
|
||||
//送货人电话号码
|
||||
private String delivererPhone;
|
||||
|
||||
//所在城市
|
||||
private String location;
|
||||
|
||||
/**
|
||||
* {@link KdniaoLogisticsStatusEnum }
|
||||
*/
|
||||
//物流状态
|
||||
private Integer status;
|
||||
|
||||
//状态名称
|
||||
private String statusName;
|
||||
|
||||
/**
|
||||
* {@link KdniaoLogisticsStatusEnum }
|
||||
*/
|
||||
//增值物流状态
|
||||
private Integer statusEx;
|
||||
|
||||
//增值物流状态名称
|
||||
private String statusExName;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
//事件轨迹集
|
||||
public static class TraceItem {
|
||||
//状态
|
||||
private Integer status;
|
||||
|
||||
//状态名称
|
||||
private String statusName;
|
||||
|
||||
//描述
|
||||
private String desc;
|
||||
|
||||
//时间
|
||||
private String time;
|
||||
|
||||
//所在城市
|
||||
private String location;
|
||||
}
|
||||
|
||||
public void handleData() {
|
||||
this.statusName = KdniaoLogisticsStatusEnum.getEnum(this.status).getDesc();
|
||||
this.statusExName = KdniaoLogisticsStatusEnum.getEnum(this.statusEx).getDesc();
|
||||
if (CollectionUtils.isEmpty(this.traceList)) {
|
||||
this.traceList = new ArrayList();
|
||||
}
|
||||
this.traceList.forEach(item -> item.statusName = KdniaoLogisticsStatusEnum.getEnum(item.status).getDesc());
|
||||
}
|
||||
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
package co.yixiang.yshop.module.express.kdniao.model.vo;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 快递鸟-面单-响应参数
|
||||
* </p>
|
||||
* @author hupeng
|
||||
* @date 2023/7/22
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class KdniaoOrderVO {
|
||||
//返回编码
|
||||
private String ResultCode;
|
||||
|
||||
//失败原因
|
||||
private String Reason;
|
||||
|
||||
//成功与否 true/false
|
||||
private String Success;
|
||||
|
||||
//面单打印模板内容(html格式)
|
||||
private String PrintTemplate;
|
||||
|
||||
//唯一标识
|
||||
private String UniquerRequestNumber;
|
||||
|
||||
//子单数量
|
||||
private Integer SubCount;
|
||||
|
||||
//子单单号
|
||||
private String SubOrders;
|
||||
|
||||
//子单模板内容(html格式)
|
||||
private String SubPrintTemplates;
|
||||
|
||||
//签回单模板内容
|
||||
private String SignBillPrintTemplate;
|
||||
|
||||
//订单信息
|
||||
private OrderInfo Order;
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class OrderInfo {
|
||||
|
||||
//订单编号
|
||||
private String OrderCode;
|
||||
|
||||
//快递公司编码
|
||||
private String ShipperCode;
|
||||
|
||||
//快递单号
|
||||
private String LogisticCode;
|
||||
|
||||
//大头笔
|
||||
private String MarkDestination;
|
||||
|
||||
//签回单单号
|
||||
private String SignWaybillCode;
|
||||
|
||||
|
||||
//始发地区域编码
|
||||
private String OriginCode;
|
||||
|
||||
//始发地/始发网点
|
||||
private String OriginName;
|
||||
|
||||
//目的地区域编码
|
||||
private String DestinatioCode;
|
||||
|
||||
//目的地/到达网点
|
||||
private String DestinatioName;
|
||||
|
||||
//分拣编码
|
||||
private String SortingCode;
|
||||
|
||||
|
||||
//集包编码
|
||||
private String PackageCode;
|
||||
|
||||
//集包地
|
||||
private String PackageName;
|
||||
|
||||
//目的地分拨
|
||||
private String DestinationAllocationCentre;
|
||||
|
||||
//配送产品类型
|
||||
private Integer TransType;
|
||||
|
||||
//运输方式(用于自行设计京东模板):
|
||||
//0:陆运
|
||||
//1:航空
|
||||
private Integer TransportType;
|
||||
|
||||
//自行设计模板用
|
||||
private String ShipperInfo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+343
@@ -0,0 +1,343 @@
|
||||
package co.yixiang.yshop.module.express.kdniao.util;
|
||||
|
||||
import co.yixiang.yshop.framework.common.exception.ErrorCode;
|
||||
import co.yixiang.yshop.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import co.yixiang.yshop.module.express.kdniao.model.dto.KdniaoApiDTO;
|
||||
import co.yixiang.yshop.module.express.kdniao.model.dto.KdniaoElectronicsOrderDTO;
|
||||
import co.yixiang.yshop.module.express.kdniao.model.dto.KdniaoElectronicsOrderGoodsDTO;
|
||||
import co.yixiang.yshop.module.express.kdniao.model.vo.KdniaoApiVO;
|
||||
import co.yixiang.yshop.module.express.kdniao.model.vo.KdniaoOrderVO;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* <p> 快递鸟工具类 </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2023/7/219
|
||||
*/
|
||||
@Slf4j
|
||||
public class KdniaoUtil {
|
||||
//查询物流当url
|
||||
private final String KDNIAO_LOGISTIC_QUERY = "https://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx";
|
||||
//电子面单url
|
||||
private final String KDNIAO_ELECT_QUERY = "https://api.kdniao.com/api/EOrderService";
|
||||
|
||||
/**
|
||||
* 快递查询接口
|
||||
*
|
||||
* @param queryDTO 请求参数
|
||||
* @return 物流信息
|
||||
*/
|
||||
public static KdniaoApiVO getLogisticInfo(KdniaoApiDTO queryDTO){
|
||||
KdniaoApiVO kdniaoApiVO = new KdniaoUtil().getLogisticBase(queryDTO);
|
||||
if (kdniaoApiVO.getSuccess() == "false"){
|
||||
throw ServiceExceptionUtil.exception(new ErrorCode(999999,kdniaoApiVO.getReason()));
|
||||
}
|
||||
|
||||
kdniaoApiVO.handleData();
|
||||
return kdniaoApiVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取电子面单信息
|
||||
* @param queryDTO
|
||||
* @param kdniaoElectronicsOrderGoodsDTOList
|
||||
* @return
|
||||
*/
|
||||
public static KdniaoOrderVO getOrderInfo(KdniaoElectronicsOrderDTO queryDTO,
|
||||
List<KdniaoElectronicsOrderGoodsDTO> kdniaoElectronicsOrderGoodsDTOList) {
|
||||
KdniaoOrderVO kdniaoOrderVO = new KdniaoUtil().getEleCtBase(queryDTO,kdniaoElectronicsOrderGoodsDTOList);
|
||||
//todo 由于目前快递鸟订单打印需要申请当地营业网店账号 所有目前这个没法测试 如果有其他用户有可以测试反馈给我们官方
|
||||
if (kdniaoOrderVO.getSuccess() == "false"){
|
||||
log.error(kdniaoOrderVO.getReason());
|
||||
throw ServiceExceptionUtil.exception(new ErrorCode(999999,kdniaoOrderVO.getReason()));
|
||||
}
|
||||
|
||||
return kdniaoOrderVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 快递查询接口
|
||||
*
|
||||
* @param queryDTO 请求参数
|
||||
* @return 物流信息
|
||||
*/
|
||||
@SneakyThrows(Exception.class)
|
||||
private KdniaoApiVO getLogisticBase(KdniaoApiDTO queryDTO) {
|
||||
String EBusinessID = queryDTO.getEBusinessID();
|
||||
String ApiKey = queryDTO.getApiKey();
|
||||
String shipperCode = queryDTO.getShipperCode();
|
||||
String logisticCode = queryDTO.getLogisticCode();
|
||||
|
||||
// 组装应用级参数
|
||||
Map<String, String> requestParamMap = new HashMap<>();
|
||||
requestParamMap.put("shipperCode", shipperCode);
|
||||
requestParamMap.put("LogisticCode", logisticCode);
|
||||
String RequestData = JSON.toJSONString(requestParamMap);
|
||||
// 组装系统级参数
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("RequestData", this.urlEncoder(RequestData, "UTF-8"));
|
||||
params.put("EBusinessID", EBusinessID);
|
||||
if(queryDTO.getIsFree()) {
|
||||
params.put("RequestType", "1002");//免费1002 收费8001
|
||||
}else{
|
||||
params.put("RequestType", "8001");
|
||||
}
|
||||
String dataSign = this.encrypt(RequestData, ApiKey, "UTF-8");
|
||||
params.put("DataSign", this.urlEncoder(dataSign, "UTF-8"));
|
||||
params.put("DataType", "2");
|
||||
// 以form表单形式提交post请求,post请求体中包含了应用级参数和系统级参数
|
||||
String resultJson = this.sendPost(KDNIAO_LOGISTIC_QUERY, params);
|
||||
return JSON.parseObject(resultJson, KdniaoApiVO.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 快递查询接口
|
||||
*
|
||||
* @param queryDTO 请求参数
|
||||
* @return 物流信息
|
||||
*/
|
||||
@SneakyThrows(Exception.class)
|
||||
private KdniaoOrderVO getEleCtBase(KdniaoElectronicsOrderDTO queryDTO,
|
||||
List<KdniaoElectronicsOrderGoodsDTO> kdniaoElectronicsOrderGoodsDTOList) {
|
||||
String EBusinessID = queryDTO.getEBusinessID();
|
||||
String ApiKey = queryDTO.getApiKey();
|
||||
|
||||
|
||||
Map<String, Object> requestParamMap = this.doMap(queryDTO,kdniaoElectronicsOrderGoodsDTOList);
|
||||
System.out.println("map:"+requestParamMap);
|
||||
String RequestData = JSON.toJSONString(requestParamMap);
|
||||
// 组装系统级参数
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("RequestData", this.urlEncoder(RequestData, "UTF-8"));
|
||||
params.put("EBusinessID", EBusinessID);
|
||||
params.put("RequestType", "1007");
|
||||
String dataSign = this.encrypt(RequestData, ApiKey, "UTF-8");
|
||||
params.put("DataSign", this.urlEncoder(dataSign, "UTF-8"));
|
||||
params.put("DataType", "2");
|
||||
|
||||
String resultJson = this.sendPost(KDNIAO_ELECT_QUERY, params);
|
||||
return JSON.parseObject(resultJson, KdniaoOrderVO.class);
|
||||
}
|
||||
|
||||
//组合数据
|
||||
private Map<String, Object> doMap(KdniaoElectronicsOrderDTO queryDTO,
|
||||
List<KdniaoElectronicsOrderGoodsDTO> kdniaoElectronicsOrderGoodsDTOList){
|
||||
|
||||
// 组装应用级参数
|
||||
Map<String, Object> requestParamMap = new HashMap<>();
|
||||
requestParamMap.put("MemberID", queryDTO.getMemberID());
|
||||
requestParamMap.put("OrderCode", queryDTO.getOrderCode());
|
||||
requestParamMap.put("ShipperCode", queryDTO.getShipperCode());
|
||||
requestParamMap.put("LogisticCode", queryDTO.getLogisticCode());
|
||||
requestParamMap.put("CustomerName", queryDTO.getCustomerName());
|
||||
requestParamMap.put("CustomerPwd", queryDTO.getCustomerPwd());
|
||||
requestParamMap.put("SendSite", queryDTO.getSendSite());
|
||||
|
||||
requestParamMap.put("PayType", queryDTO.getPaytype());
|
||||
requestParamMap.put("MonthCode", queryDTO.getMonthCode());
|
||||
requestParamMap.put("IsReturnSignBill", queryDTO.getIsReturnSignBill());
|
||||
requestParamMap.put("OperateRequire", queryDTO.getOperateRequire());
|
||||
requestParamMap.put("ExpType", queryDTO.getExpType());
|
||||
requestParamMap.put("Cost", queryDTO.getCost());
|
||||
|
||||
requestParamMap.put("OtherCost", queryDTO.getOtherCost());
|
||||
|
||||
Map<String, Object> senderMap = new HashMap<>();
|
||||
senderMap.put("Name", queryDTO.getName());
|
||||
senderMap.put("Tel", queryDTO.getTel());
|
||||
senderMap.put("Company", queryDTO.getCompany());
|
||||
senderMap.put("Mobile", queryDTO.getMobile());
|
||||
senderMap.put("PostCode", queryDTO.getPostCode());
|
||||
senderMap.put("ProvinceName", queryDTO.getProvinceName());
|
||||
senderMap.put("CityName", queryDTO.getCityName());
|
||||
senderMap.put("ExpAreaName", queryDTO.getExpAreaName());
|
||||
senderMap.put("Address", queryDTO.getAddress());
|
||||
requestParamMap.put("Sender", senderMap);
|
||||
|
||||
Map<String, Object> receiverMap = new HashMap<>();
|
||||
receiverMap.put("Name", queryDTO.getReceiverName());
|
||||
receiverMap.put("Tel", queryDTO.getReceiverTel());
|
||||
receiverMap.put("Company", queryDTO.getReceiverCompany());
|
||||
receiverMap.put("Mobile", queryDTO.getReceiverMobile());
|
||||
receiverMap.put("PostCode", queryDTO.getReceiverPostCode());
|
||||
receiverMap.put("ProvinceName", queryDTO.getReceiverProvinceName());
|
||||
receiverMap.put("CityName", queryDTO.getReceiverCityName());
|
||||
receiverMap.put("ExpAreaName", queryDTO.getReceiverExpAreaName());
|
||||
receiverMap.put("Address", queryDTO.getReceiverAddress());
|
||||
requestParamMap.put("Receiver", receiverMap);
|
||||
|
||||
List<Map<String, Object>> commodityMapList = new ArrayList<>();
|
||||
for (KdniaoElectronicsOrderGoodsDTO kdniaoElectronicsOrderGoodsDTO : kdniaoElectronicsOrderGoodsDTOList) {
|
||||
Map<String, Object> commodityMap = new HashMap<>();
|
||||
commodityMap.put("GoodsName", kdniaoElectronicsOrderGoodsDTO.getGoodsName());
|
||||
commodityMap.put("GoodsCode", kdniaoElectronicsOrderGoodsDTO.getGoodsCode());
|
||||
commodityMap.put("Goodsquantity", kdniaoElectronicsOrderGoodsDTO.getGoodsQuantity());
|
||||
commodityMap.put("GoodsPrice", kdniaoElectronicsOrderGoodsDTO.getGoodsPrice());
|
||||
commodityMap.put("GoodsWeight", kdniaoElectronicsOrderGoodsDTO.getGoodsWeight());
|
||||
commodityMap.put("GoodsVol", kdniaoElectronicsOrderGoodsDTO.getGoodsVol());
|
||||
commodityMap.put("GoodsDesc", kdniaoElectronicsOrderGoodsDTO.getGoodsDesc());
|
||||
|
||||
commodityMapList.add(commodityMap);
|
||||
}
|
||||
|
||||
requestParamMap.put("Commodity", commodityMapList);
|
||||
|
||||
requestParamMap.put("IsNotice", queryDTO.getIsNotice());
|
||||
requestParamMap.put("StartDate", queryDTO.getStartDate());
|
||||
requestParamMap.put("EndDate", queryDTO.getEndDate());
|
||||
requestParamMap.put("Weight", queryDTO.getWeight());
|
||||
requestParamMap.put("Quantity", queryDTO.getQuantity());
|
||||
requestParamMap.put("Volume", queryDTO.getVolume());
|
||||
requestParamMap.put("IsReturnPrintTemplate", queryDTO.getIsReturnTemp());
|
||||
requestParamMap.put("Remark", queryDTO.getRemark());
|
||||
|
||||
return requestParamMap;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* MD5加密
|
||||
* str 内容
|
||||
* charset 编码方式
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private String MD5(String str, String charset) throws Exception {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update(str.getBytes(charset));
|
||||
byte[] result = md.digest();
|
||||
StringBuffer sb = new StringBuffer(32);
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
int val = result[i] & 0xff;
|
||||
if (val <= 0xf) {
|
||||
sb.append("0");
|
||||
}
|
||||
sb.append(Integer.toHexString(val));
|
||||
}
|
||||
return sb.toString().toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* base64编码
|
||||
* str 内容
|
||||
* charset 编码方式
|
||||
*
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
private String base64(String str, String charset) throws UnsupportedEncodingException {
|
||||
String encoded = Base64.encode(str.getBytes(charset));
|
||||
return encoded;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private String urlEncoder(String str, String charset) throws UnsupportedEncodingException {
|
||||
String result = URLEncoder.encode(str, charset);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 电商Sign签名生成
|
||||
* content 内容
|
||||
* keyValue ApiKey
|
||||
* charset 编码方式
|
||||
*
|
||||
* @return DataSign签名
|
||||
* @throws UnsupportedEncodingException ,Exception
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private String encrypt(String content, String keyValue, String charset) throws UnsupportedEncodingException, Exception {
|
||||
if (keyValue != null) {
|
||||
return base64(MD5(content + keyValue, charset), charset);
|
||||
}
|
||||
return base64(MD5(content, charset), charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向指定 URL 发送POST方法的请求
|
||||
* url 发送请求的 URL
|
||||
* params 请求的参数集合
|
||||
*
|
||||
* @return 远程资源的响应结果
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private String sendPost(String url, Map<String, String> params) {
|
||||
OutputStreamWriter out = null;
|
||||
BufferedReader in = null;
|
||||
StringBuilder result = new StringBuilder();
|
||||
try {
|
||||
URL realUrl = new URL(url);
|
||||
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
|
||||
// 发送POST请求必须设置如下两行
|
||||
conn.setDoOutput(true);
|
||||
conn.setDoInput(true);
|
||||
// POST方法
|
||||
conn.setRequestMethod("POST");
|
||||
// 设置通用的请求属性
|
||||
conn.setRequestProperty("accept", "*/*");
|
||||
conn.setRequestProperty("connection", "Keep-Alive");
|
||||
conn.setRequestProperty("user-agent",
|
||||
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
||||
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
conn.connect();
|
||||
// 获取URLConnection对象对应的输出流
|
||||
out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
|
||||
// 发送请求参数
|
||||
if (params != null) {
|
||||
StringBuilder param = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry : params.entrySet()) {
|
||||
if (param.length() > 0) {
|
||||
param.append("&");
|
||||
}
|
||||
param.append(entry.getKey());
|
||||
param.append("=");
|
||||
param.append(entry.getValue());
|
||||
}
|
||||
log.info("[快递鸟] 请求参数: [{}]", param);
|
||||
out.write(param.toString());
|
||||
}
|
||||
// flush输出流的缓冲
|
||||
out.flush();
|
||||
// 定义BufferedReader输入流来读取URL的响应
|
||||
in = new BufferedReader(
|
||||
new InputStreamReader(conn.getInputStream(), "UTF-8"));
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
result.append(line);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//使用finally块来关闭输出流、输入流
|
||||
finally {
|
||||
try {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yshop-module-express</artifactId>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>yshop-module-express-biz</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>
|
||||
快递 模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-module-express-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 业务组件 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>co.yixiang.boot</groupId>-->
|
||||
<!-- <artifactId>yshop-spring-boot-starter-biz-operatelog</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-spring-boot-starter-biz-tenant</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Web 相关 -->
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-spring-boot-starter-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 消息队列相关 -->
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-spring-boot-starter-mq</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Test 测试相关 -->
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- 工具类相关 -->
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-spring-boot-starter-excel</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
package co.yixiang.yshop.module.express.controller.admin.express;
|
||||
|
||||
import co.yixiang.yshop.framework.common.pojo.CommonResult;
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
import co.yixiang.yshop.framework.excel.core.util.ExcelUtils;
|
||||
import co.yixiang.yshop.module.express.controller.admin.express.vo.*;
|
||||
import co.yixiang.yshop.module.express.convert.express.ExpressConvert;
|
||||
import co.yixiang.yshop.module.express.dal.dataobject.express.ExpressDO;
|
||||
import co.yixiang.yshop.module.express.dal.redis.express.ExpressRedisDAO;
|
||||
import co.yixiang.yshop.module.express.kdniao.model.dto.KdniaoApiBaseDTO;
|
||||
import co.yixiang.yshop.module.express.kdniao.model.dto.KdniaoApiDTO;
|
||||
import co.yixiang.yshop.module.express.kdniao.model.vo.KdniaoApiVO;
|
||||
import co.yixiang.yshop.module.express.kdniao.util.KdniaoUtil;
|
||||
import co.yixiang.yshop.module.express.service.express.ExpressService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.pojo.CommonResult.success;
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - 快递公司")
|
||||
@RestController
|
||||
@RequestMapping("/order/express")
|
||||
@Validated
|
||||
public class ExpressController {
|
||||
|
||||
@Resource
|
||||
private ExpressService expressService;
|
||||
@Resource
|
||||
private ExpressRedisDAO expressRedisDAO;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建快递公司")
|
||||
@PreAuthorize("@ss.hasPermission('order:express:create')")
|
||||
public CommonResult<Integer> createExpress(@Valid @RequestBody ExpressCreateReqVO createReqVO) {
|
||||
return success(expressService.createExpress(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新快递公司")
|
||||
@PreAuthorize("@ss.hasPermission('order:express:update')")
|
||||
public CommonResult<Boolean> updateExpress(@Valid @RequestBody ExpressUpdateReqVO updateReqVO) {
|
||||
expressService.updateExpress(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除快递公司")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('order:express:delete')")
|
||||
public CommonResult<Boolean> deleteExpress(@RequestParam("id") Integer id) {
|
||||
expressService.deleteExpress(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得快递公司")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('order:express:query')")
|
||||
public CommonResult<ExpressRespVO> getExpress(@RequestParam("id") Integer id) {
|
||||
ExpressDO express = expressService.getExpress(id);
|
||||
return success(ExpressConvert.INSTANCE.convert(express));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得快递公司列表")
|
||||
@PreAuthorize("@ss.hasPermission('order:express:query')")
|
||||
public CommonResult<List<ExpressRespVO>> getExpressList() {
|
||||
List<ExpressDO> list = expressService.getExpressList();
|
||||
return success(ExpressConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得快递公司分页")
|
||||
@PreAuthorize("@ss.hasPermission('order:express:query')")
|
||||
public CommonResult<PageResult<ExpressRespVO>> getExpressPage(@Valid ExpressPageReqVO pageVO) {
|
||||
PageResult<ExpressDO> pageResult = expressService.getExpressPage(pageVO);
|
||||
return success(ExpressConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出快递公司 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('order:express:export')")
|
||||
public void exportExpressExcel(@Valid ExpressExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<ExpressDO> list = expressService.getExpressList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<ExpressExcelVO> datas = ExpressConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "快递公司.xls", "数据", ExpressExcelVO.class, datas);
|
||||
}
|
||||
|
||||
@GetMapping("/set")
|
||||
@Operation(summary = "获得快递鸟配置")
|
||||
public CommonResult<KdniaoApiBaseDTO> getExpressSet() {
|
||||
return success(expressRedisDAO.get());
|
||||
}
|
||||
|
||||
@PostMapping("/set")
|
||||
@Operation(summary = "快递鸟配置")
|
||||
public CommonResult<Boolean> postExpressSet(@RequestBody KdniaoApiBaseDTO kdniaoApiBaseDTO) {
|
||||
expressRedisDAO.set(kdniaoApiBaseDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/getLogistic")
|
||||
@Parameters({
|
||||
@Parameter(name = "shipperCode", description = "快递公司编码", required = true),
|
||||
@Parameter(name = "logisticCode", description = "快递单号", required = true),
|
||||
})
|
||||
@Operation(summary = "查询物流")
|
||||
public CommonResult<KdniaoApiVO> getLogistic(@RequestParam(value = "shipperCode") String shipperCode,
|
||||
@RequestParam("logisticCode") String logisticCode) {
|
||||
KdniaoApiBaseDTO kdniaoApiBaseDTO = expressRedisDAO.get();
|
||||
KdniaoApiDTO params = new KdniaoApiDTO();
|
||||
params.setLogisticCode(logisticCode);
|
||||
params.setShipperCode(shipperCode);
|
||||
params.setApiKey(kdniaoApiBaseDTO.getApiKey());
|
||||
params.setEBusinessID(kdniaoApiBaseDTO.getEBusinessID());
|
||||
params.setIsFree(kdniaoApiBaseDTO.getIsFree());
|
||||
//此处注意 这个地方分收费与免费当 目前用当免费免费当只支持圆通 申通 百世 如果是收费当 改里面RequestType参数 函数里有说明
|
||||
return success(KdniaoUtil.getLogisticInfo(params));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package co.yixiang.yshop.module.express.controller.admin.express.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 快递公司 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class ExpressBaseVO {
|
||||
|
||||
@Schema(description = "快递公司简称", required = true)
|
||||
@NotNull(message = "快递公司简称不能为空")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "快递公司全称", required = true, example = "yshop")
|
||||
@NotNull(message = "快递公司全称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "排序", required = true)
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package co.yixiang.yshop.module.express.controller.admin.express.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 快递公司创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ExpressCreateReqVO extends ExpressBaseVO {
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package co.yixiang.yshop.module.express.controller.admin.express.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 快递公司 Excel VO
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@Data
|
||||
public class ExpressExcelVO {
|
||||
|
||||
@ExcelProperty("快递公司id")
|
||||
private Integer id;
|
||||
|
||||
@ExcelProperty("快递公司简称")
|
||||
private String code;
|
||||
|
||||
@ExcelProperty("快递公司全称")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty("排序")
|
||||
private Integer sort;
|
||||
|
||||
@ExcelProperty("添加时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package co.yixiang.yshop.module.express.controller.admin.express.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 快递公司 Excel 导出 Request VO,参数和 ExpressPageReqVO 是一致的")
|
||||
@Data
|
||||
public class ExpressExportReqVO {
|
||||
|
||||
@Schema(description = "快递公司简称")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "快递公司全称", example = "yshop")
|
||||
private String name;
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package co.yixiang.yshop.module.express.controller.admin.express.vo;
|
||||
|
||||
import co.yixiang.yshop.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 快递公司分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ExpressPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "快递公司简称")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "快递公司全称", example = "yshop")
|
||||
private String name;
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package co.yixiang.yshop.module.express.controller.admin.express.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 快递公司 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ExpressRespVO extends ExpressBaseVO {
|
||||
|
||||
@Schema(description = "快递公司id", required = true, example = "27172")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "添加时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package co.yixiang.yshop.module.express.controller.admin.express.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 快递公司更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ExpressUpdateReqVO extends ExpressBaseVO {
|
||||
|
||||
@Schema(description = "快递公司id", required = true, example = "27172")
|
||||
@NotNull(message = "快递公司id不能为空")
|
||||
private Integer id;
|
||||
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package co.yixiang.yshop.module.express.controller.app.express;
|
||||
|
||||
import co.yixiang.yshop.framework.common.pojo.CommonResult;
|
||||
import co.yixiang.yshop.module.express.dal.redis.express.ExpressRedisDAO;
|
||||
import co.yixiang.yshop.module.express.kdniao.model.dto.KdniaoApiBaseDTO;
|
||||
import co.yixiang.yshop.module.express.kdniao.model.dto.KdniaoApiDTO;
|
||||
import co.yixiang.yshop.module.express.kdniao.model.vo.KdniaoApiVO;
|
||||
import co.yixiang.yshop.module.express.kdniao.util.KdniaoUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "app - 查询快递")
|
||||
@RestController
|
||||
@RequestMapping("/express")
|
||||
@Validated
|
||||
public class AppExpressController {
|
||||
|
||||
@Resource
|
||||
private ExpressRedisDAO expressRedisDAO;
|
||||
|
||||
|
||||
|
||||
@GetMapping("/getLogistic")
|
||||
@Parameters({
|
||||
@Parameter(name = "shipperCode", description = "快递公司编码", required = true),
|
||||
@Parameter(name = "logisticCode", description = "快递单号", required = true),
|
||||
})
|
||||
@Operation(summary = "查询物流")
|
||||
public CommonResult<KdniaoApiVO> getLogistic(@RequestParam(value = "shipperCode") String shipperCode,
|
||||
@RequestParam("logisticCode") String logisticCode) {
|
||||
KdniaoApiBaseDTO kdniaoApiBaseDTO = expressRedisDAO.get();
|
||||
KdniaoApiDTO params = new KdniaoApiDTO();
|
||||
params.setLogisticCode(logisticCode);
|
||||
params.setShipperCode(shipperCode);
|
||||
params.setApiKey(kdniaoApiBaseDTO.getApiKey());
|
||||
params.setEBusinessID(kdniaoApiBaseDTO.getEBusinessID());
|
||||
params.setIsFree(kdniaoApiBaseDTO.getIsFree());
|
||||
//此处注意 这个地方分收费与免费当 目前用当免费免费当只支持圆通 申通 百世 如果是收费当 改里面RequestType参数 函数里有说明
|
||||
return success(KdniaoUtil.getLogisticInfo(params));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package co.yixiang.yshop.module.express.convert.express;
|
||||
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
import co.yixiang.yshop.module.express.controller.admin.express.vo.ExpressCreateReqVO;
|
||||
import co.yixiang.yshop.module.express.controller.admin.express.vo.ExpressExcelVO;
|
||||
import co.yixiang.yshop.module.express.controller.admin.express.vo.ExpressRespVO;
|
||||
import co.yixiang.yshop.module.express.controller.admin.express.vo.ExpressUpdateReqVO;
|
||||
import co.yixiang.yshop.module.express.dal.dataobject.express.ExpressDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 快递公司 Convert
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@Mapper
|
||||
public interface ExpressConvert {
|
||||
|
||||
ExpressConvert INSTANCE = Mappers.getMapper(ExpressConvert.class);
|
||||
|
||||
ExpressDO convert(ExpressCreateReqVO bean);
|
||||
|
||||
ExpressDO convert(ExpressUpdateReqVO bean);
|
||||
|
||||
ExpressRespVO convert(ExpressDO bean);
|
||||
|
||||
List<ExpressRespVO> convertList(List<ExpressDO> list);
|
||||
|
||||
PageResult<ExpressRespVO> convertPage(PageResult<ExpressDO> page);
|
||||
|
||||
List<ExpressExcelVO> convertList02(List<ExpressDO> list);
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package co.yixiang.yshop.module.express.dal.dataobject.express;
|
||||
|
||||
import co.yixiang.yshop.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 快递公司 DO
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@TableName("yshop_express")
|
||||
@KeySequence("yshop_express_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ExpressDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 快递公司id
|
||||
*/
|
||||
@TableId
|
||||
private Integer id;
|
||||
/**
|
||||
* 快递公司简称
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 快递公司全称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package co.yixiang.yshop.module.express.dal.mysql.express;
|
||||
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
import co.yixiang.yshop.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import co.yixiang.yshop.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import co.yixiang.yshop.module.express.controller.admin.express.vo.ExpressExportReqVO;
|
||||
import co.yixiang.yshop.module.express.controller.admin.express.vo.ExpressPageReqVO;
|
||||
import co.yixiang.yshop.module.express.dal.dataobject.express.ExpressDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 快递公司 Mapper
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@Mapper
|
||||
public interface ExpressMapper extends BaseMapperX<ExpressDO> {
|
||||
|
||||
default PageResult<ExpressDO> selectPage(ExpressPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ExpressDO>()
|
||||
.eqIfPresent(ExpressDO::getCode, reqVO.getCode())
|
||||
.likeIfPresent(ExpressDO::getName, reqVO.getName())
|
||||
.orderByDesc(ExpressDO::getId));
|
||||
}
|
||||
|
||||
default List<ExpressDO> selectList(ExpressExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<ExpressDO>()
|
||||
.eqIfPresent(ExpressDO::getCode, reqVO.getCode())
|
||||
.likeIfPresent(ExpressDO::getName, reqVO.getName())
|
||||
.orderByDesc(ExpressDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package co.yixiang.yshop.module.express.dal.redis;
|
||||
|
||||
import co.yixiang.yshop.framework.redis.core.RedisKeyDefine;
|
||||
import co.yixiang.yshop.module.express.kdniao.model.dto.KdniaoApiBaseDTO;
|
||||
|
||||
import static co.yixiang.yshop.framework.redis.core.RedisKeyDefine.KeyTypeEnum.STRING;
|
||||
|
||||
/**
|
||||
* System Redis Key 枚举类
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
public interface RedisKeyConstants {
|
||||
|
||||
|
||||
RedisKeyDefine YSHOP_EXPRESS_CACHE_KEY = new RedisKeyDefine("快递鸟配置",
|
||||
"yshop_express_cache:", //
|
||||
STRING, KdniaoApiBaseDTO.class, RedisKeyDefine.TimeoutTypeEnum.FOREVER);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package co.yixiang.yshop.module.express.dal.redis.express;
|
||||
|
||||
import co.yixiang.yshop.framework.common.util.json.JsonUtils;
|
||||
import co.yixiang.yshop.framework.tenant.core.context.TenantContextHolder;
|
||||
import co.yixiang.yshop.module.express.kdniao.model.dto.KdniaoApiBaseDTO;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import static co.yixiang.yshop.module.express.dal.redis.RedisKeyConstants.YSHOP_EXPRESS_CACHE_KEY;
|
||||
|
||||
|
||||
/**
|
||||
* {@link KdniaoApiBaseDTO} 的 RedisDAO
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@Repository
|
||||
public class ExpressRedisDAO {
|
||||
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
|
||||
public KdniaoApiBaseDTO get() {
|
||||
String redisKey = formatKey();
|
||||
return JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(redisKey), KdniaoApiBaseDTO.class);
|
||||
}
|
||||
|
||||
public void set(KdniaoApiBaseDTO apiBaseDTO) {
|
||||
String redisKey = formatKey();
|
||||
stringRedisTemplate.opsForValue().set(redisKey, JsonUtils.toJsonString(apiBaseDTO));
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
String redisKey = formatKey();
|
||||
stringRedisTemplate.delete(redisKey);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static String formatKey() {
|
||||
return String.format(YSHOP_EXPRESS_CACHE_KEY.getKeyTemplate());
|
||||
}
|
||||
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package co.yixiang.yshop.module.express.service.express;
|
||||
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
import co.yixiang.yshop.module.express.controller.admin.express.vo.ExpressCreateReqVO;
|
||||
import co.yixiang.yshop.module.express.controller.admin.express.vo.ExpressExportReqVO;
|
||||
import co.yixiang.yshop.module.express.controller.admin.express.vo.ExpressPageReqVO;
|
||||
import co.yixiang.yshop.module.express.controller.admin.express.vo.ExpressUpdateReqVO;
|
||||
import co.yixiang.yshop.module.express.dal.dataobject.express.ExpressDO;
|
||||
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 快递公司 Service 接口
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
public interface ExpressService {
|
||||
|
||||
/**
|
||||
* 创建快递公司
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Integer createExpress(@Valid ExpressCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新快递公司
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateExpress(@Valid ExpressUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除快递公司
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteExpress(Integer id);
|
||||
|
||||
/**
|
||||
* 获得快递公司
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 快递公司
|
||||
*/
|
||||
ExpressDO getExpress(Integer id);
|
||||
|
||||
/**
|
||||
* 获得快递公司列表
|
||||
*
|
||||
* @return 快递公司列表
|
||||
*/
|
||||
List<ExpressDO> getExpressList();
|
||||
|
||||
/**
|
||||
* 获得快递公司分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 快递公司分页
|
||||
*/
|
||||
PageResult<ExpressDO> getExpressPage(ExpressPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得快递公司列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 快递公司列表
|
||||
*/
|
||||
List<ExpressDO> getExpressList(ExpressExportReqVO exportReqVO);
|
||||
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
package co.yixiang.yshop.module.express.service.express;
|
||||
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
import co.yixiang.yshop.module.express.controller.admin.express.vo.ExpressCreateReqVO;
|
||||
import co.yixiang.yshop.module.express.controller.admin.express.vo.ExpressExportReqVO;
|
||||
import co.yixiang.yshop.module.express.controller.admin.express.vo.ExpressPageReqVO;
|
||||
import co.yixiang.yshop.module.express.controller.admin.express.vo.ExpressUpdateReqVO;
|
||||
import co.yixiang.yshop.module.express.convert.express.ExpressConvert;
|
||||
import co.yixiang.yshop.module.express.dal.dataobject.express.ExpressDO;
|
||||
import co.yixiang.yshop.module.express.dal.mysql.express.ExpressMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static co.yixiang.yshop.module.express.enums.ErrorCodeConstants.EXPRESS_NOT_EXISTS;
|
||||
|
||||
|
||||
/**
|
||||
* 快递公司 Service 实现类
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ExpressServiceImpl implements ExpressService {
|
||||
|
||||
@Resource
|
||||
private ExpressMapper expressMapper;
|
||||
|
||||
@Override
|
||||
public Integer createExpress(ExpressCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
ExpressDO express = ExpressConvert.INSTANCE.convert(createReqVO);
|
||||
expressMapper.insert(express);
|
||||
// 返回
|
||||
return express.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateExpress(ExpressUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateExpressExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ExpressDO updateObj = ExpressConvert.INSTANCE.convert(updateReqVO);
|
||||
expressMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteExpress(Integer id) {
|
||||
// 校验存在
|
||||
validateExpressExists(id);
|
||||
// 删除
|
||||
expressMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateExpressExists(Integer id) {
|
||||
if (expressMapper.selectById(id) == null) {
|
||||
throw exception(EXPRESS_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressDO getExpress(Integer id) {
|
||||
return expressMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExpressDO> getExpressList() {
|
||||
return expressMapper.selectList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ExpressDO> getExpressPage(ExpressPageReqVO pageReqVO) {
|
||||
return expressMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExpressDO> getExpressList(ExpressExportReqVO exportReqVO) {
|
||||
return expressMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user