zhuyifan

feat(customer): 添加通过 hisCustomerNo 查询客户信息接口

......@@ -37,6 +37,13 @@ public class ClientCustomerController {
return clientCustomerService.getClientCustomerByHISCustomerId(hisCustomerId);
}
@ApiOperation(value = "根据hisCustomerNo获取ClientCustomer")
@GetMapping("/his/customer/{hisCustomerNo}")
@ResponseStatus(HttpStatus.OK)
public ClientCustomerDto getClientCustomerByHISCustomerNo(@PathVariable String hisCustomerNo) {
return clientCustomerService.getClientCustomerByHISCustomerNo(hisCustomerNo);
}
@ApiOperation(value = "根据customerId获取ClientCustomer")
@GetMapping("/customers/{customerId}")
@ResponseStatus(HttpStatus.OK)
......
......@@ -3,7 +3,6 @@ package com.infoloop.tianting.model.dto;
import com.infoloop.tianting.enums.LoginSourceEnum;
import io.swagger.annotations.ApiModel;
import lombok.Builder;
import lombok.Builder.Default;
import lombok.Data;
@Data
......@@ -16,9 +15,9 @@ public class PermissionDTO {
public static class LoginDto {
private LoginSourceEnum loginSourceEnum;
@Builder.Default
private boolean shouldLoginWithHisCustomerId = false;
private boolean shouldLoginWithHisCustomerNo = false;
@Builder.Default
private String hisCustomerId = "";
private String hisCustomerNo = "";
@Builder.Default
private boolean shouldLoginWithOperatorPhone = false;
@Builder.Default
......
......@@ -8,6 +8,7 @@ import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchCreateCustomerLabelRe
import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRefRequestDto;
import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRefResponseDto;
import com.infoloop.tianting.model.dto.ClientLabelDTO.CustomerLabelRefDetailDto;
import java.util.List;
public interface ClientCustomerService {
......@@ -34,4 +35,5 @@ public interface ClientCustomerService {
TodayOrderDto getTodayOrderStatisticForHis(String token);
ClientCustomerDto getClientCustomerByHISCustomerNo(String hisCustomerNo);
}
......
......@@ -10,6 +10,8 @@ import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByContactNoR
import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByContactNoRpcResponse;
import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByHISCustomerIdRpcRequest;
import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByHISCustomerIdRpcResponse;
import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByHISCustomerNoRpcRequest;
import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByHISCustomerNoRpcResponse;
import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByIdRpcRequest;
import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByIdRpcResponse;
import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByMobileRpcRequest;
......@@ -47,6 +49,15 @@ public class ClientCustomerServiceRpcClient {
return clientCustomerServiceRpcBlockingStub.getClientCustomerByHISCustomerId(request);
}
public GetClientCustomerByHISCustomerNoRpcResponse getClientCustomerByHISCustomerNo(
String hisCustomerNo
) {
final var request = GetClientCustomerByHISCustomerNoRpcRequest.newBuilder()
.setHISCustomerNo(hisCustomerNo)
.build();
return clientCustomerServiceRpcBlockingStub.getClientCustomerByHISCustomerNo(request);
}
public GetClientCustomersByHISCustomerIdsRpcResponse getClientCustomersByHISCustomerIds(
List<String> hisCustomerIds
) {
......
......@@ -553,7 +553,7 @@ public class OrderServiceRpcClient {
.setMenuId(createOrderDto.getMenuId())
.setTotalNum(createOrderDto.getTotalNum())
.setPayPrice(createOrderDto.getPayPrice())
.setMealTime(LocalDate.now().atStartOfDay().toInstant(ZoneOffset.UTC).toEpochMilli())
.setMealTime(createOrderDto.getMealTime().toLocalDate().atStartOfDay().toInstant(ZoneOffset.UTC).toEpochMilli())
.setShouldCreateTableCode(createOrderDto.getCloseTimeType().equals(CloseTimeType.IMMEDIATELY))
.setShouldCreatePickupCode(createOrderDto.getCloseTimeType().equals(CloseTimeType.IMMEDIATELY))
.setPickupCode(generatePickupCode())
......
......@@ -547,4 +547,32 @@ public class ClientCustomerServiceImpl implements ClientCustomerService {
.build();
}
@Override
public ClientCustomerDto getClientCustomerByHISCustomerNo(String hisCustomerNo) {
var response = clientCustomerServiceRpcClient.getClientCustomerByHISCustomerNo(hisCustomerNo).getResponse();
return ClientCustomerDto.builder()
.id(response.getId())
.clientId(response.getClientId())
.enterpriseId(response.getEnterpriseId())
.age(response.getAge())
.height(response.getHeight())
.HISCustomerId(response.getHISCustomerId())
.identityCardNo(response.getIdentityCardNo())
.mobile(response.getMobile())
.name(response.getName())
.openId(response.getOpenId())
.sex(response.getSex())
.stallId(response.getStallId())
.weight(response.getWeight())
.isDeleted(response.getIsDeleted())
.birthday(DateUtil.formatDate(response.getBirthday()))
.createdAt(DateUtil.formatDate(response.getCreatedAt()))
.createdBy(response.getCreatedBy())
.creationSource(response.getCreationSource())
.updatedAt(DateUtil.formatDate(response.getUpdatedAt()))
.updateSource(response.getUpdateSource())
.updatedBy(response.getUpdatedBy())
.build();
}
}
......
......@@ -40,11 +40,11 @@ public class LoginServiceImpl implements LoginService {
.setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue())
.build());
return StpUtil.getTokenInfo();
} else if (loginDto.isShouldLoginWithHisCustomerId()) {
var customer = clientCustomerServiceRpcClient.getClientCustomerByHISCustomerId(loginDto.getHisCustomerId()).getResponse();
} else if (loginDto.isShouldLoginWithHisCustomerNo()) {
var customer = clientCustomerServiceRpcClient.getClientCustomerByHISCustomerNo(loginDto.getHisCustomerNo()).getResponse();
if (customer.getId() == 0) {
// 根据hisCustomerId拿不到用户的话再去根据合同号去his查一次,即认为是月子中心客户
customer = clientCustomerServiceRpcClient.getClientCustomerByContactNo(loginDto.getHisCustomerId()).getResponse();
// 根据hisCustomerNo拿不到用户的话再去根据合同号去his查一次,即认为是月子中心客户
customer = clientCustomerServiceRpcClient.getClientCustomerByContactNo(loginDto.getHisCustomerNo()).getResponse();
if (customer.getId() == 0) {
throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.VALIDATE_FAILED.name());
} else {
......
......@@ -13,6 +13,8 @@ service ClientCustomerServiceRpc {
rpc GetClientCustomerById (GetClientCustomerByIdRpcRequest) returns (GetClientCustomerByIdRpcResponse) {}
//HIS客户
rpc GetClientCustomerByHISCustomerId (GetClientCustomerByHISCustomerIdRpcRequest) returns (GetClientCustomerByHISCustomerIdRpcResponse) {}
//腕带号获取客户
rpc GetClientCustomerByHISCustomerNo (GetClientCustomerByHISCustomerNoRpcRequest) returns (GetClientCustomerByHISCustomerNoRpcResponse) {}
//HIS客户
rpc GetClientCustomersByHISCustomerIds (GetClientCustomersByHISCustomerIdsRpcRequest) returns (GetClientCustomersByHISCustomerIdsRpcResponse) {}
//月子中心客户
......@@ -52,6 +54,11 @@ service ClientCustomerServiceRpc {
rpc BatchCreateClientCustomerLabelRefs (BatchCreateClientCustomerLabelRefsRpcRequest) returns (BatchCreateClientCustomerLabelRefsRpcResponse) {}
rpc DeleteClientCustomerLabelRefsByIds (DeleteClientCustomerLabelRefsByIdsRpcRequest) returns (DeleteClientCustomerLabelRefsRpcResponse) {}
rpc DeleteClientCustomerLabelRefsByLabelIds (DeleteClientCustomerLabelRefsByLabelIdsRpcRequest) returns (DeleteClientCustomerLabelRefsByLabelIdsRpcResponse) {}
//客户操作记录
rpc QueryClientCustomerOperationRecordsByCondition (QueryClientCustomerOperationRecordsByConditionRpcRequest) returns (QueryClientCustomerOperationRecordsByConditionRpcResponse) {}
rpc CreateClientCustomerOperationRecord (CreateClientCustomerOperationRecordRpcRequest) returns (CreateClientCustomerOperationRecordRpcResponse) {}
rpc BatchCreateClientCustomerOperationRecords (BatchCreateClientCustomerOperationRecordsRpcRequest) returns (BatchCreateClientCustomerOperationRecordsRpcResponse) {}
}
enum ClientCustomerSexEnum {
......@@ -82,6 +89,7 @@ message SingleClientCustomerRpcResponse {
bool isDeleted = 19;
int32 stallId = 20;
string openId = 21;
string HISCustomerNo = 22;
}
message GetClientCustomerByIdRpcRequest {
......@@ -102,6 +110,14 @@ message GetClientCustomerByHISCustomerIdRpcResponse {
SingleClientCustomerRpcResponse response = 1;
}
message GetClientCustomerByHISCustomerNoRpcRequest {
string HISCustomerNo = 1;
}
message GetClientCustomerByHISCustomerNoRpcResponse {
SingleClientCustomerRpcResponse response = 1;
}
message GetClientCustomersByHISCustomerIdsRpcRequest {
repeated string HISCustomerIds = 1;
}
......@@ -200,6 +216,8 @@ message ClientCustomerCreation{
int32 stallId = 16;
bool shouldCreateOpenId = 17;
string openId = 18;
bool shouldCreateHISCustomerNo = 19;
string HISCustomerNo = 20;
}
message CreateClientCustomerRpcRequest {
......@@ -598,3 +616,70 @@ message DeleteClientCustomerLabelRefsByLabelIdsRpcRequest {
message DeleteClientCustomerLabelRefsByLabelIdsRpcResponse {
bool isDeleted = 1;
}
enum ClientCustomerOperationRecordTypeEnum {
CLIENT_CUSTOMER_OPERATION_RECORD_TYPE_UNKNOWN = 0;
CLIENT_CUSTOMER_OPERATION_RECORD_TYPE_CREATE = 1;
CLIENT_CUSTOMER_OPERATION_RECORD_TYPE_UPDATE = 2;
CLIENT_CUSTOMER_OPERATION_RECORD_TYPE_BIND_MENUS = 3;
CLIENT_CUSTOMER_OPERATION_RECORD_TYPE_LEAVE_HOSPITAL = 4;
}
message SingleClientCustomerOperationRecordRpcResponse {
int32 id = 1;
int32 enterpriseId = 2;
int32 clientCustomerId = 3;
ClientCustomerOperationRecordTypeEnum type = 4;
string originalJson = 5;
string adjustJson = 6;
string operator = 7;
int32 createdBy = 8;
int64 createdAt = 9;
int32 creationSource = 10;
}
message QueryClientCustomerOperationRecordsByConditionRpcRequest {
int32 enterpriseId = 1;
bool shouldFilterClientCustomerIds = 2;
repeated int32 clientCustomerIds = 3;
bool shouldFilterType = 4;
ClientCustomerOperationRecordTypeEnum type = 5;
}
message QueryClientCustomerOperationRecordsByConditionRpcResponse {
repeated SingleClientCustomerOperationRecordRpcResponse responses = 1;
}
message ClientCustomerOperationRecordCreation{
int32 clientCustomerId = 1;
ClientCustomerOperationRecordTypeEnum type = 2;
bool shouldCreateOriginalJson = 3;
string originalJson = 4;
bool shouldCreateAdjustJson = 5;
string adjustJson = 6;
string operator = 7;
}
message CreateClientCustomerOperationRecordRpcRequest {
ClientCustomerOperationRecordCreation creation = 1;
int32 enterpriseId = 2;
int32 createdBy = 3;
int32 creationSource = 4;
}
message CreateClientCustomerOperationRecordRpcResponse {
int32 id = 1;
bool isCreated = 2;
}
message BatchCreateClientCustomerOperationRecordsRpcRequest {
repeated ClientCustomerOperationRecordCreation creations = 1;
int32 enterpriseId = 2;
int32 createdBy = 3;
int32 creationSource = 4;
}
message BatchCreateClientCustomerOperationRecordsRpcResponse {
repeated int32 ids = 1;
bool isCreated = 2;
}
......