订单过期返还库存
This commit is contained in:
@@ -52,7 +52,4 @@ public interface TbProductMapper extends BaseMapper<TbProductDto, TbProduct> {
|
|||||||
.map(String::valueOf)
|
.map(String::valueOf)
|
||||||
.collect(Collectors.joining(","));
|
.collect(Collectors.joining(","));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Select("select * from tb_product where id=#{id}")
|
|
||||||
TbProduct selectById(@Param("id") Integer productId);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ package cn.ysk.cashier.mapper.product;
|
|||||||
import cn.ysk.cashier.base.BaseMapper;
|
import cn.ysk.cashier.base.BaseMapper;
|
||||||
import cn.ysk.cashier.pojo.product.TbProductSku;
|
import cn.ysk.cashier.pojo.product.TbProductSku;
|
||||||
import cn.ysk.cashier.dto.product.TbProductSkuDto;
|
import cn.ysk.cashier.dto.product.TbProductSkuDto;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Update;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.ReportingPolicy;
|
import org.mapstruct.ReportingPolicy;
|
||||||
|
|
||||||
|
|||||||
@@ -51,4 +51,8 @@ public interface TbProductRepository extends JpaRepository<TbProduct, Integer>,
|
|||||||
@Query("update FROM TbProduct pro set pro.stockNumber=:stocktakinNum where pro.id=:id and pro.stockNumber=:stockNumber")
|
@Query("update FROM TbProduct pro set pro.stockNumber=:stocktakinNum where pro.id=:id and pro.stockNumber=:stockNumber")
|
||||||
Integer updateStock(@Param("id") Integer id,@Param("stockNumber") Integer stockNumber,
|
Integer updateStock(@Param("id") Integer id,@Param("stockNumber") Integer stockNumber,
|
||||||
@Param("stocktakinNum") Integer stocktakinNum);
|
@Param("stocktakinNum") Integer stocktakinNum);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("update TbProduct set stockNumber=stockNumber+:num where id=:id")
|
||||||
|
void incrStock(@Param("id") Integer id, @Param("num") Integer num);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package cn.ysk.cashier.repository.product;
|
|||||||
import cn.ysk.cashier.pojo.product.TbProductSku;
|
import cn.ysk.cashier.pojo.product.TbProductSku;
|
||||||
import cn.ysk.cashier.vo.StockV2Vo;
|
import cn.ysk.cashier.vo.StockV2Vo;
|
||||||
import cn.ysk.cashier.vo.StockVo;
|
import cn.ysk.cashier.vo.StockVo;
|
||||||
|
import org.apache.ibatis.annotations.Update;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
@@ -151,4 +152,8 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
|
|||||||
@Modifying
|
@Modifying
|
||||||
@Query("UPDATE TbProductSku p SET p.warnLine = :warnLine WHERE p.shopId = :shopId")
|
@Query("UPDATE TbProductSku p SET p.warnLine = :warnLine WHERE p.shopId = :shopId")
|
||||||
Integer updateWarnLineByShopId(@Param("warnLine")Integer warnLine, @Param("shopId")String shopId);
|
Integer updateWarnLineByShopId(@Param("warnLine")Integer warnLine, @Param("shopId")String shopId);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("update TbProductSku set stockNumber=stockNumber+:num where id=:productId")
|
||||||
|
void incrStock(@Param("productId") Integer productId, @Param("num") Double num);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,14 @@ import cn.ysk.cashier.dto.order.TbOrderInfoDto;
|
|||||||
import cn.ysk.cashier.dto.order.TbOrderInfoQueryCriteria;
|
import cn.ysk.cashier.dto.order.TbOrderInfoQueryCriteria;
|
||||||
import cn.ysk.cashier.dto.order.TbPayCountQueryCriteria;
|
import cn.ysk.cashier.dto.order.TbPayCountQueryCriteria;
|
||||||
import cn.ysk.cashier.mapper.order.TbOrderInfoMapper;
|
import cn.ysk.cashier.mapper.order.TbOrderInfoMapper;
|
||||||
|
import cn.ysk.cashier.mapper.product.TbProductMapper;
|
||||||
|
import cn.ysk.cashier.mapper.product.TbProductSkuMapper;
|
||||||
import cn.ysk.cashier.mybatis.entity.TbOrderPayment;
|
import cn.ysk.cashier.mybatis.entity.TbOrderPayment;
|
||||||
import cn.ysk.cashier.mybatis.service.TbOrderPaymentService;
|
import cn.ysk.cashier.mybatis.service.TbOrderPaymentService;
|
||||||
import cn.ysk.cashier.pojo.TbShopPayType;
|
import cn.ysk.cashier.pojo.TbShopPayType;
|
||||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||||
|
import cn.ysk.cashier.pojo.product.TbProduct;
|
||||||
import cn.ysk.cashier.pojo.shop.TbMerchantThirdApply;
|
import cn.ysk.cashier.pojo.shop.TbMerchantThirdApply;
|
||||||
import cn.ysk.cashier.repository.TbShopPayTypeRepository;
|
import cn.ysk.cashier.repository.TbShopPayTypeRepository;
|
||||||
import cn.ysk.cashier.repository.order.TbCashierCartRepository;
|
import cn.ysk.cashier.repository.order.TbCashierCartRepository;
|
||||||
@@ -19,6 +22,7 @@ import cn.ysk.cashier.repository.order.TbOrderInfoRepository;
|
|||||||
import cn.ysk.cashier.repository.product.TbProductSkuRepository;
|
import cn.ysk.cashier.repository.product.TbProductSkuRepository;
|
||||||
import cn.ysk.cashier.repository.shop.TbMerchantThirdApplyRepository;
|
import cn.ysk.cashier.repository.shop.TbMerchantThirdApplyRepository;
|
||||||
import cn.ysk.cashier.service.order.TbOrderInfoService;
|
import cn.ysk.cashier.service.order.TbOrderInfoService;
|
||||||
|
import cn.ysk.cashier.service.product.TbProductService;
|
||||||
import cn.ysk.cashier.thirdpay.resp.OrderStatusQueryResp;
|
import cn.ysk.cashier.thirdpay.resp.OrderStatusQueryResp;
|
||||||
import cn.ysk.cashier.thirdpay.resp.PublicResp;
|
import cn.ysk.cashier.thirdpay.resp.PublicResp;
|
||||||
import cn.ysk.cashier.thirdpay.service.ThirdPayService;
|
import cn.ysk.cashier.thirdpay.service.ThirdPayService;
|
||||||
@@ -65,6 +69,9 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||||||
private final TbOrderDetailRepository tbOrderDetailRepository;
|
private final TbOrderDetailRepository tbOrderDetailRepository;
|
||||||
private final TbShopPayTypeRepository payTypeRepository;
|
private final TbShopPayTypeRepository payTypeRepository;
|
||||||
private final TbProductSkuRepository skuRepository;
|
private final TbProductSkuRepository skuRepository;
|
||||||
|
private final TbProductMapper productMapper;
|
||||||
|
private final TbProductSkuMapper productSkuMapper;
|
||||||
|
private final TbProductService productService;
|
||||||
private final TbOrderPaymentService paymentService;
|
private final TbOrderPaymentService paymentService;
|
||||||
private final TbMerchantThirdApplyRepository thirdApplyRepository;
|
private final TbMerchantThirdApplyRepository thirdApplyRepository;
|
||||||
private final RedisUtils redisUtils;
|
private final RedisUtils redisUtils;
|
||||||
@@ -247,7 +254,6 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||||||
if (tbOrderInfo.getStatus().equals("unpaid")) {
|
if (tbOrderInfo.getStatus().equals("unpaid")) {
|
||||||
upOrderStatus(tbOrderInfo);
|
upOrderStatus(tbOrderInfo);
|
||||||
jsonObject1.put("orderId",tbOrderInfo.getId());
|
jsonObject1.put("orderId",tbOrderInfo.getId());
|
||||||
|
|
||||||
// 发送取消订单mq消息
|
// 发送取消订单mq消息
|
||||||
rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT,
|
rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT,
|
||||||
jsonObject1.toJSONString(), new CorrelationData(UUID.randomUUID().toString()));
|
jsonObject1.toJSONString(), new CorrelationData(UUID.randomUUID().toString()));
|
||||||
@@ -320,7 +326,8 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||||||
Set<String> keys = new HashSet<>();
|
Set<String> keys = new HashSet<>();
|
||||||
for (TbOrderDetail detail : details) {
|
for (TbOrderDetail detail : details) {
|
||||||
detail.setStatus("cancelled");
|
detail.setStatus("cancelled");
|
||||||
skuRepository.updateStockNumber(detail.getId(), new Double(detail.getNum()));
|
// 返还库存
|
||||||
|
productService.returnStockByPro(detail.getProductId(), detail.getProductSkuId(), detail.getNum());
|
||||||
tbOrderDetailRepository.save(detail);
|
tbOrderDetailRepository.save(detail);
|
||||||
keys.add(CacheKey.PRODUCT_SKU + detail.getShopId() + ":" + detail.getId());
|
keys.add(CacheKey.PRODUCT_SKU + detail.getShopId() + ":" + detail.getId());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import cn.ysk.cashier.dto.product.TbProductSortCriteria;
|
|||||||
import cn.ysk.cashier.dto.shop.TbCouponCategoryDto;
|
import cn.ysk.cashier.dto.shop.TbCouponCategoryDto;
|
||||||
import cn.ysk.cashier.exception.BadRequestException;
|
import cn.ysk.cashier.exception.BadRequestException;
|
||||||
import cn.ysk.cashier.mapper.product.TbProductMapper;
|
import cn.ysk.cashier.mapper.product.TbProductMapper;
|
||||||
|
import cn.ysk.cashier.mapper.product.TbProductSkuMapper;
|
||||||
import cn.ysk.cashier.mybatis.entity.TagProductDepts;
|
import cn.ysk.cashier.mybatis.entity.TagProductDepts;
|
||||||
import cn.ysk.cashier.mybatis.service.TagProductDeptsService;
|
import cn.ysk.cashier.mybatis.service.TagProductDeptsService;
|
||||||
import cn.ysk.cashier.pojo.product.*;
|
import cn.ysk.cashier.pojo.product.*;
|
||||||
@@ -61,6 +62,7 @@ public class TbProductServiceImpl implements TbProductService {
|
|||||||
private final TbProductSkuRepository tbProductSkuRepository;
|
private final TbProductSkuRepository tbProductSkuRepository;
|
||||||
private final TbShopUnitRepository tbShopUnitRepository;
|
private final TbShopUnitRepository tbShopUnitRepository;
|
||||||
private final TbProductSpecRepository tbProductSpecRepository;
|
private final TbProductSpecRepository tbProductSpecRepository;
|
||||||
|
private final TbProductSkuMapper TbProductSkuMapper;
|
||||||
private final TbProductSkuResultRepository tbProductSkuResultRepository;
|
private final TbProductSkuResultRepository tbProductSkuResultRepository;
|
||||||
private final TbShopCategoryRepository tbShopCategoryRepository;
|
private final TbShopCategoryRepository tbShopCategoryRepository;
|
||||||
private final TbShopUserDutyDetailRepository tbShopUserDutyDetailRe;
|
private final TbShopUserDutyDetailRepository tbShopUserDutyDetailRe;
|
||||||
@@ -650,4 +652,19 @@ public class TbProductServiceImpl implements TbProductService {
|
|||||||
public void incrStockNumber(String productId, Integer number) {
|
public void incrStockNumber(String productId, Integer number) {
|
||||||
tbProductRepository.incrProductStockNumber(Integer.valueOf(productId), number);
|
tbProductRepository.incrProductStockNumber(Integer.valueOf(productId), number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void returnStockByPro(Integer productId, Integer productSkuId, Integer num) {
|
||||||
|
log.info("开始返还库存,订单超时取消,商品id:{}", productId);
|
||||||
|
TbProduct product = tbProductRepository.findById(productId).orElse(null);
|
||||||
|
if (product == null) {
|
||||||
|
log.info("返还库存失败,商品不存在: {}", productId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (product.getIsDistribute() == 1) {
|
||||||
|
tbProductRepository.incrStock(productId, num);
|
||||||
|
}else {
|
||||||
|
tbProductSkuRepository.incrStock(productSkuId, Double.valueOf(num));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,58 +5,64 @@ import cn.ysk.cashier.pojo.product.TbProduct;
|
|||||||
import cn.ysk.cashier.vo.TbProductVo;
|
import cn.ysk.cashier.vo.TbProductVo;
|
||||||
import cn.ysk.cashier.dto.product.TbProductDto;
|
import cn.ysk.cashier.dto.product.TbProductDto;
|
||||||
import cn.ysk.cashier.dto.product.TbProductQueryCriteria;
|
import cn.ysk.cashier.dto.product.TbProductQueryCriteria;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @website https://eladmin.vip
|
* @author lyf
|
||||||
* @description 服务接口
|
* @website https://eladmin.vip
|
||||||
* @author lyf
|
* @description 服务接口
|
||||||
* @date 2023-12-11
|
* @date 2023-12-11
|
||||||
**/
|
**/
|
||||||
public interface TbProductService {
|
public interface TbProductService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询数据分页
|
* 查询数据分页
|
||||||
* @param criteria 条件
|
*
|
||||||
* @param isAdmin 是否为后台查询
|
* @param criteria 条件
|
||||||
* @return Map<String,Object>
|
* @param isAdmin 是否为后台查询
|
||||||
*/
|
* @return Map<String, Object>
|
||||||
Map<String,Object> queryAll(TbProductQueryCriteria criteria, boolean isAdmin);
|
*/
|
||||||
|
Map<String, Object> queryAll(TbProductQueryCriteria criteria, boolean isAdmin);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有数据不分页
|
* 查询所有数据不分页
|
||||||
* @param criteria 条件参数
|
*
|
||||||
* @return List<TbProductDto>
|
* @param criteria 条件参数
|
||||||
*/
|
* @return List<TbProductDto>
|
||||||
List<TbProductDto> queryAlls(TbProductQueryCriteria criteria);
|
*/
|
||||||
|
List<TbProductDto> queryAlls(TbProductQueryCriteria criteria);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID查询
|
* 根据ID查询
|
||||||
|
*
|
||||||
* @param id ID
|
* @param id ID
|
||||||
* @return TbProductDto
|
* @return TbProductDto
|
||||||
*/
|
*/
|
||||||
TbProductDto findById(Integer id);
|
TbProductDto findById(Integer id);
|
||||||
|
|
||||||
TbProductVo findByProductId(Integer id)throws Exception;
|
TbProductVo findByProductId(Integer id) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
List<TbProduct>findByProductList(List<String> productList);
|
List<TbProduct> findByProductList(List<String> productList);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建
|
* 创建
|
||||||
* @param resources /
|
*
|
||||||
* @return TbProductDto
|
* @param resources /
|
||||||
*/
|
* @return TbProductDto
|
||||||
|
*/
|
||||||
Object create(TbProductVo resources);
|
Object create(TbProductVo resources);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑
|
* 编辑
|
||||||
* @param resources /
|
*
|
||||||
*/
|
* @param resources /
|
||||||
|
*/
|
||||||
void update(TbProductVo resources);
|
void update(TbProductVo resources);
|
||||||
|
|
||||||
void upProSort(TbProductSortCriteria param);
|
void upProSort(TbProductSortCriteria param);
|
||||||
@@ -64,26 +70,38 @@ public interface TbProductService {
|
|||||||
void updateStockNumber(Integer id, Double stockNumber);
|
void updateStockNumber(Integer id, Double stockNumber);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多选删除
|
* 多选删除
|
||||||
* @param ids /
|
*
|
||||||
*/
|
* @param ids /
|
||||||
|
*/
|
||||||
void deleteAll(Integer[] ids);
|
void deleteAll(Integer[] ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出数据
|
* 导出数据
|
||||||
* @param all 待导出的数据
|
*
|
||||||
* @param response /
|
* @param all 待导出的数据
|
||||||
* @throws IOException /
|
* @param response /
|
||||||
*/
|
* @throws IOException /
|
||||||
|
*/
|
||||||
void download(List<TbProductDto> all, HttpServletResponse response) throws IOException;
|
void download(List<TbProductDto> all, HttpServletResponse response) throws IOException;
|
||||||
|
|
||||||
void updateIsHot(Integer id, String shopId);
|
void updateIsHot(Integer id, String shopId);
|
||||||
void updateIsStock(Integer proId, String shopId,Integer isStock);
|
|
||||||
|
void updateIsStock(Integer proId, String shopId, Integer isStock);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 增加库存
|
* 增加库存
|
||||||
|
*
|
||||||
* @param productId 商品id
|
* @param productId 商品id
|
||||||
* @param number 增加数量
|
* @param number 增加数量
|
||||||
*/
|
*/
|
||||||
void incrStockNumber(String productId, Integer number);
|
void incrStockNumber(String productId, Integer number);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返还库存
|
||||||
|
* @param productId 商品
|
||||||
|
* @param productSkuId sku
|
||||||
|
* @param num 数量
|
||||||
|
*/
|
||||||
|
void returnStockByPro(Integer productId, Integer productSkuId, Integer num);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user