Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
张松
2024-11-22 17:20:51 +08:00
24 changed files with 1263 additions and 6 deletions

View File

@@ -0,0 +1,97 @@
package cn.ysk.cashier.controller.booking;
import cn.ysk.cashier.dto.booking.ShopTableBookingDTO;
import cn.ysk.cashier.mybatis.entity.TbShopTableBooking;
import cn.ysk.cashier.mybatis.service.TbShopTableBookingService;
import cn.ysk.cashier.pojo.shop.TbShopArea;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 店铺台桌预订
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-21
*/
@RestController
@RequestMapping("/api/booking/shop-table")
@Api(tags = "店铺台桌预订")
public class TbShopTableBookingController {
@Resource
private TbShopTableBookingService tbShopTableBookingService;
@GetMapping("page")
@ApiOperation("分页")
public ResponseEntity page(@RequestParam Map<String, Object> params) {
Map<String, Object> data = tbShopTableBookingService.page(params);
return ResponseEntity.ok().body(data);
}
@GetMapping("{id}")
@ApiOperation("信息")
public ResponseEntity get(@PathVariable("id") Long id) {
TbShopTableBooking data = tbShopTableBookingService.getById(id);
return ResponseEntity.ok().body(data);
}
@PostMapping
@ApiOperation("预订")
public ResponseEntity booking(@RequestBody TbShopTableBooking dto) {
String orderNo = tbShopTableBookingService.booking(dto);
Map<String, Object> data = new HashMap<>(2);
data.put("id", dto.getId());
data.put("orderNo", orderNo);
return ResponseEntity.ok().body(data);
}
@PutMapping
@ApiOperation("修改预订信息")
public ResponseEntity update(@RequestBody TbShopTableBooking dto) {
boolean ret = tbShopTableBookingService.update(dto);
return ResponseEntity.ok().body(ret);
}
@PostMapping("mark-status")
@ApiOperation("修改预订状态")
public ResponseEntity markStatus(@RequestBody TbShopTableBooking dto) {
tbShopTableBookingService.markStatus(dto.getId(), dto.getStatus());
return ResponseEntity.ok().build();
}
@DeleteMapping("/delete/{id}")
@ApiOperation("删除")
public ResponseEntity delete(@PathVariable("id") Long id) {
tbShopTableBookingService.delete(id);
return ResponseEntity.ok().build();
}
@GetMapping("sms/{id}")
@ApiOperation("获取待发送的短信内容")
public ResponseEntity sms(@PathVariable("id") Long id) {
String smsContent = tbShopTableBookingService.getBookingSms(id);
return ResponseEntity.ok().body(smsContent);
}
@GetMapping("area")
@ApiOperation("获取区域列表")
public ResponseEntity areaList(@RequestParam Integer shopId) {
List<TbShopArea> list = tbShopTableBookingService.findShopAreaList(shopId);
return ResponseEntity.ok().body(list);
}
@GetMapping("list")
@ApiOperation("获取台桌列表")
public ResponseEntity list(@RequestParam Map<String, Object> params) {
List<ShopTableBookingDTO> list = tbShopTableBookingService.findShopTableList(params);
return ResponseEntity.ok().body(list);
}
}

View File

@@ -0,0 +1,63 @@
package cn.ysk.cashier.controller.credit;
import cn.ysk.cashier.mybatis.entity.TbCreditBuyer;
import cn.ysk.cashier.mybatis.service.TbCreditBuyerService;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Map;
/**
* 挂账人
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-20
*/
@RestController
@RequestMapping("/api/credit/buyer")
@Tag(name = "挂账人")
public class TbCreditBuyerController {
@Resource
private TbCreditBuyerService tbCreditBuyerService;
@GetMapping("page")
@ApiOperation("分页")
public ResponseEntity page(@RequestParam Map<String, Object> params){
Map<String, Object> page = tbCreditBuyerService.page(params);
return ResponseEntity.ok().body(page);
}
@GetMapping("{id}")
@ApiOperation("信息")
public ResponseEntity get(@PathVariable("id") String id){
TbCreditBuyer data = tbCreditBuyerService.getById(id);
return ResponseEntity.ok().body(data);
}
@PostMapping
@ApiOperation("保存")
public ResponseEntity save(@RequestBody TbCreditBuyer entity){
boolean ret = tbCreditBuyerService.save(entity);
return ResponseEntity.ok().body(ret);
}
@PutMapping
@ApiOperation("修改")
public ResponseEntity update(@RequestBody TbCreditBuyer dto){
boolean ret = tbCreditBuyerService.update(dto);
return ResponseEntity.ok().body(ret);
}
@DeleteMapping("{id}")
@ApiOperation("删除")
public ResponseEntity delete(@PathVariable("id") String id){
tbCreditBuyerService.delete(id);
return ResponseEntity.ok().build();
}
}

View File

@@ -0,0 +1,48 @@
package cn.ysk.cashier.controller.credit;
import cn.ysk.cashier.mybatis.entity.TbCreditBuyerOrder;
import cn.ysk.cashier.mybatis.service.TbCreditBuyerOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Map;
/**
* 挂账账单
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-20
*/
@RestController
@RequestMapping("/api/credit/buyer-order")
@Api(tags = "挂账账单")
public class TbCreditBuyerOrderController {
@Resource
private TbCreditBuyerOrderService tbCreditBuyerOrderService;
@GetMapping("page")
@ApiOperation("分页")
public ResponseEntity page(@RequestParam Map<String, Object> params){
Map<String, Object> page = tbCreditBuyerOrderService.page(params);
return ResponseEntity.ok().body(page);
}
@PostMapping("pay")
@ApiOperation("付款")
public ResponseEntity pay(@RequestBody TbCreditBuyerOrder dto){
boolean ret = tbCreditBuyerOrderService.save(dto);
return ResponseEntity.ok().body(ret);
}
@GetMapping("summary")
@ApiOperation("统计")
public ResponseEntity summary(@RequestParam Map<String, Object> params){
Map<String, Object> data = tbCreditBuyerOrderService.summary(params);
return ResponseEntity.ok().body(data);
}
}

View File

@@ -0,0 +1,37 @@
package cn.ysk.cashier.controller.credit;
import cn.ysk.cashier.mybatis.service.TbCreditPaymentRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Map;
/**
* 挂账账单付款记录
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-20
*/
@RestController
@RequestMapping("/api/credit/payment-record")
@Api(tags = "挂账账单付款记录")
public class TbCreditPaymentRecordController {
@Resource
private TbCreditPaymentRecordService tbCreditPaymentRecordService;
@GetMapping("page")
@ApiOperation("分页")
public ResponseEntity page(@RequestParam Map<String, Object> params){
Map<String, Object> page = tbCreditPaymentRecordService.page(params);
return ResponseEntity.ok().body(page);
}
}

View File

@@ -0,0 +1,16 @@
package cn.ysk.cashier.dto.booking;
import cn.ysk.cashier.mybatis.entity.TbShopTableBooking;
import cn.ysk.cashier.pojo.shop.TbShopTable;
import lombok.Data;
/**
* 店铺台桌及预订信息
*
* @author tankaikai
* @since 2024-11-22 11:24
*/
@Data
public class ShopTableBookingDTO extends TbShopTable {
private TbShopTableBooking bookingInfo;
}

View File

@@ -15,9 +15,8 @@
*/
package cn.ysk.cashier.dto.shop;
import cn.ysk.cashier.enums.TableStateEnum;
import lombok.Data;
import cn.ysk.cashier.annotation.Query;
import lombok.Data;
import javax.validation.constraints.NotNull;
@@ -43,8 +42,22 @@ public class TbShopTableQueryCriteria{
@Query
private Long qrcode;
/**
* 是否接受网络预订
*/
@Query
private Integer isPredate;
private String state;
private Integer page = 1;
private Integer size = 99999;
public Integer getIsPredate() {
return isPredate;
}
public void setIsPredate(Integer isPredate) {
this.isPredate = isPredate;
}
}

View File

@@ -0,0 +1,96 @@
package cn.ysk.cashier.mybatis.entity;
import cn.hutool.core.util.NumberUtil;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/**
* 挂账人
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-20
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("tb_credit_buyer")
public class TbCreditBuyer {
private static final long serialVersionUID = 1L;
/**
* 挂账编码
*/
@TableId(type = IdType.ASSIGN_ID)
private String id;
/**
* 店铺id
*/
private Integer shopId;
/**
* 状态 1-启用 0-停用
*/
private Integer status;
/**
* 挂账人
*/
private String debtor;
/**
* 手机号
*/
private String mobile;
/**
* 职务
*/
private String position;
/**
* 挂账额度
*/
private BigDecimal creditAmount;
/**
* 还款方式 total-按总金额还款 order-按订单还款
*/
private String repaymentMethod;
/**
* 支付方式
*/
private String paymentMethod;
/**
* 备注
*/
private String remark;
/**
* 删除标志 0-正常 1-删除
*/
private Integer delFlag;
/**
* 已挂账金额
*/
@TableField(value = "(select sum(unpaid_amount) from view_credit_buyer_order where credit_buyer_id = id)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
private BigDecimal owedAmount;
/**
* 剩余挂账额度
*/
@TableField(exist = false)
private BigDecimal remainingAmount;
/**
* 累计挂账金额
*/
@TableField(value = "(select sum(pay_amount) from view_credit_buyer_order where credit_buyer_id = id)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
private BigDecimal accumulateAmount;
/**
* 适用门店
*/
@TableField(value = "(select shop_name from tb_shop_info where id = shop_id)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
private String shopName;
public BigDecimal getRemainingAmount() {
return NumberUtil.sub(creditAmount, NumberUtil.null2Zero(owedAmount));
}
}

View File

@@ -0,0 +1,61 @@
package cn.ysk.cashier.mybatis.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
/**
* 挂账账单
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-20
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("tb_credit_buyer_order")
public class TbCreditBuyerOrder {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 订单id
*/
private Long orderId;
/**
* 挂账人编码
*/
private String creditBuyerId;
/**
* 已付金额
*/
private BigDecimal paidAmount;
/**
* 未付金额
*/
private BigDecimal unpaidAmount;
/**
* 状态 unpaid-未付款 paid-已付款
*/
private String status;
/**
* 最近一次付款时间
*/
private Date lastPaymentTime;
/**
* 最近一次付款方式
*/
private String lastPaymentMethod;
/**
* 备注
*/
private String remark;
}

View File

@@ -0,0 +1,57 @@
package cn.ysk.cashier.mybatis.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
/**
* 挂账账单付款记录
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-20
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("tb_credit_payment_record")
public class TbCreditPaymentRecord {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 订单id
*/
private Long orderId;
/**
* 挂账人编码
*/
private String creditBuyerId;
/**
* 还款金额
*/
private BigDecimal repaymentAmount;
/**
* 支付方式
*/
private String paymentMethod;
/**
* 备注
*/
private String remark;
/**
* 还款时间
*/
private Date paymentTime;
/**
* 操作时间
*/
private Date createTime;
}

View File

@@ -0,0 +1,129 @@
package cn.ysk.cashier.mybatis.entity;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
/**
* 店铺台桌预订
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-21
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("tb_shop_table_booking")
public class TbShopTableBooking {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 店铺桌台id
*/
private Integer shopTableId;
/**
* 店铺id
*/
private Integer shopId;
/**
* 订单编号
*/
private String orderNo;
/**
* 预约日期
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@JSONField(format = "yyyy-MM-dd")
private Date bookingDate;
/**
* 预约类型 lunch-午餐 dinner-晚餐
*/
private String bookingType;
/**
* 用餐人数
*/
private Integer dinerNum;
/**
* 电话号码
*/
private String phoneNumber;
/**
* 订餐人
*/
private String bookingPerson;
/**
* 性别/称呼 1-先生 2-女士
*/
private Integer gender;
/**
* 预约时间
*/
private Date bookingTime;
/**
* 用餐类型 普通用餐/宴会套餐/自助餐/...,由前端定义或者输入文本
*/
private String diningType;
/**
* 重点关注 1-是 0-否
*/
private Integer focus;
/**
* 接收营销短信 1-是 0-否
*/
private Integer receiveMarketingSms;
/**
* 摆台桌数
*/
private Integer bookingTableNum;
/**
* 餐标(单价)
*/
private BigDecimal diningStandardPrice;
/**
* 餐标(单位) table-元/桌 person-元/人
*/
private String diningStandardUnit;
/**
* 预订状态 -1-已取消 10-已到店 20-待到店 999-已超时
* 注:此处定义为数字是为了方便按状态排序
*/
private Integer status;
/**
* 留座时间
*/
private Integer timeoutMinute;
/**
* 操作时间
*/
private Date createTime;
/**
* 操作人
*/
private String createUserName;
/**
* 到店时间
*/
@TableField(value = "arrived_time", updateStrategy = FieldStrategy.ALWAYS)
private Date arrivedTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 备注
*/
private String remark;
/**
* 删除标志 1-是 0-否
*/
private Integer delFlag;
}

View File

@@ -0,0 +1,16 @@
package cn.ysk.cashier.mybatis.mapper;
import cn.ysk.cashier.mybatis.entity.TbCreditBuyer;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 挂账人
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-20
*/
@Mapper
public interface TbCreditBuyerMapper extends BaseMapper<TbCreditBuyer> {
}

View File

@@ -0,0 +1,16 @@
package cn.ysk.cashier.mybatis.mapper;
import cn.ysk.cashier.mybatis.entity.TbCreditBuyerOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 挂账账单
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-20
*/
@Mapper
public interface TbCreditBuyerOrderMapper extends BaseMapper<TbCreditBuyerOrder> {
}

View File

@@ -0,0 +1,16 @@
package cn.ysk.cashier.mybatis.mapper;
import cn.ysk.cashier.mybatis.entity.TbCreditPaymentRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 挂账账单付款记录
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-20
*/
@Mapper
public interface TbCreditPaymentRecordMapper extends BaseMapper<TbCreditPaymentRecord> {
}

View File

@@ -0,0 +1,16 @@
package cn.ysk.cashier.mybatis.mapper;
import cn.ysk.cashier.mybatis.entity.TbShopTableBooking;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 店铺台桌预订
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-21
*/
@Mapper
public interface TbShopTableBookingMapper extends BaseMapper<TbShopTableBooking> {
}

View File

@@ -0,0 +1,19 @@
package cn.ysk.cashier.mybatis.service;
import cn.ysk.cashier.mybatis.entity.TbCreditBuyerOrder;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.Map;
/**
* 挂账账单
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-20
*/
public interface TbCreditBuyerOrderService extends IService<TbCreditBuyerOrder> {
Map<String, Object> page(Map<String, Object> params);
Map<String, Object> summary(Map<String, Object> params);
}

View File

@@ -0,0 +1,24 @@
package cn.ysk.cashier.mybatis.service;
import cn.ysk.cashier.mybatis.entity.TbCreditBuyer;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.Map;
/**
* 挂账人
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-20
*/
public interface TbCreditBuyerService extends IService<TbCreditBuyer> {
Map<String, Object> page(Map<String, Object> params);
boolean save(TbCreditBuyer entity);
boolean update(TbCreditBuyer dto);
void delete(String id);
}

View File

@@ -0,0 +1,18 @@
package cn.ysk.cashier.mybatis.service;
import cn.ysk.cashier.mybatis.entity.TbCreditPaymentRecord;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.Map;
/**
* 挂账账单付款记录
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-20
*/
public interface TbCreditPaymentRecordService extends IService<TbCreditPaymentRecord> {
Map<String, Object> page(Map<String, Object> params);
}

View File

@@ -0,0 +1,39 @@
package cn.ysk.cashier.mybatis.service;
import cn.ysk.cashier.dto.booking.ShopTableBookingDTO;
import cn.ysk.cashier.mybatis.entity.TbShopTableBooking;
import cn.ysk.cashier.pojo.shop.TbShopArea;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import java.util.Map;
/**
* 店铺台桌预订
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-21
*/
public interface TbShopTableBookingService extends IService<TbShopTableBooking> {
Map<String, Object> page(Map<String, Object> params);
String booking(TbShopTableBooking entity);
boolean update(TbShopTableBooking dto);
void markStatus(Long id, Integer status);
void delete(Long id);
/**
* 获取待发送的短信内容
* @param id 预订id
*/
String getBookingSms(Long id);
List<TbShopArea> findShopAreaList(Integer shopId);
List<ShopTableBookingDTO> findShopTableList(Map<String, Object> params);
}

View File

@@ -0,0 +1,37 @@
package cn.ysk.cashier.mybatis.service.impl;
import cn.ysk.cashier.mybatis.entity.TbCreditBuyerOrder;
import cn.ysk.cashier.mybatis.mapper.TbCreditBuyerOrderMapper;
import cn.ysk.cashier.mybatis.service.TbCreditBuyerOrderService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* 挂账账单
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-20
*/
@Service
public class TbCreditBuyerOrderServiceImpl extends ServiceImpl<TbCreditBuyerOrderMapper, TbCreditBuyerOrder> implements TbCreditBuyerOrderService {
public QueryWrapper<TbCreditBuyerOrder> getWrapper(Map<String, Object> params){
QueryWrapper<TbCreditBuyerOrder> wrapper = new QueryWrapper<>();
wrapper.orderByDesc("id");
return wrapper;
}
@Override
public Map<String, Object> page(Map<String, Object> params) {
return null;
}
@Override
public Map<String, Object> summary(Map<String, Object> params) {
return null;
}
}

View File

@@ -0,0 +1,134 @@
package cn.ysk.cashier.mybatis.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.map.MapProxy;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.entity.TbCreditBuyer;
import cn.ysk.cashier.mybatis.mapper.TbCreditBuyerMapper;
import cn.ysk.cashier.mybatis.service.TbCreditBuyerService;
import cn.ysk.cashier.utils.PageUtil;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
/**
* 挂账人
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-20
*/
@Service
public class TbCreditBuyerServiceImpl extends ServiceImpl<TbCreditBuyerMapper, TbCreditBuyer> implements TbCreditBuyerService {
private LambdaQueryWrapper<TbCreditBuyer> getWrapper(Map<String, Object> params) {
MapProxy mapProxy = MapProxy.create(params);
String keywords = mapProxy.getStr("keywords");
TbCreditBuyer param = BeanUtil.toBean(params, TbCreditBuyer.class);
LambdaQueryWrapper<TbCreditBuyer> wrapper = Wrappers.lambdaQuery();
wrapper.eq(TbCreditBuyer::getShopId, param.getShopId());
wrapper.eq(StrUtil.isNotEmpty(param.getId()), TbCreditBuyer::getId, param.getId());
wrapper.eq(param.getStatus() != null, TbCreditBuyer::getStatus, param.getStatus());
if (StrUtil.isNotEmpty(keywords)) {
wrapper.nested(i -> i.like(TbCreditBuyer::getDebtor, keywords).or().like(TbCreditBuyer::getMobile, keywords));
}
wrapper.eq(TbCreditBuyer::getDelFlag, 0);
wrapper.select(TbCreditBuyer::getId, TbCreditBuyer::getShopId, TbCreditBuyer::getStatus, TbCreditBuyer::getDebtor, TbCreditBuyer::getMobile, TbCreditBuyer::getPosition, TbCreditBuyer::getCreditAmount, TbCreditBuyer::getRepaymentMethod, TbCreditBuyer::getPaymentMethod, TbCreditBuyer::getRemark, TbCreditBuyer::getDelFlag, TbCreditBuyer::getOwedAmount, TbCreditBuyer::getAccumulateAmount, TbCreditBuyer::getShopName);
wrapper.orderByDesc(TbCreditBuyer::getStatus);
wrapper.orderByDesc(TbCreditBuyer::getId);
return wrapper;
}
@Override
public Map<String, Object> page(Map<String, Object> params) {
MapProxy mapProxy = MapProxy.create(params);
int pageNum = mapProxy.getInt("page", 1);
int pageSize = mapProxy.getInt("size", 10);
LambdaQueryWrapper<TbCreditBuyer> wrapper = getWrapper(params);
Page<TbCreditBuyer> page = super.page(new Page<>(pageNum, pageSize), wrapper);
return PageUtil.toPlusPage(page.getRecords(), Convert.toInt(page.getTotal()));
}
private void commonVerify(TbCreditBuyer entity) {
try {
Assert.notNull(entity.getShopId(), "{}({})不能为空", "店铺id", "shopId");
Assert.notNull(entity.getStatus(), "{}({})不能为空", "状态", "status");
Assert.notEmpty(entity.getDebtor(), "{}({})不能为空", "挂账人", "debtor");
Assert.notEmpty(entity.getMobile(), "{}({})不能为空", "手机号", "mobile");
Assert.notNull(entity.getCreditAmount(), "{}({})不能为空", "挂账额度", "creditAmount");
} catch (IllegalArgumentException e) {
throw new BadRequestException(e.getMessage());
}
if (!Validator.isMobile(entity.getMobile())) {
throw new BadRequestException(StrUtil.format("{}({})不合法", "手机号", "mobile"));
}
if (NumberUtil.isLessOrEqual(entity.getCreditAmount(), BigDecimal.ZERO)) {
throw new BadRequestException(StrUtil.format("{}({})必须大于0", "挂账额度", "creditAmount"));
}
}
@Override
public boolean save(TbCreditBuyer entity) {
commonVerify(entity);
try {
Assert.notEmpty(entity.getRepaymentMethod(), "{}({})不能为空", "还款方式", "repaymentMethod");
} catch (IllegalArgumentException e) {
throw new BadRequestException(e.getMessage());
}
if (!ArrayUtil.contains(new String[]{"total", "order"}, entity.getRepaymentMethod())) {
throw new BadRequestException(StrUtil.format("{}({})不合法", "还款方式", "repaymentMethod"));
}
return super.save(entity);
}
@Override
public boolean update(TbCreditBuyer dto) {
try {
Assert.notEmpty(dto.getId(), "{}不能为空", "id");
} catch (IllegalArgumentException e) {
throw new BadRequestException(e.getMessage());
}
commonVerify(dto);
TbCreditBuyer entity = super.getById(dto.getId());
if (entity == null) {
throw new BadRequestException("挂账人不存在");
}
Map<String, Object> params = new HashMap<>();
params.put("id", dto.getId());
params.put("shopId", dto.getShopId());
LambdaQueryWrapper<TbCreditBuyer> wrapper = getWrapper(params);
entity = baseMapper.selectOne(wrapper);
// 验证挂账额度是否小于已挂账金额
boolean less = NumberUtil.isLess(dto.getCreditAmount(), NumberUtil.null2Zero(entity.getOwedAmount()));
if (less) {
throw new BadRequestException(StrUtil.format("{}({})不能小于已挂账金额({})", "挂账额度", "creditAmount", entity.getOwedAmount()));
}
BeanUtil.copyProperties(dto, entity, CopyOptions.create().setIgnoreNullValue(false).setIgnoreProperties("repaymentMethod"));
return super.updateById(entity);
}
@Override
public void delete(String id) {
try {
Assert.notEmpty(id, "{}不能为空", "id");
} catch (IllegalArgumentException e) {
throw new BadRequestException(e.getMessage());
}
super.update(Wrappers.<TbCreditBuyer>lambdaUpdate().set(TbCreditBuyer::getDelFlag, 1).eq(TbCreditBuyer::getId, id));
}
}

View File

@@ -0,0 +1,32 @@
package cn.ysk.cashier.mybatis.service.impl;
import cn.ysk.cashier.mybatis.entity.TbCreditPaymentRecord;
import cn.ysk.cashier.mybatis.mapper.TbCreditPaymentRecordMapper;
import cn.ysk.cashier.mybatis.service.TbCreditPaymentRecordService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* 挂账账单付款记录
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-20
*/
@Service
public class TbCreditPaymentRecordServiceImpl extends ServiceImpl<TbCreditPaymentRecordMapper, TbCreditPaymentRecord> implements TbCreditPaymentRecordService {
public QueryWrapper<TbCreditPaymentRecord> getWrapper(Map<String, Object> params){
QueryWrapper<TbCreditPaymentRecord> wrapper = new QueryWrapper<>();
wrapper.orderByDesc("id");
return wrapper;
}
@Override
public Map<String, Object> page(Map<String, Object> params) {
return null;
}
}

View File

@@ -0,0 +1,265 @@
package cn.ysk.cashier.mybatis.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.map.MapProxy;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.ysk.cashier.dto.booking.ShopTableBookingDTO;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.entity.TbShopTableBooking;
import cn.ysk.cashier.mybatis.mapper.MpShopAreaMapper;
import cn.ysk.cashier.mybatis.mapper.MpShopTableMapper;
import cn.ysk.cashier.mybatis.mapper.TbShopTableBookingMapper;
import cn.ysk.cashier.mybatis.service.TbShopTableBookingService;
import cn.ysk.cashier.pojo.shop.TbShopArea;
import cn.ysk.cashier.pojo.shop.TbShopInfo;
import cn.ysk.cashier.pojo.shop.TbShopTable;
import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
import cn.ysk.cashier.utils.PageUtil;
import cn.ysk.cashier.utils.SecurityUtils;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
/**
* 店铺台桌预订
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-21
*/
@Service
public class TbShopTableBookingServiceImpl extends ServiceImpl<TbShopTableBookingMapper, TbShopTableBooking> implements TbShopTableBookingService {
private static final Map<String, String> BOOKING_TYPE = MapUtil.builder("lunch", "午餐")
.put("dinner", "晚餐")
.build();
@Resource
private TbShopInfoRepository tbShopInfoRepository;
@Resource
private MpShopTableMapper mpShopTableMapper;
@Resource
private MpShopAreaMapper mpShopAreaMapper;
private LambdaQueryWrapper<TbShopTableBooking> getWrapper(Map<String, Object> params) {
MapProxy mapProxy = MapProxy.create(params);
String keywords = mapProxy.getStr("keywords");
TbShopTableBooking param = BeanUtil.toBean(params, TbShopTableBooking.class);
LambdaQueryWrapper<TbShopTableBooking> wrapper = Wrappers.lambdaQuery();
wrapper.eq(TbShopTableBooking::getShopId, param.getShopId());
wrapper.eq(param.getId() != null, TbShopTableBooking::getId, param.getId());
wrapper.like(StrUtil.isNotEmpty(param.getOrderNo()), TbShopTableBooking::getOrderNo, param.getOrderNo());
wrapper.eq(param.getBookingDate() != null, TbShopTableBooking::getBookingDate, param.getBookingDate());
wrapper.eq(StrUtil.isNotEmpty(param.getBookingType()), TbShopTableBooking::getBookingType, param.getBookingType());
wrapper.like(StrUtil.isNotEmpty(param.getDiningType()), TbShopTableBooking::getDiningType, param.getDiningType());
wrapper.eq(param.getFocus() != null, TbShopTableBooking::getFocus, param.getFocus());
wrapper.eq(param.getReceiveMarketingSms() != null, TbShopTableBooking::getReceiveMarketingSms, param.getReceiveMarketingSms());
wrapper.eq(param.getReceiveMarketingSms() != null, TbShopTableBooking::getReceiveMarketingSms, param.getReceiveMarketingSms());
wrapper.eq(param.getStatus() != null, TbShopTableBooking::getStatus, param.getStatus());
if (StrUtil.isNotEmpty(keywords)) {
wrapper.nested(i -> i.like(TbShopTableBooking::getBookingPerson, keywords).or().like(TbShopTableBooking::getPhoneNumber, keywords));
}
wrapper.eq(TbShopTableBooking::getDelFlag, 0);
wrapper.orderByDesc(TbShopTableBooking::getFocus);
wrapper.orderByDesc(TbShopTableBooking::getStatus);
wrapper.orderByAsc(TbShopTableBooking::getBookingTime);
wrapper.orderByDesc(TbShopTableBooking::getId);
return wrapper;
}
@Override
public Map<String, Object> page(Map<String, Object> params) {
MapProxy mapProxy = MapProxy.create(params);
int pageNum = mapProxy.getInt("page", 1);
int pageSize = mapProxy.getInt("size", 10);
LambdaQueryWrapper<TbShopTableBooking> wrapper = getWrapper(params);
Page<TbShopTableBooking> page = super.page(new Page<>(pageNum, pageSize), wrapper);
return PageUtil.toPlusPage(page.getRecords(), Convert.toInt(page.getTotal()));
}
private void commonVerify(TbShopTableBooking entity) {
try {
Assert.notNull(entity.getShopTableId(), "{}({})不能为空", "台桌id", "shopTableId");
Assert.notNull(entity.getShopId(), "{}({})不能为空", "店铺id", "shopId");
Assert.notNull(entity.getBookingDate(), "{}({})不能为空", "预约日期", "bookingDate");
Assert.notEmpty(entity.getBookingType(), "{}({})不能为空", "预订类型(午餐/晚餐)", "bookingType");
Assert.notNull(entity.getDinerNum(), "{}({})不能为空", "用餐人数", "dinerNum");
Assert.notEmpty(entity.getPhoneNumber(), "{}({})不能为空", "电话号码", "phoneNumber");
Assert.notEmpty(entity.getBookingPerson(), "{}({})不能为空", "订餐人", "bookingPerson");
Assert.notNull(entity.getGender(), "{}({})不能为空", "性别/称呼", "gender");
Assert.notNull(entity.getBookingTime(), "{}({})不能为空", "约定时间", "bookingTime");
Assert.notEmpty(entity.getDiningType(), "{}({})不能为空", "用餐类型", "diningType");
Assert.notNull(entity.getFocus(), "{}({})不能为空", "重点关注", "focus");
Assert.notNull(entity.getReceiveMarketingSms(), "{}({})不能为空", "接收营销短信", "receiveMarketingSms");
} catch (IllegalArgumentException e) {
throw new BadRequestException(e.getMessage());
}
}
@Override
public String booking(TbShopTableBooking entity) {
commonVerify(entity);
if (DateUtil.compare(entity.getBookingTime(), new Date()) < 0) {
throw new BadRequestException("预订日期(bookingDate)不能小于今天");
}
long existCount = baseMapper.selectCount(Wrappers.<TbShopTableBooking>lambdaQuery()
.eq(TbShopTableBooking::getShopId, entity.getShopId())
.eq(TbShopTableBooking::getShopTableId, entity.getShopTableId())
.eq(TbShopTableBooking::getBookingDate, entity.getBookingDate())
.eq(TbShopTableBooking::getBookingType, entity.getBookingType())
.ne(TbShopTableBooking::getStatus, -1)
.eq(TbShopTableBooking::getDelFlag, 0)
);
if (existCount > 0) {
throw new BadRequestException(StrUtil.format("该台桌{}档在{}已被预订", BOOKING_TYPE.get(entity.getBookingType()), DateUtil.formatDate(entity.getBookingDate())));
}
String randomStr = RandomUtil.randomString(RandomUtil.BASE_CHAR_NUMBER, 4);
String orderNo = DateUtil.format(new Date(), "yyMMddHHmmss") + "-" + randomStr.toUpperCase();
entity.setOrderNo("BK" + orderNo);
entity.setStatus(20);
entity.setCreateTime(new Date());
entity.setCreateUserName(SecurityUtils.getCurrentUserNickName());
entity.setDelFlag(0);
super.save(entity);
return entity.getOrderNo();
}
@Override
public boolean update(TbShopTableBooking dto) {
if (dto.getId() == null) {
throw new BadRequestException("id不能为空");
}
commonVerify(dto);
TbShopTableBooking entity = super.getById(dto.getId());
if (entity == null) {
throw new BadRequestException("预订信息不存在");
}
if (DateUtil.compare(dto.getBookingTime(), new Date()) < 0) {
throw new BadRequestException("预订日期(bookingDate)不能小于今天");
}
long existCount = baseMapper.selectCount(Wrappers.<TbShopTableBooking>lambdaQuery()
.ne(TbShopTableBooking::getId, entity.getId())
.eq(TbShopTableBooking::getShopId, dto.getShopId())
.eq(TbShopTableBooking::getShopTableId, dto.getShopTableId())
.eq(TbShopTableBooking::getBookingDate, dto.getBookingDate())
.eq(TbShopTableBooking::getBookingType, dto.getBookingType())
.ne(TbShopTableBooking::getStatus, -1)
.eq(TbShopTableBooking::getDelFlag, 0)
);
if (existCount > 0) {
throw new BadRequestException(StrUtil.format("该台桌{}档在{}已被预订", BOOKING_TYPE.get(entity.getBookingType()), DateUtil.formatDate(entity.getBookingDate())));
}
BeanUtil.copyProperties(dto, entity, CopyOptions.create().setIgnoreNullValue(true).setIgnoreProperties("orderNo", "status", "createTime", "createUserName", "delFlag"));
entity.setUpdateTime(new Date());
return super.updateById(entity);
}
@Override
public void markStatus(Long id, Integer status) {
if (id == null) {
throw new BadRequestException("id不能为空");
}
if (status == null) {
throw new BadRequestException("状态不能为空");
}
TbShopTableBooking entity = super.getById(id);
if (entity == null) {
throw new BadRequestException("预订信息不存在");
}
entity.setStatus(status);
entity.setUpdateTime(new Date());
if (status == 10) {
entity.setArrivedTime(new Date());
} else {
entity.setArrivedTime(null);
}
super.updateById(entity);
}
@Override
public void delete(Long id) {
baseMapper.update(Wrappers.<TbShopTableBooking>lambdaUpdate()
.set(TbShopTableBooking::getDelFlag, 1)
.eq(TbShopTableBooking::getId, id));
}
@Override
public String getBookingSms(Long id) {
if (id == null) {
throw new BadRequestException("id不能为空");
}
TbShopTableBooking entity = super.getById(id);
if (entity == null) {
throw new BadRequestException("预订信息不存在");
}
Integer shopId = entity.getShopId();
TbShopInfo shop = tbShopInfoRepository.getById(shopId);
if (shop == null) {
throw new BadRequestException("店铺信息不存在");
}
return shop.getBookingSms();
}
@Override
public List<TbShopArea> findShopAreaList(Integer shopId) {
List<TbShopTable> tableList = mpShopTableMapper.selectList(Wrappers.<TbShopTable>lambdaQuery().eq(TbShopTable::getShopId, shopId).eq(TbShopTable::getIsPredate, 1));
if (CollUtil.isEmpty(tableList)) {
return new ArrayList<>();
}
Set<Integer> areaId = tableList.stream().map(TbShopTable::getAreaId).collect(Collectors.toSet());
List<TbShopArea> areaList = mpShopAreaMapper.selectList(Wrappers.<TbShopArea>lambdaQuery().in(TbShopArea::getId, areaId));
if (CollUtil.isEmpty(areaList)) {
return new ArrayList<>();
}
return areaList;
}
@Override
public List<ShopTableBookingDTO> findShopTableList(Map<String, Object> params) {
MapProxy mapProxy = MapProxy.create(params);
Integer areaId = mapProxy.getInt("areaId");
TbShopTableBooking param = BeanUtil.toBean(params, TbShopTableBooking.class);
List<TbShopTable> tableList = mpShopTableMapper.selectList(
Wrappers.<TbShopTable>lambdaQuery()
.eq(TbShopTable::getShopId, param.getShopId())
.eq(TbShopTable::getIsPredate, 1)
.eq(areaId != null, TbShopTable::getAreaId, areaId)
.orderByAsc(TbShopTable::getName)
);
if (CollUtil.isEmpty(tableList)) {
return new ArrayList<>();
}
List<ShopTableBookingDTO> result = BeanUtil.copyToList(tableList, ShopTableBookingDTO.class);
Date bookingDate = param.getBookingDate();
String bookingType = param.getBookingType();
LambdaQueryWrapper<TbShopTableBooking> wrapper = Wrappers.lambdaQuery();
wrapper.eq(bookingDate != null, TbShopTableBooking::getBookingDate, bookingDate);
wrapper.eq(StrUtil.isNotEmpty(bookingType), TbShopTableBooking::getBookingType, bookingType);
wrapper.ne(TbShopTableBooking::getStatus, -1);
wrapper.eq(TbShopTableBooking::getDelFlag, 0);
List<TbShopTableBooking> list = super.list(wrapper);
if (CollUtil.isEmpty(list)) {
return result;
}
for (ShopTableBookingDTO dto : result) {
dto.setBookingInfo(list.stream().filter(item -> item.getShopTableId().equals(dto.getId())).findFirst().orElse(null));
}
return result;
}
}

View File

@@ -15,14 +15,14 @@
*/
package cn.ysk.cashier.pojo.shop;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @website https://eladmin.vip
@@ -295,6 +295,10 @@ public class TbShopInfo implements Serializable {
@ApiModelProperty(value = "店铺收款码")
private String paymentQrcode;
@Column(name = "booking_sms")
@ApiModelProperty(value = "台桌预订短信")
private String bookingSms;
public void copy(TbShopInfo source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}

View File

@@ -261,6 +261,10 @@ public class TbShopTableServiceImpl implements TbShopTableService {
query.eq(TbShopTable::getStatus, criteria.getState()).isNotNull(TbShopTable::getQrcode).ne(TbShopTable::getQrcode, "");
}
if (criteria.getIsPredate() != null) {
query.eq(TbShopTable::getIsPredate, criteria.getIsPredate());
}
com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbShopTable> shopTablePage =
mpShopTableService.page(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(criteria.getPage(), criteria.getSize()), query);
List<TbShopTable> tbShopTableList = shopTablePage.getRecords();