预约段 接口
This commit is contained in:
@@ -0,0 +1,122 @@
|
|||||||
|
package com.czg.controller.admin;
|
||||||
|
|
||||||
|
import com.czg.account.dto.BkOrderDTO;
|
||||||
|
import com.czg.account.dto.calltable.CallTablePage;
|
||||||
|
import com.czg.account.entity.BkContactList;
|
||||||
|
import com.czg.account.entity.BkOrder;
|
||||||
|
import com.czg.account.service.BkContactListService;
|
||||||
|
import com.czg.account.service.BkOrderService;
|
||||||
|
import com.czg.account.vo.BkTableVO;
|
||||||
|
import com.czg.annotation.SaAdminCheckPermission;
|
||||||
|
import com.czg.resp.CzgResult;
|
||||||
|
import com.czg.sa.StpKit;
|
||||||
|
import com.czg.utils.AssertUtil;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约端-联系人列表
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/bk/notify")
|
||||||
|
@Slf4j
|
||||||
|
public class BkContactListController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BkContactListService contactListService;
|
||||||
|
@Resource
|
||||||
|
private BkOrderService bkOrderService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通讯录 获取联系人订单数等
|
||||||
|
*/
|
||||||
|
// @SaAdminCheckPermission(value = "bk:bkContactList:list", name = "预约端-联系人列表")
|
||||||
|
@PostMapping("/contactList")
|
||||||
|
public CzgResult<List<BkContactList>> getUserList(@RequestBody Set<String> phones) {
|
||||||
|
return CzgResult.success(contactListService.getUserList(StpKit.USER.getShopId(), phones));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约端-台桌:查询台桌列表
|
||||||
|
*/
|
||||||
|
// @SaAdminCheckPermission(value = "bk:bkOrder:table", name = "预约端-台桌:查询台桌列表")
|
||||||
|
@GetMapping("/bkOrder/table")
|
||||||
|
public CzgResult<List<BkTableVO>> table(@RequestParam(value = "areaId", required = false) Long areaId,
|
||||||
|
@RequestParam LocalDate day,
|
||||||
|
@RequestParam(value = "seatTimeType", required = false) String seatTimeType) {
|
||||||
|
List<BkTableVO> tables = bkOrderService.table(StpKit.USER.getShopId(), areaId, day, seatTimeType);
|
||||||
|
return CzgResult.success(tables);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约端-台桌:查询台桌列表
|
||||||
|
*/
|
||||||
|
// @SaAdminCheckPermission(value = "bk:bkOrder:bookings", name = "预约端-预约单:列表")
|
||||||
|
@GetMapping("/bkOrder/bookings")
|
||||||
|
public CzgResult<List<BkOrder>> bookings(@RequestParam(required = false) String search,
|
||||||
|
@RequestParam(required = false) LocalDate start,
|
||||||
|
@RequestParam(required = false) LocalDate end,
|
||||||
|
@RequestParam(required = false) String status) {
|
||||||
|
List<BkOrder> tables = bkOrderService.bookings(StpKit.USER.getShopId(), search, start, end, status);
|
||||||
|
return CzgResult.success(tables);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约端-预约单:预约/修改预约
|
||||||
|
*/
|
||||||
|
// @SaAdminCheckPermission(value = "bk:bkOrder:booking", name = "预约端-预约单:预约")
|
||||||
|
@PostMapping("/bkOrder/booking")
|
||||||
|
public CzgResult<Void> booking(@RequestBody BkOrderDTO bkOrder) {
|
||||||
|
Long shopId = StpKit.USER.getShopId();
|
||||||
|
if (bkOrder.getShopId() != null && !bkOrder.getShopId().equals(shopId)) {
|
||||||
|
return CzgResult.failure("违规操作");
|
||||||
|
}
|
||||||
|
bkOrderService.booking(shopId, bkOrder);
|
||||||
|
return CzgResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约端-预约单:取消预约
|
||||||
|
*/
|
||||||
|
// @SaAdminCheckPermission(value = "bk:bkOrder:booking", name = "预约端-预约单:取消预约")
|
||||||
|
@PostMapping("/bkOrder/cancel")
|
||||||
|
public CzgResult<Void> cancel(@RequestBody BkOrderDTO bkOrder) {
|
||||||
|
AssertUtil.isNull(bkOrder.getId(), "需要撤销的预约单id不能为空");
|
||||||
|
bkOrderService.upStatus(StpKit.USER.getShopId(), "已取消", bkOrder.getId(), bkOrder.getCancelReason());
|
||||||
|
return CzgResult.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
|
||||||
|
package com.czg.account.dto;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import com.czg.account.entity.BkOrderTable;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约单 实体类。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-11-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class BkOrderDTO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private Long shopId;
|
||||||
|
/**
|
||||||
|
* 预约用餐人数
|
||||||
|
*/
|
||||||
|
private Integer seatNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 就餐类型 普通用餐
|
||||||
|
*/
|
||||||
|
private String seatType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注 80字以内
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 就餐时段类型 午餐/晚餐
|
||||||
|
*/
|
||||||
|
private String seatTimeType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 来电电话
|
||||||
|
*/
|
||||||
|
private String callPhone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 来电用户名
|
||||||
|
*/
|
||||||
|
private String callUsername;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预留电话
|
||||||
|
*/
|
||||||
|
private String bookingPhone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预留称呼
|
||||||
|
*/
|
||||||
|
private String bookingUsername;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预定台桌
|
||||||
|
*/
|
||||||
|
private List<BkOrderTable> bookingTables;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预定台桌数
|
||||||
|
*/
|
||||||
|
private Integer bookingTableNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约的到店时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime bookingTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 餐标
|
||||||
|
*/
|
||||||
|
private BigDecimal standardPrice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 元/人 元/桌
|
||||||
|
*/
|
||||||
|
private String standardPriceType;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消原因 80字限制
|
||||||
|
*/
|
||||||
|
private String cancelReason;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package com.czg.account.entity;
|
||||||
|
|
||||||
|
import com.mybatisflex.annotation.Column;
|
||||||
|
import com.mybatisflex.annotation.Id;
|
||||||
|
import com.mybatisflex.annotation.KeyType;
|
||||||
|
import com.mybatisflex.annotation.Table;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通讯录联系人列表 实体类。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-11-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Table("bk_contact_list")
|
||||||
|
public class BkContactList implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 暂无意义
|
||||||
|
*/
|
||||||
|
@Id(keyType = KeyType.Auto)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺
|
||||||
|
*/
|
||||||
|
private Long shopId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电话号码
|
||||||
|
*/
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 历史订单数
|
||||||
|
*/
|
||||||
|
@Column(ignore = true)
|
||||||
|
private Integer orderNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消数
|
||||||
|
*/
|
||||||
|
@Column(ignore = true)
|
||||||
|
private Integer cannelNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后一次预约时间
|
||||||
|
*/
|
||||||
|
@Column(ignore = true)
|
||||||
|
private LocalDateTime lastBookingTime;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
package com.czg.account.entity;
|
||||||
|
|
||||||
|
import com.mybatisflex.annotation.Column;
|
||||||
|
import com.mybatisflex.annotation.Id;
|
||||||
|
import com.mybatisflex.annotation.KeyType;
|
||||||
|
import com.mybatisflex.annotation.Table;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约单 实体类。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-11-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Table("bk_order")
|
||||||
|
public class BkOrder implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 暂无意义
|
||||||
|
*/
|
||||||
|
@Id(keyType = KeyType.Auto)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺
|
||||||
|
*/
|
||||||
|
private Long shopId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约订单号
|
||||||
|
*/
|
||||||
|
private String bookingOrderNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约用餐人数
|
||||||
|
*/
|
||||||
|
private Integer seatNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 就餐类型 普通用餐
|
||||||
|
*/
|
||||||
|
private String seatType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@Column(onInsertValue = "now()")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注 80字以内
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态 '待到店', '已到店', '已超时', '已取消'
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 就餐时段类型 午餐/晚餐
|
||||||
|
*/
|
||||||
|
private String seatTimeType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 来电电话
|
||||||
|
*/
|
||||||
|
private String callPhone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 来电用户名
|
||||||
|
*/
|
||||||
|
private String callUsername;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预留电话
|
||||||
|
*/
|
||||||
|
private String bookingPhone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预留称呼
|
||||||
|
*/
|
||||||
|
private String bookingUsername;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预定台桌数
|
||||||
|
*/
|
||||||
|
private Integer bookingTableNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 餐标 钱
|
||||||
|
*/
|
||||||
|
private BigDecimal standardPrice;
|
||||||
|
/**
|
||||||
|
* 餐标 元/人 元/桌 字符串表示
|
||||||
|
*/
|
||||||
|
private String standardPriceStr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自留字段 钱 元/人
|
||||||
|
*/
|
||||||
|
private BigDecimal standardPricePerson;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约的到店时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime bookingTime;
|
||||||
|
/**
|
||||||
|
* 修改预约时间 (修改预约的到店时间) 触发的时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime upBookingTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消原因 80字限制
|
||||||
|
*/
|
||||||
|
private String cancelReason;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 到店时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime arrivalTime;
|
||||||
|
/**
|
||||||
|
* 取消时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime cancelTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约的台桌名称
|
||||||
|
*/
|
||||||
|
@Column(ignore = true)
|
||||||
|
private String tableInFos;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package com.czg.account.entity;
|
||||||
|
|
||||||
|
import com.mybatisflex.annotation.Id;
|
||||||
|
import com.mybatisflex.annotation.KeyType;
|
||||||
|
import com.mybatisflex.annotation.Table;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约单台桌关联 实体类。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-11-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Table("bk_order_table")
|
||||||
|
public class BkOrderTable implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 暂无意义
|
||||||
|
*/
|
||||||
|
@Id(keyType = KeyType.Auto)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺
|
||||||
|
*/
|
||||||
|
private Long shopId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约单Id
|
||||||
|
*/
|
||||||
|
private Long bookOrderId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 台桌区域id
|
||||||
|
*/
|
||||||
|
private Long tableAreaId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 台桌区域名称
|
||||||
|
*/
|
||||||
|
private String tableAreaName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 台桌id
|
||||||
|
*/
|
||||||
|
private Long tableId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 台桌名称
|
||||||
|
*/
|
||||||
|
private String tableName;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.czg.account.service;
|
||||||
|
|
||||||
|
import com.mybatisflex.core.service.IService;
|
||||||
|
import com.czg.account.entity.BkContactList;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通讯录联系人列表 服务层。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-11-27
|
||||||
|
*/
|
||||||
|
public interface BkContactListService extends IService<BkContactList> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户联系人列表
|
||||||
|
*
|
||||||
|
* @param shopId 店铺id
|
||||||
|
* @param phones 电话号码列表
|
||||||
|
* @return 联系人列表
|
||||||
|
*/
|
||||||
|
List<BkContactList> getUserList(Long shopId, Set<String> phones);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package com.czg.account.service;
|
||||||
|
|
||||||
|
import com.czg.account.dto.BkOrderDTO;
|
||||||
|
import com.czg.account.vo.BkTableVO;
|
||||||
|
import com.mybatisflex.core.service.IService;
|
||||||
|
import com.czg.account.entity.BkOrder;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约单 服务层。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-11-27
|
||||||
|
*/
|
||||||
|
public interface BkOrderService extends IService<BkOrder> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询预约单列表
|
||||||
|
* @param shopId 店铺id
|
||||||
|
* @param search 搜索关键词 客户姓名/客户手机号
|
||||||
|
* @param start 开始日期
|
||||||
|
* @param end 结束日期
|
||||||
|
* @param status 预约单状态
|
||||||
|
* @return 预约单列表
|
||||||
|
*/
|
||||||
|
List<BkOrder> bookings(Long shopId, String search, LocalDate start, LocalDate end, String status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约
|
||||||
|
*/
|
||||||
|
void booking(Long shopId, BkOrderDTO bkOrder);
|
||||||
|
/**
|
||||||
|
* 更新预约状态
|
||||||
|
* @param shopId 店铺id
|
||||||
|
* @param status 预约单状态 已取消/已到店
|
||||||
|
* @param bkOrderId 预约单id
|
||||||
|
* @param cancelReason 取消原因
|
||||||
|
*/
|
||||||
|
void upStatus(Long shopId, String status, Long bkOrderId,String cancelReason);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询台桌列表
|
||||||
|
* @param shopId 店铺id
|
||||||
|
* @param areaId 区域id
|
||||||
|
* @param day 预约日期
|
||||||
|
* @param seatTimeType 预约时间类型
|
||||||
|
* @return 台桌列表
|
||||||
|
*/
|
||||||
|
List<BkTableVO> table(Long shopId, Long areaId, LocalDate day, String seatTimeType);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.czg.account.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ww
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BkTableVO {
|
||||||
|
private Long areaId;
|
||||||
|
|
||||||
|
private String areaName;
|
||||||
|
|
||||||
|
private List<BkTableVO.tableVO> tables;
|
||||||
|
|
||||||
|
record tableVO(
|
||||||
|
String tableName, List<BkOrder> bkOrders
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
record BkOrder(
|
||||||
|
String callPhone, String callUsername, String bookingPhone, String bookingUsername
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.czg.service.account.mapper;
|
||||||
|
|
||||||
|
import com.mybatisflex.core.BaseMapper;
|
||||||
|
import com.czg.account.entity.BkContactList;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通讯录联系人列表 映射层。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-11-27
|
||||||
|
*/
|
||||||
|
public interface BkContactListMapper extends BaseMapper<BkContactList> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取店铺的通讯录联系人列表
|
||||||
|
* @param shopId 店铺ID
|
||||||
|
* @return 通讯录联系人列表
|
||||||
|
*/
|
||||||
|
List<BkContactList> getUserList(Long shopId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.czg.service.account.mapper;
|
||||||
|
|
||||||
|
import com.mybatisflex.core.BaseMapper;
|
||||||
|
import com.czg.account.entity.BkOrder;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约单 映射层。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-11-27
|
||||||
|
*/
|
||||||
|
public interface BkOrderMapper extends BaseMapper<BkOrder> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询预约单列表
|
||||||
|
*/
|
||||||
|
List<BkOrder> bookings(Long shopId, String search, LocalDate start, LocalDate end, String status);
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.czg.service.account.mapper;
|
||||||
|
|
||||||
|
import com.czg.account.vo.BkTableVO;
|
||||||
|
import com.mybatisflex.core.BaseMapper;
|
||||||
|
import com.czg.account.entity.BkOrderTable;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约单台桌关联 映射层。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-11-27
|
||||||
|
*/
|
||||||
|
public interface BkOrderTableMapper extends BaseMapper<BkOrderTable> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量插入预约单台桌关联
|
||||||
|
*
|
||||||
|
* @param shopId 店铺id
|
||||||
|
* @param bookOrderId 预约单id
|
||||||
|
* @param bkOrderTables 台桌信息
|
||||||
|
*/
|
||||||
|
void customInsertBatch(Long shopId, Long bookOrderId, List<BkOrderTable> bkOrderTables);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询预约单台桌关联
|
||||||
|
*
|
||||||
|
* @param shopId 店铺id
|
||||||
|
* @param areaId 台桌区域id
|
||||||
|
* @param day 预约日期
|
||||||
|
* @param seatTimeType 预约时间类型
|
||||||
|
* @return 预约单台桌关联列表
|
||||||
|
*/
|
||||||
|
List<BkTableVO> table(Long shopId, Long areaId, LocalDate day, String seatTimeType);
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.czg.service.account.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
|
import com.czg.account.entity.BkContactList;
|
||||||
|
import com.czg.account.service.BkContactListService;
|
||||||
|
import com.czg.service.account.mapper.BkContactListMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通讯录联系人列表 服务层实现。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-11-27
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class BkContactListServiceImpl extends ServiceImpl<BkContactListMapper, BkContactList> implements BkContactListService{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BkContactList> getUserList(Long shopId, Set<String> phones) {
|
||||||
|
remove(QueryWrapper.create().eq(BkContactList::getShopId, shopId));
|
||||||
|
saveBatch(phones.stream()
|
||||||
|
.filter(StrUtil::isNotEmpty)
|
||||||
|
.map(phone -> {
|
||||||
|
BkContactList bkContact = new BkContactList();
|
||||||
|
bkContact.setShopId(shopId);
|
||||||
|
bkContact.setPhone(phone.trim());
|
||||||
|
return bkContact;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
return mapper.getUserList(shopId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
package com.czg.service.account.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import com.czg.account.dto.BkOrderDTO;
|
||||||
|
import com.czg.account.entity.BkOrderTable;
|
||||||
|
import com.czg.account.vo.BkTableVO;
|
||||||
|
import com.czg.exception.CzgException;
|
||||||
|
import com.czg.service.account.mapper.BkOrderTableMapper;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import com.mybatisflex.core.update.UpdateWrapper;
|
||||||
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
|
import com.czg.account.entity.BkOrder;
|
||||||
|
import com.czg.account.service.BkOrderService;
|
||||||
|
import com.czg.service.account.mapper.BkOrderMapper;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约单 服务层实现。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-11-27
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class BkOrderServiceImpl extends ServiceImpl<BkOrderMapper, BkOrder> implements BkOrderService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BkOrderTableMapper tableMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约端-预约单:列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<BkOrder> bookings(Long shopId, String search, LocalDate start, LocalDate end, String status) {
|
||||||
|
return mapper.bookings(shopId, search, start, end, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void booking(Long shopId, BkOrderDTO bkOrder) {
|
||||||
|
BkOrder bkOrderEntity = BeanUtil.copyProperties(bkOrder, BkOrder.class);
|
||||||
|
bkOrderEntity.setShopId(shopId);
|
||||||
|
if (bkOrder.getId() != null) {
|
||||||
|
bkOrderEntity.setUpBookingTime(LocalDateTime.now());
|
||||||
|
tableMapper.deleteByQuery(QueryWrapper.create().eq(BkOrderTable::getBookOrderId, bkOrderEntity.getId()));
|
||||||
|
tableMapper.customInsertBatch(shopId, bkOrderEntity.getId(), bkOrder.getBookingTables());
|
||||||
|
} else {
|
||||||
|
bkOrderEntity.setBookingOrderNo("BK" + IdUtil.getSnowflakeNextId());
|
||||||
|
}
|
||||||
|
|
||||||
|
bkOrderEntity.setStatus("待到店");
|
||||||
|
bkOrderEntity.setStandardPricePerson(BigDecimal.ZERO);
|
||||||
|
if (bkOrderEntity.getStandardPrice() != null && bkOrderEntity.getStandardPrice().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
if (bkOrderEntity.getStandardPriceStr().contains("桌")) {
|
||||||
|
BigDecimal seatNumBd = new BigDecimal(bkOrderEntity.getSeatNum());
|
||||||
|
BigDecimal bookingTableNumBd = new BigDecimal(bkOrderEntity.getBookingTableNum());
|
||||||
|
BigDecimal seatPerTable = seatNumBd.divide(bookingTableNumBd, 2, RoundingMode.HALF_UP);
|
||||||
|
BigDecimal divide = bkOrderEntity.getStandardPrice().divide(seatPerTable, 2, RoundingMode.HALF_UP);
|
||||||
|
bkOrderEntity.setStandardPricePerson(divide);
|
||||||
|
} else {
|
||||||
|
bkOrderEntity.setStandardPricePerson(bkOrderEntity.getStandardPrice());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
saveOrUpdate(bkOrderEntity);
|
||||||
|
if (bkOrder.getId() == null) {
|
||||||
|
tableMapper.customInsertBatch(shopId, bkOrderEntity.getId(), bkOrder.getBookingTables());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void upStatus(Long shopId, String status, Long bkOrderId, String cancelReason) {
|
||||||
|
BkOrder upBkOrder = new BkOrder();
|
||||||
|
if ("已取消".equals(status)) {
|
||||||
|
upBkOrder.setStatus(status);
|
||||||
|
upBkOrder.setCancelReason(cancelReason);
|
||||||
|
upBkOrder.setCancelTime(LocalDateTime.now());
|
||||||
|
} else if ("已到店".equals(status)) {
|
||||||
|
upBkOrder.setStatus(status);
|
||||||
|
upBkOrder.setArrivalTime(LocalDateTime.now());
|
||||||
|
}
|
||||||
|
boolean update = update(upBkOrder, QueryWrapper.create().eq(BkOrder::getId, bkOrderId).eq(BkOrder::getShopId, shopId));
|
||||||
|
if (!update) {
|
||||||
|
throw new CzgException("修改失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BkTableVO> table(Long shopId, Long areaId, LocalDate day, String seatTimeType) {
|
||||||
|
return tableMapper.table(shopId, areaId, day, seatTimeType);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.czg.service.account.mapper.BkContactListMapper">
|
||||||
|
|
||||||
|
<select id="getUserList" resultType="com.czg.account.entity.BkContactList">
|
||||||
|
SELECT
|
||||||
|
`order`.call_phone AS phone,
|
||||||
|
count( 1 ) AS orderNum,
|
||||||
|
sum( CASE `order`.`status` WHEN '已取消' THEN 1 ELSE 0 END ) AS cannelNum,
|
||||||
|
MAX(`order`.create_time) AS lastBookingTime
|
||||||
|
FROM
|
||||||
|
`bk_order` `order`
|
||||||
|
INNER JOIN bk_contact_list contact ON `order`.call_phone = contact.phone AND contact.shop_id = #{shopId}
|
||||||
|
WHERE
|
||||||
|
`order`.shop_id = #{shopId}
|
||||||
|
GROUP BY `order`.call_phone
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.czg.service.account.mapper.BkOrderMapper">
|
||||||
|
|
||||||
|
<select id="bookings" resultType="com.czg.account.entity.BkOrder">
|
||||||
|
SELECT
|
||||||
|
o.*, IFNULL(GROUP_CONCAT(DISTINCT t.name SEPARATOR '、'), '') AS tableInFos
|
||||||
|
FROM bk_order o
|
||||||
|
LEFT JOIN bk_order_table t ON t.book_order_id = o.id
|
||||||
|
WHERE o.shop_id = #{shopId}
|
||||||
|
<if test="search != null and search != ''">
|
||||||
|
AND (o.call_username LIKE CONCAT('%', #{search}, '%')
|
||||||
|
OR o.call_phone LIKE CONCAT('%', #{search}, '%')
|
||||||
|
OR o.booking_username LIKE CONCAT('%', #{search}, '%')
|
||||||
|
OR o.booking_phone LIKE CONCAT('%', #{search}, '%'))
|
||||||
|
</if>
|
||||||
|
<if test="start != null and end != null">
|
||||||
|
AND o.booking_time >= CONCAT(#{start}, ' 00:00:00')
|
||||||
|
AND o.booking_time <= CONCAT(#{end}, ' 23:59:59')
|
||||||
|
</if>
|
||||||
|
<if test="status != null and status != ''">
|
||||||
|
<if test="status == '已超时'">
|
||||||
|
AND o.status = '待到店'
|
||||||
|
AND o.booking_time < DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s')
|
||||||
|
</if>
|
||||||
|
<if test="status != '已超时'">
|
||||||
|
AND o.status = #{status}
|
||||||
|
</if>
|
||||||
|
</if>
|
||||||
|
group by o.id
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.czg.service.account.mapper.BkOrderTableMapper">
|
||||||
|
|
||||||
|
<insert id="customInsertBatch">
|
||||||
|
insert into bk_order_table (shop_id, book_order_id, table_area_id ,table_area_name,table_id,table_name)
|
||||||
|
values
|
||||||
|
<foreach collection="bkOrderTables" item="item" separator=",">
|
||||||
|
(#{shopId}, #{bookOrderId}, #{item.tableAreaId}, #{item.tableAreaName}, #{item.tableId}, #{item.tableName})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="table" resultMap="BkTableVOResultMap">
|
||||||
|
SELECT
|
||||||
|
`table`.area_id,
|
||||||
|
`area`.`name` as area_name,
|
||||||
|
`table`.id as table_id,
|
||||||
|
`table`.`name` as table_name,
|
||||||
|
`order`.call_phone,
|
||||||
|
`order`.call_username,
|
||||||
|
`order`.booking_phone,
|
||||||
|
`order`.booking_username,
|
||||||
|
`order`.booking_time
|
||||||
|
FROM
|
||||||
|
`tb_shop_table` `table`
|
||||||
|
LEFT JOIN tb_shop_table_area `area` on `table`.area_id = `area`.id
|
||||||
|
LEFT JOIN bk_order `order` ON `table`.shop_id = `order`.shop_id
|
||||||
|
AND DATE(`order`.booking_time) = #{day}
|
||||||
|
<if test="seatTimeType != null and seatTimeType != ''">
|
||||||
|
AND `order`.seat_time_type = #{seatTimeType}
|
||||||
|
</if>
|
||||||
|
LEFT JOIN bk_order_table oTable on oTable.book_order_id = `order`.id
|
||||||
|
and `table`.id = oTable.table_id
|
||||||
|
WHERE
|
||||||
|
`table`.shop_id = #{shopId}
|
||||||
|
AND `table`.`status` != 'unbound'
|
||||||
|
<if test="areaId != null">
|
||||||
|
AND `table`.area_id = #{areaId}
|
||||||
|
</if>
|
||||||
|
ORDER BY `table`.area_id, `table`.id
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<resultMap id="BkTableVOResultMap" type="com.czg.account.vo.BkTableVO">
|
||||||
|
<result property="areaId" column="area_id"/>
|
||||||
|
<result property="areaName" column="area_name"/>
|
||||||
|
<collection property="tables" ofType="com.czg.account.vo.BkTableVO$tableVO">
|
||||||
|
<result property="tableName" column="table_name"/>
|
||||||
|
<collection property="bkOrders" ofType="com.czg.account.vo.BkTableVO$BkOrder">
|
||||||
|
<result property="callPhone" column="call_phone"/>
|
||||||
|
<result property="callUsername" column="call_username"/>
|
||||||
|
<result property="bookingPhone" column="booking_phone"/>
|
||||||
|
<result property="bookingUsername" column="booking_username"/>
|
||||||
|
</collection>
|
||||||
|
</collection>
|
||||||
|
</resultMap>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user