新增漫画购买功能

This commit is contained in:
Yutousama 2022-04-08 13:36:55 +08:00
parent d9b3e7f558
commit 3fdd2cf5ec
2 changed files with 11 additions and 10 deletions

View File

@ -23,7 +23,7 @@ public class BiliBiliManga {
}
private static boolean isPayMission = false;
private static final Product missionProduct = new Product();
private static Product missionProduct = new Product();
private static Timer mission = null;
private final List<ObjectInterface> anInterface = new ArrayList<>();
@ -58,7 +58,7 @@ public class BiliBiliManga {
return list;
}
private int getMyPoint() {
public static int getMyPoint() {
JSONObject user = BiliBiliUtils.http_post("https://manga.bilibili.com/twirp/pointshop.v1.Pointshop/GetUserPoint", "");
if (user != null && user.getInteger("code") == 0) {
return user.getJSONObject("data").getInteger("point");
@ -75,14 +75,14 @@ public class BiliBiliManga {
}
int userPoint = getMyPoint();
List<Product> list = getListProduct();
Product item = null;
missionProduct = null;
for (Product product : list) {
if (product.getId() == id) {
item = product;
missionProduct = product;
break;
}
}
if (item == null) {
if (missionProduct == null) {
json.put("code", -1);
json.put("msg", "未找到商品可能id有误 id:" + id);
return json;
@ -90,17 +90,17 @@ public class BiliBiliManga {
if (num == -1) {
num = 99999;
}
int userPointNum = userPoint / item.getReal_cost();
int userPointNum = userPoint / missionProduct.getReal_cost();
num = Math.min(num, userPointNum);
if (num < item.getRemain_amount()) {
num = item.getRemain_amount();
if (num < missionProduct.getRemain_amount()) {
num = missionProduct.getRemain_amount();
}
JSONObject data = new JSONObject();
data.put("product_id", id);
data.put("product_num", num);
data.put("point", num * item.getReal_cost());
data.put("point", num * missionProduct.getReal_cost());
startPayMission(data);
isPayMission = true;
@ -109,7 +109,7 @@ public class BiliBiliManga {
json.put("msg", "商品无货,正在抢购");
}else {
json.put("code", 0);
json.put("msg", "任务创建成功:"+item+" 购买数量:"+num);
json.put("msg", "任务创建成功:"+missionProduct+" 购买数量:"+num);
}
return json;
}

View File

@ -49,6 +49,7 @@ public class BiliBiliMangeSign extends Model {
QQBotManager.getInstance().sendMessage(qq, builder.toString());
return;
}
builder.append("可用积分:").append(BiliBiliManga.getMyPoint()).append("\n");
builder.append("-------商城列表-------").append("\n");
for (BiliBiliManga.Product product : BiliBiliManga.getListProduct()) {
builder.append(product).append("\n");