feat:用户商户部门
This commit is contained in:
1 parent
4360790f68
commit
360fcf8c98
15 files changed
+109
-30
No files matched your search
+4
@@ -40,6 +40,10 @@ import java.util.Set;
|
||||
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.UPMS_SERVICE)
|
||||
public interface RemoteUserService {
|
||||
|
||||
@NoToken
|
||||
@PostMapping("/user/inner/sync-user-canteen")
|
||||
R syncUserCanteen(@RequestParam(required = false) Long userId, @RequestParam(required = false) Long deptId, @RequestParam(required = false) Boolean foure);
|
||||
|
||||
@NoToken
|
||||
@PostMapping("/user/inner-page")
|
||||
R<List<UserVO>> getRemoteUserPage(@RequestParam Long current, @RequestParam Long size, @RequestBody UserDTO userDTO);
|
||||
|
||||
+12
@@ -86,6 +86,18 @@ public class SysUserController {
|
||||
|
||||
/* ************************************* end 回调 end ************************************* */
|
||||
|
||||
/* ************************************* start 远程调用 start ************************************* */
|
||||
|
||||
@Inner()
|
||||
@PostMapping("/inner/sync-user-canteen")
|
||||
public R syncUserCanteen(@RequestParam(required = false) Long userId, @RequestParam(required = false) Long deptId, @RequestParam(required = false) Boolean foure) {
|
||||
if (ObjectUtil.isEmpty(foure)) foure = true;
|
||||
userService.syncUserCanteen(userId, deptId, foure);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/* ************************************* end 远程调用 end ************************************* */
|
||||
|
||||
@Operation(summary = "同步用户食堂信息", description = "同步用户食堂信息")
|
||||
@PostMapping("/sync-user-canteen")
|
||||
public R syncUserCanteen() {
|
||||
|
||||
+12
-1
@@ -222,6 +222,7 @@ public interface SysUserService extends IService<SysUser> {
|
||||
|
||||
/**
|
||||
* 根据部门id/姓名,获取用户信息
|
||||
*
|
||||
* @param deptId
|
||||
* @param name
|
||||
* @return
|
||||
@@ -229,7 +230,17 @@ public interface SysUserService extends IService<SysUser> {
|
||||
List<SimpleUserListVO> listUserIdByDeptId(Long deptId, String name);
|
||||
|
||||
/**
|
||||
* 同步用户食堂信息
|
||||
* 同步所有用户食堂信息
|
||||
*/
|
||||
void syncUserCanteen();
|
||||
|
||||
/**
|
||||
* 按条件同步用户食堂信息
|
||||
*/
|
||||
void syncUserCanteen(Long userId, Long deptId, boolean foure);
|
||||
|
||||
/**
|
||||
* 获取用户食堂id
|
||||
*/
|
||||
Long getUserCanteenId(Long deptId);
|
||||
}
|
||||
+42
-6
@@ -53,6 +53,7 @@ import com.bsd.pjcloud.common.audit.annotation.Audit;
|
||||
import com.bsd.pjcloud.common.core.constant.CacheConstants;
|
||||
import com.bsd.pjcloud.common.core.constant.CommonConstants;
|
||||
import com.bsd.pjcloud.common.core.constant.CommonRoleConstant;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.MerchantTypeEnum;
|
||||
import com.bsd.pjcloud.common.core.exception.ErrorCodes;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.core.util.MsgUtils;
|
||||
@@ -174,6 +175,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
sysUser.setUpdateBy(userDto.getUsername());
|
||||
sysUser.setPassword(ENCODER.encode(userDto.getPassword()));
|
||||
sysUser.setPasswordModifyTime(LocalDateTime.now());
|
||||
// 获取用户食堂id
|
||||
sysUser.setCanteenId(getUserCanteenId(sysUser.getDeptId()));
|
||||
baseMapper.insert(sysUser);
|
||||
// 保存用户岗位信息
|
||||
Optional.ofNullable(userDto.getPost()).ifPresent(posts -> {
|
||||
@@ -209,7 +212,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
||||
CompletableFuture.runAsync(() -> {
|
||||
RequestContextHolder.setRequestAttributes(requestAttributes);
|
||||
// 创建钱包
|
||||
remoteWalletService.createWallet(sysUser.getUserId());
|
||||
// 通知钱包
|
||||
remoteWalletService.userChange(sysUser.getUserId(), Boolean.FALSE);
|
||||
});
|
||||
}
|
||||
@@ -890,6 +895,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
updateUser.setUserId(detail.getUserId());
|
||||
updateUser.setProcessStatus(processStatus);
|
||||
updateUser.setProcessTime(LocalDateTime.now());
|
||||
if (isConsent) updateUser.setCanteenId(getUserCanteenId(detail.getDeptId()));
|
||||
baseMapper.updateById(updateUser);
|
||||
if (isConsent) {
|
||||
// 创建用户默认钱包
|
||||
@@ -961,6 +967,35 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按条件同步用户食堂信息
|
||||
*/
|
||||
@Override
|
||||
public void syncUserCanteen(Long userId, Long deptId, boolean foure) {
|
||||
SysUser userDto = new SysUser();
|
||||
userDto.setUserId(userId);
|
||||
userDto.setDeptId(deptId);
|
||||
Long current = 1L;
|
||||
while (true) {
|
||||
boolean result = syncUserCanteenGroup(current, userDto, foure);
|
||||
if (!result) break;
|
||||
current++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户食堂id
|
||||
*/
|
||||
@Override
|
||||
public Long getUserCanteenId(Long deptId) {
|
||||
if (ObjectUtil.isEmpty(deptId)) return -1L;
|
||||
MchManageVo mchDetail = remoteMchService.getFirstMchByDeptId(deptId, MerchantTypeEnum.CANTEEN).getData();
|
||||
if (ObjectUtil.isNotEmpty(mchDetail) && ObjectUtil.isNotEmpty(mchDetail.getTypes()) && ObjectUtil.equals(mchDetail.getTypes(), MerchantTypeEnum.CANTEEN.getType())) {
|
||||
return mchDetail.getId();
|
||||
}
|
||||
return -1L;
|
||||
}
|
||||
|
||||
public boolean syncUserCanteenGroup(Long current, SysUser userDto, boolean foure) {
|
||||
Page page = new Page<>();
|
||||
page.setCurrent(current);
|
||||
@@ -977,14 +1012,15 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
|
||||
for (SysUser v : pageList.getRecords()) {
|
||||
if (!foure && ObjectUtil.isNotEmpty(v.getCanteenId())) continue;
|
||||
MchManageVo mchDetail = remoteMchService.getFirstMchByDeptId(v.getDeptId()).getData();
|
||||
if (ObjectUtil.isEmpty(mchDetail)) {
|
||||
noneMchUserSum++;
|
||||
continue;
|
||||
}
|
||||
SysUser item = new SysUser();
|
||||
item.setUserId(v.getUserId());
|
||||
item.setCanteenId(mchDetail.getId());
|
||||
Long mchId = getUserCanteenId(v.getDeptId());
|
||||
if (ObjectUtil.equals(mchId, -1L)) {
|
||||
item.setCanteenId(-1L);
|
||||
noneMchUserSum++;
|
||||
} else {
|
||||
item.setCanteenId(mchId);
|
||||
}
|
||||
updateUserList.add(item);
|
||||
}
|
||||
baseMapper.updateById(updateUserList);
|
||||
|
||||
+1
@@ -205,6 +205,7 @@ public class SysUserTransactionServiceImpl extends ServiceImpl<SysUserTransactio
|
||||
SysUser userUpdateObj = new SysUser();
|
||||
userUpdateObj.setUserId(detail.getUserId());
|
||||
userUpdateObj.setDeptId(detail.getTargetDeptId());
|
||||
userUpdateObj.setCanteenId(sysUserService.getUserCanteenId(detail.getTargetDeptId()));
|
||||
sysUserService.updateById(userUpdateObj);
|
||||
// 通知正元
|
||||
if (ObjectUtil.equals(detail.getBizType(), UserTransactionEnum.INNER_TRANSFER.getType())) {
|
||||
|
||||
Reference in new issue
Block a user