Merge remote-tracking branch 'origin/master'

This commit is contained in:
Tankaikai
2025-02-26 16:57:54 +08:00
24 changed files with 544 additions and 77 deletions

View File

@@ -6,6 +6,7 @@ import com.czg.account.service.PermissionService;
import com.czg.account.vo.LoginVO;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.annotation.SaStaffCheckPermission;
import com.czg.config.RabbitPublisher;
import com.czg.mq.PrintMqListener;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
@@ -54,9 +55,12 @@ public class AuthorizationController {
@Resource
PrintMqListener printMqListener;
@Resource
RabbitPublisher rabbitPublisher;
@GetMapping("test")
public CzgResult<?> login() {
printMqListener.orderPrint("1");
rabbitPublisher.sendOrderPrintMsg("1");
// printMqListener.orderPrint("1");
// return CzgResult.success(Map.of("token", StpKit.USER.getShopId()));
return CzgResult.success();
}

View File

@@ -0,0 +1,91 @@
package com.czg.controller.admin;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.ad.ShopAdDTO;
import com.czg.account.entity.ShopAd;
import com.czg.account.service.ShopAdService;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.exception.ApiNotPrintException;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.validator.group.InsertGroup;
import com.czg.validator.group.UpdateGroup;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 小程序广告管理
* @author Administrator
*/
@RestController
@RequestMapping("/admin/shopAd")
public class ShopAdController {
@Resource
private ShopAdService shopAdService;
/**
* 小程序广告列表
* @param showPosition 展示位置 home首页make_order点餐页
* @param status 状态 0未启用1已启用
* @return 列表
*/
@SaAdminCheckPermission(value = "shopAd:list", name = "小程序广告列表")
@GetMapping
public CzgResult<List<ShopAd>> list(String showPosition, Integer status) {
QueryWrapper queryWrapper = new QueryWrapper().eq(ShopAd::getShopId, StpKit.USER.getShopId());
if (StrUtil.isNotBlank(showPosition)) {
queryWrapper.eq(ShopAd::getShowPosition, showPosition);
}
queryWrapper.eq(ShopAd::getStatus, status);
return CzgResult.success(shopAdService.list(queryWrapper));
}
/**
* 小程序广告详情
* @param id adId
* @return 详情
*/
@SaAdminCheckPermission(value = "shopAd:detail", name = "小程序广告详情")
@GetMapping("/detail")
public CzgResult<ShopAd> detail(@RequestParam Integer id) {
return CzgResult.success(shopAdService.getOne(new QueryWrapper().eq(ShopAd::getId, id).eq(ShopAd::getShopId, StpKit.USER.getShopId())));
}
/**
* 小程序广告编辑
* @return 是否成功
*/
@SaAdminCheckPermission(value = "shopAd:list", name = "小程序广告编辑")
@PutMapping
public CzgResult<Boolean> edit(@RequestBody @Validated(UpdateGroup.class) ShopAdDTO shopAdEditDTO) {
ShopAd shopAd = BeanUtil.copyProperties(shopAdEditDTO, ShopAd.class);
long count = shopAdService.count(new QueryWrapper().eq(ShopAd::getShopId, StpKit.USER.getShopId()).like(ShopAd::getShowPosition, shopAdEditDTO.getShowPosition()).ne(ShopAd::getId, shopAdEditDTO.getId()));
if (count > 0) {
return CzgResult.failure("小程序此位置已存在广告");
}
return CzgResult.success(shopAdService.update(shopAd, new QueryWrapper().eq(ShopAd::getId, shopAdEditDTO.getId()).eq(ShopAd::getShopId, StpKit.USER.getShopId())));
}
/**
* 小程序广告添加
* @return 是否成功
*/
@SaAdminCheckPermission(value = "shopAd:add", name = "小程序广告添加")
@PostMapping
public CzgResult<Boolean> add(@RequestBody @Validated(InsertGroup.class) ShopAdDTO shopAdEditDTO) {
long count = shopAdService.count(new QueryWrapper().eq(ShopAd::getShopId, StpKit.USER.getShopId()).like(ShopAd::getShowPosition, shopAdEditDTO.getShowPosition()));
if (count > 0) {
return CzgResult.failure("小程序此位置已存在广告");
}
ShopAd shopAd = BeanUtil.copyProperties(shopAdEditDTO, ShopAd.class);
shopAd.setShopId(StpKit.USER.getShopId());
return CzgResult.success(shopAdService.save(shopAd));
}
}

View File

@@ -15,7 +15,9 @@ import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
@@ -40,7 +42,7 @@ public class PrintMqListener {
@Resource
private PrinterHandler printerHandler;
// @RabbitListener(queues = {RabbitConstants.Queue.ORDER_PRINT_QUEUE})
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.ORDER_PRINT_QUEUE})
public void orderPrint(String orderId) {
long startTime = DateUtil.date().getTime();
log.info("接收到订单打印消息:{}", orderId);
@@ -52,18 +54,17 @@ public class PrintMqListener {
throw new RuntimeException("订单信息不存在");
}
getPrintMachine(1L, "cash", "one", "order").forEach(machine -> {
getPrintMachine(orderInfo.getShopId(), "cash", "all", "order").forEach(machine -> {
printerHandler.handleRequest(machine, orderInfo, null);
// printPlaceTicket(isReturn, machine, orderInfo, shopInfo);
});
}catch (Exception e) {
log.error("订单打印失败", e);
mqLog.setErrInfo(JSONObject.toJSONString(e));
mqLog.setDuration(DateUtil.date().getTime() - startTime);
mqLog.setFailTime(DateUtil.date().toLocalDateTime());
// mqLogService.save(mqLog);
mqLogService.save(mqLog);
}
}