PROXY\_ACCOUNT 租赁账户,首页中的租赁套餐,不应该用列表的的方式,应为一个userId用户对应一个套餐,请修正,要求页面美观,用户交互友好
This commit is contained in:
1 parent
0fd0450ddb
commit
127d575a1c
11 files changed
+65
-18
No files matched your search
@@ -73,7 +73,7 @@ public class RentalApiController {
|
||||
"SELECT"
|
||||
+ " id,package_code,revision,name,network,resource_type,resource_quantity,duration_seconds,sale_amount"
|
||||
+ " FROM rent_package p WHERE status='ACTIVE' AND network=?"
|
||||
+ " AND EXISTS(SELECT 1 FROM rent_user_package b WHERE b.package_id=p.id AND b.user_id=? AND b.status='ACTIVE') ORDER BY"
|
||||
+ " AND EXISTS(SELECT 1 FROM rent_user_package b WHERE b.package_id=p.id AND b.user_id=? AND b.status='ACTIVE' AND b.default_slot=1) ORDER BY"
|
||||
+ " id",
|
||||
network(input(data, "network", 16)), number(app, "user_id"));
|
||||
return AjaxResult.success(products);
|
||||
|
||||
@@ -84,7 +84,7 @@ public class RentalOrders {
|
||||
validatePackage(product);
|
||||
require("ACTIVE".equals(text(product, "status")), "套餐未上架");
|
||||
Map<String, Object> binding = store.one("SELECT * FROM rent_user_package"
|
||||
+ " WHERE user_id=? AND package_id=? AND status='ACTIVE' FOR UPDATE",
|
||||
+ " WHERE user_id=? AND package_id=? AND status='ACTIVE' AND default_slot=1 FOR UPDATE",
|
||||
number(app, "user_id"), packageId);
|
||||
require(binding != null, "该套餐未绑定到应用所属用户或绑定已停用");
|
||||
if (request.containsKey("network")) {
|
||||
|
||||
@@ -26,14 +26,14 @@ public class RentalPackageBindings {
|
||||
require("ACTIVE".equals(text(product, "status")), "请先审核上架套餐再绑定用户");
|
||||
RentalOrders.validatePackage(product);
|
||||
}
|
||||
require(enabled || !makeDefault, "停用绑定不能设为默认");
|
||||
if (makeDefault) {
|
||||
store.execute("UPDATE rent_user_package SET default_slot=NULL,version=version+1,updated_at=? WHERE user_id=? AND default_slot=1",
|
||||
now(), userId);
|
||||
// 一人仅一个当前套餐,切换时停用其他绑定,历史记录继续保留。
|
||||
if (enabled) {
|
||||
store.execute("UPDATE rent_user_package SET status='DISABLED',default_slot=NULL,version=version+1,updated_at=? WHERE user_id=? AND package_id<>?",
|
||||
now(), userId, packageId);
|
||||
}
|
||||
Map<String, Object> existing = store.one("SELECT * FROM rent_user_package WHERE user_id=? AND package_id=? FOR UPDATE", userId, packageId);
|
||||
Map<String, Object> values = map("status", enabled ? "ACTIVE" : "DISABLED",
|
||||
"default_slot", makeDefault ? 1 : null);
|
||||
"default_slot", enabled ? 1 : null);
|
||||
if (existing == null) {
|
||||
values.put("user_id", userId);
|
||||
values.put("package_id", packageId);
|
||||
@@ -43,13 +43,13 @@ public class RentalPackageBindings {
|
||||
store.update("user_package", number(existing, "id"), values);
|
||||
}
|
||||
store.event("PACKAGE", packageId, "BIND_USER", actor,
|
||||
"用户ID=" + userId + ",状态=" + values.get("status") + ",默认=" + makeDefault);
|
||||
"用户ID=" + userId + ",状态=" + values.get("status") + ",一人一个当前套餐");
|
||||
}
|
||||
|
||||
/** 显式安全列,供本人/管理员页面查看,不返回成本或供应商利润。 */
|
||||
public List<Map<String, Object>> list(long userId) {
|
||||
return store.rows("SELECT b.id AS binding_id,b.user_id,b.package_id,b.status AS binding_status,b.default_slot,"
|
||||
+ "p.name,p.network,p.resource_type,p.resource_quantity,p.duration_seconds,p.sale_amount,p.status"
|
||||
+ "p.name,p.revision,p.network,p.resource_type,p.resource_quantity,p.redundancy_percent,p.duration_seconds,p.sale_amount,p.status"
|
||||
+ " FROM rent_user_package b JOIN rent_package p ON p.id=b.package_id"
|
||||
+ " WHERE b.user_id=? ORDER BY b.default_slot DESC,b.id DESC", userId);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class RentalQueries {
|
||||
where = "r.user_id=?";
|
||||
break;
|
||||
case "package":
|
||||
where = "r.status='ACTIVE' AND EXISTS(SELECT 1 FROM rent_user_package b WHERE b.package_id=r.id AND b.user_id=? AND b.status='ACTIVE')";
|
||||
where = "r.status='ACTIVE' AND EXISTS(SELECT 1 FROM rent_user_package b WHERE b.package_id=r.id AND b.user_id=? AND b.status='ACTIVE' AND b.default_slot=1)";
|
||||
break;
|
||||
case "wallet":
|
||||
where =
|
||||
|
||||
Reference in new issue
Block a user