Browse Source

fixed 商户权限隔离

fushengqian 1 year ago
parent
commit
e05e9358a3

+ 2 - 2
fuint-application/src/main/java/com/fuint/common/service/AccountService.java

@@ -29,7 +29,7 @@ public interface AccountService extends IService<TAccount> {
     /**
      * 根据用户名获取用户对象
      *
-     * @param userName
+     * @param userName 用户名
      * @return
      */
     AccountInfo getAccountByName(String userName);
@@ -49,7 +49,7 @@ public interface AccountService extends IService<TAccount> {
      * @param  duties
      * @return
      * */
-    TAccount createAccountInfo(TAccount accountInfo, List<TDuty> duties);
+    TAccount createAccountInfo(TAccount accountInfo, List<TDuty> duties) throws BusinessCheckException;
 
     /**
      * 获取账号角色ID

+ 9 - 5
fuint-application/src/main/java/com/fuint/common/service/BannerService.java

@@ -10,7 +10,7 @@ import java.util.List;
 import java.util.Map;
 
 /**
- * banner业务接口
+ * 焦点图业务接口
  *
  * Created by FSQ
  * CopyRight https://www.fuint.cn
@@ -30,6 +30,7 @@ public interface BannerService extends IService<MtBanner> {
      *
      * @param reqBannerDto
      * @throws BusinessCheckException
+     * @return
      */
     MtBanner addBanner(BannerDto reqBannerDto) throws BusinessCheckException;
 
@@ -38,31 +39,34 @@ public interface BannerService extends IService<MtBanner> {
      *
      * @param id Banner ID
      * @throws BusinessCheckException
+     * @return
      */
     MtBanner queryBannerById(Integer id) throws BusinessCheckException;
 
     /**
-     * 根据ID删除
+     * 根据ID删除焦点图
      *
      * @param id ID
      * @param operator 操作人
      * @throws BusinessCheckException
+     * @return
      */
     void deleteBanner(Integer id, String operator) throws BusinessCheckException;
 
     /**
-     * 更新Banner
+     * 更新焦点图
      * @param bannerDto
      * @throws BusinessCheckException
+     * @return
      * */
     MtBanner updateBanner(BannerDto bannerDto) throws BusinessCheckException;
 
     /**
-     * 根据条件搜索Banner
+     * 根据条件搜索焦点图
      *
      * @param params 查询参数
+     * @throws BusinessCheckException
      * @return
      * */
     List<MtBanner> queryBannerListByParams(Map<String, Object> params) throws BusinessCheckException;
-
 }

+ 4 - 3
fuint-application/src/main/java/com/fuint/common/service/CateService.java

@@ -28,8 +28,9 @@ public interface CateService extends IService<MtGoodsCate> {
     /**
      * 添加商品分类
      *
-     * @param  reqDto
+     * @param  reqDto 分类参数
      * @throws BusinessCheckException
+     * @return
      */
     MtGoodsCate addCate(MtGoodsCate reqDto) throws BusinessCheckException;
 
@@ -44,7 +45,7 @@ public interface CateService extends IService<MtGoodsCate> {
     /**
      * 根据ID删除
      *
-     * @param  id       ID
+     * @param  id 分类ID
      * @param  operator 操作人
      * @throws BusinessCheckException
      * @return
@@ -53,7 +54,7 @@ public interface CateService extends IService<MtGoodsCate> {
 
     /**
      * 更新分类
-     * @param  reqDto
+     * @param  reqDto 分类参数
      * @throws BusinessCheckException
      * @return
      * */

+ 15 - 2
fuint-application/src/main/java/com/fuint/common/service/impl/AccountServiceImpl.java

@@ -7,6 +7,7 @@ import com.fuint.common.dto.AccountDto;
 import com.fuint.common.dto.AccountInfo;
 import com.fuint.common.service.AccountService;
 import com.fuint.common.service.StaffService;
+import com.fuint.common.service.StoreService;
 import com.fuint.framework.annoation.OperationServiceLog;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.exception.BusinessRuntimeException;
@@ -52,6 +53,11 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
      */
     private StaffService staffService;
 
+    /**
+     * 店铺服务接口
+     * */
+    private StoreService storeService;
+
     /**
      * 分页查询账号列表
      *
@@ -156,14 +162,14 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
     }
 
     /**
-     * 创建账号信息
+     * 新增后台账户
      *
      * @param tAccount
      * @return
      * */
     @Override
     @OperationServiceLog(description = "新增后台账户")
-    public TAccount createAccountInfo(TAccount tAccount, List<TDuty> duties) {
+    public TAccount createAccountInfo(TAccount tAccount, List<TDuty> duties) throws BusinessCheckException {
         TAccount account = new TAccount();
         account.setAccountKey(tAccount.getAccountKey());
         account.setAccountName(tAccount.getAccountName().toLowerCase());
@@ -171,6 +177,13 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
         account.setRealName(tAccount.getRealName());
         account.setRoleIds(tAccount.getRoleIds());
         account.setStaffId(tAccount.getStaffId());
+        Integer storeId = tAccount.getStoreId() == null ? 0 : tAccount.getStoreId();
+        if (tAccount.getMerchantId() == null || tAccount.getMerchantId() <= 0) {
+            MtStore mtStore = storeService.queryStoreById(storeId);
+            if (mtStore != null) {
+                tAccount.setMerchantId(mtStore.getMerchantId());
+            }
+        }
         account.setMerchantId(tAccount.getMerchantId());
         account.setStoreId(tAccount.getStoreId());
         account.setCreateDate(new Date());

+ 17 - 3
fuint-application/src/main/java/com/fuint/common/service/impl/ArticleServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fuint.common.dto.ArticleDto;
 import com.fuint.common.service.ArticleService;
 import com.fuint.common.service.MerchantService;
+import com.fuint.common.service.StoreService;
 import com.fuint.framework.annoation.OperationServiceLog;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.pagination.PaginationRequest;
@@ -14,6 +15,7 @@ import com.fuint.repository.mapper.MtArticleMapper;
 import com.fuint.repository.model.MtArticle;
 import com.fuint.common.service.SettingService;
 import com.fuint.common.enums.StatusEnum;
+import com.fuint.repository.model.MtStore;
 import com.github.pagehelper.PageHelper;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
@@ -47,6 +49,11 @@ public class ArticleServiceImpl extends ServiceImpl<MtArticleMapper, MtArticle>
      * */
     private MerchantService merchantService;
 
+    /**
+     * 店铺接口
+     */
+    private StoreService storeService;
+
     /**
      * 分页查询文章列表
      *
@@ -108,18 +115,25 @@ public class ArticleServiceImpl extends ServiceImpl<MtArticleMapper, MtArticle>
     /**
      * 添加文章
      *
-     * @param articleDto
+     * @param articleDto 文章参数
      * @return
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
     @OperationServiceLog(description = "新增文章")
-    public MtArticle addArticle(ArticleDto articleDto) {
+    public MtArticle addArticle(ArticleDto articleDto) throws BusinessCheckException {
         MtArticle mtArticle = new MtArticle();
         mtArticle.setTitle(articleDto.getTitle());
         mtArticle.setBrief(articleDto.getBrief());
+        Integer storeId = articleDto.getStoreId() == null ? 0 : articleDto.getStoreId();
+        if (articleDto.getMerchantId() == null || articleDto.getMerchantId() <= 0) {
+            MtStore mtStore = storeService.queryStoreById(storeId);
+            if (mtStore != null) {
+                articleDto.setMerchantId(mtStore.getMerchantId());
+            }
+        }
         mtArticle.setMerchantId(articleDto.getMerchantId());
-        mtArticle.setStoreId(articleDto.getStoreId() == null ? 0 : articleDto.getStoreId());
+        mtArticle.setStoreId(storeId);
         mtArticle.setUrl(articleDto.getUrl());
         mtArticle.setClick(0l);
         mtArticle.setStatus(StatusEnum.ENABLED.getKey());

+ 21 - 6
fuint-application/src/main/java/com/fuint/common/service/impl/BannerServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
+import com.fuint.common.service.StoreService;
 import com.fuint.framework.annoation.OperationServiceLog;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.pagination.PaginationRequest;
@@ -15,6 +16,7 @@ import com.fuint.common.service.SettingService;
 import com.fuint.common.enums.StatusEnum;
 import com.fuint.repository.mapper.MtBannerMapper;
 
+import com.fuint.repository.model.MtStore;
 import com.github.pagehelper.PageHelper;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
@@ -48,7 +50,12 @@ public class BannerServiceImpl extends ServiceImpl<MtBannerMapper, MtBanner> imp
     private SettingService settingService;
 
     /**
-     * 分页查询Banner列表
+     * 店铺接口
+     */
+    private StoreService storeService;
+
+    /**
+     * 分页查询焦点图列表
      *
      * @param paginationRequest
      * @return
@@ -92,14 +99,22 @@ public class BannerServiceImpl extends ServiceImpl<MtBannerMapper, MtBanner> imp
     /**
      * 添加焦点图
      *
-     * @param bannerDto
+     * @param bannerDto 焦点图信息
+     * @return
      */
     @Override
     @OperationServiceLog(description = "新增焦点图")
-    public MtBanner addBanner(BannerDto bannerDto) {
+    public MtBanner addBanner(BannerDto bannerDto) throws BusinessCheckException {
         MtBanner mtBanner = new MtBanner();
         BeanUtils.copyProperties(bannerDto, mtBanner);
-        mtBanner.setStoreId(bannerDto.getStoreId() == null ? 0 : bannerDto.getStoreId());
+        Integer storeId = bannerDto.getStoreId() == null ? 0 : bannerDto.getStoreId();
+        if (bannerDto.getMerchantId() == null || bannerDto.getMerchantId() <= 0) {
+            MtStore mtStore = storeService.queryStoreById(storeId);
+            if (mtStore != null) {
+                mtBanner.setMerchantId(mtStore.getMerchantId());
+            }
+        }
+        mtBanner.setStoreId(storeId);
         mtBanner.setStatus(StatusEnum.ENABLED.getKey());
         mtBanner.setUpdateTime(new Date());
         mtBanner.setCreateTime(new Date());
@@ -108,7 +123,7 @@ public class BannerServiceImpl extends ServiceImpl<MtBannerMapper, MtBanner> imp
             return mtBanner;
         } else {
             logger.error("新增焦点图失败.");
-            return null;
+            throw new BusinessCheckException("新增焦点图失败");
         }
     }
 
@@ -149,7 +164,7 @@ public class BannerServiceImpl extends ServiceImpl<MtBannerMapper, MtBanner> imp
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    @OperationServiceLog(description = "更新Banner图")
+    @OperationServiceLog(description = "更新焦点图")
     public MtBanner updateBanner(BannerDto bannerDto) throws BusinessCheckException {
         MtBanner mtBanner = queryBannerById(bannerDto.getId());
         if (mtBanner == null) {

+ 2 - 2
fuint-application/src/main/java/com/fuint/common/service/impl/CartServiceImpl.java

@@ -197,7 +197,7 @@ public class CartServiceImpl extends ServiceImpl<MtCartMapper, MtCart> implement
     /**
      * 删除购物车
      *
-     * @param  cartIds
+     * @param  cartIds 购物车ID
      * @throws BusinessCheckException
      * @return
      */
@@ -235,7 +235,7 @@ public class CartServiceImpl extends ServiceImpl<MtCartMapper, MtCart> implement
     /**
      * 清空会员购物车
      *
-     * @param userId
+     * @param userId 会员ID
      * @throws BusinessCheckException
      * @return
      */

+ 12 - 4
fuint-application/src/main/java/com/fuint/common/service/impl/CateServiceImpl.java

@@ -109,23 +109,31 @@ public class CateServiceImpl extends ServiceImpl<MtGoodsCateMapper, MtGoodsCate>
     /**
      * 添加商品分类
      *
-     * @param reqDto
+     * @param reqDto 商品分类参数
      * @throws BusinessCheckException
+     * @return
      */
     @Override
     @OperationServiceLog(description = "新增商品分类")
-    public MtGoodsCate addCate(MtGoodsCate reqDto) {
+    public MtGoodsCate addCate(MtGoodsCate reqDto) throws BusinessCheckException {
         MtGoodsCate mtCate = new MtGoodsCate();
         if (null != reqDto.getId()) {
             mtCate.setId(reqDto.getId());
         }
+        Integer storeId = reqDto.getStoreId() == null ? 0 : reqDto.getStoreId();
+        if (storeId > 0 && (reqDto.getMerchantId() == null || reqDto.getMerchantId() <= 0)) {
+            MtStore mtStore = storeService.queryStoreById(storeId);
+            if (mtStore != null) {
+                reqDto.setMerchantId(mtStore.getMerchantId());
+            }
+        }
         mtCate.setName(reqDto.getName());
         mtCate.setStatus(StatusEnum.ENABLED.getKey());
         mtCate.setLogo(reqDto.getLogo());
         mtCate.setDescription(reqDto.getDescription());
         mtCate.setOperator(reqDto.getOperator());
         mtCate.setMerchantId(reqDto.getMerchantId());
-        mtCate.setStoreId(reqDto.getStoreId() == null ? 0 : reqDto.getStoreId());
+        mtCate.setStoreId(storeId);
         mtCate.setUpdateTime(new Date());
         mtCate.setCreateTime(new Date());
         this.save(mtCate);
@@ -146,7 +154,7 @@ public class CateServiceImpl extends ServiceImpl<MtGoodsCateMapper, MtGoodsCate>
     /**
      * 根据ID删除分类信息
      *
-     * @param id       ID
+     * @param id ID
      * @param operator 操作人
      * @throws BusinessCheckException
      */

+ 10 - 2
fuint-application/src/main/java/com/fuint/common/service/impl/GoodsServiceImpl.java

@@ -169,13 +169,14 @@ public class GoodsServiceImpl extends ServiceImpl<MtGoodsMapper, MtGoods> implem
     /**
      * 保存商品信息
      *
-     * @param  reqDto
+     * @param  reqDto 商品参数
      * @throws BusinessCheckException
+     * @return
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
     @OperationServiceLog(description = "保存商品信息")
-    public MtGoods saveGoods(MtGoods reqDto) {
+    public MtGoods saveGoods(MtGoods reqDto) throws BusinessCheckException {
         MtGoods mtGoods = new MtGoods();
         if (reqDto.getId() > 0) {
             mtGoods = queryGoodsById(reqDto.getId());
@@ -187,6 +188,13 @@ public class GoodsServiceImpl extends ServiceImpl<MtGoodsMapper, MtGoods> implem
         if (reqDto.getStoreId() != null) {
             mtGoods.setStoreId(reqDto.getStoreId() >= 0 ? reqDto.getStoreId() : 0);
         }
+        Integer storeId = reqDto.getStoreId() == null ? 0 : reqDto.getStoreId();
+        if (reqDto.getMerchantId() == null || reqDto.getMerchantId() <= 0) {
+            MtStore mtStore = storeService.queryStoreById(storeId);
+            if (mtStore != null) {
+                mtGoods.setMerchantId(mtStore.getMerchantId());
+            }
+        }
         if (StringUtil.isNotEmpty(reqDto.getIsSingleSpec())) {
             mtGoods.setIsSingleSpec(reqDto.getIsSingleSpec());
         }

+ 23 - 7
fuint-application/src/main/java/com/fuint/common/service/impl/MemberGroupServiceImpl.java

@@ -42,6 +42,11 @@ public class MemberGroupServiceImpl extends ServiceImpl<MtUserGroupMapper, MtUse
 
     private MtUserGroupMapper mtUserGroupMapper;
 
+    /**
+     * 店铺接口
+     */
+    private StoreService storeService;
+
     /**
      * 分页查询会员分组列表
      *
@@ -101,15 +106,23 @@ public class MemberGroupServiceImpl extends ServiceImpl<MtUserGroupMapper, MtUse
     /**
      * 添加会员分组
      *
-     * @param  memberGroupDto
+     * @param  memberGroupDto 会员分组
      * @throws BusinessCheckException
+     * @return
      */
     @Override
     @OperationServiceLog(description = "新增会员分组")
-    public MtUserGroup addMemberGroup(MemberGroupDto memberGroupDto) {
+    public MtUserGroup addMemberGroup(MemberGroupDto memberGroupDto) throws BusinessCheckException {
         MtUserGroup userGroup = new MtUserGroup();
+        Integer storeId = memberGroupDto.getStoreId() == null ? 0 : memberGroupDto.getStoreId();
+        if (memberGroupDto.getMerchantId() == null || memberGroupDto.getMerchantId() <= 0) {
+            MtStore mtStore = storeService.queryStoreById(storeId);
+            if (mtStore != null) {
+                memberGroupDto.setMerchantId(mtStore.getMerchantId());
+            }
+        }
         userGroup.setMerchantId(memberGroupDto.getMerchantId());
-        userGroup.setStoreId(memberGroupDto.getStoreId());
+        userGroup.setStoreId(storeId);
         userGroup.setParentId(memberGroupDto.getParentId());
         userGroup.setName(CommonUtil.replaceXSS(memberGroupDto.getName()));
         userGroup.setDescription(CommonUtil.replaceXSS(memberGroupDto.getDescription()));
@@ -126,6 +139,7 @@ public class MemberGroupServiceImpl extends ServiceImpl<MtUserGroupMapper, MtUse
      *
      * @param  id 分组ID
      * @throws BusinessCheckException
+     * @return
      */
     @Override
     public MtUserGroup queryMemberGroupById(Integer id) {
@@ -138,6 +152,7 @@ public class MemberGroupServiceImpl extends ServiceImpl<MtUserGroupMapper, MtUse
      * @param  id       分组ID
      * @param  operator 操作人
      * @throws BusinessCheckException
+     * @return
      */
     @Override
     @OperationServiceLog(description = "删除会员分组")
@@ -155,10 +170,11 @@ public class MemberGroupServiceImpl extends ServiceImpl<MtUserGroupMapper, MtUse
     }
 
     /**
-     * 修改卡券分组
+     * 修改会员分组
      *
      * @param  memberGroupDto
      * @throws BusinessCheckException
+     * @return
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -188,7 +204,7 @@ public class MemberGroupServiceImpl extends ServiceImpl<MtUserGroupMapper, MtUse
     /**
      * 获取会员分组子类
      *
-     * @param groupId
+     * @param groupId 分组ID
      * @return
      * */
     public List<UserGroupDto> getChildren(Integer groupId) {
@@ -212,7 +228,7 @@ public class MemberGroupServiceImpl extends ServiceImpl<MtUserGroupMapper, MtUse
     /**
      * 获取分组会员数量
      *
-     * @param groupId
+     * @param groupId 分组ID
      * @return
      * */
     public Long getMemberNum(Integer groupId) {
@@ -224,7 +240,7 @@ public class MemberGroupServiceImpl extends ServiceImpl<MtUserGroupMapper, MtUse
     /**
      * 获取会员分组子类ID
      *
-     * @param groupId
+     * @param groupId 分组ID
      * @return
      * */
     public List<Integer> getGroupIds(Integer groupId) {

+ 6 - 4
fuint-application/src/main/java/com/fuint/common/service/impl/UserGradeServiceImpl.java

@@ -89,7 +89,8 @@ public class UserGradeServiceImpl extends ServiceImpl<MtUserGradeMapper, MtUserG
     /**
      * 添加会员等级信息
      *
-     * @param mtUserGrade
+     * @param mtUserGrade 会员等级
+     * @return
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -108,7 +109,7 @@ public class UserGradeServiceImpl extends ServiceImpl<MtUserGradeMapper, MtUserG
     /**
      * 根据ID获取会员等级信息
      *
-     * @param merchantId
+     * @param merchantId 商户ID
      * @param gradeId 会员等级ID
      * @param userId 会员ID
      * @return
@@ -202,8 +203,9 @@ public class UserGradeServiceImpl extends ServiceImpl<MtUserGradeMapper, MtUserG
     /**
      * 获取付费会员等级列表
      *
-     * @param merchantId
-     * @param userInfo
+     * @param merchantId 商户ID
+     * @param userInfo 会员信息
+     * @return
      * */
     @Override
     public List<MtUserGrade> getPayUserGradeList(Integer merchantId, MtUser userInfo) {

+ 1 - 1
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendAccountController.java

@@ -205,7 +205,7 @@ public class BackendAccountController extends BaseController {
     @RequestMapping(value = "/doCreate", method = RequestMethod.POST)
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('system:account:add')")
-    public ResponseObject doCreate(HttpServletRequest request, @RequestBody Map<String, Object> param) {
+    public ResponseObject doCreate(HttpServletRequest request, @RequestBody Map<String, Object> param) throws BusinessCheckException {
         String token = request.getHeader("Access-Token");
         AccountInfo loginAccount = TokenUtil.getAccountInfoByToken(token);
         if (loginAccount == null) {