|
@@ -100,6 +100,7 @@ public class ApiCartController extends ApiBaseAction {
|
|
param.put("user_id", loginUser.getId());
|
|
param.put("user_id", loginUser.getId());
|
|
Long storeId = getStoreId();
|
|
Long storeId = getStoreId();
|
|
param.put("store_id", storeId);
|
|
param.put("store_id", storeId);
|
|
|
|
+ param.put("merchSn", getMerchSn());
|
|
List<CartVo> cartList = cartService.queryList(param);
|
|
List<CartVo> cartList = cartService.queryList(param);
|
|
|
|
|
|
List<CartVo> validCartList = cartService.queryValidCartList(param);
|
|
List<CartVo> validCartList = cartService.queryValidCartList(param);
|
|
@@ -230,15 +231,25 @@ public class ApiCartController extends ApiBaseAction {
|
|
Integer number = jsonParam.getInteger("number");
|
|
Integer number = jsonParam.getInteger("number");
|
|
//判断商品是否可以购买
|
|
//判断商品是否可以购买
|
|
GoodsVo goodsInfo = goodsService.queryObject(goodsId);
|
|
GoodsVo goodsInfo = goodsService.queryObject(goodsId);
|
|
- if (null == goodsInfo || goodsInfo.getIs_delete() == 1) {
|
|
|
|
|
|
+ if (null == goodsInfo || goodsInfo.getIs_delete() == 1 || goodsInfo.getIs_on_sale() == 0) {
|
|
return toResponsFail("商品已下架");
|
|
return toResponsFail("商品已下架");
|
|
}
|
|
}
|
|
Long storeId = getStoreId();
|
|
Long storeId = getStoreId();
|
|
//取得规格的信息,判断规格库存
|
|
//取得规格的信息,判断规格库存
|
|
- ProductVo productInfo = productService.queryObjectByStoreId(productId, storeId);
|
|
|
|
|
|
+ /*ProductVo productInfo = productService.queryObjectByStoreId(productId, storeId);
|
|
if (null == productInfo) {
|
|
if (null == productInfo) {
|
|
return toResponsFail("商品已下架");
|
|
return toResponsFail("商品已下架");
|
|
}
|
|
}
|
|
|
|
+ if(productInfo.getStock_num() <= 0){
|
|
|
|
+ return toResponsFail("库存不足");
|
|
|
|
+ }*/
|
|
|
|
+ ProductVo productInfo = productService.queryByStoreId(productId, storeId);
|
|
|
|
+ if (null == productInfo) {
|
|
|
|
+ return toResponsFail("商品已下架");
|
|
|
|
+ }
|
|
|
|
+ if(productInfo.getStock_num() == null || number > productInfo.getStock_num() || productInfo.getStock_num() <= 0){
|
|
|
|
+ return toResponsFail("该商品库存不足");
|
|
|
|
+ }
|
|
if (null == productInfo.getRetail_price()) {
|
|
if (null == productInfo.getRetail_price()) {
|
|
productInfo.setRetail_price(goodsInfo.getRetail_price());
|
|
productInfo.setRetail_price(goodsInfo.getRetail_price());
|
|
productInfo.setMarket_price(goodsInfo.getMarket_price());
|
|
productInfo.setMarket_price(goodsInfo.getMarket_price());
|
|
@@ -251,11 +262,7 @@ public class ApiCartController extends ApiBaseAction {
|
|
cartParam.put("store_id", storeId);
|
|
cartParam.put("store_id", storeId);
|
|
List<CartVo> cartInfoList = cartService.queryList(cartParam);
|
|
List<CartVo> cartInfoList = cartService.queryList(cartParam);
|
|
CartVo cartInfo = null != cartInfoList && cartInfoList.size() > 0 ? cartInfoList.get(0) : null;
|
|
CartVo cartInfo = null != cartInfoList && cartInfoList.size() > 0 ? cartInfoList.get(0) : null;
|
|
- if (null == cartInfo) {
|
|
|
|
- if(productInfo.getStock_num() <= 0){
|
|
|
|
- return toResponsFail("库存不足");
|
|
|
|
- }
|
|
|
|
- //添加规格名和值
|
|
|
|
|
|
+ if (null == cartInfo) {//添加规格名和值
|
|
cartInfo = new CartVo();
|
|
cartInfo = new CartVo();
|
|
|
|
|
|
cartInfo.setGoods_id(goodsId);
|
|
cartInfo.setGoods_id(goodsId);
|
|
@@ -296,7 +303,7 @@ public class ApiCartController extends ApiBaseAction {
|
|
Long goodsId = jsonParam.getLong("goodsId");
|
|
Long goodsId = jsonParam.getLong("goodsId");
|
|
//判断商品是否可以购买
|
|
//判断商品是否可以购买
|
|
GoodsVo goodsInfo = goodsService.queryObject(goodsId);
|
|
GoodsVo goodsInfo = goodsService.queryObject(goodsId);
|
|
- if (null == goodsInfo || goodsInfo.getIs_delete() == 1) {
|
|
|
|
|
|
+ if (null == goodsInfo || goodsInfo.getIs_delete() == 1 || goodsInfo.getIs_on_sale() == 0) {
|
|
return toResponsFail("商品已下架");
|
|
return toResponsFail("商品已下架");
|
|
}
|
|
}
|
|
Long storeId = getStoreId();
|
|
Long storeId = getStoreId();
|
|
@@ -320,7 +327,7 @@ public class ApiCartController extends ApiBaseAction {
|
|
for (OrderGoodsVo goodsVo : orderGoodsVos) {
|
|
for (OrderGoodsVo goodsVo : orderGoodsVos) {
|
|
//判断商品是否可以购买
|
|
//判断商品是否可以购买
|
|
GoodsVo goodsInfo = goodsService.queryObject(goodsVo.getGoods_id());
|
|
GoodsVo goodsInfo = goodsService.queryObject(goodsVo.getGoods_id());
|
|
- if (null == goodsInfo || goodsInfo.getIs_delete() == 1) {
|
|
|
|
|
|
+ if (null == goodsInfo || goodsInfo.getIs_delete() == 1 || goodsInfo.getIs_on_sale() == 0) {
|
|
return toResponsFail("商品已下架");
|
|
return toResponsFail("商品已下架");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -330,8 +337,8 @@ public class ApiCartController extends ApiBaseAction {
|
|
if (null == productInfo) {
|
|
if (null == productInfo) {
|
|
return toResponsFail("商品已下架");
|
|
return toResponsFail("商品已下架");
|
|
}
|
|
}
|
|
- if(productInfo.getStock_num() == null || goodsVo.getNumber() > productInfo.getStock_num() || productInfo.getStock_num() == 0){
|
|
|
|
- return toResponsFail("该商品暂无库存");
|
|
|
|
|
|
+ if(productInfo.getStock_num() == null || goodsVo.getNumber() > productInfo.getStock_num() || productInfo.getStock_num() <= 0){
|
|
|
|
+ return toResponsFail("该商品库存不足");
|
|
}
|
|
}
|
|
CartVo cartInfo = new CartVo();
|
|
CartVo cartInfo = new CartVo();
|
|
cartInfo.setGoods_id(goodsVo.getGoods_id());
|
|
cartInfo.setGoods_id(goodsVo.getGoods_id());
|
|
@@ -417,19 +424,19 @@ public class ApiCartController extends ApiBaseAction {
|
|
Integer id = jsonParam.getInteger("id");
|
|
Integer id = jsonParam.getInteger("id");
|
|
boolean isAdd = true;
|
|
boolean isAdd = true;
|
|
//取得规格的信息,判断规格库存
|
|
//取得规格的信息,判断规格库存
|
|
- ProductVo productInfo = productService.queryObjectByStoreId(productId, storeId);
|
|
|
|
- if (null == productInfo || productInfo.getStock_num() == 0) {
|
|
|
|
-// String[] productIds = new String[1];
|
|
|
|
-// productIds[0] = productId + "";
|
|
|
|
-// cartService.deleteByProductIds(productIds, storeId);
|
|
|
|
- return this.toResponsObject(400, "商品已下架", "");
|
|
|
|
|
|
+ ProductVo productInfo = productService.queryByStoreId(productId, storeId);
|
|
|
|
+ if (null == productInfo) {
|
|
|
|
+ return this.toResponsObject(400, "商品已下架", getCart());
|
|
}
|
|
}
|
|
- String msg = "";
|
|
|
|
- if (productInfo.getStock_num() < number) {
|
|
|
|
- msg = "库存不足,仅剩余" + productInfo.getStock_num();
|
|
|
|
- number = productInfo.getStock_num();
|
|
|
|
-// return this.toResponsObject(400, "库存不足,仅剩余" + productInfo.getStock_num(), "");
|
|
|
|
|
|
+ if(productInfo.getStock_num() == null || number > productInfo.getStock_num() || productInfo.getStock_num() <= 0){
|
|
|
|
+ return this.toResponsObject(400, "该商品库存不足", getCart());
|
|
}
|
|
}
|
|
|
|
+ String msg = "";
|
|
|
|
+// if (productInfo.getStock_num() < number) {
|
|
|
|
+// msg = "库存不足,仅剩余" + productInfo.getStock_num();
|
|
|
|
+// number = productInfo.getStock_num();
|
|
|
|
+//// return this.toResponsObject(400, "库存不足,仅剩余" + productInfo.getStock_num(), "");
|
|
|
|
+// }
|
|
//判断是否已经存在product_id购物车商品
|
|
//判断是否已经存在product_id购物车商品
|
|
CartVo cartInfo = cartService.queryObject(id);
|
|
CartVo cartInfo = cartService.queryObject(id);
|
|
//只是更新number
|
|
//只是更新number
|