会员 mainShopId

This commit is contained in:
2025-09-23 13:43:27 +08:00
parent eb31057b3e
commit fc2757ff17
20 changed files with 599 additions and 482 deletions

View File

@@ -80,7 +80,7 @@ public class MyStpLogic {
logic.createLoginSession(id);
session = logic.getSession();
}
Object parentId1 = session.get("headId");
Object parentId1 = session.get("headShopId");
if (!isMain && parentId1 == null) {
session.set("headId", headId);
}
@@ -95,7 +95,7 @@ public class MyStpLogic {
* @param loginType 登录类型枚举
* @param isAdmin 是否为管理员账号
*/
public void login(Long id, String account, Long shopId, String shopName, LoginType loginType, boolean isAdmin, String platForm) {
public void login(Long id, String account, Long shopId, Long headShopId, String shopName, LoginType loginType, boolean isAdmin, String platForm) {
StpLogic logic = getLogic();
logic.login(id);
if (loginType.equals(LoginType.MANAGER) && shopId == null) {
@@ -107,6 +107,9 @@ public class MyStpLogic {
if (shopId != null) {
session.set("shopId", shopId);
}
if (headShopId != null) {
session.set("headShopId", headShopId);
}
if (shopName != null) {
session.set("shopName", shopName);
}
@@ -153,7 +156,7 @@ public class MyStpLogic {
* @return id
*/
public Long getHeadId() {
Object headId = getLogic().getSession().get("headId");
Object headId = getLogic().getSession().get("headShopId");
return headId == null ? null : Long.parseLong(headId.toString());
}
@@ -214,79 +217,27 @@ public class MyStpLogic {
}
/**
* 获取适用的店铺id主分店模式使用若全部开启同步返回主店id。若未开启同步则返回分店id
* 获取主店Id 非主店铺则获取当前shopId
*
* @return 主店id
*/
public Long getUsableShopId() {
Long shopId = getShopId(0L);
Long mainId = DbChain.table("tb_shop_config").select("main_id").where("id = ? and is_enable_prod_sync = 1 and is_enable_vip_sync = 1 and is_enable_cons_sync = 1", shopId).objAs(Long.class);
if (mainId != null) {
return mainId;
}
return shopId;
public Long getHeadShopIdBySession() {
SaSession session = getLogic().getSession();
Object headId = session.get("headShopId");
return headId != null ? Long.parseLong(headId.toString()) : session.get("shopId") instanceof Long l ? l : null;
}
/**
* 获取主店id
* 是否为管理端登录
*
* @return 主店id
* @return 布尔值
*/
public Long getHeadShopId() {
return getHeadShopId(getShopId(0L));
}
/**
* 获取主店id
*
* @param shopId 店铺id
* @return 主店id
*/
public Long getHeadShopId(Long shopId) {
Long mainId = DbChain.table("tb_shop_config").select("main_id").where("id = ?", shopId).objAs(Long.class);
if (mainId != null) {
return mainId;
}
return shopId;
}
/**
* 是否启用同步功能
*
* @param shopId 店铺id
* @return 主店id
*/
public boolean isEnableSync(Long shopId) {
Integer isEnableProdSync = DbChain.table("tb_shop_config").select("is_enable_prod_sync").where("id = ?", shopId).objAs(Integer.class);
if (isEnableProdSync == null) {
return false;
}
return isEnableProdSync == 1;
}
/**
* 校验是否为管理端登录
*/
public void checkManager() {
public boolean isManager() {
StpLogic logic = getLogic();
logic.checkLogin();
Object object = logic.getSession().get("isManager");
if (object instanceof Boolean t && !t) {
throw new NotPermissionException("权限不足");
}
return object instanceof Boolean t && t;
}
/**
* 校验是否为小程序登录
*/
public void checkMiniUser() {
StpLogic logic = getLogic();
logic.checkLogin();
Object object = logic.getSession().get("isManager");
if (object instanceof Boolean t && t) {
throw new NotPermissionException("权限不足");
}
}
/**
* 是否为管理端登录
@@ -303,16 +254,6 @@ public class MyStpLogic {
return object instanceof LoginType t && t.equals(LoginType.STAFF);
}
/**
* 是否为管理端登录
*
* @return 布尔值
*/
public boolean isManager() {
StpLogic logic = getLogic();
Object object = logic.getSession().get("isManager");
return object instanceof Boolean t && t;
}
/**
* 是否为管理员