Pārlūkot izejas kodu

fixed 默认店铺

fushengqian 1 gadu atpakaļ
vecāks
revīzija
4ec1dca065

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

@@ -29,9 +29,10 @@ public interface DutyService extends IService<TDuty> {
      * 获取有效的角色集合
      *
      * @param merchantId 商户ID
+     * @param accountId  账号ID
      * @return
      */
-    List<TDuty> getAvailableRoles(Integer merchantId);
+    List<TDuty> getAvailableRoles(Integer merchantId, Integer accountId);
 
     /**
      * 根据ID获取角色实体

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

@@ -46,8 +46,23 @@ public class DutyServiceImpl extends ServiceImpl<TDutyMapper, TDuty> implements
     private TDutySourceMapper tDutySourceMapper;
 
     @Override
-    public List<TDuty> getAvailableRoles(Integer merchantId) {
+    public List<TDuty> getAvailableRoles(Integer merchantId, Integer accountId) {
         List<TDuty> result = tDutyMapper.findByStatus(merchantId, StatusEnum.ENABLED.getKey());
+        List<Long> ids = new ArrayList<>();
+        if (result != null && result.size() > 0) {
+            for (TDuty tDuty : result) {
+                 ids.add(tDuty.getDutyId().longValue());
+            }
+        }
+        List<Long> roleIds = findDutiesByAccountId(accountId);
+        if (roleIds.size() > 0) {
+            for (Long roleId : roleIds) {
+                 if (!ids.contains(roleId)) {
+                     TDuty duty = getRoleById(roleId);
+                     result.add(duty);
+                 }
+            }
+        }
         return result;
     }
 
@@ -246,7 +261,7 @@ public class DutyServiceImpl extends ServiceImpl<TDutyMapper, TDuty> implements
      */
     @Override
     public List<TreeNode> getDutyTree(Integer merchantId) {
-        List<TDuty> tDuties = getAvailableRoles(merchantId);
+        List<TDuty> tDuties = getAvailableRoles(merchantId, 0);
         List<TreeNode> trees = new ArrayList<TreeNode>();
         if (tDuties != null && tDuties.size() > 0) {
             TreeNode sourceTreeNode;

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

@@ -162,7 +162,7 @@ public class StoreServiceImpl extends ServiceImpl<MtStoreMapper, MtStore> implem
 
         if (storeDto.getIsDefault() != null) {
             if (storeDto.getIsDefault().equals(YesOrNoEnum.YES.getKey())) {
-                mtStoreMapper.resetDefaultStore();
+                mtStoreMapper.resetDefaultStore(storeDto.getMerchantId());
             }
         }
 
@@ -250,7 +250,7 @@ public class StoreServiceImpl extends ServiceImpl<MtStoreMapper, MtStore> implem
     /**
      * 根据店铺名称获取店铺信息
      *
-     * @param storeName 店铺名称
+     * @param  storeName 店铺名称
      * @throws BusinessCheckException
      */
     @Override

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

@@ -135,7 +135,7 @@ public class BackendAccountController extends BaseController {
         }
         Map<String, Object> result = new HashMap<>();
 
-        List<TDuty> roleList = tDutyService.getAvailableRoles(accountInfo.getMerchantId());
+        List<TDuty> roleList = tDutyService.getAvailableRoles(accountInfo.getMerchantId(), accountInfo.getId());
         List<RoleDto> roles = new ArrayList<>();
         if (roleList.size() > 0) {
             for (TDuty duty : roleList) {

+ 1 - 1
fuint-repository/src/main/java/com/fuint/repository/mapper/MtStoreMapper.java

@@ -17,7 +17,7 @@ public interface MtStoreMapper extends BaseMapper<MtStore> {
 
     MtStore queryStoreByName(@Param("name") String name);
 
-    void resetDefaultStore();
+    void resetDefaultStore(@Param("merchantId") Integer merchantId);
 
     List<MtStore> findStoresByIds(@Param("ids") List<Integer> ids);
 

+ 4 - 1
fuint-repository/src/main/resources/mapper/MtStoreMapper.xml

@@ -6,7 +6,10 @@
     </select>
 
     <update id="resetDefaultStore">
-        update mt_store p set p.IS_DEFAULT = 'N'
+        update mt_store p set p.IS_DEFAULT = 'N' where p.STATUS != 'D'
+        <if test="merchantId != null and merchantId != ''">
+            AND p.MERCHANT_ID = #{merchantId}
+        </if>
     </update>
 
     <select id="findStoresByIds" resultType="com.fuint.repository.model.MtStore">