bug fix
This commit is contained in:
@@ -5,27 +5,24 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.peanut.common.utils.PageUtils;
|
import com.peanut.common.utils.PageUtils;
|
||||||
import com.peanut.common.utils.Query;
|
|
||||||
import com.peanut.common.utils.R;
|
import com.peanut.common.utils.R;
|
||||||
import com.peanut.config.Constants;
|
import com.peanut.config.Constants;
|
||||||
import com.peanut.config.DelayQueueConfig;
|
import com.peanut.config.DelayQueueConfig;
|
||||||
import com.peanut.modules.book.entity.*;
|
import com.peanut.modules.book.entity.*;
|
||||||
import com.peanut.modules.book.service.*;
|
import com.peanut.modules.book.service.*;
|
||||||
|
import com.peanut.modules.book.vo.UserAddressVo;
|
||||||
import com.peanut.modules.book.vo.request.BuyOrderListRequestVo;
|
import com.peanut.modules.book.vo.request.BuyOrderListRequestVo;
|
||||||
import com.peanut.modules.book.vo.request.ModifyOrderAddressRequestVo;
|
import com.peanut.modules.book.vo.request.ModifyOrderAddressRequestVo;
|
||||||
import com.peanut.modules.book.vo.request.ProductRequestVo;
|
import com.peanut.modules.book.vo.request.ProductRequestVo;
|
||||||
import com.peanut.modules.book.vo.request.ProductTransportVo;
|
import com.peanut.modules.book.vo.request.ProductTransportVo;
|
||||||
import com.peanut.modules.book.vo.response.BuyOrderResponseVo;
|
import com.peanut.modules.book.vo.response.BuyOrderResponseVo;
|
||||||
import com.peanut.modules.book.vo.response.ExpressQueryResponseVo;
|
import com.peanut.modules.book.vo.response.ExpressQueryResponseVo;
|
||||||
import com.peanut.modules.book.vo.ShippingAddressRequestVo;
|
|
||||||
import com.peanut.modules.book.vo.UserAddressVo;
|
|
||||||
import com.peanut.modules.book.vo.response.OrderAddressResponseVo;
|
import com.peanut.modules.book.vo.response.OrderAddressResponseVo;
|
||||||
import com.peanut.modules.pay.weChatPay.dto.WechatPaymentInfo;
|
import com.peanut.modules.pay.weChatPay.dto.WechatPaymentInfo;
|
||||||
import com.peanut.modules.pay.weChatPay.service.WxpayService;
|
import com.peanut.modules.pay.weChatPay.service.WxpayService;
|
||||||
import com.peanut.modules.sys.entity.SysConfigEntity;
|
import com.peanut.modules.sys.entity.SysConfigEntity;
|
||||||
import com.peanut.modules.sys.service.SysConfigService;
|
import com.peanut.modules.sys.service.SysConfigService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.poi.ss.formula.functions.Count;
|
|
||||||
import org.springframework.amqp.core.MessagePostProcessor;
|
import org.springframework.amqp.core.MessagePostProcessor;
|
||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -182,7 +179,7 @@ public class BuyOrderController {
|
|||||||
buyOrderService.save(buyOrder);
|
buyOrderService.save(buyOrder);
|
||||||
|
|
||||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetails) {
|
for (BuyOrderDetail buyOrderDetail : buyOrderDetails) {
|
||||||
buyOrderDetail.setOrderId(buyOrder.getOrderId());
|
buyOrderDetail.setOrderId(buyOrder.getId());
|
||||||
buyOrderDetail.setUserId(buyOrder.getUserId());
|
buyOrderDetail.setUserId(buyOrder.getUserId());
|
||||||
if (Constants.BUY_TYPE_CART.equals(buyOrder.getBuyType())) {
|
if (Constants.BUY_TYPE_CART.equals(buyOrder.getBuyType())) {
|
||||||
handleBuyCart(buyOrder, buyOrderDetail);
|
handleBuyCart(buyOrder, buyOrderDetail);
|
||||||
@@ -207,12 +204,12 @@ public class BuyOrderController {
|
|||||||
rabbitTemplate.convertAndSend(
|
rabbitTemplate.convertAndSend(
|
||||||
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
|
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
|
||||||
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,
|
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,
|
||||||
buyOrder.getOrderId(),
|
buyOrder.getId(),
|
||||||
messagePostProcessor()
|
messagePostProcessor()
|
||||||
);
|
);
|
||||||
WechatPaymentInfo paymentInfo = new WechatPaymentInfo();
|
WechatPaymentInfo paymentInfo = new WechatPaymentInfo();
|
||||||
paymentInfo.setOrderSn(orderSn);
|
paymentInfo.setOrderSn(orderSn);
|
||||||
paymentInfo.setBuyOrderId(buyOrder.getOrderId());
|
paymentInfo.setBuyOrderId(buyOrder.getId());
|
||||||
paymentInfo.setTotalAmount(totalPrice);
|
paymentInfo.setTotalAmount(totalPrice);
|
||||||
wxpayService.prepay(paymentInfo);
|
wxpayService.prepay(paymentInfo);
|
||||||
}
|
}
|
||||||
@@ -229,9 +226,9 @@ public class BuyOrderController {
|
|||||||
* @return
|
* @return
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "placeOrder", method = RequestMethod.POST)
|
@RequestMapping(value = "/placeOrder", method = RequestMethod.POST)
|
||||||
public R placeOrder(@RequestBody BuyOrder buyOrder) throws IOException {
|
public R placeOrder(@RequestBody BuyOrder buyOrder) throws IOException {
|
||||||
List<BuyOrderProduct> buyOrderProductList = buyOrder.getProductInfoList();
|
List<BuyOrderProduct> buyOrderProductList = buyOrder.getProductList();
|
||||||
// 订单总金额
|
// 订单总金额
|
||||||
BigDecimal totalPrice = new BigDecimal(0);
|
BigDecimal totalPrice = new BigDecimal(0);
|
||||||
// 遍历商品总价计算
|
// 遍历商品总价计算
|
||||||
@@ -244,8 +241,6 @@ public class BuyOrderController {
|
|||||||
return R.error(500, "库存不足");
|
return R.error(500, "库存不足");
|
||||||
}
|
}
|
||||||
totalPrice = totalPrice.add(price.multiply(BigDecimal.valueOf(quantity)));
|
totalPrice = totalPrice.add(price.multiply(BigDecimal.valueOf(quantity)));
|
||||||
//buyOrderDetail.setProductName(product.getProductName());
|
|
||||||
//buyOrderDetail.setProductPrice(product.getPrice());
|
|
||||||
int originWeight = product.getWeight();
|
int originWeight = product.getWeight();
|
||||||
int originWeightIntValue = originWeight / 100;
|
int originWeightIntValue = originWeight / 100;
|
||||||
int originWeightDecimalValue = originWeightIntValue % 100;
|
int originWeightDecimalValue = originWeightIntValue % 100;
|
||||||
@@ -272,7 +267,7 @@ public class BuyOrderController {
|
|||||||
buyOrderService.save(buyOrder);
|
buyOrderService.save(buyOrder);
|
||||||
|
|
||||||
for (BuyOrderProduct buyOrderDetail : buyOrderProductList) {
|
for (BuyOrderProduct buyOrderDetail : buyOrderProductList) {
|
||||||
buyOrderDetail.setOrderId(buyOrder.getOrderId());
|
buyOrderDetail.setOrderId(buyOrder.getId());
|
||||||
//buyOrderDetail.setUserId(buyOrder.getUserId());
|
//buyOrderDetail.setUserId(buyOrder.getUserId());
|
||||||
if (Constants.BUY_TYPE_CART.equals(buyOrder.getBuyType())) {
|
if (Constants.BUY_TYPE_CART.equals(buyOrder.getBuyType())) {
|
||||||
handleBuyCart(buyOrder, buyOrderDetail);
|
handleBuyCart(buyOrder, buyOrderDetail);
|
||||||
@@ -298,12 +293,12 @@ public class BuyOrderController {
|
|||||||
rabbitTemplate.convertAndSend(
|
rabbitTemplate.convertAndSend(
|
||||||
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
|
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
|
||||||
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,
|
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,
|
||||||
buyOrder.getOrderId(),
|
buyOrder.getId(),
|
||||||
messagePostProcessor()
|
messagePostProcessor()
|
||||||
);
|
);
|
||||||
WechatPaymentInfo paymentInfo = new WechatPaymentInfo();
|
WechatPaymentInfo paymentInfo = new WechatPaymentInfo();
|
||||||
paymentInfo.setOrderSn(orderSn);
|
paymentInfo.setOrderSn(orderSn);
|
||||||
paymentInfo.setBuyOrderId(buyOrder.getOrderId());
|
paymentInfo.setBuyOrderId(buyOrder.getId());
|
||||||
paymentInfo.setTotalAmount(totalPrice);
|
paymentInfo.setTotalAmount(totalPrice);
|
||||||
wxpayService.prepay(paymentInfo);
|
wxpayService.prepay(paymentInfo);
|
||||||
}
|
}
|
||||||
@@ -347,6 +342,40 @@ public class BuyOrderController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param orderSn 订单号
|
||||||
|
* @return R
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/cancelOrder", method = RequestMethod.GET)
|
||||||
|
@Transactional
|
||||||
|
public R appDelete(@RequestParam("orderSn") String orderSn) {
|
||||||
|
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("order_sn", orderSn);
|
||||||
|
BuyOrder buyOrder = buyOrderService.getOne(queryWrapper);
|
||||||
|
|
||||||
|
if (buyOrder == null) {
|
||||||
|
return R.error("订单不存在");
|
||||||
|
}
|
||||||
|
if (buyOrder.getCouponId() != null) {
|
||||||
|
Integer couponId = buyOrder.getCouponId();
|
||||||
|
CouponHistoryEntity couponHistory = couponHistoryService.getById(couponId);
|
||||||
|
couponHistory.setUseStatus(0);
|
||||||
|
couponHistoryService.updateById(couponHistory);
|
||||||
|
}
|
||||||
|
// 库存回滚
|
||||||
|
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
|
||||||
|
buyOrderProductQueryWrapper.eq("order_id",buyOrder.getId());
|
||||||
|
List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.list(buyOrderProductQueryWrapper);
|
||||||
|
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||||
|
Integer productId = buyOrderProduct.getProductId();
|
||||||
|
ShopProduct product = shopProductService.getById(productId);
|
||||||
|
product.setProductStock(product.getProductStock() + buyOrderProduct.getQuantity());
|
||||||
|
shopProductService.updateById(product);
|
||||||
|
}
|
||||||
|
buyOrderService.removeById(buyOrder.getId());
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改
|
* 修改
|
||||||
*/
|
*/
|
||||||
@@ -389,7 +418,7 @@ public class BuyOrderController {
|
|||||||
}
|
}
|
||||||
// 库存回滚
|
// 库存回滚
|
||||||
List<BuyOrderDetail> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetail>()
|
List<BuyOrderDetail> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetail>()
|
||||||
.eq("order_id", byId.getOrderId()));
|
.eq("order_id", byId.getId()));
|
||||||
for (BuyOrderDetail buyOrderDetailEntity : buyOrderDetailEntities) {
|
for (BuyOrderDetail buyOrderDetailEntity : buyOrderDetailEntities) {
|
||||||
Integer productId = buyOrderDetailEntity.getProductId();
|
Integer productId = buyOrderDetailEntity.getProductId();
|
||||||
ShopProduct product = shopProductService.getById(productId);
|
ShopProduct product = shopProductService.getById(productId);
|
||||||
@@ -401,39 +430,6 @@ public class BuyOrderController {
|
|||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param orderSn 订单号
|
|
||||||
* @return R
|
|
||||||
*/
|
|
||||||
@RequestMapping("/cancelOrder")
|
|
||||||
@Transactional
|
|
||||||
public R appDelete(@RequestParam("orderSn") String orderSn) {
|
|
||||||
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.eq("order_sn", orderSn);
|
|
||||||
BuyOrder buyOrder = buyOrderService.getOne(queryWrapper);
|
|
||||||
|
|
||||||
if (buyOrder == null) {
|
|
||||||
return R.error("订单不存在");
|
|
||||||
}
|
|
||||||
if (buyOrder.getCouponId() != null) {
|
|
||||||
Integer couponId = buyOrder.getCouponId();
|
|
||||||
CouponHistoryEntity couponHistory = couponHistoryService.getById(couponId);
|
|
||||||
couponHistory.setUseStatus(0);
|
|
||||||
couponHistoryService.updateById(couponHistory);
|
|
||||||
}
|
|
||||||
// 库存回滚
|
|
||||||
List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.getBaseMapper().selectList(new QueryWrapper<BuyOrderProduct>()
|
|
||||||
.eq("order_id", buyOrder.getOrderId()));
|
|
||||||
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
|
||||||
Integer productId = buyOrderProduct.getProductId();
|
|
||||||
ShopProduct product = shopProductService.getById(productId);
|
|
||||||
product.setProductStock(product.getProductStock() + buyOrderProduct.getQuantity());
|
|
||||||
shopProductService.updateById(product);
|
|
||||||
}
|
|
||||||
buyOrderService.removeById(buyOrder.getOrderId());
|
|
||||||
return R.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 充值专用订单生成接口
|
* 充值专用订单生成接口
|
||||||
@@ -464,7 +460,7 @@ public class BuyOrderController {
|
|||||||
@RequestMapping("/getOrderDetail")
|
@RequestMapping("/getOrderDetail")
|
||||||
public R getOrderDetail(@RequestParam Integer orderId) {
|
public R getOrderDetail(@RequestParam Integer orderId) {
|
||||||
LambdaQueryWrapper<BuyOrder> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<BuyOrder> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(BuyOrder::getOrderId, orderId);
|
wrapper.eq(BuyOrder::getId, orderId);
|
||||||
BuyOrder one = buyOrderService.getOne(wrapper);
|
BuyOrder one = buyOrderService.getOne(wrapper);
|
||||||
if (one.equals(null)) {
|
if (one.equals(null)) {
|
||||||
return R.error("order error:order is null");
|
return R.error("order error:order is null");
|
||||||
@@ -509,10 +505,11 @@ public class BuyOrderController {
|
|||||||
* @param addressRequestVo 地址请求 value object
|
* @param addressRequestVo 地址请求 value object
|
||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/modifyOrderAddress", method = RequestMethod.POST)
|
@RequestMapping(value = "/modifyConsigneeAddress", method = RequestMethod.POST)
|
||||||
public R modifyOrderAddress(@RequestBody ShippingAddressRequestVo addressRequestVo) {
|
public R modifyOrderAddress(@RequestBody ModifyOrderAddressRequestVo addressRequestVo) {
|
||||||
BuyOrder buyOrder = buyOrderService.getById(addressRequestVo.getOrderId());
|
QueryWrapper<BuyOrder> buyOrderQueryWrapper = new QueryWrapper<>();
|
||||||
|
buyOrderQueryWrapper.eq("order_sn", addressRequestVo.getOrderSn());
|
||||||
|
BuyOrder buyOrder = buyOrderService.getOne(buyOrderQueryWrapper);
|
||||||
String provinceCode = addressRequestVo.getProvinceCode();
|
String provinceCode = addressRequestVo.getProvinceCode();
|
||||||
QueryWrapper<Province> provinceQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<Province> provinceQueryWrapper = new QueryWrapper<>();
|
||||||
provinceQueryWrapper.eq("region_code", provinceCode);
|
provinceQueryWrapper.eq("region_code", provinceCode);
|
||||||
@@ -528,8 +525,8 @@ public class BuyOrderController {
|
|||||||
countyQueryWrapper.eq("region_code", countyCode);
|
countyQueryWrapper.eq("region_code", countyCode);
|
||||||
County county = countyService.getOne(countyQueryWrapper);
|
County county = countyService.getOne(countyQueryWrapper);
|
||||||
buyOrder.setDistrict(county.getCountyName());
|
buyOrder.setDistrict(county.getCountyName());
|
||||||
buyOrder.setShippingUser(addressRequestVo.getName());
|
buyOrder.setShippingUser(addressRequestVo.getConsigneeName());
|
||||||
buyOrder.setUserPhone(addressRequestVo.getMobile());
|
buyOrder.setUserPhone(addressRequestVo.getConsigneeMobile());
|
||||||
buyOrder.setAddress(addressRequestVo.getAddress());
|
buyOrder.setAddress(addressRequestVo.getAddress());
|
||||||
buyOrderService.updateById(buyOrder);
|
buyOrderService.updateById(buyOrder);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
@@ -541,7 +538,7 @@ public class BuyOrderController {
|
|||||||
* @param orderSn 订单号
|
* @param orderSn 订单号
|
||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/getOrderAddress", method = RequestMethod.GET)
|
@RequestMapping(value = "/getConsigneeAddress", method = RequestMethod.GET)
|
||||||
public R getOrderAddress(@RequestParam("orderSn") String orderSn) {
|
public R getOrderAddress(@RequestParam("orderSn") String orderSn) {
|
||||||
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("order_sn", orderSn);
|
queryWrapper.eq("order_sn", orderSn);
|
||||||
@@ -584,7 +581,7 @@ public class BuyOrderController {
|
|||||||
QueryWrapper<BuyOrder> buyOrderQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<BuyOrder> buyOrderQueryWrapper = new QueryWrapper<>();
|
||||||
buyOrderQueryWrapper.eq("order_sn", orderSn);
|
buyOrderQueryWrapper.eq("order_sn", orderSn);
|
||||||
BuyOrder buyOrder = buyOrderService.getOne(buyOrderQueryWrapper);
|
BuyOrder buyOrder = buyOrderService.getOne(buyOrderQueryWrapper);
|
||||||
Integer orderId = buyOrder.getOrderId();
|
Integer orderId = buyOrder.getId();
|
||||||
|
|
||||||
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
|
||||||
buyOrderProductQueryWrapper.eq("order_id", orderId);
|
buyOrderProductQueryWrapper.eq("order_id", orderId);
|
||||||
@@ -629,13 +626,13 @@ public class BuyOrderController {
|
|||||||
* 分包发货
|
* 分包发货
|
||||||
*
|
*
|
||||||
* @param expressCompanyCode 快递公司编码
|
* @param expressCompanyCode 快递公司编码
|
||||||
* @param buyOrderDetailId 订单详情列表
|
* @param buyOrderProductId 订单商品
|
||||||
* @return R
|
* @return R
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/delivery", method = RequestMethod.POST)
|
@RequestMapping(value = "/delivery", method = RequestMethod.POST)
|
||||||
public R delivery(@RequestParam("expressCompanyCode") String expressCompanyCode,
|
public R delivery(@RequestParam("expressCompanyCode") String expressCompanyCode,
|
||||||
@RequestBody List<Integer> buyOrderDetailId) throws Exception {
|
@RequestBody List<Integer> buyOrderProductId) throws Exception {
|
||||||
buyOrderService.delivery(expressCompanyCode, buyOrderDetailId);
|
buyOrderService.delivery(expressCompanyCode, buyOrderProductId);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -700,7 +697,7 @@ public class BuyOrderController {
|
|||||||
CouponHistoryEntity couponHistory = couponHistoryService.getById(couponId);
|
CouponHistoryEntity couponHistory = couponHistoryService.getById(couponId);
|
||||||
couponHistory.setUseStatus(1);
|
couponHistory.setUseStatus(1);
|
||||||
couponHistory.setUseTime(new Date());
|
couponHistory.setUseTime(new Date());
|
||||||
couponHistory.setOrderId(Long.valueOf(buyOrder.getOrderId()));
|
couponHistory.setOrderId(Long.valueOf(buyOrder.getId()));
|
||||||
couponHistory.setOrderSn(buyOrder.getOrderSn());
|
couponHistory.setOrderSn(buyOrder.getOrderSn());
|
||||||
CouponEntity coupon = couponService.getById(couponHistory.getCouponId());
|
CouponEntity coupon = couponService.getById(couponHistory.getCouponId());
|
||||||
|
|
||||||
@@ -709,21 +706,6 @@ public class BuyOrderController {
|
|||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/modifyConsigneeAddress")
|
|
||||||
public R modifyConsigneeAddress(@RequestBody ModifyOrderAddressRequestVo requestVo) {
|
|
||||||
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.eq("order_sn", requestVo.getOrderSn());
|
|
||||||
BuyOrder buyOrder = buyOrderService.getOne(queryWrapper);
|
|
||||||
buyOrder.setShippingUser(requestVo.getConsigneeName());
|
|
||||||
buyOrder.setUserPhone(requestVo.getConsigneeMobile());
|
|
||||||
buyOrder.setProvince(requestVo.getProvince());
|
|
||||||
buyOrder.setCity(requestVo.getCity());
|
|
||||||
buyOrder.setDistrict(requestVo.getCounty());
|
|
||||||
buyOrder.setAddress(requestVo.getAddress());
|
|
||||||
buyOrder.setAddressModified(1);
|
|
||||||
buyOrderService.updateById(buyOrder);
|
|
||||||
return R.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算运费
|
* 计算运费
|
||||||
|
|||||||
@@ -1,91 +1,91 @@
|
|||||||
package com.peanut.modules.book.controller;
|
//package com.peanut.modules.book.controller;
|
||||||
|
//
|
||||||
import com.peanut.common.utils.PageUtils;
|
//import com.peanut.common.utils.PageUtils;
|
||||||
import com.peanut.common.utils.R;
|
//import com.peanut.common.utils.R;
|
||||||
import com.peanut.modules.book.entity.ShopSeckillEntity;
|
//import com.peanut.modules.book.entity.ShopSeckillEntity;
|
||||||
import com.peanut.modules.book.service.ShopSeckillService;
|
//import com.peanut.modules.book.service.ShopSeckillService;
|
||||||
import com.peanut.modules.book.to.SeckillRedisTo;
|
//import com.peanut.modules.book.to.SeckillRedisTo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
//import org.springframework.web.bind.annotation.*;
|
||||||
|
//
|
||||||
import java.util.Arrays;
|
//import java.util.Arrays;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 秒杀库存表
|
// * 秒杀库存表
|
||||||
*
|
// *
|
||||||
* @author yl
|
// * @author yl
|
||||||
* @email yl328572838@163.com
|
// * @email yl328572838@163.com
|
||||||
* @date 2022-10-28 11:24:05
|
// * @date 2022-10-28 11:24:05
|
||||||
*/
|
// */
|
||||||
@RestController
|
//@RestController
|
||||||
@RequestMapping("book/shopseckill")
|
//@RequestMapping("book/shopseckill")
|
||||||
public class ShopSeckillController {
|
//public class ShopSeckillController {
|
||||||
@Autowired
|
// @Autowired
|
||||||
private ShopSeckillService shopSeckillService;
|
// private ShopSeckillService shopSeckillService;
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 列表
|
// * 列表
|
||||||
*/
|
// */
|
||||||
@RequestMapping("/list")
|
// @RequestMapping("/list")
|
||||||
public R list(@RequestParam Map<String, Object> params) {
|
// public R list(@RequestParam Map<String, Object> params) {
|
||||||
PageUtils page = shopSeckillService.queryPage(params);
|
// PageUtils page = shopSeckillService.queryPage(params);
|
||||||
return R.ok().put("page", page);
|
// return R.ok().put("page", page);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 信息
|
// * 信息
|
||||||
*/
|
// */
|
||||||
@RequestMapping("/info/{seckillId}")
|
// @RequestMapping("/info/{seckillId}")
|
||||||
public R info(@PathVariable("seckillId") Long seckillId) {
|
// public R info(@PathVariable("seckillId") Long seckillId) {
|
||||||
ShopSeckillEntity shopSeckill = shopSeckillService.getById(seckillId);
|
// ShopSeckillEntity shopSeckill = shopSeckillService.getById(seckillId);
|
||||||
return R.ok().put("shopSeckill", shopSeckill);
|
// return R.ok().put("shopSeckill", shopSeckill);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 保存
|
// * 保存
|
||||||
*/
|
// */
|
||||||
@RequestMapping("/save")
|
// @RequestMapping("/save")
|
||||||
public R save(@RequestBody ShopSeckillEntity shopSeckill) {
|
// public R save(@RequestBody ShopSeckillEntity shopSeckill) {
|
||||||
shopSeckillService.save(shopSeckill);
|
// shopSeckillService.save(shopSeckill);
|
||||||
return R.ok();
|
// return R.ok();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 修改
|
// * 修改
|
||||||
*/
|
// */
|
||||||
@RequestMapping("/update")
|
// @RequestMapping("/update")
|
||||||
public R update(@RequestBody ShopSeckillEntity shopSeckill) {
|
// public R update(@RequestBody ShopSeckillEntity shopSeckill) {
|
||||||
shopSeckillService.updateById(shopSeckill);
|
// shopSeckillService.updateById(shopSeckill);
|
||||||
return R.ok();
|
// return R.ok();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 删除
|
// * 删除
|
||||||
*/
|
// */
|
||||||
@RequestMapping("/delete")
|
// @RequestMapping("/delete")
|
||||||
public R delete(@RequestBody Long[] seckillIds) {
|
// public R delete(@RequestBody Long[] seckillIds) {
|
||||||
shopSeckillService.removeByIds(Arrays.asList(seckillIds));
|
// shopSeckillService.removeByIds(Arrays.asList(seckillIds));
|
||||||
return R.ok();
|
// return R.ok();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@GetMapping("/getSeckillProd")
|
// @GetMapping("/getSeckillProd")
|
||||||
public R getSeckillProd() {
|
// public R getSeckillProd() {
|
||||||
List<SeckillRedisTo> list = shopSeckillService.getCurrentSeckillProd();
|
// List<SeckillRedisTo> list = shopSeckillService.getCurrentSeckillProd();
|
||||||
return R.ok().put("list", list);
|
// return R.ok().put("list", list);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@GetMapping("/kill")
|
// @GetMapping("/kill")
|
||||||
public R kill(@RequestParam("killId") String killId,
|
// public R kill(@RequestParam("killId") String killId,
|
||||||
@RequestParam("key") String key,
|
// @RequestParam("key") String key,
|
||||||
@RequestParam("num") Integer num,
|
// @RequestParam("num") Integer num,
|
||||||
@RequestParam("userId") Integer userId) {
|
// @RequestParam("userId") Integer userId) {
|
||||||
String orderId = shopSeckillService.kill(killId, key, num, userId);
|
// String orderId = shopSeckillService.kill(killId, key, num, userId);
|
||||||
return R.ok().put("orderId", orderId);
|
// return R.ok().put("orderId", orderId);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class UserFollowUpController {
|
|||||||
.eq("order_sn", orderSn).last("LIMIT 1")
|
.eq("order_sn", orderSn).last("LIMIT 1")
|
||||||
);
|
);
|
||||||
|
|
||||||
Integer orderId = buyOrder.getOrderId();
|
Integer orderId = buyOrder.getId();
|
||||||
Integer bookid = userRecord.getBookid();
|
Integer bookid = userRecord.getBookid();
|
||||||
Integer userid = userRecord.getUserid();
|
Integer userid = userRecord.getUserid();
|
||||||
Integer id1 = userRecord.getId();
|
Integer id1 = userRecord.getId();
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ public class UserRecordController {
|
|||||||
return error("您已评价过了,请勿重复评论");
|
return error("您已评价过了,请勿重复评论");
|
||||||
//
|
//
|
||||||
} else {
|
} else {
|
||||||
userRecord.setId(buyOrder.getOrderId());
|
userRecord.setId(buyOrder.getId());
|
||||||
userRecord.setContent(comment);
|
userRecord.setContent(comment);
|
||||||
//商品评价
|
//商品评价
|
||||||
userRecord.setBookid(bookid);
|
userRecord.setBookid(bookid);
|
||||||
@@ -201,7 +201,7 @@ public class UserRecordController {
|
|||||||
QueryWrapper<BuyOrder> buyOrderQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<BuyOrder> buyOrderQueryWrapper = new QueryWrapper<>();
|
||||||
buyOrderQueryWrapper.eq("order_sn", recordEntity.getOrderSn());
|
buyOrderQueryWrapper.eq("order_sn", recordEntity.getOrderSn());
|
||||||
BuyOrder buyOrder = buyOrderService.getOne(buyOrderQueryWrapper);
|
BuyOrder buyOrder = buyOrderService.getOne(buyOrderQueryWrapper);
|
||||||
Integer orderId = buyOrder.getOrderId();
|
Integer orderId = buyOrder.getId();
|
||||||
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
|
||||||
buyOrderProductQueryWrapper.eq("order_id", orderId);
|
buyOrderProductQueryWrapper.eq("order_id", orderId);
|
||||||
buyOrderProductQueryWrapper.eq("product_id", recordEntity.getProductId());
|
buyOrderProductQueryWrapper.eq("product_id", recordEntity.getProductId());
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class BuyOrder implements Serializable {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@TableId
|
@TableId
|
||||||
private Integer orderId;
|
private Integer id;
|
||||||
/**
|
/**
|
||||||
* 订单编号
|
* 订单编号
|
||||||
*/
|
*/
|
||||||
@@ -130,7 +130,7 @@ public class BuyOrder implements Serializable {
|
|||||||
private List<BuyOrderDetail> products;
|
private List<BuyOrderDetail> products;
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private List<BuyOrderProduct> productInfoList;
|
private List<BuyOrderProduct> productList;
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String buyType;
|
private String buyType;
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
package com.peanut.modules.book.service;
|
//package com.peanut.modules.book.service;
|
||||||
|
//
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
//import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.peanut.common.utils.PageUtils;
|
//import com.peanut.common.utils.PageUtils;
|
||||||
import com.peanut.modules.book.entity.ShopSeckillEntity;
|
//import com.peanut.modules.book.entity.ShopSeckillEntity;
|
||||||
import com.peanut.modules.book.to.SeckillRedisTo;
|
//import com.peanut.modules.book.to.SeckillRedisTo;
|
||||||
import com.peanut.modules.book.vo.SeckillProdVo;
|
//import com.peanut.modules.book.vo.SeckillProdVo;
|
||||||
|
//
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 秒杀库存表
|
// * 秒杀库存表
|
||||||
*
|
// *
|
||||||
* @author yl
|
// * @author yl
|
||||||
* @email yl328572838@163.com
|
// * @email yl328572838@163.com
|
||||||
* @date 2022-10-28 11:24:05
|
// * @date 2022-10-28 11:24:05
|
||||||
*/
|
// */
|
||||||
public interface ShopSeckillService extends IService<ShopSeckillEntity> {
|
//public interface ShopSeckillService extends IService<ShopSeckillEntity> {
|
||||||
|
//
|
||||||
PageUtils queryPage(Map<String, Object> params);
|
// PageUtils queryPage(Map<String, Object> params);
|
||||||
|
//
|
||||||
List<ShopSeckillEntity> getSeckilProd3Days();
|
// List<ShopSeckillEntity> getSeckilProd3Days();
|
||||||
|
//
|
||||||
void uploadSeckilProd3Days();
|
// void uploadSeckilProd3Days();
|
||||||
|
//
|
||||||
List<SeckillRedisTo> getCurrentSeckillProd();
|
// List<SeckillRedisTo> getCurrentSeckillProd();
|
||||||
|
//
|
||||||
String kill(String killId,String key,Integer num,Integer userId);
|
// String kill(String killId,String key,Integer num,Integer userId);
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
|||||||
if (!ObjectUtils.isEmpty(myUserEntity)) {
|
if (!ObjectUtils.isEmpty(myUserEntity)) {
|
||||||
record.setUserName(myUserEntity.getName());
|
record.setUserName(myUserEntity.getName());
|
||||||
record.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetail>()
|
record.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetail>()
|
||||||
.eq("order_id", record.getOrderId())));
|
.eq("order_id", record.getId())));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
|||||||
page = this.page(page, queryWrapper);
|
page = this.page(page, queryWrapper);
|
||||||
List<BuyOrder> records = page.getRecords();
|
List<BuyOrder> records = page.getRecords();
|
||||||
for (BuyOrder buyOrder : records) {
|
for (BuyOrder buyOrder : records) {
|
||||||
Integer orderId = buyOrder.getOrderId();
|
Integer orderId = buyOrder.getId();
|
||||||
QueryWrapper<BuyOrderDetail> buyOrderDetailQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<BuyOrderDetail> buyOrderDetailQueryWrapper = new QueryWrapper<>();
|
||||||
buyOrderDetailQueryWrapper.eq("order_id", orderId);
|
buyOrderDetailQueryWrapper.eq("order_id", orderId);
|
||||||
List<BuyOrderDetail> buyOrderDetailList = buyOrderDetailService.list(buyOrderDetailQueryWrapper);
|
List<BuyOrderDetail> buyOrderDetailList = buyOrderDetailService.list(buyOrderDetailQueryWrapper);
|
||||||
@@ -179,14 +179,14 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
|||||||
);
|
);
|
||||||
for (BuyOrder order : buyOrderList) {
|
for (BuyOrder order : buyOrderList) {
|
||||||
order.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetail>()
|
order.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetail>()
|
||||||
.eq("order_id", order.getOrderId())));
|
.eq("order_id", order.getId())));
|
||||||
orderList.add(order);
|
orderList.add(order);
|
||||||
}
|
}
|
||||||
// 清洗数据 (与前端传来的id对比后)
|
// 清洗数据 (与前端传来的id对比后)
|
||||||
List<BuyOrder> washOrderList = new ArrayList<>();
|
List<BuyOrder> washOrderList = new ArrayList<>();
|
||||||
for (BuyOrder order : orderList) {
|
for (BuyOrder order : orderList) {
|
||||||
for (int o : orderIds) {
|
for (int o : orderIds) {
|
||||||
if (o == order.getOrderId()) {
|
if (o == order.getId()) {
|
||||||
washOrderList.add(order);
|
washOrderList.add(order);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -268,7 +268,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
|||||||
);
|
);
|
||||||
for (BuyOrder order : buyOrderList.getRecords()) {
|
for (BuyOrder order : buyOrderList.getRecords()) {
|
||||||
order.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetail>()
|
order.setProducts(buyOrderDetailService.list(new QueryWrapper<BuyOrderDetail>()
|
||||||
.eq("order_id", order.getOrderId())));
|
.eq("order_id", order.getId())));
|
||||||
orderList.add(order);
|
orderList.add(order);
|
||||||
}
|
}
|
||||||
// 获取有订单的所有用户
|
// 获取有订单的所有用户
|
||||||
@@ -334,26 +334,29 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delivery(String expressCompanyCode, List<Integer> buyOrderDetailId) {
|
public void delivery(String expressCompanyCode, List<Integer> buyOrderProductId) {
|
||||||
QueryWrapper<BuyOrderDetail> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<BuyOrderProduct> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.in("id", buyOrderDetailId);
|
queryWrapper.in("id", buyOrderProductId);
|
||||||
List<BuyOrderDetail> buyOrderDetailList = buyOrderDetailService.list(queryWrapper);
|
List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.list(queryWrapper);
|
||||||
BigDecimal totalWeight = new BigDecimal(0);
|
BigDecimal totalWeight = new BigDecimal(0);
|
||||||
List<ExpressCommodity> commodityList = new ArrayList<>();
|
List<ExpressCommodity> commodityList = new ArrayList<>();
|
||||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetailList) {
|
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||||
|
int productId = buyOrderProduct.getProductId();
|
||||||
|
ShopProduct product = shopProductService.getById(productId);
|
||||||
ExpressCommodity commodity = new ExpressCommodity();
|
ExpressCommodity commodity = new ExpressCommodity();
|
||||||
commodity.setGoodsName(buyOrderDetail.getProductName());
|
commodity.setGoodsName(product.getProductName());
|
||||||
commodity.setGoodsquantity(buyOrderDetail.getQuantity());
|
commodity.setGoodsquantity(buyOrderProduct.getQuantity());
|
||||||
commodity.setGoodsWeight(buyOrderDetail.getWeight().doubleValue());
|
commodity.setGoodsWeight(product.getWeight().doubleValue());
|
||||||
totalWeight = totalWeight.add(
|
totalWeight = totalWeight.add(
|
||||||
BigDecimal.valueOf(buyOrderDetail.getWeight().doubleValue()).multiply(new BigDecimal(buyOrderDetail.getQuantity()))
|
BigDecimal.valueOf(product.getWeight().doubleValue()).multiply(new BigDecimal(buyOrderProduct.getQuantity()))
|
||||||
);
|
);
|
||||||
totalWeight = totalWeight.setScale(0, RoundingMode.UP);
|
totalWeight = totalWeight.setScale(0, RoundingMode.UP);
|
||||||
commodityList.add(commodity);
|
commodityList.add(commodity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户地址
|
// 获取用户地址
|
||||||
Integer orderId = buyOrderDetailList.get(0).getOrderId();
|
Integer orderId = buyOrderProductList.get(0).getOrderId();
|
||||||
|
|
||||||
BuyOrder buyOrder = getById(orderId);
|
BuyOrder buyOrder = getById(orderId);
|
||||||
QueryWrapper<County> countyQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<County> countyQueryWrapper = new QueryWrapper<>();
|
||||||
countyQueryWrapper.eq("county_name", buyOrder.getDistrict());
|
countyQueryWrapper.eq("county_name", buyOrder.getDistrict());
|
||||||
@@ -374,14 +377,11 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
|||||||
expressOrder.setAddress(buyOrder.getAddress());
|
expressOrder.setAddress(buyOrder.getAddress());
|
||||||
// 生成快递面单
|
// 生成快递面单
|
||||||
ExpressOrderResponseVo response = expressOrderService.placeExpressOrder(expressOrder);
|
ExpressOrderResponseVo response = expressOrderService.placeExpressOrder(expressOrder);
|
||||||
String expressBillNo = response.getOrder().getLogisticCode();
|
String expressOrderSn = response.getOrder().getLogisticCode();
|
||||||
String expressBillTemplate = response.getPrintTemplate();
|
String printTemplate = response.getPrintTemplate();
|
||||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetailList) {
|
expressOrder.setExpressOrderSn(expressOrderSn);
|
||||||
buyOrderDetail.setExpressBillNo(expressBillNo);
|
expressOrder.setPrintTemplate(printTemplate);
|
||||||
buyOrderDetail.setExpressBillTemplate(expressBillTemplate);
|
expressOrderService.save(expressOrder);
|
||||||
buyOrderDetail.setExpressCompanyCode(expressCompanyCode);
|
|
||||||
}
|
|
||||||
buyOrderDetailService.saveBatch(buyOrderDetailList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -425,7 +425,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
|||||||
consigneeVo.setAddress(buyOrder.getAddress());
|
consigneeVo.setAddress(buyOrder.getAddress());
|
||||||
responseVo.setConsignee(consigneeVo);
|
responseVo.setConsignee(consigneeVo);
|
||||||
QueryWrapper<BuyOrderProduct> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<BuyOrderProduct> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("order_id", buyOrder.getOrderId());
|
queryWrapper.eq("order_id", buyOrder.getId());
|
||||||
List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.list(queryWrapper);
|
List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.list(queryWrapper);
|
||||||
List<GoodsResponseVo> goodsResponseVoList = new ArrayList<>();
|
List<GoodsResponseVo> goodsResponseVoList = new ArrayList<>();
|
||||||
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||||
|
|||||||
@@ -1,255 +1,255 @@
|
|||||||
package com.peanut.modules.book.service.impl;
|
//package com.peanut.modules.book.service.impl;
|
||||||
|
//
|
||||||
import com.alibaba.fastjson.JSON;
|
//import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.TypeReference;
|
//import com.alibaba.fastjson.TypeReference;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
//import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
import com.peanut.modules.book.entity.SeckillProdRelationEntity;
|
//import com.peanut.modules.book.entity.SeckillProdRelationEntity;
|
||||||
import com.peanut.modules.book.entity.ShopProduct;
|
//import com.peanut.modules.book.entity.ShopProduct;
|
||||||
import com.peanut.modules.book.service.SeckillProdRelationService;
|
//import com.peanut.modules.book.service.SeckillProdRelationService;
|
||||||
import com.peanut.modules.book.service.ShopProductService;
|
//import com.peanut.modules.book.service.ShopProductService;
|
||||||
import com.peanut.modules.book.to.SeckillRedisTo;
|
//import com.peanut.modules.book.to.SeckillRedisTo;
|
||||||
import com.peanut.modules.book.vo.ProdInfoVo;
|
//import com.peanut.modules.book.vo.ProdInfoVo;
|
||||||
import com.peanut.modules.book.vo.SeckillSessionWithProdVo;
|
//import com.peanut.modules.book.vo.SeckillSessionWithProdVo;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang.StringUtils;
|
//import org.apache.commons.lang.StringUtils;
|
||||||
import org.redisson.api.RSemaphore;
|
//import org.redisson.api.RSemaphore;
|
||||||
import org.redisson.api.RedissonClient;
|
//import org.redisson.api.RedissonClient;
|
||||||
import org.springframework.beans.BeanUtils;
|
//import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.BoundHashOperations;
|
//import org.springframework.data.redis.core.BoundHashOperations;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
//import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
//import org.springframework.stereotype.Service;
|
||||||
|
//
|
||||||
import java.time.LocalDate;
|
//import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
//import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
//import java.time.LocalTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
//import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
//import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
//import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
//import java.util.stream.Collectors;
|
||||||
|
//
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
//import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.peanut.common.utils.PageUtils;
|
//import com.peanut.common.utils.PageUtils;
|
||||||
import com.peanut.common.utils.Query;
|
//import com.peanut.common.utils.Query;
|
||||||
|
//
|
||||||
import com.peanut.modules.book.dao.ShopSeckillDao;
|
//import com.peanut.modules.book.dao.ShopSeckillDao;
|
||||||
import com.peanut.modules.book.entity.ShopSeckillEntity;
|
//import com.peanut.modules.book.entity.ShopSeckillEntity;
|
||||||
import com.peanut.modules.book.service.ShopSeckillService;
|
//import com.peanut.modules.book.service.ShopSeckillService;
|
||||||
|
//
|
||||||
@Slf4j
|
//@Slf4j
|
||||||
@Service("shopSeckillService")
|
//@Service("shopSeckillService")
|
||||||
public class ShopSeckillServiceImpl extends ServiceImpl<ShopSeckillDao, ShopSeckillEntity> implements ShopSeckillService {
|
//public class ShopSeckillServiceImpl extends ServiceImpl<ShopSeckillDao, ShopSeckillEntity> implements ShopSeckillService {
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private SeckillProdRelationService seckillProdRelationService;
|
// private SeckillProdRelationService seckillProdRelationService;
|
||||||
@Autowired
|
// @Autowired
|
||||||
StringRedisTemplate stringRedisTemplate;
|
// StringRedisTemplate stringRedisTemplate;
|
||||||
@Autowired
|
// @Autowired
|
||||||
private ShopProductService shopProductService;
|
// private ShopProductService shopProductService;
|
||||||
@Autowired
|
// @Autowired
|
||||||
RedissonClient redissonClient;
|
// RedissonClient redissonClient;
|
||||||
|
//
|
||||||
private final String SESSIONS_CACHE_PREFIX = "seckill:sessions:";
|
// private final String SESSIONS_CACHE_PREFIX = "seckill:sessions:";
|
||||||
private final String PROKILL_CACHE_PREFIX = "prokill:pro";
|
// private final String PROKILL_CACHE_PREFIX = "prokill:pro";
|
||||||
private final String PRO_STOCK_SEMAPHORE = "seckill:stock:";
|
// private final String PRO_STOCK_SEMAPHORE = "seckill:stock:";
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
// public PageUtils queryPage(Map<String, Object> params) {
|
||||||
IPage<ShopSeckillEntity> page = this.page(
|
// IPage<ShopSeckillEntity> page = this.page(
|
||||||
new Query<ShopSeckillEntity>().getPage(params),
|
// new Query<ShopSeckillEntity>().getPage(params),
|
||||||
new QueryWrapper<ShopSeckillEntity>()
|
// new QueryWrapper<ShopSeckillEntity>()
|
||||||
|
//
|
||||||
);
|
// );
|
||||||
|
//
|
||||||
return new PageUtils(page);
|
// return new PageUtils(page);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public List<ShopSeckillEntity> getSeckilProd3Days() {
|
// public List<ShopSeckillEntity> getSeckilProd3Days() {
|
||||||
List<ShopSeckillEntity> list = this.baseMapper.selectList(new QueryWrapper<ShopSeckillEntity>().between("start_time", startTime(), endTime()));
|
// List<ShopSeckillEntity> list = this.baseMapper.selectList(new QueryWrapper<ShopSeckillEntity>().between("start_time", startTime(), endTime()));
|
||||||
if (list != null && list.size() > 0) {
|
// if (list != null && list.size() > 0) {
|
||||||
list.stream().map(session -> {
|
// list.stream().map(session -> {
|
||||||
Long seckillId = session.getSeckillId();
|
// Long seckillId = session.getSeckillId();
|
||||||
List<SeckillProdRelationEntity> seckillList = seckillProdRelationService.list(new QueryWrapper<SeckillProdRelationEntity>().eq("promotion_seckill_id", seckillId));
|
// List<SeckillProdRelationEntity> seckillList = seckillProdRelationService.list(new QueryWrapper<SeckillProdRelationEntity>().eq("promotion_seckill_id", seckillId));
|
||||||
session.setRelationProd(seckillList);
|
// session.setRelationProd(seckillList);
|
||||||
return session;
|
// return session;
|
||||||
}).collect(Collectors.toList());
|
// }).collect(Collectors.toList());
|
||||||
}
|
// }
|
||||||
return list;
|
// return list;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void uploadSeckilProd3Days() {
|
// public void uploadSeckilProd3Days() {
|
||||||
List<ShopSeckillEntity> seckilProd = this.getSeckilProd3Days();
|
// List<ShopSeckillEntity> seckilProd = this.getSeckilProd3Days();
|
||||||
List<SeckillSessionWithProdVo> seckilProdVo = JSON.parseObject(JSON.toJSONString(seckilProd), new TypeReference<List<SeckillSessionWithProdVo>>() {
|
// List<SeckillSessionWithProdVo> seckilProdVo = JSON.parseObject(JSON.toJSONString(seckilProd), new TypeReference<List<SeckillSessionWithProdVo>>() {
|
||||||
});
|
// });
|
||||||
saveSessionInfo(seckilProdVo);
|
// saveSessionInfo(seckilProdVo);
|
||||||
saveSessionProdInfo(seckilProdVo);
|
// saveSessionProdInfo(seckilProdVo);
|
||||||
|
//
|
||||||
Set<String> keys = stringRedisTemplate.keys(SESSIONS_CACHE_PREFIX + "*");
|
// Set<String> keys = stringRedisTemplate.keys(SESSIONS_CACHE_PREFIX + "*");
|
||||||
long time = new Date().getTime();
|
// long time = new Date().getTime();
|
||||||
for(String key : keys){
|
// for(String key : keys){
|
||||||
String replace = key.replace(SESSIONS_CACHE_PREFIX, "");
|
// String replace = key.replace(SESSIONS_CACHE_PREFIX, "");
|
||||||
String[] s = replace.split("_");
|
// String[] s = replace.split("_");
|
||||||
long endTime = Long.parseLong(s[1]);
|
// long endTime = Long.parseLong(s[1]);
|
||||||
if(endTime <= time){
|
// if(endTime <= time){
|
||||||
stringRedisTemplate.delete(key);
|
// stringRedisTemplate.delete(key);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public List<SeckillRedisTo> getCurrentSeckillProd() {
|
// public List<SeckillRedisTo> getCurrentSeckillProd() {
|
||||||
long time = new Date().getTime();
|
// long time = new Date().getTime();
|
||||||
|
//
|
||||||
Set<String> keys = stringRedisTemplate.keys(SESSIONS_CACHE_PREFIX + "*");
|
// Set<String> keys = stringRedisTemplate.keys(SESSIONS_CACHE_PREFIX + "*");
|
||||||
|
//
|
||||||
for (String key : keys) {
|
// for (String key : keys) {
|
||||||
String replace = key.replace(SESSIONS_CACHE_PREFIX, "");
|
// String replace = key.replace(SESSIONS_CACHE_PREFIX, "");
|
||||||
String[] s = replace.split("_");
|
// String[] s = replace.split("_");
|
||||||
long startTime = Long.parseLong(s[0]);
|
// long startTime = Long.parseLong(s[0]);
|
||||||
long endTime = Long.parseLong(s[1]);
|
// long endTime = Long.parseLong(s[1]);
|
||||||
|
//
|
||||||
|
//
|
||||||
if (time >= startTime && time <= endTime ) {
|
// if (time >= startTime && time <= endTime ) {
|
||||||
|
//
|
||||||
List<String> list = stringRedisTemplate.opsForList().range(key, -100, 100);
|
// List<String> list = stringRedisTemplate.opsForList().range(key, -100, 100);
|
||||||
BoundHashOperations<String, String, Object> operations = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
// BoundHashOperations<String, String, Object> operations = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
||||||
List<Object> objects = operations.multiGet(list);
|
// List<Object> objects = operations.multiGet(list);
|
||||||
if (objects.size() > 0) {
|
// if (objects.size() > 0) {
|
||||||
List<SeckillRedisTo> collect = objects.stream().map(item -> {
|
// List<SeckillRedisTo> collect = objects.stream().map(item -> {
|
||||||
SeckillRedisTo seckillRedisTo = JSON.parseObject(item.toString(), SeckillRedisTo.class);
|
// SeckillRedisTo seckillRedisTo = JSON.parseObject(item.toString(), SeckillRedisTo.class);
|
||||||
// seckillRedisTo.setRandomCode(null);
|
//// seckillRedisTo.setRandomCode(null);
|
||||||
return seckillRedisTo;
|
// return seckillRedisTo;
|
||||||
}).collect(Collectors.toList());
|
// }).collect(Collectors.toList());
|
||||||
return collect;
|
// return collect;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String kill(String killId, String key, Integer num , Integer userId) {
|
// public String kill(String killId, String key, Integer num , Integer userId) {
|
||||||
|
//
|
||||||
|
//
|
||||||
BoundHashOperations<String, String, String> hashOps = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
// BoundHashOperations<String, String, String> hashOps = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
||||||
String o = hashOps.get(killId);
|
// String o = hashOps.get(killId);
|
||||||
if (StringUtils.isEmpty(o)){
|
// if (StringUtils.isEmpty(o)){
|
||||||
return null;
|
// return null;
|
||||||
}else {
|
// }else {
|
||||||
SeckillRedisTo seckillRedisTo = JSON.parseObject(o, SeckillRedisTo.class);
|
// SeckillRedisTo seckillRedisTo = JSON.parseObject(o, SeckillRedisTo.class);
|
||||||
Long startTime = seckillRedisTo.getStartTime();
|
// Long startTime = seckillRedisTo.getStartTime();
|
||||||
Long endTime = seckillRedisTo.getEndTime();
|
// Long endTime = seckillRedisTo.getEndTime();
|
||||||
|
//
|
||||||
long time = new Date().getTime();
|
// long time = new Date().getTime();
|
||||||
|
//
|
||||||
long ttl = endTime - time;
|
// long ttl = endTime - time;
|
||||||
if ( time >= startTime && time <= endTime){
|
// if ( time >= startTime && time <= endTime){
|
||||||
String randomCode = seckillRedisTo.getRandomCode();
|
// String randomCode = seckillRedisTo.getRandomCode();
|
||||||
String prodId = seckillRedisTo.getPromotionSeckillId() + "_" + seckillRedisTo.getProdId();
|
// String prodId = seckillRedisTo.getPromotionSeckillId() + "_" + seckillRedisTo.getProdId();
|
||||||
if( randomCode.equals(key) && killId.equals(prodId)){
|
// if( randomCode.equals(key) && killId.equals(prodId)){
|
||||||
if (num <= Integer.valueOf(seckillRedisTo.getSeckillLimit())) {
|
// if (num <= Integer.valueOf(seckillRedisTo.getSeckillLimit())) {
|
||||||
String redisKey = userId + "_" + prodId;
|
// String redisKey = userId + "_" + prodId;
|
||||||
Boolean aBoolean = stringRedisTemplate.opsForValue().setIfAbsent(redisKey, num.toString(), ttl, TimeUnit.MILLISECONDS);
|
// Boolean aBoolean = stringRedisTemplate.opsForValue().setIfAbsent(redisKey, num.toString(), ttl, TimeUnit.MILLISECONDS);
|
||||||
if (aBoolean) {
|
// if (aBoolean) {
|
||||||
RSemaphore semaphore = redissonClient.getSemaphore(PRO_STOCK_SEMAPHORE + randomCode);
|
// RSemaphore semaphore = redissonClient.getSemaphore(PRO_STOCK_SEMAPHORE + randomCode);
|
||||||
try {
|
// try {
|
||||||
boolean b = semaphore.tryAcquire(num, 100, TimeUnit.MILLISECONDS);
|
// boolean b = semaphore.tryAcquire(num, 100, TimeUnit.MILLISECONDS);
|
||||||
// 秒杀成功
|
// // 秒杀成功
|
||||||
String timeId = IdWorker.getTimeId();
|
// String timeId = IdWorker.getTimeId();
|
||||||
return timeId;
|
// return timeId;
|
||||||
|
//
|
||||||
} catch (InterruptedException e) {
|
// } catch (InterruptedException e) {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
}else {
|
// }else {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}else {
|
// }else {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
}else {
|
// }else {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
private void saveSessionInfo(List<SeckillSessionWithProdVo> seckilProdVo) {
|
// private void saveSessionInfo(List<SeckillSessionWithProdVo> seckilProdVo) {
|
||||||
seckilProdVo.stream().forEach(session -> {
|
// seckilProdVo.stream().forEach(session -> {
|
||||||
long startTime = session.getStartTime().getTime();
|
// long startTime = session.getStartTime().getTime();
|
||||||
long endTime = session.getEndTime().getTime();
|
// long endTime = session.getEndTime().getTime();
|
||||||
String key = SESSIONS_CACHE_PREFIX + startTime + "_" + endTime;
|
// String key = SESSIONS_CACHE_PREFIX + startTime + "_" + endTime;
|
||||||
|
//
|
||||||
Boolean aBoolean = stringRedisTemplate.hasKey(key);
|
// Boolean aBoolean = stringRedisTemplate.hasKey(key);
|
||||||
if (!aBoolean) {
|
// if (!aBoolean) {
|
||||||
List<String> collect = session.getRelationProd().stream().map(item -> item.getPromotionSeckillId() + "_" + item.getProdId().toString()).collect(Collectors.toList());
|
// List<String> collect = session.getRelationProd().stream().map(item -> item.getPromotionSeckillId() + "_" + item.getProdId().toString()).collect(Collectors.toList());
|
||||||
stringRedisTemplate.opsForList().leftPushAll(key, collect);
|
// stringRedisTemplate.opsForList().leftPushAll(key, collect);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void saveSessionProdInfo(List<SeckillSessionWithProdVo> seckilProdVos) {
|
// private void saveSessionProdInfo(List<SeckillSessionWithProdVo> seckilProdVos) {
|
||||||
|
//
|
||||||
seckilProdVos.stream().forEach(seckilProdVo -> {
|
// seckilProdVos.stream().forEach(seckilProdVo -> {
|
||||||
|
//
|
||||||
BoundHashOperations<String, Object, Object> ops = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
// BoundHashOperations<String, Object, Object> ops = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
||||||
|
//
|
||||||
seckilProdVo.getRelationProd().stream().forEach(seckilProd -> {
|
// seckilProdVo.getRelationProd().stream().forEach(seckilProd -> {
|
||||||
String token = UUID.randomUUID().toString().replace("-", "");
|
// String token = UUID.randomUUID().toString().replace("-", "");
|
||||||
if (!ops.hasKey(seckilProd.getPromotionSeckillId().toString() + "_" + seckilProd.getProdId().toString())) {
|
// if (!ops.hasKey(seckilProd.getPromotionSeckillId().toString() + "_" + seckilProd.getProdId().toString())) {
|
||||||
SeckillRedisTo seckillRedisTo = new SeckillRedisTo();
|
// SeckillRedisTo seckillRedisTo = new SeckillRedisTo();
|
||||||
|
//
|
||||||
ShopProduct productEntity = shopProductService.getById(seckilProd.getProdId());
|
// ShopProduct productEntity = shopProductService.getById(seckilProd.getProdId());
|
||||||
ProdInfoVo prodInfoVo = JSON.parseObject(JSON.toJSONString(productEntity), new TypeReference<ProdInfoVo>() {
|
// ProdInfoVo prodInfoVo = JSON.parseObject(JSON.toJSONString(productEntity), new TypeReference<ProdInfoVo>() {
|
||||||
});
|
// });
|
||||||
seckillRedisTo.setProdInfo(prodInfoVo);
|
// seckillRedisTo.setProdInfo(prodInfoVo);
|
||||||
BeanUtils.copyProperties(seckilProd, seckillRedisTo);
|
// BeanUtils.copyProperties(seckilProd, seckillRedisTo);
|
||||||
|
//
|
||||||
seckillRedisTo.setStartTime(seckilProdVo.getStartTime().getTime());
|
// seckillRedisTo.setStartTime(seckilProdVo.getStartTime().getTime());
|
||||||
seckillRedisTo.setEndTime(seckilProdVo.getEndTime().getTime());
|
// seckillRedisTo.setEndTime(seckilProdVo.getEndTime().getTime());
|
||||||
|
//
|
||||||
seckillRedisTo.setRandomCode(token);
|
// seckillRedisTo.setRandomCode(token);
|
||||||
|
//
|
||||||
|
//
|
||||||
String string = JSON.toJSONString(seckillRedisTo);
|
// String string = JSON.toJSONString(seckillRedisTo);
|
||||||
ops.put(seckilProd.getPromotionSeckillId().toString() + "_" + seckilProd.getProdId().toString(), string);
|
// ops.put(seckilProd.getPromotionSeckillId().toString() + "_" + seckilProd.getProdId().toString(), string);
|
||||||
|
//
|
||||||
RSemaphore semaphore = redissonClient.getSemaphore(PRO_STOCK_SEMAPHORE + token);
|
// RSemaphore semaphore = redissonClient.getSemaphore(PRO_STOCK_SEMAPHORE + token);
|
||||||
semaphore.trySetPermits(Integer.valueOf(seckilProd.getSeckillCount()));
|
// semaphore.trySetPermits(Integer.valueOf(seckilProd.getSeckillCount()));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
private String startTime() {
|
// private String startTime() {
|
||||||
LocalDate now = LocalDate.now();
|
// LocalDate now = LocalDate.now();
|
||||||
LocalTime min = LocalTime.MIN;
|
// LocalTime min = LocalTime.MIN;
|
||||||
LocalDateTime start = LocalDateTime.of(now, min);
|
// LocalDateTime start = LocalDateTime.of(now, min);
|
||||||
String format = start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
// String format = start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
return format;
|
// return format;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private String endTime() {
|
// private String endTime() {
|
||||||
LocalDate now = LocalDate.now();
|
// LocalDate now = LocalDate.now();
|
||||||
LocalDate localDate = now.plusDays(2);
|
// LocalDate localDate = now.plusDays(2);
|
||||||
LocalDateTime of = LocalDateTime.of(localDate, LocalTime.MAX);
|
// LocalDateTime of = LocalDateTime.of(localDate, LocalTime.MAX);
|
||||||
String format = of.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
// String format = of.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
return format;
|
// return format;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
@@ -1,33 +1,33 @@
|
|||||||
package com.peanut.modules.book.task;
|
//package com.peanut.modules.book.task;
|
||||||
|
//
|
||||||
import com.peanut.modules.book.service.ShopSeckillService;
|
//import com.peanut.modules.book.service.ShopSeckillService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
//import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
//import org.springframework.stereotype.Service;
|
||||||
|
//
|
||||||
import java.util.concurrent.locks.Lock;
|
//import java.util.concurrent.locks.Lock;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
//import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
//
|
||||||
@Slf4j
|
//@Slf4j
|
||||||
@Service
|
//@Service
|
||||||
public class SeckillProdScheduled {
|
//public class SeckillProdScheduled {
|
||||||
@Autowired
|
// @Autowired
|
||||||
ShopSeckillService shopSeckillService;
|
// ShopSeckillService shopSeckillService;
|
||||||
|
//
|
||||||
@Scheduled(cron = "0 0/1 * * * ?")
|
// @Scheduled(cron = "0 0/1 * * * ?")
|
||||||
public void uploadSeckilProd3Days() {
|
// public void uploadSeckilProd3Days() {
|
||||||
Lock l = new ReentrantLock();
|
// Lock l = new ReentrantLock();
|
||||||
l.lock();
|
// l.lock();
|
||||||
try {
|
// try {
|
||||||
shopSeckillService.uploadSeckilProd3Days();
|
// shopSeckillService.uploadSeckilProd3Days();
|
||||||
}catch (Exception e){
|
// }catch (Exception e){
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}finally {
|
// }finally {
|
||||||
l.unlock();
|
// l.unlock();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -16,15 +16,15 @@ public class ModifyOrderAddressRequestVo {
|
|||||||
/**
|
/**
|
||||||
* 省
|
* 省
|
||||||
*/
|
*/
|
||||||
private String province;
|
private String provinceCode;
|
||||||
/**
|
/**
|
||||||
* 市
|
* 市
|
||||||
*/
|
*/
|
||||||
private String city;
|
private String cityCode;
|
||||||
/**
|
/**
|
||||||
* 区县
|
* 区县
|
||||||
*/
|
*/
|
||||||
private String county;
|
private String countyCode;
|
||||||
/**
|
/**
|
||||||
* 收货人姓名
|
* 收货人姓名
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<!-- 可根据自己的需求,是否要使用 -->
|
<!-- 可根据自己的需求,是否要使用 -->
|
||||||
<resultMap type="com.peanut.modules.book.entity.BuyOrder" id="buyOrderMap">
|
<resultMap type="com.peanut.modules.book.entity.BuyOrder" id="buyOrderMap">
|
||||||
<result property="orderId" column="order_id"/>
|
<result property="id" column="id"/>
|
||||||
<result property="orderSn" column="order_sn"/>
|
<result property="orderSn" column="order_sn"/>
|
||||||
<result property="userId" column="user_id"/>
|
<result property="userId" column="user_id"/>
|
||||||
<result property="shippingUser" column="shipping_user"/>
|
<result property="shippingUser" column="shipping_user"/>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
SELECT spb.book_id
|
SELECT spb.book_id
|
||||||
FROM shop_product_book spb
|
FROM shop_product_book spb
|
||||||
LEFT JOIN buy_order_detail bod ON spb.product_id = bod.product_id
|
LEFT JOIN buy_order_detail bod ON spb.product_id = bod.product_id
|
||||||
LEFT JOIN buy_order bo ON bo.order_id = bod.order_id
|
LEFT JOIN buy_order bo ON bo.id = bod.order_id
|
||||||
WHERE bo.order_sn = #{orderSn}
|
WHERE bo.order_sn = #{orderSn}
|
||||||
AND spb.del_flag != -1
|
AND spb.del_flag != -1
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
Reference in New Issue
Block a user