diff --git a/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java b/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java index 6839266c..6d3a0a88 100644 --- a/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java +++ b/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java @@ -17,6 +17,7 @@ import cc.hiver.core.service.*; import cc.hiver.core.service.mybatis.IUserRoleService; import cc.hiver.core.vo.RoleDTO; import cc.hiver.mall.entity.ShopUser; +import cc.hiver.mall.service.ShopService; import cc.hiver.mall.service.ShopUserService; import cn.hutool.core.util.StrUtil; import io.swagger.annotations.Api; @@ -88,6 +89,9 @@ public class UserController { @Autowired private ShopUserService shopUserService; + @Autowired + private ShopService shopService; + @PersistenceContext private EntityManager entityManager; @@ -127,6 +131,37 @@ public class UserController { return ResultUtil.success("修改成功"); } + /** + * 线上demo不允许测试账号改密码 + * + * @param password + * @param newPass + * @return + */ + @RequestMapping(value = "/modifyPassAndMobile", method = RequestMethod.POST) + @ApiOperation(value = "修改密码和手机号") + public Result modifyPassAndMobile( + @ApiParam("用户id") @RequestParam String userId, + @ApiParam("手机号") @RequestParam String mobile, + @ApiParam("旧密码") @RequestParam String password, + @ApiParam("新密码") @RequestParam String newPass) { + User user = userService.findById(userId); + if (!new BCryptPasswordEncoder().matches(password, user.getPassword())) { + return ResultUtil.error("旧密码不正确"); + } + String newEncryptPass = new BCryptPasswordEncoder().encode(newPass); + user.setPassword(newEncryptPass); + //user.setPassStrength(passStrength); + user.setMobile(mobile); + userService.update(user); + // 手动更新缓存 + redisTemplate.delete(USER + user.getUsername()); + // 删除缓存 + redisTemplate.delete(USER + user.getUsername()); + + return ResultUtil.success("修改密码和手机号成功"); + } + /** * 线上demo不允许测试账号改密码 * @@ -272,6 +307,11 @@ public class UserController { }).collect(Collectors.toList()); userRoleService.saveOrUpdateAll(userRoles); } + //注册店主和默认店铺 + + + //店主添加店员 + //添加店铺和用户信息 ShopUser shopUser = shopUserService.selectByUserIdAndShopId(u.getId(), shopId); if (shopUser != null) { diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java index ac583d46..0e1ea0d5 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java @@ -29,6 +29,7 @@ import cc.hiver.mall.service.ShopUserService; import cn.hutool.core.util.StrUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; @@ -120,6 +121,16 @@ public class ShopController { return ResultUtil.success("编辑成功"); } + @RequestMapping(value = "/modifyShopNameById", method = RequestMethod.PUT) + @ResponseBody + @ApiOperation(value = "根据店铺id修改店铺名") + public Result modifyShopNameById(@ApiParam("店铺id") @RequestParam String id,@ApiParam("店铺名称") @RequestParam String shopName) { + Shop shop = shopService.findById(id); + shop.setShopName(shopName); + shopService.update(shop); + return ResultUtil.success("编辑成功"); + } + @RequestMapping(value = "/delByIds", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "通过id删除") diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java index 75685b46..e14589c0 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/StockServiceImpl.java @@ -37,6 +37,9 @@ public class StockServiceImpl extends ServiceImpl implements @Autowired private ProductService productService; + @Autowired + private StockService stockService; + @Transactional @Override public Result putIn(PurchaseVo purchaseVo) { @@ -53,6 +56,7 @@ public class StockServiceImpl extends ServiceImpl implements QueryWrapper stockQueryWrapper = new QueryWrapper<>(); stockQueryWrapper.eq("product_id",productId); stockQueryWrapper.eq("attribute_list",attributeList); + stockQueryWrapper.eq("shop_id",purchase.getShopId()); List originList = this.list(stockQueryWrapper); Integer stockCount = 0; @@ -73,14 +77,13 @@ public class StockServiceImpl extends ServiceImpl implements //存在库存则修改库存数量 Stock origin = originList.get(0); stockCount = origin.getStockCount()!=null?origin.getStockCount():0; - UpdateWrapper updateWrapper = new UpdateWrapper<>(); - updateWrapper.eq("id",origin.getId()); - updateWrapper.set("stock_count",stockCount + purchaseDetail.getProductCount()); - this.update(); + origin.setStockCount(stockCount + purchaseDetail.getProductCount()); + stockService.saveOrUpdate(origin); }else { //没有则新建库存数据 Stock stock = new Stock(); BeanUtils.copyBeanProp(stock,purchaseDetail); + stock.setStockCount(purchaseDetail.getProductCount()); save(stock); }