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 }
......
...@@ -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
......
...@@ -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
......