记得上下班打卡 | git大法好,push需谨慎

Commit 9961ef97 authored by zhengfuxin's avatar zhengfuxin

音乐人标签

parent 15085883
......@@ -87,6 +87,12 @@ public class GoblinFrontController {
return ResponseDto.success( goblinFrontService.getCategoryList(type,categoryId,page,pageSize));
}
@GetMapping("getMusicList")
@ApiOperation("获取音乐标签列表( 1、销量优先、2、新品优先、3、价格降序、4、价格升序)")
public ResponseDto<GoblinFrontCategoryListVo> getMusicList(@RequestParam(name = "type", required = true) String type,@RequestParam(name = "musicId", required = true)String musicId,@RequestParam(name = "page", required = true)int page,@RequestParam(name = "pageSize", required = true)int pageSize) throws ParseException {
return ResponseDto.success( goblinFrontService.getMusic(musicId,type,page,pageSize));
}
@GetMapping("getCategory")
@ApiOperation("获取分类子集")
public ResponseDto getCategory(@RequestParam(name = "categoryId", required = true)String categoryId) throws ParseException {
......
......@@ -316,6 +316,57 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
}
/**
*音乐人列表
*/
public GoblinFrontCategoryListVo getMusic(String tagId,String type,int page,int pageSize){
//
Query query = new Query();
query.addCriteria(new Criteria().orOperator(
Criteria.where("extagVoList.tagId").is(tagId)
));
Pageable pageable=null;
//
boolean isRe=false;
if(type.equals("1")){
isRe=true;
}else if(type.equals("2")){
pageable = PageRequest.of(page, pageSize, Sort.by(Sort.Direction.DESC, "shelvesAt"));
}else if(type.equals("3")){
pageable = PageRequest.of(page, pageSize, Sort.by(Sort.Direction.DESC, "priceGe"));
}else if(type.equals("4")){
pageable = PageRequest.of(page, pageSize, Sort.by(Sort.Direction.ASC, "priceGe"));
}
// 排序 分页
// Query query = Query.query(Criteria.where("status").ne(1).and("status").ne(0));
// 查询总数
long count = mongoTemplate.count(query, GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName());
if(!isRe){
query.with(pageable);
}
List<GoblinGoodsInfoVo> list = mongoTemplate.find(query, GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName());
if(list.size()>0&&isRe){
//找到 销量
for(GoblinGoodsInfoVo goblinGoodsInfoVo:list){
Integer counts=goblinRedisUtils.getSpuSaleCount(goblinGoodsInfoVo.getSpuId());
if(counts==null){
goblinGoodsInfoVo.setCount(0);
}else{
goblinGoodsInfoVo.setCount(counts);
}
}
Collections.sort(list, new Comparator<GoblinGoodsInfoVo>() {
public int compare(GoblinGoodsInfoVo arg0, GoblinGoodsInfoVo arg1) {
return -(arg0.getCount().compareTo(arg1.getCount()));
}});
}
GoblinFrontCategoryListVo goblinFrontCategoryListVo=GoblinFrontCategoryListVo.getNew();
goblinFrontCategoryListVo.setCount(count);
goblinFrontCategoryListVo.setSpuList(list);
return goblinFrontCategoryListVo;
}
/**
* 获取分类列表
* 1、销量优先、2、新品优先、3、价格降序、4、价格升序
......@@ -451,6 +502,9 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
* @date 2022/1/11 下午4:16
*/
public boolean addShoopCart(String spuId, String storeId,String skuId,Integer number,String userId){
if(null==number||number<=0){
return false;
}
boolean isGoods=false;
String cardId="";
//判断该用户 redis里是否有购物车
......@@ -465,7 +519,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
//该商铺下的所有商品
ArrayList<GoblinShoppingCartVoDetail> list1=ObjectUtil.goblinShoppingCartVoDetailArrayList();
//创建 购物车vo
GoblinShoppingCartVoDetail goblinShoppingCartVoDetail=this.setValue(userId,storeId,spuId,skuId,1);
GoblinShoppingCartVoDetail goblinShoppingCartVoDetail=this.setValue(userId,storeId,spuId,skuId,number);
list1.add(goblinShoppingCartVoDetail);
goblinShoppingCartVo.setSkuList(list1);
list.add(goblinShoppingCartVo);
......@@ -486,7 +540,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
for(GoblinShoppingCartVoDetail goblinShoppingCartVoDetail:list1){
if(skuId.equals(goblinShoppingCartVoDetail.getSkuId())){
isGoods=true;
goblinShoppingCartVoDetail.setNumber((goblinShoppingCartVoDetail.getNumber()+1));
goblinShoppingCartVoDetail.setNumber((goblinShoppingCartVoDetail.getNumber()+number));
cardId=goblinShoppingCartVoDetail.getCarId();
}
}
......@@ -495,7 +549,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
//不需要做
}else{
//创建商品放入到list
GoblinShoppingCartVoDetail goblinShoppingCartVoDetail=this.setValue(userId,storeId,spuId,skuId,1);
GoblinShoppingCartVoDetail goblinShoppingCartVoDetail=this.setValue(userId,storeId,spuId,skuId,number);
cardId=goblinShoppingCartVoDetail.getCarId();
list1.add(goblinShoppingCartVoDetail);
}
......@@ -517,7 +571,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
if(isGoods){
updateShopCartMysql(cardId,number,userId);
}else{
insertShopCartMysql(cardId,spuId,storeId,skuId,1,userId);
insertShopCartMysql(cardId,spuId,storeId,skuId,number,userId);
}
}
return true;
......@@ -528,6 +582,9 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
* @date 2022/1/11 下午6:24
*/
public boolean updateShopCart(String spuId, String storeId,String skuId,Integer number,String userId){
if(null==number||number<=0){
return false;
}
GoblinShoppingCartVoo goblinShoppingCartVoo= (GoblinShoppingCartVoo) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART.concat(userId));
String cardId="";
if(null!=goblinShoppingCartVoo){
......@@ -553,6 +610,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
}
public int getShopCartCount(String userId){
log.info("获取商品数量{}",userId);
int count=0;
GoblinShoppingCartVoo goblinShoppingCartVoo= (GoblinShoppingCartVoo) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART.concat(userId));
if(null!=goblinShoppingCartVoo){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment