提交 d46b3ec5 authored 作者: 吴德鹏's avatar 吴德鹏

购物车

上级 c955034d
...@@ -94,7 +94,7 @@ public class CartController extends Controller { ...@@ -94,7 +94,7 @@ public class CartController extends Controller {
BigDecimal price = null; BigDecimal price = null;
if(itemSkuId != null) { if (itemSkuId != null) {
Optional<TbCfItemSkus> skuOptional = itemSkuRepository.findById(itemSkuId); Optional<TbCfItemSkus> skuOptional = itemSkuRepository.findById(itemSkuId);
...@@ -106,20 +106,20 @@ public class CartController extends Controller { ...@@ -106,20 +106,20 @@ public class CartController extends Controller {
} }
//Go for reptile products //Go for reptile products
if (targetUrl != null && itemSkuId == null){ if (targetUrl != null && itemSkuId == null) {
try { try {
JSONObject detail = spiderService.getItemDetail(targetUrl); JSONObject detail = spiderService.getItemDetail(targetUrl);
if( !detail.containsKey("originalPriceList")) { if (!detail.containsKey("originalPriceList")) {
logger.warn("No price detected from reptile products"); logger.warn("No price detected from reptile products");
return skuNotFound; return skuNotFound;
} }
JSONArray priceList = detail.getJSONArray("originalPriceList"); JSONArray priceList = detail.getJSONArray("originalPriceList");
if( priceList.isEmpty() ){ if (priceList.isEmpty()) {
logger.warn("No price detected from reptile products"); logger.warn("No price detected from reptile products");
return skuNotFound; return skuNotFound;
}else } else
price = BigDecimal.valueOf(priceList.getJSONObject(0).getDouble("price")); price = BigDecimal.valueOf(priceList.getJSONObject(0).getDouble("price"));
} catch (InterruptedException | IOException | ExecutionException | URISyntaxException | TimeoutException e) { } catch (InterruptedException | IOException | ExecutionException | URISyntaxException | TimeoutException e) {
logger.debug(e.getMessage()); logger.debug(e.getMessage());
...@@ -162,6 +162,7 @@ public class CartController extends Controller { ...@@ -162,6 +162,7 @@ public class CartController extends Controller {
if (cartOptional.isPresent()) { if (cartOptional.isPresent()) {
TbCfCartRecordR cart = cartOptional.get(); TbCfCartRecordR cart = cartOptional.get();
cart.setCheckFlag(StateConstant.VALID);
cart.increaseNum(itemDetail.getItemNum()); cart.increaseNum(itemDetail.getItemNum());
repository.save(cart); repository.save(cart);
} else { } else {
...@@ -214,7 +215,7 @@ public class CartController extends Controller { ...@@ -214,7 +215,7 @@ public class CartController extends Controller {
//Insert //Insert
private void insertRecord(TbCfCartRecordR itemDetail, String userId) { private void insertRecord(TbCfCartRecordR itemDetail, String userId) {
itemDetail.setCartRecordId(uid()); itemDetail.setCartRecordId(uid());
itemDetail.setCheckFlag(StateConstant.INVALID); itemDetail.setCheckFlag(StateConstant.VALID);
itemDetail.setEnableFlag(StateConstant.VALID); itemDetail.setEnableFlag(StateConstant.VALID);
itemDetail.setUserId(userId); itemDetail.setUserId(userId);
itemDetail.setCreateTime(new Date()); itemDetail.setCreateTime(new Date());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论