|
|
@@ -6,6 +6,8 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
@@ -17,6 +19,7 @@ import shop.alien.store.service.impl.PrintService;
|
|
|
import shop.alien.store.service.impl.PrintTemplate;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
@@ -122,10 +125,10 @@ public class PrintController {
|
|
|
ctx.put("orderNo", "2026");
|
|
|
ctx.put("tableNo", "A1054");
|
|
|
ctx.put("peopleCount", 2);
|
|
|
- ctx.put("diningTime", "2026/01/01 12:00:00~14:00");
|
|
|
+ ctx.put("diningTime", "2026/01/01 12:00~14:00");
|
|
|
ctx.put("name", "熊二");
|
|
|
ctx.put("phone", "123 6544 7899");
|
|
|
- ctx.put("cashierTime", "2026/01/01 12:00:00");
|
|
|
+ ctx.put("cashierTime", "2026/01/01 12:00");
|
|
|
ctx.put("orderBy", "熊大");
|
|
|
|
|
|
List<Map<String, Object>> items = new ArrayList<>();
|
|
|
@@ -156,12 +159,53 @@ public class PrintController {
|
|
|
ctx.put("paymentTotal", "630.00");
|
|
|
|
|
|
ctx.put("printBy", "吉尾尘");
|
|
|
- ctx.put("orderAt", "2026/01/01 12:00:00");
|
|
|
- ctx.put("printAt", "2026/01/01 12:00:00");
|
|
|
+ ctx.put("orderAt", "2026/01/01 12:00");
|
|
|
+ ctx.put("printAt", "2026/01/01 12:00");
|
|
|
return ctx;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 新增打印机
|
|
|
+ * 访问地址:POST /print/createPrinter
|
|
|
+ * 请求体:PrinterDO JSON(至少包含 sn、brand、printerName、storeId)
|
|
|
+ */
|
|
|
+ @PostMapping("/createPrinter")
|
|
|
+ public Object createPrinter(@RequestBody PrinterDO body) {
|
|
|
+ if (body == null) {
|
|
|
+ return "参数不能为空";
|
|
|
+ }
|
|
|
+ if (body.getSn() == null || body.getSn().trim().isEmpty()) {
|
|
|
+ return "sn不能为空";
|
|
|
+ }
|
|
|
+ if (body.getBrand() == null || body.getBrand().trim().isEmpty()) {
|
|
|
+ return "brand不能为空";
|
|
|
+ }
|
|
|
+ if (body.getPrinterName() == null || body.getPrinterName().trim().isEmpty()) {
|
|
|
+ return "printerName不能为空";
|
|
|
+ }
|
|
|
+ if (body.getStoreId() == null || body.getStoreId() <= 0) {
|
|
|
+ return "storeId必须大于0";
|
|
|
+ }
|
|
|
+ // 去重:同门店下 SN 唯一且未删除
|
|
|
+ Long exists = Long.valueOf(printerMapper.selectCount(
|
|
|
+ new LambdaQueryWrapper<PrinterDO>()
|
|
|
+ .eq(PrinterDO::getStoreId, body.getStoreId())
|
|
|
+ .eq(PrinterDO::getSn, body.getSn())
|
|
|
+ .eq(PrinterDO::getDelFlag, "0")
|
|
|
+ ));
|
|
|
+ if (exists > 0) {
|
|
|
+ return "该门店已存在相同SN的打印机";
|
|
|
+ }
|
|
|
+ body.setId(null);
|
|
|
+ body.setCreateTime(LocalDateTime.now());
|
|
|
+ if (body.getDelFlag() == null) {
|
|
|
+ body.setDelFlag("0");
|
|
|
+ }
|
|
|
+ printerMapper.insert(body);
|
|
|
+ return body;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 查询所有打印机
|
|
|
* 访问地址:http://localhost:8080/print/list
|
|
|
*/
|