台桌列表返回订单id
打印订单接口
This commit is contained in:
@@ -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;
|
||||
@@ -239,4 +246,29 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
|
||||
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 = new ShopTable();
|
||||
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