diff --git a/mall-account/src/main/java/com/suisung/mall/account/controller/admin/AccountBaseUserLevelController.java b/mall-account/src/main/java/com/suisung/mall/account/controller/admin/AccountBaseUserLevelController.java index bae3ff66..61d10fb0 100644 --- a/mall-account/src/main/java/com/suisung/mall/account/controller/admin/AccountBaseUserLevelController.java +++ b/mall-account/src/main/java/com/suisung/mall/account/controller/admin/AccountBaseUserLevelController.java @@ -11,6 +11,7 @@ import com.suisung.mall.common.utils.I18nUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; 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.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; @@ -32,6 +33,7 @@ public class AccountBaseUserLevelController { @Autowired private AccountBaseUserLevelService accountBaseUserLevelService; + @Lazy @Autowired private AccountService accountService; diff --git a/mall-account/src/main/java/com/suisung/mall/account/controller/admin/AccountUserBaseController.java b/mall-account/src/main/java/com/suisung/mall/account/controller/admin/AccountUserBaseController.java index 4e11df41..d4d63932 100644 --- a/mall-account/src/main/java/com/suisung/mall/account/controller/admin/AccountUserBaseController.java +++ b/mall-account/src/main/java/com/suisung/mall/account/controller/admin/AccountUserBaseController.java @@ -30,7 +30,6 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.util.Pair; import org.springframework.web.bind.annotation.RequestMapping; @@ -235,9 +234,15 @@ public class AccountUserBaseController extends BaseControllerImpl { @ApiOperation("注册商家账号,项目之间远程调用") @RequestMapping(value = "/merchant/inner-register", method = RequestMethod.POST) - public Pair merchantInnerRegister(@Param("mobile") String mobile, @Param("regPwd") String regPwd) { + public Pair merchantInnerRegister(@RequestParam("mobile") String mobile, @RequestParam("regPwd") String regPwd) { return accountUserBaseService.merchantInnerRegister(mobile, regPwd); } + @ApiOperation("更改分店商家的手机号(仅限于分店,尽量不要更高总店的手机号),项目之间远程调用") + @RequestMapping(value = "/change/merchant/login-mobile", method = RequestMethod.POST) + public Pair changeMerchantLoginMobile(@RequestParam("oldMobile") String oldMobile, @RequestParam("newMobile") String newMobile, @RequestParam("password") String password) { + return accountUserBaseService.changeMerchantLoginMobile(oldMobile, newMobile, password); + } + } diff --git a/mall-account/src/main/java/com/suisung/mall/account/service/AccountUserBaseService.java b/mall-account/src/main/java/com/suisung/mall/account/service/AccountUserBaseService.java index 01c8be0b..d45acea5 100644 --- a/mall-account/src/main/java/com/suisung/mall/account/service/AccountUserBaseService.java +++ b/mall-account/src/main/java/com/suisung/mall/account/service/AccountUserBaseService.java @@ -307,6 +307,16 @@ public interface AccountUserBaseService extends IBaseService { */ Pair merchantInnerRegister(String mobile, String regPwd); + /** + * 更改分店商家的手机号(仅限于分店,尽量不要更改总店的手机号),项目之间远程调用 + * + * @param oldMobile 老的手机号 + * @param newMobile 新的手机号 + * @param password 新的登录密码(可选) + * @return Pair 操作结果和提示信息,true表示成功,false表示失败 + */ + Pair changeMerchantLoginMobile(String oldMobile, String newMobile, String password); + /** * 批量保存accountInfo * diff --git a/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java b/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java index 517f83c6..957fd5a0 100644 --- a/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java +++ b/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java @@ -3338,6 +3338,104 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl 操作结果和提示信息,true表示成功,false表示失败 + */ + @Override + public Pair 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 public Map doAppConnectLogin(String bind_name, String code) { diff --git a/mall-common/src/main/java/com/suisung/mall/common/feignService/AccountService.java b/mall-common/src/main/java/com/suisung/mall/common/feignService/AccountService.java index 7147aeab..9887821f 100644 --- a/mall-common/src/main/java/com/suisung/mall/common/feignService/AccountService.java +++ b/mall-common/src/main/java/com/suisung/mall/common/feignService/AccountService.java @@ -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.res.ThirdApiRes; import io.swagger.annotations.ApiOperation; -import org.apache.ibatis.annotations.Param; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.data.util.Pair; 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) - Pair merchantInnerRegister(@Param("mobile") String mobile, @Param("regPwd") String regPwd); + Pair merchantInnerRegister(@RequestParam("mobile") String mobile, @RequestParam("regPwd") String regPwd); + + /** + * 服务间注册商家账号,项目之间远程调用 + */ + @RequestMapping(value = "/admin/account/account-user-base/merchant/inner-register", method = RequestMethod.POST) + Pair changeMerchantLoginMobile(@RequestParam("oldMobile") String oldMobile, @RequestParam("newMobile") String newMobile, @RequestParam("password") String password); + } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/activity/service/impl/ShopActivityGroupbookingServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/activity/service/impl/ShopActivityGroupbookingServiceImpl.java index e910890b..c9fc354e 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/activity/service/impl/ShopActivityGroupbookingServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/activity/service/impl/ShopActivityGroupbookingServiceImpl.java @@ -57,9 +57,11 @@ import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser; @Service public class ShopActivityGroupbookingServiceImpl extends BaseServiceImpl implements ShopActivityGroupbookingService { + @Lazy @Autowired private ShopActivityGroupbookingHistoryService shopActivityGroupbookingHistoryService; + @Lazy @Autowired private ShopActivityGroupbookingService shopActivityGroupbookingService; @@ -67,9 +69,11 @@ public class ShopActivityGroupbookingServiceImpl extends BaseServiceImpl configMap; public static Long version = 0L; + + @Lazy @Autowired private AccountService accountService; diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderInfoServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderInfoServiceImpl.java index f9beecc9..def81c7f 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderInfoServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderInfoServiceImpl.java @@ -99,8 +99,10 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl implements ShopStoreEmployeeService { + @Lazy @Autowired private AccountService accountService;