Browse Source

用户绑定更新接口

wangzhijun 1 week ago
parent
commit
f57459dfae

+ 6 - 0
nightFragrance-admin/src/main/java/com/ylx/web/controller/usercenter/UnifiedUserCenterController.java

@@ -41,4 +41,10 @@ public class UnifiedUserCenterController extends BaseController {
         return this.unifiedUserCenterService.unbind(dto);
     }
 
+    @ApiOperation("用户绑定更新")
+    @PostMapping("/userApp/bind/update")
+    public R<?> bindUpdate(@RequestBody UnifiedUserCenterDTO dto) {
+        return this.unifiedUserCenterService.bindUpdate(dto);
+    }
+
 }

+ 2 - 1
nightFragrance-framework/src/main/java/com/ylx/framework/config/SecurityConfig.java

@@ -113,7 +113,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
                         "/api/xiangmu/v1/getByid", "/api/xiangmu/v1/highlights", "/api/js/v1/wx/getByid", "/api/js/v1/wx/select", "/api/js/v1/wx/add", "/api/recharge/v1/test",
                         "/wx/pay/payNotify", "/wx/pay/refundNotify", "/weChat/getAccessToken","/weChat/phoneLogin","/weChat/sendMsg", "/weChat/getCode", "/weChat/verifyToken", "/sq/getAccessToken",
                         "/area/select", "/system/dept/list", "/api/xiangmu/v1/wx/recommend", "/product/category/create","/area/code","/area/city","/product/category/list",
-                        "/wx/pay/query/order/{outTradeNo}","/api/products/**","/api/user/point/**","/userCenter/userApp/queryBind","/weChat/uuidLogin","/couponReceive/getShareVolutionDetail").permitAll()
+                        "/wx/pay/query/order/{outTradeNo}","/api/products/**","/api/user/point/**","/userCenter/userApp/queryBind","/weChat/uuidLogin","/couponReceive/getShareVolutionDetail",
+                        "/userCenter/userApp/bind/update").permitAll()
                 // 静态资源,可匿名访问
                 .antMatchers(HttpMethod.GET, "/", "/*.txt", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
                 .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()

+ 2 - 0
nightFragrance-massage/src/main/java/com/ylx/usercenter/service/UnifiedUserCenterService.java

@@ -14,4 +14,6 @@ public interface UnifiedUserCenterService {
     OneAccountVO queryClients(String uuid);
 
     void syncLotteryCount(UnifiedUserCenterDTO dto);
+
+    R<?> bindUpdate(UnifiedUserCenterDTO dto);
 }

+ 29 - 0
nightFragrance-massage/src/main/java/com/ylx/usercenter/service/impl/UnifiedUserCenterServiceImpl.java

@@ -236,6 +236,35 @@ public class UnifiedUserCenterServiceImpl implements UnifiedUserCenterService {
         }
     }
 
+    @Override
+    public R<?> bindUpdate(UnifiedUserCenterDTO dto) {
+        try {
+
+            // 1.获取用户信息
+            TWxUser wxUser = this.wxUserService.getById(dto.getTargetUserId());
+            if (ObjUtil.isEmpty(wxUser)) {
+                log.error("用户信息不存在, userId: {}", dto.getTargetUserId());
+                throw new ServiceException("用户信息不存在");
+            }
+
+            // 2. 更新本地数据库(独立事务)
+            updateUserBindStatus(dto,wxUser);
+
+            // 3. 同步抽奖次数(异步处理)
+            syncLotteryCount(dto);
+
+            log.info("同步用户抽奖次数到本地生活服务成功, userId:{}", dto.getTargetUserId());
+
+            return R.ok();
+        } catch (ServiceException e) {
+            log.error("同步用户抽奖次数到本地生活服务异常, userId:{}", dto.getTargetUserId(), e);
+            throw e;
+        } catch (Exception e) {
+            log.error("同步用户抽奖次数到本地生活服务异常, userId:{}", dto.getTargetUserId(), e);
+            throw new ServiceException("系统异常,请稍后重试");
+        }
+    }
+
     /**
      * 异步补偿:解除用户绑定
      * 带重试机制,最多重试3次