zhuyifan

fix

...@@ -15,4 +15,5 @@ public class BusinessConfig { ...@@ -15,4 +15,5 @@ public class BusinessConfig {
15 private String hisCustomerQueryUrl; 15 private String hisCustomerQueryUrl;
16 private String clientCustomerQueryUrl; 16 private String clientCustomerQueryUrl;
17 private String payUrl; 17 private String payUrl;
18 + private String payClientId;
18 } 19 }
......
...@@ -56,4 +56,6 @@ public interface CommonConstants { ...@@ -56,4 +56,6 @@ public interface CommonConstants {
56 56
57 String LOGIN_SOURCE = "loginSource"; 57 String LOGIN_SOURCE = "loginSource";
58 58
59 + String OPEN_ID = "openId";
60 +
59 } 61 }
......
...@@ -37,6 +37,10 @@ public class LoginContextHolder { ...@@ -37,6 +37,10 @@ public class LoginContextHolder {
37 return CONTEXT_HOLDER.get().getEnterpriseId(); 37 return CONTEXT_HOLDER.get().getEnterpriseId();
38 } 38 }
39 39
40 + public static String getOpenId() {
41 + return CONTEXT_HOLDER.get().getOpenId();
42 + }
43 +
40 public static void clear() { 44 public static void clear() {
41 CONTEXT_HOLDER.remove(); 45 CONTEXT_HOLDER.remove();
42 } 46 }
...@@ -54,7 +58,8 @@ public class LoginContextHolder { ...@@ -54,7 +58,8 @@ public class LoginContextHolder {
54 58
55 private String name; 59 private String name;
56 60
57 - private String openid; 61 + @Builder.Default
62 + private String openId = "";
58 63
59 } 64 }
60 65
......
...@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.ResponseStatus; ...@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
18 import org.springframework.web.bind.annotation.RestController; 18 import org.springframework.web.bind.annotation.RestController;
19 19
20 import javax.validation.Valid; 20 import javax.validation.Valid;
21 +import java.security.NoSuchAlgorithmException;
21 22
22 @Api(tags = "登陆") 23 @Api(tags = "登陆")
23 @ApiSupport(order = -1) 24 @ApiSupport(order = -1)
...@@ -32,7 +33,7 @@ public class LoginController { ...@@ -32,7 +33,7 @@ public class LoginController {
32 @ApiOperation(value = "登陆") 33 @ApiOperation(value = "登陆")
33 @PostMapping("/login") 34 @PostMapping("/login")
34 @ResponseStatus(HttpStatus.OK) 35 @ResponseStatus(HttpStatus.OK)
35 - public SaTokenInfo login(@Valid @RequestBody PermissionDTO.LoginDto loginDto) { 36 + public SaTokenInfo login(@Valid @RequestBody PermissionDTO.LoginDto loginDto) throws NoSuchAlgorithmException {
36 return loginService.login(loginDto); 37 return loginService.login(loginDto);
37 } 38 }
38 } 39 }
......
...@@ -65,7 +65,7 @@ public class OrderController { ...@@ -65,7 +65,7 @@ public class OrderController {
65 return orderService.getOrderDetailsByOrderId(orderId); 65 return orderService.getOrderDetailsByOrderId(orderId);
66 } 66 }
67 67
68 - @ApiOperation(value = "创建订单") 68 + @ApiOperation(value = "小程序创建订单")
69 @PostMapping("/orders") 69 @PostMapping("/orders")
70 @ResponseStatus(HttpStatus.OK) 70 @ResponseStatus(HttpStatus.OK)
71 @RepeatSubmit(prefix = "createOrder", isLockByLoginUser = false) 71 @RepeatSubmit(prefix = "createOrder", isLockByLoginUser = false)
......
1 package com.infoloop.tianting.enums; 1 package com.infoloop.tianting.enums;
2 2
3 -import com.infoloop.tianting.exception.BaseEnum;
4 import lombok.AllArgsConstructor; 3 import lombok.AllArgsConstructor;
5 import lombok.Getter; 4 import lombok.Getter;
6 5
7 @Getter 6 @Getter
8 @AllArgsConstructor 7 @AllArgsConstructor
9 public enum LoginSourceEnum{ 8 public enum LoginSourceEnum{
10 - CUSTOMER(1, "小程序住院客户"), 9 + CUSTOMER(1, "住院客户"),
11 - MINI_PROGRAM(2, "小程序非住院客户"), 10 + MINI_PROGRAM(2, "阳光厅客户"),
12 OPERATOR(3, "院区端"), 11 OPERATOR(3, "院区端"),
13 KDS(4, "KDS"), 12 KDS(4, "KDS"),
14 ; 13 ;
......
...@@ -12,15 +12,12 @@ import com.infoloop.tianting.enums.LoginSourceEnum; ...@@ -12,15 +12,12 @@ import com.infoloop.tianting.enums.LoginSourceEnum;
12 import com.infoloop.tianting.exception.ClientEndExceptions; 12 import com.infoloop.tianting.exception.ClientEndExceptions;
13 import com.infoloop.tianting.exception.ErrorCodeEnum; 13 import com.infoloop.tianting.exception.ErrorCodeEnum;
14 import com.infoloop.tianting.model.common.ResponseResult; 14 import com.infoloop.tianting.model.common.ResponseResult;
15 -import com.infoloop.tianting.service.ClientCustomerService;
16 import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; 15 import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient;
17 import com.infoloop.tianting.service.client.OperatorServiceRpcClient; 16 import com.infoloop.tianting.service.client.OperatorServiceRpcClient;
18 import com.infoloop.tianting.service.client.WOperatorServiceRpcClient; 17 import com.infoloop.tianting.service.client.WOperatorServiceRpcClient;
19 import com.infoloop.tianting.utils.ResponseUtil; 18 import com.infoloop.tianting.utils.ResponseUtil;
20 import lombok.RequiredArgsConstructor; 19 import lombok.RequiredArgsConstructor;
21 import lombok.extern.slf4j.Slf4j; 20 import lombok.extern.slf4j.Slf4j;
22 -import org.apache.tomcat.jni.Error;
23 -import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.http.HttpStatus; 21 import org.springframework.http.HttpStatus;
25 import org.springframework.stereotype.Component; 22 import org.springframework.stereotype.Component;
26 import org.springframework.web.method.HandlerMethod; 23 import org.springframework.web.method.HandlerMethod;
...@@ -71,6 +68,7 @@ public class LoginInterceptor extends HandlerInterceptorAdapter { ...@@ -71,6 +68,7 @@ public class LoginInterceptor extends HandlerInterceptorAdapter {
71 final var enterpriseId = Convert.toInt(StpUtil.getExtra(CommonConstants.ENTERPRISE_ID)); 68 final var enterpriseId = Convert.toInt(StpUtil.getExtra(CommonConstants.ENTERPRISE_ID));
72 final var loginSource = Convert.toInt(StpUtil.getExtra(CommonConstants.LOGIN_SOURCE)); 69 final var loginSource = Convert.toInt(StpUtil.getExtra(CommonConstants.LOGIN_SOURCE));
73 if (loginSource.equals(LoginSourceEnum.CUSTOMER.getValue())) { 70 if (loginSource.equals(LoginSourceEnum.CUSTOMER.getValue())) {
71 + final var openId = Convert.toStr(StpUtil.getExtra(CommonConstants.OPEN_ID));
74 final var loginId = StpUtil.getLoginIdAsInt(); 72 final var loginId = StpUtil.getLoginIdAsInt();
75 final var customer = clientCustomerServiceRpcClient.getClientCustomerById(enterpriseId, loginId); 73 final var customer = clientCustomerServiceRpcClient.getClientCustomerById(enterpriseId, loginId);
76 if (customer == null) { 74 if (customer == null) {
...@@ -78,7 +76,7 @@ public class LoginInterceptor extends HandlerInterceptorAdapter { ...@@ -78,7 +76,7 @@ public class LoginInterceptor extends HandlerInterceptorAdapter {
78 ResponseUtil.write(response, ResponseResult.failed(ErrorCodeEnum.VALIDATE_FAILED)); 76 ResponseUtil.write(response, ResponseResult.failed(ErrorCodeEnum.VALIDATE_FAILED));
79 return false; 77 return false;
80 } 78 }
81 - builder.id(loginId).enterpriseId(enterpriseId).name(customer.getResponse().getName()); 79 + builder.id(loginId).enterpriseId(enterpriseId).name(customer.getResponse().getName()).openId(openId);
82 return true; 80 return true;
83 } else if (loginSource.equals(LoginSourceEnum.OPERATOR.getValue())){ 81 } else if (loginSource.equals(LoginSourceEnum.OPERATOR.getValue())){
84 final var loginId = StpUtil.getLoginIdAsInt(); 82 final var loginId = StpUtil.getLoginIdAsInt();
...@@ -101,7 +99,7 @@ public class LoginInterceptor extends HandlerInterceptorAdapter { ...@@ -101,7 +99,7 @@ public class LoginInterceptor extends HandlerInterceptorAdapter {
101 return true; 99 return true;
102 } else { 100 } else {
103 final var loginId = StpUtil.getLoginIdAsString(); 101 final var loginId = StpUtil.getLoginIdAsString();
104 - builder.openid(loginId).enterpriseId(enterpriseId); 102 + builder.openId(loginId).enterpriseId(enterpriseId);
105 return true; 103 return true;
106 } 104 }
107 } 105 }
......
...@@ -3,6 +3,8 @@ package com.infoloop.tianting.service; ...@@ -3,6 +3,8 @@ package com.infoloop.tianting.service;
3 import cn.dev33.satoken.stp.SaTokenInfo; 3 import cn.dev33.satoken.stp.SaTokenInfo;
4 import com.infoloop.tianting.model.dto.PermissionDTO.LoginDto; 4 import com.infoloop.tianting.model.dto.PermissionDTO.LoginDto;
5 5
6 +import java.security.NoSuchAlgorithmException;
7 +
6 public interface LoginService { 8 public interface LoginService {
7 - SaTokenInfo login(LoginDto loginDto); 9 + SaTokenInfo login(LoginDto loginDto) throws NoSuchAlgorithmException;
8 } 10 }
......
...@@ -545,6 +545,7 @@ public class OrderServiceRpcClient { ...@@ -545,6 +545,7 @@ public class OrderServiceRpcClient {
545 .setRoomNo(createOrderDto.getRoomNo()) 545 .setRoomNo(createOrderDto.getRoomNo())
546 .setShouldCreateTableCode(createOrderDto.getOrderType().equals(OrderTypeEnum.DINE_IN.getValue()) || !createOrderDto.getTableCode().isEmpty()) 546 .setShouldCreateTableCode(createOrderDto.getOrderType().equals(OrderTypeEnum.DINE_IN.getValue()) || !createOrderDto.getTableCode().isEmpty())
547 .setTableCode(createOrderDto.getTableCode()) 547 .setTableCode(createOrderDto.getTableCode())
548 + .setShouldCreateOnlinePay(true)
548 .setOnlinePay(createOrderDto.getOnlinePay()) 549 .setOnlinePay(createOrderDto.getOnlinePay())
549 .setShouldCreatePayStatus(createOrderDto.getOnlinePay()) 550 .setShouldCreatePayStatus(createOrderDto.getOnlinePay())
550 .setPayStatus(PayStatusEnum.TO_PAY) 551 .setPayStatus(PayStatusEnum.TO_PAY)
...@@ -581,7 +582,6 @@ public class OrderServiceRpcClient { ...@@ -581,7 +582,6 @@ public class OrderServiceRpcClient {
581 if ((skuSellQuantityRpcResponse.getTodaySellQuantity() + orderDetail.getCount()) > skuSellQuantityRpcResponse.getMaxSellQuantity()) { 582 if ((skuSellQuantityRpcResponse.getTodaySellQuantity() + orderDetail.getCount()) > skuSellQuantityRpcResponse.getMaxSellQuantity()) {
582 log.error("skuSellQuantityRpcResponse stock no enough; stallId:{}, skuId:{}, count:{}", createOrderDto.getStallId(), orderDetail.getSkuId(), orderDetail.getCount()); 583 log.error("skuSellQuantityRpcResponse stock no enough; stallId:{}, skuId:{}, count:{}", createOrderDto.getStallId(), orderDetail.getSkuId(), orderDetail.getCount());
583 skuStockMap.put(skuMap.get(orderDetail.getSkuId()).getName(), skuSellQuantityRpcResponse.getMaxSellQuantity() - skuSellQuantityRpcResponse.getTodaySellQuantity()); 584 skuStockMap.put(skuMap.get(orderDetail.getSkuId()).getName(), skuSellQuantityRpcResponse.getMaxSellQuantity() - skuSellQuantityRpcResponse.getTodaySellQuantity());
584 - continue;
585 } 585 }
586 } 586 }
587 if (!soldOutSkus.isEmpty()) { 587 if (!soldOutSkus.isEmpty()) {
......
...@@ -23,7 +23,6 @@ import com.infoloop.tianting.utils.EncryptionUtil; ...@@ -23,7 +23,6 @@ import com.infoloop.tianting.utils.EncryptionUtil;
23 import lombok.RequiredArgsConstructor; 23 import lombok.RequiredArgsConstructor;
24 import lombok.extern.slf4j.Slf4j; 24 import lombok.extern.slf4j.Slf4j;
25 import org.springframework.beans.factory.annotation.Autowired; 25 import org.springframework.beans.factory.annotation.Autowired;
26 -import org.springframework.beans.factory.annotation.Value;
27 import org.springframework.http.HttpEntity; 26 import org.springframework.http.HttpEntity;
28 import org.springframework.http.HttpHeaders; 27 import org.springframework.http.HttpHeaders;
29 import org.springframework.http.HttpMethod; 28 import org.springframework.http.HttpMethod;
...@@ -33,6 +32,7 @@ import org.springframework.stereotype.Service; ...@@ -33,6 +32,7 @@ import org.springframework.stereotype.Service;
33 import org.springframework.web.client.RestTemplate; 32 import org.springframework.web.client.RestTemplate;
34 33
35 import java.math.BigDecimal; 34 import java.math.BigDecimal;
35 +import java.text.MessageFormat;
36 import java.text.ParseException; 36 import java.text.ParseException;
37 import java.time.LocalDateTime; 37 import java.time.LocalDateTime;
38 38
...@@ -47,9 +47,8 @@ public class PayServiceClient { ...@@ -47,9 +47,8 @@ public class PayServiceClient {
47 private final BusinessConfig businessConfig; 47 private final BusinessConfig businessConfig;
48 48
49 private final OrderServiceRpcClient orderServiceRpcClient; 49 private final OrderServiceRpcClient orderServiceRpcClient;
50 +
50 private final XmlMapper xmlMapper = new XmlMapper(); 51 private final XmlMapper xmlMapper = new XmlMapper();
51 - @Value("${payment.client-id:Order0001}")
52 - private String clientId;
53 52
54 public PayResponseDto payInform(PayInformRequestDto payRequestDto) { 53 public PayResponseDto payInform(PayInformRequestDto payRequestDto) {
55 final var orderById = orderServiceRpcClient.getOrderById(Integer.valueOf(payRequestDto.getOrderId())); 54 final var orderById = orderServiceRpcClient.getOrderById(Integer.valueOf(payRequestDto.getOrderId()));
...@@ -57,7 +56,7 @@ public class PayServiceClient { ...@@ -57,7 +56,7 @@ public class PayServiceClient {
57 log.info("Order {} not found or canceled, skipping.", payRequestDto.getOrderId()); 56 log.info("Order {} not found or canceled, skipping.", payRequestDto.getOrderId());
58 throw ClientEndExceptions.BusinessException.build(ErrorCodeEnum.ORDER_CANCEL); 57 throw ClientEndExceptions.BusinessException.build(ErrorCodeEnum.ORDER_CANCEL);
59 } 58 }
60 - String url = businessConfig.getPayUrl(); 59 + String url = MessageFormat.format(businessConfig.getPayUrl(), businessConfig.getPayClientId());
61 String requestDate = DateUtil.formatDate(LocalDateTime.now(), DateUtil.YMDHMS); 60 String requestDate = DateUtil.formatDate(LocalDateTime.now(), DateUtil.YMDHMS);
62 ThirdPartyPayInformRequestDto jsonData = buildRequestData(payRequestDto, requestDate); 61 ThirdPartyPayInformRequestDto jsonData = buildRequestData(payRequestDto, requestDate);
63 String jsonDataString; 62 String jsonDataString;
...@@ -79,7 +78,7 @@ public class PayServiceClient { ...@@ -79,7 +78,7 @@ public class PayServiceClient {
79 78
80 private ThirdPartyPayInformRequestDto buildRequestData(PayInformRequestDto payRequestDto, String requestDate) { 79 private ThirdPartyPayInformRequestDto buildRequestData(PayInformRequestDto payRequestDto, String requestDate) {
81 ThirdPartyPayInformRequestDto jsonData = new ThirdPartyPayInformRequestDto(); 80 ThirdPartyPayInformRequestDto jsonData = new ThirdPartyPayInformRequestDto();
82 - jsonData.setClientId(clientId); 81 + jsonData.setClientId(businessConfig.getPayClientId());
83 jsonData.setTradeId(payRequestDto.getOrderId()); 82 jsonData.setTradeId(payRequestDto.getOrderId());
84 jsonData.setRequestDate(requestDate); 83 jsonData.setRequestDate(requestDate);
85 jsonData.setRequestSource("OFWXApplet"); 84 jsonData.setRequestSource("OFWXApplet");
...@@ -89,7 +88,7 @@ public class PayServiceClient { ...@@ -89,7 +88,7 @@ public class PayServiceClient {
89 jsonData.setRemark(""); 88 jsonData.setRemark("");
90 jsonData.setTransAmount(payRequestDto.getPrice()); 89 jsonData.setTransAmount(payRequestDto.getPrice());
91 jsonData.setTradeDesc(""); 90 jsonData.setTradeDesc("");
92 - jsonData.setSign(EncryptionUtil.sha1Encryption(clientId + payRequestDto.getOrderId() + requestDate + clientId)); 91 + jsonData.setSign(EncryptionUtil.sha1Encryption(businessConfig.getPayClientId() + payRequestDto.getOrderId() + requestDate + businessConfig.getPayClientId()));
93 return jsonData; 92 return jsonData;
94 } 93 }
95 94
......
...@@ -18,6 +18,9 @@ import lombok.extern.slf4j.Slf4j; ...@@ -18,6 +18,9 @@ import lombok.extern.slf4j.Slf4j;
18 import org.springframework.beans.factory.annotation.Autowired; 18 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.stereotype.Service; 19 import org.springframework.stereotype.Service;
20 20
21 +import java.security.MessageDigest;
22 +import java.security.NoSuchAlgorithmException;
23 +
21 @Slf4j 24 @Slf4j
22 @Service 25 @Service
23 @RequiredArgsConstructor(onConstructor = @__(@Autowired)) 26 @RequiredArgsConstructor(onConstructor = @__(@Autowired))
...@@ -29,78 +32,82 @@ public class LoginServiceImpl implements LoginService { ...@@ -29,78 +32,82 @@ public class LoginServiceImpl implements LoginService {
29 private final WOperatorServiceRpcClient wOperatorServiceRpcClient; 32 private final WOperatorServiceRpcClient wOperatorServiceRpcClient;
30 33
31 @Override 34 @Override
32 - public SaTokenInfo login(LoginDto loginDto) { 35 + public SaTokenInfo login(LoginDto loginDto) throws NoSuchAlgorithmException {
33 if (loginDto.isShouldLoginWithOpenCode()) { 36 if (loginDto.isShouldLoginWithOpenCode()) {
34 final var wxUserOpenIdDto = wxMiniProgramHttpClient.getUserOpenIdByCode(loginDto.getOpenCode()); 37 final var wxUserOpenIdDto = wxMiniProgramHttpClient.getUserOpenIdByCode(loginDto.getOpenCode());
35 - StpUtil.login( 38 + StpUtil.login(wxUserOpenIdDto.getOpenid(), SaLoginModel.create()
36 - wxUserOpenIdDto.getOpenid(),
37 - SaLoginModel.create()
38 .setExtra(CommonConstants.ENTERPRISE_ID, loginDto.getEnterpriseId()) 39 .setExtra(CommonConstants.ENTERPRISE_ID, loginDto.getEnterpriseId())
39 .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) 40 .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue())
40 .build()); 41 .build());
41 return StpUtil.getTokenInfo(); 42 return StpUtil.getTokenInfo();
42 } else if (loginDto.isShouldLoginWithHisCustomerId()) { 43 } else if (loginDto.isShouldLoginWithHisCustomerId()) {
43 - var customer = 44 + var customer = clientCustomerServiceRpcClient.getClientCustomerByHISCustomerId(loginDto.getHisCustomerId()).getResponse();
44 - clientCustomerServiceRpcClient
45 - .getClientCustomerByHISCustomerId(loginDto.getHisCustomerId())
46 - .getResponse();
47 if (customer.getId() == 0) { 45 if (customer.getId() == 0) {
48 // 根据hisCustomerId拿不到用户的话再去根据合同号去his查一次,即认为是月子中心客户 46 // 根据hisCustomerId拿不到用户的话再去根据合同号去his查一次,即认为是月子中心客户
49 - customer = 47 + customer = clientCustomerServiceRpcClient.getClientCustomerByContactNo(loginDto.getHisCustomerId()).getResponse();
50 - clientCustomerServiceRpcClient
51 - .getClientCustomerByContactNo(loginDto.getHisCustomerId())
52 - .getResponse();
53 if (customer.getId() == 0) { 48 if (customer.getId() == 0) {
54 throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.VALIDATE_FAILED.name()); 49 throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.VALIDATE_FAILED.name());
55 } else { 50 } else {
56 - var record = 51 + var record = clientCustomerServiceRpcClient.getClientCustomerHospitalRecordsByCustomerId(customer.getEnterpriseId(), customer.getId());
57 - clientCustomerServiceRpcClient.getClientCustomerHospitalRecordsByCustomerId( 52 + if (!record.hasResponse() || record.getResponse().getHospitalStatus() != ClientCustomerHospitalRecordHospitalStatusEnum.CURRENT) {
58 - customer.getEnterpriseId(), customer.getId()); 53 + throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.VALIDATE_FAILED.name());
59 - if (!record.hasResponse()
60 - || record.getResponse().getHospitalStatus()
61 - != ClientCustomerHospitalRecordHospitalStatusEnum.CURRENT) {
62 - throw ClientEndExceptions.IncorrectRequestValue.build(
63 - ErrorCodeEnum.VALIDATE_FAILED.name());
64 } 54 }
65 } 55 }
56 + } else {
57 + var record = clientCustomerServiceRpcClient.getClientCustomerHospitalRecordsByCustomerId(customer.getEnterpriseId(), customer.getId());
58 + if (!record.hasResponse() || record.getResponse().getHospitalStatus() != ClientCustomerHospitalRecordHospitalStatusEnum.CURRENT) {
59 + throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.VALIDATE_FAILED.name());
66 } 60 }
67 - StpUtil.login( 61 + }
68 - customer.getId(), 62 + final var wxUserOpenIdDto = wxMiniProgramHttpClient.getUserOpenIdByCode(loginDto.getOpenCode());
69 - SaLoginModel.create() 63 + StpUtil.login(customer.getId(), SaLoginModel.create()
70 .setExtra(CommonConstants.ENTERPRISE_ID, customer.getEnterpriseId()) 64 .setExtra(CommonConstants.ENTERPRISE_ID, customer.getEnterpriseId())
71 .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) 65 .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue())
66 + .setExtra(CommonConstants.OPEN_ID, wxUserOpenIdDto.getOpenid())
72 .build()); 67 .build());
73 return StpUtil.getTokenInfo(); 68 return StpUtil.getTokenInfo();
74 } else if (loginDto.isShouldLoginWithOperatorPhone()) { 69 } else if (loginDto.isShouldLoginWithOperatorPhone()) {
75 - final var operator = 70 + final var operator = operatorServiceRpcClient.getCOperatorByMobileOrEmail(loginDto.getOperatorPhone());
76 - operatorServiceRpcClient.getCOperatorByMobileOrEmail(loginDto.getOperatorPhone());
77 if (operator.getId() == 0) { 71 if (operator.getId() == 0) {
78 throw ClientEndExceptions.AuthenticationFailure.build(ErrorCodeEnum.UNAUTHORIZED.name()); 72 throw ClientEndExceptions.AuthenticationFailure.build(ErrorCodeEnum.UNAUTHORIZED.name());
79 } 73 }
80 - StpUtil.login( 74 + if (!operator.getPassword().equals(sha1Hash(loginDto.getPassword()))) {
81 - operator.getId(), 75 + throw ClientEndExceptions.AuthenticationFailure.build(ErrorCodeEnum.VALIDATE_FAILED.name());
82 - SaLoginModel.create() 76 + }
77 + StpUtil.login(operator.getId(), SaLoginModel.create()
83 .setExtra(CommonConstants.ENTERPRISE_ID, operator.getEnterpriseId()) 78 .setExtra(CommonConstants.ENTERPRISE_ID, operator.getEnterpriseId())
84 .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) 79 .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue())
85 .build()); 80 .build());
86 return StpUtil.getTokenInfo(); 81 return StpUtil.getTokenInfo();
87 } else { 82 } else {
88 - final var operator = 83 + final var operator = wOperatorServiceRpcClient.getWOperatorByEmail(loginDto.getEmail()).getResponse();
89 - wOperatorServiceRpcClient.getWOperatorByEmail(loginDto.getEmail()).getResponse();
90 if (operator.getId() == 0) { 84 if (operator.getId() == 0) {
91 throw ClientEndExceptions.AuthenticationFailure.build(ErrorCodeEnum.UNAUTHORIZED.name()); 85 throw ClientEndExceptions.AuthenticationFailure.build(ErrorCodeEnum.UNAUTHORIZED.name());
92 } 86 }
93 -// if (!operator.getPassword().equals(loginDto.getPassword())) { 87 + if (!operator.getPassword().equals(sha1Hash(loginDto.getPassword()))) {
94 -// throw ClientEndExceptions.AuthenticationFailure.build(ErrorCodeEnum.VALIDATE_FAILED.name()); 88 + throw ClientEndExceptions.AuthenticationFailure.build(ErrorCodeEnum.VALIDATE_FAILED.name());
95 -// } 89 + }
96 - StpUtil.login( 90 + StpUtil.login(operator.getId(), SaLoginModel.create()
97 - operator.getId(),
98 - SaLoginModel.create()
99 .setExtra(CommonConstants.ENTERPRISE_ID, operator.getEnterpriseId()) 91 .setExtra(CommonConstants.ENTERPRISE_ID, operator.getEnterpriseId())
100 .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) 92 .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue())
101 .build()); 93 .build());
102 return StpUtil.getTokenInfo(); 94 return StpUtil.getTokenInfo();
103 } 95 }
104 } 96 }
97 +
98 + public static String sha1Hash(String input) throws NoSuchAlgorithmException {
99 + MessageDigest md = MessageDigest.getInstance("SHA-1");
100 + md.update(input.getBytes());
101 + byte[] digest = md.digest();
102 + return bytesToHex(digest);
103 + }
104 +
105 + private static String bytesToHex(byte[] bytes) {
106 + StringBuilder sb = new StringBuilder();
107 + for (byte b : bytes) {
108 + sb.append(String.format("%02x", b));
109 + }
110 + return sb.toString();
111 + }
105 } 112 }
106 113
......
...@@ -92,8 +92,8 @@ public class OrderServiceImpl implements OrderService { ...@@ -92,8 +92,8 @@ public class OrderServiceImpl implements OrderService {
92 final var record = clientCustomerServiceRpcClient.getClientCustomerHospitalRecordsByCustomerId(customer.getEnterpriseId(), customer.getId()).getResponse(); 92 final var record = clientCustomerServiceRpcClient.getClientCustomerHospitalRecordsByCustomerId(customer.getEnterpriseId(), customer.getId()).getResponse();
93 CreateOrderDto createOrderDto = new CreateOrderDto(); 93 CreateOrderDto createOrderDto = new CreateOrderDto();
94 createOrderDto.setShouldCreateCustomerId(true); 94 createOrderDto.setShouldCreateCustomerId(true);
95 - createOrderDto.setShouldCreateOpenId(false); 95 + createOrderDto.setShouldCreateOpenId(true);
96 - createOrderDto.setOpenId(""); 96 + createOrderDto.setOpenId(operatorLoginInfo.getOpenId());
97 createOrderDto.setTableCode(operatorCreateOrderDto.getTableCode()); 97 createOrderDto.setTableCode(operatorCreateOrderDto.getTableCode());
98 createOrderDto.setCustomerId(operatorCreateOrderDto.getCustomerId()); 98 createOrderDto.setCustomerId(operatorCreateOrderDto.getCustomerId());
99 createOrderDto.setStallId(operatorCreateOrderDto.getStallId()); 99 createOrderDto.setStallId(operatorCreateOrderDto.getStallId());
...@@ -156,13 +156,11 @@ public class OrderServiceImpl implements OrderService { ...@@ -156,13 +156,11 @@ public class OrderServiceImpl implements OrderService {
156 .doctors(Stream.of(doctors, dietDoctors).flatMap(List::stream).collect(Collectors.toList())) 156 .doctors(Stream.of(doctors, dietDoctors).flatMap(List::stream).collect(Collectors.toList()))
157 .build(); 157 .build();
158 createOrderDto.setCustomerNoticeJson(customerNotice); 158 createOrderDto.setCustomerNoticeJson(customerNotice);
159 -
160 createOrderDto.setUpdatedBy(operatorLoginInfo.getId()); 159 createOrderDto.setUpdatedBy(operatorLoginInfo.getId());
161 createOrderDto.setUpdateSource(OrderSourceEnum.STALL.getNumber()); 160 createOrderDto.setUpdateSource(OrderSourceEnum.STALL.getNumber());
162 List<CreateOrderDetailDto> orderDetailDtoList = new ArrayList<>(); 161 List<CreateOrderDetailDto> orderDetailDtoList = new ArrayList<>();
163 final var menuDetails = menuServiceRpcClient.queryMenuDetailsByMenuId(menu.getEnterpriseId(), operatorCreateOrderDto.getMenuId()).getResponsesList(); 162 final var menuDetails = menuServiceRpcClient.queryMenuDetailsByMenuId(menu.getEnterpriseId(), operatorCreateOrderDto.getMenuId()).getResponsesList();
164 - final var skuIds = 163 + final var skuIds = menuDetails.stream()
165 - menuDetails.stream()
166 .map(SingleMenuDetailRpcResponse::getSkuId) 164 .map(SingleMenuDetailRpcResponse::getSkuId)
167 .collect(Collectors.toList()); 165 .collect(Collectors.toList());
168 final var rpcSkus = skuServiceRpcClient.getDishSkusByIds(skuIds).getResponseList(); 166 final var rpcSkus = skuServiceRpcClient.getDishSkusByIds(skuIds).getResponseList();
......
...@@ -75,7 +75,8 @@ miniprogram.appSecret=5b309517bf918abf760b2195e91b99f3 ...@@ -75,7 +75,8 @@ miniprogram.appSecret=5b309517bf918abf760b2195e91b99f3
75 75
76 business-config.hisCustomerQueryUrl = https://nutri.amcare.com.cn/v3/hiscustomers/current/query 76 business-config.hisCustomerQueryUrl = https://nutri.amcare.com.cn/v3/hiscustomers/current/query
77 business-config.clientCustomerQueryUrl = https://nutri.amcare.com.cn/v3/clientcustomers/current/query 77 business-config.clientCustomerQueryUrl = https://nutri.amcare.com.cn/v3/clientcustomers/current/query
78 -business-config.payUrl = http://10.2.5.162:21051/API/Microapp/CreateOrder?appid=Order0001 78 +business-config.payUrl = http://10.2.5.162:21051/API/Microapp/CreateOrder?appid={0}
79 +business-config.payClientId = Order
79 80
80 ##Actuator\u914D\u7F6E 81 ##Actuator\u914D\u7F6E
81 management.server.port=8088 82 management.server.port=8088
......