完成离职人员关卡

This commit is contained in:
lulz1 2024-05-06 16:17:27 +08:00
parent 487055cbd2
commit 266889852b
19 changed files with 248 additions and 48 deletions

View File

@ -0,0 +1,18 @@
package com.chint.application.commands;
import com.chint.domain.aggregates.user.User;
import com.chint.infrastructure.echo_framework.command.Command;
import lombok.Data;
import java.util.List;
@Data
public class UserDisabledCommand extends Command {
private User user;
private List<User> userList;
public UserDisabledCommand user(User user) {
this.user = user;
return this;
}
}

View File

@ -12,6 +12,7 @@ import com.chint.infrastructure.util.PageResult;
import com.chint.infrastructure.util.Result; import com.chint.infrastructure.util.Result;
import com.chint.interfaces.rest.ctrip.order.CTripOrderRecordAutoSave; import com.chint.interfaces.rest.ctrip.order.CTripOrderRecordAutoSave;
import com.chint.interfaces.rest.ly.reconciliation.dto.PageInfo; import com.chint.interfaces.rest.ly.reconciliation.dto.PageInfo;
import com.chint.interfaces.rest.user.BatchUserWorker;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -38,6 +39,18 @@ public class AutoWorkController {
@Autowired @Autowired
private LyStatementOrder lyStatementOrder; private LyStatementOrder lyStatementOrder;
@Autowired
private BatchUserWorker batchUserWorker;
@ApiOperation("用户状态检查,离职用户将关闭开卡")
@PostMapping("/user/status/check")
public Result<String> autoCheckUserStatus(){
batchUserWorker.checkUserStatus();
return Result.Success(SUCCESS);
}
@Transactional @Transactional
@ApiOperation("自动拉取昨天的流水号每天晚上8点执行") @ApiOperation("自动拉取昨天的流水号每天晚上8点执行")
@PostMapping("/cTrip/record/save") @PostMapping("/cTrip/record/save")

View File

@ -150,11 +150,9 @@ public class LoginController {
@PostMapping("/AN/login/sso") @PostMapping("/AN/login/sso")
public Result<UserLoginResult> ANLoginSSO(@RequestBody UserLoginParam userLoginParam) { public Result<UserLoginResult> ANLoginSSO(@RequestBody UserLoginParam userLoginParam) {
String employeeNo = anFeiShuLoginStrategy.login(userLoginParam.getCode()); String employeeNo = anFeiShuLoginStrategy.login(userLoginParam.getCode());
userLoginParam.setSfno(employeeNo); userLoginParam.setSfno(employeeNo);
UserLoginResult userLoginResult = authenticateService UserLoginResult userLoginResult = authenticateService
.authenticateEmployeeNo(userLoginParam); .authenticateEmployeeNo(userLoginParam);
//异步执行更新用户信息到同程 //异步执行更新用户信息到同程
User currentUser = BaseContext.getCurrentUser(); User currentUser = BaseContext.getCurrentUser();
loginEventBoarder(currentUser); loginEventBoarder(currentUser);
@ -163,7 +161,6 @@ public class LoginController {
private void loginEventBoarder(User user) { private void loginEventBoarder(User user) {
Command.of(UserSFCommand.class).user(user).sendToQueue();
Command.of(UserLoginCommand.class).user(user).sendToQueue(); Command.of(UserLoginCommand.class).user(user).sendToQueue();
user.setSyncTime(LocalDateTime.now()); user.setSyncTime(LocalDateTime.now());
userRepository.save(user); userRepository.save(user);

View File

@ -7,7 +7,7 @@ import com.chint.domain.aggregates.user.UserDepartmentInfo;
import com.chint.domain.repository.UserRepository; import com.chint.domain.repository.UserRepository;
import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.util.Result; import com.chint.infrastructure.util.Result;
import com.chint.interfaces.rest.user.PushUser; import com.chint.interfaces.rest.user.BatchUserWorker;
import com.chint.interfaces.rest.user.UserHttpRequest; import com.chint.interfaces.rest.user.UserHttpRequest;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -22,7 +22,7 @@ import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
public class UserController { public class UserController {
@Autowired @Autowired
private PushUser pushUser; private BatchUserWorker pushUser;
@Autowired @Autowired
private UserRepository userRepository; private UserRepository userRepository;

View File

@ -57,6 +57,7 @@ public class User implements Serializable {
private String phoneNumber; private String phoneNumber;
private String password; private String password;
private LocalDateTime syncTime; private LocalDateTime syncTime;
private Integer status;
@Transient @Transient
private String manaLevel; private String manaLevel;
@Transient @Transient
@ -82,6 +83,12 @@ public class User implements Serializable {
if (this.userDepartmentInfoList == null || this.userDepartmentInfoList.isEmpty()) { if (this.userDepartmentInfoList == null || this.userDepartmentInfoList.isEmpty()) {
//如果发现 用户的 部门信息为空 那么直接调用 sf查询 //如果发现 用户的 部门信息为空 那么直接调用 sf查询
Command.of(UserSFCommand.class).user(this).sendToQueue(); Command.of(UserSFCommand.class).user(this).sendToQueue();
} else {
for (UserDepartmentInfo userDepartmentInfo : userDepartmentInfoList) {
if (userDepartmentInfo.getUname() == null) {
Command.of(UserSFCommand.class).user(this).sendToQueue();
}
}
} }
if (userDepartmentInfoList == null) { if (userDepartmentInfoList == null) {
throw new NotFoundException(SF_DATA_NOT_EXIST); throw new NotFoundException(SF_DATA_NOT_EXIST);
@ -116,7 +123,6 @@ public class User implements Serializable {
UserDepartmentInfo fallbackDeptInfo = getFallbackDeptInfo(); UserDepartmentInfo fallbackDeptInfo = getFallbackDeptInfo();
loadInfoFromDeptInfo(fallbackDeptInfo); loadInfoFromDeptInfo(fallbackDeptInfo);
} }
return this; return this;
} }

View File

@ -392,9 +392,6 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
hotelOrderDetail = new HotelOrderDetail(); hotelOrderDetail = new HotelOrderDetail();
} }
// hotelOrderDetail.setSupplier(SUPPLIER_C_TRIP_EXTENSION_NAME);
hotelOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP); hotelOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP);
if (routeOrder != null) { if (routeOrder != null) {
@ -421,7 +418,10 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
user = userRepository.findByUserEmployeeNo(EmployeeNo); user = userRepository.findByUserEmployeeNo(EmployeeNo);
} }
Optional<OrderDetail> first = routeOrder.getOrderDetails().stream().filter(orderDetail -> orderDetail.getOrderNo().equals(orderNo)).findFirst(); Optional<OrderDetail> first = routeOrder
.getOrderDetails()
.stream()
.filter(orderDetail -> orderDetail.getOrderNo().equals(orderNo)).findFirst();
first.ifPresent(orderDetail -> { first.ifPresent(orderDetail -> {
OrderEvent lastEvent = orderDetail.getLastEvent(); OrderEvent lastEvent = orderDetail.getLastEvent();
if (lastEvent != null) { if (lastEvent != null) {
@ -546,6 +546,8 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
@Override @Override
public HotelOrderDetail updateHotelOrderDetailData(HotelOrderDetail hotelOrderDetail, Object hotelOrderInfo) { public HotelOrderDetail updateHotelOrderDetailData(HotelOrderDetail hotelOrderDetail, Object hotelOrderInfo) {
return null; return null;
} }

View File

@ -2,8 +2,20 @@ package com.chint.domain.repository;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import java.util.List;
public interface UserRepository { public interface UserRepository {
User findById(Long id); User findById(Long id);
User findByUserEmployeeNo(String employeeNo); User findByUserEmployeeNo(String employeeNo);
User save(User user); User save(User user);
void saveAll(List<User> userList);
List<User> findAll();
List<User> findByStatus(Integer status);
List<User> findByStatusIsNull();
} }

View File

@ -16,6 +16,7 @@ import com.chint.infrastructure.echo_framework.annotation.ListenTo;
import com.chint.infrastructure.echo_framework.command.Command; import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.infrastructure.repository.jdbc.JdbcLegRepository; import com.chint.infrastructure.repository.jdbc.JdbcLegRepository;
import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository; import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository;
import com.chint.infrastructure.util.DateTimeUtil;
import com.chint.interfaces.rest.bpm.BPMParamFactory; import com.chint.interfaces.rest.bpm.BPMParamFactory;
import com.chint.interfaces.rest.bpm.BPMRequest; import com.chint.interfaces.rest.bpm.BPMRequest;
import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest; import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest;
@ -211,7 +212,7 @@ public class OrderDomainService {
if (!orderEventType.equals(ORDER_EVENT_ETA) && orderDetail.getProductType().equals(LEG_TYPE_AIRPLANE)) { if (!orderEventType.equals(ORDER_EVENT_ETA) && orderDetail.getProductType().equals(LEG_TYPE_AIRPLANE)) {
cTripFlightRefundAndChangeOrder(orderDetail.getOrderNo()); cTripFlightRefundAndChangeOrder(orderDetail.getOrderNo());
} }
if (!orderEventType.equals(ORDER_EVENT_ETA) && orderDetail.getProductType().equals(LEG_TYPE_HOTEL)) { if (orderDetail.getProductType().equals(LEG_TYPE_HOTEL)) {
cTripHotelRefundAndChangeOrder(orderDetail.getOrderNo()); cTripHotelRefundAndChangeOrder(orderDetail.getOrderNo());
} }
if (!orderEventType.equals(ORDER_EVENT_ETA) && orderDetail.getProductType().equals(LEG_TYPE_TAXI)) { if (!orderEventType.equals(ORDER_EVENT_ETA) && orderDetail.getProductType().equals(LEG_TYPE_TAXI)) {
@ -309,17 +310,16 @@ public class OrderDomainService {
private void cTripHotelRefundAndChangeOrder(String orderNo) { private void cTripHotelRefundAndChangeOrder(String orderNo) {
SearchOrderResponse response = cTripOrderSearchRequest.searchOrderResponseByOrderId(orderNo); SearchOrderResponse response = cTripOrderSearchRequest.searchOrderResponseByOrderId(orderNo);
HotelOrderInfoEntity flightOrderInfoEntity = response.getItineraryList().get(0).getHotelOrderInfoList().get(0); HotelOrderInfoEntity hotelOrderInfoEntity = response.getItineraryList().get(0).getHotelOrderInfoList().get(0);
List<RefundInfo> refundInfo = flightOrderInfoEntity.getRefundInfo(); List<RefundInfo> refundInfo = hotelOrderInfoEntity.getRefundInfo();
if (refundInfo != null && !refundInfo.isEmpty()) { if (refundInfo != null && !refundInfo.isEmpty()) {
for (RefundInfo flightRefundInfo : refundInfo) { for (RefundInfo flightRefundInfo : refundInfo) {
if (flightOrderInfoEntity.getOrderDetailStatus().equals("Cancelled")) { Command.of(RefundOrderGenerateCommand.class)
Command.of(RefundOrderGenerateCommand.class).Info(String.valueOf(flightRefundInfo.getRefundInfoID()), .Info(String.valueOf(flightRefundInfo.getRefundInfoID()),
flightOrderInfoEntity.getOrderID(), hotelOrderInfoEntity.getOrderID(),
"-" + flightRefundInfo.getRefundCustomerAmount(), "-" + flightRefundInfo.getRefundCustomerAmount(),
"4", "4",
flightOrderInfoEntity.getCancelTime()).sendToQueue(); DateTimeUtil.timeToStrCommon(LocalDateTime.now())).sendToQueue();
}
} }
} }
} }
@ -425,7 +425,7 @@ public class OrderDomainService {
} }
public RouteOrder checkRouteOrderStatus(RouteOrder routeOrder) { public RouteOrder checkRouteOrderStatus(RouteOrder routeOrder) {
if(routeOrder.getOrderStatus() == null ) { if (routeOrder.getOrderStatus() == null) {
routeOrder.reloadStatus(); routeOrder.reloadStatus();
routeRepository.save(routeOrder); routeRepository.save(routeOrder);
} }

View File

@ -8,6 +8,9 @@ import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.List;
@Repository @Repository
public class UserRepositoryImpl implements UserRepository { public class UserRepositoryImpl implements UserRepository {
@ -32,4 +35,28 @@ public class UserRepositoryImpl implements UserRepository {
public User save(User user) { public User save(User user) {
return jdbcUserRepository.save(user); return jdbcUserRepository.save(user);
} }
@Override
public void saveAll(List<User> userList) {
jdbcUserRepository.saveAll(userList);
}
@Override
public List<User> findAll() {
List<User> userList = new ArrayList<>();
jdbcUserRepository.findAll()
.forEach(userList::add);
return userList;
}
@Override
public List<User> findByStatus(Integer status) {
return jdbcUserRepository.findByStatus(status);
}
@Override
public List<User> findByStatusIsNull() {
return jdbcUserRepository.findByStatusIsNull();
}
} }

View File

@ -4,8 +4,13 @@ import com.chint.domain.aggregates.user.User;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
@Repository @Repository
public interface JdbcUserRepository extends CrudRepository<User, String> { public interface JdbcUserRepository extends CrudRepository<User, String> {
User findByEmployeeNo(String employeeNo); User findByEmployeeNo(String employeeNo);
List<User> findByStatus(Integer status);
List<User> findByStatusIsNull();
} }

View File

@ -1,5 +1,6 @@
package com.chint.interfaces.rest.amap; package com.chint.interfaces.rest.amap;
import com.chint.application.commands.UserDisabledCommand;
import com.chint.application.commands.UserLoginCommand; import com.chint.application.commands.UserLoginCommand;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.UserNameRepository; import com.chint.domain.repository.UserNameRepository;
@ -80,6 +81,17 @@ public class AmapUserRequest implements UserSync {
return user; return user;
} }
@ListenTo(command = "UserDisabledCommand",order = 0)
@Override
public Boolean disableUserToSupplier(UserDisabledCommand command) {
User user = command.getUser();
String updateUserUrl = BaseUrl + USER_UPDATE_PATH;
UserParam userParamByUser = createUserParamByUser(user);
userParamByUser.setStatus(0);
BaseResponse post = amapRequest.post(updateUserUrl, userParamByUser, BaseResponse.class);
return post.getCode().equals(1);
}
@Data @Data
public static class UserParam extends BaseRequestParam { public static class UserParam extends BaseRequestParam {
private String userId; // 用户Id private String userId; // 用户Id

View File

@ -1,5 +1,6 @@
package com.chint.interfaces.rest.ctrip; package com.chint.interfaces.rest.ctrip;
import com.chint.application.commands.UserDisabledCommand;
import com.chint.application.commands.UserLoginCommand; import com.chint.application.commands.UserLoginCommand;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.UserNameRepository; import com.chint.domain.repository.UserNameRepository;
@ -86,6 +87,11 @@ public class CTripUserSaveRequest implements UserSync {
} }
public void saveUserToCTrip(User user) { public void saveUserToCTrip(User user) {
AuthenticationListRequest authenticationListRequest = buildUserParam(user);
postRequest.post(userUrl, authenticationListRequest, AuthenticationResponseList.class);
}
private AuthenticationListRequest buildUserParam(User user) {
String ticket = ticketRequest.loadTicket(); String ticket = ticketRequest.loadTicket();
AuthenticationEntity authenticationEntity = buildAuthenticationEntityWithUser(user); AuthenticationEntity authenticationEntity = buildAuthenticationEntityWithUser(user);
AuthenticationListRequest authenticationListRequest = new AuthenticationListRequest(); AuthenticationListRequest authenticationListRequest = new AuthenticationListRequest();
@ -96,7 +102,7 @@ public class CTripUserSaveRequest implements UserSync {
authenticationInfo.setSequence("0"); authenticationInfo.setSequence("0");
authenticationInfo.setAuthentication(authenticationEntity); authenticationInfo.setAuthentication(authenticationEntity);
authenticationListRequest.setAuthenticationInfoList(List.of(authenticationInfo)); authenticationListRequest.setAuthenticationInfoList(List.of(authenticationInfo));
postRequest.post(userUrl, authenticationListRequest, AuthenticationResponseList.class); return authenticationListRequest;
} }
@ -105,12 +111,12 @@ public class CTripUserSaveRequest implements UserSync {
userNameRepository.findByEmployeeNo(user.getEmployeeNo()).ifPresentOrElse(it -> authenticationEntity.setName(it.getIdName()), userNameRepository.findByEmployeeNo(user.getEmployeeNo()).ifPresentOrElse(it -> authenticationEntity.setName(it.getIdName()),
() -> authenticationEntity.setName(user.getName())); () -> authenticationEntity.setName(user.getName()));
authenticationEntity.setEmployeeID(user.getEmployeeNo()); authenticationEntity.setEmployeeID(user.getEmployeeNo());
authenticationEntity.setValid(user.getWorkStatus().charAt(0)); authenticationEntity.setValid(user.getWorkStatus() == null ? 'A' : 'I');
authenticationEntity.setSubAccountName(subAccountName); authenticationEntity.setSubAccountName(subAccountName);
return authenticationEntity; return authenticationEntity;
} }
@ListenTo(command = "UserLoginCommand",order = 1) @ListenTo(command = "UserLoginCommand", order = 1)
@Override @Override
public User syncUserInfoToSupplier(UserLoginCommand command) { public User syncUserInfoToSupplier(UserLoginCommand command) {
User user = command.getUser(); User user = command.getUser();
@ -122,4 +128,18 @@ public class CTripUserSaveRequest implements UserSync {
} }
return user; return user;
} }
@ListenTo(command = "UserDisabledCommand", order = 1)
@Override
public Boolean disableUserToSupplier(UserDisabledCommand command) {
User user = command.getUser();
AuthenticationListRequest authenticationListRequest = buildUserParam(user);
List<AuthenticationInfo> authenticationInfoList = authenticationListRequest.getAuthenticationInfoList();
if (authenticationInfoList != null && !authenticationInfoList.isEmpty()) {
AuthenticationInfo authenticationInfo = authenticationInfoList.get(0);
authenticationInfo.getAuthentication().setValid('I');
}
AuthenticationResponseList response = postRequest.post(userUrl, authenticationListRequest, AuthenticationResponseList.class);
return response.getResult().equals("Success");
}
} }

View File

@ -1,5 +1,6 @@
package com.chint.interfaces.rest.ctrip.in; package com.chint.interfaces.rest.ctrip.in;
import cn.hutool.core.bean.BeanUtil;
import com.chint.application.commands.OrderStatusChangeCommand; import com.chint.application.commands.OrderStatusChangeCommand;
import com.chint.domain.aggregates.order.OrderDetail; import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.domain.repository.SupplierCallBackLogRepository; import com.chint.domain.repository.SupplierCallBackLogRepository;
@ -15,6 +16,7 @@ import com.chint.interfaces.rest.ctrip.dto.put.CTripStatusNotification;
import com.chint.interfaces.rest.ctrip.dto.search.ItineraryEntity; import com.chint.interfaces.rest.ctrip.dto.search.ItineraryEntity;
import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse; import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse;
import com.chint.interfaces.rest.ctrip.dto.search.hotel.HotelOrderInfoEntity; import com.chint.interfaces.rest.ctrip.dto.search.hotel.HotelOrderInfoEntity;
import com.chint.interfaces.rest.ctrip.dto.search.hotel.RefundInfo;
import com.chint.interfaces.rest.ctrip.tools.CTripUtils; import com.chint.interfaces.rest.ctrip.tools.CTripUtils;
import com.google.gson.Gson; import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -29,9 +31,11 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static com.chint.infrastructure.constant.LegConstant.*; import static com.chint.infrastructure.constant.LegConstant.*;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_REFUND;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_STATUS_REFUSE_MSG; import static com.chint.infrastructure.constant.OrderConstant.ORDER_STATUS_REFUSE_MSG;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP; import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
@ -159,7 +163,12 @@ public class CTripNoteController {
.extension(getETAReason(response, LEG_TYPE_AIRPLANE)); .extension(getETAReason(response, LEG_TYPE_AIRPLANE));
break; break;
case LEG_TYPE_HOTEL: case LEG_TYPE_HOTEL:
command.eventType(CTripUtils.mapHotelStatus(orderStatus)) Integer eventType = CTripUtils.mapHotelStatus(orderStatus);
if (!eventType.equals(ORDER_EVENT_REFUND)) {
//如果是酒店的话会存在部分退款的情况 需要额外发送一个部分退款状态
checkHotelIfRefund(response, command);
}
command.eventType(eventType)
.extension(getETAReason(response, LEG_TYPE_HOTEL)); .extension(getETAReason(response, LEG_TYPE_HOTEL));
break; break;
case LEG_TYPE_TRAIN: case LEG_TYPE_TRAIN:
@ -175,6 +184,21 @@ public class CTripNoteController {
return Result.Success("成功收到消息"); return Result.Success("成功收到消息");
} }
private void checkHotelIfRefund(SearchOrderResponse response, OrderStatusChangeCommand command) {
ItineraryEntity itineraryEntity = response.getItineraryList().get(0);
List<HotelOrderInfoEntity> hotelOrderInfoList = itineraryEntity.getHotelOrderInfoList();
if (hotelOrderInfoList != null && !hotelOrderInfoList.isEmpty()) {
HotelOrderInfoEntity hotelOrderInfoEntity = hotelOrderInfoList.get(0);
List<RefundInfo> refundInfo = hotelOrderInfoEntity.getRefundInfo();
if (refundInfo != null && !refundInfo.isEmpty()) {
OrderStatusChangeCommand orderStatusChangeCommand = BeanUtil
.copyProperties(command, OrderStatusChangeCommand.class);
orderStatusChangeCommand.outStatus("部分退款").eventType(ORDER_EVENT_REFUND).sendToQueue();
}
}
}
private String getETAReason(SearchOrderResponse response, Integer productType) { private String getETAReason(SearchOrderResponse response, Integer productType) {
ItineraryEntity itineraryEntity = response.getItineraryList().get(0); ItineraryEntity itineraryEntity = response.getItineraryList().get(0);
return switch (productType) { return switch (productType) {

View File

@ -1,5 +1,6 @@
package com.chint.interfaces.rest.ly; package com.chint.interfaces.rest.ly;
import com.chint.application.commands.UserDisabledCommand;
import com.chint.application.commands.UserLoginCommand; import com.chint.application.commands.UserLoginCommand;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.UserNameRepository; import com.chint.domain.repository.UserNameRepository;
@ -113,4 +114,16 @@ public class LYUserRequest implements UserSync {
} }
return user; return user;
} }
@ListenTo(command = "UserDisabledCommand",order = 3)
@Override
public Boolean disableUserToSupplier(UserDisabledCommand command) {
User user = command.getUser();
EmployeeEntity employeeEntity = user2LYEmployee(user);
employeeEntity.setWorkingState(0);
EmployeeRequest employeeData = new EmployeeRequest();
employeeData.setParam(employeeEntity);
UserResponse post = postRequest.post(userUrl, employeeData, UserResponse.class);
return post.isSuccess();
}
} }

View File

@ -1,5 +1,6 @@
package com.chint.interfaces.rest.user; package com.chint.interfaces.rest.user;
import com.chint.application.commands.UserDisabledCommand;
import com.chint.dc.api.DataCenterResult; import com.chint.dc.api.DataCenterResult;
import com.chint.dc.api.dto.DataCenterOption; import com.chint.dc.api.dto.DataCenterOption;
import com.chint.dc.api.service.DataCenterService; import com.chint.dc.api.service.DataCenterService;
@ -7,6 +8,7 @@ import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.StaffRankRepository; import com.chint.domain.repository.StaffRankRepository;
import com.chint.domain.repository.UserRepository; import com.chint.domain.repository.UserRepository;
import com.chint.domain.service.JTCompanyDomainService; import com.chint.domain.service.JTCompanyDomainService;
import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.interfaces.rest.ctrip.CTripUserSaveRequest; import com.chint.interfaces.rest.ctrip.CTripUserSaveRequest;
import com.chint.interfaces.rest.ly.LYUserRequest; import com.chint.interfaces.rest.ly.LYUserRequest;
import com.chint.interfaces.rest.user.dto.AccessKeyDTO; import com.chint.interfaces.rest.user.dto.AccessKeyDTO;
@ -35,7 +37,7 @@ import static com.chint.infrastructure.constant.SFConstant.*;
@Slf4j @Slf4j
@Component @Component
public class PushUser { public class BatchUserWorker {
@Value("${sf.systemId}") @Value("${sf.systemId}")
private String systemId; private String systemId;
@ -79,12 +81,38 @@ public class PushUser {
} }
} }
public void checkUserStatus() {
List<User> userList = userRepository.findByStatus(1);
List<User> byStatusIsNull = userRepository.findByStatusIsNull();
userList.addAll(byStatusIsNull);
List<User> userStatusChangeList = new ArrayList<>();
for (User user : userList) {
List<UserDataDTO> userSFDataFromOpenApi = userSFRequest.getUserSFDataFromOpenApi(user);
for (UserDataDTO userDataDTO : userSFDataFromOpenApi) {
user.addDeptInfo(userDataDTO);
}
List<UserDataDTO> userDataDTOList = userSFDataFromOpenApi
.stream()
.filter(it -> it.getStatus().equals("A"))
.toList();
if (userDataDTOList.isEmpty()) {
//如果这里不存在状态为A的SF数据说明他已经处于离职状态
user.setStatus(0);
user.loadInfoFromDept();
Command.of(UserDisabledCommand.class).user(user).sendToQueue();
userStatusChangeList.add(user);
}
}
if (!userStatusChangeList.isEmpty()) {
userRepository.saveAll(userStatusChangeList);
}
}
public List<User> getUserSFDataFromOpenApiBatch() { public List<User> getUserSFDataFromOpenApiBatch() {
int pageSize = 1000; int pageSize = 1000;
int page = 1; int page = 1;
List<User> list = new ArrayList<>(); List<User> list = new ArrayList<>();
boolean shouldContinue = true; boolean shouldContinue = true;
while (shouldContinue) { while (shouldContinue) {
int start = (page - 1) * pageSize; int start = (page - 1) * pageSize;
log.info("Pulling user data. Page={}", page); log.info("Pulling user data. Page={}", page);
@ -135,12 +163,12 @@ public class PushUser {
shouldContinue = false; shouldContinue = false;
} }
} }
return list.stream() return list.stream()
.filter(user -> user.getEmployeeNo() != null) .filter(user -> user.getEmployeeNo() != null)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
private List<UserDataDTO> parseUserData(DataCenterResult result) { private List<UserDataDTO> parseUserData(DataCenterResult result) {
Type type = new TypeToken<List<UserDataDTO>>() { Type type = new TypeToken<List<UserDataDTO>>() {
}.getType(); }.getType();
@ -175,7 +203,6 @@ public class PushUser {
Optional.ofNullable(userRepository.findByUserEmployeeNo(user.getEmployeeNo())) Optional.ofNullable(userRepository.findByUserEmployeeNo(user.getEmployeeNo()))
.ifPresentOrElse( .ifPresentOrElse(
it -> { it -> {
// user.setUserId(it.getUserId());
if (it.checkSyncTime()) { if (it.checkSyncTime()) {
it.setWorkStatus(user.getWorkStatus()); it.setWorkStatus(user.getWorkStatus());
asyncUser(it); asyncUser(it);

View File

@ -1,10 +1,11 @@
package com.chint.interfaces.rest.user; package com.chint.interfaces.rest.user;
import com.chint.application.commands.UserDisabledCommand;
import com.chint.application.commands.UserLoginCommand;
import com.chint.application.commands.UserSFCommand; import com.chint.application.commands.UserSFCommand;
import com.chint.domain.aggregates.standards.Ranks; import com.chint.domain.aggregates.standards.Ranks;
import com.chint.domain.aggregates.standards.StaffRank; import com.chint.domain.aggregates.standards.StaffRank;
import com.chint.domain.aggregates.system.JTCompany;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.domain.aggregates.user.UserDepartmentInfo; import com.chint.domain.aggregates.user.UserDepartmentInfo;
import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.exceptions.NotFoundException;
@ -15,6 +16,7 @@ import com.chint.domain.service.JTCompanyDomainService;
import com.chint.domain.service.RankDomainService; import com.chint.domain.service.RankDomainService;
import com.chint.infrastructure.constant.SFConstant; import com.chint.infrastructure.constant.SFConstant;
import com.chint.infrastructure.echo_framework.annotation.ListenTo; import com.chint.infrastructure.echo_framework.annotation.ListenTo;
import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.util.StringCheck; import com.chint.infrastructure.util.StringCheck;
import com.chint.interfaces.rest.base.PostRequest; import com.chint.interfaces.rest.base.PostRequest;
@ -120,6 +122,15 @@ public class UserHttpRequestImpl implements UserHttpRequest {
} }
@ListenTo(command = "UserLoginCommand", order = 0)
public void loadSfInfo(UserLoginCommand command) {
User user = command.getUser();
if (user.checkSyncTime()) {
loadSFInfo(Command.of(UserSFCommand.class).user(user));
}
}
@ListenTo(command = "UserSFCommand", order = 0) @ListenTo(command = "UserSFCommand", order = 0)
public User loadSFInfo(UserSFCommand command) { public User loadSFInfo(UserSFCommand command) {
User user = command.getUser(); User user = command.getUser();
@ -139,6 +150,14 @@ public class UserHttpRequestImpl implements UserHttpRequest {
for (UserDataDTO userDataDTO : fromJson) { for (UserDataDTO userDataDTO : fromJson) {
user.addDeptInfo(userDataDTO); user.addDeptInfo(userDataDTO);
} }
if(fromJson.isEmpty()){
user.setStatus(0);
user.loadInfoFromDept();
Command.of(UserDisabledCommand.class).user(user).sendToQueue();
} else {
user.setStatus(1);
}
return user; return user;
} }

View File

@ -1,10 +1,11 @@
package com.chint.interfaces.rest.user; package com.chint.interfaces.rest.user;
import com.chint.application.commands.UserDisabledCommand;
import com.chint.application.commands.UserLoginCommand; import com.chint.application.commands.UserLoginCommand;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import java.lang.reflect.Modifier;
public interface UserSync { public interface UserSync {
User syncUserInfoToSupplier(UserLoginCommand command); User syncUserInfoToSupplier(UserLoginCommand command);
Boolean disableUserToSupplier(UserDisabledCommand command);
} }

View File

@ -34,6 +34,9 @@ public class AmapTest {
@Autowired @Autowired
private AmapLocationRequest amapLocationRequest; private AmapLocationRequest amapLocationRequest;
@Autowired
private OrderDetailRequest orderDetailRequest;
private Gson gson = new Gson(); private Gson gson = new Gson();
private User user = new User(1L, "230615020", 1, "卢麟哲", "lulz1@chint.com", "15857193365", "A30000001"); private User user = new User(1L, "230615020", 1, "卢麟哲", "lulz1@chint.com", "15857193365", "A30000001");
@ -43,41 +46,48 @@ public class AmapTest {
@Autowired @Autowired
private SettleBillRequest settleBillRequest; private SettleBillRequest settleBillRequest;
@Test
public void search() {
Gson gson = new Gson();
OrderDetailResponse orderDetailResponse = orderDetailRequest.queryOrderDetail("40920084001340019626730137");
System.out.println(gson.toJson(orderDetailResponse));
}
/** /**
* 完单数据查询 * 完单数据查询
*/ */
@Test @Test
public void pageFinishedOrder() { public void pageFinishedOrder() {
List<FinishedOrderResponse> responses= settleBillRequest.pageFinishedOrder("20240401", "20240431"); List<FinishedOrderResponse> responses = settleBillRequest.pageFinishedOrder("20240401", "20240431");
System.out.println(responses); System.out.println(responses);
} }
@Test @Test
public void createUser() { public void createUser() {
BaseResponse baseResponse = amapUserRequest.createUser(user2); BaseResponse baseResponse = amapUserRequest.createUser(user2);
System.out.println(gson.toJson(baseResponse)); System.out.println(gson.toJson(baseResponse));
} }
@Test @Test
public void queryUser(){ public void queryUser() {
UserQueryResponse userQueryResponse = amapUserRequest.queryUser(user2); UserQueryResponse userQueryResponse = amapUserRequest.queryUser(user2);
System.out.println(gson.toJson(userQueryResponse)); System.out.println(gson.toJson(userQueryResponse));
} }
@Test @Test
public void updateUser(){ public void updateUser() {
BaseResponse baseResponse = amapUserRequest.updateUser(user); BaseResponse baseResponse = amapUserRequest.updateUser(user);
System.out.println(gson.toJson(baseResponse)); System.out.println(gson.toJson(baseResponse));
} }
@Test @Test
public void login(){ public void login() {
H5LoginResponse h5LoginResponse = amapLoginRequest.h5Login(user); H5LoginResponse h5LoginResponse = amapLoginRequest.h5Login(user);
System.out.println(gson.toJson(h5LoginResponse.getRedirectUrl())); System.out.println(gson.toJson(h5LoginResponse.getRedirectUrl()));
} }
@Test @Test
public void queryLocation(){ public void queryLocation() {
LocationResponse locationQuery = amapLocationRequest.locationQuery("北京"); LocationResponse locationQuery = amapLocationRequest.locationQuery("北京");
System.out.println(gson.toJson(locationQuery.getData())); System.out.println(gson.toJson(locationQuery.getData()));
} }
@ -85,10 +95,8 @@ public class AmapTest {
@Autowired @Autowired
private TokenRequest tokenRequest; private TokenRequest tokenRequest;
@Autowired
private OrderDetailRequest orderDetailRequest;
@Test @Test
public void gaoDe() { public void gaoDe() {
// TokenDto.UserInfo userInfo = new TokenDto.UserInfo(); // TokenDto.UserInfo userInfo = new TokenDto.UserInfo();
// userInfo.setUserId("230615020"); // userInfo.setUserId("230615020");
@ -114,7 +122,7 @@ public class AmapTest {
/** /**
* 取消订单 * 取消订单
*/ */
// @Test // @Test
public void cancelOrder() { public void cancelOrder() {
takeCarRequest.cancelOrder("20240301", "行程变更"); takeCarRequest.cancelOrder("20240301", "行程变更");
} }

View File

@ -10,7 +10,6 @@ import com.chint.domain.aggregates.location.basedata.CountryLevelInfoEntity;
import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEntity; import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEntity;
import com.chint.domain.aggregates.order.Leg; import com.chint.domain.aggregates.order.Leg;
import com.chint.domain.aggregates.order.Location; import com.chint.domain.aggregates.order.Location;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHotelRecord; import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHotelRecord;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.*; import com.chint.domain.repository.*;
@ -38,7 +37,7 @@ import com.chint.interfaces.rest.ly.dto.hotelorderdatapushbach.OrderInfo;
import com.chint.interfaces.rest.ly.dto.search.response.hotel.HotelDetailResponse; import com.chint.interfaces.rest.ly.dto.search.response.hotel.HotelDetailResponse;
import com.chint.interfaces.rest.ly.dto.strokepush.StrokePushResult; import com.chint.interfaces.rest.ly.dto.strokepush.StrokePushResult;
import com.chint.interfaces.rest.ly.dto.strokepush.TrainChange.TrainChangeRequest; import com.chint.interfaces.rest.ly.dto.strokepush.TrainChange.TrainChangeRequest;
import com.chint.interfaces.rest.user.PushUser; import com.chint.interfaces.rest.user.BatchUserWorker;
import com.chint.interfaces.rest.user.UserHttpRequest; import com.chint.interfaces.rest.user.UserHttpRequest;
import com.chint.interfaces.rest.user.UserHttpRequestImpl; import com.chint.interfaces.rest.user.UserHttpRequestImpl;
import com.chint.interfaces.rest.user.UserSFRequest; import com.chint.interfaces.rest.user.UserSFRequest;
@ -49,17 +48,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import java.time.Instant;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.chint.infrastructure.constant.LocationConstant.*; import static com.chint.infrastructure.constant.LocationConstant.*;
import static com.chint.infrastructure.constant.RankConstant.DEFAULT_RANK_NAME; import static com.chint.infrastructure.constant.RankConstant.DEFAULT_RANK_NAME;
import static com.chint.infrastructure.util.DateTimeUtil.formatter;
import static com.chint.infrastructure.util.DateTimeUtil.lastMonthStr; import static com.chint.infrastructure.util.DateTimeUtil.lastMonthStr;
@Slf4j @Slf4j
@ -134,7 +130,7 @@ class RouteApplicationTests {
private UserSFRequest userSFRequest; private UserSFRequest userSFRequest;
@Autowired @Autowired
private PushUser pushUser; private BatchUserWorker pushUser;
@Autowired @Autowired