580 lines
20 KiB
Java
580 lines
20 KiB
Java
package com.peanut.modules.book.controller;
|
||
|
||
import com.alibaba.fastjson.JSONObject;
|
||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||
import com.peanut.common.utils.PageUtils;
|
||
import com.peanut.common.utils.R;
|
||
import com.peanut.config.Constants;
|
||
import com.peanut.config.DelayQueueConfig;
|
||
import com.peanut.modules.book.entity.*;
|
||
import com.peanut.modules.book.service.*;
|
||
import com.peanut.modules.pay.weChatPay.dto.WechatPaymentInfo;
|
||
import com.peanut.modules.pay.weChatPay.service.WxpayService;
|
||
import lombok.extern.slf4j.Slf4j;
|
||
import org.springframework.amqp.core.MessagePostProcessor;
|
||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.transaction.annotation.Transactional;
|
||
import org.springframework.web.bind.annotation.*;
|
||
|
||
import java.io.IOException;
|
||
import java.math.BigDecimal;
|
||
import java.util.*;
|
||
import java.util.stream.Collectors;
|
||
|
||
|
||
/**
|
||
* 订单表
|
||
*
|
||
* @author yl
|
||
* @email yl328572838@163.com
|
||
* @date 2022-08-29 15:27:44
|
||
*/
|
||
@Slf4j
|
||
@RestController
|
||
@RequestMapping("book/buyorder")
|
||
public class BuyOrderController {
|
||
@Autowired
|
||
private BuyOrderService buyOrderService;
|
||
@Autowired
|
||
private ShopProductService shopProductService;
|
||
@Autowired
|
||
private BuyOrderDetailService buyOrderDetailService;
|
||
@Autowired
|
||
private CouponService couponService;
|
||
@Autowired
|
||
private CouponHistoryService couponHistoryService;
|
||
@Autowired
|
||
private OrderCartService orderCartService;
|
||
@Autowired
|
||
private MyUserService myUserService;
|
||
@Autowired
|
||
private TransactionDetailsService transactionDetailsService;
|
||
@Autowired
|
||
private UserEbookBuyService userEbookBuyService;
|
||
@Autowired
|
||
private UserRecordService userRecordService;
|
||
@Autowired
|
||
private WxpayService wxpayService;
|
||
@Autowired
|
||
private RabbitTemplate rabbitTemplate;
|
||
|
||
@Autowired
|
||
private ShopProductBookService shopProductBookService;
|
||
|
||
/**
|
||
* 列表
|
||
*/
|
||
@RequestMapping("/list")
|
||
public R list(@RequestParam Map<String, Object> params) throws Exception {
|
||
|
||
if ("all".equals(params.get("orderStatus"))) {
|
||
params.remove("orderStatus");
|
||
}
|
||
PageUtils page = buyOrderService.queryPage(params);
|
||
return R.ok().put("page", page);
|
||
}
|
||
|
||
|
||
/**
|
||
* @param params
|
||
* @return 听书未购买页面展示
|
||
* (销量最多的书,最先放最前面展示。最新上线的书,预售的书,放最前面展示
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping("/lists")
|
||
public R lists(@RequestParam Map<String, Object> params) throws Exception {
|
||
|
||
if ("all".equals(params.get("orderStatus"))) {
|
||
params.remove("orderStatus");
|
||
}
|
||
PageUtils page = buyOrderService.queryPages(params);
|
||
return R.ok().put("page", page);
|
||
}
|
||
|
||
/**
|
||
* 信息
|
||
*/
|
||
@RequestMapping("/info/{orderId}")
|
||
public R info(@PathVariable("orderId") Integer orderId) {
|
||
BuyOrderEntity buyOrder = buyOrderService.getById(orderId);
|
||
return R.ok().put("buyOrder", buyOrder);
|
||
}
|
||
|
||
|
||
/**
|
||
* 下单
|
||
*
|
||
* @param buyOrder 订单
|
||
* @return R
|
||
*/
|
||
@RequestMapping("/buySave")
|
||
@Transactional
|
||
public R buySave(@RequestBody BuyOrderEntity buyOrder) throws IOException {
|
||
// 获取订单详情
|
||
List<BuyOrderDetailEntity> products = buyOrder.getProducts();
|
||
// 订单总金额
|
||
BigDecimal totalPrice = new BigDecimal(0);
|
||
// 遍历商品总价计算
|
||
for (BuyOrderDetailEntity buyOrderDetail : products) {
|
||
Integer productId = buyOrderDetail.getProductId();
|
||
int quantity = buyOrderDetail.getQuantity();
|
||
ShopProductEntity product = shopProductService.getById(productId);
|
||
BigDecimal price = getRealPrice(product);
|
||
if (!handleStock(buyOrderDetail, product)) {
|
||
return R.error(500, "库存不足");
|
||
}
|
||
totalPrice = totalPrice.add(price.multiply(BigDecimal.valueOf(quantity)));
|
||
buyOrderDetail.setProductName(product.getProductName());
|
||
buyOrderDetail.setProductPrice(product.getPrice());
|
||
buyOrderDetail.setAddressId(buyOrder.getAddressId());
|
||
buyOrderDetail.setProductUrl(product.getProductImages());
|
||
buyOrderDetail.setOrderStatus(Constants.ORDER_STATUS_TO_BE_PAID);
|
||
}
|
||
|
||
totalPrice = totalPrice.subtract(useCouponAmount(buyOrder));
|
||
totalPrice = totalPrice.add(getShoppingAmount(buyOrder));
|
||
String orderSn = IdWorker.getTimeId().substring(0, 32);
|
||
buyOrder.setOrderSn(orderSn);
|
||
buyOrder.setPaymentDate(new Date());
|
||
buyOrderService.save(buyOrder);
|
||
|
||
for (BuyOrderDetailEntity buyOrderDetail : products) {
|
||
buyOrderDetail.setOrderId(buyOrder.getOrderId());
|
||
buyOrderDetail.setUserId(buyOrder.getUserId());
|
||
if (Constants.BUY_TYPE_CART.equals(buyOrder.getBuyType())) {
|
||
handleBuyCart(buyOrder, buyOrderDetail);
|
||
}
|
||
}
|
||
buyOrderDetailService.saveBatch(products);
|
||
// 1. 虚拟币支付
|
||
if (Constants.PAYMENT_METHOD_VIRTUAL.equals(buyOrder.getPaymentMethod())) {
|
||
buyOrder.setOrderStatus(Constants.ORDER_STATUS_TO_BE_SHIPPED);
|
||
MyUserEntity user = this.myUserService.getById(buyOrder.getUserId());
|
||
if (usePeanutCoin(user, totalPrice)) {
|
||
// 更新订单状态
|
||
buyOrderService.updateOrderStatus(user.getId(), buyOrder.getOrderSn(), "0");
|
||
recordTransaction(buyOrder, user, totalPrice);
|
||
addEbookToUser(products, buyOrder);
|
||
} else {
|
||
return R.error(500, "花生币余额不足!");
|
||
}
|
||
}
|
||
// 2. 微信支付
|
||
if (Constants.PAYMENT_METHOD_WECHAT_PAY.equals(buyOrder.getPaymentMethod())) {
|
||
rabbitTemplate.convertAndSend(
|
||
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
|
||
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,
|
||
buyOrder.getOrderId(),
|
||
messagePostProcessor()
|
||
);
|
||
WechatPaymentInfo paymentInfo = new WechatPaymentInfo();
|
||
paymentInfo.setOrderSn(orderSn);
|
||
paymentInfo.setBuyOrderId(buyOrder.getOrderId());
|
||
paymentInfo.setTotalAmount(totalPrice);
|
||
wxpayService.prepay(paymentInfo);
|
||
}
|
||
Map<String, Object> result = new HashMap<>();
|
||
result.put("orderSn", buyOrder.getOrderSn());
|
||
result.put("money", totalPrice);
|
||
return R.ok(result);
|
||
}
|
||
|
||
|
||
/**
|
||
* 修改
|
||
*/
|
||
@RequestMapping("/update")
|
||
public R update(@RequestBody BuyOrderEntity buyOrder) {
|
||
buyOrderService.updateById(buyOrder);
|
||
return R.ok();
|
||
}
|
||
|
||
/**
|
||
* 删除
|
||
*/
|
||
@RequestMapping("/delete")
|
||
public R delete(@RequestBody Integer[] orderIds) {
|
||
buyOrderService.removeByIds(Arrays.asList(orderIds));
|
||
return R.ok();
|
||
}
|
||
|
||
/**
|
||
* 列表
|
||
*/
|
||
@RequestMapping("/appUserGetlist")
|
||
public R appUserGetlist(@RequestParam Map<String, Object> params) {
|
||
PageUtils page = buyOrderService.queryPage1(params);
|
||
return R.ok().put("page", page);
|
||
}
|
||
|
||
|
||
/**
|
||
* app 端 取消订单
|
||
*/
|
||
@RequestMapping("/appDelete")
|
||
@Transactional
|
||
public R appDelete(@RequestParam("orderId") Integer orderId) {
|
||
|
||
//1. 判断订单状态
|
||
BuyOrderEntity byId = buyOrderService.getById(orderId);
|
||
if (byId != null) {
|
||
//2. 判断当前订单是否存在优惠券 进行 回显
|
||
Integer couponId = byId.getCouponId();
|
||
if (couponId != null) {
|
||
|
||
CouponHistoryEntity byId1 = couponHistoryService.getById(couponId);
|
||
byId1.setUseStatus(0);
|
||
couponHistoryService.updateById(byId1);
|
||
}
|
||
// 库存回滚
|
||
List<BuyOrderDetailEntity> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
|
||
.eq("order_id", byId.getOrderId()));
|
||
for (BuyOrderDetailEntity buyOrderDetailEntity : buyOrderDetailEntities) {
|
||
Integer productId = buyOrderDetailEntity.getProductId();
|
||
ShopProductEntity product = shopProductService.getById(productId);
|
||
product.setProductStock(product.getProductStock() + buyOrderDetailEntity.getQuantity());
|
||
shopProductService.updateById(product);
|
||
}
|
||
buyOrderService.removeById(orderId);
|
||
}
|
||
return R.ok();
|
||
}
|
||
|
||
@RequestMapping("/randomOrderCode")
|
||
@Transactional
|
||
public R randomOrderCode(@RequestBody BuyOrderEntity buyOrder) {
|
||
return R.ok();
|
||
}
|
||
|
||
/**
|
||
* 充值专用订单生成接口
|
||
*/
|
||
@RequestMapping("/rechargeSave")
|
||
@Transactional
|
||
public R rechargeSave(@RequestBody BuyOrderEntity buyOrder) {
|
||
String timeId = IdWorker.getTimeId().substring(0, 32);
|
||
buyOrder.setOrderSn(timeId);
|
||
buyOrderService.save(buyOrder);
|
||
return R.ok().put("orderSn", timeId);
|
||
}
|
||
|
||
/**
|
||
* 获取订单详情
|
||
* @param orderId
|
||
* @return
|
||
*/
|
||
@RequestMapping("/getOrderDetail")
|
||
public R getOrderDetail(@RequestParam Integer orderId){
|
||
LambdaQueryWrapper<BuyOrderEntity> wrapper = new LambdaQueryWrapper<>();
|
||
wrapper.eq(BuyOrderEntity::getOrderId,orderId);
|
||
BuyOrderEntity one = buyOrderService.getOne(wrapper);
|
||
if(one.equals(null)){
|
||
return R.error("order error:order is null");
|
||
}
|
||
//添加用户信息
|
||
one.setUser(myUserService.getById(one.getUserId()));
|
||
//添加商品信息
|
||
LambdaQueryWrapper<BuyOrderDetailEntity> wrapper1 = new LambdaQueryWrapper<>();
|
||
wrapper1.eq(BuyOrderDetailEntity::getOrderId,orderId);
|
||
List<BuyOrderDetailEntity> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(wrapper1);
|
||
one.setProducts(buyOrderDetailEntities);
|
||
|
||
return R.ok().put("detail",one);
|
||
}
|
||
|
||
|
||
/**
|
||
* 信息
|
||
*/
|
||
@RequestMapping("/appGetOrderInfo/{type}")
|
||
public R appGetOrderInfo(@PathVariable String type, @RequestParam("orderId") Integer orderId) {
|
||
BuyOrderEntity buyOrder = buyOrderService.getById(orderId);
|
||
buyOrder.setTimestamp(buyOrder.getCreateTime().getTime()/1000);
|
||
List<BuyOrderDetailEntity> orderDetail = null;
|
||
if ("1".equals(type)) {
|
||
orderDetail = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
|
||
.eq("order_id", orderId));
|
||
} else {
|
||
orderDetail = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>()
|
||
.eq("order_id", orderId));
|
||
}
|
||
for (BuyOrderDetailEntity buyOrderDetailEntity : orderDetail) {
|
||
|
||
ShopProductEntity prod = shopProductService.getById(buyOrderDetailEntity.getProductId());
|
||
if (prod != null) {
|
||
buyOrderDetailEntity.setImage(prod.getProductImages());
|
||
}
|
||
}
|
||
|
||
List<BuyOrderDetailEntity> resultOrder = new ArrayList<BuyOrderDetailEntity>();
|
||
Set<String> sn_no = new HashSet<String>();
|
||
for (BuyOrderDetailEntity buyOrderDetailEntity : orderDetail) {
|
||
resultOrder.add(buyOrderDetailEntity);
|
||
sn_no.add(buyOrderDetailEntity.getShippingSn());
|
||
}
|
||
|
||
UserRecordEntity userRecordEntity = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecordEntity>()
|
||
.eq("orderSn", buyOrder.getOrderSn())
|
||
.eq("userid", buyOrder.getUserId())
|
||
.eq("orderdid", buyOrder.getOrderId())
|
||
.last("LIMIT 1"));
|
||
Integer id = null;
|
||
if (userRecordEntity != null) {
|
||
id = userRecordEntity.getId();
|
||
}
|
||
buyOrder.setProducts(resultOrder);
|
||
Date createDate = buyOrder.getCreateTime();
|
||
return R.ok().put("buyOrder", buyOrder).put("CreateTime", createDate).put("userRecordid", id);
|
||
}
|
||
|
||
/**
|
||
* 计算快递费用
|
||
*/
|
||
@RequestMapping("/getTransPrice/{area}")
|
||
public R getTransPrice(@PathVariable String area, @RequestParam Map<String, Object> productMap) {
|
||
Map<String, Object> params = new HashMap<>();
|
||
params.put("kdCode", "YD");
|
||
params.put("area", area);
|
||
int price = this.buyOrderService.getProductGoodsType(params, productMap);
|
||
return R.ok().put("price", price);
|
||
}
|
||
|
||
|
||
/**
|
||
* 后台发货按钮
|
||
*
|
||
* @Param shipperCode 快递公司编码
|
||
* @Param sendType 0:订单列表发货 1:商品列表发货
|
||
* @Param type 合并发货/拆分发货
|
||
* @Param ids 订单id串
|
||
*/
|
||
@RequestMapping("/delivery/{shipperCode}")
|
||
public R delivery(@PathVariable("shipperCode") String shipperCode, @RequestParam("shipperName") String shipperName, @RequestBody Integer[] ids) {
|
||
|
||
buyOrderService.sendFMS(ids, shipperCode, shipperName);
|
||
|
||
return R.ok();
|
||
}
|
||
|
||
|
||
/**
|
||
* 及时查询快递信息
|
||
*/
|
||
@RequestMapping("/queryFMS")
|
||
public R queryFMS(@RequestParam Map<String, String> params) {
|
||
List<BuyOrderDetailEntity> detailList = this.buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetailEntity>().eq("order_id", params.get("orderId")));
|
||
List<JSONObject> jsonList = new ArrayList<>();
|
||
JSONObject jsonObj = null;
|
||
for (BuyOrderDetailEntity detail : detailList) {
|
||
jsonObj = buyOrderService.queryFMS(detail.getShipperCode(), detail.getShippingSn());
|
||
if (Objects.isNull(jsonObj)) {
|
||
return R.ok("暂未查到物流信息!");
|
||
}
|
||
jsonObj.put("ShipperName", detail.getShipperName());
|
||
jsonList.add(jsonObj);
|
||
|
||
}
|
||
return R.ok().put("rntStr", jsonList);
|
||
}
|
||
|
||
/**
|
||
* 检查可合并的订单信息
|
||
*
|
||
* @return
|
||
*/
|
||
@RequestMapping("/checkOrder")
|
||
public R checkOrder(@RequestParam Map<String, Object> params) {
|
||
Page page = buyOrderService.checkOrder(params);
|
||
return R.ok().put("page", page);
|
||
}
|
||
|
||
/**
|
||
* 检查传来的orderId 是否有可合并的其他订单信息
|
||
*
|
||
* @param orderIds
|
||
* @return
|
||
*/
|
||
@RequestMapping("/checkMerge")
|
||
public R checkMerge(@RequestBody Integer[] orderIds) {
|
||
List list = buyOrderService.checkOrder(orderIds);
|
||
return R.ok().put("list", list);
|
||
}
|
||
|
||
/**
|
||
* 批量发货功能
|
||
*
|
||
* @param orderDetailIds 订单详情
|
||
* @return
|
||
*/
|
||
@RequestMapping("/blendSendFMS/{shipperCode}")
|
||
public R blendSendFMS(@PathVariable("shipperCode") String shipperCode, @RequestParam("shipperName") String shipperName, @RequestBody Integer[] orderDetailIds) {
|
||
|
||
|
||
buyOrderService.blendSendFMS(orderDetailIds, shipperCode, shipperName);
|
||
return R.ok();
|
||
|
||
}
|
||
|
||
/**
|
||
* 后台取消订单接口
|
||
*/
|
||
@RequestMapping("/cancelFMS")
|
||
public R cancelFMS(@RequestParam Map<String, Object> params) {
|
||
buyOrderService.cancelFMS(params.get("orderSn").toString(), params.get("shipperCode").toString(),
|
||
params.get("expNo").toString());
|
||
return R.ok().put("paramsTEXT", params);
|
||
}
|
||
|
||
/**
|
||
* 去重查询可打印面单
|
||
*
|
||
* @param params
|
||
* @return
|
||
*/
|
||
@RequestMapping("/querySheetPage")
|
||
public R querySheetPage(@RequestParam Map<String, Object> params) {
|
||
|
||
PageUtils page = buyOrderDetailService.querySheet(params);
|
||
|
||
return R.ok().put("page", page);
|
||
}
|
||
|
||
/**
|
||
* 获取商品实际价格
|
||
*
|
||
* @param product 商品信息
|
||
* @return 商品实际价格
|
||
*/
|
||
private BigDecimal getRealPrice(ShopProductEntity product) {
|
||
BigDecimal activityPrice = product.getActivityPrice();
|
||
return (activityPrice == null || activityPrice.equals(BigDecimal.ZERO)) ? product.getPrice() : activityPrice;
|
||
}
|
||
|
||
/**
|
||
* 处理商品库存
|
||
*
|
||
* @param buyOrderDetail
|
||
* @param product
|
||
* @return
|
||
*/
|
||
private boolean handleStock(BuyOrderDetailEntity buyOrderDetail, ShopProductEntity product) {
|
||
int quantity = buyOrderDetail.getQuantity();
|
||
if (product.getProductStock() - quantity < 0) {
|
||
return false;
|
||
}
|
||
product.setProductStock(product.getProductStock() - quantity);
|
||
product.setSumSales(product.getSumSales() + quantity);
|
||
shopProductService.updateById(product);
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* 使用优惠券
|
||
*
|
||
* @param buyOrder
|
||
* @return
|
||
*/
|
||
private BigDecimal useCouponAmount(BuyOrderEntity buyOrder) {
|
||
Integer couponId = buyOrder.getCouponId();
|
||
if (couponId != null) {
|
||
CouponHistoryEntity couponHistory = couponHistoryService.getById(couponId);
|
||
couponHistory.setUseStatus(1);
|
||
couponHistory.setUseTime(new Date());
|
||
couponHistory.setOrderId(Long.valueOf(buyOrder.getOrderId()));
|
||
couponHistory.setOrderSn(buyOrder.getOrderSn());
|
||
CouponEntity coupon = couponService.getById(couponHistory.getCouponId());
|
||
|
||
return coupon.getCouponAmount();
|
||
}
|
||
return BigDecimal.ZERO;
|
||
}
|
||
|
||
/**
|
||
* 计算运费
|
||
*
|
||
* @param buyOrder
|
||
* @return
|
||
*/
|
||
private BigDecimal getShoppingAmount(BuyOrderEntity buyOrder) {
|
||
return buyOrder.getOrderMoney() == null ? BigDecimal.ZERO : buyOrder.getShippingMoney();
|
||
}
|
||
|
||
/**
|
||
* 使用虚拟币支付
|
||
*
|
||
* @param user
|
||
* @param totalPrice
|
||
* @return
|
||
*/
|
||
private boolean usePeanutCoin(MyUserEntity user, BigDecimal totalPrice) {
|
||
if (user.getPeanutCoin().compareTo(totalPrice) >= 0) {
|
||
user.setPeanutCoin(user.getPeanutCoin().subtract(totalPrice));
|
||
this.myUserService.updateById(user);
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
/**
|
||
* 交易记录
|
||
*
|
||
* @param buyOrder
|
||
* @param user
|
||
* @param totalPrice
|
||
*/
|
||
private void recordTransaction(BuyOrderEntity buyOrder, MyUserEntity user, BigDecimal totalPrice) {
|
||
TransactionDetailsEntity transactionDetailsEntity = new TransactionDetailsEntity();
|
||
transactionDetailsEntity.setRemark("订单编号为 - " + buyOrder.getOrderSn());
|
||
transactionDetailsEntity.setUserId(user.getId());
|
||
transactionDetailsEntity.setUserName(user.getNickname());
|
||
transactionDetailsEntity.setChangeAmount(totalPrice.negate());
|
||
transactionDetailsEntity.setUserBalance(user.getPeanutCoin());
|
||
transactionDetailsEntity.setTel(user.getTel());
|
||
transactionDetailsEntity.setOrderType("购买商品");
|
||
transactionDetailsService.save(transactionDetailsEntity);
|
||
}
|
||
|
||
/**
|
||
* 给用户添加电子书
|
||
*
|
||
* @param products
|
||
* @param buyOrder
|
||
*/
|
||
private void addEbookToUser(List<BuyOrderDetailEntity> products, BuyOrderEntity buyOrder) {
|
||
List<Integer> productIds = products.stream().map(BuyOrderDetailEntity::getProductId).collect(Collectors.toList());
|
||
for (Integer productId : productIds) {
|
||
List<Integer> collect = shopProductBookService.getBaseMapper().selectList(new LambdaQueryWrapper<ShopProductBookEntity>()
|
||
.eq(ShopProductBookEntity::getProductId, productId)
|
||
.eq(ShopProductBookEntity::getDelFlag, 0)).stream().map(ShopProductBookEntity::getBookId).collect(Collectors.toList());
|
||
userEbookBuyService.addBookForUser(buyOrder.getUserId(), collect);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 购物车
|
||
*
|
||
* @param buyOrder
|
||
* @param buyOrderDetail
|
||
*/
|
||
private void handleBuyCart(BuyOrderEntity buyOrder, BuyOrderDetailEntity buyOrderDetail) {
|
||
List<OrderCartEntity> orderCartList = orderCartService.getBaseMapper().selectList(new QueryWrapper<OrderCartEntity>()
|
||
.eq("user_id", buyOrder.getUserId()).eq("product_id", buyOrderDetail.getProductId()));
|
||
if (orderCartList.size() > 0) {
|
||
List<Integer> collect = orderCartList.stream().map(OrderCartEntity::getCartId).collect(Collectors.toList());
|
||
orderCartService.removeByIds(collect);
|
||
}
|
||
}
|
||
|
||
private MessagePostProcessor messagePostProcessor() {
|
||
return message -> {
|
||
//设置有效期30分钟
|
||
message.getMessageProperties().setExpiration(String.valueOf(30*60*1000));
|
||
return message;
|
||
};
|
||
}
|
||
}
|