Merge remote-tracking branch 'origin/dev' into zs

This commit is contained in:
2024-08-02 09:12:28 +08:00
8 changed files with 28 additions and 16 deletions

View File

@@ -99,6 +99,7 @@ public class AuthorizationController {
throw new BadRequestException("验证码错误");
}
String loginpre="";
String shopId="";
// 判断是否是员工登录
if (authUser.getLoginType() != null && "staff".equals(authUser.getLoginType())) {
if (StrUtil.isBlank(authUser.getMerchantName())) {
@@ -109,7 +110,8 @@ public class AuthorizationController {
if (merchant == null) {
throw new BadRequestException("商户不存在");
}
loginpre=merchant.getShopId() + "@";
loginpre = merchant.getShopId() + "@";
shopId = merchant.getShopId();
}
//生成token
@@ -123,7 +125,12 @@ public class AuthorizationController {
// SecurityContextHolder.getContext().setAuthentication(authentication);
final JwtUserDto jwtUserDto = (JwtUserDto) authentication.getPrincipal();
// TbShopInfo byAccount = tbShopInfoRepository.findByAccount(jwtUserDto.getUsername());
TbPlussShopStaff tbPlussShopStaff = staffRepository.queryByAccount(authUser.getUsername());
TbPlussShopStaff tbPlussShopStaff;
if (authUser.getLoginType() != null && "staff".equals(authUser.getLoginType())) {
tbPlussShopStaff = staffRepository.queryByAccount(authUser.getUsername(),shopId);
} else {
tbPlussShopStaff = staffRepository.queryByAccount(authUser.getUsername());
}
if (tbPlussShopStaff != null && tbPlussShopStaff.getType().equals("staff")) {
Integer isManage = tbPlussShopStaff.getIsManage();
if (isManage != null && isManage != 1) {

View File

@@ -114,7 +114,7 @@ public class StockController {
}
@Log("商品库存:上下架商品")
@Log("商品库存 上下架商品")
@PutMapping("/grounding")
@ApiOperation("上下架商品")
public ResponseEntity<Object> grounding(
@@ -141,7 +141,7 @@ public class StockController {
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("商品库存:修改商品状态")
@Log("商品库存 修改商品状态")
@PutMapping("productStatus")
public ResponseEntity<Object> updateProductStatus(@RequestBody StockUpdateValueVO updateValueVO) {
stockService.updateProductStatus(updateValueVO);

View File

@@ -129,7 +129,7 @@ public class TbProductSku implements Serializable {
@Column(name = "`is_grounding`")
@ApiModelProperty(value = "是否上架")
private Integer isGrounding = 1;
private Integer isGrounding;
public void setIsDel(Integer isDel) {
if(isDel!=null){

View File

@@ -45,6 +45,9 @@ public interface TbPlussShopStaffRepository extends JpaRepository<TbPlussShopSta
@Query("select staff from TbPlussShopStaff as staff where staff.account = :account")
TbPlussShopStaff queryByAccount(String account);
@Query("select staff from TbPlussShopStaff as staff where staff.account = :account and staff.shopId=:shopId")
TbPlussShopStaff queryByAccount(String account,String shopId);
@Modifying
@Query("update TbPlussShopStaff set name=:name where shopId = :shopId and type='master'")
void updateNameById(String name, String shopId);

View File

@@ -374,6 +374,8 @@ public class TbProductServiceImpl implements TbProductService {
}
}
// 默认开启共享库存和库存
// product.setIsDistribute(1);
TbProduct save = tbProductRepository.save(product);
if (save.getId() == null) {
throw new BadRequestException("添加商品失败");

View File

@@ -84,7 +84,7 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(id).orElseGet(TbPlussShopStaff::new);
ValidationUtil.isNull(tbPlussShopStaff.getId(),"TbPlussShopStaff","id",id);
TbPlussShopStaffDto dto = tbPlussShopStaffMapper.toDto(tbPlussShopStaff);
UserDto userDto = userService.findByName(tbPlussShopStaff.getAccount());
UserDto userDto = userService.findByName(tbPlussShopStaff.getShopId()+"@"+tbPlussShopStaff.getAccount());
// dto.setUser(userDto);
if(!CollectionUtils.isEmpty(userDto.getRoles())){
dto.setRoleId(userDto.getRoles().stream().findFirst().get().getId());
@@ -100,7 +100,7 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
if (!PhoneUtil.validator(resources.getPhone())){
throw new BadRequestException("手机号格式有误");
}
if (userRepository.findByUsername(resources.getAccount()) != null) {
if (userRepository.findByUsername(resources.getShopId()+"@"+resources.getAccount()) != null) {
throw new BadRequestException("员工账号已存在");
}
@@ -163,7 +163,7 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(resources.getId()).orElseGet(TbPlussShopStaff::new);
User sysUser = userRepository.findByUsername(resources.getShopId()+"@"+tbPlussShopStaff.getAccount());
if(!tbPlussShopStaff.getAccount().equals(resources.getAccount())){
if (userRepository.findByUsername(resources.getAccount()) != null) {
if (userRepository.findByUsername(resources.getShopId()+"@"+resources.getAccount()) != null) {
throw new BadRequestException("员工账号不可重复");
}
}

View File

@@ -36,6 +36,7 @@ public interface RoleRepository extends JpaRepository<Role, Long>, JpaSpecificat
* @return /
*/
Role findByName(String name);
Role findByNameAndShopId(String name,Integer shopId);
/**
* 删除多个角色

View File

@@ -91,8 +91,8 @@ public class RoleServiceImpl implements RoleService {
@Override
@Transactional(rollbackFor = Exception.class)
public void create(Role resources) {
if (roleRepository.findByName(resources.getName()) != null) {
throw new EntityExistException(Role.class, "username", resources.getName());
if (roleRepository.findByNameAndShopId(resources.getName(),resources.getShopId()) != null) {
throw new BadRequestException("角色已存在");
}
roleRepository.save(resources);
}
@@ -101,13 +101,12 @@ public class RoleServiceImpl implements RoleService {
@Transactional(rollbackFor = Exception.class)
public void update(Role resources) {
Role role = roleRepository.findById(resources.getId()).orElseGet(Role::new);
ValidationUtil.isNull(role.getId(), "Role", "id", resources.getId());
Role role1 = roleRepository.findByName(resources.getName());
if (role1 != null && !role1.getId().equals(role.getId())) {
throw new EntityExistException(Role.class, "username", resources.getName());
if (!resources.getName().equals(role.getName())) {
if (roleRepository.findByNameAndShopId(resources.getName(),resources.getShopId()) != null) {
throw new BadRequestException("修改失败,角色名称不可重复");
}
}
ValidationUtil.isNull(role.getId(), "Role", "id", resources.getId());
role.setName(resources.getName());
role.setDescription(resources.getDescription());
role.setDataScope(resources.getDataScope());