订单打印修改

This commit is contained in:
张松
2025-03-06 16:42:40 +08:00
parent 126a9ac6c5
commit d06ba4de98
7 changed files with 52 additions and 46 deletions

View File

@@ -5,19 +5,12 @@ 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;
@@ -30,11 +23,6 @@ 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) {
@@ -68,19 +56,4 @@ 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;
}
}