Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.czg.account.dto.print.PrinterAddDTO;
|
||||
import com.czg.account.dto.print.PrinterDelDTO;
|
||||
import com.czg.account.dto.print.PrinterEditDTO;
|
||||
import com.czg.account.dto.print.PrinterOrderDTO;
|
||||
import com.czg.account.entity.PrintMachine;
|
||||
import com.czg.account.service.PrintMachineService;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
@@ -90,4 +91,14 @@ public class PrintMachineController {
|
||||
return CzgResult.success(printMachineService.remove(new QueryWrapper().eq(PrintMachine::getShopId, StpKit.USER.getShopId()).eq(PrintMachine::getId, printerDelDTO.getId())));
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印订单
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckPermission(value = "printer:order", name = "打印机打印订单")
|
||||
@PostMapping("/order")
|
||||
public CzgResult<Boolean> printOrder(@RequestBody @Validated PrinterOrderDTO printerOrderDTO) {
|
||||
return CzgResult.success(printMachineService.printOrder(StpKit.USER.getShopId(), printerOrderDTO));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.czg.account.dto.table.ShopTableAddDTO;
|
||||
import com.czg.account.dto.table.ShopTableBindDTO;
|
||||
import com.czg.account.dto.table.ShopTableClearDTO;
|
||||
import com.czg.account.dto.table.ShopTableDTO;
|
||||
import com.czg.account.entity.ShopTable;
|
||||
import com.czg.account.service.ShopTableService;
|
||||
import com.czg.account.vo.ShopTableVO;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryMethods;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
@@ -56,24 +55,8 @@ public class ShopTableController {
|
||||
*/
|
||||
@SaAdminCheckPermission("shopTable:list")
|
||||
@GetMapping
|
||||
public CzgResult<Page<ShopTable>> list(Integer areaId, String tableCode, String status, String name) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper().eq(ShopTable::getShopId, StpKit.USER.getShopId());
|
||||
if (areaId != null) {
|
||||
queryWrapper.eq(ShopTable::getAreaId, areaId);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(tableCode)) {
|
||||
queryWrapper.like(ShopTable::getTableCode, tableCode);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(status)) {
|
||||
queryWrapper.eq(ShopTable::getStatus, status);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(name)) {
|
||||
queryWrapper.like(ShopTable::getName, name);
|
||||
}
|
||||
return CzgResult.success(shopTableService.page(PageUtil.buildPage(), queryWrapper));
|
||||
public CzgResult<Page<ShopTableVO>> list(Integer areaId, String tableCode, String status, String name) {
|
||||
return CzgResult.success(shopTableService.pageInfo(StpKit.USER.getShopId(), areaId, tableCode, status, name));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,8 +87,18 @@ public class ShopTableController {
|
||||
@SaAdminCheckPermission("shopTable:edit")
|
||||
@PutMapping
|
||||
public CzgResult<Boolean> edit(@RequestBody @Validated ShopTableDTO shopTableDTO) {
|
||||
ShopTable shopTable = BeanUtil.copyProperties(shopTableDTO, ShopTable.class);
|
||||
return CzgResult.success(shopTableService.update(shopTable, new QueryWrapper().eq(ShopTable::getShopId, StpKit.USER.getShopId()).eq(ShopTable::getId, shopTableDTO.getId())));
|
||||
return CzgResult.success(shopTableService.updateInfo(StpKit.USER.getLoginIdAsLong(), shopTableDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 台桌清台
|
||||
* 权限标识: shopTable:clear
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckPermission("shopTable:clear")
|
||||
@PutMapping("/clear")
|
||||
public CzgResult<Boolean> clear(@RequestBody @Validated ShopTableClearDTO shopTableClearDTO) {
|
||||
return CzgResult.success(shopTableService.clear(StpKit.USER.getLoginIdAsLong(), shopTableClearDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,4 +136,5 @@ public class ShopTableController {
|
||||
public CzgResult<Boolean> bind(@RequestBody @Validated ShopTableBindDTO shopTableBindDTO) {
|
||||
return CzgResult.success(shopTableService.bind(StpKit.USER.getShopId(), shopTableBindDTO));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.czg.account.dto.print;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Data
|
||||
public class PrinterOrderDTO {
|
||||
@NotNull(message = "订单id不为空")
|
||||
private Long orderId;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
|
||||
package com.czg.account.dto.table;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 台桌配置 实体类。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-13
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ShopTableClearDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 自增id
|
||||
*/
|
||||
@NotNull
|
||||
private Integer id;
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.czg.account.service;
|
||||
|
||||
import com.czg.account.dto.print.PrinterAddDTO;
|
||||
import com.czg.account.dto.print.PrinterEditDTO;
|
||||
import com.czg.account.dto.print.PrinterOrderDTO;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.account.entity.PrintMachine;
|
||||
@@ -18,4 +19,6 @@ public interface PrintMachineService extends IService<PrintMachine> {
|
||||
|
||||
Boolean edit(Long shopId, PrinterEditDTO printerEditDTO);
|
||||
|
||||
Boolean printOrder(Long shopId, PrinterOrderDTO printerOrderDTO);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,11 @@ package com.czg.account.service;
|
||||
|
||||
import com.czg.account.dto.table.ShopTableAddDTO;
|
||||
import com.czg.account.dto.table.ShopTableBindDTO;
|
||||
import com.czg.account.dto.table.ShopTableClearDTO;
|
||||
import com.czg.account.dto.table.ShopTableDTO;
|
||||
import com.czg.account.entity.ShopTable;
|
||||
import com.czg.account.vo.ShopTableVO;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
@@ -27,4 +31,9 @@ public interface ShopTableService extends IService<ShopTable> {
|
||||
|
||||
Boolean bind(Long shopId, ShopTableBindDTO shopTableBindDTO);
|
||||
|
||||
Boolean updateInfo(long shopId, ShopTableDTO shopTableDTO);
|
||||
|
||||
Boolean clear(long shopId, ShopTableClearDTO shopTableClearDTO);
|
||||
|
||||
Page<ShopTableVO> pageInfo(Long shopId, Integer areaId, String tableCode, String status, String name);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
package com.czg.account.vo;
|
||||
|
||||
import com.czg.account.entity.ShopTable;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.*;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 台桌配置 实体类。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-13
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ShopTableVO extends ShopTable {
|
||||
private Long orderId;
|
||||
private Long userId;
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.czg.account.vo.ShopTableVO;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.ShopTable;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 台桌配置 映射层。
|
||||
@@ -11,4 +15,6 @@ import com.czg.account.entity.ShopTable;
|
||||
*/
|
||||
public interface ShopTableMapper extends BaseMapper<ShopTable> {
|
||||
|
||||
List<ShopTableVO> pageInfo(@Param("shopId") Long shopId, @Param("areaId") Integer areaId,
|
||||
@Param("tableCode") String tableCode, @Param("status") String status, @Param("name") String name);
|
||||
}
|
||||
|
||||
@@ -5,13 +5,19 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.czg.account.dto.print.PrinterAddDTO;
|
||||
import com.czg.account.dto.print.PrinterEditDTO;
|
||||
import com.czg.account.dto.print.PrinterOrderDTO;
|
||||
import com.czg.config.RabbitPublisher;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.service.OrderInfoService;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.PrintMachine;
|
||||
import com.czg.account.service.PrintMachineService;
|
||||
import com.czg.service.account.mapper.PrintMachineMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -24,6 +30,11 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
@DubboService
|
||||
public class PrintMachineServiceImpl extends ServiceImpl<PrintMachineMapper, PrintMachine> implements PrintMachineService{
|
||||
@DubboReference
|
||||
private OrderInfoService orderInfoService;
|
||||
|
||||
@Resource
|
||||
private RabbitPublisher rabbitPublisher;
|
||||
|
||||
@Override
|
||||
public boolean add(Long shopId, PrinterAddDTO dto) {
|
||||
@@ -57,4 +68,19 @@ public class PrintMachineServiceImpl extends ServiceImpl<PrintMachineMapper, Pri
|
||||
BeanUtil.copyProperties(printerEditDTO, printMachine);
|
||||
return updateById(printMachine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean printOrder(Long shopId, PrinterOrderDTO printerOrderDTO) {
|
||||
OrderInfo orderInfo = orderInfoService.getOne(new QueryWrapper().eq(OrderInfo::getShopId, shopId).eq(OrderInfo::getId, printerOrderDTO.getOrderId()));
|
||||
if (orderInfo == null) {
|
||||
throw new ApiNotPrintException("订单信息不存在");
|
||||
}
|
||||
|
||||
long count = count(new QueryWrapper().eq(PrintMachine::getShopId, shopId));
|
||||
if (count == 0) {
|
||||
throw new ApiNotPrintException("未配置打印机");
|
||||
}
|
||||
rabbitPublisher.sendOrderPrintMsg(orderInfo.getId().toString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.dev33.satoken.context.SaHolder;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.img.ImgUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -10,15 +9,22 @@ import cn.hutool.core.util.ZipUtil;
|
||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||
import com.czg.account.dto.table.ShopTableAddDTO;
|
||||
import com.czg.account.dto.table.ShopTableBindDTO;
|
||||
import com.czg.account.dto.table.ShopTableClearDTO;
|
||||
import com.czg.account.dto.table.ShopTableDTO;
|
||||
import com.czg.account.entity.ShopTable;
|
||||
import com.czg.account.entity.ShopTableArea;
|
||||
import com.czg.account.entity.ShopTableCode;
|
||||
import com.czg.account.service.ShopTableAreaService;
|
||||
import com.czg.account.service.ShopTableCodeService;
|
||||
import com.czg.account.service.ShopTableService;
|
||||
import com.czg.account.vo.ShopTableVO;
|
||||
import com.czg.enums.ShopTableStatusEnum;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.account.mapper.ShopTableMapper;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
@@ -29,6 +35,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -236,6 +243,35 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
|
||||
shopTableCodeService.updateById(tableCode);
|
||||
|
||||
shopTable.setTableCode(tableCode.getTableCode());
|
||||
shopTable.setStatus(ShopTableStatusEnum.IDLE.getValue());
|
||||
return updateById(shopTable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateInfo(long shopId, ShopTableDTO shopTableDTO) {
|
||||
ShopTable shopTable = BeanUtil.copyProperties(shopTableDTO, ShopTable.class);
|
||||
return update(shopTable, new QueryWrapper().eq(ShopTable::getShopId, StpKit.USER.getShopId()).eq(ShopTable::getId, shopTableDTO.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean clear(long shopId, ShopTableClearDTO shopTableClearDTO) {
|
||||
ShopTable shopTable = getOne(new QueryWrapper().eq(ShopTable::getShopId, shopId).eq(ShopTable::getId, shopTableClearDTO.getId()));
|
||||
if (ShopTableStatusEnum.CLEANING.equalsVal(shopTable.getStatus())) {
|
||||
throw new ApiNotPrintException("台桌不处于待清台状态");
|
||||
}
|
||||
shopTable.setStatus(ShopTableStatusEnum.IDLE.getValue());
|
||||
shopTable.setEndTime(DateUtil.date().toLocalDateTime());
|
||||
shopTable.setProductNum(0);
|
||||
shopTable.setTotalAmount(BigDecimal.ZERO);
|
||||
shopTable.setRealAmount(BigDecimal.ZERO);
|
||||
shopTable.setUseNum(0);
|
||||
return update(shopTable, new QueryWrapper().eq(ShopTable::getShopId, shopId)
|
||||
.eq(ShopTable::getId, shopTableClearDTO.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ShopTableVO> pageInfo(Long shopId, Integer areaId, String tableCode, String status, String name) {
|
||||
PageHelper.startPage(PageUtil.buildPageHelp());
|
||||
return PageUtil.convert(new PageInfo<>(mapper.pageInfo(shopId, areaId, tableCode, status, name)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,4 +4,26 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.account.mapper.ShopTableMapper">
|
||||
|
||||
<select id="pageInfo" resultType="com.czg.account.vo.ShopTableVO">
|
||||
select a.*, b.id orderId, b.user_id
|
||||
from tb_shop_table as a
|
||||
left join tb_order_info as b
|
||||
on a.table_code = b.table_code and b.`status` = 'unpaid' and b.table_code != '' and
|
||||
b.table_code is not null
|
||||
where a.shop_id=#{shopId}
|
||||
<if test="areaId != null">
|
||||
and a.area_id=#{areaId}
|
||||
</if>
|
||||
<if test="tableCode != null and tableCode != ''">
|
||||
and a.area_id=#{areaId}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
and a.status=#{status}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and a.name like concat('%', #{name}, '%')
|
||||
</if>
|
||||
ORDER BY a.create_time
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user