6
0
Fork 0

更新版本号,增加对amount单位格式输出

master
nishengli 1 year ago
parent 91631fab98
commit fece48abe4
  1. 37
      pom.xml
  2. 7
      src/main/java/com/tsl3060/open/extend/core/ApiClient.java
  3. 5
      src/main/java/com/tsl3060/open/extend/core/constant/BuildInfo.java
  4. 30
      src/main/java/com/tsl3060/open/extend/core/notify/CarbonOrderNotify.java

@ -9,6 +9,7 @@
<version>0.3.12</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
@ -18,6 +19,8 @@
<logback.version>1.4.7</logback.version>
</properties>
<dependencies>
<dependency>
@ -77,6 +80,7 @@
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -111,6 +115,39 @@
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-antrun-plugin -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<goals>
<goal>run</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<target>
<property name="src.dir" value="${project.build.sourceDirectory}" />
<property name="package.dir" value="com/tsl3060/open/extend/core/constant" />
<property name="package.name" value="com.tsl3060.open.extend.core.constant" />
<property name="project.version" value="${project.version}" />
<echo file="${src.dir}/${package.dir}/BuildInfo.java" message="package ${package.name};${line.separator}" />
<echo file="${src.dir}/${package.dir}/BuildInfo.java" append="true" message="public final class BuildInfo {${line.separator}" />
<echo file="${src.dir}/${package.dir}/BuildInfo.java" append="true"
message="/** SDK Version */${line.separator}public static String VERSION=&quot;${project.version}&quot;;${line.separator}" />
<echo file="${src.dir}/${package.dir}/BuildInfo.java" append="true" message="}${line.separator}" />
<echo message="BUILD OK" />
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

@ -7,6 +7,7 @@ import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.tsl3060.open.extend.core.constant.BuildInfo;
import com.tsl3060.open.extend.core.exception.ApiException;
import com.tsl3060.open.extend.core.exception.BadResourceException;
import com.tsl3060.open.extend.core.notify.IAnswer;
@ -24,7 +25,6 @@ import java.util.*;
import java.util.concurrent.TimeUnit;
public class ApiClient {
private static final int ERROR_OK = 1000;
private static final int SUB_OK = 2000;
@ -47,6 +47,11 @@ public class ApiClient {
private final Log log = LogFactory.get();
public ApiClient() {
//输出版本
log.debug("SDK VERSION : {}", BuildInfo.VERSION);
}
private SecureTool getSecureTool() {
if (secureTool == null) {
secureTool = new SecureTool(getConfig());

@ -0,0 +1,5 @@
package com.tsl3060.open.extend.core.constant;
public final class BuildInfo {
/** SDK Version */
public static String VERSION="0.3.12";
}

@ -3,6 +3,8 @@ package com.tsl3060.open.extend.core.notify;
import com.alibaba.fastjson2.annotation.JSONField;
public class CarbonOrderNotify {
private final double scale = 100.0;
/**
* 用户OpenID
*/
@ -19,13 +21,13 @@ public class CarbonOrderNotify {
private String carbonNo;
/**
* 用户低碳积分
* 用户低碳积分 单位(0.01g)
*/
@JSONField(name = "carbon")
private int carbon;
/**
* 本次订单新增积分
* 本次订单新增积分 单位(0.01g)
*/
@JSONField(name = "amount")
private int amount;
@ -68,11 +70,29 @@ public class CarbonOrderNotify {
this.carbonNo = carbonNo;
}
/**
* 获取用户的低碳值单位(0.01g)
*
* @return
*/
public int getCarbon() {
return carbon;
}
/**
* 获取用户的低碳值单位(g)
*
* @return
*/
public double getCarbonValue() {
return carbon / scale;
}
/**
* 设置用户的低碳值 单位 (0.01g)
*
* @param carbon
*/
public void setCarbon(int carbon) {
this.carbon = carbon;
}
@ -81,6 +101,10 @@ public class CarbonOrderNotify {
return amount;
}
public double getAmountValue() {
return amount / scale;
}
public void setAmount(int amount) {
this.amount = amount;
}

Loading…
Cancel
Save