This commit is contained in:
wangjinlei
2023-10-07 10:56:27 +08:00
parent fb7016d471
commit 880c412b19
5 changed files with 48 additions and 20 deletions

View File

@@ -59,6 +59,8 @@ public class BookController {
private ShopProductService shopProductService;
@Autowired
private ShopProudictBookService shopProudictBookService;
@Autowired
private ShopProductToLabelService shopProductToLabelService;
final ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10);
/**
@@ -82,6 +84,21 @@ public class BookController {
return R.ok().put("page", page);
}
/**
* 获取精品图书
* @return
*/
@RequestMapping("/getJPBooks")
public R getJPBooks(){
LambdaQueryWrapper<ShopProductToLabelEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ShopProductToLabelEntity::getSplId,5);//精选图书
wrapper.eq(ShopProductToLabelEntity::getDelFlag,0);
List<Integer> pIds = shopProductToLabelService.getBaseMapper().selectList(wrapper).stream().map(ShopProductToLabelEntity::getProductId).collect(Collectors.toList());
List<ShopProductEntity> shopProductEntities = shopProductService.getBaseMapper().selectList(new LambdaQueryWrapper<ShopProductEntity>().in(ShopProductEntity::getProductId, pIds));
return R.ok().put("Products",shopProductEntities);
}
/**

View File

@@ -7,6 +7,7 @@ import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
@@ -71,6 +72,8 @@ public class BuyOrderController {
private PayWechatOrderService payWechatOrderService;
@Autowired
private PayZfbOrderService payZfbOrderService;
@Autowired
private ShopProudictBookService shopProudictBookService;
// @Autowired
// private
/**
@@ -255,6 +258,15 @@ public class BuyOrderController {
transactionDetailsEntity.setOrderType("购买健康超市用品!");
transactionDetailsService.save(transactionDetailsEntity);
//购买成功后,添加书到个人表中
List<Integer> pros = products.stream().map(BuyOrderDetailEntity::getProductId).collect(Collectors.toList());
for (Integer s : pros){
List<Integer> collect = shopProudictBookService.getBaseMapper().selectList(new LambdaQueryWrapper<ShopProudictBookEntity>()
.eq(ShopProudictBookEntity::getProudictId, s)
.eq(ShopProudictBookEntity::getDelFlag, 0)).stream().map(ShopProudictBookEntity::getBookId).collect(Collectors.toList());
userEbookBuyService.addBookForUser(buyOrder.getUserId(),collect);
}
}else{
return R.error("余额不足!");
}

View File

@@ -29,7 +29,6 @@ public class ShopProductLabelController {
@Autowired
private ShopProductLabelService shopProductLabelService;
@Autowired
private ShopProductToLabelService shopProductToLabelService;
@Autowired
@@ -113,6 +112,7 @@ public class ShopProductLabelController {
MPJLambdaWrapper<ShopProductToLabelEntity> shopProductEntityMPJLambdaWrapper = new MPJLambdaWrapper<ShopProductToLabelEntity>();
shopProductEntityMPJLambdaWrapper.selectAll(ShopProductEntity.class);
shopProductEntityMPJLambdaWrapper.leftJoin(ShopProductEntity.class,ShopProductEntity::getProductId,ShopProductToLabelEntity::getProductId);
shopProductEntityMPJLambdaWrapper.eq(ShopProductToLabelEntity::getSplId,splId);
shopProductEntityMPJLambdaWrapper.eq(ShopProductToLabelEntity::getDelFlag,0);
shopProductEntityMPJLambdaWrapper.eq(ShopProductEntity::getDelFlag,0);
Page<ShopProductEntity> shopProductEntityPage = shopProductToLabelDao.selectJoinPage(new Page<ShopProductEntity>(page, limit), ShopProductEntity.class, shopProductEntityMPJLambdaWrapper);