Browse Source

fixed 解决接口服务循环依赖问题

fushengqian 1 month ago
parent
commit
e24d71e54e

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

@@ -35,6 +35,7 @@ import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.core.env.Environment;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageRequest;
@@ -57,7 +58,7 @@ import java.util.stream.Collectors;
  * CopyRight https://www.fuint.cn
  */
 @Service
-@AllArgsConstructor
+@AllArgsConstructor(onConstructor_= {@Lazy})
 public class GoodsServiceImpl extends ServiceImpl<MtGoodsMapper, MtGoods> implements GoodsService {
 
     private static final Logger logger = LoggerFactory.getLogger(GoodsServiceImpl.class);

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

@@ -21,6 +21,7 @@ import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
@@ -35,7 +36,7 @@ import java.util.*;
  * CopyRight https://www.fuint.cn
  */
 @Service
-@AllArgsConstructor
+@AllArgsConstructor(onConstructor_= {@Lazy})
 public class MemberGroupServiceImpl extends ServiceImpl<MtUserGroupMapper, MtUserGroup> implements MemberGroupService {
 
     private static final Logger logger = LoggerFactory.getLogger(CouponGroupServiceImpl.class);

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

@@ -464,7 +464,7 @@ public class MemberServiceImpl extends ServiceImpl<MtUserMapper, MtUser> impleme
         }
         String mobile = mtUser.getMobile();
         if (PhoneFormatCheckUtils.isChinaPhoneLegal(mobile)) {
-            mtUserMapper.resetMobile(mobile, mtUser.getId());
+            mtUserMapper.resetMobile(mtUser.getMerchantId(), mobile, mtUser.getId());
             mtUser.setMobile(mobile);
         }
 
@@ -904,7 +904,10 @@ public class MemberServiceImpl extends ServiceImpl<MtUserMapper, MtUser> impleme
         if (mobile == null || StringUtil.isEmpty(mobile)) {
             return;
         }
-        mtUserMapper.resetMobile(mobile, userId);
+        MtUser mtUser = mtUserMapper.selectById(userId);
+        if (mtUser != null) {
+            mtUserMapper.resetMobile(mtUser.getMerchantId(), mobile, userId);
+        }
     }
 
     /**

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

@@ -24,6 +24,7 @@ import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
@@ -37,7 +38,7 @@ import java.util.*;
  * CopyRight https://www.fuint.cn
  */
 @Service
-@AllArgsConstructor
+@AllArgsConstructor(onConstructor_= {@Lazy})
 public class MerchantServiceImpl extends ServiceImpl<MtMerchantMapper, MtMerchant> implements MerchantService {
 
     private static final Logger logger = LoggerFactory.getLogger(MerchantServiceImpl.class);

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

@@ -25,6 +25,7 @@ import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
@@ -39,7 +40,7 @@ import java.util.*;
  * CopyRight https://www.fuint.cn
  */
 @Service
-@AllArgsConstructor
+@AllArgsConstructor(onConstructor_= {@Lazy})
 public class OpenGiftServiceImpl extends ServiceImpl<MtOpenGiftMapper, MtOpenGift> implements OpenGiftService {
 
     private static final Logger logger = LoggerFactory.getLogger(OpenGiftServiceImpl.class);

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

@@ -27,6 +27,7 @@ import org.apache.commons.lang.StringUtils;
 import com.github.pagehelper.Page;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
@@ -40,7 +41,7 @@ import java.util.*;
  * CopyRight https://www.fuint.cn
  */
 @Service
-@AllArgsConstructor
+@AllArgsConstructor(onConstructor_= {@Lazy})
 public class PointServiceImpl extends ServiceImpl<MtPointMapper, MtPoint> implements PointService {
 
     private static final Logger logger = LoggerFactory.getLogger(PointServiceImpl.class);

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

@@ -17,6 +17,7 @@ import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.utils.ArrayUtil;
 import com.fuint.utils.StringUtil;
 import lombok.AllArgsConstructor;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import java.util.*;
@@ -29,7 +30,7 @@ import java.util.stream.Collectors;
  * CopyRight https://www.fuint.cn
  */
 @Service
-@AllArgsConstructor
+@AllArgsConstructor(onConstructor_= {@Lazy})
 public class SourceServiceImpl extends ServiceImpl<TSourceMapper, TSource> implements SourceService {
 
     private TSourceMapper tSourceMapper;

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

@@ -28,6 +28,7 @@ import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
@@ -42,7 +43,7 @@ import java.util.*;
  * CopyRight https://www.fuint.cn
  */
 @Service
-@AllArgsConstructor
+@AllArgsConstructor(onConstructor_= {@Lazy})
 public class StoreServiceImpl extends ServiceImpl<MtStoreMapper, MtStore> implements StoreService {
 
     private static final Logger logger = LoggerFactory.getLogger(StoreServiceImpl.class);

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

@@ -29,7 +29,7 @@ public interface MtUserMapper extends BaseMapper<MtUser> {
 
     void updateUserBalance(@Param("merchantId") Integer merchantId, @Param("userIds") List<Integer> userIds, @Param("amount") BigDecimal amount);
 
-    void resetMobile(@Param("mobile") String mobile, @Param("userId") Integer userId);
+    void resetMobile(@Param("merchantId") Integer merchantId, @Param("mobile") String mobile, @Param("userId") Integer userId);
 
     Long getUserCount(@Param("merchantId") Integer merchantId);
 

+ 3 - 0
fuint-repository/src/main/resources/mapper/MtUserMapper.xml

@@ -50,6 +50,9 @@
 
     <update id="resetMobile">
         update mt_user t set t.MOBILE = '' where t.MOBILE = #{mobile} and t.ID != #{userId}
+        <if test="merchantId != null and merchantId > 0">
+            AND t.MERCHANT_ID = #{merchantId}
+        </if>
     </update>
 
     <select id="getUserCount" resultType="java.lang.Long">