更新
This commit is contained in:
@@ -260,7 +260,6 @@ public class BuyOrderController {
|
||||
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);
|
||||
@@ -272,6 +271,7 @@ public class BuyOrderController {
|
||||
buyOrder.setAddress(userAddress.getDetailAddress());
|
||||
buyOrderService.save(buyOrder);
|
||||
|
||||
//解决购物车相关问题
|
||||
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
|
||||
buyOrderProduct.setOrderId(buyOrder.getOrderId());
|
||||
if (Constants.BUY_TYPE_CART.equals(buyOrder.getBuyType())) {
|
||||
@@ -458,6 +458,12 @@ public class BuyOrderController {
|
||||
paymentInfo.setBuyOrderId(Integer.valueOf(buyOrderEntity.getProductId()));
|
||||
paymentInfo.setTotalAmount(buyOrderEntity.getRealMoney());
|
||||
wxpayService.prepay(paymentInfo);
|
||||
rabbitTemplate.convertAndSend(
|
||||
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
|
||||
DelayQueueConfig.ORDER_TO_BE_PAY_ROUTING_KEY,
|
||||
buyOrder.getOrderId(),
|
||||
messagePostProcessor()
|
||||
);
|
||||
return R.ok().put("orderSn", timeId);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.peanut.modules.book.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.book.entity.BuyOrderProduct;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface BuyOrderProductDao extends BaseMapper<BuyOrderProduct> {
|
||||
public interface BuyOrderProductDao extends MPJBaseMapper<BuyOrderProduct> {
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package com.peanut.modules.book.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.book.entity.ShopProductBookEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ShopProductBookDao extends BaseMapper<ShopProductBookEntity> {
|
||||
public interface ShopProductBookDao extends MPJBaseMapper<ShopProductBookEntity> {
|
||||
|
||||
List<Integer> getOrderBookId(String orderSn);
|
||||
}
|
||||
|
||||
@@ -87,6 +87,11 @@ public class ExpressOrder {
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String printString;
|
||||
/**
|
||||
* 商品列表
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<ShopProduct> products;
|
||||
/**
|
||||
* 快递单号
|
||||
*/
|
||||
|
||||
@@ -151,6 +151,11 @@ public class ShopProduct implements Serializable {
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private ArrayList<String> bookids;
|
||||
/**
|
||||
* 实体书list
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<BookEntity> books;
|
||||
|
||||
/**
|
||||
* 多个电子书Id ArrayList<Map<String,String>>
|
||||
@@ -167,4 +172,14 @@ public class ShopProduct implements Serializable {
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<String> shoproudLabels;
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Integer quantity;
|
||||
/**
|
||||
* 属于的订单,特殊情况下启用
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String orderSn;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ 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.BookEntity;
|
||||
import com.peanut.modules.book.entity.ShopProductBookEntity;
|
||||
import com.peanut.modules.book.vo.ProductBookQueryVO;
|
||||
|
||||
@@ -17,6 +18,8 @@ public interface ShopProductBookService extends IService<ShopProductBookEntity>
|
||||
|
||||
List<Integer> getBookIdsByProductId(Integer productId);
|
||||
|
||||
List<BookEntity> getBookByProductId(Integer productId);
|
||||
|
||||
Integer getProductByBookId(Integer bookId);
|
||||
|
||||
List<Integer> getOrderBookId(String orderSn);
|
||||
|
||||
@@ -8,12 +8,15 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
|
||||
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.BuyOrderProductDao;
|
||||
import com.peanut.modules.book.dao.ExpressOrderDao;
|
||||
import com.peanut.modules.book.dao.ShopProductBookDao;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.to.UserOrderDto;
|
||||
@@ -61,6 +64,9 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
@Autowired
|
||||
ShopProductService shopProductService;
|
||||
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
@Autowired
|
||||
private BuyOrderProductService buyOrderProductService;
|
||||
|
||||
@@ -72,7 +78,13 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
@Autowired
|
||||
private ExpressOrderDao expressOrderDao;
|
||||
@Autowired
|
||||
private BuyOrderProductDao buyOrderProductDao;
|
||||
@Autowired
|
||||
private ShopProductBookDao shopProductBookDao;
|
||||
@Autowired
|
||||
private OssService ossService;
|
||||
@Autowired
|
||||
private ShopProductBookService shopProductBookService;
|
||||
|
||||
protected Logger logger = LoggerFactory.getLogger(BuyOrderServiceImpl.class);
|
||||
|
||||
@@ -404,7 +416,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
ShopProduct product = shopProductService.getById(productId);
|
||||
//定义快递商品
|
||||
ExpressCommodity commodity = new ExpressCommodity();
|
||||
commodity.setGoodsName(product.getProductName());
|
||||
commodity.setGoodsName(product.getProductName()+" ×"+buyOrderProduct.getQuantity());
|
||||
commodity.setGoodsquantity(buyOrderProduct.getQuantity());
|
||||
commodity.setGoodsWeight((product.getWeight().doubleValue())/1000);
|
||||
totalWeight = totalWeight.add(
|
||||
@@ -607,6 +619,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
goodsResponseVo.setProductImage(shopProduct.getProductImages());
|
||||
goodsResponseVo.setProductPrice(shopProduct.getPrice());
|
||||
goodsResponseVo.setQuantity(buyOrderProduct.getQuantity());
|
||||
goodsResponseVo.setProductId(shopProduct.getProductId());
|
||||
QueryWrapper<ExpressOrder> expressOrderQueryWrapper = new QueryWrapper<>();
|
||||
expressOrderQueryWrapper.eq("id", buyOrderProduct.getExpressOrderId());
|
||||
ExpressOrder expressOrder = expressOrderService.getOne(expressOrderQueryWrapper);
|
||||
@@ -617,6 +630,11 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
expressResponseVo.setPrintTemplate(expressOrder.getPrintTemplate());
|
||||
}
|
||||
goodsResponseVo.setExpressInfo(expressResponseVo);
|
||||
|
||||
//设置商品对应的具体书
|
||||
List<BookEntity> bookByProductId = shopProductBookService.getBookByProductId(buyOrderProduct.getProductId());
|
||||
goodsResponseVo.setBooks(bookByProductId);
|
||||
|
||||
goodsResponseVoList.add(goodsResponseVo);
|
||||
}
|
||||
responseVo.setGoodsList(goodsResponseVoList);
|
||||
@@ -628,6 +646,25 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
|
||||
List<Integer> collect = buyOrderProductService.getBaseMapper().selectList(b_wrapper).stream().map(BuyOrderProduct::getExpressOrderId).collect(Collectors.toList());
|
||||
if(collect.size()>0){
|
||||
List<ExpressOrder> expressOrders = expressOrderService.getBaseMapper().selectList(new LambdaQueryWrapper<ExpressOrder>().in(ExpressOrder::getId, collect));
|
||||
for (ExpressOrder e : expressOrders){
|
||||
MPJLambdaWrapper<BuyOrderProduct> buyOrderProductMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
||||
buyOrderProductMPJLambdaWrapper.selectAll(ShopProduct.class);
|
||||
buyOrderProductMPJLambdaWrapper.select(BuyOrderProduct::getQuantity);
|
||||
buyOrderProductMPJLambdaWrapper.select(BuyOrder::getOrderSn);
|
||||
buyOrderProductMPJLambdaWrapper.leftJoin(ShopProduct.class,ShopProduct::getProductId,BuyOrderProduct::getProductId);
|
||||
buyOrderProductMPJLambdaWrapper.leftJoin(BuyOrder.class,BuyOrder::getOrderId,BuyOrderProduct::getOrderId);
|
||||
buyOrderProductMPJLambdaWrapper.eq(BuyOrderProduct::getExpressOrderId,e.getId());
|
||||
List<ShopProduct> shopProducts = buyOrderProductDao.selectJoinList(ShopProduct.class, buyOrderProductMPJLambdaWrapper);
|
||||
for(ShopProduct s : shopProducts){
|
||||
MPJLambdaWrapper<ShopProductBookEntity> shopProductBookEntityMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
||||
shopProductBookEntityMPJLambdaWrapper.selectAll(BookEntity.class);
|
||||
shopProductBookEntityMPJLambdaWrapper.leftJoin(BookEntity.class,BookEntity::getId,ShopProductBookEntity::getBookId);
|
||||
shopProductBookEntityMPJLambdaWrapper.eq(ShopProductBookEntity::getProductId,s.getProductId());
|
||||
List<BookEntity> bookEntities = shopProductBookDao.selectJoinList(BookEntity.class, shopProductBookEntityMPJLambdaWrapper);
|
||||
s.setBooks(bookEntities);
|
||||
}
|
||||
e.setProducts(shopProducts);
|
||||
}
|
||||
responseVo.setExpressOrders(expressOrders);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ExpressOrderServiceImpl extends ServiceImpl<ExpressOrderDao, Expres
|
||||
orderRequestVo.setCustomerName(Constants.EXPRESS_YD_CUSTOMER_NAME);
|
||||
orderRequestVo.setCustomerPwd(Constants.EXPRESS_YD_CUSTOMER_PWD);
|
||||
}
|
||||
orderRequestVo.setExpType(2);//1特快2标快
|
||||
orderRequestVo.setExpType(231);//1特快2标快
|
||||
orderRequestVo.setCost(expressOrder.getExpressFee().doubleValue());
|
||||
// 发货人
|
||||
ExpressUserInfoVo sender = new ExpressUserInfoVo();
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service("shopProductBookService")
|
||||
public class ShopProductBookServiceImpl extends ServiceImpl<ShopProductBookDao, ShopProductBookEntity> implements ShopProductBookService {
|
||||
@@ -87,6 +88,12 @@ public class ShopProductBookServiceImpl extends ServiceImpl<ShopProductBookDao,
|
||||
return ids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookEntity> getBookByProductId(Integer productId) {
|
||||
List<Integer> collect = getBaseMapper().selectList(new QueryWrapper<ShopProductBookEntity>().eq("product_id", productId)).stream().map(ShopProductBookEntity::getBookId).collect(Collectors.toList());
|
||||
return collect.size()==0?null:bookService.list(new LambdaQueryWrapper<BookEntity>().in(BookEntity::getId, collect));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getProductByBookId(Integer bookId) {
|
||||
LambdaQueryWrapper<ShopProductBookEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.peanut.modules.book.vo.response;
|
||||
|
||||
import com.peanut.modules.book.entity.BookEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 商品信息 Value Object
|
||||
@@ -11,6 +13,8 @@ import java.math.BigDecimal;
|
||||
*/
|
||||
@Data
|
||||
public class GoodsResponseVo {
|
||||
private Integer ProductId;
|
||||
|
||||
private Integer buyOrderProductId;
|
||||
/**
|
||||
* 商品名称
|
||||
@@ -32,4 +36,8 @@ public class GoodsResponseVo {
|
||||
* 快递
|
||||
*/
|
||||
private ExpressResponseVo expressInfo;
|
||||
/**
|
||||
* 对应的书list
|
||||
*/
|
||||
private List<BookEntity> books;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ connection-timeout: 6000000ms
|
||||
spring:
|
||||
# 环境 dev|test|prod
|
||||
profiles:
|
||||
active: dev
|
||||
active: prod
|
||||
# jackson时间格式化
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
|
||||
@@ -5,7 +5,7 @@ wxpay.mchId:1612860909
|
||||
# ?? URL
|
||||
wxpay.payUrl:https://api.mch.weixin.qq.com/v3/pay/transactions/app
|
||||
# ????
|
||||
wxpay.notifyUrl:https://testapi.nuttyreading.com/pay/payNotify
|
||||
wxpay.notifyUrl:https://api.nuttyreading.com/pay/payNotify
|
||||
# ?? url
|
||||
wxpay.refundNotifyUrl:http://pjm6m9.natappfree.cc/pay/refundNotify
|
||||
# key pem
|
||||
|
||||
Reference in New Issue
Block a user