no message
This commit is contained in:
37
pom.xml
37
pom.xml
@ -243,20 +243,17 @@
|
||||
<artifactId>shedlock-provider-redis-spring</artifactId>
|
||||
<version>4.44.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.douyin.openapi</groupId>
|
||||
<artifactId>sdk</artifactId>
|
||||
<version>1.0.6</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/src/main/resources/lib/sdk-1.0.6.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>douyin-openapi-repo</id>
|
||||
<url>https://artifacts-cn-beijing.volces.com/repository/douyin-openapi/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
<!-- Build Configuration -->
|
||||
<build>
|
||||
@ -275,6 +272,19 @@
|
||||
<exclude>*.yml</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.jar</include>
|
||||
</includes>
|
||||
<targetPath>${project.build.directory}/lib</targetPath>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<excludes>
|
||||
<exclude>lib/**</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<!-- Compiler Plugin -->
|
||||
@ -310,6 +320,19 @@
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@ -1,19 +1,40 @@
|
||||
package com.sczx.order.service.impl;
|
||||
|
||||
|
||||
import com.aliyun.tea.TeaException;
|
||||
import com.douyin.openapi.client.Client;
|
||||
import com.douyin.openapi.client.models.*;
|
||||
import com.douyin.openapi.credential.models.Config;
|
||||
|
||||
|
||||
import com.sczx.order.config.DouyinTokenManager;
|
||||
import com.sczx.order.exception.InnerException;
|
||||
import com.sczx.order.service.DouyinService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DouyinServiceImpl implements DouyinService {
|
||||
|
||||
@Value("${douyin.appId}")
|
||||
private String CLIENT_KEY = "awomt6nnjlfc491m";
|
||||
|
||||
@Value("${douyin.appSecret}")
|
||||
private String CLIENT_SECRET = "c678c411c7a68c6f97969f2dbd8ef8fc";
|
||||
|
||||
@Value("${douyin.appSecret}")
|
||||
private String ACCOUNT_ID = "7442188302710065206";
|
||||
|
||||
@Value("${douyin.appSecret}")
|
||||
private String POI_ID = "7442188302710065206";
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public String resolveShortUrlToGetObjectId(String shortUrl) {
|
||||
@ -44,6 +65,54 @@ public class DouyinServiceImpl implements DouyinService {
|
||||
throw new InnerException("扫码核销失败,二维码不正确");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Prepare(List<String> orderIds) throws Exception {
|
||||
// 获取当前有效的access_token
|
||||
String accessToken = DouyinTokenManager.getCurrentToken();
|
||||
|
||||
if (accessToken == null || accessToken.isEmpty()) {
|
||||
throw new RuntimeException("无法获取有效的access_token");
|
||||
}
|
||||
|
||||
try {
|
||||
Config config = new Config().setClientKey(CLIENT_KEY).setClientSecret(CLIENT_SECRET); // 改成自己的app_id跟secret
|
||||
Client client = new Client(config);
|
||||
/* 构建请求参数,该代码示例中只给出部分参数,请用户根据需要自行构建参数值
|
||||
token:
|
||||
1.若用户自行维护token,将用户维护的token赋值给该参数即可
|
||||
2.SDK包中有获取token的函数,请根据接口path在《OpenAPI SDK 总览》文档中查找获取token函数的名字
|
||||
在使用过程中,请注意token互刷问题
|
||||
header:
|
||||
sdk中默认填充content-type请求头,若不需要填充除content-type之外的请求头,删除该参数即可
|
||||
*/
|
||||
CertificatePrepareRequest sdkRequest = new CertificatePrepareRequest();
|
||||
sdkRequest.setAccessToken(accessToken);
|
||||
sdkRequest.setAccountId(ACCOUNT_ID);
|
||||
sdkRequest.setCode("GB3ChSgXHc");
|
||||
sdkRequest.setEncryptedData("9Q28CnUoEX");
|
||||
sdkRequest.setPoiId("KY9n9WUFKe");
|
||||
CertificatePrepareResponse sdkResponse = client.CertificatePrepare(sdkRequest);
|
||||
processCertificatePrepareResponse(sdkResponse);
|
||||
} catch (TeaException e) {
|
||||
System.out.println(e.getMessage());
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void processCertificatePrepareResponse(CertificatePrepareResponse response) {
|
||||
String verifyToken = response.getData().getVerifyToken();
|
||||
|
||||
response.getData().getCertificates().forEach(certificate -> {
|
||||
Long certificateId = certificate.getCertificateId();
|
||||
String skuId =certificate.getSku().getSkuId() ;
|
||||
certificate.getReserveInfo().getOrderReserveUserInfoList().forEach(orderReserveUserInfo -> {
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
BIN
src/main/resources/lib/sdk-1.0.6.jar
Normal file
BIN
src/main/resources/lib/sdk-1.0.6.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user