|
|
@@ -250,7 +250,8 @@ public class ProductScrmController extends AppBaseController {
|
|
|
@Login
|
|
|
@ApiOperation("检查商品限购")
|
|
|
@GetMapping("/checkPurchaseLimit")
|
|
|
- public R checkPurchaseLimit(@RequestParam(value="productId") Long productId){
|
|
|
+ public R checkPurchaseLimit(@RequestParam(value="productId") Long productId,
|
|
|
+ @RequestParam(value="num", required = false, defaultValue = "1") Integer num){
|
|
|
try {
|
|
|
// 查询商品信息
|
|
|
FsStoreProductScrm product = productService.selectFsStoreProductById(productId);
|
|
|
@@ -279,9 +280,9 @@ public class ProductScrmController extends AppBaseController {
|
|
|
|
|
|
// 计算剩余可购买数量
|
|
|
int remainingPurchaseLimit = product.getPurchaseLimit() - purchasedNum;
|
|
|
- if (remainingPurchaseLimit <= 0) {
|
|
|
+ if (remainingPurchaseLimit < num) {
|
|
|
// 剩余可购买数量不足
|
|
|
- return R.error("该商品限购" + product.getPurchaseLimit() + "件,目前剩余可购买数量不足");
|
|
|
+ return R.error("该商品限购" + product.getPurchaseLimit() + "件,您已购买" + purchasedNum + "件,本次购买" + num + "件,超出限购数量");
|
|
|
}
|
|
|
|
|
|
// 剩余可购买数量充足
|