新版
This commit is contained in:
@@ -59,6 +59,8 @@ public class BookController {
|
|||||||
private ShopProductService shopProductService;
|
private ShopProductService shopProductService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ShopProudictBookService shopProudictBookService;
|
private ShopProudictBookService shopProudictBookService;
|
||||||
|
@Autowired
|
||||||
|
private ShopProductToLabelService shopProductToLabelService;
|
||||||
final ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10);
|
final ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,6 +84,21 @@ public class BookController {
|
|||||||
return R.ok().put("page", page);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
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.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
|
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
|
||||||
@@ -71,6 +72,8 @@ public class BuyOrderController {
|
|||||||
private PayWechatOrderService payWechatOrderService;
|
private PayWechatOrderService payWechatOrderService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private PayZfbOrderService payZfbOrderService;
|
private PayZfbOrderService payZfbOrderService;
|
||||||
|
@Autowired
|
||||||
|
private ShopProudictBookService shopProudictBookService;
|
||||||
// @Autowired
|
// @Autowired
|
||||||
// private
|
// private
|
||||||
/**
|
/**
|
||||||
@@ -255,6 +258,15 @@ public class BuyOrderController {
|
|||||||
transactionDetailsEntity.setOrderType("购买健康超市用品!");
|
transactionDetailsEntity.setOrderType("购买健康超市用品!");
|
||||||
transactionDetailsService.save(transactionDetailsEntity);
|
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{
|
}else{
|
||||||
return R.error("余额不足!");
|
return R.error("余额不足!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ public class ShopProductLabelController {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ShopProductLabelService shopProductLabelService;
|
private ShopProductLabelService shopProductLabelService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ShopProductToLabelService shopProductToLabelService;
|
private ShopProductToLabelService shopProductToLabelService;
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -113,6 +112,7 @@ public class ShopProductLabelController {
|
|||||||
MPJLambdaWrapper<ShopProductToLabelEntity> shopProductEntityMPJLambdaWrapper = new MPJLambdaWrapper<ShopProductToLabelEntity>();
|
MPJLambdaWrapper<ShopProductToLabelEntity> shopProductEntityMPJLambdaWrapper = new MPJLambdaWrapper<ShopProductToLabelEntity>();
|
||||||
shopProductEntityMPJLambdaWrapper.selectAll(ShopProductEntity.class);
|
shopProductEntityMPJLambdaWrapper.selectAll(ShopProductEntity.class);
|
||||||
shopProductEntityMPJLambdaWrapper.leftJoin(ShopProductEntity.class,ShopProductEntity::getProductId,ShopProductToLabelEntity::getProductId);
|
shopProductEntityMPJLambdaWrapper.leftJoin(ShopProductEntity.class,ShopProductEntity::getProductId,ShopProductToLabelEntity::getProductId);
|
||||||
|
shopProductEntityMPJLambdaWrapper.eq(ShopProductToLabelEntity::getSplId,splId);
|
||||||
shopProductEntityMPJLambdaWrapper.eq(ShopProductToLabelEntity::getDelFlag,0);
|
shopProductEntityMPJLambdaWrapper.eq(ShopProductToLabelEntity::getDelFlag,0);
|
||||||
shopProductEntityMPJLambdaWrapper.eq(ShopProductEntity::getDelFlag,0);
|
shopProductEntityMPJLambdaWrapper.eq(ShopProductEntity::getDelFlag,0);
|
||||||
Page<ShopProductEntity> shopProductEntityPage = shopProductToLabelDao.selectJoinPage(new Page<ShopProductEntity>(page, limit), ShopProductEntity.class, shopProductEntityMPJLambdaWrapper);
|
Page<ShopProductEntity> shopProductEntityPage = shopProductToLabelDao.selectJoinPage(new Page<ShopProductEntity>(page, limit), ShopProductEntity.class, shopProductEntityMPJLambdaWrapper);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
import com.peanut.common.utils.PageUtils;
|
import com.peanut.common.utils.PageUtils;
|
||||||
import com.peanut.modules.book.entity.UserEbookBuyEntity;
|
import com.peanut.modules.book.entity.UserEbookBuyEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,6 +20,8 @@ public interface UserEbookBuyService extends IService<UserEbookBuyEntity> {
|
|||||||
|
|
||||||
PageUtils queryPages(Map<String, Object> params);
|
PageUtils queryPages(Map<String, Object> params);
|
||||||
|
|
||||||
|
void addBookForUser(Integer userId, List<Integer> bookIds);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.peanut.modules.book.service.impl;
|
package com.peanut.modules.book.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.peanut.modules.book.entity.BuyOrderEntity;
|
import com.peanut.modules.book.entity.BuyOrderEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
@@ -45,23 +47,17 @@ public class UserEbookBuyServiceImpl extends ServiceImpl<UserEbookBuyDao, UserEb
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addBookForUser(Integer userId, List<Integer> bookIds) {
|
||||||
|
for (Integer i:bookIds){
|
||||||
|
List<UserEbookBuyEntity> userEbookBuyEntities = this.getBaseMapper().selectList(new LambdaQueryWrapper<UserEbookBuyEntity>().eq(UserEbookBuyEntity::getUserId, userId).eq(UserEbookBuyEntity::getBookId, i));
|
||||||
|
if(userEbookBuyEntities.size()==0){
|
||||||
|
UserEbookBuyEntity userEbookBuyEntity = new UserEbookBuyEntity();
|
||||||
|
userEbookBuyEntity.setUserId(userId);
|
||||||
|
userEbookBuyEntity.setBookId(i);
|
||||||
|
userEbookBuyEntity.setPayTime(new Date());
|
||||||
|
this.save(userEbookBuyEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user