merge
This commit is contained in:
@@ -93,6 +93,70 @@ public class CommonEnum {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 快递鸟物流状态
|
||||
*/
|
||||
public enum ExpressStatusEnum {
|
||||
NO_MSG("无信息", 0),
|
||||
HAS_TAKE("已取件", 1),
|
||||
ON_THE_WAY("在途中", 2),
|
||||
RECEIVED("已签收", 3),
|
||||
QUESTION("问题件", 4),
|
||||
TO_TAKE("待取件", 5),
|
||||
TO_SEND("待派件", 6),
|
||||
HAS_BEEN_SHIPPED("已发货", 8),
|
||||
UFILLED("未发货", 9);
|
||||
private String name;
|
||||
private int value;
|
||||
|
||||
ExpressStatusEnum(String name, int value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 快递鸟 快递公司编码
|
||||
*/
|
||||
public enum ShipperCodeEnum {
|
||||
SF("顺丰速运", "SF"),
|
||||
HTKY("百世快递", "HTKY"),
|
||||
ZTO("中通快递", "ZTO"),
|
||||
STO("申通快递", "STO"),
|
||||
YTO("圆通速递", "YTO"),
|
||||
YD("韵达速递", "YD"),
|
||||
YZPY("邮政快递包裹", "YZPY"),
|
||||
EMS("EMS", "EMS"),
|
||||
HHTT("天天快递", "HHTT"),
|
||||
JD("京东物流", "JD"),
|
||||
AMAZON("亚马逊", "AMAZON"),
|
||||
ZJS("宅急送", "ZJS");
|
||||
private String name;
|
||||
private String code;
|
||||
|
||||
ShipperCodeEnum(String name, String code) {
|
||||
this.name = name;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String code = "Y";
|
||||
// for (YesOrNoEnum yesOrNoEnum : YesOrNoEnum.values()) {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.xwbing.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/17 9:26
|
||||
* 作者: xiangwb
|
||||
* 说明: 快递信息
|
||||
*/
|
||||
@Data
|
||||
@ApiModel
|
||||
public class ExpressInfo {
|
||||
@ApiModelProperty(value = "快递公司编号", example = "HTKY")
|
||||
private String shipperCode;
|
||||
@ApiModelProperty(value = "物流单号", example = "211386517825")
|
||||
private String logisticCode;
|
||||
// @ApiModelProperty(value = "快递名称", example = "百世汇通")
|
||||
// private String expressName;
|
||||
// @ApiModelProperty(value = "订单编号", example = "201703140000000018")
|
||||
// private String orderNo;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.xwbing.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/17 9:22
|
||||
* 作者: xiangwb
|
||||
* 说明: 快递追踪信息
|
||||
*/
|
||||
@Data
|
||||
public class Trace {
|
||||
private String AcceptTime;
|
||||
private String AcceptStation;
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.xwbing.entity;
|
||||
package com.xwbing.entity.sys;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.xwbing.entity;
|
||||
package com.xwbing.entity.sys;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.xwbing.entity;
|
||||
package com.xwbing.entity.sys;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.xwbing.entity;
|
||||
package com.xwbing.entity.sys;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.xwbing.entity;
|
||||
package com.xwbing.entity.sys;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.xwbing.entity;
|
||||
package com.xwbing.entity.sys;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.xwbing.entity;
|
||||
package com.xwbing.entity.sys;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.xwbing.entity;
|
||||
package com.xwbing.entity.sys;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.xwbing.entity.vo;
|
||||
|
||||
import com.xwbing.entity.Trace;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/17 9:20
|
||||
* 作者: xiangwb
|
||||
* 说明: 快递信息展示
|
||||
*/
|
||||
@Data
|
||||
public class ExpressInfoVo {
|
||||
/**
|
||||
* 快递代码
|
||||
*/
|
||||
private String ShipperCode;
|
||||
private Boolean Success;
|
||||
/**
|
||||
* 运单号
|
||||
*/
|
||||
private String LogisticCode;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String State;
|
||||
/**
|
||||
* 物流信息
|
||||
*/
|
||||
private List<Trace> traces;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String describe;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.xwbing.entity.vo;
|
||||
|
||||
import com.xwbing.entity.SysAuthority;
|
||||
import com.xwbing.entity.sys.SysAuthority;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.List;
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/14 15:43
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
* 说明: 权限树信息
|
||||
*/
|
||||
@Data
|
||||
public class SysAuthVo extends SysAuthority {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.xwbing.repository.sys;
|
||||
|
||||
import com.xwbing.entity.SysAuthority;
|
||||
import com.xwbing.entity.sys.SysAuthority;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.xwbing.repository.sys;
|
||||
|
||||
import com.xwbing.entity.SysConfig;
|
||||
import com.xwbing.entity.sys.SysConfig;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.xwbing.repository.sys;
|
||||
|
||||
import com.xwbing.entity.SysRoleAuthority;
|
||||
import com.xwbing.entity.sys.SysRoleAuthority;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.xwbing.repository.sys;
|
||||
|
||||
import com.xwbing.entity.SysRole;
|
||||
import com.xwbing.entity.sys.SysRole;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.xwbing.repository.sys;
|
||||
|
||||
import com.xwbing.entity.SysUserLoginInOut;
|
||||
import com.xwbing.entity.sys.SysUserLoginInOut;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.xwbing.repository.sys;
|
||||
|
||||
import com.xwbing.entity.SysUser;
|
||||
import com.xwbing.entity.sys.SysUser;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
/**
|
||||
* 说明:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.xwbing.repository.sys;
|
||||
|
||||
import com.xwbing.entity.SysUserRole;
|
||||
import com.xwbing.entity.sys.SysUserRole;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.xwbing.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xwbing.constant.CommonEnum;
|
||||
import com.xwbing.entity.ExpressInfo;
|
||||
import com.xwbing.entity.vo.ExpressInfoVo;
|
||||
import com.xwbing.exception.BusinessException;
|
||||
import com.xwbing.util.KdniaoUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.xwbing.util.KdniaoUtil.urlEncoder;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/17 9:14
|
||||
* 作者: xiangwb
|
||||
* 说明: 快递查询服务层
|
||||
*/
|
||||
@Service
|
||||
@PropertySource("classpath:kdniao.properties")
|
||||
public class ExpressDeliveryService {
|
||||
private final Logger logger = LoggerFactory.getLogger(ExpressDeliveryService.class);
|
||||
/**
|
||||
* 电商用户ID
|
||||
*/
|
||||
@Value("${EBusinessID}")
|
||||
private String EBusinessID;
|
||||
/**
|
||||
* 电商加密私钥
|
||||
*/
|
||||
@Value("${appKey}")
|
||||
private String appKey;
|
||||
/**
|
||||
* 正式请求url
|
||||
*/
|
||||
@Value("${reqURL}")
|
||||
private String reqURL;
|
||||
|
||||
/**
|
||||
* 快递公司列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<JSONObject> listShipperCode() {
|
||||
List<JSONObject> resultVos = new ArrayList<>();
|
||||
JSONObject jsonObject;
|
||||
for (CommonEnum.ShipperCodeEnum shipperCode : CommonEnum.ShipperCodeEnum.values()) {
|
||||
jsonObject = new JSONObject();
|
||||
jsonObject.put("code", shipperCode.getCode());
|
||||
jsonObject.put("name", shipperCode.getName());
|
||||
resultVos.add(jsonObject);
|
||||
}
|
||||
return resultVos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 快递信息查询
|
||||
*
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
public ExpressInfoVo queryOrderTraces(ExpressInfo info) {
|
||||
String requestData = "{'ShipperCode':'" + info.getShipperCode() + "','LogisticCode':'" + info.getLogisticCode() + "'}";
|
||||
Map<String, String> params = new HashMap<>();
|
||||
try {
|
||||
params.put("RequestData", urlEncoder(requestData, "UTF-8"));
|
||||
params.put("EBusinessID", EBusinessID);
|
||||
params.put("RequestType", "1002");
|
||||
String dataSign = KdniaoUtil.encrypt(requestData, appKey, "UTF-8");
|
||||
params.put("DataSign", urlEncoder(dataSign, "UTF-8"));
|
||||
params.put("DataType", "2");
|
||||
} catch (Exception e) {
|
||||
logger.error("快递查询出错:{}", e.getMessage());
|
||||
throw new BusinessException("快递查询出错");
|
||||
}
|
||||
// 返回物流信息
|
||||
// status: 0|null 无信息 1已取件 2在途中 3已签收 4问题件 5待取件 6待派件 8已发货 9未发货
|
||||
String result = KdniaoUtil.sendPost(reqURL, params);
|
||||
ExpressInfoVo infoVo = JSONObject.parseObject(result, ExpressInfoVo.class);
|
||||
if (infoVo != null) {
|
||||
logger.info("查询快递信息:{}", infoVo.getSuccess());
|
||||
String status = infoVo.getState();
|
||||
if (StringUtils.isEmpty(status)) {
|
||||
status = String.valueOf(0);
|
||||
}
|
||||
int statusValue = Integer.valueOf(status);
|
||||
CommonEnum.ExpressStatusEnum expressStatus = Arrays.stream(CommonEnum.ExpressStatusEnum.values()).filter(obj -> obj.getValue() == statusValue).findFirst().get();
|
||||
infoVo.setDescribe(expressStatus.getName());
|
||||
// TODO: 2017/11/17 根据公司业务处理返回的信息......
|
||||
}
|
||||
return infoVo;
|
||||
}
|
||||
|
||||
// DEMO
|
||||
public static void main(String[] args) {
|
||||
ExpressDeliveryService api = new ExpressDeliveryService();
|
||||
ExpressInfo info = new ExpressInfo();
|
||||
info.setShipperCode("HTKY");
|
||||
info.setLogisticCode("211386517825");
|
||||
try {
|
||||
ExpressInfoVo result = api.queryOrderTraces(info);
|
||||
String status = result.getState();
|
||||
if (StringUtils.isEmpty(status)) {
|
||||
status = String.valueOf(0);
|
||||
}
|
||||
String describe = null;
|
||||
//更新订单物流状态
|
||||
for (CommonEnum.ExpressStatusEnum statusEnum : CommonEnum.ExpressStatusEnum.values()) {
|
||||
int value = statusEnum.getValue();
|
||||
if (Integer.valueOf(status) == value) {
|
||||
describe = statusEnum.getName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
// TODO: 2017/11/17
|
||||
System.out.print(describe);
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.xwbing.service.sys;
|
||||
|
||||
import com.xwbing.constant.CommonConstant;
|
||||
import com.xwbing.entity.SysAuthority;
|
||||
import com.xwbing.entity.SysRoleAuthority;
|
||||
import com.xwbing.entity.sys.SysAuthority;
|
||||
import com.xwbing.entity.sys.SysRoleAuthority;
|
||||
import com.xwbing.entity.vo.SysAuthVo;
|
||||
import com.xwbing.exception.BusinessException;
|
||||
import com.xwbing.repository.sys.SysAuthorityRepository;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.xwbing.service.sys;
|
||||
|
||||
import com.xwbing.entity.SysConfig;
|
||||
import com.xwbing.entity.sys.SysConfig;
|
||||
import com.xwbing.exception.BusinessException;
|
||||
import com.xwbing.repository.sys.SysConfigRepository;
|
||||
import com.xwbing.util.PassWordUtil;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.xwbing.service.sys;
|
||||
|
||||
import com.xwbing.entity.SysRoleAuthority;
|
||||
import com.xwbing.entity.sys.SysRoleAuthority;
|
||||
import com.xwbing.repository.sys.SysRoleAuthorityRepository;
|
||||
import com.xwbing.util.PassWordUtil;
|
||||
import com.xwbing.util.RestMessage;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.xwbing.service.sys;
|
||||
|
||||
import com.xwbing.entity.SysRole;
|
||||
import com.xwbing.entity.SysRoleAuthority;
|
||||
import com.xwbing.entity.SysUserRole;
|
||||
import com.xwbing.entity.sys.SysRole;
|
||||
import com.xwbing.entity.sys.SysRoleAuthority;
|
||||
import com.xwbing.entity.sys.SysUserRole;
|
||||
import com.xwbing.exception.BusinessException;
|
||||
import com.xwbing.repository.sys.SysRoleRepository;
|
||||
import com.xwbing.util.PassWordUtil;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.xwbing.service.sys;
|
||||
|
||||
import com.xwbing.constant.CommonEnum;
|
||||
import com.xwbing.entity.SysUser;
|
||||
import com.xwbing.entity.SysUserLoginInOut;
|
||||
import com.xwbing.entity.sys.SysUser;
|
||||
import com.xwbing.entity.sys.SysUserLoginInOut;
|
||||
import com.xwbing.repository.sys.SysUserLoginInOutRepository;
|
||||
import com.xwbing.util.DateUtil2;
|
||||
import com.xwbing.util.PassWordUtil;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.xwbing.service.sys;
|
||||
|
||||
import com.xwbing.entity.SysUserRole;
|
||||
import com.xwbing.entity.sys.SysUserRole;
|
||||
import com.xwbing.repository.sys.SysUserRoleRepository;
|
||||
import com.xwbing.util.PassWordUtil;
|
||||
import com.xwbing.util.RestMessage;
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.xwbing.service.sys;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xwbing.constant.CommonConstant;
|
||||
import com.xwbing.constant.CommonEnum;
|
||||
import com.xwbing.entity.*;
|
||||
import com.xwbing.entity.model.EmailModel;
|
||||
import com.xwbing.entity.sys.*;
|
||||
import com.xwbing.exception.BusinessException;
|
||||
import com.xwbing.repository.sys.SysUserRepository;
|
||||
import com.xwbing.util.*;
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
package com.xwbing.util;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/16 17:46
|
||||
* 作者: xiangwb
|
||||
* 说明: 快递鸟工具类
|
||||
* 文档: http://www.kdniao.com/documents
|
||||
*/
|
||||
public class KdniaoUtil {
|
||||
/**
|
||||
* 向指定 URL 发送POST方法的请求
|
||||
*
|
||||
* @param url 发送请求的 URL
|
||||
* @param params 请求的参数集合
|
||||
* @return 远程资源的响应结果
|
||||
*/
|
||||
public static 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());
|
||||
System.out.println(entry.getKey() + ":" + entry.getValue());
|
||||
}
|
||||
System.out.println("param:" + param.toString());
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param str 内容
|
||||
* @param charset 编码方式
|
||||
* @return
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
public static String urlEncoder(String str, String charset) throws UnsupportedEncodingException {
|
||||
return URLEncoder.encode(str, charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 电商Sign签名生成
|
||||
*
|
||||
* @param content 内容
|
||||
* @param keyValue Appkey
|
||||
* @param charset 编码方式
|
||||
* @return DataSign签名
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String encrypt(String content, String keyValue, String charset) throws Exception {
|
||||
if (keyValue != null) {
|
||||
return base64(MD5(content + keyValue, charset), charset);
|
||||
}
|
||||
return base64(MD5(content, charset), charset);
|
||||
}
|
||||
|
||||
private static char[] base64EncodeChars = new char[]{'A', 'B', 'C', 'D',
|
||||
'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
|
||||
'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
|
||||
'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
|
||||
'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3',
|
||||
'4', '5', '6', '7', '8', '9', '+', '/'};
|
||||
|
||||
/**
|
||||
* MD5加密
|
||||
*
|
||||
* @param str 内容
|
||||
* @param charset 编码方式
|
||||
* @throws Exception
|
||||
*/
|
||||
private static String MD5(String str, String charset) throws Exception {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update(str.getBytes(charset));
|
||||
byte[] result = md.digest();
|
||||
StringBuilder sb = new StringBuilder(32);
|
||||
for (byte aResult : result) {
|
||||
int val = aResult & 0xff;
|
||||
if (val <= 0xf) {
|
||||
sb.append("0");
|
||||
}
|
||||
sb.append(Integer.toHexString(val));
|
||||
}
|
||||
return sb.toString().toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* base64编码
|
||||
*
|
||||
* @param str 内容
|
||||
* @param charset 编码方式
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
private static String base64(String str, String charset) throws UnsupportedEncodingException {
|
||||
return base64Encode(str.getBytes(charset));
|
||||
}
|
||||
|
||||
private static String base64Encode(byte[] data) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int len = data.length;
|
||||
int i = 0;
|
||||
int b1, b2, b3;
|
||||
while (i < len) {
|
||||
b1 = data[i++] & 0xff;
|
||||
if (i == len) {
|
||||
sb.append(base64EncodeChars[b1 >>> 2]);
|
||||
sb.append(base64EncodeChars[(b1 & 0x3) << 4]);
|
||||
sb.append("==");
|
||||
break;
|
||||
}
|
||||
b2 = data[i++] & 0xff;
|
||||
if (i == len) {
|
||||
sb.append(base64EncodeChars[b1 >>> 2]);
|
||||
sb.append(base64EncodeChars[((b1 & 0x03) << 4)
|
||||
| ((b2 & 0xf0) >>> 4)]);
|
||||
sb.append(base64EncodeChars[(b2 & 0x0f) << 2]);
|
||||
sb.append("=");
|
||||
break;
|
||||
}
|
||||
b3 = data[i++] & 0xff;
|
||||
sb.append(base64EncodeChars[b1 >>> 2]);
|
||||
sb.append(base64EncodeChars[((b1 & 0x03) << 4)
|
||||
| ((b2 & 0xf0) >>> 4)]);
|
||||
sb.append(base64EncodeChars[((b2 & 0x0f) << 2)
|
||||
| ((b3 & 0xc0) >>> 6)]);
|
||||
sb.append(base64EncodeChars[b3 & 0x3f]);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#---------------快递鸟config----------------
|
||||
###------------ID和Key请到官网申请:http://www.kdniao.com/ServiceApply.aspx-------------###
|
||||
EBusinessID=1255383
|
||||
appKey=94f7286a-8ae5-4394-8809-26dd645e82ca
|
||||
reqURL=http://api.kdniao.cc/Ebusiness/EbusinessOrderHandle.aspx
|
||||
@@ -1,15 +1,20 @@
|
||||
package com.xwbing.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xwbing.annotation.LogInfo;
|
||||
import com.xwbing.entity.ExpressInfo;
|
||||
import com.xwbing.entity.vo.ExpressInfoVo;
|
||||
import com.xwbing.redis.RedisService;
|
||||
import com.xwbing.service.ExpressDeliveryService;
|
||||
import com.xwbing.util.JSONObjResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 说明: 测试控制层
|
||||
@@ -23,6 +28,8 @@ import javax.annotation.Resource;
|
||||
public class TestControl {
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
@Resource
|
||||
private ExpressDeliveryService expressDeliveryService;
|
||||
private final Logger logger = LoggerFactory.getLogger(TestControl.class);
|
||||
|
||||
@LogInfo("redis功能测试")
|
||||
@@ -39,4 +46,21 @@ public class TestControl {
|
||||
logger.info("info test");
|
||||
logger.error("error test");
|
||||
}
|
||||
|
||||
@LogInfo("获取快递列表")
|
||||
@GetMapping("listShipperCode")
|
||||
public JSONObject listShipperCode() {
|
||||
List<JSONObject> list = expressDeliveryService.listShipperCode();
|
||||
return JSONObjResult.toJSONObj(list, true, "");
|
||||
}
|
||||
|
||||
|
||||
@LogInfo("快递查询")
|
||||
@PostMapping("expressInfo")
|
||||
public JSONObject getExpressInfo(@RequestBody ExpressInfo info) {
|
||||
if (StringUtils.isEmpty(info.getLogisticCode()) || StringUtils.isEmpty(info.getShipperCode()))
|
||||
return JSONObjResult.toJSONObj("快递公司或物流单号不能为空");
|
||||
ExpressInfoVo infoVo = expressDeliveryService.queryOrderTraces(info);
|
||||
return JSONObjResult.toJSONObj(infoVo, true, "查询快递信息成功");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.xwbing.annotation.LogInfo;
|
||||
import com.xwbing.constant.CommonConstant;
|
||||
import com.xwbing.constant.CommonEnum;
|
||||
import com.xwbing.entity.SysAuthority;
|
||||
import com.xwbing.entity.sys.SysAuthority;
|
||||
import com.xwbing.entity.vo.SysAuthVo;
|
||||
import com.xwbing.redis.RedisService;
|
||||
import com.xwbing.service.sys.SysAuthorityService;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.xwbing.controller.sys;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xwbing.entity.SysConfig;
|
||||
import com.xwbing.entity.sys.SysConfig;
|
||||
import com.xwbing.service.sys.SysConfigService;
|
||||
import com.xwbing.util.JSONObjResult;
|
||||
import com.xwbing.util.RestMessage;
|
||||
|
||||
@@ -2,9 +2,9 @@ package com.xwbing.controller.sys;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xwbing.annotation.LogInfo;
|
||||
import com.xwbing.entity.SysAuthority;
|
||||
import com.xwbing.entity.SysRole;
|
||||
import com.xwbing.entity.SysRoleAuthority;
|
||||
import com.xwbing.entity.sys.SysAuthority;
|
||||
import com.xwbing.entity.sys.SysRole;
|
||||
import com.xwbing.entity.sys.SysRoleAuthority;
|
||||
import com.xwbing.service.sys.SysAuthorityService;
|
||||
import com.xwbing.service.sys.SysRoleAuthorityService;
|
||||
import com.xwbing.service.sys.SysRoleService;
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.xwbing.annotation.LogInfo;
|
||||
import com.xwbing.constant.CommonConstant;
|
||||
import com.xwbing.constant.CommonEnum;
|
||||
import com.xwbing.entity.SysAuthority;
|
||||
import com.xwbing.entity.SysRole;
|
||||
import com.xwbing.entity.SysUser;
|
||||
import com.xwbing.entity.SysUserRole;
|
||||
import com.xwbing.entity.sys.SysAuthority;
|
||||
import com.xwbing.entity.sys.SysRole;
|
||||
import com.xwbing.entity.sys.SysUser;
|
||||
import com.xwbing.entity.sys.SysUserRole;
|
||||
import com.xwbing.service.sys.SysAuthorityService;
|
||||
import com.xwbing.service.sys.SysRoleService;
|
||||
import com.xwbing.service.sys.SysUserRoleService;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.xwbing.controller.sys;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xwbing.annotation.LogInfo;
|
||||
import com.xwbing.entity.SysUserLoginInOut;
|
||||
import com.xwbing.entity.sys.SysUserLoginInOut;
|
||||
import com.xwbing.service.sys.SysUserLoginInOutService;
|
||||
import com.xwbing.util.JSONObjResult;
|
||||
import io.swagger.annotations.Api;
|
||||
|
||||
Reference in New Issue
Block a user