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

购物车

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