Showing
5 changed files
with
64 additions
and
3 deletions
| ... | @@ -42,6 +42,7 @@ dependencies { | ... | @@ -42,6 +42,7 @@ dependencies { |
| 42 | implementation "org.apache.poi:poi:4.1.2" //poi | 42 | implementation "org.apache.poi:poi:4.1.2" //poi |
| 43 | implementation "org.apache.poi:poi-ooxml:4.1.2" //poi | 43 | implementation "org.apache.poi:poi-ooxml:4.1.2" //poi |
| 44 | implementation 'cn.hutool:hutool-all:5.8.27' //huTool-util | 44 | implementation 'cn.hutool:hutool-all:5.8.27' //huTool-util |
| 45 | + implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.11.2' // Jackson XML 模块 | ||
| 45 | 46 | ||
| 46 | implementation 'com.aliyun:aliyun-java-sdk-core:4.6.4' //阿里云SDK核心库 | 47 | implementation 'com.aliyun:aliyun-java-sdk-core:4.6.4' //阿里云SDK核心库 |
| 47 | implementation 'com.aliyun:aliyun-java-sdk-dysmsapi:2.2.1'//阿里云短信服务SDK | 48 | implementation 'com.aliyun:aliyun-java-sdk-dysmsapi:2.2.1'//阿里云短信服务SDK | ... | ... |
| ... | @@ -2,6 +2,7 @@ package com.infoloop.tianting.config; | ... | @@ -2,6 +2,7 @@ package com.infoloop.tianting.config; |
| 2 | 2 | ||
| 3 | import com.aliyuncs.DefaultAcsClient; | 3 | import com.aliyuncs.DefaultAcsClient; |
| 4 | import com.aliyuncs.profile.DefaultProfile; | 4 | import com.aliyuncs.profile.DefaultProfile; |
| 5 | +import com.fasterxml.jackson.dataformat.xml.XmlMapper; | ||
| 5 | import com.infoloop.tianting.store.LoginCodeStore; | 6 | import com.infoloop.tianting.store.LoginCodeStore; |
| 6 | import com.infoloop.tianting.utils.SmsUtil; | 7 | import com.infoloop.tianting.utils.SmsUtil; |
| 7 | import io.lettuce.core.api.StatefulRedisConnection; | 8 | import io.lettuce.core.api.StatefulRedisConnection; |
| ... | @@ -10,6 +11,7 @@ import org.springframework.beans.factory.annotation.Qualifier; | ... | @@ -10,6 +11,7 @@ import org.springframework.beans.factory.annotation.Qualifier; |
| 10 | import org.springframework.context.annotation.Bean; | 11 | import org.springframework.context.annotation.Bean; |
| 11 | import org.springframework.context.annotation.Configuration; | 12 | import org.springframework.context.annotation.Configuration; |
| 12 | import org.springframework.context.annotation.Import; | 13 | import org.springframework.context.annotation.Import; |
| 14 | +import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter; | ||
| 13 | 15 | ||
| 14 | import static com.infoloop.tianting.constant.ConfigConstants.REDIS_CONNECTION; | 16 | import static com.infoloop.tianting.constant.ConfigConstants.REDIS_CONNECTION; |
| 15 | 17 | ||
| ... | @@ -32,4 +34,9 @@ public class AppConfig { | ... | @@ -32,4 +34,9 @@ public class AppConfig { |
| 32 | return new SmsUtil(smsConfig, new DefaultAcsClient(profile)); | 34 | return new SmsUtil(smsConfig, new DefaultAcsClient(profile)); |
| 33 | } | 35 | } |
| 34 | 36 | ||
| 37 | + @Bean | ||
| 38 | + public MappingJackson2XmlHttpMessageConverter mappingJackson2XmlHttpMessageConverter() { | ||
| 39 | + return new MappingJackson2XmlHttpMessageConverter(new XmlMapper()); | ||
| 40 | + } | ||
| 41 | + | ||
| 35 | } | 42 | } | ... | ... |
| ... | @@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaIgnore; | ... | @@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaIgnore; |
| 4 | import com.github.xiaoymin.knife4j.annotations.ApiSupport; | 4 | import com.github.xiaoymin.knife4j.annotations.ApiSupport; |
| 5 | import com.infoloop.tianting.model.dto.PayDTO; | 5 | import com.infoloop.tianting.model.dto.PayDTO; |
| 6 | import com.infoloop.tianting.model.dto.PayDTO.PayResponseDto; | 6 | import com.infoloop.tianting.model.dto.PayDTO.PayResponseDto; |
| 7 | +import com.infoloop.tianting.model.dto.PaymentCallbackDTO; | ||
| 7 | import com.infoloop.tianting.service.client.PayServiceClient; | 8 | import com.infoloop.tianting.service.client.PayServiceClient; |
| 8 | import io.swagger.annotations.Api; | 9 | import io.swagger.annotations.Api; |
| 9 | import io.swagger.annotations.ApiOperation; | 10 | import io.swagger.annotations.ApiOperation; |
| ... | @@ -11,6 +12,7 @@ import lombok.RequiredArgsConstructor; | ... | @@ -11,6 +12,7 @@ import lombok.RequiredArgsConstructor; |
| 11 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; |
| 12 | import org.springframework.beans.factory.annotation.Autowired; | 13 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | import org.springframework.http.HttpStatus; | 14 | import org.springframework.http.HttpStatus; |
| 15 | +import org.springframework.http.MediaType; | ||
| 14 | import org.springframework.validation.annotation.Validated; | 16 | import org.springframework.validation.annotation.Validated; |
| 15 | import org.springframework.web.bind.annotation.PostMapping; | 17 | import org.springframework.web.bind.annotation.PostMapping; |
| 16 | import org.springframework.web.bind.annotation.RequestBody; | 18 | import org.springframework.web.bind.annotation.RequestBody; |
| ... | @@ -39,9 +41,9 @@ public class PayController { | ... | @@ -39,9 +41,9 @@ public class PayController { |
| 39 | 41 | ||
| 40 | @SaIgnore | 42 | @SaIgnore |
| 41 | @ApiOperation(value = "支付通知") | 43 | @ApiOperation(value = "支付通知") |
| 42 | - @PostMapping("/pay/callback") | 44 | + @PostMapping(value = "/pay/callback", consumes = MediaType.APPLICATION_XML_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) |
| 43 | @ResponseStatus(HttpStatus.OK) | 45 | @ResponseStatus(HttpStatus.OK) |
| 44 | - public void callback(@Valid @RequestBody PayDTO.PayInformRequestDto payInformRequestDto) { | 46 | + public void callback(@RequestBody PaymentCallbackDTO payInformRequestDto) { |
| 45 | payServiceClient.callback(payInformRequestDto); | 47 | payServiceClient.callback(payInformRequestDto); |
| 46 | } | 48 | } |
| 47 | 49 | ... | ... |
| 1 | +package com.infoloop.tianting.model.dto; | ||
| 2 | + | ||
| 3 | +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +@Data | ||
| 7 | +public class PaymentCallbackDTO { | ||
| 8 | + | ||
| 9 | + @JacksonXmlProperty(localName = "TradeId") | ||
| 10 | + private String tradeId; | ||
| 11 | + | ||
| 12 | + @JacksonXmlProperty(localName = "TransSN") | ||
| 13 | + private String transSN; | ||
| 14 | + | ||
| 15 | + @JacksonXmlProperty(localName = "TransType") | ||
| 16 | + private String transType; | ||
| 17 | + | ||
| 18 | + @JacksonXmlProperty(localName = "TransAmount") | ||
| 19 | + private String transAmount; | ||
| 20 | + | ||
| 21 | + @JacksonXmlProperty(localName = "RealAmount") | ||
| 22 | + private String realAmount; | ||
| 23 | + | ||
| 24 | + @JacksonXmlProperty(localName = "PayMode") | ||
| 25 | + private String payMode; | ||
| 26 | + | ||
| 27 | + @JacksonXmlProperty(localName = "PayModeRemark") | ||
| 28 | + private String payModeRemark; | ||
| 29 | + | ||
| 30 | + @JacksonXmlProperty(localName = "TransDate") | ||
| 31 | + private String transDate; | ||
| 32 | + | ||
| 33 | + @JacksonXmlProperty(localName = "OrginalTransSN") | ||
| 34 | + private String orginalTransSN; | ||
| 35 | + | ||
| 36 | + @JacksonXmlProperty(localName = "Remark") | ||
| 37 | + private String remark; | ||
| 38 | + | ||
| 39 | + @JacksonXmlProperty(localName = "PayModeNote") | ||
| 40 | + private String payModeNote; | ||
| 41 | + | ||
| 42 | + @JacksonXmlProperty(localName = "PayIdentify") | ||
| 43 | + private String payIdentify; | ||
| 44 | + | ||
| 45 | + @JacksonXmlProperty(localName = "PayIdentifyNote") | ||
| 46 | + private String payIdentifyNote; | ||
| 47 | +} |
| ... | @@ -7,6 +7,7 @@ import com.infoloop.tianting.config.BusinessConfig; | ... | @@ -7,6 +7,7 @@ import com.infoloop.tianting.config.BusinessConfig; |
| 7 | import com.infoloop.tianting.model.dto.PayDTO.PayInformRequestDto; | 7 | import com.infoloop.tianting.model.dto.PayDTO.PayInformRequestDto; |
| 8 | import com.infoloop.tianting.model.dto.PayDTO.PayResponseDto; | 8 | import com.infoloop.tianting.model.dto.PayDTO.PayResponseDto; |
| 9 | import com.infoloop.tianting.model.dto.PayDTO.ThirdPartyPayInformRequestDto; | 9 | import com.infoloop.tianting.model.dto.PayDTO.ThirdPartyPayInformRequestDto; |
| 10 | +import com.infoloop.tianting.model.dto.PaymentCallbackDTO; | ||
| 10 | import com.infoloop.tianting.utils.DateUtil; | 11 | import com.infoloop.tianting.utils.DateUtil; |
| 11 | import com.infoloop.tianting.utils.EncryptionUtil; | 12 | import com.infoloop.tianting.utils.EncryptionUtil; |
| 12 | import lombok.RequiredArgsConstructor; | 13 | import lombok.RequiredArgsConstructor; |
| ... | @@ -30,7 +31,9 @@ import java.time.LocalDateTime; | ... | @@ -30,7 +31,9 @@ import java.time.LocalDateTime; |
| 30 | public class PayServiceClient { | 31 | public class PayServiceClient { |
| 31 | 32 | ||
| 32 | private final RestTemplate restTemplate; | 33 | private final RestTemplate restTemplate; |
| 34 | + | ||
| 33 | private final BusinessConfig businessConfig; | 35 | private final BusinessConfig businessConfig; |
| 36 | + | ||
| 34 | private final ObjectMapper objectMapper; | 37 | private final ObjectMapper objectMapper; |
| 35 | 38 | ||
| 36 | @Value("${payment.client-id:Order0001}") | 39 | @Value("${payment.client-id:Order0001}") |
| ... | @@ -85,7 +88,8 @@ public class PayServiceClient { | ... | @@ -85,7 +88,8 @@ public class PayServiceClient { |
| 85 | return responseEntity.getBody(); | 88 | return responseEntity.getBody(); |
| 86 | } | 89 | } |
| 87 | 90 | ||
| 88 | - public void callback(PayInformRequestDto payInformRequestDto) { | 91 | + public void callback(PaymentCallbackDTO payInformRequestDto) { |
| 92 | + log.info("callback: {}", payInformRequestDto); | ||
| 89 | 93 | ||
| 90 | } | 94 | } |
| 91 | } | 95 | } | ... | ... |
-
Please register or login to post a comment