订单打印修改
This commit is contained in:
parent
126a9ac6c5
commit
d06ba4de98
|
|
@ -91,14 +91,4 @@ public class PrintMachineController {
|
||||||
return CzgResult.success(printMachineService.remove(new QueryWrapper().eq(PrintMachine::getShopId, StpKit.USER.getShopId()).eq(PrintMachine::getId, printerDelDTO.getId())));
|
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,6 +1,7 @@
|
||||||
package com.czg.controller.admin;
|
package com.czg.controller.admin;
|
||||||
|
|
||||||
import com.czg.order.dto.OrderInfoAddDTO;
|
import com.czg.order.dto.OrderInfoAddDTO;
|
||||||
|
import com.czg.order.dto.OrderInfoPrintDTO;
|
||||||
import com.czg.order.dto.OrderInfoQueryDTO;
|
import com.czg.order.dto.OrderInfoQueryDTO;
|
||||||
import com.czg.order.dto.OrderInfoRefundDTO;
|
import com.czg.order.dto.OrderInfoRefundDTO;
|
||||||
import com.czg.order.entity.OrderInfo;
|
import com.czg.order.entity.OrderInfo;
|
||||||
|
|
@ -72,4 +73,12 @@ public class AdminOrderController {
|
||||||
public CzgResult<Object> refundOrder(@Validated @RequestBody OrderInfoRefundDTO refundDTO) {
|
public CzgResult<Object> refundOrder(@Validated @RequestBody OrderInfoRefundDTO refundDTO) {
|
||||||
return payService.refundOrderBefore(refundDTO);
|
return payService.refundOrderBefore(refundDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单打印
|
||||||
|
*/
|
||||||
|
@PostMapping("/print")
|
||||||
|
public CzgResult<Boolean> printOrder(@Validated @RequestBody OrderInfoPrintDTO orderInfoPrintDTO) {
|
||||||
|
return CzgResult.success(orderInfoService.printOrder(StpKit.USER.getShopId(), orderInfoPrintDTO));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,5 @@ public interface PrintMachineService extends IService<PrintMachine> {
|
||||||
|
|
||||||
Boolean edit(Long shopId, PrinterEditDTO printerEditDTO);
|
Boolean edit(Long shopId, PrinterEditDTO printerEditDTO);
|
||||||
|
|
||||||
Boolean printOrder(Long shopId, PrinterOrderDTO printerOrderDTO);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
package com.czg.order.dto;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单表 实体类。
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2025-02-13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class OrderInfoPrintDTO{
|
||||||
|
/**
|
||||||
|
* 订单id
|
||||||
|
*/
|
||||||
|
@NotNull(message = "id不为空")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,7 @@
|
||||||
package com.czg.order.service;
|
package com.czg.order.service;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.order.dto.BigDecimalDTO;
|
import com.czg.order.dto.*;
|
||||||
import com.czg.order.dto.CheckOrderPay;
|
|
||||||
import com.czg.order.dto.OrderInfoAddDTO;
|
|
||||||
import com.czg.order.dto.OrderInfoQueryDTO;
|
|
||||||
import com.czg.order.entity.OrderDetail;
|
import com.czg.order.entity.OrderDetail;
|
||||||
import com.czg.order.entity.OrderInfo;
|
import com.czg.order.entity.OrderInfo;
|
||||||
import com.czg.order.enums.PayEnums;
|
import com.czg.order.enums.PayEnums;
|
||||||
|
|
@ -53,4 +50,7 @@ public interface OrderInfoService extends IService<OrderInfo> {
|
||||||
BigDecimalDTO prodCouponAmount, BigDecimalDTO totalAmount, BigDecimalDTO packAmount,
|
BigDecimalDTO prodCouponAmount, BigDecimalDTO totalAmount, BigDecimalDTO packAmount,
|
||||||
boolean isAllPack, boolean isVipPrice);
|
boolean isAllPack, boolean isVipPrice);
|
||||||
|
|
||||||
|
|
||||||
|
Boolean printOrder(Long shopId, OrderInfoPrintDTO orderInfoPrintDTO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,19 +5,12 @@ import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.czg.account.dto.print.PrinterAddDTO;
|
import com.czg.account.dto.print.PrinterAddDTO;
|
||||||
import com.czg.account.dto.print.PrinterEditDTO;
|
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.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.core.query.QueryWrapper;
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
import com.czg.account.entity.PrintMachine;
|
import com.czg.account.entity.PrintMachine;
|
||||||
import com.czg.account.service.PrintMachineService;
|
import com.czg.account.service.PrintMachineService;
|
||||||
import com.czg.service.account.mapper.PrintMachineMapper;
|
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.apache.dubbo.config.annotation.DubboService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
@ -30,11 +23,6 @@ import org.springframework.stereotype.Service;
|
||||||
@Service
|
@Service
|
||||||
@DubboService
|
@DubboService
|
||||||
public class PrintMachineServiceImpl extends ServiceImpl<PrintMachineMapper, PrintMachine> implements PrintMachineService{
|
public class PrintMachineServiceImpl extends ServiceImpl<PrintMachineMapper, PrintMachine> implements PrintMachineService{
|
||||||
@DubboReference
|
|
||||||
private OrderInfoService orderInfoService;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private RabbitPublisher rabbitPublisher;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean add(Long shopId, PrinterAddDTO dto) {
|
public boolean add(Long shopId, PrinterAddDTO dto) {
|
||||||
|
|
@ -68,19 +56,4 @@ public class PrintMachineServiceImpl extends ServiceImpl<PrintMachineMapper, Pri
|
||||||
BeanUtil.copyProperties(printerEditDTO, printMachine);
|
BeanUtil.copyProperties(printerEditDTO, printMachine);
|
||||||
return updateById(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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.czg.account.dto.print.PrinterOrderDTO;
|
||||||
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
||||||
import com.czg.account.entity.*;
|
import com.czg.account.entity.*;
|
||||||
import com.czg.account.service.*;
|
import com.czg.account.service.*;
|
||||||
|
|
@ -15,10 +16,8 @@ import com.czg.config.RedisCst;
|
||||||
import com.czg.entity.notify.CzgPayNotifyDTO;
|
import com.czg.entity.notify.CzgPayNotifyDTO;
|
||||||
import com.czg.entity.notify.CzgRefundNotifyDTO;
|
import com.czg.entity.notify.CzgRefundNotifyDTO;
|
||||||
import com.czg.enums.ShopUserFlowBizEnum;
|
import com.czg.enums.ShopUserFlowBizEnum;
|
||||||
import com.czg.order.dto.BigDecimalDTO;
|
import com.czg.exception.ApiNotPrintException;
|
||||||
import com.czg.order.dto.CheckOrderPay;
|
import com.czg.order.dto.*;
|
||||||
import com.czg.order.dto.OrderInfoAddDTO;
|
|
||||||
import com.czg.order.dto.OrderInfoQueryDTO;
|
|
||||||
import com.czg.order.entity.CashierCart;
|
import com.czg.order.entity.CashierCart;
|
||||||
import com.czg.order.entity.OrderDetail;
|
import com.czg.order.entity.OrderDetail;
|
||||||
import com.czg.order.entity.OrderInfo;
|
import com.czg.order.entity.OrderInfo;
|
||||||
|
|
@ -751,4 +750,19 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||||
redisService.set(key, count, 24 * 60 * 60);
|
redisService.set(key, count, 24 * 60 * 60);
|
||||||
return "#" + count;
|
return "#" + count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean printOrder(Long shopId, OrderInfoPrintDTO orderInfoPrintDTO) {
|
||||||
|
OrderInfo orderInfo = getOne(new QueryWrapper().eq(OrderInfo::getShopId, shopId).eq(OrderInfo::getId, orderInfoPrintDTO.getId()));
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue