bug--修复商品单规格价格、销量等读取不了

This commit is contained in:
taochengbo
2020-09-11 23:58:38 +08:00
parent eb1b5dc5b9
commit 7ef279fa14
3 changed files with 85 additions and 4 deletions

View File

@ -132,14 +132,41 @@ public class StoreCombinationController {
productDto.setAttrs(productFormatDtos);
productDto.setItems(result.getObject("attr",ArrayList.class));
}else{
productDto.setAttr(productFormatDtos.get(0));
productFormat(productDto, result);
}
map.put("productInfo",productDto);
return new ResponseEntity<>(map,HttpStatus.OK);
}
/**
* 获取商品属性
* @param productDto
* @param result
*/
private void productFormat(YxStoreCombinationDto productDto, JSONObject result) {
Map<String,Object> mapAttr = (Map<String,Object>) result.getObject("value",ArrayList.class).get(0);
ProductFormatDto productFormatDto = ProductFormatDto.builder()
.pic(mapAttr.get("pic").toString())
.price(Double.valueOf(mapAttr.get("price").toString()))
.cost(Double.valueOf(mapAttr.get("cost").toString()))
.otPrice(Double.valueOf(mapAttr.get("otPrice").toString()))
.stock(Integer.valueOf(mapAttr.get("stock").toString()))
.barCode(mapAttr.get("barCode").toString())
.weight(Double.valueOf(mapAttr.get("weight").toString()))
.volume(Double.valueOf(mapAttr.get("volume").toString()))
.value1(mapAttr.get("value1").toString())
.brokerage(Double.valueOf(mapAttr.get("brokerage").toString()))
.brokerageTwo(Double.valueOf(mapAttr.get("brokerageTwo").toString()))
.pinkPrice(Double.valueOf(mapAttr.get("pinkPrice").toString()))
.pinkStock(Integer.valueOf(mapAttr.get("pinkStock").toString()))
.seckillPrice(Double.valueOf(mapAttr.get("seckillPrice").toString()))
.seckillStock(Integer.valueOf(mapAttr.get("seckillStock").toString()))
.build();
productDto.setAttr(productFormatDto);
}
@CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true)
@Log("修改拼团")
@ApiOperation(value = "新增/修改拼团")

View File

@ -148,7 +148,7 @@ public class StoreSeckillController {
productDto.setAttrs(productFormatDtos);
productDto.setItems(result.getObject("attr",ArrayList.class));
}else{
productDto.setAttr(productFormatDtos.get(0));
productFormat(productDto, result);
}
@ -156,4 +156,31 @@ public class StoreSeckillController {
return new ResponseEntity<>(map,HttpStatus.OK);
}
/**
* 获取商品属性
* @param productDto
* @param result
*/
private void productFormat(YxStoreSeckillDto productDto, JSONObject result) {
Map<String,Object> mapAttr = (Map<String,Object>) result.getObject("value",ArrayList.class).get(0);
ProductFormatDto productFormatDto = ProductFormatDto.builder()
.pic(mapAttr.get("pic").toString())
.price(Double.valueOf(mapAttr.get("price").toString()))
.cost(Double.valueOf(mapAttr.get("cost").toString()))
.otPrice(Double.valueOf(mapAttr.get("otPrice").toString()))
.stock(Integer.valueOf(mapAttr.get("stock").toString()))
.barCode(mapAttr.get("barCode").toString())
.weight(Double.valueOf(mapAttr.get("weight").toString()))
.volume(Double.valueOf(mapAttr.get("volume").toString()))
.value1(mapAttr.get("value1").toString())
.brokerage(Double.valueOf(mapAttr.get("brokerage").toString()))
.brokerageTwo(Double.valueOf(mapAttr.get("brokerageTwo").toString()))
.pinkPrice(Double.valueOf(mapAttr.get("pinkPrice").toString()))
.pinkStock(Integer.valueOf(mapAttr.get("pinkStock").toString()))
.seckillPrice(Double.valueOf(mapAttr.get("seckillPrice").toString()))
.seckillStock(Integer.valueOf(mapAttr.get("seckillStock").toString()))
.build();
productDto.setAttr(productFormatDto);
}
}

View File

@ -200,7 +200,7 @@ public class StoreProductController {
productDto.setItems(result.getObject("attr",ArrayList.class));
}else{
productDto.setAttr(productFormatDtos.get(0));
productFromat(productDto, result);
}
map.put("productInfo",productDto);
@ -208,6 +208,33 @@ public class StoreProductController {
return new ResponseEntity<>(map,HttpStatus.OK);
}
/**
* 获取商品属性
* @param productDto
* @param result
*/
private void productFromat(ProductDto productDto, JSONObject result) {
Map<String,Object> mapAttr = (Map<String,Object>) result.getObject("value",ArrayList.class).get(0);
ProductFormatDto productFormatDto = ProductFormatDto.builder()
.pic(mapAttr.get("pic").toString())
.price(Double.valueOf(mapAttr.get("price").toString()))
.cost(Double.valueOf(mapAttr.get("cost").toString()))
.otPrice(Double.valueOf(mapAttr.get("otPrice").toString()))
.stock(Integer.valueOf(mapAttr.get("stock").toString()))
.barCode(mapAttr.get("barCode").toString())
.weight(Double.valueOf(mapAttr.get("weight").toString()))
.volume(Double.valueOf(mapAttr.get("volume").toString()))
.value1(mapAttr.get("value1").toString())
.brokerage(Double.valueOf(mapAttr.get("brokerage").toString()))
.brokerageTwo(Double.valueOf(mapAttr.get("brokerageTwo").toString()))
.pinkPrice(Double.valueOf(mapAttr.get("pinkPrice").toString()))
.pinkStock(Integer.valueOf(mapAttr.get("pinkStock").toString()))
.seckillPrice(Double.valueOf(mapAttr.get("seckillPrice").toString()))
.seckillStock(Integer.valueOf(mapAttr.get("seckillStock").toString()))
.build();
productDto.setAttr(productFormatDto);
}
/**
* 分类递归