From 3c644472ffb95906550f2ab79a698cd5454db35b Mon Sep 17 00:00:00 2001
From: zheng sen he <61687266+meteorOSS@users.noreply.github.com>
Date: Wed, 3 Jan 2024 18:11:16 +0800
Subject: [PATCH] =?UTF-8?q?-=20=E4=BF=AE=E5=A4=8Dsqlite=E5=AD=98=E5=82=A8?=
=?UTF-8?q?=E4=B8=8B=E8=AE=A2=E5=8D=95=E9=87=8D=E5=A4=8D=E5=8F=91=E8=B4=A7?=
=?UTF-8?q?=20-=20=E6=95=B0=E6=8D=AE=E5=BA=93=E5=A2=9E=E5=8A=A0=E4=BA=8B?=
=?UTF-8?q?=E5=8A=A1=E6=8E=A7=E5=88=B6=20-=20=E5=A2=9E=E5=8A=A0=20=20=20-?=
=?UTF-8?q?=20/apl=20so=20[=E8=AE=A2=E5=8D=95=E7=BC=96=E5=8F=B7]=20?=
=?UTF-8?q?=E7=94=A8=E4=BA=8E=E6=89=8B=E5=8A=A8=E5=8F=91=E8=B4=A7=E8=AE=A2?=
=?UTF-8?q?=E5=8D=95=20=20=20-=20/apl=20info=20[=E8=AE=A2=E5=8D=95?=
=?UTF-8?q?=E7=BC=96=E5=8F=B7]=20=E6=9F=A5=E8=AF=A2=E8=AE=A2=E5=8D=95?=
=?UTF-8?q?=E7=8A=B6=E6=80=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 2 +-
.../meteor/aifadianpay/afdian/AfadianApi.java | 2 +-
.../afdian/request/AfdOrderReq.java | 17 ++-
.../command/AifadianCommandMain.java | 2 +
.../aifadianpay/command/sub/InfoCmd.java | 78 +++++++++++++
.../aifadianpay/command/sub/SendOutCmd.java | 96 ++++++++++++++++
.../aifadianpay/filter/FilterManager.java | 2 -
.../meteor/aifadianpay/storage/IStorage.java | 4 +-
.../aifadianpay/storage/sub/MysqlStorage.java | 108 ++++++++++++------
.../storage/sub/SqliteStorage.java | 67 +++++++----
src/main/resources/message.yml | 21 ++++
src/test/java/com/zsenhe/test/TestPack.java | 33 ++++++
12 files changed, 362 insertions(+), 70 deletions(-)
create mode 100644 src/main/java/com/meteor/aifadianpay/command/sub/InfoCmd.java
create mode 100644 src/main/java/com/meteor/aifadianpay/command/sub/SendOutCmd.java
create mode 100644 src/test/java/com/zsenhe/test/TestPack.java
diff --git a/pom.xml b/pom.xml
index 55d5872..2a7f471 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.meteor
AifadianPay
- 3.3-SNAPSHOT
+ 3.4-SNAPSHOT
jar
AifadianPay
diff --git a/src/main/java/com/meteor/aifadianpay/afdian/AfadianApi.java b/src/main/java/com/meteor/aifadianpay/afdian/AfadianApi.java
index d18b318..b02b1d6 100644
--- a/src/main/java/com/meteor/aifadianpay/afdian/AfadianApi.java
+++ b/src/main/java/com/meteor/aifadianpay/afdian/AfadianApi.java
@@ -119,7 +119,7 @@ public void success(PackHttpResponse packHttpResponse) {
@Override
public void fail(Exception e) {
-
+ e.printStackTrace();
}
});
}
diff --git a/src/main/java/com/meteor/aifadianpay/afdian/request/AfdOrderReq.java b/src/main/java/com/meteor/aifadianpay/afdian/request/AfdOrderReq.java
index 9885128..a2602c1 100644
--- a/src/main/java/com/meteor/aifadianpay/afdian/request/AfdOrderReq.java
+++ b/src/main/java/com/meteor/aifadianpay/afdian/request/AfdOrderReq.java
@@ -3,7 +3,7 @@
import com.google.gson.annotations.SerializedName;
public class AfdOrderReq {
- @SerializedName("page")
+
private Integer page;
@SerializedName("out_trade_no")
private String out_trade_no;
@@ -12,11 +12,19 @@ public AfdOrderReq(Integer page) {
this.page = page;
}
- public AfdOrderReq(Integer page, String out_trade_no) {
- this.page = page;
+ public AfdOrderReq(String out_trade_no) {
this.out_trade_no = out_trade_no;
}
+ /**
+ * 当为0时防止被序列化以查询特定编号订单
+ * @return
+ */
+ @SerializedName("page")
+ public Integer getPage(){
+ return page==0?null:page;
+ }
+
public void setPage(Integer page) {
this.page = page;
}
@@ -25,9 +33,6 @@ public void setOut_trade_no(String out_trade_no) {
this.out_trade_no = out_trade_no;
}
- public Integer getPage() {
- return page;
- }
public String getOut_trade_no() {
return out_trade_no;
diff --git a/src/main/java/com/meteor/aifadianpay/command/AifadianCommandMain.java b/src/main/java/com/meteor/aifadianpay/command/AifadianCommandMain.java
index c73cfe9..12ed428 100644
--- a/src/main/java/com/meteor/aifadianpay/command/AifadianCommandMain.java
+++ b/src/main/java/com/meteor/aifadianpay/command/AifadianCommandMain.java
@@ -16,5 +16,7 @@ public void init() {
register(new HelpCmd(AifadianPay.INSTANCE));
register(new PingCmd(AifadianPay.INSTANCE));
register(new DebugCmd(AifadianPay.INSTANCE));
+ register(new InfoCmd(AifadianPay.INSTANCE));
+ register(new SendOutCmd(AifadianPay.INSTANCE));
}
}
diff --git a/src/main/java/com/meteor/aifadianpay/command/sub/InfoCmd.java b/src/main/java/com/meteor/aifadianpay/command/sub/InfoCmd.java
new file mode 100644
index 0000000..ee2bfa5
--- /dev/null
+++ b/src/main/java/com/meteor/aifadianpay/command/sub/InfoCmd.java
@@ -0,0 +1,78 @@
+package com.meteor.aifadianpay.command.sub;
+
+import com.meteor.aifadianpay.AifadianPay;
+import com.meteor.aifadianpay.afdian.AfadianApi;
+import com.meteor.aifadianpay.afdian.request.AfdOrderReq;
+import com.meteor.aifadianpay.afdian.response.Order;
+import com.meteor.aifadianpay.afdian.response.Orders;
+import com.meteor.aifadianpay.afdian.response.QueryOrderResponse;
+import com.meteor.aifadianpay.command.SubCmd;
+import com.meteor.aifadianpay.httputil.callback.AsyncHttpResponseCallBack;
+import com.meteor.aifadianpay.httputil.response.PackHttpResponse;
+import com.meteor.aifadianpay.util.BaseConfig;
+import org.bukkit.command.CommandSender;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class InfoCmd extends SubCmd {
+ public InfoCmd(JavaPlugin plugin) {
+ super(plugin);
+ }
+
+ @Override
+ public String label() {
+ return "info";
+ }
+
+ @Override
+ public String getPermission() {
+ return "afadian.admin";
+ }
+
+ @Override
+ public boolean playersOnly() {
+ return false;
+ }
+
+ @Override
+ public String usage() {
+ return null;
+ }
+
+ @Override
+ public void perform(CommandSender p0, String[] p1) {
+
+ if(p1.length<2) return;
+
+ AfadianApi.afadianApi.queryOrders(new AfdOrderReq(p1[1]), new AsyncHttpResponseCallBack() {
+ @Override
+ public void success(PackHttpResponse packHttpResponse) {
+ QueryOrderResponse queryOrderResponse = AfadianApi.afadianApi.toOrders(packHttpResponse);
+ List orderList = queryOrderResponse.getOrders().getOrderList();
+ if(orderList.isEmpty()){
+ p0.sendMessage(BaseConfig.STORE.getMessageBox().getMessage(null,"message.order-info.notExistOrder"));
+ }else {
+ Order order = orderList.get(0);
+ Map params = new HashMap<>();
+ params.put("@trade_no@",order.getOutTradeNo());
+ params.put("@state@", AifadianPay.INSTANCE.getiStorage().isHandleOrder(order.getOutTradeNo())
+ ?"§a已处理":"§c未处理");
+ params.put("@remark@",order.getRemark()==null?"§c未留言":order.getRemark());
+ params.put("@plan@",order.getPlanTitle());
+ params.put("@price@",order.getTotalAmount());
+
+ BaseConfig.STORE.getMessageBox().getMessageList(params,"message.order-info.state")
+ .forEach(s->p0.sendMessage(s));
+ }
+ }
+
+ @Override
+ public void fail(Exception e) {
+
+ }
+ });
+ }
+}
diff --git a/src/main/java/com/meteor/aifadianpay/command/sub/SendOutCmd.java b/src/main/java/com/meteor/aifadianpay/command/sub/SendOutCmd.java
new file mode 100644
index 0000000..4b65ab9
--- /dev/null
+++ b/src/main/java/com/meteor/aifadianpay/command/sub/SendOutCmd.java
@@ -0,0 +1,96 @@
+package com.meteor.aifadianpay.command.sub;
+
+import com.meteor.aifadianpay.AifadianPay;
+import com.meteor.aifadianpay.afdian.AfadianApi;
+import com.meteor.aifadianpay.afdian.request.AfdOrderReq;
+import com.meteor.aifadianpay.afdian.response.Order;
+import com.meteor.aifadianpay.afdian.response.QueryOrderResponse;
+import com.meteor.aifadianpay.command.SubCmd;
+import com.meteor.aifadianpay.httputil.callback.AsyncHttpResponseCallBack;
+import com.meteor.aifadianpay.httputil.response.PackHttpResponse;
+import com.meteor.aifadianpay.util.BaseConfig;
+import org.bukkit.Bukkit;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 手动发货订单
+ */
+public class SendOutCmd extends SubCmd {
+ public SendOutCmd(JavaPlugin plugin) {
+ super(plugin);
+ }
+
+ @Override
+ public String label() {
+ return "so";
+ }
+
+ @Override
+ public String getPermission() {
+ return "afadian.use.so";
+ }
+
+ @Override
+ public boolean playersOnly() {
+ return false;
+ }
+
+ @Override
+ public String usage() {
+ return null;
+ }
+
+ @Override
+ public void perform(CommandSender p0, String[] p1) {
+
+ if(p1.length<2) return;
+
+ AfadianApi.afadianApi.queryOrders(new AfdOrderReq(p1[1]), new AsyncHttpResponseCallBack() {
+ @Override
+ public void success(PackHttpResponse packHttpResponse) {
+ QueryOrderResponse queryOrderResponse = AfadianApi.afadianApi.toOrders(packHttpResponse);
+ List orderList = queryOrderResponse.getOrders().getOrderList();
+ if(orderList.isEmpty()){
+ p0.sendMessage(BaseConfig.STORE.getMessageBox().getMessage(null,"message.order-info.notExistOrder"));
+ }else {
+ Order order = orderList.get(0);
+ if(p0 instanceof Player){
+ Player player = (Player) p0;
+ if(!player.isOp() && (order.getRemark()==null|| !order.getRemark().equalsIgnoreCase(player.getName()))){
+ player.sendMessage(BaseConfig.STORE.getMessageBox().getMessage(null,"message.send-out.remark-error"));
+ return;
+ }
+ }
+
+ if(AifadianPay.INSTANCE.getiStorage().isHandleOrder(order.getOutTradeNo())){
+ p0.sendMessage(BaseConfig.STORE.getMessageBox().getMessage(null,"message.send-out.repeat"));
+ }else {
+ if(order.getRemark()==null|| Bukkit.getPlayerExact(order.getRemark())==null){
+ p0.sendMessage(BaseConfig.STORE.getMessageBox().getMessage(null,"message.send-out.not-online"));
+ return;
+ }
+ if(AifadianPay.INSTANCE.getiStorage().handeOrder(order,true)){
+ p0.sendMessage(BaseConfig.STORE.getMessageBox().getMessage(null,"message.send-out.success"));
+ }else {
+ p0.sendMessage(BaseConfig.STORE.getMessageBox().getMessage(null,"message.send-out.fail"));
+ }
+ }
+
+
+
+ }
+ }
+
+ @Override
+ public void fail(Exception e) {
+ e.printStackTrace();
+ }
+ });
+ }
+}
diff --git a/src/main/java/com/meteor/aifadianpay/filter/FilterManager.java b/src/main/java/com/meteor/aifadianpay/filter/FilterManager.java
index 93dd459..382f5fe 100644
--- a/src/main/java/com/meteor/aifadianpay/filter/FilterManager.java
+++ b/src/main/java/com/meteor/aifadianpay/filter/FilterManager.java
@@ -26,8 +26,6 @@ public class FilterManager {
* @return
*/
public static List meet(List orders){
-
-
for (OrderFilter filter : filters) {
orders = filter.meet(orders);
}
diff --git a/src/main/java/com/meteor/aifadianpay/storage/IStorage.java b/src/main/java/com/meteor/aifadianpay/storage/IStorage.java
index fc62329..72156dd 100644
--- a/src/main/java/com/meteor/aifadianpay/storage/IStorage.java
+++ b/src/main/java/com/meteor/aifadianpay/storage/IStorage.java
@@ -9,7 +9,7 @@ public interface IStorage {
/**
* 处理订单
*/
- void handeOrder(Order order,boolean b);
+ boolean handeOrder(Order order,boolean b);
/**
* 获取玩家捐赠总数
@@ -18,4 +18,6 @@ public interface IStorage {
*/
int queryPlayerDonate(String p);
+ boolean isHandleOrder(String tradeNo);
+
}
diff --git a/src/main/java/com/meteor/aifadianpay/storage/sub/MysqlStorage.java b/src/main/java/com/meteor/aifadianpay/storage/sub/MysqlStorage.java
index 9135334..a024306 100644
--- a/src/main/java/com/meteor/aifadianpay/storage/sub/MysqlStorage.java
+++ b/src/main/java/com/meteor/aifadianpay/storage/sub/MysqlStorage.java
@@ -15,6 +15,7 @@
import org.bukkit.entity.Player;
import org.checkerframework.checker.units.qual.C;
+import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -45,6 +46,13 @@ public MysqlStorage(AifadianPay plugin){
this.plugin = plugin;
this.fastMySQLStorage = new FastMySQLStorage(plugin,plugin.getConfig().getConfigurationSection("mysql-info"));
this.connect();
+ // 启用事务
+ try {
+ this.getConnection().setAutoCommit(false);
+ plugin.getLogger().info("已禁用数据库自动提交");
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
}
private void connect(){
@@ -91,56 +99,79 @@ private boolean isExistOrder(String trade_no){
* @param order
*/
@Override
- public void handeOrder(Order order,boolean isSave) {
+ public boolean handeOrder(Order order,boolean isSave) {
// 过滤订单
List orders = FilterManager.meet(Arrays.asList(order));
if(!orders.isEmpty()){
Order handleOrder = orders.get(0);
Player playerExact = Bukkit.getPlayerExact(handleOrder.getRemark());
+ Connection connection = getConnection();
+
if(playerExact!=null&&isSave){
- if(!isExistOrder(handleOrder.getOutTradeNo())){
-
- /***
- * 插入已处理订单表
- */
- KeyValue[] tradeLog = {
- new KeyValue("out_trade_no",handleOrder.getOutTradeNo()),
- new KeyValue("remark",handleOrder.getRemark()),
- new KeyValue("user_id",handleOrder.getUserId()),
- new KeyValue("plan_title",handleOrder.getPlanTitle()),
- new KeyValue("redeem_id",handleOrder.getRedeemId()),
- new KeyValue("price",handleOrder.getTotalAmount()),
- new KeyValue("insert_time",System.currentTimeMillis())
- };
- fastMySQLStorage.put(ORDER_TABLE,tradeLog);
-
- /***
- * 型号处理
- */
- for (SkuDetail skuDetail : handleOrder.getSkuDetail()) {
- KeyValue[] skuDetailLog = {
+
+ try {
+ if(!isExistOrder(handleOrder.getOutTradeNo())){
+
+ /***
+ * 插入已处理订单表
+ */
+ KeyValue[] tradeLog = {
new KeyValue("out_trade_no",handleOrder.getOutTradeNo()),
- new KeyValue("sku_id",skuDetail.getSkuId()),
- new KeyValue("price",skuDetail.getPic()),
- new KeyValue("name",skuDetail.getName()),
- new KeyValue("count",skuDetail.getCount())
+ new KeyValue("remark",handleOrder.getRemark()),
+ new KeyValue("user_id",handleOrder.getUserId()),
+ new KeyValue("plan_title",handleOrder.getPlanTitle()),
+ new KeyValue("redeem_id",handleOrder.getRedeemId()),
+ new KeyValue("price",handleOrder.getTotalAmount()),
+ new KeyValue("insert_time",System.currentTimeMillis())
};
- fastMySQLStorage.put(SKU_DETAIL_TABLE,skuDetailLog);
+ fastMySQLStorage.put(ORDER_TABLE,tradeLog);
+
+ /***
+ * 型号处理
+ */
+ for (SkuDetail skuDetail : handleOrder.getSkuDetail()) {
+ KeyValue[] skuDetailLog = {
+ new KeyValue("out_trade_no",handleOrder.getOutTradeNo()),
+ new KeyValue("sku_id",skuDetail.getSkuId()),
+ new KeyValue("price",skuDetail.getPic()),
+ new KeyValue("name",skuDetail.getName()),
+ new KeyValue("count",skuDetail.getCount())
+ };
+ fastMySQLStorage.put(SKU_DETAIL_TABLE,skuDetailLog);
+ }
+
+ // 提交事务
+ connection.commit();
+
+ /**
+ * 发货
+ */
+ ShopItem shopItem = BaseConfig.STORE.getShopItemMap().get(handleOrder.getPlanTitle());
+ Bukkit.getScheduler().runTask(plugin,()->{
+ SendOutGoodsEvent sendOutGoodsEvent = new SendOutGoodsEvent(playerExact,shopItem,handleOrder.getOutTradeNo(),handleOrder.getSkuDetail(),handleOrder);
+ Bukkit.getServer().getPluginManager().callEvent(sendOutGoodsEvent);
+ });
+ return true;
+ }
+ }catch (SQLException sqlException){
+ try {
+ connection.rollback();
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
}
-
- /**
- * 发货
- */
- ShopItem shopItem = BaseConfig.STORE.getShopItemMap().get(handleOrder.getPlanTitle());
- Bukkit.getScheduler().runTask(plugin,()->{
- SendOutGoodsEvent sendOutGoodsEvent = new SendOutGoodsEvent(playerExact,shopItem,handleOrder.getOutTradeNo(),handleOrder.getSkuDetail(),handleOrder);
- Bukkit.getServer().getPluginManager().callEvent(sendOutGoodsEvent);
- });
}
}
}
+ return false;
+ }
+ private Connection getConnection(){
+ try {
+ return fastMySQLStorage.getConnection();
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
}
@Override
@@ -163,4 +194,9 @@ public int queryPlayerDonate(String p) {
}
return 0;
}
+
+ @Override
+ public boolean isHandleOrder(String tradeNo) {
+ return isExistOrder(tradeNo);
+ }
}
diff --git a/src/main/java/com/meteor/aifadianpay/storage/sub/SqliteStorage.java b/src/main/java/com/meteor/aifadianpay/storage/sub/SqliteStorage.java
index 3c55b71..25aedca 100644
--- a/src/main/java/com/meteor/aifadianpay/storage/sub/SqliteStorage.java
+++ b/src/main/java/com/meteor/aifadianpay/storage/sub/SqliteStorage.java
@@ -57,6 +57,11 @@ private void connect(){
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
+ try {
+ connection.setAutoCommit(false);
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
}
@@ -71,6 +76,7 @@ public boolean isExistOrder(String no){
resultSet = null;
try {
preparedStatement = this.connection.prepareStatement("select * from " + ORDER_TABLE + " where out_trade_no = ?");
+ preparedStatement.setString(1,no);
resultSet = preparedStatement.executeQuery();
while (resultSet.next()) return true;
} catch (SQLException e) {
@@ -123,41 +129,51 @@ public void insertSkudetail(Order order,SkuDetail skuDetail) {
}
@Override
- public void handeOrder(Order order, boolean b) {
+ public boolean handeOrder(Order order, boolean b) {
List orders = FilterManager.meet(Arrays.asList(order));
if(!orders.isEmpty()){
Order handleOrder = orders.get(0);
Player playerExact = Bukkit.getPlayerExact(handleOrder.getRemark());
if(playerExact!=null&&b){
+ try {
+ if(!isExistOrder(handleOrder.getOutTradeNo())){
+ /***
+ * 插入已处理订单表
+ */
+ this.insertOrder(handleOrder);
+ /***
+ * 型号处理
+ */
+ for (SkuDetail skuDetail : handleOrder.getSkuDetail()) {
+ this.insertSkudetail(handleOrder,skuDetail);
+ }
+ /**
+ * 发货
+ */
+ ShopItem shopItem = BaseConfig.STORE.getShopItemMap().get(handleOrder.getPlanTitle());
+ Bukkit.getScheduler().runTask(plugin,()->{
+ SendOutGoodsEvent sendOutGoodsEvent = new SendOutGoodsEvent(playerExact,shopItem,handleOrder.getOutTradeNo(),handleOrder.getSkuDetail(),handleOrder);
+ Bukkit.getServer().getPluginManager().callEvent(sendOutGoodsEvent);
+ });
+ connection.commit();
+ return true;
+ }
+ }catch (SQLException sqlException){
-
- if(!isExistOrder(handleOrder.getOutTradeNo())){
-
- /***
- * 插入已处理订单表
- */
- this.insertOrder(handleOrder);
-
-
- /***
- * 型号处理
- */
- for (SkuDetail skuDetail : handleOrder.getSkuDetail()) {
- this.insertSkudetail(handleOrder,skuDetail);
+ try {
+ connection.rollback();
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
}
- /**
- * 发货
- */
- ShopItem shopItem = BaseConfig.STORE.getShopItemMap().get(handleOrder.getPlanTitle());
- Bukkit.getScheduler().runTask(plugin,()->{
- SendOutGoodsEvent sendOutGoodsEvent = new SendOutGoodsEvent(playerExact,shopItem,handleOrder.getOutTradeNo(),handleOrder.getSkuDetail(),handleOrder);
- Bukkit.getServer().getPluginManager().callEvent(sendOutGoodsEvent);
- });
}
+
+
}
}
+
+ return false;
}
@Override
@@ -182,4 +198,9 @@ public int queryPlayerDonate(String p) {
}
return 0;
}
+
+ @Override
+ public boolean isHandleOrder(String tradeNo) {
+ return isExistOrder(tradeNo);
+ }
}
diff --git a/src/main/resources/message.yml b/src/main/resources/message.yml
index d532e99..79789d0 100644
--- a/src/main/resources/message.yml
+++ b/src/main/resources/message.yml
@@ -4,10 +4,31 @@ message:
- '@prefix@'
- '&f/apl ping &7验证api状态'
- '&f/apl debug &7开关调试状态'
+ - '&f/apl info [订单编号] &7查询订单处理状态'
+ - '&f/apl so [订单编号] &7手动收货(发货)'
- '&f/apl reload &7重载配置文件'
only-player: '@prefix@ &c该指令仅玩家可使用'
reload: '@prefix@ &c已重载配置文件'
no-perm: '@prefix@ &f缺少指定权限 &6@permission@'
+
+ send-out:
+ remark-error: '@prefix@ &7订单未留言玩家id或你不是该订单的主人'
+ success: '@prefix@ &7已处理订单'
+ fail: '@prefix@ &c订单处理失败,你可以开启debug模式后再次处理订单查询失败的原因...'
+ not-online: '@prefix@ &7订单主人离线或不存在...'
+ repeat: '@prefix@ &7该订单已经处理过了,请不要重复处理'
+
+ order-info:
+ notExistOrder: '@prefix@ &7该订单不存在'
+ state:
+ - ''
+ - '&7订单编号 &3@trade_no@'
+ - '&7订单是否已处理 @state@'
+ - '&7订单留言(发货玩家) &a@remark@'
+ - ''
+ - '&7购买商品 &6&l@plan@'
+ - '&7花费 &6&n@price@¥'
+
debug: '@prefix@ &f调试模式为 &e@mode@'
ping:
success: '@prefix@ &fAPI状态正常!请放心使用'
diff --git a/src/test/java/com/zsenhe/test/TestPack.java b/src/test/java/com/zsenhe/test/TestPack.java
new file mode 100644
index 0000000..998bad2
--- /dev/null
+++ b/src/test/java/com/zsenhe/test/TestPack.java
@@ -0,0 +1,33 @@
+package com.zsenhe.test;
+
+import com.google.gson.JsonObject;
+import com.meteor.aifadianpay.afdian.AfadianApi;
+import com.meteor.aifadianpay.httputil.Http;
+import com.meteor.aifadianpay.httputil.HttpHeaders;
+import com.meteor.aifadianpay.httputil.callback.AsyncHttpResponseCallBack;
+import com.meteor.aifadianpay.httputil.response.PackHttpResponse;
+
+/**
+ * 测试拉取商品自动创建
+ */
+public class TestPack {
+ public static void main(String[] args) {
+ Http.url("https://afdian.net/api/creator/get-plan-skus?plan_id=6da20b76aa1011eeb63f5254001e7c00&is_ext=")
+ .timeOut(3000)
+ .header(HttpHeaders.ACCEPT, "application/json")
+ .asyncGet(new AsyncHttpResponseCallBack() {
+ @Override
+ public void success(PackHttpResponse packHttpResponse) {
+ String asString = packHttpResponse.getAsString("UTF-8");
+ System.out.println(asString);
+ JsonObject jsonObject = AfadianApi.gson.fromJson(asString, JsonObject.class);
+
+ }
+
+ @Override
+ public void fail(Exception e) {
+
+ }
+ });
+ }
+}