会员 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;
}
/**
* 是否为管理员

View File

@@ -61,9 +61,14 @@ public class ShopUser implements Serializable {
private Integer sex;
/**
* 店铺Id
* 店铺Id
*/
private Long shopId;
private Long mainShopId;
/**
* 来源店铺Id
*/
private Long sourceShopId;
/**
* 用户Id

View File

@@ -0,0 +1,28 @@
package com.czg.account.service;
import com.czg.account.dto.shopuser.*;
import com.czg.account.entity.ShopUser;
import com.czg.resp.CzgResult;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
import java.math.BigDecimal;
/**
* 商户储值会员 服务层。
*
* @author Administrator
* @since 2025-02-08
*/
public interface AShopUserService {
Page<ShopUserDTO> getPage(String key, Integer isVip, BigDecimal amount);
Boolean add(Long shopId, ShopUserAddDTO shopUserAddDTO);
Boolean updateInfo(Long shopId, ShopUserEditDTO shopUserEditDTO);
ShopUserSummaryDTO getSummary(Long shopId, Integer isVip);
ShopUser getDetail(Integer id, Integer userId);
}

View File

@@ -27,4 +27,6 @@ public interface ShopInfoService extends IService<ShopInfo> {
Page<ShopInfoSubVO> getSubList(String lat, String lng, float distance);
List<ShopBranchSelectDTO> findShopBranch(Long shopId);
Long getMainIdByShopId(Long shopId);
}

View File

@@ -16,31 +16,11 @@ import java.math.BigDecimal;
*/
public interface ShopUserService extends IService<ShopUser> {
Page<ShopUserDTO> getPage(String key, Integer isVip, BigDecimal amount);
Boolean updateInfo(Long shopId, ShopUserEditDTO shopUserEditDTO);
/**
* 返回流水Id
*/
Long updateMoney(Long shopId, ShopUserMoneyEditDTO shopUserEditDTO);
ShopUserSummaryDTO getSummary(Long shopId, Integer isVip);
ShopUser getShopUserInfo(Long shopId, long userId);
Boolean add(Long shopId, ShopUserAddDTO shopUserAddDTO);
/**
* 获取小程序登录用户所有店铺会员信息
*/
Page<ShopUserVipCardDTO> vipCard(long userInfoId);
CzgResult<String> getCode(long userInfoId, long shopId);
boolean join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO);
ShopUserDetailDTO getInfo(Long shopId, long userId);
ShopUser getDetail(Integer id, Integer userId);
}

View File

@@ -0,0 +1,32 @@
package com.czg.account.service;
import com.czg.account.dto.shopuser.*;
import com.czg.account.entity.ShopUser;
import com.czg.resp.CzgResult;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
import java.math.BigDecimal;
/**
* 商户储值会员 服务层。
*
* @author Administrator
* @since 2025-02-08
*/
public interface UShopUserService {
ShopUser getShopUserInfo(Long shopId, long userId);
/**
* 获取小程序登录用户所有店铺会员信息
*/
Page<ShopUserVipCardDTO> vipCard(long userInfoId);
CzgResult<String> getCode(long userInfoId, long shopId);
boolean join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO);
ShopUserDetailDTO getInfo(Long shopId, long userId);
}

View File

@@ -20,11 +20,16 @@ public class AssertUtil {
/**
* 判断两个对象是否不相等,如果不相等则抛出异常
* @param a 实际值
* @param b 期望
*
* @param a 实际
* @param b 期望值
* @param message 异常消息
*/
public static void isNotEqual(Object a, Object b, String message) {
// 检查是否有任何一个为null
if (a == null || b == null) {
throw new ValidateException("参数不能为null: " + message);
}
// 如果实际值与期望值不相等,则抛出异常
if (!Objects.equals(a, b)) {
throw new ValidateException(message);
@@ -43,6 +48,7 @@ public class AssertUtil {
throw new ValidateException(msg);
}
}
/**
* 检查字符串是否不为空或空白字符,如果为空或空白字符则抛出异常
*
@@ -54,6 +60,7 @@ public class AssertUtil {
public static void isBlank(String str, String errorMsgTemplate, Object... params) {
isBlank(str, StrUtil.format(errorMsgTemplate, params));
}
/**
* 检查对象是否不为 null如果为 null 则抛出异常
*
@@ -66,6 +73,7 @@ public class AssertUtil {
throw new ValidateException(msg);
}
}
/**
* 检查对象是否不为 null如果为 null 则抛出异常
*
@@ -77,6 +85,7 @@ public class AssertUtil {
public static void isNull(Object object, String errorMsgTemplate, Object... params) {
isNull(object, StrUtil.format(errorMsgTemplate, params));
}
public static void isTrue(boolean flag, String errorMsgTemplate, Object... params) {
if (flag) {
throw new ValidateException(StrUtil.format(errorMsgTemplate, params));
@@ -95,6 +104,7 @@ public class AssertUtil {
throw new ValidateException(msg);
}
}
/**
* 检查数组是否不为空,如果为空则抛出异常
*
@@ -106,6 +116,7 @@ public class AssertUtil {
public static void isArrayEmpty(Object[] array, String errorMsgTemplate, Object... params) {
isArrayEmpty(array, StrUtil.format(errorMsgTemplate, params));
}
/**
* 检查列表是否不为空,如果为空则抛出异常
*
@@ -118,6 +129,7 @@ public class AssertUtil {
throw new ValidateException(msg);
}
}
/**
* 检查列表是否不为空,如果为空则抛出异常
*
@@ -129,13 +141,14 @@ public class AssertUtil {
public static void isListEmpty(List<?> list, String errorMsgTemplate, Object... params) {
isListEmpty(list, StrUtil.format(errorMsgTemplate, params));
}
/**
* 检查 Map 是否不为空,如果为空则抛出异常
*
* @param <K> Map 的键类型
* @param <V> Map 的值类型
* @param map 要检查的 Map
* @param msg 异常信息
* @param <K> Map 的键类型
* @param <V> Map 的值类型
* @param map 要检查的 Map
* @param msg 异常信息
* @throws ValidateException 如果 Map 为空
*/
public static <K, V> void isMapEmpty(Map<K, V> map, String msg) {
@@ -143,6 +156,7 @@ public class AssertUtil {
throw new ValidateException(msg);
}
}
/**
* 检查 Map 是否不为空,如果为空则抛出异常
*