-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 数据库增加事务控制 - 增加 - /apl so [订单编号] 用于手动发货订单 - /apl info [订单编号] 查询订单状态
- Loading branch information
Showing
12 changed files
with
362 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/main/java/com/meteor/aifadianpay/command/sub/InfoCmd.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Order> 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<String,String> 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) { | ||
|
||
} | ||
}); | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
src/main/java/com/meteor/aifadianpay/command/sub/SendOutCmd.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Order> 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(); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.