rk
13 小时以前 f9e4883831956328e73f4df77c8d6887a0f8d70b
server/dmmall_service/src/main/java/com/doumee/service/business/impl/ShopServiceImpl.java
@@ -1000,5 +1000,29 @@
        redisTemplate.delete(token);
    }
    @Override
    public void updatePwd(Integer shopId, String oldPassword, String newPassword){
        if(StringUtils.isBlank(oldPassword) || StringUtils.isBlank(newPassword)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "旧密码和新密码不能为空");
        }
        if(oldPassword.equals(newPassword)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "新密码不能与旧密码相同");
        }
        Shop shop = shopMapper.selectById(shopId);
        if(shop == null){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "商户信息不存在");
        }
        String oldPwd = Utils.Secure.encryptPassword(oldPassword, shop.getSalt());
        if(!oldPwd.equals(shop.getPassword())){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "旧密码错误");
        }
        String newSalt = RandomStringUtils.randomAlphabetic(6);
        String newPwd = Utils.Secure.encryptPassword(newPassword, newSalt);
        shopMapper.update(null, new UpdateWrapper<Shop>().lambda()
                .set(Shop::getPassword, newPwd)
                .set(Shop::getSalt, newSalt)
                .eq(Shop::getId, shopId));
    }
}