feat:确认预约

This commit is contained in:
dzc committed 2026-06-10 14:28:20 +08:00
1 parent 69a0228549
commit 5993c1d34a
14 files changed
+150 -15

No files matched your search

@@ -55,6 +55,11 @@ public class HardOrderDto extends HardOrderEntity implements BaseIsIncludeTreeIn
*/
private Boolean isFindCarList = false;
/**
* 是否查询预约相关
*/
private Boolean isFindApptList = false;
/**
* 退款相关
*/
@@ -8,6 +8,7 @@ import com.bsd.pjcloud.wallet.api.vo.base.BaseWalletInterface;
import com.bsd.pjcloud.wallet.api.vo.base.BaseWalletTypeInterface;
import lombok.Data;
import java.time.LocalTime;
import java.util.List;
@Data
@@ -69,4 +70,14 @@ public class HardOrderVo extends HardOrderEntity implements BaseUserDeptInterfac
*/
private String walletTypeUniqueCode;
/**
* 预约时间相关
*/
private String apptTitle;
private String apptHourType;
private LocalTime apptStartTime;
private LocalTime apptEndTime;
}
@@ -68,6 +68,7 @@ import java.io.IOException;
import java.time.LocalDate;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -125,6 +126,28 @@ public class HardOrderController {
/* ************************************* end 远程调用 ************************************* */
/* ************************************* start app start ************************************* */
@Operation(summary = "app查询当前用户的预约订单", description = "app查询当前用户的预约订单")
@GetMapping("/app/user-appt-list")
public R<List<HardOrderVo>> userApptList() {
HardOrderDto dto = new HardOrderDto();
LocalDateTime now = LocalDateTime.now();
PjcloudUser user = SecurityUtils.getUser();
dto.setUserId(user.getId());
dto.setIsFindCarList(true);
dto.setIsFindApptList(true);
dto.setCreateTimeList(
new LocalDateTime[]{
now.withHour(0).withMinute(0).withSecond(0),
now.withHour(23).withMinute(59).withSecond(59)
}
);
dto.setOrderType(HardOrderTypeEnum.RESERVE.getType());
return R.ok(hardwareOrderService.scopeList(dto, null));
}
@Operation(summary = "app查询订单列表", description = "app查询订单列表")
@GetMapping("/app/page-join")
public R appPageJoin(@ParameterObject Page page, @ParameterObject HardOrderDto dto) {
@@ -36,7 +36,7 @@ public class HardApptServiceImpl extends ServiceImpl<HardApptMapper, HardApptEnt
@Override
public Long create(HardApptEntity dto) {
// title不能重复
if (existTitle(dto.getTitle(), null)) {
if (existTitle(dto.getTitle(), dto.getMchId(), null)) {
throw new RuntimeException("标题不能重复");
}
// 查询商户id
@@ -54,7 +54,7 @@ public class HardApptServiceImpl extends ServiceImpl<HardApptMapper, HardApptEnt
@Override
public Long edit(HardApptEntity dto) {
// title不能重复
if (existTitle(dto.getTitle(), dto.getId())) {
if (existTitle(dto.getTitle(), dto.getMchId(), dto.getId())) {
throw new RuntimeException("标题不能重复");
}
// 查询商户id
@@ -86,9 +86,10 @@ public class HardApptServiceImpl extends ServiceImpl<HardApptMapper, HardApptEnt
return baseMapper.selectPageByScope(page, wrapper, of);
}
private boolean existTitle(String title, Long id) {
private boolean existTitle(String title, Long mchId, Long id) {
Long count = baseMapper.selectCount(new LambdaQueryWrapper<HardApptEntity>()
.eq(ObjectUtil.isNotEmpty(title), HardApptEntity::getTitle, title)
.eq(ObjectUtil.isNotEmpty(mchId), HardApptEntity::getMchId, mchId)
.ne(ObjectUtil.isNotEmpty(id), HardApptEntity::getId, id)
);
if (ObjectUtil.isNotEmpty(id)) {
@@ -2097,13 +2097,33 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
}
});
// 购物车
if (dto.getIsFindCarList()) {
for (HardOrderVo v : list) {
List<HardCarEntity> carList = hardCarService.getByParentCarId(v.getParentCarId());
List<HardCarVo> carVoList = BeanUtils.toBean(carList, HardCarVo.class);
v.setCarList(carVoList);
CompletableFuture<Void> findCarListFuture = CompletableFuture.runAsync(() -> {
if (dto.getIsFindCarList()) {
for (HardOrderVo v : list) {
List<HardCarEntity> carList = hardCarService.getByParentCarId(v.getParentCarId());
List<HardCarVo> carVoList = BeanUtils.toBean(carList, HardCarVo.class);
v.setCarList(carVoList);
}
}
}
CompletableFuture.allOf(deptFuture, mchFuture, deviceFuture, currentDeptFuture, walletFuture).join();
});
// 预约订单
CompletableFuture<Void> findApptListFuture = CompletableFuture.runAsync(() -> {
if (dto.getIsFindApptList()) {
List<Long> apptList = list.stream().map(HardOrderVo::getApptId).filter(ObjectUtil::isNotEmpty).distinct().toList();
if (ObjectUtil.isEmpty(apptList)) return;
List<HardApptEntity> apptOrderList = hardApptService.listByIds(apptList);
if (ObjectUtil.isEmpty(apptOrderList)) return;
Map<Long, HardApptEntity> apptMap = CollectionUtils.convertMap(apptOrderList, HardApptEntity::getId);
for (HardOrderVo v : list) {
HardApptEntity target = apptMap.get(v.getApptId());
if (ObjectUtil.isEmpty(target)) continue;
v.setApptTitle(target.getTitle());
v.setApptHourType(target.getHourType());
v.setApptStartTime(target.getStartTime());
v.setApptEndTime(target.getEndTime());
}
}
});
CompletableFuture.allOf(deptFuture, mchFuture, deviceFuture, currentDeptFuture, walletFuture, findCarListFuture, findApptListFuture).join();
}
}
@@ -58,6 +58,7 @@
a.order_status,
a.pay_type,
a.hour_type,
a.appt_id,
a.sys_type,
a.total_price,
a.extra_price,
@@ -219,6 +219,10 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
treeNode.setWeight(dept.getSortOrder());
return treeNode;
}).toList(), 0L);
if (ObjectUtil.isEmpty(user) || ObjectUtil.isEmpty(user.getDeptId()) || CollUtil.isEmpty(deptAllTree)) {
return Collections.emptyList();
}
Tree<Long> currentDeptTree = null;
for (Tree<Long> rootNode : deptAllTree) {
currentDeptTree = TreeUtil.getNode(rootNode, user.getDeptId());
@@ -226,8 +230,26 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
break;
}
}
// List<Tree<Long>> currentDeptAllNodes = getSubTreeNodes(currentDeptTree);
return List.of(currentDeptTree);
if (currentDeptTree == null) {
return Collections.emptyList();
}
Tree<Long> child = currentDeptTree;
Tree<Long> ancestor = currentDeptTree.getParent();
while (ancestor != null) {
List<Tree<Long>> children = ancestor.getChildren();
if (children != null) {
Long childId = child.getId();
children.removeIf(item -> !Objects.equals(item.getId(), childId));
}
child = ancestor;
ancestor = ancestor.getParent();
}
if (Objects.equals(child.getId(), 0L)) {
return Optional.ofNullable(child.getChildren()).orElseGet(Collections::emptyList);
}
return List.of(child);
}
public List<Tree<Long>> getSubTreeNodes(Tree<Long> node) {
@@ -654,14 +654,14 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
if (ObjectUtil.isNotEmpty(v.getUsername())) {
long repetitionUsername = usernameList.stream().filter(i -> ObjectUtil.equals(i, v.getUsername())).count();
if (repetitionUsername > 1) {
errorMsg.add("用户名 <" + v.getUsername() + "> 重复");
// errorMsg.add("用户名 <" + v.getUsername() + "> 重复");
}
}
// 判断输入的编制是否合法
String staffingType = null;
if (ObjectUtil.isEmpty(v.getStaffingType())) {
errorMsg.add("请选择编制");
// errorMsg.add("请选择编制");
} else {
UserStaffingTypeEnum staffingTypeEnum = UserStaffingTypeEnum.valueOfByDescription(v.getStaffingType());
if (ObjectUtil.isEmpty(staffingTypeEnum)) {
@@ -14,8 +14,12 @@ import java.util.List;
@Data
public class MchManageDto extends MchManageEntity {
private Long parentDeptId;
private List<Long> deptIds;
private List<Long> excludeIds;
private List<Long> ids;
private List<Long> notIds;
@@ -25,6 +25,8 @@ public class WalletActiveDto extends WalletActiveEntity {
private List<Long> userIds;
private List<Long> deptIds;
/**
* 是否绑定用户
*/
@@ -6,6 +6,10 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.admin.api.dto.UserInfo;
import com.bsd.pjcloud.admin.api.entity.SysDept;
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.core.validation.Group;
import com.bsd.pjcloud.common.excel.annotation.RequestExcel;
@@ -19,7 +23,9 @@ import com.bsd.pjcloud.wallet.api.dto.WalletRemoteOpenCardListDto;
import com.bsd.pjcloud.wallet.api.dto.WalletActiveBindCardDto;
import com.bsd.pjcloud.wallet.api.dto.WalletActiveDto;
import com.bsd.pjcloud.wallet.api.entity.WalletActiveEntity;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletActiveVo;
import com.bsd.pjcloud.wallet.service.MchManageService;
import com.bsd.pjcloud.wallet.service.WalletActiveService;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -51,7 +57,10 @@ import java.util.List;
public class WalletActiveController {
private final WalletActiveService walletActiveService;
private final MchManageService mchManageService;
private final RemoteDeptService remoteDeptService;
private final RemoteUserService remoteUserService;
/* ************************************* start 远程调用 start ************************************* */
@@ -77,7 +86,20 @@ public class WalletActiveController {
@GetMapping("/ad/open-card-list")
@Operation(summary = "android开卡列表")
public R<Page<WalletActiveVo>> AdOpenCardList(@ParameterObject Page page, @ParameterObject WalletActiveDto dto) {
return R.ok(walletActiveService.pageJoin(page, dto));
PjcloudUser user = SecurityUtils.getUser();
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getDeptId())) {
UserInfo userInfo = remoteUserService.getInnerByUserId(user.getId()).getData();
MchManageVo targetMch = mchManageService.getViewsCanteenMchByDeptId(userInfo.getSysUser().getDeptId());
if (ObjectUtil.isNotEmpty(targetMch)) {
dto.setDeptIds(List.of(targetMch.getId()));
} else {
List<SysDept> deptIdList = remoteDeptService.getDescendantList(userInfo.getSysUser().getDeptId()).getData();
if (ObjectUtil.isNotEmpty(deptIdList)) {
dto.setDeptIds(deptIdList.stream().map(SysDept::getDeptId).toList());
}
}
}
return R.ok(walletActiveService.scopePageList(page, dto));
}
@GetMapping("/ad/open-card-success")
@@ -33,6 +33,7 @@ import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
@@ -145,6 +146,11 @@ public class MchManageController {
MchManageVo targetMch = mchManageService.getViewsCanteenMchByDeptId(userInfo.getSysUser().getDeptId());
if (ObjectUtil.isNotEmpty(targetMch)) {
dto.setIds(List.of(targetMch.getId()));
} else {
List<SysDept> deptIdList = remoteDeptService.getDescendantList(userInfo.getSysUser().getDeptId()).getData();
if (ObjectUtil.isNotEmpty(deptIdList)) {
dto.setDeptIds(deptIdList.stream().map(SysDept::getDeptId).toList());
}
}
} else {
R.ok(new Page<>());
@@ -212,6 +218,17 @@ public class MchManageController {
@GetMapping("/select")
public R getSelect(@ParameterObject Page page, @ParameterObject MchManageDto dto) {
DataScope dataScope = null;
if (ObjectUtil.isNotEmpty(dto.getParentDeptId())) {
List<SysDept> deptIdList = remoteDeptService.getDescendantList(dto.getParentDeptId()).getData();
if (ObjectUtil.isNotEmpty(deptIdList)) {
List<Long> deptIds = dto.getDeptIds();
if (ObjectUtil.isEmpty(deptIds)) {
deptIds = new ArrayList<>();
}
deptIds.addAll(deptIdList.stream().map(SysDept::getDeptId).toList());
dto.setDeptIds(deptIds);
}
}
return R.ok(mchManageService.scopePageList(page, dto, dataScope));
}
@@ -34,6 +34,7 @@ public interface WalletActiveMapper extends PjcloudBaseMapper<WalletActiveEntity
.eq(ObjectUtil.isNotEmpty(dto.getIsActiveHardware()), WalletActiveEntity::getIsActiveHardware, dto.getIsActiveHardware())
.eq(ObjectUtil.isNotEmpty(dto.getDeptId()), WalletActiveEntity::getDeptId, dto.getDeptId())
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletActiveEntity::getUserId, dto.getUserIds())
.in(ObjectUtil.isNotEmpty(dto.getDeptIds()), WalletActiveEntity::getDeptId, dto.getDeptIds())
.orderByDesc(WalletActiveEntity::getCardSort);
if (ObjectUtil.isNotEmpty(dto.getIsBindUser())) {
if (dto.getIsBindUser()) {
@@ -82,6 +82,12 @@
#{v}
</foreach>
</if>
<if test="dto.excludeIds != null and dto.excludeIds.size() != 0">
and a.id not in
<foreach collection="dto.excludeIds" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.ids != null and dto.ids.size() != 0">
and a.id in
<foreach collection="dto.ids" item="v" open="(" close=")" separator=",">