Commit 21738dd8 authored by zhangzc's avatar zhangzc

添加header校验

添加抢单模块
parent 5d5def06
......@@ -3,9 +3,10 @@ package com.esv.freight.app.common.filter;
import com.esv.freight.app.common.response.ECode;
import com.esv.freight.app.common.response.EResponse;
import com.esv.freight.app.common.util.AESSecretUtils;
import com.esv.freight.app.common.util.SecurityUtils;
import com.esv.freight.app.common.wrapper.RestRequestWrapper;
import com.esv.freight.app.module.account.CustomToken;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
......@@ -40,35 +41,75 @@ public class AuthFilter implements Filter {
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
/************************ Token加解密示例 ************************/
log.info(AES_KEY);
String tokenTest = "1,13912345678,sn001," + System.currentTimeMillis();
String accessTokenTest = AESSecretUtils.encryptToStr(tokenTest, AES_KEY);
log.info(tokenTest);
log.info(accessTokenTest);
log.info(AESSecretUtils.decryptToStr(accessTokenTest, AES_KEY));
// log.info(AES_KEY);
// String tokenTest = "1,13912345678,sn001";
// String accessTokenTest = AESSecretUtils.encryptToStr(tokenTest, AES_KEY);
// log.info(tokenTest);
// log.info(accessTokenTest);
// log.info(AESSecretUtils.decryptToStr(accessTokenTest, AES_KEY));
/************************ Token加解密示例 ************************/
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
/**
* APP请求头示例
*
*Map<String,String> map = new HashMap<>();
* map.put("requestSource", "2"); // 访问来源
* map.put("Union-Authorization", AppConfig.getInstance().getToken()); // token
* map.put("osType", osType); // 客户端操作系统名称
* map.put("osVer", osVer); // 客户端操作系统版本
* map.put("mobileId", mobileId); // 手机唯一标识
* map.put("cVer", cVer); // 客户端版本
*/
// 请求来源:1-浏览器端、2-Android端、3-iOS端、4-后台服务端
String requestSource = request.getHeader("requestSource");
if(!"2".equals(requestSource) && !"3".equals(requestSource)) { // 如果不是android或IOS端的请求直接返回
this.errorResponse(EResponse.error(ECode.ACCESS_DENIED), response);
return;
}
String cVer = request.getHeader("cVer");
// TODO 终端程序的版本号,以后当程序升级时可以通过版本检测,过低的版本的请求可能需要返回“您的版本过低,请更新应用!”
String mobileId = request.getHeader("mobileId");
// TODO 设备标识,用于日后消息推送
String token = request.getHeader("Union-Authorization");
log.info(token);
CustomToken customToken = CheckCustomToken.getCustomToken(SecurityUtils.desDecode(AES_KEY, token));
request.setAttribute("tokenInfo", customToken);
log.info(customToken.toString());
Long tenantId = customToken.getTenantId();
// TODO 判断租户ID是否正确,如果不存在此租户,直接返回,目前暂定租户名"100100100"
if(tenantId != 100100100L) {
this.errorResponse(EResponse.error(ECode.TOKEN_INVALID), response);
return;
}
// TODO 如果租户ID正确,进行设置操作,网关请求头
RestRequestWrapper requestWrapper = new RestRequestWrapper((HttpServletRequest)servletRequest);
String url = requestWrapper.getRequestURI();
if("/app/ownerBackend/account/login/loginByPwd".equals(url) ||
"/app/ownerBackend/account/login/loginBySms".equals(url)){
"/app/ownerBackend/account/login/loginBySms".equals(url) ||
"/app/ownerBackend/password/reset".equals(url) ||
"/app/driverBackend/account/login/loginBySms".equals(url) ||
"/app/driverBackend/account/login/loginByPwd".equals(url) ||
"/app/driverBackend/password/reset".equals(url)) {
//此类接口不校验token
}
else {
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
String accessToken = request.getHeader("Union-Authorization");
if (StringUtils.isBlank(accessToken)) {
this.errorResponse(EResponse.error(ECode.TOKEN_INVALID), response);
return;
} else {
// 解析并校验Token
String analysisToken = AESSecretUtils.decryptToStr(accessToken, AES_KEY);
}
log.info("start check");
CheckCustomToken.check(customToken);
log.info("check success");
String userId = customToken.getUserId();
// TODO 将userId进行设置操作,网关请求头
}
filterChain.doFilter(servletRequest, servletResponse);
......
package com.esv.freight.app.common.filter;
import com.esv.freight.app.common.exception.EException;
import com.esv.freight.app.module.account.CustomToken;
import org.apache.commons.lang3.StringUtils;
import java.util.regex.Pattern;
public class CheckCustomToken {
public static CustomToken getCustomToken(String originalToken) {
if (StringUtils.isEmpty(originalToken)) {
throw new EException(601, "无效的Token");
}
String[] ss = originalToken.split(",");
if(ss == null || ss.length != 5) {
throw new EException(601, "无效的Token");
}
CustomToken customToken = new CustomToken();
customToken.setTenantId(Long.parseLong(ss[0]));
customToken.setAccessToken(ss[1]);
customToken.setRefreshToken(ss[2]);
customToken.setUserId(ss[3]);
customToken.setAccount(ss[4].substring(0,11));
return customToken;
}
/**
* 校验token有效性
*/
public static void check(CustomToken customToken) {
if (StringUtils.isEmpty(customToken.getAccount()) || StringUtils.isEmpty(customToken.getAccessToken()) || StringUtils.isEmpty(customToken.getRefreshToken())|| StringUtils.isEmpty(customToken.getUserId())) {
throw new EException(601, "无效的Token");
}
if(!isPhone(customToken.getAccount())) {
throw new EException(601, "无效的Token");
}
}
/**
* 判断是不是一个合法的手机号码
*/
private static boolean isPhone(String phoneNum) {
if (phoneNum == null || phoneNum.trim().length() == 0) {
return false;
}
Pattern PHONE = Pattern.compile("^((1[0-9][0-9]))\\d{8}$");
return PHONE.matcher(phoneNum).matches();
}
}
package com.esv.freight.app.common.util;
import java.io.ByteArrayOutputStream;
/**
* Created by zzc on 2018/8/16.
*/
public class Base64 {
private static final 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', '+', '/' };
private static byte[] base64DecodeChars = new byte[] { -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59,
60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1,
-1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1,
-1, -1 };
private Base64() {
}
public static String encode(byte[] data) {
StringBuffer sb = new StringBuffer();
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();
}
public static byte[] decode(String str) {
byte[] data = str.getBytes();
int len = data.length;
ByteArrayOutputStream buf = new ByteArrayOutputStream(len);
int i = 0;
int b1, b2, b3, b4;
while (i < len) {
/* b1 */
do {
b1 = base64DecodeChars[data[i++]];
} while (i < len && b1 == -1);
if (b1 == -1) {
break;
}
/* b2 */
do {
b2 = base64DecodeChars[data[i++]];
} while (i < len && b2 == -1);
if (b2 == -1) {
break;
}
buf.write((int) ((b1 << 2) | ((b2 & 0x30) >>> 4)));
/* b3 */
do {
b3 = data[i++];
if (b3 == 61) {
return buf.toByteArray();
}
b3 = base64DecodeChars[b3];
} while (i < len && b3 == -1);
if (b3 == -1) {
break;
}
buf.write((int) (((b2 & 0x0f) << 4) | ((b3 & 0x3c) >>> 2)));
/* b4 */
do {
b4 = data[i++];
if (b4 == 61) {
return buf.toByteArray();
}
b4 = base64DecodeChars[b4];
} while (i < len && b4 == -1);
if (b4 == -1) {
break;
}
buf.write((int) (((b3 & 0x03) << 6) | b4));
}
return buf.toByteArray();
}
}
package com.esv.freight.app.common.util;
import com.esv.freight.app.module.account.CustomToken;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
......@@ -20,6 +21,12 @@ public class ReqUtils {
return request.getHeader(headerKey);
}
public static CustomToken getTokenInfo() {
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = servletRequestAttributes.getRequest();
return (CustomToken) request.getAttribute("tokenInfo");
}
/**
* 获得Http客户端的ip
* @param req
......
package com.esv.freight.app.common.util;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import javax.crypto.Cipher;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import java.io.File;
import java.io.FileInputStream;
import java.io.UnsupportedEncodingException;
import java.security.Key;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Locale;
/**
* @description: 加密DES工具类
* @project: SpringCloudTemplate
* @name: com.esv.freight.app.common.util.SecurityUtils
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/04/27 10:00
* @version:1.0
*/
@Slf4j
public class SecurityUtils {
public static final String ALGORITHM_DES = "DES/ECB/NoPadding";
private static byte[] iv = {1, 2, 3, 4, 5, 6, 7, 8};
/**
* MD5加密,使用java.security.MessageDigest过程
*
* @param content
* @return
* @throws NoSuchAlgorithmException
* @throws UnsupportedEncodingException
*/
public static String md5(String content) throws NoSuchAlgorithmException,
UnsupportedEncodingException {
String s = null;
char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f'};
try {
java.security.MessageDigest md = java.security.MessageDigest
.getInstance("MD5");
md.update(content.getBytes());
byte tmp[] = md.digest();
char str[] = new char[16 * 2];
int k = 0;
for (int i = 0; i < 16; i++) {
byte byte0 = tmp[i];
str[k++] = hexDigits[byte0 >>> 4 & 0xf];
str[k++] = hexDigits[byte0 & 0xf];
}
s = new String(str);
} catch (Exception e) {
e.printStackTrace();
}
return s;
}
public static String byte2HexString(byte[] b) {
String a = "";
for (int i = 0; i < b.length; i++) {
String hex = Integer.toHexString(b[i] & 0xFF)
.toUpperCase(Locale.US);
if (hex.length() == 1) {
hex = '0' + hex;
}
a = a + hex;
}
return a;
}
public static byte[] hexString2Byte(String str) {
if (str == null)
return null;
str = str.trim();
int len = str.length();
if (len == 0 || len % 2 == 1)
return null;
byte[] b = new byte[len / 2];
try {
for (int i = 0; i < str.length(); i += 2) {
b[i / 2] = (byte) Integer
.decode("0x" + str.substring(i, i + 2)).intValue();
}
return b;
} catch (Exception e) {
return null;
}
}
/**
* DES算法,加密
*
* @param data 待加密字符串
* @param key 加密私钥,长度不能够小于8位
* @return 加密后的字节数组,一般结合Base64编码使用
* @throws Exception 异常
*/
public static String desEncode(String key, String data) {
String str = "";
try {
str = desEncode(key, data.getBytes());
} catch (Exception e) {
e.printStackTrace();
} finally {
return str;
}
}
/**
* DES算法,加密
*
* @param data 待加密字符串
* @param key 加密私钥,长度不能够小于8位
* @return 加密后的字节数组,一般结合Base64编码使用
* @throws Exception 异常
*/
public static String desEncode(String key, byte[] data) throws Exception {
try {
//加密的位数必须是8的整数倍
int count = data.length / 8;
int m = data.length % 8;
if (count == 0 && m == 0)
return "";
if (m > 0)
count++;
byte[] bts = new byte[count * 8];
System.arraycopy(data, 0, bts, 0, data.length);
DESKeySpec dks = new DESKeySpec(key.getBytes());
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
//key的长度不能够小于8位字节
Key secretKey = keyFactory.generateSecret(dks);
Cipher cipher = Cipher.getInstance(ALGORITHM_DES);
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
byte[] bytes = cipher.doFinal(bts);
return Base64.encode(bytes);
} catch (Exception e) {
throw new Exception(e);
}
}
/**
* des解密操作
*
* @param key 秘钥
* @param b64Data Base64编码方式的密文
* @return 明文
*/
public static String desDecode(String key, String b64Data) {
byte[] data = Base64.decode(b64Data);
byte[] decryptBytes = desDecode(key, data);
if (null == decryptBytes) {
return null;
}
String result = new String(decryptBytes);
// String result = StringUtils.substringBefore(new String(decryptBytes), "\r");
return result;
}
/**
* DES算法,解密
*
* @param data 待解密字符串
* @param key 解密私钥,长度不能够小于8位
* @return 解密后的字节数组
* @throws Exception 异常
*/
public static byte[] desDecode(String key, byte[] data) {
try {
DESKeySpec dks = new DESKeySpec(key.getBytes());
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
//key的长度不能够小于8位字节
Key secretKey = keyFactory.generateSecret(dks);
Cipher cipher = Cipher.getInstance(ALGORITHM_DES);
cipher.init(Cipher.DECRYPT_MODE, secretKey);
return cipher.doFinal(data);
} catch (Exception e) {
log.error("AES解密字符串失败", e.getMessage());
}
return null;
}
/**
* 获取文件的MD5值!
*
* @param
* @return
*/
public static String getFileMD5(String path) {
File file = new File(path);
if (!file.isFile()) {
return "";
}
MessageDigest digest;
FileInputStream in;
byte buffer[] = new byte[1024];
int len;
try {
digest = MessageDigest.getInstance("MD5");
in = new FileInputStream(file);
while ((len = in.read(buffer, 0, 1024)) != -1) {
digest.update(buffer, 0, len);
}
in.close();
} catch (Exception e) {
e.printStackTrace();
return "";
}
return byteArrayToHex(digest.digest());
}
private static String byteArrayToHex(byte[] byteArray) {
String hs = "";
String stmp = "";
for (int n = 0; n < byteArray.length; n++) {
stmp = (Integer.toHexString(byteArray[n] & 0XFF));
if (stmp.length() == 1) {
hs = hs + "0" + stmp;
} else {
hs = hs + stmp;
}
if (n < byteArray.length - 1) {
hs = hs + "";
}
}
return hs;
}
//此函数是pkcs7padding填充函数
public static String pkcs7padding(String data) {
int bs = 16;
int padding = bs - (data.length() % bs);
String padding_text = "";
for (int i = 0; i < padding; i++) {
padding_text += (char) padding;
}
return data + padding_text;
}
}
......@@ -55,4 +55,20 @@ public interface TmsInterface {
*/
@PostMapping(value = "tms/order/detail")
JSONObject getOrderDetail(JSONObject bodyJson);
/**
* 查询抢单信息列表
* @param bodyJson
* @return
*/
@PostMapping(value = "tms/order/grabbing/list")
JSONObject getOrderGrabbingList(JSONObject bodyJson);
/**
* 司机抢单
* @param bodyJson
* @return
*/
@PostMapping(value = "tms/order/grabbing/grab")
JSONObject grabOrder(JSONObject bodyJson);
}
package com.esv.freight.app.module.account;
import com.esv.freight.app.common.exception.EException;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @description: 自定义token
* @project: Freight
* @name: com.esv.freight.app.module.account.CustomToken
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/04/27 14:00
* @version:1.0
*/
@Data
public class CustomToken {
/**
* token格式:
* 租户ID,访问toekn,刷新token,用户ID,登录账号
* String tokenTest = "XXX,XXX,XXX,XXX,XXX"
* String tokenTest = "test001,607083d2ab8d4455adf6c1863eda8944,607083d2ab8d4455adf6c1863eda8944,7,15040196792";
*/
/**
* 用户登录账号
*/
private String account;
/**
* 访问token
*/
private String accessToken;
/**
* 刷新token
*/
private String refreshToken;
/**
* 用户ID(货主APP访问对应货主ID、司机APP访问对应司机ID)
*/
private String userId;
/**
* 租户ID(每个租户下的APP固定传入)
*/
private Long tenantId;
}
......@@ -52,7 +52,7 @@ public class DriverAccountController {
* createTime 2020/04/14 14:00
**/
@PostMapping("/login/loginBySms")
public EResponse loginBySms(@RequestBody(required=false) @Validated(ValidatorLoginBySms.class) LoginForm loginForm) {
public EResponse loginBySms(@RequestHeader @RequestBody(required=false) @Validated(ValidatorLoginBySms.class) LoginForm loginForm) {
// 调用通知服务验证短信接口
JSONObject reqJson = new JSONObject();
......@@ -134,11 +134,16 @@ public class DriverAccountController {
detailVO.setId("12345678");
detailVO.setAccount("15040196726");
detailVO.setAuditStatus(1);
detailVO.setOwnerFullName("测试666");
detailVO.setSourceType("2");
detailVO.setName("测试666");
detailVO.setIdCard("210112198707070023");
detailVO.setIdCardExpireDate("2030-02-05");
detailVO.setIdCardFileFrontURL("1123");
detailVO.setIdCardFileBackURL("4456");
detailVO.setIdCardExpireDate("2030.02.05");
detailVO.setIdCardFileBackId("111");
detailVO.setIdCardFileFrontId("222");
detailVO.setProvinceCode("210000");
detailVO.setCityCode("210100");
detailVO.setDistrictCode("210104");
detailVO.setDetailAddress("惠工街206号卓展中心");
return EResponse.ok(detailVO);
}
}
package com.esv.freight.app.module.account.controller;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.app.common.util.ReqUtils;
import com.esv.freight.app.feign.DictInterface;
import com.esv.freight.app.feign.FileInterface;
import com.esv.freight.app.feign.GoodsOwnerInterface;
import com.esv.freight.app.feign.NoticeInterface;
import com.esv.freight.app.module.account.CustomToken;
import com.esv.freight.app.module.account.form.*;
import com.esv.freight.app.module.account.service.AppLoginService;
import com.esv.freight.app.module.account.validator.groups.ValidatorLoginByPwd;
......@@ -116,8 +118,9 @@ public class OwnerAccountController {
* createTime 2020/04/11 11:00
**/
@PostMapping("/logout")
public EResponse logout(@RequestHeader("Union-Authorization") String accessToken) {
appLoginService.logout(accessToken);
public EResponse logout() {
CustomToken customToken = ReqUtils.getTokenInfo();
appLoginService.logout(customToken.getAccessToken());
return EResponse.ok();
}
......@@ -129,9 +132,10 @@ public class OwnerAccountController {
* createTime 2020/04/13 09:00
**/
@PostMapping("/token/refresh")
public EResponse refresh(@RequestHeader("Union-Authorization") String accessToken, @RequestBody(required=false) @Validated(ValidatorInsert.class) RefreshTokenForm refreshTokenForm) {
public EResponse refresh(@RequestBody(required=false) @Validated(ValidatorInsert.class) RefreshTokenForm refreshTokenForm) {
LoginVO loginByPwdVO = appLoginService.refreshToken(accessToken, refreshTokenForm);
CustomToken customToken = ReqUtils.getTokenInfo();
LoginVO loginByPwdVO = appLoginService.refreshToken(customToken.getAccessToken(), refreshTokenForm);
return EResponse.ok(loginByPwdVO);
}
......@@ -143,8 +147,8 @@ public class OwnerAccountController {
* createTime 2020/04/13 10:00
**/
@PostMapping("/detail")
public EResponse detail(@RequestHeader("Union-Authorization") String accessToken) {
public EResponse detail() {
String accessToken = ReqUtils.getTokenInfo().getAccessToken();
if(appLoginService.isInvalidAccessToken(accessToken)) {
return EResponse.error(ECode.TOKEN_EXPIRED);
}
......@@ -171,12 +175,20 @@ public class OwnerAccountController {
accountDetailVO.setName(result.getJSONObject("data").getString("contactor"));
accountDetailVO.setIdCard(result.getJSONObject("data").getString("idCard"));
accountDetailVO.setIdCardExpireDate(result.getJSONObject("data").getString("idCardExpireDate"));
accountDetailVO.setIdCardFileFrontId(result.getJSONObject("data").getString("idCardFrontUrl"));
accountDetailVO.setIdCardFileBackId(result.getJSONObject("data").getString("idCardBackUrl"));
accountDetailVO.setIdCardFileFrontUrl(result.getJSONObject("data").getString("idCardFrontUrl"));
accountDetailVO.setIdCardFileBackUrl(result.getJSONObject("data").getString("idCardBackUrl"));
accountDetailVO.setProvinceCode(result.getJSONObject("data").getString("provinceCode"));
accountDetailVO.setCityCode(result.getJSONObject("data").getString("cityCode"));
accountDetailVO.setDistrictCode(result.getJSONObject("data").getString("districtCode"));
accountDetailVO.setDetailAddress(result.getJSONObject("data").getString("detailAddress"));
accountDetailVO.setOwnerFullName(result.getJSONObject("data").getString("ownerFullName"));
accountDetailVO.setOwnerBriefName(result.getJSONObject("data").getString("ownerBriefName"));
accountDetailVO.setUniCreditCode(result.getJSONObject("data").getString("uniCreditCode"));
accountDetailVO.setCreditExpireDate(result.getJSONObject("data").getString("creditExpireDate"));
accountDetailVO.setCreditOriginalUrl(result.getJSONObject("data").getString("creditOriginalUrl"));
accountDetailVO.setCreditCopyUrl(result.getJSONObject("data").getString("creditCopyUrl"));
accountDetailVO.setLegalPerson(result.getJSONObject("data").getString("legalPerson"));
accountDetailVO.setLegalPhone(result.getJSONObject("data").getString("legalPhone"));
return EResponse.ok(accountDetailVO);
}
......@@ -188,57 +200,40 @@ public class OwnerAccountController {
* createTime 2020/04/13 10:00
**/
@PostMapping("/realNameAuth")
public EResponse realNameAuth(@RequestHeader("Union-Authorization") String accessToken, @RequestBody(required=false) @Validated(ValidatorInsert.class) RealNameAuthForm realNameAuthForm) {
public EResponse realNameAuth(@RequestBody(required=false) @Validated(ValidatorInsert.class) RealNameAuthForm realNameAuthForm) {
String accessToken = ReqUtils.getTokenInfo().getAccessToken();
if(appLoginService.isInvalidAccessToken(accessToken)) {
return EResponse.error(ECode.TOKEN_EXPIRED);
}
// 调用上传单个文件接口-身份证正面
JSONObject reqJson = new JSONObject();
reqJson.put("fileType", "image");
reqJson.put("fileData", realNameAuthForm.getIdCardFileFront());
reqJson.put("fileName", "idCardFileFront");
log.info(reqJson.toJSONString());
JSONObject result = fileInterface.uploadSingleFile(reqJson);
log.info(result.toJSONString());
if(result.getInteger("code") != 200) {
return EResponse.error(result.getInteger("code"), result.getString("message"));
}
String idCardFrontId = String.valueOf(result.getJSONObject("data").getString("id"));
// 调用上传单个文件接口-身份证反面
reqJson.clear();
reqJson.put("fileType", "image");
reqJson.put("fileData", realNameAuthForm.getIdCardFileBack());
reqJson.put("fileName", "idCardFileBack");
log.info(reqJson.toJSONString());
result = fileInterface.uploadSingleFile(reqJson);
log.info(result.toJSONString());
if(result.getInteger("code") != 200) {
return EResponse.error(result.getInteger("code"), result.getString("message"));
}
String idCardBackId = String.valueOf(result.getJSONObject("data").getString("id"));
// 调用编辑帐号信息接口
reqJson.clear();
JSONObject reqJson = new JSONObject();
reqJson.put("id", realNameAuthForm.getId());
reqJson.put("ownerType", realNameAuthForm.getOwnerType());
reqJson.put("contactor", realNameAuthForm.getName());
reqJson.put("idCard", realNameAuthForm.getIdCard());
reqJson.put("idCardExpireDate", realNameAuthForm.getIdCardExpireDate());
reqJson.put("idCardFrontUrl", idCardFrontId);
reqJson.put("idCardBackUrl", idCardBackId);
reqJson.put("idCardFrontUrl", realNameAuthForm.getIdCardFileFrontUrl());
reqJson.put("idCardBackUrl", realNameAuthForm.getIdCardFileBackUrl());
reqJson.put("detailAddress", realNameAuthForm.getDetailAddress());
reqJson.put("provinceCode", realNameAuthForm.getProvinceCode());
reqJson.put("cityCode", realNameAuthForm.getCityCode());
reqJson.put("districtCode", realNameAuthForm.getDistrictCode());
if("2".equals(realNameAuthForm.getOwnerType())) {
reqJson.put("ownerFullName", realNameAuthForm.getOwnerFullName());
reqJson.put("ownerBriefName", realNameAuthForm.getOwnerBriefName());
reqJson.put("uniCreditCode", realNameAuthForm.getUniCreditCode());
reqJson.put("creditExpireDate", realNameAuthForm.getCreditExpireDate());
reqJson.put("creditOriginalUrl", realNameAuthForm.getCreditOriginalUrl());
reqJson.put("creditCopyUrl", realNameAuthForm.getCreditCopyUrl());
reqJson.put("legalPerson", realNameAuthForm.getLegalPerson());
reqJson.put("legalPhone", realNameAuthForm.getLegalPhone());
}
log.info(reqJson.toJSONString());
result = goodsOwnerInterface.updateAccountInfo(reqJson);
JSONObject result = goodsOwnerInterface.updateAccountInfo(reqJson);
log.info(result.toJSONString());
if(result.getInteger("code") != 200) {
......
......@@ -2,6 +2,7 @@ package com.esv.freight.app.module.account.controller;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.app.common.response.ECode;
import com.esv.freight.app.common.util.ReqUtils;
import com.esv.freight.app.feign.GoodsOwnerInterface;
import com.esv.freight.app.feign.NoticeInterface;
import com.esv.freight.app.module.account.form.LoginForm;
......@@ -104,8 +105,9 @@ public class OwnerPasswordController {
* createTime 2020/04/13 10:00
**/
@PostMapping("/edit")
public EResponse edit(@RequestHeader("Union-Authorization") String accessToken, @RequestBody(required=false) @Validated(ValidatorInsert.class) ModifyPasswordForm modifyPasswordFrom) {
public EResponse edit(@RequestBody(required=false) @Validated(ValidatorInsert.class) ModifyPasswordForm modifyPasswordFrom) {
String accessToken = ReqUtils.getTokenInfo().getAccessToken();
if(appLoginService.isInvalidAccessToken(accessToken)) {
return EResponse.error(ECode.TOKEN_EXPIRED);
}
......
......@@ -41,13 +41,13 @@ public class RealNameAuthForm {
* 身份证正面图片数据
*/
@NotBlank(message = "参数idCardFileFront不能为空", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String idCardFileFront;
private String idCardFileFrontUrl;
/**
* 身份证背面图片数据
*/
@NotBlank(message = "参数idCardFileBack不能为空", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String idCardFileBack;
private String idCardFileBackUrl;
/**
* 姓名
......@@ -97,6 +97,54 @@ public class RealNameAuthForm {
@NotBlank(message = "参数detailAddress不能为空", groups = {ValidatorInsert.class})
private String detailAddress;
/**
* 客户名称
*/
@Length(max = 50, message = "参数ownerFullName长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String ownerFullName;
/**
* 客户简称
*/
@Length(max = 50, message = "参数ownerBriefName长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String ownerBriefName;
/**
* 统一社会信用代码
*/
@Length(max = 20, message = "参数uniCreditCode长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String uniCreditCode;
/**
* 营业期限
*/
@Length(max = 50, message = "参数creditExpireDate长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String creditExpireDate;
/**
* 营业执照正本ULR
*/
@Length(max = 200, message = "参数creditOriginalUrl长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String creditOriginalUrl;
/**
* 营业执照副本ULR
*/
@Length(max = 200, message = "参数creditCopyUrl长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String creditCopyUrl;
/**
* 企业法人姓名
*/
@Length(max = 20, message = "参数legalPerson长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String legalPerson;
/**
* 企业法人手机号
*/
@Length(max = 20, message = "参数legalPhone长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String legalPhone;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
......
......@@ -56,6 +56,7 @@ public class AppLoginImpl extends ServiceImpl<AppLoginDao, AppLoginEntity> imple
appLoginEntity.setLoginStatus("1");
appLoginEntity.setLoginTime(new Date());
appLoginEntity.setRefreshTime(new Date());
appLoginEntity.setLogoutTime(new Date());
appLoginEntity.setAccessTokenValidTime(getFuture(1));
appLoginEntity.setRefreshTokenValidTime(getFuture(30));
this.baseMapper.insert(appLoginEntity);
......
......@@ -17,14 +17,17 @@ public class DriverAccountDetailVO {
// 账号ID
private String id;
// 登录帐号,司机手机号
// 登录帐号,货主手机号
private String account;
// 创建来源:1-平台创建、2-自行注册
private String sourceType;
// 货主帐号审核状态:0-待审核、1-审核成功,2-审核失败,APP自行注册需要平台审核
private Integer auditStatus;
// 姓名
private String ownerFullName;
private String name;
// 身份证号码
private String idCard;
......@@ -32,9 +35,21 @@ public class DriverAccountDetailVO {
// 身份证有效期 格式yyyy.MM.dd,或长期
private String idCardExpireDate;
// 身份证正面图片URL
private String idCardFileFrontURL;
// 身份证正面图片ID
private String idCardFileFrontId;
// 身份证反面图片ID
private String idCardFileBackId;
// 省份代码
private String provinceCode;
// 市代码
private String cityCode;
// 区县代码
private String districtCode;
// 身份证反面图片URL
private String idCardFileBackURL;
// 详细地址
private String detailAddress;
}
......@@ -38,11 +38,11 @@ public class OwnerAccountDetailVO {
// 身份证有效期 格式yyyy.MM.dd,或长期
private String idCardExpireDate;
// 身份证正面图片ID
private String idCardFileFrontId;
// 身份证正面图片ULR
private String idCardFileFrontUrl;
// 身份证反面图片ID
private String idCardFileBackId;
// 身份证反面图片ULR
private String idCardFileBackUrl;
// 省份代码
private String provinceCode;
......@@ -55,4 +55,28 @@ public class OwnerAccountDetailVO {
// 详细地址
private String detailAddress;
// 客户名称
private String ownerFullName;
// 客户简称
private String ownerBriefName;
// 统一社会信用代码
private String uniCreditCode;
// 营业期限
private String creditExpireDate;
// 营业执照正本ULR
private String creditOriginalUrl;
// 营业执照副本ULR
private String creditCopyUrl;
// 企业法人姓名
private String legalPerson;
// 企业法人手机号
private String legalPhone;
}
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.app.common.response.ECode;
import com.esv.freight.app.common.response.EResponse;
import com.esv.freight.app.common.util.ReqUtils;
import com.esv.freight.app.common.validator.groups.*;
import com.esv.freight.app.feign.DeliveryAddressInterface;
import com.esv.freight.app.module.account.service.AppLoginService;
......@@ -51,8 +52,9 @@ public class DeliveryAddressController {
* createTime 2020/04/17 13:00
**/
@PostMapping("/list")
public EResponse list(@RequestHeader("Union-Authorization") String accessToken, @RequestBody(required=false) @Validated(ValidatorList.class) AddressQueryForm addressQueryForm) {
public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) AddressQueryForm addressQueryForm) {
String accessToken = ReqUtils.getTokenInfo().getAccessToken();
if(appLoginService.isInvalidAccessToken(accessToken)) {
return EResponse.error(ECode.TOKEN_EXPIRED);
}
......@@ -93,8 +95,9 @@ public class DeliveryAddressController {
* createTime 2020/04/13 11:00
**/
@PostMapping("/add")
public EResponse add(@RequestHeader("Union-Authorization") String accessToken, @RequestBody(required=false) @Validated(ValidatorInsert.class) DeliveryAddressForm deliveryAddressForm) {
public EResponse add(@RequestBody(required=false) @Validated(ValidatorInsert.class) DeliveryAddressForm deliveryAddressForm) {
String accessToken = ReqUtils.getTokenInfo().getAccessToken();
if(appLoginService.isInvalidAccessToken(accessToken)) {
return EResponse.error(ECode.TOKEN_EXPIRED);
}
......@@ -128,8 +131,9 @@ public class DeliveryAddressController {
* createTime 2020/04/13 11:00
**/
@PostMapping("/edit")
public EResponse edit(@RequestHeader("Union-Authorization") String accessToken, @RequestBody(required=false) @Validated(ValidatorUpdate.class) DeliveryAddressForm deliveryAddressForm) {
public EResponse edit(@RequestBody(required=false) @Validated(ValidatorUpdate.class) DeliveryAddressForm deliveryAddressForm) {
String accessToken = ReqUtils.getTokenInfo().getAccessToken();
if(appLoginService.isInvalidAccessToken(accessToken)) {
return EResponse.error(ECode.TOKEN_EXPIRED);
}
......@@ -162,8 +166,9 @@ public class DeliveryAddressController {
* createTime 2020/04/13 11:00
**/
@PostMapping("/delete")
public EResponse delete(@RequestHeader("Union-Authorization") String accessToken, @RequestBody(required=false) @Validated(ValidatorDelete.class) AddressQueryForm addressQueryForm) {
public EResponse delete(@RequestBody(required=false) @Validated(ValidatorDelete.class) AddressQueryForm addressQueryForm) {
String accessToken = ReqUtils.getTokenInfo().getAccessToken();
if(appLoginService.isInvalidAccessToken(accessToken)) {
return EResponse.error(ECode.TOKEN_EXPIRED);
}
......@@ -188,8 +193,9 @@ public class DeliveryAddressController {
* createTime 2020/04/23 11:00
**/
@PostMapping("/detail")
public EResponse detail(@RequestHeader("Union-Authorization") String accessToken, @RequestBody(required=false) @Validated(ValidatorDetail.class) DeliveryAddressForm deliveryAddressForm) {
public EResponse detail(@RequestBody(required=false) @Validated(ValidatorDetail.class) DeliveryAddressForm deliveryAddressForm) {
String accessToken = ReqUtils.getTokenInfo().getAccessToken();
if(appLoginService.isInvalidAccessToken(accessToken)) {
return EResponse.error(ECode.TOKEN_EXPIRED);
}
......
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.app.common.response.ECode;
import com.esv.freight.app.common.response.EResponse;
import com.esv.freight.app.common.util.ReqUtils;
import com.esv.freight.app.common.validator.groups.ValidatorDetail;
import com.esv.freight.app.common.validator.groups.ValidatorInsert;
import com.esv.freight.app.common.validator.groups.ValidatorList;
......@@ -53,8 +54,9 @@ public class ReceiveAddressController {
* createTime 2020/04/17 13:00
**/
@PostMapping("/list")
public EResponse list(@RequestHeader("Union-Authorization") String accessToken, @RequestBody(required=false) @Validated(ValidatorList.class) AddressQueryForm addressQueryForm) {
public EResponse list(@RequestBody(required=false) @Validated(ValidatorList.class) AddressQueryForm addressQueryForm) {
String accessToken = ReqUtils.getTokenInfo().getAccessToken();
if(appLoginService.isInvalidAccessToken(accessToken)) {
return EResponse.error(ECode.TOKEN_EXPIRED);
}
......@@ -95,8 +97,9 @@ public class ReceiveAddressController {
* createTime 2020/04/13 11:00
**/
@PostMapping("/add")
public EResponse add(@RequestHeader("Union-Authorization") String accessToken, @RequestBody(required=false) @Validated(ValidatorInsert.class) ReceiveAddressForm receiveAddressForm) {
public EResponse add(@RequestBody(required=false) @Validated(ValidatorInsert.class) ReceiveAddressForm receiveAddressForm) {
String accessToken = ReqUtils.getTokenInfo().getAccessToken();
if(appLoginService.isInvalidAccessToken(accessToken)) {
return EResponse.error(ECode.TOKEN_EXPIRED);
}
......@@ -130,8 +133,9 @@ public class ReceiveAddressController {
* createTime 2020/04/13 11:00
**/
@PostMapping("/edit")
public EResponse edit(@RequestHeader("Union-Authorization") String accessToken, @RequestBody(required=false) @Validated(ValidatorInsert.class) ReceiveAddressForm receiveAddressForm) {
public EResponse edit(@RequestBody(required=false) @Validated(ValidatorInsert.class) ReceiveAddressForm receiveAddressForm) {
String accessToken = ReqUtils.getTokenInfo().getAccessToken();
if(appLoginService.isInvalidAccessToken(accessToken)) {
return EResponse.error(ECode.TOKEN_EXPIRED);
}
......@@ -164,8 +168,9 @@ public class ReceiveAddressController {
* createTime 2020/04/13 11:00
**/
@PostMapping("/delete")
public EResponse delete(@RequestHeader("Union-Authorization") String accessToken, @RequestBody(required=false) @Validated(ValidatorInsert.class) AddressQueryForm addressQueryForm) {
public EResponse delete(@RequestBody(required=false) @Validated(ValidatorInsert.class) AddressQueryForm addressQueryForm) {
String accessToken = ReqUtils.getTokenInfo().getAccessToken();
if(appLoginService.isInvalidAccessToken(accessToken)) {
return EResponse.error(ECode.TOKEN_EXPIRED);
}
......@@ -190,8 +195,9 @@ public class ReceiveAddressController {
* createTime 2020/04/23 11:00
**/
@PostMapping("/detail")
public EResponse detail(@RequestHeader("Union-Authorization") String accessToken, @RequestBody(required=false) @Validated(ValidatorDetail.class) ReceiveAddressForm receiveAddressForm) {
public EResponse detail(@RequestBody(required=false) @Validated(ValidatorDetail.class) ReceiveAddressForm receiveAddressForm) {
String accessToken = ReqUtils.getTokenInfo().getAccessToken();
if(appLoginService.isInvalidAccessToken(accessToken)) {
return EResponse.error(ECode.TOKEN_EXPIRED);
}
......
package com.esv.freight.app.module.grabbing.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.app.common.response.ECode;
import com.esv.freight.app.common.response.EResponse;
import com.esv.freight.app.common.validator.groups.ValidatorList;
import com.esv.freight.app.common.validator.groups.ValidatorUpdate;
import com.esv.freight.app.feign.TmsInterface;
import com.esv.freight.app.module.account.service.AppLoginService;
import com.esv.freight.app.module.grabbing.form.OrderGrabbingQueryForm;
import com.esv.freight.app.module.grabbing.vo.GrabListItemVO;
import com.esv.freight.app.module.grabbing.vo.GrabListVO;
import com.esv.freight.app.module.order.vo.OrderStatisticsVO;
import com.mysql.cj.util.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
* @description: 司机找货抢单订单Controller
* @project: Freight
* @name: com.esv.freight.app.module.grabbing.controller.GrabController
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/04/13 13:00
* @version:1.0
*/
@RestController
@RequestMapping("/driverBackend/grab")
@Slf4j
@Validated
public class GrabController {
private AppLoginService appLoginService;
private TmsInterface tmsInterface;
@Autowired
public GrabController(TmsInterface tmsInterface, AppLoginService appLoginService) {
this.appLoginService = appLoginService;
this.tmsInterface = tmsInterface;
}
/**
* description 获取全部路线找货列表
* param param [accessToken]
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/04/24 17:00
**/
@PostMapping("/find/list")
public EResponse getFindGoodsList(@RequestHeader("Union-Authorization") String accessToken, @RequestBody(required=false) @Validated(ValidatorList.class) OrderGrabbingQueryForm orderGrabbingQueryForm) {
if(appLoginService.isInvalidAccessToken(accessToken)) {
return EResponse.error(ECode.TOKEN_EXPIRED);
}
// 调用查询抢单信息列表接口
JSONObject reqJson = new JSONObject();
reqJson.put("vehicleTypeMain", orderGrabbingQueryForm.getVehicleTypeMain());
reqJson.put("vehicleTypeSub", orderGrabbingQueryForm.getVehicleTypeSub());
if(!StringUtils.isNullOrEmpty(orderGrabbingQueryForm.getDeliveryProvinceCode())) {
reqJson.put("deliveryProvinceCode", orderGrabbingQueryForm.getDeliveryProvinceCode());
}
if(!StringUtils.isNullOrEmpty(orderGrabbingQueryForm.getDeliveryCityCode())) {
reqJson.put("deliveryCityCode", orderGrabbingQueryForm.getDeliveryCityCode());
}
if(!StringUtils.isNullOrEmpty(orderGrabbingQueryForm.getReceiveProvinceCode())) {
reqJson.put("receiveProvinceCode", orderGrabbingQueryForm.getReceiveProvinceCode());
}
if(!StringUtils.isNullOrEmpty(orderGrabbingQueryForm.getReceiveCityCode())) {
reqJson.put("receiveCityCode", orderGrabbingQueryForm.getReceiveCityCode());
}
reqJson.put("pageNum", orderGrabbingQueryForm.getPageNum());
reqJson.put("pageSize", orderGrabbingQueryForm.getPageSize());
log.info(reqJson.toJSONString());
JSONObject result = tmsInterface.getOrderGrabbingList(reqJson);
log.info(result.toJSONString());
if(result.getInteger("code") != 200) {
return EResponse.error(result.getInteger("code"), result.getString("message"));
}
GrabListVO grabListVO = new GrabListVO();
JSONObject data = result.getJSONObject("data");
grabListVO.setPageSize(data.getLong("pageSize"));
grabListVO.setPageNum(data.getLong("pageNum"));
grabListVO.setTotal(data.getLong("total"));
grabListVO.setRecordSize(data.getLong("recordSize"));
if(grabListVO.getRecordSize() > 0) {
JSONArray items = data.getJSONArray("records");
List<GrabListItemVO> records = new ArrayList<>();
for(int i=0; i<items.size(); ++i) {
GrabListItemVO vo = new GrabListItemVO();
JSONObject object = items.getJSONObject(i);
vo.setId(object.getLong("orderId"));
vo.setOrderNo(object.getString("orderNo"));
vo.setDeliveryProvinceCode(object.getString("deliveryProvinceCode"));
vo.setDeliveryCityCode(object.getString("deliveryCityCode"));
vo.setReceiveProvinceCode(object.getString("receiveProvinceCode"));
vo.setReceiveCityCode(object.getString("receiveCityCode"));
records.add(vo);
}
grabListVO.setRecord(records);
}
return EResponse.ok(grabListVO);
}
/**
* description 抢单
* param param [accessToken]
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/04/24 17:00
**/
@PostMapping("/find/grab")
public EResponse grabOrder(@RequestHeader("Union-Authorization") String accessToken, @RequestBody(required=false) @Validated(ValidatorUpdate.class) OrderGrabbingQueryForm orderGrabbingQueryForm) {
if (appLoginService.isInvalidAccessToken(accessToken)) {
return EResponse.error(ECode.TOKEN_EXPIRED);
}
// 调用抢单接口
JSONObject reqJson = new JSONObject();
reqJson.put("orderGrabbingId", orderGrabbingQueryForm.getOrderId());
log.info(reqJson.toJSONString());
JSONObject result = tmsInterface.grabOrder(reqJson);
log.info(result.toJSONString());
if(result.getInteger("code") != 200) {
return EResponse.error(result.getInteger("code"), result.getString("message"));
}
return EResponse.ok();
}
}
package com.esv.freight.app.module.grabbing.form;
import com.esv.freight.app.common.validator.groups.ValidatorDetail;
import com.esv.freight.app.common.validator.groups.ValidatorList;
import com.esv.freight.app.common.validator.groups.ValidatorUpdate;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
/**
* @description:
* @project: freight-tms-service
* @name: com.esv.freight.app.module.grabbing.form.OrderGrabbingQueryForm
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/4/24 15:00
* @version:1.0
*/
@Data
public class OrderGrabbingQueryForm {
/**
* 订单ID
*/
@NotNull(message = "参数订单ID不能为空", groups = {ValidatorUpdate.class})
private Long orderId;
/**
* 车辆类型,主类型
*/
@Positive(message = "参数车辆类型(主)不合法", groups = {ValidatorList.class})
private Integer vehicleTypeMain;
/**
* 车辆类型,子类型
*/
@Positive(message = "参数车辆类型(子)不合法", groups = {ValidatorList.class})
private Integer vehicleTypeSub;
/**
* 发货地址 省份
*/
@Length(max = 6, message = "参数发货地址 省份长度不合法", groups = {ValidatorList.class})
private String deliveryProvinceCode;
/**
* 发货地址 城市
*/
@Length(max = 6, message = "参数发货地址 城市长度不合法", groups = {ValidatorList.class})
private String deliveryCityCode;
/**
* 交货地址 省份
*/
@Length(max = 6, message = "参数交货地址 省份长度不合法", groups = {ValidatorList.class})
private String receiveProvinceCode;
/**
* 交货地址 城市
*/
@Length(max = 6, message = "参数交货地址 城市长度不合法", groups = {ValidatorList.class})
private String receiveCityCode;
/**
* 页码
**/
@Range(min = 1, max = 1000, message = "无效的pageNum", groups = {ValidatorList.class})
@NotNull(message = "参数pageNum不能为空", groups = {ValidatorList.class})
private Long pageNum;
/**
* 每页记录条数
**/
@Range(min = 1, max = 1000, message = "pageSize", groups = {ValidatorList.class})
@NotNull(message = "参数pageSize不能为空", groups = {ValidatorList.class})
private Long pageSize;
}
\ No newline at end of file
package com.esv.freight.app.module.grabbing.vo;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @description: 订单列表VO
* @project: Freight
* @name: com.esv.freight.app.module.grabbing.vo.GrabListItemVO
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/04/24 16:00
* @version:1.0
*/
@Data
public class GrabListItemVO {
/**
* 抢单ID
*/
private Long id;
/**
* 订单号
*/
private String orderNo;
/**
* 发货地址 省份
*/
private String deliveryProvinceCode;
/**
* 发货地址 城市
*/
private String deliveryCityCode;
/**
* 交货地址 省份
*/
private String receiveProvinceCode;
/**
* 交货地址 城市
*/
private String receiveCityCode;
/**
* 货物类型
*/
private Integer goodsType;
/**
* 货物名称编码
*/
private Integer goodsName;
/**
* 货物订单量
*/
private BigDecimal goodsTotalAmount;
/**
* 货物单位
*/
private String goodsUnit;
/**
* 要求发货时间
*/
private Date requiredDeliveryTime;
/**
* 订单创建时间
*/
private Date createTime;
/**
* 订单来源
*/
private String orderSource;
/**
* 运费单价(支出)
*/
private BigDecimal freightUnitPriceOutput;
/**
* 需求车辆数
*/
private Integer requiredVehicleCount;
/**
* 当前抢单车辆数
*/
private Integer currentVehicleCount;
}
package com.esv.freight.app.module.grabbing.vo;
import lombok.Data;
import java.util.List;
/**
* @description: 订单列表VO
* @project: Freight
* @name: com.esv.freight.app.module.grabbing.vo.GrabListVO
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/04/24 16:00
* @version:1.0
*/
@Data
public class GrabListVO {
/**
* 每页记录条数
**/
private Long pageSize;
/**
* 当前页码
**/
private Long pageNum;
/**
* 总记录条数
**/
private Long total;
/**
* 当前页的记录条数
**/
private Long recordSize;
/**
* 数据
**/
private List<GrabListItemVO> record;
}
......@@ -21,9 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
......
package com.esv.freight.app.module.waybill.controller;
import com.esv.freight.app.common.response.ECode;
import com.esv.freight.app.common.response.EResponse;
import com.esv.freight.app.common.validator.groups.ValidatorDetail;
import com.esv.freight.app.common.validator.groups.ValidatorList;
import com.esv.freight.app.feign.TmsInterface;
import com.esv.freight.app.module.account.service.AppLoginService;
import com.esv.freight.app.module.waybill.form.WaybillQueryForm;
import com.esv.freight.app.module.waybill.vo.WaybillListItemVO;
import com.esv.freight.app.module.waybill.vo.WaybillListVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @description: 司机运单Controller
......@@ -19,4 +33,80 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
@Validated
public class DriverWaybillController {
private AppLoginService appLoginService;
private TmsInterface tmsInterface;
private WaybillListVO mWaybillListVO;
private void createTestData() {
mWaybillListVO = new WaybillListVO();
List<WaybillListItemVO> verifyList = new ArrayList<>();
WaybillListItemVO itemVO = new WaybillListItemVO();
itemVO.setId(10056L);
itemVO.setWaybillNO("YD202004221300002");
itemVO.setOrderNO("D2020042109300101");
itemVO.setWaybillState(5);
itemVO.setDeliveryCity("210100");
itemVO.setReceiveCity("210100");
itemVO.setGoodsName(1101);
itemVO.setGoodsTotalAmount(new BigDecimal(26));
itemVO.setGoodsUnit("吨");
itemVO.setCreateTime(new Date());
itemVO.setRequiredReceiveTime(new Date());
itemVO.setRequiredDeliveryTime(new Date());
itemVO.setVehicleNum("辽A12345");
verifyList.add(itemVO);
mWaybillListVO.setPageNum(1L);
mWaybillListVO.setPageSize(20L);
mWaybillListVO.setTotal(1L);
mWaybillListVO.setRecordSize(1L);
mWaybillListVO.setRecord(verifyList);
}
@Autowired
public DriverWaybillController(TmsInterface tmsInterface, AppLoginService appLoginService) {
this.appLoginService = appLoginService;
this.tmsInterface = tmsInterface;
createTestData();
}
/**
* description 获取运单列表
* param [accessToken, waybillQueryForm]
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/04/26 115:00
**/
@PostMapping("/list")
public EResponse list(@RequestHeader("Union-Authorization") String accessToken, @RequestBody(required=false) @Validated(ValidatorList.class) WaybillQueryForm waybillQueryForm) {
if(appLoginService.isInvalidAccessToken(accessToken)) {
return EResponse.error(ECode.TOKEN_EXPIRED);
}
//TODO 调用获取运单列表接口
return EResponse.ok(mWaybillListVO);
}
/**
* description 获取运单列表
* param [accessToken, waybillQueryForm]
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/04/26 115:00
**/
@PostMapping("/detail")
public EResponse detail(@RequestHeader("Union-Authorization") String accessToken, @RequestBody(required=false) @Validated(ValidatorDetail.class) WaybillQueryForm waybillQueryForm) {
if(appLoginService.isInvalidAccessToken(accessToken)) {
return EResponse.error(ECode.TOKEN_EXPIRED);
}
//TODO 调用获取运单详情接口
return EResponse.ok(mWaybillListVO);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment