Эх сурвалжийг харах

Merge remote-tracking branch 'origin/master'

luoyb 1 жил өмнө
parent
commit
63cf698438
16 өөрчлөгдсөн 175 нэмэгдсэн , 9 устгасан
  1. 15 1
      ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/constant/HotelBusinessConstants.java
  2. 14 0
      ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/DateUtils.java
  3. 9 0
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/controller/KfGuestTeamRController.java
  4. 1 1
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/domain/KfGuest.java
  5. 1 1
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/domain/KfTeam.java
  6. 4 0
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/domain/bo/KfGuestBo.java
  7. 4 0
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/domain/bo/KfTeamBo.java
  8. 5 1
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/domain/vo/KfGuestVo.java
  9. 22 0
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/domain/vo/KfTeamVo.java
  10. 6 2
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/mapper/KfGuestTeamRMapper.java
  11. 6 0
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/service/IKfGuestTeamRService.java
  12. 6 0
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/service/impl/KfGuestTeamRServiceImpl.java
  13. 65 3
      ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/service/impl/KfTeamServiceImpl.java
  14. 1 0
      ruoyi-modules/ruoyi-hotel/src/main/resources/mapper/hotel/basics/KfGuestMapper.xml
  15. 15 0
      ruoyi-modules/ruoyi-hotel/src/main/resources/mapper/hotel/basics/KfGuestTeamRMapper.xml
  16. 1 0
      ruoyi-modules/ruoyi-hotel/src/main/resources/mapper/hotel/basics/KfTeamMapper.xml

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

@@ -6,7 +6,7 @@ package org.dromara.common.core.constant;
  * @description 客房管理系统业务常量
  */
 public class HotelBusinessConstants {
-
+    /** 订单状态*************************************/
     /** 预定 */
     public static final String ORDER_STATUS_YD = "1";
     /** 锁房 */
@@ -17,4 +17,18 @@ public class HotelBusinessConstants {
     public static final String ORDER_STATUS_QX = "4";
     /** 退房 */
     public static final String ORDER_STATUS_TF = "5";
+
+    /** 订单类型*************************************/
+    /** 散客 */
+    public static final String ORDER_TYPE_SK = "1";
+
+    /** 团客 */
+    public static final String ORDER_TYPE_TK = "2";
+
+    /** 是否*************************************/
+    /** 否 */
+    public static final String NO = "0";
+    /** 是 */
+    public static final String YES = "1";
+
 }

+ 14 - 0
ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/utils/DateUtils.java

@@ -191,4 +191,18 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     public static LocalDate lastDayOfMonth(int year, int month) {
         return firstDayOfMonth(year, month).plusMonths(1).minusDays(1);
     }
+
+    /**
+     * 判断时间是否在当前时间之前
+     */
+    public static boolean isBefore(Date date) {
+        return date.getTime() > getNowDate().getTime();
+    }
+
+    /**
+     * 判断时间是否在当前时间之后
+     */
+    public static boolean isAfter(Date date) {
+        return date.getTime() < getNowDate().getTime();
+    }
 }

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

@@ -6,6 +6,7 @@ import lombok.RequiredArgsConstructor;
 import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.constraints.*;
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.dromara.hotel.domain.vo.KfGuestVo;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.validation.annotation.Validated;
 import org.dromara.common.idempotent.annotation.RepeatSubmit;
@@ -46,6 +47,14 @@ public class KfGuestTeamRController extends BaseController {
         return kfGuestTeamRService.queryPageList(bo, pageQuery);
     }
 
+    /**
+     * 根据客团ID查询客人信息列表
+     */
+    @SaCheckPermission("basics:kfGuestTeam:list")
+    @GetMapping("/listGuestByTeamId")
+    public TableDataInfo<KfGuestVo> listGuestByTeamId(@RequestParam Long teamId, @RequestParam(required = false) String guestName) {
+        return TableDataInfo.build(kfGuestTeamRService.listGuests(teamId, guestName));
+    }
     /**
      * 导出客人客团关系列表
      */

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

@@ -56,5 +56,5 @@ public class KfGuest extends TenantEntity {
      */
     private String otherId;
 
-
+    private String dataSource;
 }

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

@@ -65,5 +65,5 @@ public class KfTeam extends TenantEntity {
     @TableLogic
     private String delFlag;
 
-
+    private String dataSource;
 }

+ 4 - 0
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/domain/bo/KfGuestBo.java

@@ -57,4 +57,8 @@ public class KfGuestBo extends BaseEntity {
      * 统一标识
      */
     private String otherId;
+    /**
+     * 数据来源
+     */
+    private String dataSource;
 }

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

@@ -7,6 +7,7 @@ import org.dromara.common.mybatis.core.domain.BaseEntity;
 import org.dromara.hotel.domain.KfTeam;
 
 import java.util.Date;
+import java.util.List;
 
 /**
  * 客团信息业务对象 t_kf_team
@@ -59,4 +60,7 @@ public class KfTeamBo extends BaseEntity {
      */
     private String tenantId;
 
+    private String dataSource;
+
+    private List<KfGuestBo> guestList;
 }

+ 5 - 1
ruoyi-modules/ruoyi-hotel/src/main/java/org/dromara/hotel/domain/vo/KfGuestVo.java

@@ -81,5 +81,9 @@ public class KfGuestVo implements Serializable {
     @ExcelProperty(value = "创建时间")
     private Date createTime;
 
-
+    /**
+     * 数据来源
+     */
+    @ExcelProperty(value = "数据来源", converter = ExcelDictConvert.class)
+    private String dataSource;
 }

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

@@ -2,6 +2,7 @@ package org.dromara.hotel.domain.vo;
 
 import java.util.Date;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import org.dromara.common.core.utils.DateUtils;
 import org.dromara.hotel.domain.KfTeam;
 import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
 import com.alibaba.excel.annotation.ExcelProperty;
@@ -72,5 +73,26 @@ public class KfTeamVo implements Serializable {
     @ExcelProperty(value = "原始数据ID")
     private String otherId;
 
+    /**
+     * 数据来源
+     */
+    @ExcelProperty(value = "数据来源", converter = ExcelDictConvert.class)
+    private String dataSource;
+
+    private String teamStatus;
+
+    public String getTeamStatus() {
+        if(DateUtils.isBefore(this.startTime)){
+            this.teamStatus = "未开始";
+        }else if(DateUtils.isAfter(this.endTime)){
+            this.teamStatus = "已结束";
+        }else {
+            this.teamStatus = "进行中";
+        }
+        return teamStatus;
+    }
 
+    public void setTeamStatus(String teamStatus) {
+        this.teamStatus = teamStatus;
+    }
 }

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

@@ -1,8 +1,12 @@
 package org.dromara.hotel.mapper;
 
+import org.apache.ibatis.annotations.Param;
+import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
 import org.dromara.hotel.domain.KfGuestTeamR;
 import org.dromara.hotel.domain.vo.KfGuestTeamRVo;
-import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
+import org.dromara.hotel.domain.vo.KfGuestVo;
+
+import java.util.List;
 
 /**
  * 客人客团关系Mapper接口
@@ -11,5 +15,5 @@ import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
  * @date 2024-11-17
  */
 public interface KfGuestTeamRMapper extends BaseMapperPlus<KfGuestTeamR, KfGuestTeamRVo> {
-
+    List<KfGuestVo> selectGuests(@Param("teamId") Long teamId, @Param("guestName") String guestName);
 }

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

@@ -4,6 +4,7 @@ import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.hotel.domain.bo.KfGuestTeamRBo;
 import org.dromara.hotel.domain.vo.KfGuestTeamRVo;
+import org.dromara.hotel.domain.vo.KfGuestVo;
 
 import java.util.Collection;
 import java.util.List;
@@ -73,4 +74,9 @@ public interface IKfGuestTeamRService {
      * @return 设置结果
      */
     boolean setGuestTeam(KfGuestTeamRBo bo);
+
+    /**
+     * 根据客团ID查询客人信息
+     */
+    List<KfGuestVo> listGuests(Long teamId, String guestName);
 }

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

@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.RequiredArgsConstructor;
+import org.dromara.hotel.domain.vo.KfGuestVo;
 import org.springframework.stereotype.Service;
 import org.dromara.hotel.domain.bo.KfGuestTeamRBo;
 import org.dromara.hotel.domain.vo.KfGuestTeamRVo;
@@ -164,4 +165,9 @@ public class KfGuestTeamRServiceImpl implements IKfGuestTeamRService {
             return baseMapper.insert(entity) > 0;
         }
     }
+
+    @Override
+    public List<KfGuestVo> listGuests(Long teamId, String guestName) {
+        return baseMapper.selectGuests(teamId, guestName);
+    }
 }

+ 65 - 3
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 org.dromara.common.core.constant.HotelBusinessConstants;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -9,12 +10,19 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.RequiredArgsConstructor;
+import org.dromara.hotel.domain.KfGuest;
+import org.dromara.hotel.domain.KfGuestTeamR;
+import org.dromara.hotel.domain.bo.KfGuestBo;
+import org.dromara.hotel.mapper.KfGuestMapper;
+import org.dromara.hotel.mapper.KfGuestTeamRMapper;
+import org.dromara.hotel.service.IKfGuestService;
 import org.springframework.stereotype.Service;
 import org.dromara.hotel.domain.bo.KfTeamBo;
 import org.dromara.hotel.domain.vo.KfTeamVo;
 import org.dromara.hotel.domain.KfTeam;
 import org.dromara.hotel.mapper.KfTeamMapper;
 import org.dromara.hotel.service.IKfTeamService;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Date;
 import java.util.List;
@@ -32,6 +40,8 @@ import java.util.Collection;
 public class KfTeamServiceImpl implements IKfTeamService {
 
     private final KfTeamMapper baseMapper;
+    private final KfGuestMapper guestMapper;
+    private final KfGuestTeamRMapper relationMapper;
 
     /**
      * 查询客团信息
@@ -74,10 +84,11 @@ public class KfTeamServiceImpl implements IKfTeamService {
         Map<String, Object> params = bo.getParams();
         LambdaQueryWrapper<KfTeam> lqw = Wrappers.lambdaQuery();
         lqw.like(StringUtils.isNotBlank(bo.getName()), KfTeam::getName, bo.getName());
-        lqw.eq(bo.getStartTime() != null, KfTeam::getStartTime, bo.getStartTime());
-        lqw.eq(bo.getEndTime() != null, KfTeam::getEndTime, bo.getEndTime());
+        lqw.between(params.get("beginStartTime") != null && params.get("endStartTime") != null,
+            KfTeam::getStartTime, params.get("beginStartTime"), params.get("endStartTime"));
         lqw.eq(bo.getPlanQuantity() != null, KfTeam::getPlanQuantity, bo.getPlanQuantity());
         lqw.eq(StringUtils.isNotBlank(bo.getOtherId()), KfTeam::getOtherId, bo.getOtherId());
+        lqw.orderByDesc(KfTeam::getStartTime);
         return lqw;
     }
 
@@ -102,12 +113,35 @@ public class KfTeamServiceImpl implements IKfTeamService {
      * @return 是否新增成功
      */
     @Override
+    @Transactional
     public Boolean insertByBo(KfTeamBo bo) {
         KfTeam add = MapstructUtils.convert(bo, KfTeam.class);
         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 =
+                    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);
+                    noIdList.stream().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);
+            }
         }
         return flag;
     }
@@ -122,7 +156,35 @@ public class KfTeamServiceImpl implements IKfTeamService {
     public Boolean updateByBo(KfTeamBo bo) {
         KfTeam update = MapstructUtils.convert(bo, KfTeam.class);
         validEntityBeforeSave(update);
-        return baseMapper.updateById(update) > 0;
+        //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.处理新的客人
+        if(newGuests.size() > 0){
+            List<Long> guestIdList =
+                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.stream().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);
+        }
+        return flag;
     }
 
     /**

+ 1 - 0
ruoyi-modules/ruoyi-hotel/src/main/resources/mapper/hotel/basics/KfGuestMapper.xml

@@ -17,5 +17,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <result property="createTime"    column="create_time"    />
             <result property="updateBy"    column="update_by"    />
             <result property="updateTime"    column="update_time"    />
+            <result property="dataSource" column="data_source" />
     </resultMap>
 </mapper>

+ 15 - 0
ruoyi-modules/ruoyi-hotel/src/main/resources/mapper/hotel/basics/KfGuestTeamRMapper.xml

@@ -17,4 +17,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <result property="tenantId"    column="tenant_id"    />
             <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 from t_kf_guest_team_r r
+            left join t_kf_guest g on r.guest_id = g.id
+        <where>
+            r.del_flag = 0
+            <if test="teamId != null">
+                and r.team_id = #{teamId}
+            </if>
+            <if test="guestName != null and guestName != ''">
+                and g.name like concat('%', #{guestName}, '%')
+            </if>
+        </where>
+        order by r.id desc
+    </select>
 </mapper>

+ 1 - 0
ruoyi-modules/ruoyi-hotel/src/main/resources/mapper/hotel/basics/KfTeamMapper.xml

@@ -19,5 +19,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <result property="createDept"    column="create_dept"    />
             <result property="tenantId"    column="tenant_id"    />
             <result property="delFlag"    column="del_flag"    />
+            <result property="dataSource" column="data_source" />
     </resultMap>
 </mapper>