diff --git a/pom.xml b/pom.xml index 7a8592c..e650653 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.tsl3060.open.extend tsl-open-sdk-java-wanshun - 0.3.16 + 0.3.17 UTF-8 diff --git a/src/main/java/com/tsl3060/open/extend/core/INotifyListener.java b/src/main/java/com/tsl3060/open/extend/core/INotifyListener.java index 5f2a4e6..9341ea0 100644 --- a/src/main/java/com/tsl3060/open/extend/core/INotifyListener.java +++ b/src/main/java/com/tsl3060/open/extend/core/INotifyListener.java @@ -1,9 +1,6 @@ package com.tsl3060.open.extend.core; -import com.tsl3060.open.extend.core.notify.CarbonIntegralNotify; -import com.tsl3060.open.extend.core.notify.CarbonIntegralNotifyAnswer; -import com.tsl3060.open.extend.core.notify.CarbonOrderNotify; -import com.tsl3060.open.extend.core.notify.CarbonOrderNotifyAnswer; +import com.tsl3060.open.extend.core.notify.*; public interface INotifyListener { /** @@ -11,9 +8,18 @@ public interface INotifyListener { * * @param notify * @return + * @deprecated 后续不再通过订单通知低碳积分变更,请使用低碳积分变更通知接口 */ + @Deprecated CarbonOrderNotifyAnswer carbon(CarbonOrderNotify notify); + /** + * 低碳积分变更通知 + * + * @param notify 变更通知 + * @return 变更响应 + */ + CarbonValueNotifyAnswer carbonUpdate(CarbonValueNotify notify); /** * 绿色值变动通知 diff --git a/src/main/java/com/tsl3060/open/extend/core/notify/CarbonValueNotify.java b/src/main/java/com/tsl3060/open/extend/core/notify/CarbonValueNotify.java new file mode 100644 index 0000000..bf8ad8f --- /dev/null +++ b/src/main/java/com/tsl3060/open/extend/core/notify/CarbonValueNotify.java @@ -0,0 +1,107 @@ +package com.tsl3060.open.extend.core.notify; + +import com.alibaba.fastjson2.annotation.JSONField; + +public class CarbonValueNotify { + private String openid; + @JSONField(name = "type_id") + private String typeId; + @JSONField(name = "type_name") + private String typeName; + /** + * 低碳值变动数量(整形,单位:0.01) + */ + private String value; + /** + * 变动后余额(整形,单位0.01) + */ + private String balance; + + /** + * 低碳值订单号 + */ + @JSONField(name = "order_no") + private String orderNo; + + private String time; + + private String fettle; + + public String getOpenid() { + return openid; + } + + public void setOpenid(String openid) { + this.openid = openid; + } + + public String getTypeId() { + return typeId; + } + + public void setTypeId(String typeId) { + this.typeId = typeId; + } + + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getBalance() { + return balance; + } + + public void setBalance(String balance) { + this.balance = balance; + } + + public String getOrderNo() { + return orderNo; + } + + public void setOrderNo(String orderNo) { + this.orderNo = orderNo; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public String getFettle() { + return fettle; + } + + public void setFettle(String fettle) { + this.fettle = fettle; + } + + @Override + public String toString() { + return "CarbonValueNotify{" + + "openid='" + openid + '\'' + + ", typeId='" + typeId + '\'' + + ", typeName='" + typeName + '\'' + + ", value='" + value + '\'' + + ", balance='" + balance + '\'' + + ", orderNo='" + orderNo + '\'' + + ", time='" + time + '\'' + + ", fettle='" + fettle + '\'' + + '}'; + } +} diff --git a/src/main/java/com/tsl3060/open/extend/core/notify/CarbonValueNotifyAnswer.java b/src/main/java/com/tsl3060/open/extend/core/notify/CarbonValueNotifyAnswer.java new file mode 100644 index 0000000..0e8192c --- /dev/null +++ b/src/main/java/com/tsl3060/open/extend/core/notify/CarbonValueNotifyAnswer.java @@ -0,0 +1,20 @@ +package com.tsl3060.open.extend.core.notify; + +public class CarbonValueNotifyAnswer implements IAnswer{ + public CarbonValueNotifyAnswer(boolean answer) { + this.answer = answer; + } + + public CarbonValueNotifyAnswer() { + } + + private boolean answer; + + public boolean isAnswer() { + return answer; + } + + public void setAnswer(boolean answer) { + this.answer = answer; + } +} diff --git a/src/main/java/com/tsl3060/open/extend/core/router/notify/CarbonIntegralNotifyRouter.java b/src/main/java/com/tsl3060/open/extend/core/router/notify/CarbonIntegralNotifyRouter.java index ca8f3cc..199bbb2 100644 --- a/src/main/java/com/tsl3060/open/extend/core/router/notify/CarbonIntegralNotifyRouter.java +++ b/src/main/java/com/tsl3060/open/extend/core/router/notify/CarbonIntegralNotifyRouter.java @@ -1,7 +1,6 @@ package com.tsl3060.open.extend.core.router.notify; import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONObject; import com.tsl3060.open.extend.core.INotifyListener; import com.tsl3060.open.extend.core.NotifyRequest; import com.tsl3060.open.extend.core.notify.CarbonIntegralNotify; diff --git a/src/main/java/com/tsl3060/open/extend/core/router/notify/CarbonValueNotifyRouter.java b/src/main/java/com/tsl3060/open/extend/core/router/notify/CarbonValueNotifyRouter.java new file mode 100644 index 0000000..6d7dcfc --- /dev/null +++ b/src/main/java/com/tsl3060/open/extend/core/router/notify/CarbonValueNotifyRouter.java @@ -0,0 +1,27 @@ +package com.tsl3060.open.extend.core.router.notify; + +import com.alibaba.fastjson2.JSON; +import com.tsl3060.open.extend.core.INotifyListener; +import com.tsl3060.open.extend.core.NotifyRequest; +import com.tsl3060.open.extend.core.notify.CarbonValueNotify; +import com.tsl3060.open.extend.core.notify.IAnswer; +import com.tsl3060.open.extend.core.router.INotifyRouter; + +public class CarbonValueNotifyRouter implements INotifyRouter { + private final INotifyListener notifyListener; + + public CarbonValueNotifyRouter(INotifyListener notifyListener) { + this.notifyListener = notifyListener; + } + + @Override + public String path() { + return "/v1/wanshun/notify/carbonupdate"; + } + + @Override + public IAnswer makeBody(NotifyRequest notifyRequest) throws Exception { + CarbonValueNotify carbonValueNotify = JSON.to(CarbonValueNotify.class, notifyRequest.getPayload()); + return this.notifyListener.carbonUpdate(carbonValueNotify); + } +}