分页数量

This commit is contained in:
wangw 2025-10-14 17:30:48 +08:00
parent b5dd99fa62
commit fa5e8893f5
15 changed files with 476 additions and 69 deletions

View File

@ -0,0 +1,58 @@
package com.czg.controller.admin;
import com.czg.config.RabbitPublisher;
import com.czg.market.dto.SmsShopTemplateDTO;
import com.czg.market.service.ShopCouponService;
import com.czg.market.service.SmsShopTemplateService;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.validator.group.InsertGroup;
import com.czg.validator.group.UpdateGroup;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 短信模板
* @author ww
* @description
*/
@Slf4j
@RestController
@RequestMapping("/admin/smsTemplate")
public class SmsShopTemplateController {
@Resource
private SmsShopTemplateService templateService;
/**
* 列表
*/
@GetMapping
public CzgResult<List<SmsShopTemplateDTO>> getTemplateList(@RequestParam(required = false) String title) {
List<SmsShopTemplateDTO> data = templateService.getTemplateList(title, StpKit.USER.getShopId());
return CzgResult.success(data);
}
/**
* 新增
*/
@PostMapping
public CzgResult<Void> addTemplate(@RequestBody @Validated(InsertGroup.class) SmsShopTemplateDTO param) {
param.setShopId(StpKit.USER.getShopId());
templateService.addTemplate(param);
return CzgResult.success();
}
/**
* 重新提交
* 状态为 -1 失败的 可以修改模板重新提交
*/
@PostMapping("/resubmit")
public CzgResult<Void> resubmit(@RequestBody @Validated(UpdateGroup.class) SmsShopTemplateDTO param) {
param.setShopId(StpKit.USER.getShopId());
templateService.resubmit(param);
return CzgResult.success();
}
}

View File

@ -21,7 +21,13 @@ public class RabbitConfig {
@Value("${spring.profiles.active}")
private String activeProfile;
@Bean
@Primary
public DirectExchange directExchange() {
return new DirectExchange(activeProfile + "-" + RabbitConstants.Exchange.CASH_EXCHANGE);
}
//------------------------------------------------------订单打印队列
@Bean
public Queue orderPrintQueue() {
// 创建一个用于存储队列参数的 Map
@ -30,7 +36,13 @@ public class RabbitConfig {
args.put("x-message-ttl", 180000);
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_PRINT_QUEUE, true, false, false, args);
}
@Bean
public Binding bindingOrderPrintExchange(Queue orderPrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(orderPrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_PRINT_QUEUE);
}
//------------------------------------------------------订单厨房票
@Bean
public Queue orderMachinePrintQueue() {
// 创建一个用于存储队列参数的 Map
@ -39,82 +51,110 @@ public class RabbitConfig {
// args.put("x-message-ttl", 180000);
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE, true, false, false);
}
@Bean
public Queue handoverPrintQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE, true, false, false);
}
@Bean
public Queue callTablePrintQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.CALL_TABLE_PRINT_QUEUE, true, false, false);
}
@Bean
public Queue orderCancelQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_CANCEL_QUEUE, true);
}
@Bean
public Queue orderStockQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_STOCK_QUEUE, true);
}
@Bean
public Queue productInfoChangeQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.PRODUCT_INFO_CHANGE_QUEUE, true);
}
@Bean
public Queue orderRefundQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_REFUND_QUEUE, true);
}
@Bean
@Primary
public DirectExchange directExchange() {
return new DirectExchange(activeProfile + "-" + RabbitConstants.Exchange.CASH_EXCHANGE);
}
@Bean
public Binding bindingOrderPrintExchange(Queue orderPrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(orderPrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_PRINT_QUEUE);
}
@Bean
public Binding bindingOrderCancelExchange(Queue orderPrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(orderPrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_CANCEL_QUEUE);
}
@Bean
public Binding bindingCallTablePrintExchange(Queue callTablePrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(callTablePrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.CALL_TABLE_PRINT_QUEUE);
}
@Bean
public Binding bindingHandoverPrintExchange(Queue handoverPrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(handoverPrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE);
}
@Bean
public Binding bindingOrderMachinePrintExchange(Queue orderMachinePrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(orderMachinePrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE);
}
//------------------------------------------------------交班打票
@Bean
public Queue handoverPrintQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE, true, false, false);
}
@Bean
public Binding bindingHandoverPrintExchange(Queue handoverPrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(handoverPrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE);
}
//------------------------------------------------------叫号 打票
@Bean
public Queue callTablePrintQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.CALL_TABLE_PRINT_QUEUE, true, false, false);
}
@Bean
public Binding bindingCallTablePrintExchange(Queue callTablePrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(callTablePrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.CALL_TABLE_PRINT_QUEUE);
}
//------------------------------------------------------订单取消
@Bean
public Queue orderCancelQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_CANCEL_QUEUE, true);
}
@Bean
public Binding bindingOrderCancelExchange(Queue orderPrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(orderPrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_CANCEL_QUEUE);
}
//------------------------------------------------------ 订单库存更新
@Bean
public Queue orderStockQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_STOCK_QUEUE, true);
}
@Bean
public Binding bindingOrderStockExchange(Queue orderStockQueue, DirectExchange exchange) {
return BindingBuilder.bind(orderStockQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_STOCK_QUEUE);
}
//------------------------------------------------------ 商品信息更新
@Bean
public Queue productInfoChangeQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.PRODUCT_INFO_CHANGE_QUEUE, true);
}
@Bean
public Binding bindingProductInfoChange(Queue productInfoChangeQueue, DirectExchange exchange) {
return BindingBuilder.bind(productInfoChangeQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.PRODUCT_INFO_CHANGE_QUEUE);
}
//------------------------------------------------------ 订单退款
@Bean
public Queue orderRefundQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_REFUND_QUEUE, true);
}
@Bean
public Binding bindingOrderRefundExchange(Queue orderRefundQueue, DirectExchange exchange) {
return BindingBuilder.bind(orderRefundQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_REFUND_QUEUE);
}
//------------------------------------------------------ 申请短信模板队列
@Bean
public Queue applySmsTemplateQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.APPLY_SMS_TEMPLATE_QUEUE, true);
}
@Bean
public Binding bindingApplySmsTemplateExchange(Queue applySmsTemplateQueue, DirectExchange exchange) {
return BindingBuilder.bind(applySmsTemplateQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.APPLY_SMS_TEMPLATE_QUEUE);
}
//------------------------------------------------------ 发送微信模板队列
@Bean
public Queue sendWechatTemplateQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.SEND_WECHAT_TEMPLATE_QUEUE, true);
}
@Bean
public Binding bindingSendWechatTemplateExchange(Queue sendWechatTemplateQueue, DirectExchange exchange) {
return BindingBuilder.bind(sendWechatTemplateQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.SEND_WECHAT_TEMPLATE_QUEUE);
}
//------------------------------------------------------ 发送营销短信队列
@Bean
public Queue sendMarketSmsQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.SEND_MARKET_SMS_QUEUE, true);
}
@Bean
public Binding bindingSendMarketSmsExchange(Queue sendMarketSmsQueue, DirectExchange exchange) {
return BindingBuilder.bind(sendMarketSmsQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.SEND_MARKET_SMS_QUEUE);
}
//------------------------------------------------------ 生日礼品短信队列
@Bean
public Queue birthdayGiftSmsQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.BIRTHDAY_GIFT_SMS_QUEUE, true);
}
@Bean
public Binding bindingBirthdayGiftSmsExchange(Queue birthdayGiftSmsQueue, DirectExchange exchange) {
return BindingBuilder.bind(birthdayGiftSmsQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.BIRTHDAY_GIFT_SMS_QUEUE);
}
}

View File

@ -18,5 +18,22 @@ public interface RabbitConstants {
public static final String ORDER_HANDOVER_PRINT_QUEUE = "order.handover.print.queue";
public static final String CALL_TABLE_PRINT_QUEUE = "call.table.print.queue";
public static final String PRODUCT_INFO_CHANGE_QUEUE = "product.info.change.queue";
/**
* 申请短信模板队列
*/
public static final String APPLY_SMS_TEMPLATE_QUEUE = "apply.sms.temp";
/**
* 发送微信模板队列
*/
public static final String SEND_WECHAT_TEMPLATE_QUEUE = "send.wechat.temp";
/**
* 发送营销短信队列
*/
public static final String SEND_MARKET_SMS_QUEUE = "send.mark.sms";
/**
* 生日礼品短信队列
*/
public static final String BIRTHDAY_GIFT_SMS_QUEUE = "birthday.gift.sms";
}
}

View File

@ -101,6 +101,41 @@ public class RabbitPublisher {
sendMsg(RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE, id.toString());
}
/**
* 申请短信模板消息
*
* @param param 申请短信模板请求 shop_id,sms_shop_template.id
*/
public void sendApplySmsTemplateMsg(String param) {
sendMsg(RabbitConstants.Queue.APPLY_SMS_TEMPLATE_QUEUE, param);
}
/**
* 发送微信模板消息
*
* @param param 发送微信模板请求 shop_id,sms_push_event.id
*/
public void sendWechatTemplateMsg(String param) {
sendMsg(RabbitConstants.Queue.SEND_WECHAT_TEMPLATE_QUEUE, param);
}
/**
* 发送营销短信队列
*
* @param param
*/
public void sendMarketSmsMsg(String param) {
sendMsg(RabbitConstants.Queue.SEND_MARKET_SMS_QUEUE, param);
}
/**
* 发送生日礼品短信队列
*
* @param param
*/
public void sendBirthdayGiftSmsMsg(String param) {
sendMsg(RabbitConstants.Queue.BIRTHDAY_GIFT_SMS_QUEUE, param);
}
private void sendMsg(String queue, String msg) {
log.info("开始发送mq消息,exchange:{}, queue: {}, msg: {}", activeProfile + "-" + RabbitConstants.Exchange.CASH_EXCHANGE, activeProfile + "-" + queue, msg);

View File

@ -8,6 +8,6 @@ import lombok.Data;
*/
@Data
public class BaseQueryParam {
private int pageNum = 1;
private int pageSize = 10;
private int page = 1;
private int size = 10;
}

View File

@ -0,0 +1,64 @@
package com.czg.market.dto;
import java.io.Serializable;
import java.time.LocalDateTime;
import com.alibaba.fastjson2.annotation.JSONField;
import java.io.Serial;
import com.czg.validator.group.InsertGroup;
import com.czg.validator.group.UpdateGroup;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Null;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* 店铺模板表 实体类
*
* @author ww
* @since 2025-10-14
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class SmsShopTemplateDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@NotNull(message = "模板内容不能为空", groups = { UpdateGroup.class})
private Long id;
private Long shopId;
/**
* 模板内容
*/
@NotNull(message = "模板内容不能为空", groups = {InsertGroup.class, UpdateGroup.class})
private Long content;
/**
* 排序
*/
private Integer sort;
/**
* 0 待申请 1 审核中 2 成功 -1失败 -2 重新申请中
*/
private Integer status;
/**
* 失败原因
*/
private String failMsg;
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,67 @@
package com.czg.market.entity;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.io.Serial;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 店铺模板表 实体类
*
* @author ww
* @since 2025-10-14
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table("sms_shop_template")
public class SmsShopTemplate implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Id(keyType = KeyType.Auto)
private Long id;
private Long shopId;
/**
* 模板名称
*/
private String title;
/**
* 模板内容
*/
private String content;
/**
* 排序
*/
private Integer sort;
/**
* 0 待申请 1 审核中 2 成功 -1失败 -2 重新申请中
*/
private Integer status;
/**
* 失败原因
*/
private String failMsg;
@Column(onInsertValue = "now()")
private LocalDateTime createTime;
@Column(onInsertValue = "now()", onUpdateValue = "now()")
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,27 @@
package com.czg.market.service;
import com.czg.market.dto.ShopCouponDTO;
import com.czg.market.dto.SmsShopTemplateDTO;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
import com.czg.market.entity.SmsShopTemplate;
import java.util.List;
/**
* 店铺模板表 服务层
*
* @author ww
* @since 2025-10-14
*/
public interface SmsShopTemplateService extends IService<SmsShopTemplate> {
/**
* 获取店铺短信模板分页列表
* @param name 模板名称 模糊
* @return 店铺短信模板列表
*/
List<SmsShopTemplateDTO> getTemplateList(String name, Long shopId);
void addTemplate(SmsShopTemplateDTO param);
void resubmit(SmsShopTemplateDTO param);
}

View File

@ -17,6 +17,7 @@ import com.alibaba.fastjson2.annotation.JSONField;
#break
#end
#end
import lombok.experimental.Accessors;
#if(withActiveRecord)
import com.mybatisflex.core.activerecord.Model;
#end
@ -54,7 +55,6 @@ import lombok.EqualsAndHashCode;
*/
#if(withLombok)
#if(withActiveRecord)
@Accessors(chain = true)
@Data(staticConstructor = "create")
@EqualsAndHashCode(callSuper = true)
#else
@ -73,6 +73,7 @@ import lombok.EqualsAndHashCode;
@Schema(description = "#(table.getComment())")
#end
#end
@Accessors(chain = true)
public class #(entityClassName)#if(withActiveRecord) extends Model<#(entityClassName)>#else#(table.buildExtends(isBase))#(table.buildImplements())#end {
#if(jdkVersion >= 14)

View File

@ -12,7 +12,11 @@
<name>market-service</name>
<dependencies>
<dependency>
<groupId>com.czg</groupId>
<artifactId>cash-common-mq</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>

View File

@ -0,0 +1,14 @@
package com.czg.service.market.mapper;
import com.mybatisflex.core.BaseMapper;
import com.czg.market.entity.SmsShopTemplate;
/**
* 店铺模板表 映射层
*
* @author ww
* @since 2025-10-14
*/
public interface SmsShopTemplateMapper extends BaseMapper<SmsShopTemplate> {
}

View File

@ -12,6 +12,7 @@ import com.czg.market.service.MkDiscountActivityService;
import com.czg.service.market.mapper.MkDiscountActivityMapper;
import com.czg.service.market.mapper.MkDiscountThresholdMapper;
import com.czg.utils.AssertUtil;
import com.czg.utils.CzgStrUtils;
import com.czg.utils.PageUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
@ -41,8 +42,8 @@ public class MkDiscountActivityServiceImpl extends ServiceImpl<MkDiscountActivit
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq(MkDiscountActivity::getShopId, shopId)
.eq(MkDiscountActivity::getIsDel, 0)
.lt(MkDiscountActivity::getValidStartTime, param.getStartTime())
.le(MkDiscountActivity::getValidEndTime, param.getEndTime())
.lt(MkDiscountActivity::getValidStartTime, CzgStrUtils.getStrOrNull(param.getStartTime()))
.le(MkDiscountActivity::getValidEndTime, CzgStrUtils.getStrOrNull(param.getEndTime()))
.orderBy(MkDiscountActivity::getSort).desc()
.orderBy(MkDiscountActivity::getUpdateTime).desc();
Page<MkDiscountActivityDTO> page = pageAs(PageUtil.buildPage(), queryWrapper, MkDiscountActivityDTO.class);

View File

@ -0,0 +1,71 @@
package com.czg.service.market.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.czg.config.RabbitPublisher;
import com.czg.market.dto.SmsShopTemplateDTO;
import com.czg.market.entity.ShopCoupon;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.market.entity.SmsShopTemplate;
import com.czg.market.service.SmsShopTemplateService;
import com.czg.service.market.mapper.SmsShopTemplateMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* 店铺模板表 服务层实现
*
* @author ww
* @since 2025-10-14
*/
@Service
public class SmsShopTemplateServiceImpl extends ServiceImpl<SmsShopTemplateMapper, SmsShopTemplate> implements SmsShopTemplateService {
@Resource
private RabbitPublisher rabbitPublisher;
@Override
public List<SmsShopTemplateDTO> getTemplateList(String name, Long shopId) {
List<Long> list = Arrays.asList(1L, shopId);
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.like(SmsShopTemplate::getTitle, name)
.in(SmsShopTemplate::getShopId, list)
.orderBy(SmsShopTemplate::getShopId).asc()
.orderBy(SmsShopTemplate::getSort).asc();
return listAs(queryWrapper, SmsShopTemplateDTO.class);
}
@Override
public void addTemplate(SmsShopTemplateDTO param) {
SmsShopTemplate template = BeanUtil.toBean(param, SmsShopTemplate.class);
template.setStatus(0);
save(template);
sendApplyMsg(template.getShopId(), template.getId());
}
@Override
public void resubmit(SmsShopTemplateDTO param) {
// 校验状态是否为 -1 失败
SmsShopTemplate template1 = getById(param.getId());
if (!template1.getStatus().equals(-1)) {
throw new IllegalArgumentException("只有失败的模板才能重新提交");
}
SmsShopTemplate template = BeanUtil.toBean(param, SmsShopTemplate.class);
template.setStatus(2);
template.setFailMsg("");
updateById(template);
sendApplyMsg(template.getShopId(), template.getId());
}
private void sendApplyMsg(Long shopId, Long templateId) {
// 推送消息 进行 阿里模板申请
rabbitPublisher.sendApplySmsTemplateMsg(shopId + "," + templateId);
}
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.czg.service.market.mapper.SmsShopTemplateMapper">
</mapper>

View File

@ -28,10 +28,11 @@
<artifactId>market-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.czg</groupId>
<artifactId>cash-common-mq</artifactId>
<version>${project.version}</version>
</dependency>
<!-- 订单服务依赖消息队列 从 market 拿 -->
<!-- <dependency>-->
<!-- <groupId>com.czg</groupId>-->
<!-- <artifactId>cash-common-mq</artifactId>-->
<!-- <version>${project.version}</version>-->
<!-- </dependency>-->
</dependencies>
</project>