Explorar o código

客房管理bug修改

baiyun hai 1 ano
pai
achega
95138d61f8
Modificáronse 17 ficheiros con 175 adicións e 70 borrados
  1. 2 2
      ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/HotelBusinessConstants.java
  2. 1 0
      ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/cardCenter/service/impl/PtSubsidyServiceImpl.java
  3. 1 1
      ruoyi-modules/ruoyi-backstage/src/main/resources/mapper/payment/PtUserAccountMapper.xml
  4. 3 3
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/controller/KfGuestTeamRController.java
  5. 24 0
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/domain/bo/KfGuestTeamRBo.java
  6. 1 1
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/domain/bo/KfTeamBo.java
  7. 36 4
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/domain/vo/KfGuestTeamRVo.java
  8. 0 2
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/domain/vo/KfOrderVo.java
  9. 0 1
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/domain/vo/KfTeamVo.java
  10. 1 1
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/mapper/KfGuestTeamRMapper.java
  11. 4 0
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/service/IKfGuestService.java
  12. 1 1
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/service/IKfGuestTeamRService.java
  13. 47 0
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/service/impl/KfGuestServiceImpl.java
  14. 1 1
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/service/impl/KfGuestTeamRServiceImpl.java
  15. 7 3
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/service/impl/KfOrderServiceImpl.java
  16. 43 48
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/service/impl/KfTeamServiceImpl.java
  17. 3 2
      ruoyi-modules/ruoyi-hotel/src/main/resources/mapper/hotel/basics/KfGuestTeamRMapper.xml

+ 2 - 2
ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/HotelBusinessConstants.java

@@ -31,9 +31,9 @@ public class HotelBusinessConstants {
 
     /** 是否*************************************/
     /** 否 */
-    public static final String NO = "0";
+    public static final String NO = "N";
     /** 是 */
-    public static final String YES = "1";
+    public static final String YES = "Y";
 
 
     /** 订单状态和房间状态对应关系*/

+ 1 - 0
ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/cardCenter/service/impl/PtSubsidyServiceImpl.java

@@ -81,6 +81,7 @@ public class PtSubsidyServiceImpl implements IPtSubsidyService {
         lqw.eq(StringUtils.isNotBlank(bo.getSubsidyType()), PtSubsidy::getSubsidyType, bo.getSubsidyType());
         lqw.eq(bo.getFillDate() != null, PtSubsidy::getFillDate, bo.getFillDate());
         lqw.eq(StringUtils.isNotBlank(bo.getFillStatus()), PtSubsidy::getFillStatus, bo.getFillStatus());
+        lqw.eq(StringUtils.isNotBlank(bo.getAuditStatus()), PtSubsidy::getAuditStatus, bo.getAuditStatus());
         return lqw;
     }
 

+ 1 - 1
ruoyi-modules/ruoyi-backstage/src/main/resources/mapper/payment/PtUserAccountMapper.xml

@@ -60,7 +60,7 @@
                 and ( u.dept_id = #{bo.deptId} or a.ancestors like concat('%',#{bo.deptId},'%'))
             </if>
             <if test="bo.realName != null and  bo.realName != ''">
-                and u.real_name = #{bo.realName}
+                and u.real_name like concat('%',#{bo.realName},'%')
             </if>
             <if test="bo.userNumb != null and  bo.userNumb != ''">
                 and u.user_numb = #{bo.userNumb}

+ 3 - 3
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/controller/KfGuestTeamRController.java

@@ -52,7 +52,7 @@ public class KfGuestTeamRController extends BaseController {
      */
     @SaCheckPermission("basics:kfGuestTeam:list")
     @GetMapping("/listGuestByTeamId")
-    public TableDataInfo<KfGuestVo> listGuestByTeamId(@RequestParam Long teamId, @RequestParam(required = false) String guestName) {
+    public TableDataInfo<KfGuestTeamRVo> listGuestByTeamId(@RequestParam Long teamId, @RequestParam(required = false) String guestName) {
         return TableDataInfo.build(kfGuestTeamRService.listGuests(teamId, guestName));
     }
     /**
@@ -73,8 +73,8 @@ public class KfGuestTeamRController extends BaseController {
     @Log(title = "团客人员列表", businessType = BusinessType.EXPORT)
     @PostMapping("/exportTeamGuest")
     public void exportTeamGuest(@RequestParam Long teamId, HttpServletResponse response) {
-        List<KfGuestVo> list = kfGuestTeamRService.listGuests(teamId, null);
-        ExcelUtil.exportExcel(list, "团客人员信息", KfGuestVo.class, response);
+        List<KfGuestTeamRVo> list = kfGuestTeamRService.listGuests(teamId, null);
+        ExcelUtil.exportExcel(list, "团客人员信息", KfGuestTeamRVo.class, response);
     }
 
     /**

+ 24 - 0
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/domain/bo/KfGuestTeamRBo.java

@@ -44,5 +44,29 @@ public class KfGuestTeamRBo extends BaseEntity {
     @NotBlank(message = "是否报到不能为空", groups = { AddGroup.class, EditGroup.class })
     private String checkInStatus;
 
+    /**
+     * 姓名
+     */
+    private String name;
+
+    /**
+     * 性别
+     */
+    private String sex;
+
+    /**
+     * 身份证号
+     */
+    private String idCard;
+
+    /**
+     * 手机号
+     */
+    private String phone;
+
+    /**
+     * 备注
+     */
+    private String remark;
 
 }

+ 1 - 1
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/domain/bo/KfTeamBo.java

@@ -62,5 +62,5 @@ public class KfTeamBo extends BaseEntity {
 
     private String dataSource;
 
-    private List<KfGuestBo> guestList;
+    private List<KfGuestTeamRBo> guestList;
 }

+ 36 - 4
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/domain/vo/KfGuestTeamRVo.java

@@ -31,26 +31,58 @@ public class KfGuestTeamRVo implements Serializable {
     /**
      * 主键
      */
-    @ExcelProperty(value = "主键")
     private Long id;
 
     /**
      * 客人ID
      */
-    @ExcelProperty(value = "客人ID")
     private Long guestId;
 
     /**
      * 客团ID
      */
-    @ExcelProperty(value = "客团ID")
     private Long teamId;
 
+    @ExcelProperty(value = "姓名")
+    private String name;
+
+
+    /**
+     * 性别
+     */
+    @ExcelProperty(value = "性别", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(dictType = "sys_user_sex")
+    private String sex;
+
+    /**
+     * 身份证号
+     */
+    @ExcelProperty(value = "身份证号")
+    private String idCard;
+
+    /**
+     * 手机号
+     */
+    @ExcelProperty(value = "手机号")
+    private String phone;
+
+
     /**
      * 是否报到
      */
-    @ExcelProperty(value = "是否报到")
+    @ExcelProperty(value = "是否报到", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(dictType = "sys_yes_no")
     private String checkInStatus;
 
+    /**
+     * 备注
+     */
+    @ExcelProperty(value = "备注")
+    private String remark;
+
+    /**
+     * 原始数据ID
+     */
+    private String otherId;
 
 }

+ 0 - 2
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/domain/vo/KfOrderVo.java

@@ -31,7 +31,6 @@ public class KfOrderVo implements Serializable {
     /**
      * 主键
      */
-    @ExcelProperty(value = "主键")
     private Long id;
 
     /**
@@ -51,7 +50,6 @@ public class KfOrderVo implements Serializable {
      * 客团名称
      */
     private Long teamId;
-    @ExcelProperty(value = "客团名称")
     private String teamName;
 
     /**

+ 0 - 1
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/domain/vo/KfTeamVo.java

@@ -34,7 +34,6 @@ public class KfTeamVo implements Serializable {
     /**
      * 主键
      */
-    @ExcelProperty(value = "主键")
     private Long id;
 
     /**

+ 1 - 1
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/mapper/KfGuestTeamRMapper.java

@@ -15,5 +15,5 @@ import java.util.List;
  * @date 2024-11-17
  */
 public interface KfGuestTeamRMapper extends BaseMapperPlus<KfGuestTeamR, KfGuestTeamRVo> {
-    List<KfGuestVo> selectGuests(@Param("teamId") Long teamId, @Param("guestName") String guestName);
+    List<KfGuestTeamRVo> selectGuests(@Param("teamId") Long teamId, @Param("guestName") String guestName);
 }

+ 4 - 0
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/service/IKfGuestService.java

@@ -1,7 +1,9 @@
 package org.dromara.hotel.service;
 
+import org.dromara.common.core.domain.R;
 import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.hotel.domain.KfGuest;
 import org.dromara.hotel.domain.bo.KfGuestBo;
 import org.dromara.hotel.domain.vo.KfGuestVo;
 
@@ -57,6 +59,8 @@ public interface IKfGuestService {
      */
     Boolean insertByBo(KfGuestBo bo);
 
+    R<String> insertBatch(List<KfGuest> guests);
+
     /**
      * 修改客人管理
      *

+ 1 - 1
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/service/IKfGuestTeamRService.java

@@ -78,7 +78,7 @@ public interface IKfGuestTeamRService {
     /**
      * 根据客团ID查询客人信息
      */
-    List<KfGuestVo> listGuests(Long teamId, String guestName);
+    List<KfGuestTeamRVo> listGuests(Long teamId, String guestName);
 
     /**
      * 更新团客客人的报到状态

+ 47 - 0
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/service/impl/KfGuestServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.RequiredArgsConstructor;
+import org.dromara.common.core.domain.R;
 import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
@@ -21,8 +22,10 @@ import org.dromara.hotel.service.IKfGuestTeamRService;
 import org.springframework.stereotype.Service;
 
 import java.util.Collection;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 客人管理Service业务层处理
@@ -94,6 +97,7 @@ public class KfGuestServiceImpl implements IKfGuestService {
         lqw.eq(StringUtils.isNotBlank(bo.getIdCard()), KfGuest::getIdCard, bo.getIdCard());
         lqw.eq(StringUtils.isNotBlank(bo.getPhone()), KfGuest::getPhone, bo.getPhone());
         lqw.eq(StringUtils.isNotBlank(bo.getOtherId()), KfGuest::getOtherId, bo.getOtherId());
+        lqw.orderByDesc(KfGuest::getCreateTime);
         return lqw;
     }
 
@@ -127,6 +131,49 @@ public class KfGuestServiceImpl implements IKfGuestService {
         return flag;
     }
 
+    @Override
+    public R<String> insertBatch(List<KfGuest> guests) {
+        String filterGuest = "操作成功";
+        if (ObjectUtil.isNotEmpty(guests)) {
+            //1.根据手机号或者身份证查询是否已存在
+            List<KfGuest> kfGuestList = baseMapper.selectList(new LambdaQueryWrapper<KfGuest>()
+                    .in(KfGuest::getIdCard, guests.stream().map(KfGuest::getIdCard).toList())
+                    .or()
+                    .in(KfGuest::getPhone, guests.stream().map(KfGuest::getPhone).toList()));
+            if (ObjectUtil.isNotEmpty(kfGuestList)) {
+                filterGuest = filterExistGuest(guests, kfGuestList);
+            }
+            //新增不存在的客人
+            baseMapper.insertBatch(guests.stream().map(item -> MapstructUtils.convert(item, KfGuest.class)).toList());
+        }
+        return R.ok(filterGuest);
+    }
+
+    /** 过滤掉已存在的客人数据*/
+
+    private boolean shouldRemoveGuest(KfGuest bo, Map<String, KfGuest> idCardMap, Map<String, KfGuest> phoneMap) {
+        return (StringUtils.isNotBlank(bo.getIdCard()) && idCardMap.containsKey(bo.getIdCard())) ||
+            (StringUtils.isNotBlank(bo.getPhone()) && phoneMap.containsKey(bo.getPhone()));
+    }
+    private  String filterExistGuest(List<KfGuest> guests, List<KfGuest> existGuestList) {
+        // 将 existGuestList 转换为 Map,以便快速查找
+        Map<String, KfGuest> idCardMap = existGuestList.stream().filter(guest -> guest.getIdCard() != null)
+            .collect(Collectors.toMap(KfGuest::getIdCard, guest -> guest));
+        Map<String, KfGuest> phoneMap = existGuestList.stream().filter(guest -> guest.getPhone() != null)
+            .collect(Collectors.toMap(KfGuest::getPhone, guest -> guest));
+        StringBuilder result = new StringBuilder("客人身份证号或手机号与其他客人重复:[");
+        Iterator<KfGuest> iterator = guests.iterator();
+        while (iterator.hasNext()) {
+            KfGuest bo = iterator.next();
+            if (shouldRemoveGuest(bo, idCardMap, phoneMap)) {
+                result.append(bo.getName()).append(",");
+                iterator.remove();
+            }
+        }
+        result.setLength(result.length() - 1);
+        result.append("]");
+        return result.toString();
+    }
     /**
      * 修改客人管理
      *

+ 1 - 1
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/service/impl/KfGuestTeamRServiceImpl.java

@@ -168,7 +168,7 @@ public class KfGuestTeamRServiceImpl implements IKfGuestTeamRService {
     }
 
     @Override
-    public List<KfGuestVo> listGuests(Long teamId, String guestName) {
+    public List<KfGuestTeamRVo> listGuests(Long teamId, String guestName) {
         return baseMapper.selectGuests(teamId, guestName);
     }
     /**

+ 7 - 3
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/service/impl/KfOrderServiceImpl.java

@@ -127,7 +127,7 @@ public class KfOrderServiceImpl implements IKfOrderService {
         //1.查询团客信息
         KfTeamGuestVo teamGuest = baseMapper.getTeamGuestCheckInfo(bo);
         if(ObjectUtil.isEmpty(teamGuest)) {
-            return R.fail("未找到对应的团客人员信息");
+            return R.fail("未找到对应的团客人员信息,请确认身份证号或手机号是否正确!");
         }
         //2.查询团客入住信息
         KfOrder order = baseMapper.selectOne(Wrappers.<KfOrder>lambdaQuery()
@@ -226,13 +226,14 @@ public class KfOrderServiceImpl implements IKfOrderService {
     @Override
     @Transactional
     public Boolean lockRoom(List<KfOrderBo> bos) {
+
         if(ObjectUtil.isNotEmpty(bos)){
             List<KfOrder> orders = MapstructUtils.convert(bos, KfOrder.class);
             Long teamId = bos.get(0).getTeamId();
             for(int i = 0; i < orders.size(); i++){
                 orders.get(i).setOrderStatus(HotelBusinessConstants.ORDER_STATUS_SF);
                 orders.get(i).setOrderType(HotelBusinessConstants.ORDER_TYPE_TK);
-                orders.get(i).setOrderIndex(i++);
+                orders.get(i).setOrderIndex(i);
             }
             //根据teamId 删除历史锁房
             baseMapper.delete(new LambdaQueryWrapper<KfOrder>()
@@ -254,7 +255,7 @@ public class KfOrderServiceImpl implements IKfOrderService {
             });
         }
 
-        return null;
+        return true;
     }
 
     /**
@@ -318,6 +319,9 @@ public class KfOrderServiceImpl implements IKfOrderService {
                 KfGuestBo guestBo = new KfGuestBo();
                 guestBo.setPhone(phone);
                 R<KfTeamGuestVo> teamGuestVoR = getTeamGuestCheckInfo(guestBo);
+                if(R.isError(teamGuestVoR)){
+                    return R.fail(teamGuestVoR.getMsg());
+                }
                 if("已报到".equals(teamGuestVoR.getData().getCheckInStatus())){
                     return R.ok("该团客已报到");
                 }

+ 43 - 48
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/service/impl/KfTeamServiceImpl.java

@@ -1,5 +1,6 @@
 package org.dromara.hotel.service.impl;
 
+import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -7,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.RequiredArgsConstructor;
 import org.dromara.common.core.constant.HotelBusinessConstants;
+import org.dromara.common.core.domain.R;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.PageQuery;
@@ -15,11 +17,14 @@ import org.dromara.hotel.domain.KfGuest;
 import org.dromara.hotel.domain.KfGuestTeamR;
 import org.dromara.hotel.domain.KfTeam;
 import org.dromara.hotel.domain.bo.KfGuestBo;
+import org.dromara.hotel.domain.bo.KfGuestTeamRBo;
 import org.dromara.hotel.domain.bo.KfTeamBo;
+import org.dromara.hotel.domain.vo.KfGuestTeamRVo;
 import org.dromara.hotel.domain.vo.KfTeamVo;
 import org.dromara.hotel.mapper.KfGuestMapper;
 import org.dromara.hotel.mapper.KfGuestTeamRMapper;
 import org.dromara.hotel.mapper.KfTeamMapper;
+import org.dromara.hotel.service.IKfGuestService;
 import org.dromara.hotel.service.IKfTeamService;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -28,6 +33,7 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Stream;
 
 /**
  * 客团信息Service业务层处理
@@ -40,7 +46,8 @@ import java.util.Map;
 public class KfTeamServiceImpl implements IKfTeamService {
 
     private final KfTeamMapper baseMapper;
-    private final KfGuestMapper guestMapper;
+//    private final KfGuestMapper guestMapper;
+    private final IKfGuestService guestService;
     private final KfGuestTeamRMapper relationMapper;
 
     /**
@@ -119,29 +126,8 @@ public class KfTeamServiceImpl implements IKfTeamService {
         validEntityBeforeSave(add);
         //1.新增客团信息
         boolean flag = baseMapper.insert(add) > 0;
-        if (flag) {
-            bo.setId(add.getId());
-            //2.新增客人信息
-            List<KfGuestBo> guestBoList = bo.getGuestList();
-            if (guestBoList != null && guestBoList.size() > 0) {
-                List<Long> guestIdList =
-                    new java.util.ArrayList<>(guestBoList.stream().filter(item -> item.getId() != null).map(item -> item.getId()).toList());
-                List<KfGuestBo> noIdBoList = guestBoList.stream().filter(item -> item.getId() == null).toList();
-                if (noIdBoList != null && noIdBoList.size() > 0) {
-                    Collection<KfGuest> noIdList = MapstructUtils.convert(noIdBoList, KfGuest.class);
-                    guestMapper.insertBatch(noIdList);
-                    guestIdList.addAll(noIdList.stream().map(KfGuest::getId).toList());
-                }
-                //3.新增客人客团关系
-                List<KfGuestTeamR> relations = guestIdList.stream().map(item -> {
-                    KfGuestTeamR kfGuestTeamR = new KfGuestTeamR();
-                    kfGuestTeamR.setGuestId(item);
-                    kfGuestTeamR.setTeamId(bo.getId());
-                    kfGuestTeamR.setCheckInStatus(HotelBusinessConstants.NO);
-                    return kfGuestTeamR;
-                }).toList();
-                relationMapper.insertBatch(relations);
-            }
+        if (flag && bo.getGuestList().size() > 0) {
+            addGuestTeamR(add.getId(), bo.getGuestList());
         }
         return flag;
     }
@@ -158,35 +144,44 @@ public class KfTeamServiceImpl implements IKfTeamService {
         validEntityBeforeSave(update);
         //1.修改客团信息
         boolean flag = baseMapper.updateById(update) > 0;
-        //2.过滤已在该团的客人
-        List<Long> dbGuestIds =
-            relationMapper.selectObjs(Wrappers.lambdaQuery(KfGuestTeamR.class)
-                .select(KfGuestTeamR::getGuestId).eq(KfGuestTeamR::getTeamId, bo.getId()));
-        List<KfGuestBo> newGuests =
-            bo.getGuestList().stream().filter(item -> !dbGuestIds.contains(item.getId())).toList();
-        //3.处理新的客人
+        //2.更新客团成员
+        List<KfGuestTeamRBo> newGuests = bo.getGuestList();
         if (newGuests.size() > 0) {
-            List<Long> guestIdList =
-                new java.util.ArrayList<>(newGuests.stream().filter(item -> item.getId() != null).map(item -> item.getId()).toList());
-            List<KfGuestBo> noIdBoList = newGuests.stream().filter(item -> item.getId() == null).toList();
-            if (noIdBoList != null && noIdBoList.size() > 0) {
-                Collection<KfGuest> noIdList = MapstructUtils.convert(noIdBoList, KfGuest.class);
-                guestMapper.insertBatch(noIdList);
-                noIdList.forEach(item -> guestIdList.add(item.getId()));
-            }
-            //3.新增客人客团关系
-            List<KfGuestTeamR> relations = guestIdList.stream().map(item -> {
-                KfGuestTeamR kfGuestTeamR = new KfGuestTeamR();
-                kfGuestTeamR.setGuestId(item);
-                kfGuestTeamR.setTeamId(bo.getId());
-                kfGuestTeamR.setCheckInStatus(HotelBusinessConstants.NO);
-                return kfGuestTeamR;
-            }).toList();
-            relationMapper.insertBatch(relations);
+           addGuestTeamR(update.getId(), newGuests);
         }
         return flag;
     }
 
+    /** 新增客团成员*/
+    private R<String> addGuestTeamR(Long teamId, List<KfGuestTeamRBo> boList){
+        //1.新增客人
+        List guestBoList = boList.stream().filter(item -> item.getGuestId() == null).toList();
+        List<KfGuest> guests = BeanUtil.copyToList(guestBoList, KfGuest.class);
+        //插入客人信息
+        R<String> result = guestService.insertBatch(guests);
+
+        //2.新增客人客团关系
+        List<Long> existGuestIdList =
+            boList.stream()
+            .filter(item -> item.getGuestId() != null)
+            .map(item -> item.getGuestId()).toList();
+        List<Long> existGuestIdList1 = guests.stream().map(KfGuest::getId).toList();
+        //合并两个list
+        List<Long> allGuestIdList = Stream.concat(existGuestIdList.stream(), existGuestIdList1.stream()).toList();
+        List<KfGuestTeamR> relations = initGuestTeamRList(teamId, allGuestIdList);
+        relationMapper.insertBatch(relations);
+        return result;
+    }
+
+    private List<KfGuestTeamR> initGuestTeamRList(Long teamId, List<Long> guestIds) {
+        return guestIds.stream().map(item -> {
+            KfGuestTeamR kfGuestTeamR = new KfGuestTeamR();
+            kfGuestTeamR.setGuestId(item);
+            kfGuestTeamR.setTeamId(teamId);
+            kfGuestTeamR.setCheckInStatus(HotelBusinessConstants.NO);
+            return kfGuestTeamR;
+        }).toList();
+    }
     /**
      * 保存前的数据校验
      */

+ 3 - 2
ruoyi-modules/ruoyi-hotel/src/main/resources/mapper/hotel/basics/KfGuestTeamRMapper.xml

@@ -18,8 +18,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <result property="delFlag"    column="del_flag"    />
     </resultMap>
 
-    <select id="selectGuests" resultType="org.dromara.hotel.domain.vo.KfGuestVo">
-        select r.id, g.name, g.sex, g.id_card as idCard, g.phone, g.remark, g.create_time, g.create_by,g.data_source
+    <select id="selectGuests" resultType="org.dromara.hotel.domain.vo.KfGuestTeamRVo">
+        select r.id, g.id as guestId, g.name, g.sex, g.id_card as idCard, g.phone, g.remark, g.create_time,
+        g.create_by,g.data_source, r.check_in_status as checkInStatus
         from t_kf_guest_team_r r
             left join t_kf_guest g on r.guest_id = g.id
         <where>