fix:高德打车正式环境配置
This commit is contained in:
parent
3a1b59c779
commit
a674b0e571
|
@ -0,0 +1,11 @@
|
|||
package com.chint.application.dtos.system;
|
||||
|
||||
public class SupplierRedirectDTO {
|
||||
private String redirectUrl;
|
||||
|
||||
public static SupplierRedirectDTO of(String redirectUrl) {
|
||||
SupplierRedirectDTO supplierRedirectDTO = new SupplierRedirectDTO();
|
||||
supplierRedirectDTO.redirectUrl = redirectUrl;
|
||||
return supplierRedirectDTO;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.chint.application.dtos.system;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserLoginSupplierParam {
|
||||
private String employeeNo;
|
||||
private String supplierName;
|
||||
}
|
|
@ -42,6 +42,10 @@ public class SupplierLoginService {
|
|||
return lyLoginRequest.loginPC(L_Y_ENTRANCE_HOME, getEmployeeNo(supplierLoginParam.getRouteId()));
|
||||
}
|
||||
|
||||
public LYRedirectUrlResponse lyLoginPC(String employeeNo) {
|
||||
return lyLoginRequest.loginPC(L_Y_ENTRANCE_HOME, employeeNo);
|
||||
}
|
||||
|
||||
public H5LoginResponse cTripLogin(SupplierLoginParam supplierLoginParam) {
|
||||
return cTripLoginRequest.hSingleLogin(getEmployeeNo(supplierLoginParam.getRouteId()));
|
||||
}
|
||||
|
@ -50,6 +54,10 @@ public class SupplierLoginService {
|
|||
return cTripLoginRequest.authLogin(getEmployeeNo(supplierLoginParam.getRouteId()));
|
||||
}
|
||||
|
||||
public PCLoginResponse cTripLoginPC(String employeeNo) {
|
||||
return cTripLoginRequest.authLogin(employeeNo);
|
||||
}
|
||||
|
||||
public H5LoginResponse cTripLoginHtml(SupplierLoginParam supplierLoginParam) {
|
||||
return cTripLoginRequest.hSingleLoginHtml(getEmployeeNo(supplierLoginParam.getRouteId()));
|
||||
}
|
||||
|
@ -62,6 +70,10 @@ public class SupplierLoginService {
|
|||
return amapLoginRequest.h5LoginByEmployeeNo(getEmployeeNo(supplierLoginParam.getRouteId()));
|
||||
}
|
||||
|
||||
public H5LoginResponse amapLoginHtml(String employeeNo) {
|
||||
return amapLoginRequest.h5LoginByEmployeeNo(employeeNo);
|
||||
}
|
||||
|
||||
private String getEmployeeNo(Long routeId) {
|
||||
if (routeId != null) {
|
||||
RouteOrder routeOrder = routeRepository.queryById(routeId);
|
||||
|
|
|
@ -3,10 +3,14 @@ package com.chint.application.system;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.chint.application.dtos.response.UserRes;
|
||||
import com.chint.application.dtos.system.RoleOrgParam;
|
||||
import com.chint.application.dtos.system.SupplierRedirectDTO;
|
||||
import com.chint.application.dtos.system.UserLoginSupplierParam;
|
||||
import com.chint.application.services.SupplierLoginService;
|
||||
import com.chint.domain.aggregates.user.Role;
|
||||
import com.chint.domain.aggregates.user.RoleUser;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.aggregates.user.UserDepartmentInfo;
|
||||
import com.chint.domain.exceptions.NotFoundException;
|
||||
import com.chint.domain.repository.RoleRepository;
|
||||
import com.chint.domain.repository.RoleUserRepository;
|
||||
import com.chint.domain.repository.UserRepository;
|
||||
|
@ -26,6 +30,7 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
|
||||
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
|
||||
import static com.chint.infrastructure.constant.SupplierNameConstant.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/users")
|
||||
|
@ -49,6 +54,9 @@ public class UserController {
|
|||
@Autowired
|
||||
private SystemDomainService systemDomainService;
|
||||
|
||||
@Autowired
|
||||
private SupplierLoginService supplierLoginService;
|
||||
|
||||
@ApiOperation("根据Id查询用户信息")
|
||||
@PostMapping("/query")
|
||||
public Result<UserRes> getUserByEmployeeNo() {
|
||||
|
@ -56,6 +64,23 @@ public class UserController {
|
|||
return Result.Success(SUCCESS, BeanUtil.copyProperties(currentUser, UserRes.class));
|
||||
}
|
||||
|
||||
@ApiOperation("根据用户工号登录到供应商")
|
||||
@PostMapping("/login/supplier")
|
||||
public Result<SupplierRedirectDTO> loginSupplier(@RequestBody UserLoginSupplierParam param) {
|
||||
String supplierName = param.getSupplierName();
|
||||
SupplierRedirectDTO supplierRedirectDTO = switch (supplierName) {
|
||||
case SUPPLIER_C_TRIP ->
|
||||
SupplierRedirectDTO.of(supplierLoginService.cTripLoginPC(param.getEmployeeNo()).getRedirectUrl());
|
||||
case SUPPLIER_L_Y ->
|
||||
SupplierRedirectDTO.of(supplierLoginService.lyLoginPC(param.getEmployeeNo()).getRedirectUrl());
|
||||
case SUPPLIER_AMAP ->
|
||||
SupplierRedirectDTO.of(supplierLoginService.amapLoginHtml(param.getEmployeeNo()).getRedirectUrl());
|
||||
default -> throw new NotFoundException("未知供应商");
|
||||
};
|
||||
return Result.Success(SUCCESS, supplierRedirectDTO);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("分页查看角色数据")
|
||||
@PostMapping("/query/role")
|
||||
public Result<PageResult<RoleVO>> queryRole(@RequestBody RoleOrgParam roleOrgParam) {
|
||||
|
@ -128,7 +153,8 @@ public class UserController {
|
|||
|
||||
@ApiOperation("获取当前登录用户信息")
|
||||
@PostMapping("/current")
|
||||
public Result<User> currentUser() {
|
||||
return Result.Success(SUCCESS, BaseContext.getCurrentUser());
|
||||
public Result<UserRes> currentUser() {
|
||||
User currentUser = BaseContext.getCurrentUser().loadRoleOrg();
|
||||
return Result.Success(SUCCESS, BeanUtil.copyProperties(currentUser, UserRes.class));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,7 +139,9 @@ public class AmapUserRequest implements UserSync {
|
|||
userParam.setUserId(user.getEmployeeNo());
|
||||
userParam.setEmail(user.getEmail());
|
||||
userParam.setMobile(user.getPhoneNumber());
|
||||
userParam.setRealName(user.getName());
|
||||
userNameRepository.findByEmployeeNo(user.getEmployeeNo()).ifPresentOrElse(
|
||||
it -> userParam.setRealName(it.getIdName()),
|
||||
() -> userParam.setRealName(user.getName()));
|
||||
return userParam;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package com.chint.interfaces.rest.amap.in;
|
||||
|
||||
import com.chint.application.commands.OrderStatusChangeCommand;
|
||||
import com.chint.application.commands.SupplierCallBackErrorCommand;
|
||||
import com.chint.domain.aggregates.order.OrderDetail;
|
||||
import com.chint.domain.service.supplier.SupplierService;
|
||||
import com.chint.domain.value_object.SupplierCallbackData;
|
||||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
|
@ -13,6 +11,7 @@ import com.chint.interfaces.rest.amap.request.AmapOrderDetailRequest;
|
|||
import com.google.gson.Gson;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -21,13 +20,13 @@ import org.springframework.web.util.UriUtils;
|
|||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TAXI;
|
||||
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP;
|
||||
import static com.chint.interfaces.rest.amap.util.AmapStatusUtil.checkCarStatus;
|
||||
import static com.chint.interfaces.rest.amap.util.AmapStatusUtil.mapCarStatus;
|
||||
import static com.chint.interfaces.rest.amap.util.AmapStatusUtil.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
|
@ -42,6 +41,11 @@ public class AmapNoteController {
|
|||
@Autowired
|
||||
private SupplierService supplierService;
|
||||
|
||||
@Value("${amap.aesKey}")
|
||||
private String aesKey;
|
||||
@Value("${amap.signKey}")
|
||||
private String signKey;
|
||||
|
||||
@PostMapping("/status")
|
||||
public AmapNoteResponse statusEvent(@RequestBody String in) {
|
||||
String requestBody = in;
|
||||
|
@ -64,6 +68,14 @@ public class AmapNoteController {
|
|||
}
|
||||
|
||||
AmapNoteParam amapNoteParam = AmapNoteParam.convert(params);
|
||||
// params.entrySet().forEach(it -> {
|
||||
// if (it.getValue() == null || it.getValue().isEmpty()) {
|
||||
// it.setValue("\"\"");
|
||||
// }
|
||||
// });
|
||||
// String generateSing = calculateSign(params, signKey, List.of("sign"));
|
||||
// String sign = amapNoteParam.getSign();
|
||||
|
||||
String json = gson.toJson(amapNoteParam);
|
||||
log.info(json);
|
||||
|
||||
|
|
|
@ -1,5 +1,19 @@
|
|||
package com.chint.interfaces.rest.amap.util;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.hash.Hashing;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.chint.infrastructure.constant.FSSCConstant.FSSC_CAR_STATUS_REFUND;
|
||||
import static com.chint.infrastructure.constant.FSSCConstant.FSSC_CAR_STATUS_SUCCESS;
|
||||
import static com.chint.infrastructure.constant.OrderConstant.*;
|
||||
|
@ -59,4 +73,63 @@ public class AmapStatusUtil {
|
|||
"99";
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* jdk 1.8及以上的签名计算方式
|
||||
* 1、过滤不加签参数
|
||||
* 2、对参数的key值按ASCII码自然排序
|
||||
* 3、参数按照 key=value&拼接
|
||||
* 4、最后拼接 @signKey
|
||||
* 5、对拼接后的字符串做MD5,得到sign值
|
||||
*
|
||||
* @param paramsMap
|
||||
* @return
|
||||
*/
|
||||
public static String calculateSign(Map<String, String> paramsMap, String signKey, List<String> UN_SIGN_KEYS) {
|
||||
String originParamStr = paramsMap.entrySet().stream()
|
||||
.filter(entry -> !UN_SIGN_KEYS.contains(entry.getKey()))
|
||||
.sorted(Map.Entry.comparingByKey())
|
||||
.map(entry -> entry.getKey() + "=" + entry.getValue())
|
||||
.collect(Collectors.joining("&"));
|
||||
originParamStr = originParamStr + "@" + signKey;
|
||||
System.out.println(originParamStr);
|
||||
return Hashing.md5().hashString(originParamStr, Charsets.UTF_8).toString().toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密算法
|
||||
*
|
||||
* @param inParameter 解密串
|
||||
* @param aesKey aes加密秘钥
|
||||
* @return 解密后的明文数据
|
||||
*/
|
||||
public static String decrypt(String inParameter, String aesKey) throws Exception {
|
||||
byte[] inData = Base64.decodeBase64(inParameter);
|
||||
byte[] iv = Arrays.copyOfRange(inData, 0, 16);
|
||||
inData = Arrays.copyOfRange(inData, 16, inData.length);
|
||||
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
SecretKeySpec k = new SecretKeySpec(aesKey.getBytes(), "AES");
|
||||
cipher.init(Cipher.DECRYPT_MODE, k, new IvParameterSpec(iv));
|
||||
return new String(cipher.doFinal(inData), "utf-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* 加密算法
|
||||
*
|
||||
* @param inParameter 加密前的原始数据串
|
||||
* @param aesKey aes加密秘钥
|
||||
* @return 加密后的密文串
|
||||
*/
|
||||
public static String encrypt(String input, String aesKey) throws Exception {
|
||||
byte[] iv = new byte[16];
|
||||
new Random().nextBytes(iv);
|
||||
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
SecretKeySpec k = new SecretKeySpec(aesKey.getBytes(), "AES");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, k, new IvParameterSpec(iv));
|
||||
byte[] e = cipher.doFinal(input.getBytes("utf-8"));
|
||||
|
||||
return new String(Base64.encodeBase64(ArrayUtils.addAll(iv, e)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.chint.interfaces.rest.data_center.user;
|
||||
|
||||
import com.chint.application.commands.UserDisabledCommand;
|
||||
import com.chint.application.commands.UserSFCommand;
|
||||
import com.chint.dc.api.DataCenterResult;
|
||||
import com.chint.dc.api.dto.DataCenterOption;
|
||||
import com.chint.dc.api.service.DataCenterService;
|
||||
|
@ -9,10 +10,11 @@ import com.chint.domain.repository.StaffRankRepository;
|
|||
import com.chint.domain.repository.UserRepository;
|
||||
import com.chint.domain.service.JTCompanyDomainService;
|
||||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
import com.chint.interfaces.rest.amap.AmapUserRequest;
|
||||
import com.chint.interfaces.rest.ctrip.CTripUserSaveRequest;
|
||||
import com.chint.interfaces.rest.ly.LYUserRequest;
|
||||
import com.chint.interfaces.rest.data_center.user.dto.AccessKeyDTO;
|
||||
import com.chint.interfaces.rest.data_center.user.dto.UserDataDTO;
|
||||
import com.chint.interfaces.rest.ly.LYUserRequest;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -66,6 +68,9 @@ public class BatchUserWorker {
|
|||
@Autowired
|
||||
private UserHttpRequestImpl userHttpRequest;
|
||||
|
||||
@Autowired
|
||||
private AmapUserRequest amapUserRequest;
|
||||
|
||||
private AccessKeyDTO akSkLoad() {
|
||||
String asSkUrl = AK_BASE_URL + GET_AK_URL + "?systemId=" + systemId;
|
||||
HttpClient client = HttpClients.createDefault();
|
||||
|
@ -227,10 +232,21 @@ public class BatchUserWorker {
|
|||
}
|
||||
|
||||
|
||||
public void asyncUserToAmap(String employeeNo) {
|
||||
Optional.ofNullable(userRepository.findByUserEmployeeNo(employeeNo))
|
||||
.ifPresentOrElse(user -> amapUserRequest.syncUser(user), () ->
|
||||
amapUserRequest.syncUser(
|
||||
userHttpRequest.loadSFInfo(Command.of(UserSFCommand.class).user(User.withEmployeeNo(employeeNo)))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static <T> boolean isNullOrEmpty(List<T> list) {
|
||||
if (list == null) {
|
||||
return true;
|
||||
}
|
||||
return list.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -44,14 +44,14 @@ ly:
|
|||
|
||||
#高德
|
||||
amap:
|
||||
eId: 612660
|
||||
appId: car_zhengtecm3noxh
|
||||
key: a1vxgdwobkphirln5fgup0oj6e2rsniw
|
||||
keyt: car_zhengtecm3noxh
|
||||
signKey: ngwdzlembqju9lairthw264bzkhw2vto
|
||||
aesKey: 7eEdUzuVflM8n9Wo
|
||||
baseUrl: https://sns.testing.amap.com
|
||||
baseLoginUrl: https://pre-hailing.amap.com
|
||||
eId: 201107
|
||||
appId: car_zhengtveefkay6
|
||||
key: vibcxd6ltlxxuct0j9sc079u0rdaur0s
|
||||
keyt: car_zhengtveefkay6
|
||||
signKey: fb0jcukg6hjbn2k2cxedvweux4uozzxo
|
||||
aesKey: UTatMtHBBVzc05PY
|
||||
baseUrl: https://gws.amap.com
|
||||
baseLoginUrl: https://dache.amap.com
|
||||
sf:
|
||||
openApiBaseUrl: https://openapi.chint.com
|
||||
akBaseUrl: https://transitbridge.chint.com
|
||||
|
|
|
@ -166,6 +166,9 @@ class RouteApplicationTests {
|
|||
@Autowired
|
||||
private OrgRequest orgRequest;
|
||||
|
||||
@Autowired
|
||||
private BatchUserWorker batchUserWorker;
|
||||
|
||||
|
||||
@Test
|
||||
void testQueryIdsFromCache() {
|
||||
|
@ -299,7 +302,7 @@ class RouteApplicationTests {
|
|||
|
||||
@Test
|
||||
void loginSign() {
|
||||
String sfno = "220727017";
|
||||
String sfno = "230615020";
|
||||
String syscode = "FSSC";
|
||||
String billcode = "CLSQ240225000099";
|
||||
String companycode = "正泰集团股份有限公司";
|
||||
|
@ -379,6 +382,17 @@ class RouteApplicationTests {
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
void postUserToAmap(){
|
||||
// 读取文件内容
|
||||
String filePath = "D:\\data\\routeData\\itinerary_booking_user_employee_no.sql"; // 修改为实际文件路径
|
||||
String s = readFileAsString(filePath);
|
||||
String[] split = s.replace("'", "").split(", ");
|
||||
for (String employeeNo : split) {
|
||||
batchUserWorker.asyncUserToAmap(employeeNo);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void post() {
|
||||
|
||||
|
|
Loading…
Reference in New Issue