feat:在线商城部分远程接口
This commit is contained in:
1 parent
52f97ef0f6
commit
aa464ee2d2
6 files changed
+170
-3
No files matched your search
+30
@@ -0,0 +1,30 @@
|
||||
package com.bsd.pjcloud.supermarket.api.feign;
|
||||
|
||||
|
||||
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.supermarket.vo.ShopCategoryTreeVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.erp.SmErpCategorySimpleVo;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zjf
|
||||
* @date 2018/6/22
|
||||
*/
|
||||
@FeignClient(contextId = "remoteShopCategoryService", value = ServiceNameConstants.SUPERMARKET_SERVICE)
|
||||
public interface RemoteShopCategoryService {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有分类列表(树形结构)
|
||||
* @return R
|
||||
*/
|
||||
@GetMapping("/app/shopCategory/list")
|
||||
R<List<ShopCategoryTreeVo>> appCategoryList();
|
||||
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.supermarket.api.feign;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.supermarket.dto.SupermarketSpuQueryDTO;
|
||||
import com.bsd.pjcloud.supermarket.dto.SupermarketSpuUpdateStockByCodeReqDTO;
|
||||
import com.bsd.pjcloud.supermarket.dto.SupermarketSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.supermarket.vo.ad.SmErpSpuDetailsVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.ad.SpuVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.app.ShopSpuDetailAppVo;
|
||||
import com.bsd.pjcloud.supermarket.vo.app.ShopSpuListAppVo;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zjf
|
||||
* @date 2018/6/22
|
||||
*/
|
||||
@FeignClient(contextId = "remoteShopSpuService", value = ServiceNameConstants.SUPERMARKET_SERVICE)
|
||||
public interface RemoteShopSpuService {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 商品分页
|
||||
* @return R
|
||||
*/
|
||||
@GetMapping("/app/shopSpu/page")
|
||||
R<Page<ShopSpuListAppVo>> page(@RequestParam Page page,
|
||||
@RequestParam(required = false) Long categoryId,
|
||||
@RequestParam(required = false) String keyword,
|
||||
@RequestParam(required = false) String merchantId);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据spu id 查询spu详情,详情包括辅助条码和包装单位基本信息
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/app/shopSpu/spuDetails")
|
||||
R<List<ShopSpuDetailAppVo>> getShopSpuDetailByIds(@RequestParam List<Long> ids);
|
||||
|
||||
|
||||
/**
|
||||
* 更新库存
|
||||
* @return
|
||||
*/
|
||||
/**
|
||||
* 根据skuId和数量扣减库存
|
||||
* @param skuId
|
||||
* @param num * 正数:增加库存,负数:扣减库存
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/app/shopSpu/deductStock")
|
||||
R<Boolean> deductStock(@RequestParam Long skuId, @RequestParam Integer num);
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有的超市spu列表信息,根据条件
|
||||
* @return R
|
||||
*/
|
||||
// @PostMapping("/supermarketSpu/app/selectListAll")
|
||||
// R getSupermarketSpu(@RequestBody SupermarketSpuQueryDTO supermarketSpuQueryDTO);
|
||||
|
||||
|
||||
/**
|
||||
* 购物车效验库存
|
||||
* @param spuId
|
||||
* @param incrCount 扣减数量,正数负数都行
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/app/shopSpu/checkSpuStock")
|
||||
R<Boolean> checkSpuStock(@RequestParam(value ="spuId")Long spuId,@RequestParam("incrCount")Integer incrCount);
|
||||
|
||||
}
|
||||
+1
-1
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
* @author zjf
|
||||
* @date 2018/6/22
|
||||
*/
|
||||
@FeignClient(contextId = "remoteSupermarketCategoryServic", value = ServiceNameConstants.SUPERMARKET_SERVICE)
|
||||
@FeignClient(contextId = "remoteSupermarketCategoryService", value = ServiceNameConstants.SUPERMARKET_SERVICE)
|
||||
public interface RemoteSupermarketCategoryService {
|
||||
|
||||
|
||||
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketCategoryService
|
||||
com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketSpuService
|
||||
com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketUnitSkuService
|
||||
com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketUnitSkuService
|
||||
com.bsd.pjcloud.supermarket.api.feign.RemoteShopCategoryService
|
||||
com.bsd.pjcloud.supermarket.api.feign.RemoteShopSpuService
|
||||
+32
@@ -9,6 +9,8 @@ import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.supermarket.entity.ShopSpuEntity;
|
||||
import com.bsd.pjcloud.supermarket.entity.ShopSkuEntity;
|
||||
import com.bsd.pjcloud.supermarket.entity.SmErpSpuEntity;
|
||||
import com.bsd.pjcloud.supermarket.entity.SmErpStockEntity;
|
||||
import com.bsd.pjcloud.supermarket.service.ShopSpuService;
|
||||
import com.bsd.pjcloud.supermarket.service.ShopSkuService;
|
||||
import com.bsd.pjcloud.supermarket.vo.app.ShopSpuListAppVo;
|
||||
@@ -19,6 +21,8 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -84,10 +88,38 @@ public class AppShopSpuController {
|
||||
return R.ok(vo);
|
||||
}
|
||||
|
||||
@GetMapping("/spuDetails")
|
||||
@Operation(summary = "商品详情", description = "根据SpuIds获取商品详情")
|
||||
public R<List<ShopSpuDetailAppVo>> getShopSpuDetailByIds(@RequestParam List<Long> ids) {
|
||||
List<ShopSpuEntity> shopSpuEntities = shopSpuService.listByIdsDeep(ids);
|
||||
List<ShopSpuDetailAppVo> shopSpuDetailAppVos = new ArrayList<>();
|
||||
for (ShopSpuEntity shopSpuEntity : shopSpuEntities) {
|
||||
ShopSpuDetailAppVo shopSpuDetailAppVo = BeanUtils.toBean(shopSpuEntity, ShopSpuDetailAppVo.class);
|
||||
shopSpuDetailAppVos.add(shopSpuDetailAppVo);
|
||||
// 查询sku列表
|
||||
List<ShopSkuEntity> skuList = shopSkuService.list(Wrappers.<ShopSkuEntity>lambdaQuery().eq(ShopSkuEntity::getSpuId, shopSpuEntity.getId()));
|
||||
shopSpuDetailAppVo.setSkuList(skuList.stream().map(sku -> BeanUtils.toBean(sku, ShopSkuAppVo.class)).collect(Collectors.toList()));
|
||||
shopSpuDetailAppVos.add(shopSpuDetailAppVo);
|
||||
}
|
||||
return R.ok(shopSpuDetailAppVos);
|
||||
}
|
||||
|
||||
@PostMapping("/deductStock")
|
||||
@Operation(summary = "扣减库存", description = "根据skuId和数量扣减库存")
|
||||
public R<Boolean> deductStock(@RequestParam Long skuId, @RequestParam Integer num) {
|
||||
boolean result = shopSkuService.deductStock(skuId, num);
|
||||
return result ? R.ok(true) : R.failed("库存不足或扣减失败");
|
||||
}
|
||||
|
||||
@GetMapping("/checkSpuStock")
|
||||
@Operation(summary = "检查商品库存", description = "检查商品库存")
|
||||
public R<Boolean> checkSpuStock(@RequestParam(value ="skuId")Long skuId,@RequestParam("incrCount")Integer incrCount) {
|
||||
ShopSkuEntity shopSkuEntity = shopSkuService.getById(skuId);
|
||||
if (shopSkuEntity == null) return R.failed("商品sku不存在");
|
||||
if (shopSkuEntity.getStock()<Math.abs(incrCount)){
|
||||
return R.failed("库存不足");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -87,7 +87,7 @@ public class SmErpSpuController {
|
||||
wrapper.eq(StringUtils.isNotBlank(supermarketSpu.getProductCode()), SmErpSpuEntity::getProductCode,supermarketSpu.getProductCode());
|
||||
wrapper.eq(StringUtils.isNotBlank(supermarketSpu.getBarCode()), SmErpSpuEntity::getBarCode,supermarketSpu.getBarCode());
|
||||
wrapper.like(StringUtils.isNotBlank(supermarketSpu.getProductName()), SmErpSpuEntity::getProductName,supermarketSpu.getProductName());
|
||||
wrapper.orderByDesc(SmErpSpuEntity::getCreateTime);
|
||||
wrapper.orderByDesc(SmErpSpuEntity::getCreateTime).orderByDesc(SmErpSpuEntity::getId);
|
||||
return R.ok(smErpSpuService.pageScope(page, wrapper));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user