Compare commits

..

No commits in common. "887ab084e96188bbf4934028cca7b08c965b9683" and "5b7c78e0247c29a229a0c0e6b3e584bb265cc1d5" have entirely different histories.

8 changed files with 4 additions and 80 deletions

View File

@ -85,10 +85,4 @@ public interface CacheNames {
*/ */
String DELAY_ORDER_UNPAY = GlobalConstants.GLOBAL_REDIS_KEY + "order_unpay"; String DELAY_ORDER_UNPAY = GlobalConstants.GLOBAL_REDIS_KEY + "order_unpay";
/**
* 延时队列订单支付未核销
*/
String DELAY_ORDER_TO_BE_USED = GlobalConstants.GLOBAL_REDIS_KEY + "order_tobe_used";
} }

View File

@ -73,14 +73,9 @@ public interface Constants {
Long TOP_PARENT_ID = 0L; Long TOP_PARENT_ID = 0L;
/** /**
* 订单未支付自动取消时间分钟 * 订单未支付自动取消时间
*/ */
Long ORDER_CANCEL_TIME = 15L; Long ORDER_CANCEL_TIME = 900L;
/**
* 订单支付未核销自动退款时间
*/
Long ORDER_REFUND_TIME = 14L;
} }

View File

@ -14,7 +14,6 @@ import org.dromara.common.core.domain.R;
import org.dromara.common.log.annotation.Log; import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType; import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.web.core.BaseController; import org.dromara.common.web.core.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
@ -30,7 +29,6 @@ import java.util.List;
@RestController @RestController
@RequestMapping("/pms/product/category") @RequestMapping("/pms/product/category")
@RequiredArgsConstructor @RequiredArgsConstructor
@Validated
public class ProductCategoryController extends BaseController { public class ProductCategoryController extends BaseController {
private final ProductCategoryService service; private final ProductCategoryService service;

View File

@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data; import lombok.Data;
import org.apache.ibatis.type.JdbcType; import org.apache.ibatis.type.JdbcType;
import org.dromara.common.core.domain.model.BaseAudit; import org.dromara.common.core.domain.model.BaseAudit;
@ -31,7 +30,6 @@ public class ProductCategory extends BaseAudit {
@Schema(description = "NAME") @Schema(description = "NAME")
@Excel(name = "NAME") @Excel(name = "NAME")
@NotBlank(message = "名称不能为空")
private String name; private String name;
@Schema(description = "分类级别0->1级1->2级") @Schema(description = "分类级别0->1级1->2级")
@ -48,7 +46,6 @@ public class ProductCategory extends BaseAudit {
@Schema(description = "图标") @Schema(description = "图标")
@Excel(name = "图标") @Excel(name = "图标")
@NotBlank(message = "图标不能为空")
private String icon; private String icon;
@Schema(description = "删除标志0代表存在1代表删除") @Schema(description = "删除标志0代表存在1代表删除")

View File

@ -8,10 +8,5 @@ import com.wzj.soopin.goods.domain.vo.ProductCategoryVO;
import java.util.List; import java.util.List;
public interface ProductCategoryService extends IService<ProductCategory> { public interface ProductCategoryService extends IService<ProductCategory> {
boolean save(ProductCategory productCategory);
boolean updateById(ProductCategory productCategory);
List<ProductCategoryVO> tree(Wrapper<ProductCategory> wrapper); List<ProductCategoryVO> tree(Wrapper<ProductCategory> wrapper);
} }

View File

@ -1,8 +1,6 @@
package com.wzj.soopin.goods.service.impl; package com.wzj.soopin.goods.service.impl;
import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wzj.soopin.goods.convert.ProductCategoryConvert; import com.wzj.soopin.goods.convert.ProductCategoryConvert;
import com.wzj.soopin.goods.domain.entity.ProductCategory; import com.wzj.soopin.goods.domain.entity.ProductCategory;
@ -10,7 +8,6 @@ import com.wzj.soopin.goods.domain.vo.ProductCategoryVO;
import com.wzj.soopin.goods.mapper.ProductCategoryMapper; import com.wzj.soopin.goods.mapper.ProductCategoryMapper;
import com.wzj.soopin.goods.service.ProductCategoryService; import com.wzj.soopin.goods.service.ProductCategoryService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.dromara.common.core.exception.ServiceException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -31,32 +28,6 @@ public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMappe
private final ProductCategoryConvert convert; private final ProductCategoryConvert convert;
@Override
public boolean save(ProductCategory productCategory) {
if (productCategory.getParentId() == null || productCategory.getParentId() == 0) {
productCategory.setLevel(1);
productCategory.setParentId(0L);
} else {
ProductCategory parent = this.getById(productCategory.getParentId());
productCategory.setLevel(parent.getLevel() + 1);
}
boolean exists = this.exists(Wrappers.lambdaQuery(ProductCategory.class)
.eq(ProductCategory::getName, productCategory.getName())
.eq(ProductCategory::getParentId, productCategory.getParentId()));
Assert.isFalse(exists, () -> ServiceException.of("分类已存在"));
return super.save(productCategory);
}
@Override
public boolean updateById(ProductCategory productCategory) {
boolean exists = this.exists(Wrappers.lambdaQuery(ProductCategory.class)
.ne(ProductCategory::getId, productCategory.getId())
.eq(ProductCategory::getName, productCategory.getName())
.eq(ProductCategory::getParentId, productCategory.getParentId()));
Assert.isFalse(exists, () -> ServiceException.of("分类已存在"));
return super.updateById(productCategory);
}
@Override @Override
public List<ProductCategoryVO> tree(Wrapper<ProductCategory> wrapper) { public List<ProductCategoryVO> tree(Wrapper<ProductCategory> wrapper) {
List<ProductCategory> list = this.list(wrapper); List<ProductCategory> list = this.list(wrapper);

View File

@ -64,10 +64,8 @@ import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.dromara.common.core.constant.CacheNames.DELAY_ORDER_TO_BE_USED;
import static org.dromara.common.core.constant.CacheNames.DELAY_ORDER_UNPAY; import static org.dromara.common.core.constant.CacheNames.DELAY_ORDER_UNPAY;
import static org.dromara.common.core.constant.Constants.ORDER_CANCEL_TIME; import static org.dromara.common.core.constant.Constants.ORDER_CANCEL_TIME;
import static org.dromara.common.core.constant.Constants.ORDER_REFUND_TIME;
/** /**
@ -283,7 +281,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
}).toList(); }).toList();
orderItemMapper.insert(orderItemList); orderItemMapper.insert(orderItemList);
// 添加订单到延迟队列 // 添加订单到延迟队列
QueueUtils.addDelayedQueueObject(DELAY_ORDER_UNPAY, order.getId(), ORDER_CANCEL_TIME, TimeUnit.MINUTES); QueueUtils.addDelayedQueueObject(DELAY_ORDER_UNPAY, order.getId(), ORDER_CANCEL_TIME, TimeUnit.SECONDS);
return BeanUtil.copyProperties(order, OrderVO.class); return BeanUtil.copyProperties(order, OrderVO.class);
} }
@ -567,8 +565,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
.paymentTime(LocalDateTime.now()) .paymentTime(LocalDateTime.now())
.payType(payType) .payType(payType)
.build()); .build());
// 添加已支付订单到延迟队列14天未使用自动退款
QueueUtils.addDelayedQueueObject(DELAY_ORDER_TO_BE_USED, order.getId(), ORDER_REFUND_TIME, TimeUnit.DAYS);
//发出消息 //发出消息
MqUtil.sendIMMessage(buildMQMessage(order)); MqUtil.sendIMMessage(buildMQMessage(order));
} }

View File

@ -14,7 +14,6 @@ import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import static org.dromara.common.core.constant.CacheNames.DELAY_ORDER_TO_BE_USED;
import static org.dromara.common.core.constant.CacheNames.DELAY_ORDER_UNPAY; import static org.dromara.common.core.constant.CacheNames.DELAY_ORDER_UNPAY;
/** /**
@ -66,26 +65,4 @@ public class OrderScheduledTask {
}); });
}, true); }, true);
} }
/**
* 订阅redis延迟队列退款已支付未核销的订单
*/
@PostConstruct
public void orderRefundByDelayedQueue() {
log.info("订单已支付未核销延时队列: {} 监听中......",DELAY_ORDER_TO_BE_USED);
// 项目初始化设置一次即可
QueueUtils.subscribeBlockingQueue(DELAY_ORDER_TO_BE_USED, (Long orderId) -> {
// 观察接收时间
log.info("订单未支付延时队列: {}, 收到订单id: {}", DELAY_ORDER_TO_BE_USED, orderId);
return CompletableFuture.runAsync(() -> {
// 异步处理数据逻辑 不要在上方处理业务逻辑
orderService.update(Wrappers.lambdaUpdate(Order.class)
.eq(Order::getId, orderId)
.eq(Order::getStatus, OrderStatusEnum.VERIFY.getValue())
.set(Order::getStatus, OrderStatusEnum.REFUNDED.getValue()));
// TODO退款
});
}, true);
}
} }