Merge branch 'develop/express'
# Conflicts: # src/main/resources/application-dev.yml
This commit is contained in:
@@ -19,13 +19,14 @@ public class Constants {
|
||||
*/
|
||||
public static final String ORDER_STATUS_SHIPPED = "2";
|
||||
/**
|
||||
* 订单状态 - 已发货
|
||||
* 订单状态 - 已完成
|
||||
*/
|
||||
public static final String ORDER_STATUS_FINISHED = "3";
|
||||
/**
|
||||
* 订单状态 - 交易失败
|
||||
*/
|
||||
public static final String ORDER_STATUS_FAIL = "4";
|
||||
|
||||
/**
|
||||
* 订单状态 - 全部
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.BookClockEntryEntity;
|
||||
@@ -69,6 +70,7 @@ public class BookClockForumController {
|
||||
@RequestParam(value = "userId", required = false) Integer userId,
|
||||
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
|
||||
@RequestParam(value = "currentPage", defaultValue = "1") Integer currentPage) {
|
||||
Page<BookClockEntryChat> chatPage = new Page<>(currentPage, pageSize);
|
||||
QueryWrapper<BookClockEntryChat> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("entry_id", entryId);
|
||||
queryWrapper.eq("fid", 0);
|
||||
@@ -77,7 +79,8 @@ public class BookClockForumController {
|
||||
}
|
||||
queryWrapper.orderByAsc("fid", "create_time");
|
||||
List<ClockInCommentVo> resultList = new ArrayList<>();
|
||||
List<BookClockEntryChat> chatEntityList = bookClockEntryChatService.list(queryWrapper);
|
||||
Page<BookClockEntryChat> page = bookClockEntryChatService.page(chatPage, queryWrapper);
|
||||
List<BookClockEntryChat> chatEntityList = page.getRecords();
|
||||
for (BookClockEntryChat entity : chatEntityList) {
|
||||
List<String> imageList = JSON.parseObject(entity.getImages(), new TypeReference<List<String>>() {
|
||||
});
|
||||
@@ -89,8 +92,7 @@ public class BookClockForumController {
|
||||
vo.setAvatar(user.getAvatar());
|
||||
resultList.add(vo);
|
||||
}
|
||||
PageUtils page = new PageUtils(resultList, resultList.size(), pageSize, currentPage);
|
||||
return R.ok().put("result", page);
|
||||
return R.ok().put("result", resultList);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,9 +107,11 @@ public class BookClockForumController {
|
||||
public R getSubChatList(@RequestParam("fid") Integer fid,
|
||||
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
|
||||
@RequestParam(value = "currentPage", defaultValue = "1") Integer currentPage) {
|
||||
Page<BookClockEntryChat> bookClockEntryChatPage = new Page<>(currentPage, pageSize);
|
||||
QueryWrapper<BookClockEntryChat> subQueryWrapper = new QueryWrapper<>();
|
||||
subQueryWrapper.eq("fid", fid);
|
||||
List<BookClockEntryChat> subClockInChatList = bookClockEntryChatService.list(subQueryWrapper);
|
||||
Page<BookClockEntryChat> page = bookClockEntryChatService.page(bookClockEntryChatPage, subQueryWrapper);
|
||||
List<BookClockEntryChat> subClockInChatList = page.getRecords();
|
||||
List<ClockInCommentVo> subCommentList = new ArrayList<>();
|
||||
for (BookClockEntryChat subChat : subClockInChatList) {
|
||||
ClockInCommentVo subVo = new ClockInCommentVo();
|
||||
@@ -120,8 +124,7 @@ public class BookClockForumController {
|
||||
subVo.setNickName(subChatUser.getNickname());
|
||||
subCommentList.add(subVo);
|
||||
}
|
||||
PageUtils subChatPage = new PageUtils(subCommentList, subCommentList.size(), pageSize, currentPage);
|
||||
return R.ok().put("result", subChatPage);
|
||||
return R.ok().put("result", subCommentList);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,14 +10,15 @@ 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.book.to.UserOrderDto;
|
||||
import com.peanut.modules.book.vo.UserAddressVo;
|
||||
import com.peanut.modules.book.vo.request.BuyOrderListRequestVo;
|
||||
import com.peanut.modules.book.vo.request.ModifyOrderAddressRequestVo;
|
||||
import com.peanut.modules.book.vo.request.ProductRequestVo;
|
||||
import com.peanut.modules.book.vo.request.ProductTransportVo;
|
||||
import com.peanut.modules.book.vo.response.BuyOrderResponseVo;
|
||||
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.pay.weChatPay.dto.WechatPaymentInfo;
|
||||
import com.peanut.modules.pay.weChatPay.service.WxpayService;
|
||||
import com.peanut.modules.sys.entity.SysConfigEntity;
|
||||
@@ -80,10 +81,18 @@ public class BuyOrderController {
|
||||
private ExpressFeeService expressFeeService;
|
||||
@Autowired
|
||||
private SysConfigService sysConfigService;
|
||||
@Autowired
|
||||
private BuyOrderProductService buyOrderProductService;
|
||||
@Autowired
|
||||
private ProvinceService provinceService;
|
||||
@Autowired
|
||||
private CityService cityService;
|
||||
@Autowired
|
||||
private CountyService countyService;
|
||||
|
||||
@RequestMapping(value = "/decomposeShipment", method = RequestMethod.GET)
|
||||
public R decomposeShipment(@RequestParam("userId") Integer userId) {
|
||||
Map<Integer, List<String>> result = buyOrderService.decomposeShipment(userId);
|
||||
@RequestMapping(value = "/decomposeShipment", method = RequestMethod.POST)
|
||||
public R decomposeShipment(@RequestBody BuyOrderListRequestVo requestVo) {
|
||||
Map<String, Object> result = buyOrderService.decomposeShipment(requestVo);
|
||||
return R.ok().put("result", result);
|
||||
}
|
||||
|
||||
@@ -103,8 +112,19 @@ public class BuyOrderController {
|
||||
*/
|
||||
@RequestMapping(path = "/orderList", method = RequestMethod.POST)
|
||||
public R orderList(@RequestBody BuyOrderListRequestVo requestVo) {
|
||||
PageUtils page = buyOrderService.orderList(requestVo);
|
||||
return R.ok().put("result", page);
|
||||
Map<String, Object> result = buyOrderService.orderList(requestVo);
|
||||
return R.ok().put("result", result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户订单列表
|
||||
* @param userOrderDto
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getUserOrderList")
|
||||
public R getUserOrderList(@RequestBody UserOrderDto userOrderDto){
|
||||
Page<BuyOrder> userOrderList = buyOrderService.getUserOrderList(userOrderDto);
|
||||
return R.ok().put("page",userOrderList);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,6 +141,7 @@ public class BuyOrderController {
|
||||
|
||||
/**
|
||||
* 下单
|
||||
* TODO 原下单接口,新版本上线后废弃
|
||||
*
|
||||
* @param buyOrder 订单
|
||||
* @return R
|
||||
@@ -210,6 +231,93 @@ public class BuyOrderController {
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下单
|
||||
*
|
||||
* @param buyOrder
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@RequestMapping(value = "/placeOrder", method = RequestMethod.POST)
|
||||
@Transactional
|
||||
public R placeOrder(@RequestBody BuyOrder buyOrder) throws IOException {
|
||||
List<BuyOrderProduct> buyOrderProductList = buyOrder.getProductList();
|
||||
// 订单总金额
|
||||
BigDecimal totalPrice = new BigDecimal(0);
|
||||
// 遍历商品总价计算
|
||||
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||
Integer productId = buyOrderProduct.getProductId();
|
||||
int quantity = buyOrderProduct.getQuantity();
|
||||
ShopProduct product = shopProductService.getById(productId);
|
||||
BigDecimal price = getRealPrice(product);
|
||||
if (!handleStock(buyOrderProduct, product)) {
|
||||
return R.error(500, "库存不足");
|
||||
}
|
||||
totalPrice = totalPrice.add(price.multiply(BigDecimal.valueOf(quantity)));
|
||||
}
|
||||
|
||||
totalPrice = totalPrice.subtract(useCouponAmount(buyOrder));
|
||||
totalPrice = totalPrice.add(getShoppingAmount(buyOrder));
|
||||
String orderSn = IdWorker.getTimeId().substring(0, 32);
|
||||
buyOrder.setOrderSn(orderSn);
|
||||
buyOrder.setPaymentDate(new Date());
|
||||
QueryWrapper<UserAddress> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("id", buyOrder.getAddressId());
|
||||
UserAddress userAddress = userAddressService.getOne(queryWrapper);
|
||||
UserAddressVo vo = new UserAddressVo();
|
||||
vo = userAddressService.getAddressName(vo, userAddress.getRegionCode());
|
||||
buyOrder.setProvince(vo.getProvince());
|
||||
buyOrder.setCity(vo.getCity());
|
||||
buyOrder.setDistrict(vo.getCounty());
|
||||
buyOrder.setAddress(userAddress.getDetailAddress());
|
||||
buyOrderService.save(buyOrder);
|
||||
|
||||
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||
buyOrderProduct.setOrderId(buyOrder.getOrderId());
|
||||
if (Constants.BUY_TYPE_CART.equals(buyOrder.getBuyType())) {
|
||||
handleBuyCart(buyOrder, buyOrderProduct);
|
||||
}
|
||||
}
|
||||
buyOrderProductService.saveBatch(buyOrderProductList);
|
||||
// 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(buyOrderProductList, buyOrder, 0);
|
||||
} 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算运费
|
||||
*
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(path = "/calculateTransportPrice", method = RequestMethod.POST)
|
||||
public R getTransportPrice(@RequestBody ProductTransportVo vo) {
|
||||
String regionCode = vo.getRegionCode();
|
||||
@@ -217,14 +325,21 @@ public class BuyOrderController {
|
||||
BigDecimal totalWeight = new BigDecimal(0);
|
||||
for (ProductRequestVo product : products) {
|
||||
ShopProduct shopProduct = shopProductService.getById(product.getProductId());
|
||||
if(shopProduct.getIsFreeMail()==0){
|
||||
continue;
|
||||
}
|
||||
BigDecimal weight = BigDecimal.valueOf(Double.valueOf(shopProduct.getWeight()) / 1000.0);
|
||||
totalWeight = totalWeight.add(weight.multiply(new BigDecimal(product.getQuantity())));
|
||||
}
|
||||
totalWeight = totalWeight.setScale(0, RoundingMode.UP);
|
||||
QueryWrapper<SysConfigEntity> configQueryWrapper = new QueryWrapper<>();
|
||||
configQueryWrapper.eq("param_key", "DEFAULT_EXPRESS");
|
||||
SysConfigEntity config = sysConfigService.getOne(configQueryWrapper);
|
||||
BigDecimal expressFee = expressFeeService.calculateExpressFee(config.getParamValue(), totalWeight, regionCode);
|
||||
BigDecimal expressFee = new BigDecimal(0);
|
||||
if(totalWeight.compareTo(BigDecimal.ZERO)!=0){
|
||||
totalWeight = totalWeight.setScale(0, RoundingMode.UP);
|
||||
QueryWrapper<SysConfigEntity> configQueryWrapper = new QueryWrapper<>();
|
||||
configQueryWrapper.eq("param_key", "DEFAULT_EXPRESS");
|
||||
SysConfigEntity config = sysConfigService.getOne(configQueryWrapper);
|
||||
expressFee = expressFeeService.calculateExpressFee(config.getParamValue(), totalWeight, regionCode);
|
||||
}
|
||||
|
||||
return R.ok().put("result", expressFee);
|
||||
}
|
||||
|
||||
@@ -238,6 +353,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.getOrderId());
|
||||
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.getOrderId());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@@ -251,14 +400,17 @@ public class BuyOrderController {
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] orderIds) {
|
||||
buyOrderService.removeByIds(Arrays.asList(orderIds));
|
||||
public R delete(@RequestBody List<String> orderSnList) {
|
||||
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("order_sn", orderSnList);
|
||||
buyOrderService.remove(queryWrapper);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* app 端 取消订单
|
||||
* TODO 新版本上线后此方法删除
|
||||
*/
|
||||
@RequestMapping("/appDelete")
|
||||
@Transactional
|
||||
@@ -340,6 +492,7 @@ public class BuyOrderController {
|
||||
*
|
||||
* @param orderId 订单 ID
|
||||
* @return R
|
||||
* TODO 新版本上线后 该方法删除
|
||||
*/
|
||||
@RequestMapping(value = "/getOrderInfo", method = RequestMethod.GET)
|
||||
public R appGetOrderInfo(@RequestParam("orderId") Integer orderId) {
|
||||
@@ -357,39 +510,93 @@ public class BuyOrderController {
|
||||
return R.ok().put("result", buyOrder);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/modifyOrderAddress", method = RequestMethod.POST)
|
||||
public R modifyOrderAddress(@RequestBody ShippingAddressRequestVo addressRequestVo) {
|
||||
BuyOrder buyOrder = buyOrderService.getById(addressRequestVo.getOrderId());
|
||||
buyOrder.setProvince(addressRequestVo.getProvince());
|
||||
buyOrder.setCity(addressRequestVo.getCity());
|
||||
buyOrder.setDistrict(addressRequestVo.getCounty());
|
||||
buyOrder.setShippingUser(addressRequestVo.getName());
|
||||
buyOrder.setUserPhone(addressRequestVo.getMobile());
|
||||
/**
|
||||
* 修改订单地址
|
||||
*
|
||||
* @param addressRequestVo 地址请求 value object
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping(value = "/modifyConsigneeAddress", method = RequestMethod.POST)
|
||||
public R modifyOrderAddress(@RequestBody ModifyOrderAddressRequestVo addressRequestVo) {
|
||||
QueryWrapper<BuyOrder> buyOrderQueryWrapper = new QueryWrapper<>();
|
||||
buyOrderQueryWrapper.eq("order_sn", addressRequestVo.getOrderSn());
|
||||
BuyOrder buyOrder = buyOrderService.getOne(buyOrderQueryWrapper);
|
||||
String provinceCode = addressRequestVo.getProvinceCode();
|
||||
QueryWrapper<Province> provinceQueryWrapper = new QueryWrapper<>();
|
||||
provinceQueryWrapper.eq("region_code", provinceCode);
|
||||
Province province = provinceService.getOne(provinceQueryWrapper);
|
||||
buyOrder.setProvince(province.getProvName());
|
||||
String cityCode = addressRequestVo.getCityCode();
|
||||
QueryWrapper<City> cityQueryWrapper = new QueryWrapper<>();
|
||||
cityQueryWrapper.eq("region_code", cityCode);
|
||||
City city = cityService.getOne(cityQueryWrapper);
|
||||
buyOrder.setCity(city.getCityName());
|
||||
String countyCode = addressRequestVo.getCountyCode();
|
||||
QueryWrapper<County> countyQueryWrapper = new QueryWrapper<>();
|
||||
countyQueryWrapper.eq("region_code", countyCode);
|
||||
County county = countyService.getOne(countyQueryWrapper);
|
||||
buyOrder.setDistrict(county.getCountyName());
|
||||
buyOrder.setShippingUser(addressRequestVo.getConsigneeName());
|
||||
buyOrder.setUserPhone(addressRequestVo.getConsigneeMobile());
|
||||
buyOrder.setAddress(addressRequestVo.getAddress());
|
||||
buyOrderService.updateById(buyOrder);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单地址
|
||||
*
|
||||
* @param orderSn 订单号
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping(value = "/getConsigneeAddress", method = RequestMethod.GET)
|
||||
public R getOrderAddress(@RequestParam("orderSn") String orderSn) {
|
||||
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_sn", orderSn);
|
||||
BuyOrder buyOrder = buyOrderService.getOne(queryWrapper);
|
||||
OrderAddressResponseVo responseVo = new OrderAddressResponseVo();
|
||||
responseVo.setConsigneeMobile(buyOrder.getUserPhone());
|
||||
responseVo.setConsigneeName(buyOrder.getShippingUser());
|
||||
responseVo.setDetailAddress(buyOrder.getAddress());
|
||||
String provinceName = buyOrder.getProvince();
|
||||
String cityName = buyOrder.getCity();
|
||||
String countyName = buyOrder.getDistrict();
|
||||
|
||||
QueryWrapper<Province> provinceQueryWrapper = new QueryWrapper<>();
|
||||
provinceQueryWrapper.eq("prov_name", provinceName);
|
||||
Province province = provinceService.getOne(provinceQueryWrapper);
|
||||
responseVo.setProvinceCode(province.getRegionCode());
|
||||
|
||||
QueryWrapper<City> cityQueryWrapper = new QueryWrapper<>();
|
||||
cityQueryWrapper.eq("city_name", cityName);
|
||||
City city = cityService.getOne(cityQueryWrapper);
|
||||
responseVo.setCityCode(city.getRegionCode());
|
||||
|
||||
QueryWrapper<County> countyQueryWrapper = new QueryWrapper<>();
|
||||
countyQueryWrapper.eq("county_name", countyName);
|
||||
County county = countyService.getOne(countyQueryWrapper);
|
||||
responseVo.setCountyCode(county.getRegionCode());
|
||||
|
||||
return R.ok().put("result", responseVo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询订单快递
|
||||
*
|
||||
* @param orderId 订单号
|
||||
* @param expressOrderSn 运单号
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping(value = "/queryExpress", method = RequestMethod.GET)
|
||||
public R queryExpress(@RequestParam("orderId") Integer orderId) {
|
||||
QueryWrapper<BuyOrderDetail> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_id", orderId);
|
||||
List<BuyOrderDetail> buyOrderDetailList = buyOrderDetailService.list(queryWrapper);
|
||||
List<ExpressQueryResponseVo> result = new ArrayList<>();
|
||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetailList) {
|
||||
ExpressQueryResponseVo vo = new ExpressQueryResponseVo();
|
||||
vo.setOrderDetailId(buyOrderDetail.getId());
|
||||
ExpressQueryResponse expressQueryResponse = expressOrderService.queryExpressOrder(buyOrderDetail.getExpressCompanyCode(), buyOrderDetail.getExpressBillNo());
|
||||
vo.setLogisticCode(expressQueryResponse.getLogisticCode());
|
||||
vo.setTraces(expressQueryResponse.getTraces());
|
||||
result.add(vo);
|
||||
}
|
||||
return R.ok().put("result", result);
|
||||
public R queryExpress(@RequestParam("expressOrderSn") String expressOrderSn,
|
||||
@RequestParam("expressCompanyCode") String expressCompanyCode,
|
||||
@RequestParam("customerName") String customerName) {
|
||||
|
||||
ExpressQueryResponseVo vo = new ExpressQueryResponseVo();
|
||||
ExpressQueryResponse expressQueryResponse = expressOrderService.queryExpressOrder(expressCompanyCode, expressOrderSn, customerName);
|
||||
vo.setLogisticCode(expressQueryResponse.getLogisticCode());
|
||||
vo.setTraces(expressQueryResponse.getTraces());
|
||||
return R.ok().put("result", vo);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -419,13 +626,13 @@ public class BuyOrderController {
|
||||
* 分包发货
|
||||
*
|
||||
* @param expressCompanyCode 快递公司编码
|
||||
* @param buyOrderDetailId 订单详情列表
|
||||
* @param buyOrderProductId 订单商品
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping(value = "/delivery", method = RequestMethod.POST)
|
||||
public R delivery(@RequestParam("expressCompanyCode") String expressCompanyCode,
|
||||
@RequestBody List<Integer> buyOrderDetailId) throws Exception {
|
||||
buyOrderService.delivery(expressCompanyCode, buyOrderDetailId);
|
||||
@RequestBody List<Integer> buyOrderProductId) throws Exception {
|
||||
buyOrderService.delivery(expressCompanyCode, buyOrderProductId);
|
||||
return R.ok();
|
||||
|
||||
}
|
||||
@@ -443,6 +650,7 @@ public class BuyOrderController {
|
||||
|
||||
/**
|
||||
* 处理商品库存
|
||||
* TODO 新版本上线后删除此方法
|
||||
*
|
||||
* @param buyOrderDetail
|
||||
* @param product
|
||||
@@ -459,6 +667,24 @@ public class BuyOrderController {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理商品库存
|
||||
*
|
||||
* @param buyOrderProduct 订单商品信息
|
||||
* @param product 商品
|
||||
* @return boolean
|
||||
*/
|
||||
private boolean handleStock(BuyOrderProduct buyOrderProduct, ShopProduct product) {
|
||||
int quantity = buyOrderProduct.getQuantity();
|
||||
if (product.getProductStock() - quantity < 0) {
|
||||
return false;
|
||||
}
|
||||
product.setProductStock(product.getProductStock() - quantity);
|
||||
product.setSumSales(product.getSumSales() + quantity);
|
||||
shopProductService.updateById(product);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用优惠券
|
||||
*
|
||||
@@ -480,21 +706,6 @@ public class BuyOrderController {
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算运费
|
||||
@@ -543,8 +754,9 @@ public class BuyOrderController {
|
||||
|
||||
/**
|
||||
* 给用户添加电子书
|
||||
* TODO 新版本上线删除此接口
|
||||
* @param products
|
||||
*
|
||||
* @param products
|
||||
* @param buyOrder
|
||||
*/
|
||||
private void addEbookToUser(List<BuyOrderDetail> products, BuyOrder buyOrder) {
|
||||
@@ -557,8 +769,26 @@ public class BuyOrderController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 给用户添加电子书
|
||||
* TODO 这里的参数 0 没用 新版本上线后删除
|
||||
*
|
||||
* @param products
|
||||
* @param buyOrder
|
||||
*/
|
||||
private void addEbookToUser(List<BuyOrderProduct> products, BuyOrder buyOrder, Integer x) {
|
||||
List<Integer> productIds = products.stream().map(BuyOrderProduct::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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 购物车
|
||||
* TODO 新版本上线后删除此方法
|
||||
*
|
||||
* @param buyOrder
|
||||
* @param buyOrderDetail
|
||||
@@ -572,6 +802,21 @@ public class BuyOrderController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 购物车
|
||||
*
|
||||
* @param buyOrder 订单
|
||||
* @param buyOrderProduct
|
||||
*/
|
||||
private void handleBuyCart(BuyOrder buyOrder, BuyOrderProduct buyOrderProduct) {
|
||||
List<OrderCartEntity> orderCartList = orderCartService.getBaseMapper().selectList(new QueryWrapper<OrderCartEntity>()
|
||||
.eq("user_id", buyOrder.getUserId()).eq("product_id", buyOrderProduct.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分钟
|
||||
|
||||
@@ -1,113 +1,113 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.BuyOrderDetail;
|
||||
import com.peanut.modules.book.service.BuyOrderDetailService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 商品订单详情表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/buyorderdetail")
|
||||
public class BuyOrderDetailController {
|
||||
@Autowired
|
||||
private BuyOrderDetailService buyOrderDetailService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = buyOrderDetailService.queryPage(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询已购买书籍
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/querybuy")
|
||||
public R querybuy(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = buyOrderDetailService.querybuy(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 去重查询可打印面单
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/querySheetPage")
|
||||
public R querySheetPage(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = buyOrderDetailService.querySheet(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{allOrderId}")
|
||||
public R info(@PathVariable("allOrderId") Long allOrderId) {
|
||||
BuyOrderDetail buyOrderDetail = buyOrderDetailService.getById(allOrderId);
|
||||
return R.ok().put("buyOrderDetail", buyOrderDetail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody BuyOrderDetail buyOrderDetail) {
|
||||
buyOrderDetailService.save(buyOrderDetail);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody BuyOrderDetail buyOrderDetail) {
|
||||
buyOrderDetailService.updateById(buyOrderDetail);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Long[] allOrderIds) {
|
||||
buyOrderDetailService.removeByIds(Arrays.asList(allOrderIds));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/updateOrderStatus")
|
||||
public R updateOrderStatus(@RequestBody BuyOrderDetail buyOrderDetail) {
|
||||
buyOrderDetail.setOrderStatus("2");
|
||||
buyOrderDetailService.updateById(buyOrderDetail);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据运单号批量修改打印状态
|
||||
*
|
||||
* @param shippingSnList
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/batchUpdateByShippingSns")
|
||||
public R batchUpdateByShippingSns(@RequestBody String[] shippingSnList) {
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
//package com.peanut.modules.book.controller;
|
||||
//
|
||||
//import com.peanut.common.utils.PageUtils;
|
||||
//import com.peanut.common.utils.R;
|
||||
//import com.peanut.modules.book.entity.BuyOrderDetail;
|
||||
//import com.peanut.modules.book.service.BuyOrderDetailService;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//
|
||||
//import java.util.Arrays;
|
||||
//import java.util.Map;
|
||||
//
|
||||
///**
|
||||
// * 商品订单详情表
|
||||
// *
|
||||
// * @author yl
|
||||
// * @email yl328572838@163.com
|
||||
// * @date 2022-08-29 15:27:44
|
||||
// */
|
||||
//@RestController
|
||||
//@RequestMapping("book/buyorderdetail")
|
||||
//public class BuyOrderDetailController {
|
||||
// @Autowired
|
||||
// private BuyOrderDetailService buyOrderDetailService;
|
||||
//
|
||||
// /**
|
||||
// * 列表
|
||||
// */
|
||||
// @RequestMapping("/list")
|
||||
// public R list(@RequestParam Map<String, Object> params) {
|
||||
// PageUtils page = buyOrderDetailService.queryPage(params);
|
||||
// return R.ok().put("page", page);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 查询已购买书籍
|
||||
// *
|
||||
// * @param params
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping("/querybuy")
|
||||
// public R querybuy(@RequestParam Map<String, Object> params) {
|
||||
// PageUtils page = buyOrderDetailService.querybuy(params);
|
||||
// return R.ok().put("page", page);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 去重查询可打印面单
|
||||
// *
|
||||
// * @param params
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping("/querySheetPage")
|
||||
// public R querySheetPage(@RequestParam Map<String, Object> params) {
|
||||
// PageUtils page = buyOrderDetailService.querySheet(params);
|
||||
// return R.ok().put("page", page);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 信息
|
||||
// */
|
||||
// @RequestMapping("/info/{allOrderId}")
|
||||
// public R info(@PathVariable("allOrderId") Long allOrderId) {
|
||||
// BuyOrderDetail buyOrderDetail = buyOrderDetailService.getById(allOrderId);
|
||||
// return R.ok().put("buyOrderDetail", buyOrderDetail);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 保存
|
||||
// */
|
||||
// @RequestMapping("/save")
|
||||
// public R save(@RequestBody BuyOrderDetail buyOrderDetail) {
|
||||
// buyOrderDetailService.save(buyOrderDetail);
|
||||
// return R.ok();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 修改
|
||||
// */
|
||||
// @RequestMapping("/update")
|
||||
// public R update(@RequestBody BuyOrderDetail buyOrderDetail) {
|
||||
// buyOrderDetailService.updateById(buyOrderDetail);
|
||||
// return R.ok();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 删除
|
||||
// */
|
||||
// @RequestMapping("/delete")
|
||||
// public R delete(@RequestBody Long[] allOrderIds) {
|
||||
// buyOrderDetailService.removeByIds(Arrays.asList(allOrderIds));
|
||||
// return R.ok();
|
||||
// }
|
||||
//
|
||||
// @RequestMapping("/updateOrderStatus")
|
||||
// public R updateOrderStatus(@RequestBody BuyOrderDetail buyOrderDetail) {
|
||||
// buyOrderDetail.setOrderStatus("2");
|
||||
// buyOrderDetailService.updateById(buyOrderDetail);
|
||||
// return R.ok();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 根据运单号批量修改打印状态
|
||||
// *
|
||||
// * @param shippingSnList
|
||||
// * @return
|
||||
// */
|
||||
// @RequestMapping("/batchUpdateByShippingSns")
|
||||
// public R batchUpdateByShippingSns(@RequestBody String[] shippingSnList) {
|
||||
// return R.ok();
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -2,23 +2,22 @@ package com.peanut.modules.book.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.BuyOrder;
|
||||
import com.peanut.modules.book.entity.BuyOrderProduct;
|
||||
import com.peanut.modules.book.entity.ExpressCompany;
|
||||
import com.peanut.modules.book.entity.ExpressOrder;
|
||||
import com.peanut.modules.book.service.BuyOrderProductService;
|
||||
import com.peanut.modules.book.service.BuyOrderService;
|
||||
import com.peanut.modules.book.service.ExpressCompanyService;
|
||||
import com.peanut.modules.book.service.ExpressOrderService;
|
||||
import com.peanut.modules.book.vo.ExpressCompanyVo;
|
||||
import com.peanut.modules.book.vo.response.PrintTemplateVo;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 快递 Controller
|
||||
@@ -32,10 +31,6 @@ public class ExpressController {
|
||||
@Autowired
|
||||
private ExpressCompanyService expressCompanyService;
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
@Autowired
|
||||
private BuyOrderProductService buyOrderProductService;
|
||||
@Autowired
|
||||
private ExpressOrderService expressOrderService;
|
||||
|
||||
|
||||
@@ -53,36 +48,44 @@ public class ExpressController {
|
||||
/**
|
||||
* 获取快递面单列表
|
||||
*
|
||||
* @return
|
||||
* @return R
|
||||
*/
|
||||
@RequestMapping(path = "/getPrintTemplateList", method = RequestMethod.GET)
|
||||
public R getPrintTemplate(String orderSn) {
|
||||
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_sn", orderSn);
|
||||
BuyOrder buyOrder = buyOrderService.getOne(queryWrapper);
|
||||
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
|
||||
buyOrderProductQueryWrapper.eq("order_id", buyOrder.getOrderId());
|
||||
List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.list(buyOrderProductQueryWrapper);
|
||||
List<Integer> expressOrderIdList = new ArrayList<>();
|
||||
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||
expressOrderIdList.add(buyOrderProduct.getExpressOrderId());
|
||||
}
|
||||
public R getPrintTemplate(@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
@RequestParam(value = "currentPage", defaultValue = "1") Integer currentPage) {
|
||||
Page<ExpressOrder> expressOrderPage = new Page<>(currentPage, pageSize);
|
||||
QueryWrapper<ExpressOrder> expressOrderQueryWrapper = new QueryWrapper<>();
|
||||
expressOrderQueryWrapper.in("id", expressOrderIdList);
|
||||
expressOrderQueryWrapper.select("print_template");
|
||||
List<ExpressOrder> expressOrderList = expressOrderService.list(expressOrderQueryWrapper);
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
int totalDataSize = expressOrderService.count(expressOrderQueryWrapper);
|
||||
int totalPage = totalDataSize / pageSize + 1;
|
||||
Page<ExpressOrder> page = expressOrderService.page(expressOrderPage, expressOrderQueryWrapper);
|
||||
List<ExpressOrder> expressOrderList = page.getRecords();
|
||||
List<PrintTemplateVo> data = new ArrayList<>();
|
||||
for (ExpressOrder expressOrder : expressOrderList) {
|
||||
result.add(expressOrder.getPrintTemplate());
|
||||
PrintTemplateVo vo = new PrintTemplateVo();
|
||||
QueryWrapper<ExpressCompany> expressCompanyQueryWrapper = new QueryWrapper<>();
|
||||
expressCompanyQueryWrapper.eq("code", expressOrder.getExpressCompanyCode());
|
||||
ExpressCompany expressCompany = expressCompanyService.getOne(expressCompanyQueryWrapper);
|
||||
vo.setExpressCompanyCode(expressCompany.getName());
|
||||
vo.setPrintTemplate(expressOrder.getPrintTemplate());
|
||||
vo.setExpressOrderSn(expressOrder.getExpressOrderSn());
|
||||
vo.setTemplatedPrinted(vo.getTemplatedPrinted());
|
||||
data.add(vo);
|
||||
}
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("data", data);
|
||||
result.put("currentPage", currentPage);
|
||||
result.put("pageSize", pageSize);
|
||||
result.put("totalDataSize", totalDataSize);
|
||||
result.put("totalPage", totalPage);
|
||||
return R.ok().put("result", result);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/printTemplate", method = RequestMethod.GET)
|
||||
public R printTemplate(@RequestParam("expressOrderId") Integer expressOrderId) {
|
||||
@RequestMapping(value = "/printTemplate", method = RequestMethod.POST)
|
||||
public R printTemplate(@RequestBody List<Integer> expressOrderIdList) {
|
||||
UpdateWrapper<ExpressOrder> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.set("template_printed", 1);
|
||||
updateWrapper.eq("id", expressOrderId);
|
||||
updateWrapper.in("id", expressOrderIdList);
|
||||
expressOrderService.update(updateWrapper);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -37,8 +37,6 @@ public class ProvinceController {
|
||||
//获取地址
|
||||
@RequestMapping("/getProvince")
|
||||
public R getProvince() {
|
||||
|
||||
|
||||
//优化查询速度 目录放入redis中
|
||||
String s = redisTemplate.opsForValue().get("Province");
|
||||
List<Map<String, Object>> listData = new ArrayList<>();
|
||||
|
||||
@@ -32,13 +32,15 @@ public class ShopProductController {
|
||||
@Autowired
|
||||
private ShopCategoryService shopCategoryService;
|
||||
@Autowired
|
||||
private BuyOrderDetailService buyOrderDetailService;
|
||||
private BuyOrderProductService buyOrderProductService;
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
@Autowired
|
||||
private ShopProductBookService shopProductBookService;
|
||||
@Autowired
|
||||
private ShopProductToLabelService shopProductToLabelService;
|
||||
@Autowired
|
||||
private BuyOrderDetailService buyOrderDetailService;
|
||||
|
||||
/**
|
||||
* 精选商品 列表
|
||||
@@ -87,7 +89,6 @@ public class ShopProductController {
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 未购买书列表
|
||||
*
|
||||
@@ -95,7 +96,7 @@ public class ShopProductController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/booklist")
|
||||
public R bookList(@RequestParam("userId") Integer userId
|
||||
public R booklist(@RequestParam("userId") Integer userId
|
||||
) {
|
||||
//查询已购买的书籍
|
||||
List<BuyOrderDetail> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetail>()
|
||||
@@ -131,6 +132,47 @@ public class ShopProductController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 未购买书列表
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/bookList")
|
||||
public R bookList(@RequestParam("userId") Integer userId
|
||||
) {
|
||||
//查询已购买的书籍
|
||||
List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.getBaseMapper().selectList(new QueryWrapper<BuyOrderProduct>()
|
||||
.eq("user_id", userId));
|
||||
//hashset不重复 且无序
|
||||
Set<String> purchasedProductIds = new HashSet<>();
|
||||
ArrayList<Object> list = new ArrayList<>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
for (BuyOrderProduct buyOrderDetail : buyOrderProductList) {
|
||||
map.put("ProductId", String.valueOf(buyOrderDetail.getProductId()));
|
||||
list.add(map);
|
||||
//去重取出以后买书籍的id
|
||||
purchasedProductIds.add(String.valueOf(buyOrderDetail.getProductId()));
|
||||
}
|
||||
//查询商品表并过滤已购买商品id,根据时间倒叙展示
|
||||
List<ShopProduct> allProductEntities = shopProductService.getBaseMapper().selectList(new QueryWrapper<ShopProduct>()
|
||||
.notIn("product_id", purchasedProductIds)
|
||||
.orderByDesc("create_time")
|
||||
// .notLike("book_ids",",")
|
||||
.isNotNull("book_ids")
|
||||
|
||||
);
|
||||
List lists = new ArrayList<>();
|
||||
|
||||
for (ShopProduct product : allProductEntities) {
|
||||
Map<String, Object> productMap = new HashMap<>();
|
||||
productMap.put("product", product);
|
||||
lists.add(productMap);
|
||||
}
|
||||
return R.ok().put("pages", lists); // 返回未购买的书籍分页
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/bookinfo/{productId}")
|
||||
public R bookInfo(@PathVariable("productId") Integer productId) {
|
||||
ArrayList<Map<String, String>> imagesUrl = new ArrayList<Map<String, String>>();
|
||||
|
||||
@@ -1,91 +1,91 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.ShopSeckillEntity;
|
||||
import com.peanut.modules.book.service.ShopSeckillService;
|
||||
import com.peanut.modules.book.to.SeckillRedisTo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 秒杀库存表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-28 11:24:05
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/shopseckill")
|
||||
public class ShopSeckillController {
|
||||
@Autowired
|
||||
private ShopSeckillService shopSeckillService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = shopSeckillService.queryPage(params);
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{seckillId}")
|
||||
public R info(@PathVariable("seckillId") Long seckillId) {
|
||||
ShopSeckillEntity shopSeckill = shopSeckillService.getById(seckillId);
|
||||
return R.ok().put("shopSeckill", shopSeckill);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody ShopSeckillEntity shopSeckill) {
|
||||
shopSeckillService.save(shopSeckill);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody ShopSeckillEntity shopSeckill) {
|
||||
shopSeckillService.updateById(shopSeckill);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Long[] seckillIds) {
|
||||
shopSeckillService.removeByIds(Arrays.asList(seckillIds));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/getSeckillProd")
|
||||
public R getSeckillProd() {
|
||||
List<SeckillRedisTo> list = shopSeckillService.getCurrentSeckillProd();
|
||||
return R.ok().put("list", list);
|
||||
}
|
||||
|
||||
@GetMapping("/kill")
|
||||
public R kill(@RequestParam("killId") String killId,
|
||||
@RequestParam("key") String key,
|
||||
@RequestParam("num") Integer num,
|
||||
@RequestParam("userId") Integer userId) {
|
||||
String orderId = shopSeckillService.kill(killId, key, num, userId);
|
||||
return R.ok().put("orderId", orderId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//package com.peanut.modules.book.controller;
|
||||
//
|
||||
//import com.peanut.common.utils.PageUtils;
|
||||
//import com.peanut.common.utils.R;
|
||||
//import com.peanut.modules.book.entity.ShopSeckillEntity;
|
||||
//import com.peanut.modules.book.service.ShopSeckillService;
|
||||
//import com.peanut.modules.book.to.SeckillRedisTo;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//
|
||||
//import java.util.Arrays;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * 秒杀库存表
|
||||
// *
|
||||
// * @author yl
|
||||
// * @email yl328572838@163.com
|
||||
// * @date 2022-10-28 11:24:05
|
||||
// */
|
||||
//@RestController
|
||||
//@RequestMapping("book/shopseckill")
|
||||
//public class ShopSeckillController {
|
||||
// @Autowired
|
||||
// private ShopSeckillService shopSeckillService;
|
||||
//
|
||||
// /**
|
||||
// * 列表
|
||||
// */
|
||||
// @RequestMapping("/list")
|
||||
// public R list(@RequestParam Map<String, Object> params) {
|
||||
// PageUtils page = shopSeckillService.queryPage(params);
|
||||
// return R.ok().put("page", page);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 信息
|
||||
// */
|
||||
// @RequestMapping("/info/{seckillId}")
|
||||
// public R info(@PathVariable("seckillId") Long seckillId) {
|
||||
// ShopSeckillEntity shopSeckill = shopSeckillService.getById(seckillId);
|
||||
// return R.ok().put("shopSeckill", shopSeckill);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 保存
|
||||
// */
|
||||
// @RequestMapping("/save")
|
||||
// public R save(@RequestBody ShopSeckillEntity shopSeckill) {
|
||||
// shopSeckillService.save(shopSeckill);
|
||||
// return R.ok();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 修改
|
||||
// */
|
||||
// @RequestMapping("/update")
|
||||
// public R update(@RequestBody ShopSeckillEntity shopSeckill) {
|
||||
// shopSeckillService.updateById(shopSeckill);
|
||||
// return R.ok();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 删除
|
||||
// */
|
||||
// @RequestMapping("/delete")
|
||||
// public R delete(@RequestBody Long[] seckillIds) {
|
||||
// shopSeckillService.removeByIds(Arrays.asList(seckillIds));
|
||||
// return R.ok();
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/getSeckillProd")
|
||||
// public R getSeckillProd() {
|
||||
// List<SeckillRedisTo> list = shopSeckillService.getCurrentSeckillProd();
|
||||
// return R.ok().put("list", list);
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/kill")
|
||||
// public R kill(@RequestParam("killId") String killId,
|
||||
// @RequestParam("key") String key,
|
||||
// @RequestParam("num") Integer num,
|
||||
// @RequestParam("userId") Integer userId) {
|
||||
// String orderId = shopSeckillService.kill(killId, key, num, userId);
|
||||
// return R.ok().put("orderId", orderId);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.MyUserEntity;
|
||||
import com.peanut.modules.book.entity.UserFeedbackEntity;
|
||||
import com.peanut.modules.book.entity.UserRecordEntity;
|
||||
import com.peanut.modules.book.service.MyUserService;
|
||||
import com.peanut.modules.book.service.UserFeedbackSerivce;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -3,15 +3,19 @@ package com.peanut.modules.book.controller;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.entity.BuyOrder;
|
||||
import com.peanut.modules.book.entity.MyUserEntity;
|
||||
import com.peanut.modules.book.entity.UserFollowUpEntity;
|
||||
import com.peanut.modules.book.entity.UserRecord;
|
||||
import com.peanut.modules.book.service.BuyOrderService;
|
||||
import com.peanut.modules.book.service.MyUserService;
|
||||
import com.peanut.modules.book.service.UserFollowUpService;
|
||||
import com.peanut.modules.book.service.UserRecordService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.peanut.common.utils.R.error;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/user/followUp")
|
||||
public class UserFollowUpController {
|
||||
@@ -25,41 +29,34 @@ public class UserFollowUpController {
|
||||
private MyUserService myUserService;
|
||||
@Autowired
|
||||
private BuyOrderService buyOrderService;
|
||||
@Autowired
|
||||
private BuyOrderDetailService buyOrderDetailService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public R list(@RequestParam Map<String, Object> params ){
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
PageUtils page = userFollowUpService.queryPage(params);
|
||||
return R.ok().put("page", page);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 我的评价
|
||||
* 我的评价
|
||||
*/
|
||||
@RequestMapping("/Allevaluations")
|
||||
public R Allevaluations(@RequestBody UserFollowUpEntity userFollowUpEntity){
|
||||
public R Allevaluations(@RequestBody UserFollowUpEntity userFollowUpEntity) {
|
||||
List<UserFollowUpEntity> userid = userFollowUpService.getBaseMapper().selectList(new QueryWrapper<UserFollowUpEntity>().eq("userid", userFollowUpEntity.getUserId()));
|
||||
return R.ok().put("Allevaluations",userid);
|
||||
return R.ok().put("Allevaluations", userid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 全部评价
|
||||
* 全部评价
|
||||
*/
|
||||
@RequestMapping("/Alllevas")
|
||||
public R Alllevas(@RequestBody UserFollowUpEntity users){
|
||||
public R Alllevas(@RequestBody UserFollowUpEntity users) {
|
||||
HashMap<Object, Object> maps = new HashMap<>();
|
||||
List list = new ArrayList<>();
|
||||
List<UserFollowUpEntity> bookid = userFollowUpService.getBaseMapper().selectList(new QueryWrapper<UserFollowUpEntity>().eq("bookid", users.getBookid()));
|
||||
@@ -68,67 +65,62 @@ public class UserFollowUpController {
|
||||
Integer bookid1 = userRecord.getBookid();
|
||||
Integer userid1 = userRecord.getUserId();
|
||||
List<MyUserEntity> id = myUserService.getBaseMapper().selectList(new QueryWrapper<MyUserEntity>().eq("id", userid1));
|
||||
String usser="";
|
||||
String usser = "";
|
||||
String name = "";
|
||||
for (MyUserEntity user : id) {
|
||||
usser = user.getAvatar();
|
||||
name =user.getNickname();
|
||||
usser = user.getAvatar();
|
||||
name = user.getNickname();
|
||||
|
||||
}
|
||||
map.put("Avatar",usser);
|
||||
map.put("name",name);
|
||||
map.put("Avatar", usser);
|
||||
map.put("name", name);
|
||||
map.put("userId", users.getUserId());
|
||||
map.put("bookid",bookid1);
|
||||
map.put("userid",userid1);
|
||||
map.put("content",users.getConTent());
|
||||
map.put("create_date",users.getCreateDate());
|
||||
map.put("oid",users.getOid());
|
||||
map.put("praIse",users.getPraIse());
|
||||
map.put("bookid", bookid1);
|
||||
map.put("userid", userid1);
|
||||
map.put("content", users.getConTent());
|
||||
map.put("create_date", users.getCreateDate());
|
||||
map.put("oid", users.getOid());
|
||||
map.put("praIse", users.getPraIse());
|
||||
|
||||
list.add(map);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
maps.put("list",list);
|
||||
maps.put("list", list);
|
||||
|
||||
return R.ok().put("list",list);
|
||||
return R.ok().put("list", list);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 追加评论(用户只可评论一次)
|
||||
*
|
||||
* */
|
||||
@RequestMapping("/userFollowUp")
|
||||
public Object UserFollowUp(@RequestBody UserFollowUpEntity userFollowUpEntity ) {
|
||||
public Object UserFollowUp(@RequestBody UserFollowUpEntity userFollowUpEntity) {
|
||||
|
||||
|
||||
//根据传过来的userid和oid查询出来userRecordEntity中关联数据
|
||||
UserRecordEntity userRecord = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecordEntity>()
|
||||
UserRecord userRecord = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecord>()
|
||||
.eq("userid", userFollowUpEntity.getUserId()).last("LIMIT 1")
|
||||
.eq("bookid", userFollowUpEntity.getBookid())
|
||||
.eq("id",userFollowUpEntity.getOid())
|
||||
.eq("id", userFollowUpEntity.getOid())
|
||||
);
|
||||
if (userRecord==null){
|
||||
return R.error("请先评论再追评");
|
||||
}
|
||||
if (userRecord == null) {
|
||||
return R.error("请先评论再追评");
|
||||
}
|
||||
String orderSn = userRecord.getOrderSn();
|
||||
BuyOrder buyOrder =buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>()
|
||||
.eq("order_sn",orderSn).last("LIMIT 1")
|
||||
BuyOrder buyOrder = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>()
|
||||
.eq("order_sn", orderSn).last("LIMIT 1")
|
||||
);
|
||||
|
||||
Integer orderId = buyOrder.getOrderId();
|
||||
Integer bookid = userRecord.getBookid();
|
||||
Integer userid = userRecord.getUserid();
|
||||
Integer id1 = userRecord.getId();
|
||||
BuyOrderDetail detailEntity = buyOrderDetailService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderDetail>()
|
||||
.eq("Order_id", orderId).eq("product_id",bookid));
|
||||
|
||||
UserFollowUpEntity followUpEntity = userFollowUpService.getBaseMapper().selectOne(new QueryWrapper<UserFollowUpEntity>().eq("userid", userid).eq("oid",id1).last("LIMIT 1"));
|
||||
UserFollowUpEntity followUpEntity = userFollowUpService.getBaseMapper().selectOne(new QueryWrapper<UserFollowUpEntity>().eq("userid", userid).eq("oid", id1).last("LIMIT 1"));
|
||||
|
||||
// if (followUpEntity != null) {
|
||||
// return R.error("您已评价过");
|
||||
@@ -136,11 +128,11 @@ public class UserFollowUpController {
|
||||
|
||||
buyOrder.setRecordId(2);
|
||||
buyOrderService.saveOrUpdate(buyOrder);
|
||||
if (userFollowUpEntity.getImages()!=null) {
|
||||
if (userFollowUpEntity.getImages() != null) {
|
||||
|
||||
List<Map<String,String>> imageList = (ArrayList<Map<String,String>>)userFollowUpEntity.getImages();
|
||||
List<Map<String, String>> imageList = (ArrayList<Map<String, String>>) userFollowUpEntity.getImages();
|
||||
String imageStr = "";
|
||||
for(Map m : imageList){
|
||||
for (Map m : imageList) {
|
||||
imageStr += m.get("url") + ",";
|
||||
}
|
||||
|
||||
@@ -148,33 +140,30 @@ public class UserFollowUpController {
|
||||
|
||||
}
|
||||
|
||||
userFollowUpEntity.setOid(id1);
|
||||
userFollowUpEntity.setDelflag(0);
|
||||
userFollowUpEntity.setCreateDate(new Date());
|
||||
userFollowUpService.saveOrUpdate(userFollowUpEntity);
|
||||
return R.ok("成功").put("userFollowUpEntity",userFollowUpEntity);
|
||||
}
|
||||
|
||||
|
||||
userFollowUpEntity.setOid(id1);
|
||||
userFollowUpEntity.setDelflag(0);
|
||||
userFollowUpEntity.setCreateDate(new Date());
|
||||
userFollowUpService.saveOrUpdate(userFollowUpEntity);
|
||||
return R.ok("成功").put("userFollowUpEntity", userFollowUpEntity);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
public R info(@PathVariable("id") Integer id){
|
||||
public R info(@PathVariable("id") Integer id) {
|
||||
UserFollowUpEntity user = userFollowUpService.getById(id);
|
||||
|
||||
return R.ok().put("UserFollowUpEntity", user);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody UserRecordEntity user){
|
||||
public R update(@RequestBody UserRecord user) {
|
||||
userRecordService.updateById(user);
|
||||
|
||||
return R.ok();
|
||||
@@ -184,7 +173,7 @@ public class UserFollowUpController {
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
public R delete(@RequestBody Integer[] ids){
|
||||
public R delete(@RequestBody Integer[] ids) {
|
||||
userRecordService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
|
||||
@@ -192,4 +181,4 @@ public class UserFollowUpController {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,11 @@ public class UserRecordController {
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
@Autowired
|
||||
private BuyOrderDetailService buyOrderDetailService;
|
||||
private BuyOrderProductService buyOrderProductService;
|
||||
@Autowired
|
||||
private UserFollowUpService userFollowUpService;
|
||||
@Autowired
|
||||
private BuyOrderDetailService buyOrderDetailService;
|
||||
|
||||
|
||||
/**
|
||||
@@ -43,8 +45,8 @@ public class UserRecordController {
|
||||
* 查看我的评价
|
||||
*/
|
||||
@RequestMapping("/Allevaluations")
|
||||
public R Allevaluations(@RequestBody UserRecordEntity userRecordEntity) {
|
||||
List<UserRecordEntity> userid = userRecordService.getBaseMapper().selectList(new QueryWrapper<UserRecordEntity>().eq("userid", userRecordEntity.getUserid()).orderByDesc("create_date"));
|
||||
public R Allevaluations(@RequestBody UserRecord userRecord) {
|
||||
List<UserRecord> userid = userRecordService.getBaseMapper().selectList(new QueryWrapper<UserRecord>().eq("userid", userRecord.getUserid()).orderByDesc("create_date"));
|
||||
return R.ok().put("Allevaluations", userid);
|
||||
}
|
||||
|
||||
@@ -52,16 +54,16 @@ public class UserRecordController {
|
||||
* 查看全部评价
|
||||
*/
|
||||
@RequestMapping("/All")
|
||||
public R All(@RequestBody UserRecordEntity userRecordEntity) {
|
||||
public R All(@RequestBody UserRecord userRecordEntity) {
|
||||
|
||||
|
||||
List list = new ArrayList<>();
|
||||
//此处bookid实际传的是商品id
|
||||
List<UserRecordEntity> bookid = userRecordService.getBaseMapper().selectList(new QueryWrapper<UserRecordEntity>().eq("bookid", userRecordEntity.getBookid()).orderByDesc("create_date"));
|
||||
List<UserRecord> bookid = userRecordService.getBaseMapper().selectList(new QueryWrapper<UserRecord>().eq("bookid", userRecordEntity.getBookid()).orderByDesc("create_date"));
|
||||
|
||||
|
||||
if (bookid != null) {
|
||||
for (UserRecordEntity userRecord : bookid) {
|
||||
for (UserRecord userRecord : bookid) {
|
||||
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
Integer bookid1 = userRecord.getBookid();
|
||||
@@ -114,16 +116,16 @@ public class UserRecordController {
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
public R info(@PathVariable("id") Integer id) {
|
||||
UserRecordEntity userRecordEntity = userRecordService.getById(id);
|
||||
return R.ok().put("bookChapterContent", userRecordEntity);
|
||||
UserRecord userRecord = userRecordService.getById(id);
|
||||
return R.ok().put("bookChapterContent", userRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody UserRecordEntity userRecordEntity) {
|
||||
userRecordService.save(userRecordEntity);
|
||||
public R save(@RequestBody UserRecord userRecord) {
|
||||
userRecordService.save(userRecord);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -131,8 +133,8 @@ public class UserRecordController {
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody UserRecordEntity userRecordEntity) {
|
||||
userRecordService.updateById(userRecordEntity);
|
||||
public R update(@RequestBody UserRecord userRecord) {
|
||||
userRecordService.updateById(userRecord);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -169,23 +171,23 @@ public class UserRecordController {
|
||||
//状态3为已收货
|
||||
// .eq("order_status","3")
|
||||
);
|
||||
UserRecordEntity userRecordEntity = new UserRecordEntity();
|
||||
UserRecord userRecord = new UserRecord();
|
||||
|
||||
|
||||
if (!ToolObject.isNullOrEmpty(buyOrder)) {
|
||||
return error("您已评价过了,请勿重复评论");
|
||||
//
|
||||
} else {
|
||||
userRecordEntity.setId(buyOrder.getOrderId());
|
||||
userRecordEntity.setContent(comment);
|
||||
userRecord.setId(buyOrder.getOrderId());
|
||||
userRecord.setContent(comment);
|
||||
//商品评价
|
||||
userRecordEntity.setBookid(bookid);
|
||||
userRecordEntity.setUserid(userid);
|
||||
userRecordEntity.setOrderSn(orderSn);
|
||||
userRecordEntity.setDelflag(0);
|
||||
userRecordEntity.setProductId(bookid);
|
||||
userRecordService.saveOrUpdate(userRecordEntity);
|
||||
return R.ok("成功").put("userRecordEntity", userRecordEntity);
|
||||
userRecord.setBookid(bookid);
|
||||
userRecord.setUserid(userid);
|
||||
userRecord.setOrderSn(orderSn);
|
||||
userRecord.setDelflag(0);
|
||||
userRecord.setProductId(bookid);
|
||||
userRecordService.saveOrUpdate(userRecord);
|
||||
return R.ok("成功").put("userRecordEntity", userRecord);
|
||||
}
|
||||
|
||||
|
||||
@@ -196,8 +198,44 @@ public class UserRecordController {
|
||||
* @param recordEntity
|
||||
* @return 生成评论(上传图片,星级评价
|
||||
*/
|
||||
@RequestMapping("/UserRecordComment")
|
||||
public R comment(@RequestBody UserRecord recordEntity) {
|
||||
QueryWrapper<BuyOrder> buyOrderQueryWrapper = new QueryWrapper<>();
|
||||
buyOrderQueryWrapper.eq("order_sn", recordEntity.getOrderSn());
|
||||
BuyOrder buyOrder = buyOrderService.getOne(buyOrderQueryWrapper);
|
||||
Integer orderId = buyOrder.getOrderId();
|
||||
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
|
||||
buyOrderProductQueryWrapper.eq("order_id", orderId);
|
||||
buyOrderProductQueryWrapper.eq("product_id", recordEntity.getProductId());
|
||||
BuyOrderProduct buyOrderProduct = buyOrderProductService.getOne(buyOrderProductQueryWrapper);
|
||||
Integer orderId1 = buyOrderProduct.getOrderId();
|
||||
UserRecord userRecord = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecord>().eq("orderSn", recordEntity.getOrderSn()).eq("userid", recordEntity.getUserid()).eq("orderdid", orderId1).last("LIMIT 1"));
|
||||
|
||||
if (userRecord != null) {
|
||||
return R.error("您已评价过");
|
||||
}
|
||||
if (recordEntity.getImages() != null) {
|
||||
List<Map<String, String>> imageList = (ArrayList<Map<String, String>>) recordEntity.getImages();
|
||||
String imageStr = "";
|
||||
for (Map m : imageList) {
|
||||
imageStr += m.get("url") + ",";
|
||||
|
||||
}
|
||||
recordEntity.setImages(imageStr);
|
||||
}
|
||||
recordEntity.setDelflag(0);
|
||||
recordEntity.setOrderdId(orderId1);
|
||||
userRecordService.saveOrUpdate(recordEntity);
|
||||
buyOrderProduct.setRecordId(1);
|
||||
buyOrderProductService.saveOrUpdate(buyOrderProduct);
|
||||
return R.ok("成功").put("userRecordEntity", recordEntity);
|
||||
}
|
||||
|
||||
/*
|
||||
TODO 老版本接口,新版本上线后要删除
|
||||
*/
|
||||
@RequestMapping("/UserRecordcomment")
|
||||
public R commodity(@RequestBody UserRecordEntity recordEntity) {
|
||||
public R commodity(@RequestBody UserRecord recordEntity) {
|
||||
//todo 已收货限制字段,只可评价一次
|
||||
BuyOrder buyOrder = buyOrderService.getBaseMapper().selectOne(new QueryWrapper<BuyOrder>()
|
||||
.eq("order_sn", recordEntity.getOrderSn())
|
||||
@@ -206,7 +244,7 @@ public class UserRecordController {
|
||||
Integer orderId = buyOrder.getOrderId();
|
||||
BuyOrderDetail detailEntity = buyOrderDetailService.getBaseMapper().selectOne(new QueryWrapper<BuyOrderDetail>().eq("Order_id", orderId).eq("product_id", recordEntity.getBookid()));
|
||||
Integer orderId1 = detailEntity.getOrderId();
|
||||
UserRecordEntity userRecordEntity = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecordEntity>().eq("orderSn", recordEntity.getOrderSn()).eq("userid", recordEntity.getUserid()).eq("orderdid", orderId1).last("LIMIT 1"));
|
||||
UserRecord userRecordEntity = userRecordService.getBaseMapper().selectOne(new QueryWrapper<UserRecord>().eq("orderSn", recordEntity.getOrderSn()).eq("userid", recordEntity.getUserid()).eq("orderdid", orderId1).last("LIMIT 1"));
|
||||
|
||||
if (userRecordEntity != null) {
|
||||
return R.error("您已评价过");
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品订单详情表
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-08-29 15:27:44
|
||||
@@ -17,5 +17,5 @@ import java.util.List;
|
||||
public interface BuyOrderDetailDao extends BaseMapper<BuyOrderDetail> {
|
||||
|
||||
public List<BuyOrderDetail> queryListByOrderIds(Integer[] ids);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.peanut.modules.book.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.peanut.modules.book.entity.UserFollowUpEntity;
|
||||
import com.peanut.modules.book.entity.UserRecordEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.peanut.modules.book.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.peanut.modules.book.entity.UserEbookBuyEntity;
|
||||
import com.peanut.modules.book.entity.UserRecordEntity;
|
||||
import com.peanut.modules.book.entity.UserRecord;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
//书籍评价表
|
||||
@Mapper
|
||||
public interface UserRecordDao extends BaseMapper<UserRecordEntity> {
|
||||
public interface UserRecordDao extends BaseMapper<UserRecord> {
|
||||
|
||||
}
|
||||
|
||||
@@ -125,9 +125,13 @@ public class BuyOrder implements Serializable {
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
// TODO 新版本上线后删除该属性
|
||||
@TableField(exist = false)
|
||||
private List<BuyOrderDetail> products;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<BuyOrderProduct> productList;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String buyType;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.peanut.modules.book.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -37,8 +38,19 @@ public class BuyOrderProduct {
|
||||
* 快递订单 ID
|
||||
*/
|
||||
private int expressOrderId;
|
||||
/**
|
||||
* 评价 ID
|
||||
*/
|
||||
private int recordId;
|
||||
/**
|
||||
* 删除标识
|
||||
*/
|
||||
private int delFlag;
|
||||
/**
|
||||
* 发货标识
|
||||
*/
|
||||
private int shipped;
|
||||
|
||||
@TableField(exist = false)
|
||||
private ShopProduct product;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.peanut.modules.book.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -19,7 +21,13 @@ public class ExpressOrder {
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableField(value = "id")
|
||||
@TableId(type = IdType.AUTO)
|
||||
private int id;
|
||||
/**
|
||||
* 订单Sn
|
||||
*/
|
||||
// private String orderSn;
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("user_record")
|
||||
public class UserRecordEntity {
|
||||
public class UserRecord {
|
||||
|
||||
|
||||
@TableId
|
||||
@@ -6,6 +6,7 @@ import com.peanut.modules.book.entity.BuyOrderDetail;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 商品订单详情表
|
||||
*
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.book.entity.BuyOrder;
|
||||
import com.peanut.modules.book.to.UserOrderDto;
|
||||
import com.peanut.modules.book.vo.UserOrderVo;
|
||||
import com.peanut.modules.book.vo.request.BuyOrderListRequestVo;
|
||||
import com.peanut.modules.book.vo.response.BuyOrderResponseVo;
|
||||
@@ -40,7 +41,7 @@ public interface BuyOrderService extends IService<BuyOrder> {
|
||||
* @param requestVo
|
||||
* @return
|
||||
*/
|
||||
PageUtils orderList(BuyOrderListRequestVo requestVo);
|
||||
Map<String, Object> orderList(BuyOrderListRequestVo requestVo);
|
||||
|
||||
/**
|
||||
* 订单拆分发货
|
||||
@@ -50,9 +51,11 @@ public interface BuyOrderService extends IService<BuyOrder> {
|
||||
*/
|
||||
void delivery(String expressCompanyCode, List<Integer> buyOrderDetailId);
|
||||
|
||||
Page<BuyOrder> getUserOrderList(UserOrderDto userOrderDto);
|
||||
|
||||
BuyOrderResponseVo orderDetail(String orderSn);
|
||||
|
||||
Map<Integer, List<String>> decomposeShipment(Integer userId);
|
||||
Map<String, Object> decomposeShipment(BuyOrderListRequestVo requestVo);
|
||||
|
||||
|
||||
}
|
||||
@@ -16,5 +16,5 @@ public interface ExpressOrderService extends IService<ExpressOrder> {
|
||||
*/
|
||||
ExpressOrderResponseVo placeExpressOrder(ExpressOrder expressOrder);
|
||||
|
||||
ExpressQueryResponse queryExpressOrder(String ShipperCode, String LogisticCode);
|
||||
ExpressQueryResponse queryExpressOrder(String ShipperCode, String LogisticCode, String customerName);
|
||||
}
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
package com.peanut.modules.book.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.book.entity.ShopSeckillEntity;
|
||||
import com.peanut.modules.book.to.SeckillRedisTo;
|
||||
import com.peanut.modules.book.vo.SeckillProdVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 秒杀库存表
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-28 11:24:05
|
||||
*/
|
||||
public interface ShopSeckillService extends IService<ShopSeckillEntity> {
|
||||
|
||||
PageUtils queryPage(Map<String, Object> params);
|
||||
|
||||
List<ShopSeckillEntity> getSeckilProd3Days();
|
||||
|
||||
void uploadSeckilProd3Days();
|
||||
|
||||
List<SeckillRedisTo> getCurrentSeckillProd();
|
||||
|
||||
String kill(String killId,String key,Integer num,Integer userId);
|
||||
}
|
||||
|
||||
//package com.peanut.modules.book.service;
|
||||
//
|
||||
//import com.baomidou.mybatisplus.extension.service.IService;
|
||||
//import com.peanut.common.utils.PageUtils;
|
||||
//import com.peanut.modules.book.entity.ShopSeckillEntity;
|
||||
//import com.peanut.modules.book.to.SeckillRedisTo;
|
||||
//import com.peanut.modules.book.vo.SeckillProdVo;
|
||||
//
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//
|
||||
///**
|
||||
// * 秒杀库存表
|
||||
// *
|
||||
// * @author yl
|
||||
// * @email yl328572838@163.com
|
||||
// * @date 2022-10-28 11:24:05
|
||||
// */
|
||||
//public interface ShopSeckillService extends IService<ShopSeckillEntity> {
|
||||
//
|
||||
// PageUtils queryPage(Map<String, Object> params);
|
||||
//
|
||||
// List<ShopSeckillEntity> getSeckilProd3Days();
|
||||
//
|
||||
// void uploadSeckilProd3Days();
|
||||
//
|
||||
// List<SeckillRedisTo> getCurrentSeckillProd();
|
||||
//
|
||||
// String kill(String killId,String key,Integer num,Integer userId);
|
||||
//}
|
||||
//
|
||||
|
||||
@@ -2,12 +2,12 @@ package com.peanut.modules.book.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.modules.book.entity.UserRecordEntity;
|
||||
import com.peanut.modules.book.entity.UserRecord;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface UserRecordService extends IService<UserRecordEntity> {
|
||||
public interface UserRecordService extends IService<UserRecord> {
|
||||
|
||||
|
||||
//todo 传参参数 用户id 购买订单id 星级评价 内容
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
@@ -12,8 +13,10 @@ import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.config.Constants;
|
||||
import com.peanut.modules.book.dao.BuyOrderDao;
|
||||
import com.peanut.modules.book.dao.ExpressOrderDao;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.to.UserOrderDto;
|
||||
import com.peanut.modules.book.vo.ExpressOrderResponseVo;
|
||||
import com.peanut.modules.book.vo.UserOrderVo;
|
||||
import com.peanut.modules.book.vo.request.BuyOrderListRequestVo;
|
||||
@@ -26,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.security.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -54,9 +58,17 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
@Autowired
|
||||
private BuyOrderProductService buyOrderProductService;
|
||||
|
||||
@Autowired
|
||||
private ProvinceService provinceService;
|
||||
|
||||
@Autowired
|
||||
private CityService cityService;
|
||||
@Autowired
|
||||
private ExpressOrderDao expressOrderDao;
|
||||
|
||||
protected Logger logger = LoggerFactory.getLogger(BuyOrderServiceImpl.class);
|
||||
|
||||
// TODO 新版本上线后删除
|
||||
@Override
|
||||
public PageUtils list(Map<String, Object> params) throws Exception {
|
||||
|
||||
@@ -105,6 +117,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
}
|
||||
|
||||
|
||||
// TODO 新版本上线后删除
|
||||
@Override
|
||||
public PageUtils getMyOrderList(Map<String, Object> params) {
|
||||
|
||||
@@ -226,23 +239,35 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
return userOrderVoList;
|
||||
}
|
||||
|
||||
public Map<Integer, List<String>> decomposeShipment(Integer userId) {
|
||||
@Override
|
||||
public Map<String, Object> decomposeShipment(BuyOrderListRequestVo requestVo) {
|
||||
Page<BuyOrder> buyOrderPage = new Page<>();
|
||||
List<BuyOrderResponseVo> data = new ArrayList<>();
|
||||
BuyOrder requestBuyOrder = getById(requestVo.getOrderId());
|
||||
Integer addressId = requestBuyOrder.getAddressId();
|
||||
Integer userId = requestBuyOrder.getUserId();
|
||||
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("del_flag", 0);
|
||||
queryWrapper.eq("userId", userId);
|
||||
queryWrapper.eq("order_status", Constants.ORDER_STATUS_TO_BE_SHIPPED);
|
||||
queryWrapper.eq("user_id", userId);
|
||||
queryWrapper.eq("address_id", addressId);
|
||||
queryWrapper.eq("address_modified", 0);
|
||||
List<BuyOrder> buyOrderList = list(queryWrapper);
|
||||
Map<Integer, List<String>> result = new HashMap<>();
|
||||
Integer totalSize = count(queryWrapper);
|
||||
Integer totalPage = totalSize / requestVo.getPageSize() + 1;
|
||||
Page<BuyOrder> page = page(buyOrderPage, queryWrapper);
|
||||
List<BuyOrder> buyOrderList = page.getRecords();
|
||||
for (BuyOrder buyOrder : buyOrderList) {
|
||||
if (result.containsKey(buyOrder.getAddressId())) {
|
||||
List<String> orderSnList = result.get(buyOrder.getAddressId());
|
||||
orderSnList.add(buyOrder.getOrderSn());
|
||||
} else {
|
||||
List<String> orderSnList = new ArrayList<>();
|
||||
result.put(buyOrder.getAddressId(), orderSnList);
|
||||
}
|
||||
BuyOrderResponseVo responseVo = setBuyOrderInfo(buyOrder);
|
||||
data.add(responseVo);
|
||||
}
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("totalDataSize", totalSize);
|
||||
result.put("totalPage", totalPage);
|
||||
result.put("data", data);
|
||||
result.put("currentPage", requestVo.getPageIndex());
|
||||
result.put("pageSize", requestVo.getPageSize());
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -304,43 +329,84 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageUtils orderList(BuyOrderListRequestVo requestVo) {
|
||||
List<BuyOrderResponseVo> result = new ArrayList<>();
|
||||
public Map<String, Object> orderList(BuyOrderListRequestVo requestVo) {
|
||||
Page<BuyOrder> buyOrderPage = new Page<>(requestVo.getPageIndex(), requestVo.getPageSize());
|
||||
List<BuyOrderResponseVo> data = new ArrayList<>();
|
||||
QueryWrapper<BuyOrder> buyOrderQueryWrapper = new QueryWrapper<>();
|
||||
buyOrderQueryWrapper.like(StringUtils.isNotBlank(requestVo.getSearchKeyWord()), "order_sn", requestVo.getSearchKeyWord());
|
||||
buyOrderQueryWrapper.like(StringUtils.isNotBlank(requestVo.getSearchKeyWord()), "order_sn", requestVo.getSearchKeyWord())
|
||||
.or().like(StringUtils.isNotBlank(requestVo.getSearchKeyWord()), "shipping_user", requestVo.getSearchKeyWord())
|
||||
.or().like(StringUtils.isNotBlank(requestVo.getSearchKeyWord()), "user_phone", requestVo.getSearchKeyWord());
|
||||
buyOrderQueryWrapper.eq(StringUtils.isNotBlank(requestVo.getOrderStatus()), "order_status", requestVo.getOrderStatus());
|
||||
buyOrderQueryWrapper.gt(requestVo.getStartTime() != null, "create_time", requestVo.getStartTime());
|
||||
buyOrderQueryWrapper.lt(requestVo.getEndTime() != null, "create_time", requestVo.getStartTime());
|
||||
List<BuyOrder> buyOrderList = list(buyOrderQueryWrapper);
|
||||
buyOrderQueryWrapper.eq("order_type","order");
|
||||
buyOrderQueryWrapper.orderByDesc("create_time");
|
||||
|
||||
Integer totalSize = list(buyOrderQueryWrapper).size();
|
||||
Integer totalPage = totalSize / requestVo.getPageSize() + 1;
|
||||
Page<BuyOrder> page = page(buyOrderPage, buyOrderQueryWrapper);
|
||||
List<BuyOrder> buyOrderList = page.getRecords();
|
||||
for (BuyOrder buyOrder : buyOrderList) {
|
||||
BuyOrderResponseVo responseVo = setBuyOrderInfo(buyOrder);
|
||||
result.add(responseVo);
|
||||
data.add(responseVo);
|
||||
}
|
||||
return new PageUtils(result, buyOrderList.size(), requestVo.getPageSize(), requestVo.getPageIndex());
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("totalDataSize", totalSize);
|
||||
result.put("totalPage", totalPage);
|
||||
result.put("data", data);
|
||||
result.put("currentPage", requestVo.getPageIndex());
|
||||
result.put("pageSize", requestVo.getPageSize());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<BuyOrder> getUserOrderList(UserOrderDto userOrderDto) {
|
||||
LambdaQueryWrapper<BuyOrder> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BuyOrder::getUserId,userOrderDto.getUserId());
|
||||
wrapper.eq(userOrderDto.getOrderStatus()!=null,BuyOrder::getOrderStatus,userOrderDto.getOrderStatus());
|
||||
wrapper.orderByDesc(BuyOrder::getCreateTime);
|
||||
Page<BuyOrder> buyOrderPage = this.getBaseMapper().selectPage(new Page<>(userOrderDto.getPage(), userOrderDto.getLimit()), wrapper);
|
||||
for(BuyOrder b : buyOrderPage.getRecords()){
|
||||
b.setUser(myUserService.getById(b.getUserId()));
|
||||
//组装商品
|
||||
List<BuyOrderProduct> buyOrderProducts = buyOrderProductService.getBaseMapper().selectList(new LambdaQueryWrapper<BuyOrderProduct>()
|
||||
.eq(BuyOrderProduct::getOrderId, b.getOrderId()));
|
||||
for (BuyOrderProduct bb : buyOrderProducts){
|
||||
bb.setProduct(shopProductService.getById(bb.getProductId()));
|
||||
}
|
||||
b.setProductList(buyOrderProducts);
|
||||
b.setTimestamp(b.getCreateTime().getTime()/1000);
|
||||
}
|
||||
|
||||
return buyOrderPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delivery(String expressCompanyCode, List<Integer> buyOrderDetailId) {
|
||||
QueryWrapper<BuyOrderDetail> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("id", buyOrderDetailId);
|
||||
List<BuyOrderDetail> buyOrderDetailList = buyOrderDetailService.list(queryWrapper);
|
||||
public void delivery(String expressCompanyCode, List<Integer> buyOrderProductId) {
|
||||
QueryWrapper<BuyOrderProduct> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("id", buyOrderProductId);
|
||||
List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.list(queryWrapper);
|
||||
BigDecimal totalWeight = new BigDecimal(0);
|
||||
List<ExpressCommodity> commodityList = new ArrayList<>();
|
||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetailList) {
|
||||
List<Integer> buyOrderIdList = new ArrayList<>();
|
||||
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||
buyOrderIdList.add(buyOrderProduct.getOrderId());
|
||||
int productId = buyOrderProduct.getProductId();
|
||||
ShopProduct product = shopProductService.getById(productId);
|
||||
ExpressCommodity commodity = new ExpressCommodity();
|
||||
commodity.setGoodsName(buyOrderDetail.getProductName());
|
||||
commodity.setGoodsquantity(buyOrderDetail.getQuantity());
|
||||
commodity.setGoodsWeight(buyOrderDetail.getWeight().doubleValue());
|
||||
commodity.setGoodsName(product.getProductName());
|
||||
commodity.setGoodsquantity(buyOrderProduct.getQuantity());
|
||||
commodity.setGoodsWeight(product.getWeight().doubleValue());
|
||||
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);
|
||||
}
|
||||
|
||||
// 获取用户地址
|
||||
Integer orderId = buyOrderDetailList.get(0).getOrderId();
|
||||
Integer orderId = buyOrderProductList.get(0).getOrderId();
|
||||
|
||||
BuyOrder buyOrder = getById(orderId);
|
||||
QueryWrapper<County> countyQueryWrapper = new QueryWrapper<>();
|
||||
countyQueryWrapper.eq("county_name", buyOrder.getDistrict());
|
||||
@@ -352,6 +418,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
expressOrder.setCreateTime(new Date());
|
||||
expressOrder.setTotalWeight(totalWeight);
|
||||
expressOrder.setCommodity(commodityList);
|
||||
// expressOrder.setOrderSn(buyOrder.getOrderSn());
|
||||
expressOrder.setExpressCompanyCode(expressCompanyCode);
|
||||
expressOrder.setConsigneeName(buyOrder.getShippingUser());
|
||||
expressOrder.setConsigneeMobile(buyOrder.getUserPhone());
|
||||
@@ -361,14 +428,32 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
expressOrder.setAddress(buyOrder.getAddress());
|
||||
// 生成快递面单
|
||||
ExpressOrderResponseVo response = expressOrderService.placeExpressOrder(expressOrder);
|
||||
String expressBillNo = response.getOrder().getLogisticCode();
|
||||
String expressBillTemplate = response.getPrintTemplate();
|
||||
for (BuyOrderDetail buyOrderDetail : buyOrderDetailList) {
|
||||
buyOrderDetail.setExpressBillNo(expressBillNo);
|
||||
buyOrderDetail.setExpressBillTemplate(expressBillTemplate);
|
||||
buyOrderDetail.setExpressCompanyCode(expressCompanyCode);
|
||||
String expressOrderSn = response.getOrder().getLogisticCode();
|
||||
String printTemplate = response.getPrintTemplate();
|
||||
expressOrder.setExpressOrderSn(expressOrderSn);
|
||||
expressOrder.setPrintTemplate(printTemplate);
|
||||
expressOrderDao.insert(expressOrder);
|
||||
int expressOrderId = expressOrder.getId();
|
||||
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||
buyOrderProduct.setExpressOrderId(expressOrderId);
|
||||
buyOrderProduct.setShipped(1);
|
||||
}
|
||||
buyOrderDetailService.saveBatch(buyOrderDetailList);
|
||||
buyOrderProductService.updateBatchById(buyOrderProductList);
|
||||
|
||||
//更改订单状态
|
||||
QueryWrapper<BuyOrder> buyOrderQueryWrapper = new QueryWrapper<>();
|
||||
buyOrderQueryWrapper.in("order_id", buyOrderIdList);
|
||||
List<BuyOrder> buyOrderList = list(buyOrderQueryWrapper);
|
||||
for (BuyOrder buyorder : buyOrderList) {
|
||||
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
|
||||
buyOrderProductQueryWrapper.eq("order_id", buyorder.getOrderId());
|
||||
buyOrderProductQueryWrapper.eq("express_order_id", 0);
|
||||
int count = buyOrderProductService.count(buyOrderProductQueryWrapper);
|
||||
if (count == 0) {
|
||||
buyorder.setOrderStatus(Constants.ORDER_STATUS_SHIPPED);
|
||||
}
|
||||
}
|
||||
updateBatchById(buyOrderList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -379,17 +464,41 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
return setBuyOrderInfo(buyOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置订单信息
|
||||
*
|
||||
* @param buyOrder
|
||||
* @return
|
||||
*/
|
||||
private BuyOrderResponseVo setBuyOrderInfo(BuyOrder buyOrder) {
|
||||
BuyOrderResponseVo responseVo = new BuyOrderResponseVo();
|
||||
responseVo.setOrderId(buyOrder.getOrderId());
|
||||
responseVo.setTimestamp(buyOrder.getCreateTime().getTime());
|
||||
Integer userId = buyOrder.getUserId();
|
||||
QueryWrapper<MyUserEntity> userEntityQueryWrapper = new QueryWrapper<>();
|
||||
userEntityQueryWrapper.eq("id", userId);
|
||||
MyUserEntity user = myUserService.getOne(userEntityQueryWrapper);
|
||||
UserResponseVo userResponseVo = new UserResponseVo();
|
||||
userResponseVo.setUserPhone(user.getTel());
|
||||
userResponseVo.setUserName(user.getName());
|
||||
responseVo.setUserInfo(userResponseVo);
|
||||
if (user != null) {
|
||||
UserResponseVo userResponseVo = new UserResponseVo();
|
||||
userResponseVo.setUserId(user.getId());
|
||||
userResponseVo.setUserPhone(user.getTel());
|
||||
if (user.getName() != null) {
|
||||
userResponseVo.setUserName(user.getName());
|
||||
}
|
||||
responseVo.setUserInfo(userResponseVo);
|
||||
}
|
||||
CouponResponseVo couponResponseVo = new CouponResponseVo();
|
||||
if (buyOrder.getCouponId() != null) {
|
||||
couponResponseVo.setCouponName(buyOrder.getCouponName());
|
||||
couponResponseVo.setCouponId(buyOrder.getCouponId());
|
||||
couponResponseVo.setCouponAmount(new BigDecimal(0));
|
||||
}
|
||||
responseVo.setCoupon(couponResponseVo);
|
||||
responseVo.setOrderPrice(buyOrder.getOrderMoney());
|
||||
responseVo.setRealPrice(buyOrder.getRealMoney());
|
||||
responseVo.setShippingPrice(buyOrder.getShippingMoney());
|
||||
responseVo.setDistrictPrice(buyOrder.getDistrictMoney());
|
||||
responseVo.setOrderType(buyOrder.getOrderType());
|
||||
BeanUtil.copyProperties(buyOrder, responseVo);
|
||||
ConsigneeVo consigneeVo = new ConsigneeVo();
|
||||
consigneeVo.setConsigneeName(buyOrder.getShippingUser());
|
||||
@@ -398,6 +507,29 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
consigneeVo.setCity(buyOrder.getCity());
|
||||
consigneeVo.setCounty(buyOrder.getDistrict());
|
||||
consigneeVo.setAddress(buyOrder.getAddress());
|
||||
QueryWrapper<Province> provinceQueryWrapper = new QueryWrapper<>();
|
||||
provinceQueryWrapper.eq("prov_name", buyOrder.getProvince());
|
||||
Province province = provinceService.getOne(provinceQueryWrapper);
|
||||
if (province != null) {
|
||||
consigneeVo.setProvinceCode(province.getRegionCode());
|
||||
}
|
||||
QueryWrapper<City> cityQueryWrapper = new QueryWrapper<>();
|
||||
cityQueryWrapper.eq("city_name", buyOrder.getCity());
|
||||
City city = cityService.getOne(cityQueryWrapper);
|
||||
Long cityId = null;
|
||||
if (city != null) {
|
||||
consigneeVo.setCityCode(city.getRegionCode());
|
||||
cityId = city.getCityId();
|
||||
}
|
||||
QueryWrapper<County> countyQueryWrapper = new QueryWrapper<>();
|
||||
countyQueryWrapper.eq("county_name", buyOrder.getDistrict());
|
||||
if (countyService.count(countyQueryWrapper) > 1) {
|
||||
countyQueryWrapper.eq("city_id", cityId);
|
||||
}
|
||||
County county = countyService.getOne(countyQueryWrapper);
|
||||
if (county != null) {
|
||||
consigneeVo.setCountyCode(county.getRegionCode());
|
||||
}
|
||||
responseVo.setConsignee(consigneeVo);
|
||||
QueryWrapper<BuyOrderProduct> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_id", buyOrder.getOrderId());
|
||||
@@ -408,20 +540,26 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
QueryWrapper<ShopProduct> shopProductQueryWrapper = new QueryWrapper<>();
|
||||
shopProductQueryWrapper.eq("product_id", buyOrderProduct.getProductId());
|
||||
ShopProduct shopProduct = shopProductService.getOne(shopProductQueryWrapper);
|
||||
goodsResponseVo.setBuyOrderProductId(buyOrderProduct.getId());
|
||||
goodsResponseVo.setProductName(shopProduct.getProductName());
|
||||
goodsResponseVo.setProductImage(shopProduct.getProductImages());
|
||||
goodsResponseVo.setProductPrice(shopProduct.getPrice());
|
||||
goodsResponseVo.setQuantity(buyOrderProduct.getQuantity());
|
||||
QueryWrapper<ExpressOrder> expressOrderQueryWrapper = new QueryWrapper<>();
|
||||
expressOrderQueryWrapper.eq("id", buyOrderProduct.getExpressOrderId());
|
||||
ExpressOrder expressOrder = expressOrderService.getOne(expressOrderQueryWrapper);
|
||||
ExpressResponseVo expressResponseVo = new ExpressResponseVo();
|
||||
expressResponseVo.setExpressCompany(expressOrder.getExpressCompanyCode());
|
||||
expressResponseVo.setExpressOrderSn(expressOrder.getExpressOrderSn());
|
||||
expressResponseVo.setPrintTemplate(expressOrder.getPrintTemplate());
|
||||
if (expressOrder != null) {
|
||||
expressResponseVo.setExpressCompany(expressOrder.getExpressCompanyCode());
|
||||
expressResponseVo.setExpressOrderSn(expressOrder.getExpressOrderSn());
|
||||
expressResponseVo.setPrintTemplate(expressOrder.getPrintTemplate());
|
||||
}
|
||||
goodsResponseVo.setExpressInfo(expressResponseVo);
|
||||
goodsResponseVoList.add(goodsResponseVo);
|
||||
}
|
||||
responseVo.setGoodsList(goodsResponseVoList);
|
||||
return responseVo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class ExpressFeeServiceImpl extends ServiceImpl<ExpressFeeDao, ExpressFee
|
||||
additionalWeight = weight.subtract(new BigDecimal(15));
|
||||
}
|
||||
QueryWrapper<ExpressFee> queryWrapper = new QueryWrapper<>();
|
||||
if(!regionCode.startsWith("11") && !regionCode.startsWith("12") && !regionCode.startsWith("31") && !regionCode.startsWith("50")){
|
||||
if (!regionCode.startsWith("11") && !regionCode.startsWith("12") && !regionCode.startsWith("31") && !regionCode.startsWith("50")) {
|
||||
regionCode = regionCode.substring(0, 4).concat("00");
|
||||
}
|
||||
queryWrapper.eq("dest_code", regionCode);
|
||||
@@ -72,7 +72,11 @@ public class ExpressFeeServiceImpl extends ServiceImpl<ExpressFeeDao, ExpressFee
|
||||
* @return 费用
|
||||
*/
|
||||
private BigDecimal calculateYDExpressFee(BigDecimal weight, String regionCode) {
|
||||
regionCode = regionCode.substring(0, 4).concat("00");
|
||||
if (regionCode.startsWith("11") || regionCode.startsWith("12") || regionCode.startsWith("31") || regionCode.startsWith("50")) {
|
||||
regionCode = regionCode.substring(0, 2).concat("0000");
|
||||
} else {
|
||||
regionCode = regionCode.substring(0, 4).concat("00");
|
||||
}
|
||||
QueryWrapper<ExpressFee> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("dest_code", regionCode);
|
||||
queryWrapper.eq("express_code", "YD");
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ExpressOrderServiceImpl extends ServiceImpl<ExpressOrderDao, Expres
|
||||
public ExpressOrderResponseVo placeExpressOrder(ExpressOrder expressOrder) {
|
||||
ExpressOrderRequestVo orderRequestVo = new ExpressOrderRequestVo();
|
||||
// 订单号
|
||||
// orderRequestVo.setOrderCode(expressOrder.getOrderId().toString());
|
||||
// orderRequestVo.setOrderCode(expressOrder.getOrderSn());
|
||||
orderRequestVo.setIsReturnPrintTemplate(1);
|
||||
orderRequestVo.setShipperCode(expressOrder.getExpressCompanyCode());
|
||||
orderRequestVo.setPayType(3);
|
||||
@@ -92,15 +92,15 @@ public class ExpressOrderServiceImpl extends ServiceImpl<ExpressOrderDao, Expres
|
||||
}
|
||||
params.put("DataType", "2");
|
||||
String response = HttpClientUtils.kdSendPost(Constants.EXPRESS_PLACE_ORDER_URL, params);
|
||||
ExpressOrderResponseVo responseVo = JSONObject.parseObject(response, ExpressOrderResponseVo.class);
|
||||
return responseVo;
|
||||
return JSONObject.parseObject(response, ExpressOrderResponseVo.class);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressQueryResponse queryExpressOrder(String shipperCode, String logisticCode) {
|
||||
public ExpressQueryResponse queryExpressOrder(String shipperCode, String logisticCode, String customerName) {
|
||||
ExpressQueryRequestVo requestVo = new ExpressQueryRequestVo();
|
||||
requestVo.setLogisticCode(logisticCode);
|
||||
requestVo.setCustomerName(customerName);
|
||||
requestVo.setShipperCode(shipperCode);
|
||||
String requestData = JSONObject.toJSONString(requestVo);
|
||||
Map<String, String> params = new HashMap<>();
|
||||
|
||||
@@ -1,255 +1,255 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.peanut.modules.book.entity.SeckillProdRelationEntity;
|
||||
import com.peanut.modules.book.entity.ShopProduct;
|
||||
import com.peanut.modules.book.service.SeckillProdRelationService;
|
||||
import com.peanut.modules.book.service.ShopProductService;
|
||||
import com.peanut.modules.book.to.SeckillRedisTo;
|
||||
import com.peanut.modules.book.vo.ProdInfoVo;
|
||||
import com.peanut.modules.book.vo.SeckillSessionWithProdVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.redisson.api.RSemaphore;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.BoundHashOperations;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
|
||||
import com.peanut.modules.book.dao.ShopSeckillDao;
|
||||
import com.peanut.modules.book.entity.ShopSeckillEntity;
|
||||
import com.peanut.modules.book.service.ShopSeckillService;
|
||||
|
||||
@Slf4j
|
||||
@Service("shopSeckillService")
|
||||
public class ShopSeckillServiceImpl extends ServiceImpl<ShopSeckillDao, ShopSeckillEntity> implements ShopSeckillService {
|
||||
|
||||
@Autowired
|
||||
private SeckillProdRelationService seckillProdRelationService;
|
||||
@Autowired
|
||||
StringRedisTemplate stringRedisTemplate;
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
@Autowired
|
||||
RedissonClient redissonClient;
|
||||
|
||||
private final String SESSIONS_CACHE_PREFIX = "seckill:sessions:";
|
||||
private final String PROKILL_CACHE_PREFIX = "prokill:pro";
|
||||
private final String PRO_STOCK_SEMAPHORE = "seckill:stock:";
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<ShopSeckillEntity> page = this.page(
|
||||
new Query<ShopSeckillEntity>().getPage(params),
|
||||
new QueryWrapper<ShopSeckillEntity>()
|
||||
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopSeckillEntity> getSeckilProd3Days() {
|
||||
List<ShopSeckillEntity> list = this.baseMapper.selectList(new QueryWrapper<ShopSeckillEntity>().between("start_time", startTime(), endTime()));
|
||||
if (list != null && list.size() > 0) {
|
||||
list.stream().map(session -> {
|
||||
Long seckillId = session.getSeckillId();
|
||||
List<SeckillProdRelationEntity> seckillList = seckillProdRelationService.list(new QueryWrapper<SeckillProdRelationEntity>().eq("promotion_seckill_id", seckillId));
|
||||
session.setRelationProd(seckillList);
|
||||
return session;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadSeckilProd3Days() {
|
||||
List<ShopSeckillEntity> seckilProd = this.getSeckilProd3Days();
|
||||
List<SeckillSessionWithProdVo> seckilProdVo = JSON.parseObject(JSON.toJSONString(seckilProd), new TypeReference<List<SeckillSessionWithProdVo>>() {
|
||||
});
|
||||
saveSessionInfo(seckilProdVo);
|
||||
saveSessionProdInfo(seckilProdVo);
|
||||
|
||||
Set<String> keys = stringRedisTemplate.keys(SESSIONS_CACHE_PREFIX + "*");
|
||||
long time = new Date().getTime();
|
||||
for(String key : keys){
|
||||
String replace = key.replace(SESSIONS_CACHE_PREFIX, "");
|
||||
String[] s = replace.split("_");
|
||||
long endTime = Long.parseLong(s[1]);
|
||||
if(endTime <= time){
|
||||
stringRedisTemplate.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SeckillRedisTo> getCurrentSeckillProd() {
|
||||
long time = new Date().getTime();
|
||||
|
||||
Set<String> keys = stringRedisTemplate.keys(SESSIONS_CACHE_PREFIX + "*");
|
||||
|
||||
for (String key : keys) {
|
||||
String replace = key.replace(SESSIONS_CACHE_PREFIX, "");
|
||||
String[] s = replace.split("_");
|
||||
long startTime = Long.parseLong(s[0]);
|
||||
long endTime = Long.parseLong(s[1]);
|
||||
|
||||
|
||||
if (time >= startTime && time <= endTime ) {
|
||||
|
||||
List<String> list = stringRedisTemplate.opsForList().range(key, -100, 100);
|
||||
BoundHashOperations<String, String, Object> operations = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
||||
List<Object> objects = operations.multiGet(list);
|
||||
if (objects.size() > 0) {
|
||||
List<SeckillRedisTo> collect = objects.stream().map(item -> {
|
||||
SeckillRedisTo seckillRedisTo = JSON.parseObject(item.toString(), SeckillRedisTo.class);
|
||||
// seckillRedisTo.setRandomCode(null);
|
||||
return seckillRedisTo;
|
||||
}).collect(Collectors.toList());
|
||||
return collect;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String kill(String killId, String key, Integer num , Integer userId) {
|
||||
|
||||
|
||||
BoundHashOperations<String, String, String> hashOps = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
||||
String o = hashOps.get(killId);
|
||||
if (StringUtils.isEmpty(o)){
|
||||
return null;
|
||||
}else {
|
||||
SeckillRedisTo seckillRedisTo = JSON.parseObject(o, SeckillRedisTo.class);
|
||||
Long startTime = seckillRedisTo.getStartTime();
|
||||
Long endTime = seckillRedisTo.getEndTime();
|
||||
|
||||
long time = new Date().getTime();
|
||||
|
||||
long ttl = endTime - time;
|
||||
if ( time >= startTime && time <= endTime){
|
||||
String randomCode = seckillRedisTo.getRandomCode();
|
||||
String prodId = seckillRedisTo.getPromotionSeckillId() + "_" + seckillRedisTo.getProdId();
|
||||
if( randomCode.equals(key) && killId.equals(prodId)){
|
||||
if (num <= Integer.valueOf(seckillRedisTo.getSeckillLimit())) {
|
||||
String redisKey = userId + "_" + prodId;
|
||||
Boolean aBoolean = stringRedisTemplate.opsForValue().setIfAbsent(redisKey, num.toString(), ttl, TimeUnit.MILLISECONDS);
|
||||
if (aBoolean) {
|
||||
RSemaphore semaphore = redissonClient.getSemaphore(PRO_STOCK_SEMAPHORE + randomCode);
|
||||
try {
|
||||
boolean b = semaphore.tryAcquire(num, 100, TimeUnit.MILLISECONDS);
|
||||
// 秒杀成功
|
||||
String timeId = IdWorker.getTimeId();
|
||||
return timeId;
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
return null;
|
||||
}
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void saveSessionInfo(List<SeckillSessionWithProdVo> seckilProdVo) {
|
||||
seckilProdVo.stream().forEach(session -> {
|
||||
long startTime = session.getStartTime().getTime();
|
||||
long endTime = session.getEndTime().getTime();
|
||||
String key = SESSIONS_CACHE_PREFIX + startTime + "_" + endTime;
|
||||
|
||||
Boolean aBoolean = stringRedisTemplate.hasKey(key);
|
||||
if (!aBoolean) {
|
||||
List<String> collect = session.getRelationProd().stream().map(item -> item.getPromotionSeckillId() + "_" + item.getProdId().toString()).collect(Collectors.toList());
|
||||
stringRedisTemplate.opsForList().leftPushAll(key, collect);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void saveSessionProdInfo(List<SeckillSessionWithProdVo> seckilProdVos) {
|
||||
|
||||
seckilProdVos.stream().forEach(seckilProdVo -> {
|
||||
|
||||
BoundHashOperations<String, Object, Object> ops = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
||||
|
||||
seckilProdVo.getRelationProd().stream().forEach(seckilProd -> {
|
||||
String token = UUID.randomUUID().toString().replace("-", "");
|
||||
if (!ops.hasKey(seckilProd.getPromotionSeckillId().toString() + "_" + seckilProd.getProdId().toString())) {
|
||||
SeckillRedisTo seckillRedisTo = new SeckillRedisTo();
|
||||
|
||||
ShopProduct productEntity = shopProductService.getById(seckilProd.getProdId());
|
||||
ProdInfoVo prodInfoVo = JSON.parseObject(JSON.toJSONString(productEntity), new TypeReference<ProdInfoVo>() {
|
||||
});
|
||||
seckillRedisTo.setProdInfo(prodInfoVo);
|
||||
BeanUtils.copyProperties(seckilProd, seckillRedisTo);
|
||||
|
||||
seckillRedisTo.setStartTime(seckilProdVo.getStartTime().getTime());
|
||||
seckillRedisTo.setEndTime(seckilProdVo.getEndTime().getTime());
|
||||
|
||||
seckillRedisTo.setRandomCode(token);
|
||||
|
||||
|
||||
String string = JSON.toJSONString(seckillRedisTo);
|
||||
ops.put(seckilProd.getPromotionSeckillId().toString() + "_" + seckilProd.getProdId().toString(), string);
|
||||
|
||||
RSemaphore semaphore = redissonClient.getSemaphore(PRO_STOCK_SEMAPHORE + token);
|
||||
semaphore.trySetPermits(Integer.valueOf(seckilProd.getSeckillCount()));
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
private String startTime() {
|
||||
LocalDate now = LocalDate.now();
|
||||
LocalTime min = LocalTime.MIN;
|
||||
LocalDateTime start = LocalDateTime.of(now, min);
|
||||
String format = start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
return format;
|
||||
}
|
||||
|
||||
private String endTime() {
|
||||
LocalDate now = LocalDate.now();
|
||||
LocalDate localDate = now.plusDays(2);
|
||||
LocalDateTime of = LocalDateTime.of(localDate, LocalTime.MAX);
|
||||
String format = of.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
return format;
|
||||
}
|
||||
}
|
||||
//package com.peanut.modules.book.service.impl;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSON;
|
||||
//import com.alibaba.fastjson.TypeReference;
|
||||
//import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
//import com.peanut.modules.book.entity.SeckillProdRelationEntity;
|
||||
//import com.peanut.modules.book.entity.ShopProduct;
|
||||
//import com.peanut.modules.book.service.SeckillProdRelationService;
|
||||
//import com.peanut.modules.book.service.ShopProductService;
|
||||
//import com.peanut.modules.book.to.SeckillRedisTo;
|
||||
//import com.peanut.modules.book.vo.ProdInfoVo;
|
||||
//import com.peanut.modules.book.vo.SeckillSessionWithProdVo;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.commons.lang.StringUtils;
|
||||
//import org.redisson.api.RSemaphore;
|
||||
//import org.redisson.api.RedissonClient;
|
||||
//import org.springframework.beans.BeanUtils;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.data.redis.core.BoundHashOperations;
|
||||
//import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import java.time.LocalDate;
|
||||
//import java.time.LocalDateTime;
|
||||
//import java.time.LocalTime;
|
||||
//import java.time.format.DateTimeFormatter;
|
||||
//import java.util.*;
|
||||
//import java.util.concurrent.TimeUnit;
|
||||
//import java.util.stream.Collectors;
|
||||
//
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
//import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
//import com.peanut.common.utils.PageUtils;
|
||||
//import com.peanut.common.utils.Query;
|
||||
//
|
||||
//import com.peanut.modules.book.dao.ShopSeckillDao;
|
||||
//import com.peanut.modules.book.entity.ShopSeckillEntity;
|
||||
//import com.peanut.modules.book.service.ShopSeckillService;
|
||||
//
|
||||
//@Slf4j
|
||||
//@Service("shopSeckillService")
|
||||
//public class ShopSeckillServiceImpl extends ServiceImpl<ShopSeckillDao, ShopSeckillEntity> implements ShopSeckillService {
|
||||
//
|
||||
// @Autowired
|
||||
// private SeckillProdRelationService seckillProdRelationService;
|
||||
// @Autowired
|
||||
// StringRedisTemplate stringRedisTemplate;
|
||||
// @Autowired
|
||||
// private ShopProductService shopProductService;
|
||||
// @Autowired
|
||||
// RedissonClient redissonClient;
|
||||
//
|
||||
// private final String SESSIONS_CACHE_PREFIX = "seckill:sessions:";
|
||||
// private final String PROKILL_CACHE_PREFIX = "prokill:pro";
|
||||
// private final String PRO_STOCK_SEMAPHORE = "seckill:stock:";
|
||||
//
|
||||
// @Override
|
||||
// public PageUtils queryPage(Map<String, Object> params) {
|
||||
// IPage<ShopSeckillEntity> page = this.page(
|
||||
// new Query<ShopSeckillEntity>().getPage(params),
|
||||
// new QueryWrapper<ShopSeckillEntity>()
|
||||
//
|
||||
// );
|
||||
//
|
||||
// return new PageUtils(page);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<ShopSeckillEntity> getSeckilProd3Days() {
|
||||
// List<ShopSeckillEntity> list = this.baseMapper.selectList(new QueryWrapper<ShopSeckillEntity>().between("start_time", startTime(), endTime()));
|
||||
// if (list != null && list.size() > 0) {
|
||||
// list.stream().map(session -> {
|
||||
// Long seckillId = session.getSeckillId();
|
||||
// List<SeckillProdRelationEntity> seckillList = seckillProdRelationService.list(new QueryWrapper<SeckillProdRelationEntity>().eq("promotion_seckill_id", seckillId));
|
||||
// session.setRelationProd(seckillList);
|
||||
// return session;
|
||||
// }).collect(Collectors.toList());
|
||||
// }
|
||||
// return list;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void uploadSeckilProd3Days() {
|
||||
// List<ShopSeckillEntity> seckilProd = this.getSeckilProd3Days();
|
||||
// List<SeckillSessionWithProdVo> seckilProdVo = JSON.parseObject(JSON.toJSONString(seckilProd), new TypeReference<List<SeckillSessionWithProdVo>>() {
|
||||
// });
|
||||
// saveSessionInfo(seckilProdVo);
|
||||
// saveSessionProdInfo(seckilProdVo);
|
||||
//
|
||||
// Set<String> keys = stringRedisTemplate.keys(SESSIONS_CACHE_PREFIX + "*");
|
||||
// long time = new Date().getTime();
|
||||
// for(String key : keys){
|
||||
// String replace = key.replace(SESSIONS_CACHE_PREFIX, "");
|
||||
// String[] s = replace.split("_");
|
||||
// long endTime = Long.parseLong(s[1]);
|
||||
// if(endTime <= time){
|
||||
// stringRedisTemplate.delete(key);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<SeckillRedisTo> getCurrentSeckillProd() {
|
||||
// long time = new Date().getTime();
|
||||
//
|
||||
// Set<String> keys = stringRedisTemplate.keys(SESSIONS_CACHE_PREFIX + "*");
|
||||
//
|
||||
// for (String key : keys) {
|
||||
// String replace = key.replace(SESSIONS_CACHE_PREFIX, "");
|
||||
// String[] s = replace.split("_");
|
||||
// long startTime = Long.parseLong(s[0]);
|
||||
// long endTime = Long.parseLong(s[1]);
|
||||
//
|
||||
//
|
||||
// if (time >= startTime && time <= endTime ) {
|
||||
//
|
||||
// List<String> list = stringRedisTemplate.opsForList().range(key, -100, 100);
|
||||
// BoundHashOperations<String, String, Object> operations = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
||||
// List<Object> objects = operations.multiGet(list);
|
||||
// if (objects.size() > 0) {
|
||||
// List<SeckillRedisTo> collect = objects.stream().map(item -> {
|
||||
// SeckillRedisTo seckillRedisTo = JSON.parseObject(item.toString(), SeckillRedisTo.class);
|
||||
//// seckillRedisTo.setRandomCode(null);
|
||||
// return seckillRedisTo;
|
||||
// }).collect(Collectors.toList());
|
||||
// return collect;
|
||||
// }
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String kill(String killId, String key, Integer num , Integer userId) {
|
||||
//
|
||||
//
|
||||
// BoundHashOperations<String, String, String> hashOps = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
||||
// String o = hashOps.get(killId);
|
||||
// if (StringUtils.isEmpty(o)){
|
||||
// return null;
|
||||
// }else {
|
||||
// SeckillRedisTo seckillRedisTo = JSON.parseObject(o, SeckillRedisTo.class);
|
||||
// Long startTime = seckillRedisTo.getStartTime();
|
||||
// Long endTime = seckillRedisTo.getEndTime();
|
||||
//
|
||||
// long time = new Date().getTime();
|
||||
//
|
||||
// long ttl = endTime - time;
|
||||
// if ( time >= startTime && time <= endTime){
|
||||
// String randomCode = seckillRedisTo.getRandomCode();
|
||||
// String prodId = seckillRedisTo.getPromotionSeckillId() + "_" + seckillRedisTo.getProdId();
|
||||
// if( randomCode.equals(key) && killId.equals(prodId)){
|
||||
// if (num <= Integer.valueOf(seckillRedisTo.getSeckillLimit())) {
|
||||
// String redisKey = userId + "_" + prodId;
|
||||
// Boolean aBoolean = stringRedisTemplate.opsForValue().setIfAbsent(redisKey, num.toString(), ttl, TimeUnit.MILLISECONDS);
|
||||
// if (aBoolean) {
|
||||
// RSemaphore semaphore = redissonClient.getSemaphore(PRO_STOCK_SEMAPHORE + randomCode);
|
||||
// try {
|
||||
// boolean b = semaphore.tryAcquire(num, 100, TimeUnit.MILLISECONDS);
|
||||
// // 秒杀成功
|
||||
// String timeId = IdWorker.getTimeId();
|
||||
// return timeId;
|
||||
//
|
||||
// } catch (InterruptedException e) {
|
||||
// return null;
|
||||
// }
|
||||
// }else {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }else {
|
||||
// return null;
|
||||
// }
|
||||
// }else {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private void saveSessionInfo(List<SeckillSessionWithProdVo> seckilProdVo) {
|
||||
// seckilProdVo.stream().forEach(session -> {
|
||||
// long startTime = session.getStartTime().getTime();
|
||||
// long endTime = session.getEndTime().getTime();
|
||||
// String key = SESSIONS_CACHE_PREFIX + startTime + "_" + endTime;
|
||||
//
|
||||
// Boolean aBoolean = stringRedisTemplate.hasKey(key);
|
||||
// if (!aBoolean) {
|
||||
// List<String> collect = session.getRelationProd().stream().map(item -> item.getPromotionSeckillId() + "_" + item.getProdId().toString()).collect(Collectors.toList());
|
||||
// stringRedisTemplate.opsForList().leftPushAll(key, collect);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// private void saveSessionProdInfo(List<SeckillSessionWithProdVo> seckilProdVos) {
|
||||
//
|
||||
// seckilProdVos.stream().forEach(seckilProdVo -> {
|
||||
//
|
||||
// BoundHashOperations<String, Object, Object> ops = stringRedisTemplate.boundHashOps(PROKILL_CACHE_PREFIX);
|
||||
//
|
||||
// seckilProdVo.getRelationProd().stream().forEach(seckilProd -> {
|
||||
// String token = UUID.randomUUID().toString().replace("-", "");
|
||||
// if (!ops.hasKey(seckilProd.getPromotionSeckillId().toString() + "_" + seckilProd.getProdId().toString())) {
|
||||
// SeckillRedisTo seckillRedisTo = new SeckillRedisTo();
|
||||
//
|
||||
// ShopProduct productEntity = shopProductService.getById(seckilProd.getProdId());
|
||||
// ProdInfoVo prodInfoVo = JSON.parseObject(JSON.toJSONString(productEntity), new TypeReference<ProdInfoVo>() {
|
||||
// });
|
||||
// seckillRedisTo.setProdInfo(prodInfoVo);
|
||||
// BeanUtils.copyProperties(seckilProd, seckillRedisTo);
|
||||
//
|
||||
// seckillRedisTo.setStartTime(seckilProdVo.getStartTime().getTime());
|
||||
// seckillRedisTo.setEndTime(seckilProdVo.getEndTime().getTime());
|
||||
//
|
||||
// seckillRedisTo.setRandomCode(token);
|
||||
//
|
||||
//
|
||||
// String string = JSON.toJSONString(seckillRedisTo);
|
||||
// ops.put(seckilProd.getPromotionSeckillId().toString() + "_" + seckilProd.getProdId().toString(), string);
|
||||
//
|
||||
// RSemaphore semaphore = redissonClient.getSemaphore(PRO_STOCK_SEMAPHORE + token);
|
||||
// semaphore.trySetPermits(Integer.valueOf(seckilProd.getSeckillCount()));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private String startTime() {
|
||||
// LocalDate now = LocalDate.now();
|
||||
// LocalTime min = LocalTime.MIN;
|
||||
// LocalDateTime start = LocalDateTime.of(now, min);
|
||||
// String format = start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
// return format;
|
||||
// }
|
||||
//
|
||||
// private String endTime() {
|
||||
// LocalDate now = LocalDate.now();
|
||||
// LocalDate localDate = now.plusDays(2);
|
||||
// LocalDateTime of = LocalDateTime.of(localDate, LocalTime.MAX);
|
||||
// String format = of.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
// return format;
|
||||
// }
|
||||
//}
|
||||
@@ -43,6 +43,7 @@ public class UserAddressServiceImpl extends ServiceImpl<UserAddressDao, UserAddr
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserAddressVo getAddressName(UserAddressVo vo, String regionCode) {
|
||||
QueryWrapper<County> countyQueryWrapper = new QueryWrapper<>();
|
||||
countyQueryWrapper.eq("region_code", regionCode);
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.Query;
|
||||
import com.peanut.modules.book.dao.UserFollowUpDao;
|
||||
import com.peanut.modules.book.entity.UserFollowUpEntity;
|
||||
import com.peanut.modules.book.entity.UserRecordEntity;
|
||||
import com.peanut.modules.book.service.UserFollowUpService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.*;
|
||||
import com.peanut.modules.book.dao.UserRecordDao;
|
||||
import com.peanut.modules.book.entity.MyUserEntity;
|
||||
import com.peanut.modules.book.entity.UserRecordEntity;
|
||||
import com.peanut.modules.book.entity.UserRecord;
|
||||
import com.peanut.modules.book.service.MyUserService;
|
||||
import com.peanut.modules.book.service.UserRecordService;
|
||||
import org.joda.time.DateTime;
|
||||
@@ -21,7 +21,7 @@ import java.util.*;
|
||||
|
||||
|
||||
@Service("UserRecordServiceImpl")
|
||||
public class UserRecordServiceImpl extends ServiceImpl<UserRecordDao, UserRecordEntity> implements UserRecordService {
|
||||
public class UserRecordServiceImpl extends ServiceImpl<UserRecordDao, UserRecord> implements UserRecordService {
|
||||
|
||||
@Autowired
|
||||
private MyUserService myUserService;
|
||||
@@ -37,9 +37,9 @@ public class UserRecordServiceImpl extends ServiceImpl<UserRecordDao, UserRecord
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String productId = (String) params.get("proudictId");
|
||||
IPage<UserRecordEntity> page = page(
|
||||
new Query<UserRecordEntity>().getPage(params),
|
||||
new QueryWrapper<UserRecordEntity>()
|
||||
IPage<UserRecord> page = page(
|
||||
new Query<UserRecord>().getPage(params),
|
||||
new QueryWrapper<UserRecord>()
|
||||
//订单号,开始时间
|
||||
.eq("bookid", productId).orderByDesc("create_date")
|
||||
// .eq("")
|
||||
@@ -47,13 +47,13 @@ public class UserRecordServiceImpl extends ServiceImpl<UserRecordDao, UserRecord
|
||||
);
|
||||
|
||||
|
||||
for (UserRecordEntity userRecordEntity : page.getRecords()) {
|
||||
Integer userid = userRecordEntity.getUserid();
|
||||
for (UserRecord userRecord : page.getRecords()) {
|
||||
Integer userid = userRecord.getUserid();
|
||||
MyUserEntity byId = myUserService.getById(userid);
|
||||
String avatar = byId.getAvatar();
|
||||
String nickname = byId.getNickname();
|
||||
userRecordEntity.setAvatar(avatar);
|
||||
userRecordEntity.setNickname(nickname);
|
||||
userRecord.setAvatar(avatar);
|
||||
userRecord.setNickname(nickname);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
package com.peanut.modules.book.task;
|
||||
|
||||
import com.peanut.modules.book.service.ShopSeckillService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SeckillProdScheduled {
|
||||
@Autowired
|
||||
ShopSeckillService shopSeckillService;
|
||||
|
||||
@Scheduled(cron = "0 0/1 * * * ?")
|
||||
public void uploadSeckilProd3Days() {
|
||||
Lock l = new ReentrantLock();
|
||||
l.lock();
|
||||
try {
|
||||
shopSeckillService.uploadSeckilProd3Days();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
l.unlock();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//package com.peanut.modules.book.task;
|
||||
//
|
||||
//import com.peanut.modules.book.service.ShopSeckillService;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.scheduling.annotation.Scheduled;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import java.util.concurrent.locks.Lock;
|
||||
//import java.util.concurrent.locks.ReentrantLock;
|
||||
//
|
||||
//@Slf4j
|
||||
//@Service
|
||||
//public class SeckillProdScheduled {
|
||||
// @Autowired
|
||||
// ShopSeckillService shopSeckillService;
|
||||
//
|
||||
// @Scheduled(cron = "0 0/1 * * * ?")
|
||||
// public void uploadSeckilProd3Days() {
|
||||
// Lock l = new ReentrantLock();
|
||||
// l.lock();
|
||||
// try {
|
||||
// shopSeckillService.uploadSeckilProd3Days();
|
||||
// }catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
// }finally {
|
||||
// l.unlock();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
14
src/main/java/com/peanut/modules/book/to/UserOrderDto.java
Normal file
14
src/main/java/com/peanut/modules/book/to/UserOrderDto.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.peanut.modules.book.to;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class UserOrderDto implements Serializable {
|
||||
|
||||
private Integer userId;
|
||||
private Integer orderStatus;
|
||||
private Integer limit;
|
||||
private Integer page;
|
||||
}
|
||||
@@ -17,4 +17,8 @@ public class ExpressQueryRequestVo {
|
||||
* 快递单号
|
||||
*/
|
||||
private String LogisticCode;
|
||||
/**
|
||||
* 手机尾号
|
||||
*/
|
||||
private String CustomerName;
|
||||
}
|
||||
|
||||
@@ -16,15 +16,15 @@ public class ShippingAddressRequestVo {
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
private String province;
|
||||
private String provinceCode;
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
private String city;
|
||||
private String cityCode;
|
||||
/**
|
||||
* 县
|
||||
*/
|
||||
private String county;
|
||||
private String countyCode;
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
|
||||
@@ -11,6 +11,10 @@ import java.util.Date;
|
||||
*/
|
||||
@Data
|
||||
public class BuyOrderListRequestVo {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Integer orderId;
|
||||
/**
|
||||
* 页号
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
/**
|
||||
* 收货人姓名
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.peanut.modules.book.vo.response;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -13,6 +14,7 @@ import java.util.List;
|
||||
*/
|
||||
@Data
|
||||
public class BuyOrderResponseVo {
|
||||
private Integer orderId;
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
@@ -65,4 +67,18 @@ public class BuyOrderResponseVo {
|
||||
* 用户信息
|
||||
*/
|
||||
private UserResponseVo userInfo;
|
||||
/**
|
||||
* 订单类型
|
||||
*/
|
||||
private String orderType;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
private Long timestamp;
|
||||
/**
|
||||
* 发货时间
|
||||
*/
|
||||
private Date shippingTime;
|
||||
}
|
||||
|
||||
@@ -33,5 +33,17 @@ public class ConsigneeVo {
|
||||
* 详细地址
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 省份代码
|
||||
*/
|
||||
private String provinceCode;
|
||||
/**
|
||||
* 城市代码
|
||||
*/
|
||||
private String cityCode;
|
||||
/**
|
||||
* 区县代码
|
||||
*/
|
||||
private String countyCode;
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.peanut.modules.book.vo.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @Description: 优惠券 Value Object
|
||||
* @Author: Cauchy
|
||||
@@ -9,4 +11,14 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
public class CouponResponseVo {
|
||||
/**
|
||||
* 优惠券名称
|
||||
*/
|
||||
String couponName;
|
||||
/**
|
||||
* 优惠券金额
|
||||
*/
|
||||
Integer couponId;
|
||||
|
||||
BigDecimal couponAmount;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class ExpressQueryResponseVo {
|
||||
/**
|
||||
* 订单详情 ID
|
||||
*/
|
||||
private Long orderDetailId;
|
||||
private String expressCompanyCode;
|
||||
/**
|
||||
* 快递单号
|
||||
*/
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.math.BigDecimal;
|
||||
*/
|
||||
@Data
|
||||
public class GoodsResponseVo {
|
||||
private Integer buyOrderProductId;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.peanut.modules.book.vo.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 订单地址查询响应 Value Object
|
||||
* @Author: Cauchy
|
||||
* @CreateTime: 2023/10/24
|
||||
*/
|
||||
@Data
|
||||
public class OrderAddressResponseVo {
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
private String provinceCode;
|
||||
/**
|
||||
* 市
|
||||
*/
|
||||
private String cityCode;
|
||||
/**
|
||||
* 区
|
||||
*/
|
||||
private String countyCode;
|
||||
/**
|
||||
* 收货人姓名
|
||||
*/
|
||||
private String consigneeName;
|
||||
/**
|
||||
* 收货人电话
|
||||
*/
|
||||
private String consigneeMobile;
|
||||
/**
|
||||
* 详细地址
|
||||
*/
|
||||
private String detailAddress;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.peanut.modules.book.vo.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 面单响应 value object
|
||||
* @Author: Cauchy
|
||||
* @CreateTime: 2023/10/23
|
||||
*/
|
||||
@Data
|
||||
public class PrintTemplateVo {
|
||||
/**
|
||||
* 快递单号
|
||||
*/
|
||||
private String expressOrderSn;
|
||||
/**
|
||||
* 面单
|
||||
*/
|
||||
private String printTemplate;
|
||||
/**
|
||||
* 快递公司代码
|
||||
*/
|
||||
private String expressCompanyCode;
|
||||
/**
|
||||
* 是否打印过
|
||||
*/
|
||||
private int templatedPrinted;
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
public class UserResponseVo {
|
||||
private Integer userId;
|
||||
/**
|
||||
* 用户姓名
|
||||
*/
|
||||
|
||||
@@ -3,7 +3,7 @@ spring:
|
||||
redis:
|
||||
open: false # 是否开启redis缓存 true开启 false关闭
|
||||
database: 0
|
||||
host: 39.106.36.183
|
||||
host: 59.110.212.44
|
||||
port: 6379
|
||||
password: Jgll2015 # 密码(默认为空)
|
||||
timeout: 6000000ms # 连接超时时长(毫秒)
|
||||
@@ -19,7 +19,6 @@ spring:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://59.110.212.44:3306/e_book_test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
username: root
|
||||
# password: HSXY1234hsxy
|
||||
password: Jgll2023Nutty
|
||||
initial-size: 10
|
||||
max-active: 100
|
||||
@@ -73,5 +72,5 @@ aliyun:
|
||||
server:
|
||||
port: 9200
|
||||
|
||||
redisAddress: redis://39.106.36.183:6379
|
||||
redisAddress: redis://59.110.212.44:6379
|
||||
redisPassword: Jgll2015
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
<!-- 可根据自己的需求,是否要使用 -->
|
||||
<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="userId" column="user_id"/>
|
||||
<result property="shippingUser" column="shipping_user"/>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
SELECT spb.book_id
|
||||
FROM shop_product_book spb
|
||||
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}
|
||||
AND spb.del_flag != -1
|
||||
</select>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
order by a.sort desc
|
||||
</select>
|
||||
|
||||
<select id="getTotalWeight" parameterType="list">
|
||||
<select id="getTotalWeight" parameterType="list" resultType="java.lang.Integer">
|
||||
select sum(weight) from shop_product where product_id in
|
||||
<foreach collection="list" item="id" index="index" open="(" close=")" separator=",">
|
||||
#{id}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<mapper namespace="com.peanut.modules.book.dao.UserRecordDao">
|
||||
|
||||
<!-- 可根据自己的需求,是否要使用 -->
|
||||
<resultMap type="com.peanut.modules.book.entity.UserRecordEntity" id="UserRecordMap">
|
||||
<resultMap type="com.peanut.modules.book.entity.UserRecord" id="UserRecordMap">
|
||||
<result property="id" column="oid"/>
|
||||
<result property="createDate" column="createDate"/>
|
||||
<result property="type" column="type"/>
|
||||
|
||||
Reference in New Issue
Block a user