Merge branch 'master' of http://124.223.211.244:8418/zianxin/biz-api-cloud
This commit is contained in:
commit
732ee6b6fd
11 files changed
+137
-16
No files matched your search
+10
@@ -21,6 +21,7 @@ package com.bsd.pjcloud.canteen.api.feign;
|
||||
|
||||
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenOnlineSpuEntity;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenSpuEntity;
|
||||
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
@@ -66,4 +67,13 @@ public interface RemoteCanteenSpuService {
|
||||
@PostMapping("/canteenSpu/ad/getSpuListByIds")
|
||||
R<List<CanteenSpuEntity>> getSpuListByIds(@RequestBody List<Long> ids);
|
||||
|
||||
/**
|
||||
* 购物车效验库存
|
||||
* @param spuId
|
||||
* @param incrCount 扣减数量,正数负数都行
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/canteenSpu/app/checkSpuStock")
|
||||
R checkSpuStock(@RequestParam(value ="spuId")Long spuId,@RequestParam("incrCount")Integer incrCount);
|
||||
|
||||
}
|
||||
+11
@@ -21,6 +21,7 @@ package com.bsd.pjcloud.canteen.api.feign;
|
||||
|
||||
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenOnlineSpuEntity;
|
||||
import com.bsd.pjcloud.canteen.vo.APPOnlineSpuVO;
|
||||
import com.bsd.pjcloud.canteen.vo.app.CanteenOnlineSpuAppVO;
|
||||
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
|
||||
@@ -76,4 +77,14 @@ public interface RemoteOnlineCanteenSpuService {
|
||||
@PostMapping("/canteenOnlineSpu/app/getSpuListByIds")
|
||||
R<List<CanteenOnlineSpuAppVO>> getSpuListByIds(@RequestBody List<Long> ids);
|
||||
|
||||
|
||||
/**
|
||||
* 购物车效验库存
|
||||
* @param spuId
|
||||
* @param incrCount 扣减数量,正数负数都行
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/canteenOnlineSpu/app/checkSpuStock")
|
||||
R checkSpuStock(@RequestParam(value ="spuId")Long spuId,@RequestParam("incrCount")Integer incrCount);
|
||||
|
||||
}
|
||||
+11
@@ -33,4 +33,15 @@ public class DailyMenuVO {
|
||||
* 时间类型
|
||||
*/
|
||||
private Integer hourType;
|
||||
|
||||
/**
|
||||
* 价格
|
||||
*/
|
||||
private Integer price;
|
||||
|
||||
|
||||
/**
|
||||
* 分类id
|
||||
*/
|
||||
private Long categoryId;
|
||||
}
|
||||
+16
@@ -23,6 +23,7 @@ import org.springframework.http.HttpHeaders;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -153,9 +154,24 @@ public class CanteenOnlineSpuController {
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/app/checkSpuStock")
|
||||
@SysLog("购物车效验库存")
|
||||
@Transactional
|
||||
public R checkSpuStock(@RequestParam(value ="spuId")Long spuId,@RequestParam("incrCount")Integer incrCount) {
|
||||
CanteenOnlineSpuEntity canteenOnlineSpuEntity = canteenOnlineSpuService.getById(spuId);
|
||||
if (canteenOnlineSpuEntity == null) {
|
||||
R.failed("商品不存在");
|
||||
}
|
||||
if (canteenOnlineSpuEntity.getStock()<Math.abs(incrCount)){
|
||||
return R.failed("库存不足");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/app/updateSkuStock")
|
||||
@SysLog("更新菜品库存")
|
||||
@Transactional
|
||||
public R updateSkuStock(@RequestBody CanteenOnlineSpuUpdateStockReqDTO canteenOnlineSpuUpdateStockReqDTO) {
|
||||
return canteenOnlineSpuService.updateOnlineSpuSkuStock(canteenOnlineSpuUpdateStockReqDTO);
|
||||
}
|
||||
|
||||
+18
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenOnlineSpuEntity;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenSpuEntity;
|
||||
@@ -20,6 +21,7 @@ import org.springframework.http.HttpHeaders;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -144,6 +146,7 @@ public class CanteenSpuController {
|
||||
return canteenSpuService.getCanteenSpuList(categoryId);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/ad/updateSkuStock")
|
||||
@SysLog("更新菜品库存")
|
||||
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_edit')")
|
||||
@@ -163,4 +166,19 @@ public class CanteenSpuController {
|
||||
List<CanteenSpuEntity> list = canteenSpuService.list(new LambdaQueryWrapper<CanteenSpuEntity>().in(CanteenSpuEntity::getId, ids));
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/app/checkSpuStock")
|
||||
@SysLog("购物车效验库存")
|
||||
@Transactional
|
||||
public R checkSpuStock(@RequestParam(value ="spuId")Long spuId,@RequestParam("incrCount")Integer incrCount) {
|
||||
CanteenSpuEntity canteenSpuEntity = canteenSpuService.getById(spuId);
|
||||
if (canteenSpuEntity == null) {
|
||||
R.failed("商品不存在");
|
||||
}
|
||||
if (canteenSpuEntity.getStock()<Math.abs(incrCount)){
|
||||
return R.failed("库存不足");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
+14
-5
@@ -37,12 +37,21 @@ public class CanteenOnlineSpuServiceImpl extends ServiceImpl<CanteenOnlineSpuMap
|
||||
public R updateOnlineSpuSkuStock(CanteenOnlineSpuUpdateStockReqDTO canteenOnlineSpuUpdateStockReqDTO) {
|
||||
// 更新 SKU 库存
|
||||
canteenOnlineSpuUpdateStockReqDTO.getItems().forEach(item -> {
|
||||
int i = baseMapper.updateStock(item.getId(), item.getIncrCount());
|
||||
if (item.getIncrCount() <= 0) {
|
||||
if (i == 0) {
|
||||
R.failed("商品库存不足");
|
||||
}
|
||||
// 查询当前库存
|
||||
CanteenOnlineSpuEntity spu = baseMapper.selectById(item.getId());
|
||||
if (spu == null) {
|
||||
R.failed(spu.getName()+"商品不存在");
|
||||
}
|
||||
// 检查库存是否足够
|
||||
if (item.getIncrCount() < 0 && Math.abs(item.getIncrCount()) > spu.getStock()) {
|
||||
R.failed(spu.getName()+"库存不足,无法完成操作");
|
||||
}
|
||||
int i = baseMapper.updateStock(item.getId(), item.getIncrCount());
|
||||
// if (item.getIncrCount() <= 0) {
|
||||
// if (i == 0) {
|
||||
// R.failed("商品库存不足");
|
||||
// }
|
||||
// }
|
||||
});
|
||||
|
||||
return R.ok();
|
||||
|
||||
+15
-5
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenOnlineSpuEntity;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenSpuEntity;
|
||||
import com.bsd.pjcloud.canteen.mapper.CanteenSpuMapper;
|
||||
import com.bsd.pjcloud.canteen.service.CanteenDailyMenuService;
|
||||
@@ -39,12 +40,21 @@ public class CanteenSpuServiceImpl extends ServiceImpl<CanteenSpuMapper, Canteen
|
||||
public R updateSkuStock(CanteenSpuUpdateStockReqDTO updateStockReqDTO) {
|
||||
// 更新 SKU 库存
|
||||
updateStockReqDTO.getItems().forEach(item -> {
|
||||
int i = baseMapper.updateStock(item.getId(), item.getIncrCount());
|
||||
if (item.getIncrCount() <= 0) {
|
||||
if (i == 0) {
|
||||
R.failed("商品库存不足");
|
||||
}
|
||||
// 查询当前库存
|
||||
CanteenSpuEntity spu = baseMapper.selectById(item.getId());
|
||||
if (spu == null) {
|
||||
R.failed(spu.getName()+"商品不存在");
|
||||
}
|
||||
// 检查库存是否足够
|
||||
if (item.getIncrCount() < 0 && Math.abs(item.getIncrCount()) > spu.getStock()) {
|
||||
R.failed(spu.getName()+"库存不足,无法完成操作");
|
||||
}
|
||||
int i = baseMapper.updateStock(item.getId(), item.getIncrCount());
|
||||
// if (item.getIncrCount() <= 0) {
|
||||
// if (i == 0) {
|
||||
// R.failed("商品库存不足");
|
||||
// }
|
||||
// }
|
||||
});
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
+3
-1
@@ -35,7 +35,9 @@
|
||||
t.id as tid,
|
||||
sp.name,
|
||||
sp.pic_url,
|
||||
t.hour_type
|
||||
t.hour_type,
|
||||
sp.price,
|
||||
sp.category_id
|
||||
FROM canteen_daily_menu t
|
||||
LEFT JOIN canteen_spu sp
|
||||
on t.spu_id=sp.id
|
||||
|
||||
+11
@@ -75,4 +75,15 @@ public interface RemoteSupermarketSpuService {
|
||||
*/
|
||||
@PostMapping("/supermarketSpu/app/selectListAll")
|
||||
R getSupermarketSpu(@RequestBody SupermarketSpuQueryDTO supermarketSpuQueryDTO);
|
||||
|
||||
|
||||
/**
|
||||
* 购物车效验库存
|
||||
* @param spuId
|
||||
* @param incrCount 扣减数量,正数负数都行
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/supermarketSpu/app/checkSpuStock")
|
||||
R checkSpuStock(@RequestParam(value ="spuId")Long spuId,@RequestParam("incrCount")Integer incrCount);
|
||||
|
||||
}
|
||||
+14
@@ -28,6 +28,7 @@ import org.springframework.http.HttpHeaders;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -216,5 +217,18 @@ public class SupermarketSpuController {
|
||||
return R.ok(supermarketSpuService.getSupermarketSpuAppDetailById(id));
|
||||
}
|
||||
|
||||
@GetMapping("/app/checkSpuStock")
|
||||
@SysLog("购物车效验库存")
|
||||
@Transactional
|
||||
public R checkSpuStock(@RequestParam(value ="spuId")Long spuId,@RequestParam("incrCount")Integer incrCount) {
|
||||
SupermarketSpuEntity spu= supermarketSpuService.getById(spuId);
|
||||
if (spu == null) {
|
||||
R.failed("商品不存在");
|
||||
}
|
||||
if (spu.getStock()<Math.abs(incrCount)){
|
||||
return R.failed("库存不足");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
+14
-5
@@ -124,12 +124,21 @@ public class SupermarketSpuServiceImpl extends ServiceImpl<SupermarketSpuMapper,
|
||||
public R updateSpuStock(SupermarketSpuUpdateStockReqDTO updateStockReqDTO) {
|
||||
// 更新 SKU 库存
|
||||
updateStockReqDTO.getItems().forEach(item -> {
|
||||
int i = baseMapper.updateStock(item.getId(), item.getIncrCount());
|
||||
if (item.getIncrCount() <= 0) {
|
||||
if (i == 0) {
|
||||
R.failed("商品库存不足");
|
||||
}
|
||||
// 查询当前库存
|
||||
SupermarketSpuEntity spu = baseMapper.selectById(item.getId());
|
||||
if (spu == null) {
|
||||
R.failed(spu.getProductName()+"商品不存在");
|
||||
}
|
||||
// 检查库存是否足够
|
||||
if (item.getIncrCount() < 0 && Math.abs(item.getIncrCount()) > spu.getStock()) {
|
||||
R.failed(spu.getProductName()+"库存不足,无法完成操作");
|
||||
}
|
||||
int i = baseMapper.updateStock(item.getId(), item.getIncrCount());
|
||||
// if (item.getIncrCount() <= 0) {
|
||||
// if (i == 0) {
|
||||
// R.failed("商品库存不足");
|
||||
// }
|
||||
// }
|
||||
});
|
||||
|
||||
return R.ok();
|
||||
|
||||
Reference in new issue
Block a user