远程调用 fix 修复入参问题,导致反射循环依赖。

This commit is contained in:
Jack 2025-12-29 17:28:23 +08:00
parent e919a934dd
commit b7b57d04d0
9 changed files with 138 additions and 4 deletions

View File

@ -11,6 +11,7 @@ import com.suisung.mall.common.utils.I18nUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@ -32,6 +33,7 @@ public class AccountBaseUserLevelController {
@Autowired @Autowired
private AccountBaseUserLevelService accountBaseUserLevelService; private AccountBaseUserLevelService accountBaseUserLevelService;
@Lazy
@Autowired @Autowired
private AccountService accountService; private AccountService accountService;

View File

@ -30,7 +30,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.util.Pair; import org.springframework.data.util.Pair;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -235,9 +234,15 @@ public class AccountUserBaseController extends BaseControllerImpl {
@ApiOperation("注册商家账号,项目之间远程调用") @ApiOperation("注册商家账号,项目之间远程调用")
@RequestMapping(value = "/merchant/inner-register", method = RequestMethod.POST) @RequestMapping(value = "/merchant/inner-register", method = RequestMethod.POST)
public Pair<Boolean, String> merchantInnerRegister(@Param("mobile") String mobile, @Param("regPwd") String regPwd) { public Pair<Boolean, String> merchantInnerRegister(@RequestParam("mobile") String mobile, @RequestParam("regPwd") String regPwd) {
return accountUserBaseService.merchantInnerRegister(mobile, regPwd); return accountUserBaseService.merchantInnerRegister(mobile, regPwd);
} }
@ApiOperation("更改分店商家的手机号(仅限于分店,尽量不要更高总店的手机号),项目之间远程调用")
@RequestMapping(value = "/change/merchant/login-mobile", method = RequestMethod.POST)
public Pair<Boolean, String> changeMerchantLoginMobile(@RequestParam("oldMobile") String oldMobile, @RequestParam("newMobile") String newMobile, @RequestParam("password") String password) {
return accountUserBaseService.changeMerchantLoginMobile(oldMobile, newMobile, password);
}
} }

View File

@ -307,6 +307,16 @@ public interface AccountUserBaseService extends IBaseService<AccountUserBase> {
*/ */
Pair<Boolean, String> merchantInnerRegister(String mobile, String regPwd); Pair<Boolean, String> merchantInnerRegister(String mobile, String regPwd);
/**
* 更改分店商家的手机号(仅限于分店尽量不要更改总店的手机号)项目之间远程调用
*
* @param oldMobile 老的手机号
* @param newMobile 新的手机号
* @param password 新的登录密码可选
* @return Pair<Boolean, String> 操作结果和提示信息true表示成功false表示失败
*/
Pair<Boolean, String> changeMerchantLoginMobile(String oldMobile, String newMobile, String password);
/** /**
* 批量保存accountInfo * 批量保存accountInfo
* *

View File

@ -3338,6 +3338,104 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
} }
} }
/**
* 更改分店商家的手机号(仅限于分店尽量不要更改总店的手机号)项目之间远程调用
*
* @param oldMobile 老的手机号
* @param newMobile 新的手机号
* @param password 新的登录密码可选
* @return Pair<Boolean, String> 操作结果和提示信息true表示成功false表示失败
*/
@Override
public Pair<Boolean, String> changeMerchantLoginMobile(String oldMobile, String newMobile, String password) {
log.debug("开始更改商家登录手机号,老手机号:{},新手机号:{},是否需要设置密码:{}", oldMobile, newMobile, StrUtil.isNotBlank(password));
try {
// 验证输入参数
if (StrUtil.isBlank(oldMobile) || StrUtil.isBlank(newMobile)) {
log.warn("手机号参数为空,老手机号:{},新手机号:{}", oldMobile, newMobile);
return Pair.of(false, "手机号不能为空");
}
// 格式化手机号添加国际区号
String formattedOldMobile = PhoneNumberUtils.convZhPhoneNumber(oldMobile);
String formattedNewMobile = PhoneNumberUtils.convZhPhoneNumber(newMobile);
log.debug("格式化后的手机号:老:{} 新:{}", formattedOldMobile, formattedNewMobile);
// 查询老手机号是否绑定商家账号
AccountUserBindConnect bindConnect = bindConnectService.getBindByBindId(formattedOldMobile, BindCode.MOBILE, CommonConstant.USER_TYPE_MCH);
if (bindConnect == null) {
log.warn("该老手机号未绑定商家账号,手机号:{}", formattedOldMobile);
return Pair.of(false, "该老手机号未绑定商家账号,无法进行更换");
}
// 获取用户信息
Integer userId = bindConnect.getUser_id();
log.debug("绑定记录中的用户ID{}", userId);
AccountUserBase userBase = get(userId);
if (userBase == null) {
log.warn("用户信息不存在用户ID{}", userId);
return Pair.of(false, "用户信息不存在,无法进行更换");
}
// 验证用户确实是商家类型
if (!userBase.getUser_is_admin().equals(CommonConstant.USER_TYPE_MCH)) {
log.warn("该账号不是商家账号用户ID{},用户类型:{}", userId, userBase.getUser_is_admin());
return Pair.of(false, "该账号不是商家账号,无法进行更换");
}
// 检查目标手机号是否已被其他商家账号使用
AccountUserBase existingNewUser = getByAccountAndType(formattedNewMobile, CommonConstant.USER_TYPE_MCH);
if (existingNewUser != null && !existingNewUser.getUser_id().equals(userId)) {
log.warn("目标手机号已被其他商家账号使用,手机号:{}用户ID{}", formattedNewMobile, existingNewUser.getUser_id());
return Pair.of(false, "该手机号已被其他商家账号使用");
}
// 检查新手机号是否已被其他商家绑定
AccountUserBindConnect newBindConnect = bindConnectService.getBindByBindId(formattedNewMobile, BindCode.MOBILE, CommonConstant.USER_TYPE_MCH);
if (newBindConnect != null && !newBindConnect.getUser_id().equals(userId)) {
log.warn("该新手机号已被其他商家账号绑定,手机号:{}用户ID{}", formattedNewMobile, newBindConnect.getUser_id());
return Pair.of(false, "该手机号已被其他商家账号绑定");
}
// 更新用户账号为新手机号
log.debug("开始更新用户账号信息用户ID{},新手机号:{}", userId, formattedNewMobile);
userBase.setUser_account(formattedNewMobile);
// 如果提供了密码则更新密码
if (StrUtil.isNotBlank(password)) {
log.debug("需要更新用户密码");
String user_salt = IdUtil.simpleUUID();
String encryptedPassword = SecureUtil.md5(user_salt + SecureUtil.md5(password));
userBase.setUser_password(encryptedPassword);
userBase.setUser_salt(user_salt);
}
// 更新用户基础信息
boolean updateUserResult = saveOrUpdate(userBase);
if (!updateUserResult) {
log.error("更新用户账号信息失败用户ID{}", userId);
return Pair.of(false, "更新用户账号信息失败");
}
// 更新绑定表中的bind_id为新手机号
log.debug("开始更新绑定信息原绑定ID{}新绑定ID{}", bindConnect.getBind_id(), formattedNewMobile);
bindConnect.setBind_id(formattedNewMobile);
boolean updateBindResult = accountUserBindConnectService.saveOrUpdate(bindConnect);
if (!updateBindResult) {
log.error("更新绑定信息失败绑定ID{}", formattedNewMobile);
return Pair.of(false, "更新绑定信息失败");
}
log.info("更换商家登录手机号成功用户ID{},新手机号:{}", userId, formattedNewMobile);
return Pair.of(true, "更换商家登录手机号成功");
} catch (Exception e) {
log.error("更改商家登录手机号过程中发生异常,老手机号:{},新手机号:{}", oldMobile, newMobile, e);
return Pair.of(false, "系统异常:" + e.getMessage());
}
}
@Override @Override
public Map<String, Object> doAppConnectLogin(String bind_name, String code) { public Map<String, Object> doAppConnectLogin(String bind_name, String code) {

View File

@ -6,7 +6,6 @@ import com.suisung.mall.common.modules.push.PushTemplate;
import com.suisung.mall.common.pojo.output.TimelineOutput; import com.suisung.mall.common.pojo.output.TimelineOutput;
import com.suisung.mall.common.pojo.res.ThirdApiRes; import com.suisung.mall.common.pojo.res.ThirdApiRes;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.data.util.Pair; import org.springframework.data.util.Pair;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -329,6 +328,13 @@ public interface AccountService {
* 服务间注册商家账号项目之间远程调用 * 服务间注册商家账号项目之间远程调用
*/ */
@RequestMapping(value = "/admin/account/account-user-base/merchant/inner-register", method = RequestMethod.POST) @RequestMapping(value = "/admin/account/account-user-base/merchant/inner-register", method = RequestMethod.POST)
Pair<Boolean, String> merchantInnerRegister(@Param("mobile") String mobile, @Param("regPwd") String regPwd); Pair<Boolean, String> merchantInnerRegister(@RequestParam("mobile") String mobile, @RequestParam("regPwd") String regPwd);
/**
* 服务间注册商家账号项目之间远程调用
*/
@RequestMapping(value = "/admin/account/account-user-base/merchant/inner-register", method = RequestMethod.POST)
Pair<Boolean, String> changeMerchantLoginMobile(@RequestParam("oldMobile") String oldMobile, @RequestParam("newMobile") String newMobile, @RequestParam("password") String password);
} }

View File

@ -57,9 +57,11 @@ import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
@Service @Service
public class ShopActivityGroupbookingServiceImpl extends BaseServiceImpl<ShopActivityGroupbookingMapper, ShopActivityGroupbooking> implements ShopActivityGroupbookingService { public class ShopActivityGroupbookingServiceImpl extends BaseServiceImpl<ShopActivityGroupbookingMapper, ShopActivityGroupbooking> implements ShopActivityGroupbookingService {
@Lazy
@Autowired @Autowired
private ShopActivityGroupbookingHistoryService shopActivityGroupbookingHistoryService; private ShopActivityGroupbookingHistoryService shopActivityGroupbookingHistoryService;
@Lazy
@Autowired @Autowired
private ShopActivityGroupbookingService shopActivityGroupbookingService; private ShopActivityGroupbookingService shopActivityGroupbookingService;
@ -67,9 +69,11 @@ public class ShopActivityGroupbookingServiceImpl extends BaseServiceImpl<ShopAct
@Autowired @Autowired
private ShopStoreActivityBaseService shopStoreActivityBaseService; private ShopStoreActivityBaseService shopStoreActivityBaseService;
@Lazy
@Autowired @Autowired
private AccountService accountService; private AccountService accountService;
@Lazy
@Autowired @Autowired
private ShopOrderInfoService shopOrderInfoService; private ShopOrderInfoService shopOrderInfoService;
@ -77,6 +81,7 @@ public class ShopActivityGroupbookingServiceImpl extends BaseServiceImpl<ShopAct
@Autowired @Autowired
private ShopUserVoucherService shopUserVoucherService; private ShopUserVoucherService shopUserVoucherService;
@Lazy
@Autowired @Autowired
private ShopOrderReturnService shopOrderReturnService; private ShopOrderReturnService shopOrderReturnService;
@ -84,6 +89,7 @@ public class ShopActivityGroupbookingServiceImpl extends BaseServiceImpl<ShopAct
@Autowired @Autowired
private ShopOrderBaseService shopOrderBaseService; private ShopOrderBaseService shopOrderBaseService;
@Lazy
@Autowired @Autowired
private ShopOrderDataService shopOrderDataService; private ShopOrderDataService shopOrderDataService;
@ -91,9 +97,11 @@ public class ShopActivityGroupbookingServiceImpl extends BaseServiceImpl<ShopAct
@Autowired @Autowired
private ShopStoreBaseService shopStoreBaseService; private ShopStoreBaseService shopStoreBaseService;
@Lazy
@Autowired @Autowired
private ShopOrderItemService shopOrderItemService; private ShopOrderItemService shopOrderItemService;
@Lazy
@Autowired @Autowired
private ShopProductItemService shopProductItemService; private ShopProductItemService shopProductItemService;

View File

@ -54,6 +54,8 @@ public class AccountBaseConfigServiceImpl extends BaseServiceImpl<AccountBaseCon
public static Map<String, AccountBaseConfig> configMap; public static Map<String, AccountBaseConfig> configMap;
public static Long version = 0L; public static Long version = 0L;
@Lazy
@Autowired @Autowired
private AccountService accountService; private AccountService accountService;

View File

@ -99,8 +99,10 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
private ShopStoreInfoService shopStoreInfoService; private ShopStoreInfoService shopStoreInfoService;
@Autowired @Autowired
private ShopDistributionUserCommissionService shopDistributionUserCommissionService; private ShopDistributionUserCommissionService shopDistributionUserCommissionService;
@Lazy
@Autowired @Autowired
private AccountBaseConfigService accountBaseConfigService; private AccountBaseConfigService accountBaseConfigService;
@Lazy
@Autowired @Autowired
private AccountService accountService; private AccountService accountService;
@Autowired @Autowired

View File

@ -50,6 +50,7 @@ import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
@Service @Service
public class ShopStoreEmployeeServiceImpl extends BaseServiceImpl<ShopStoreEmployeeMapper, ShopStoreEmployee> implements ShopStoreEmployeeService { public class ShopStoreEmployeeServiceImpl extends BaseServiceImpl<ShopStoreEmployeeMapper, ShopStoreEmployee> implements ShopStoreEmployeeService {
@Lazy
@Autowired @Autowired
private AccountService accountService; private AccountService accountService;