后端编辑库存从AttrValue表取值
This commit is contained in:
@ -134,6 +134,6 @@ public class YxStoreCombinationDto implements Serializable {
|
||||
private List<FromatDetailDto> items;
|
||||
|
||||
//sku结果集
|
||||
private List<Map<String,Object>> attrs;
|
||||
private List<ProductFormatDto> attrs;
|
||||
|
||||
}
|
||||
|
@ -131,6 +131,6 @@ public class YxStoreSeckillDto implements Serializable {
|
||||
private List<FromatDetailDto> items;
|
||||
|
||||
//sku结果集
|
||||
private List<Map<String,Object>> attrs;
|
||||
private List<ProductFormatDto> attrs;
|
||||
|
||||
}
|
||||
|
@ -58,13 +58,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
@ -290,14 +284,14 @@ public class YxStoreCombinationServiceImpl extends BaseServiceImpl<YxStoreCombin
|
||||
.attrHidden("")
|
||||
.detail(ListUtil.toList("默认"))
|
||||
.build();
|
||||
List<Map<String,Object>> attrs = resources.getAttrs();
|
||||
Map<String,Object> map = attrs.get(0);
|
||||
map.put("value1","规格");
|
||||
map.put("detail", MapUtil.of(new String[][] {
|
||||
{"规格", "默认"}
|
||||
}));
|
||||
List<ProductFormatDto> attrs = resources.getAttrs();
|
||||
ProductFormatDto productFormatDto = attrs.get(0);
|
||||
productFormatDto.setValue1("规格");
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("规格","默认");
|
||||
productFormatDto.setDetail(map);
|
||||
yxStoreProductAttrService.insertYxStoreProductAttr(ListUtil.toList(fromatDetailDto),
|
||||
ListUtil.toList(map),resources.getProductId());
|
||||
ListUtil.toList(productFormatDto),resources.getProductId());
|
||||
}else{
|
||||
yxStoreProductAttrService.insertYxStoreProductAttr(resources.getItems(),
|
||||
resources.getAttrs(),resources.getProductId());
|
||||
@ -311,27 +305,27 @@ public class YxStoreCombinationServiceImpl extends BaseServiceImpl<YxStoreCombin
|
||||
* @param attrs attrs
|
||||
* @return ProductResultDto
|
||||
*/
|
||||
private ProductResultDto computedProduct(List<Map<String,Object>> attrs){
|
||||
private ProductResultDto computedProduct(List<ProductFormatDto> attrs){
|
||||
//取最小价格
|
||||
Double minPrice = ListMapToListBean(attrs)
|
||||
Double minPrice = attrs
|
||||
.stream()
|
||||
.map(ProductFormatDto::getPinkPrice)
|
||||
.min(Comparator.naturalOrder())
|
||||
.orElse(0d);
|
||||
|
||||
Double minOtPrice = ListMapToListBean(attrs)
|
||||
Double minOtPrice = attrs
|
||||
.stream()
|
||||
.map(ProductFormatDto::getOtPrice)
|
||||
.min(Comparator.naturalOrder())
|
||||
.orElse(0d);
|
||||
|
||||
Double minCost = ListMapToListBean(attrs)
|
||||
Double minCost = attrs
|
||||
.stream()
|
||||
.map(ProductFormatDto::getCost)
|
||||
.min(Comparator.naturalOrder())
|
||||
.orElse(0d);
|
||||
//计算库存
|
||||
Integer stock = ListMapToListBean(attrs)
|
||||
Integer stock = attrs
|
||||
.stream()
|
||||
.map(ProductFormatDto::getPinkStock)
|
||||
.reduce(Integer::sum)
|
||||
|
@ -268,14 +268,14 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
|
||||
.attrHidden("")
|
||||
.detail(ListUtil.toList("默认"))
|
||||
.build();
|
||||
List<Map<String,Object>> attrs = resources.getAttrs();
|
||||
Map<String,Object> map = attrs.get(0);
|
||||
map.put("value1","规格");
|
||||
map.put("detail", MapUtil.of(new String[][] {
|
||||
{"规格", "默认"}
|
||||
}));
|
||||
List<ProductFormatDto> attrs = resources.getAttrs();
|
||||
ProductFormatDto productFormatDto = attrs.get(0);
|
||||
productFormatDto.setValue1("规格");
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("规格","默认");
|
||||
productFormatDto.setDetail(map);
|
||||
yxStoreProductAttrService.insertYxStoreProductAttr(ListUtil.toList(fromatDetailDto),
|
||||
ListUtil.toList(map),resources.getProductId());
|
||||
ListUtil.toList(productFormatDto),resources.getProductId());
|
||||
}else{
|
||||
yxStoreProductAttrService.insertYxStoreProductAttr(resources.getItems(),
|
||||
resources.getAttrs(),resources.getProductId());
|
||||
@ -288,27 +288,27 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
|
||||
* @param attrs attrs
|
||||
* @return ProductResultDto
|
||||
*/
|
||||
private ProductResultDto computedProduct(List<Map<String,Object>> attrs){
|
||||
private ProductResultDto computedProduct(List<ProductFormatDto> attrs){
|
||||
//取最小价格
|
||||
Double minPrice = ListMapToListBean(attrs)
|
||||
Double minPrice = attrs
|
||||
.stream()
|
||||
.map(ProductFormatDto::getSeckillPrice)
|
||||
.min(Comparator.naturalOrder())
|
||||
.orElse(0d);
|
||||
|
||||
Double minOtPrice = ListMapToListBean(attrs)
|
||||
Double minOtPrice = attrs
|
||||
.stream()
|
||||
.map(ProductFormatDto::getOtPrice)
|
||||
.min(Comparator.naturalOrder())
|
||||
.orElse(0d);
|
||||
|
||||
Double minCost = ListMapToListBean(attrs)
|
||||
Double minCost = attrs
|
||||
.stream()
|
||||
.map(ProductFormatDto::getCost)
|
||||
.min(Comparator.naturalOrder())
|
||||
.orElse(0d);
|
||||
//计算库存
|
||||
Integer stock = ListMapToListBean(attrs)
|
||||
Integer stock = attrs
|
||||
.stream()
|
||||
.map(ProductFormatDto::getSeckillStock)
|
||||
.reduce(Integer::sum)
|
||||
@ -326,17 +326,4 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* mapTobean
|
||||
* @param listMap listMap
|
||||
* @return list
|
||||
*/
|
||||
private List<ProductFormatDto> ListMapToListBean(List<Map<String, Object>> listMap){
|
||||
List<ProductFormatDto> list = new ArrayList<>();
|
||||
// 循环遍历出map对象
|
||||
for (Map<String, Object> m : listMap) {
|
||||
list.add(BeanUtil.mapToBean(m,ProductFormatDto.class,true));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import co.yixiang.common.service.BaseService;
|
||||
import co.yixiang.modules.product.domain.YxStoreProductAttr;
|
||||
import co.yixiang.modules.product.domain.YxStoreProductAttrValue;
|
||||
import co.yixiang.modules.product.service.dto.FromatDetailDto;
|
||||
import co.yixiang.modules.product.service.dto.ProductFormatDto;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -60,6 +61,6 @@ public interface YxStoreProductAttrService extends BaseService<YxStoreProductAt
|
||||
* @param attrs value
|
||||
* @param productId 商品id
|
||||
*/
|
||||
void insertYxStoreProductAttr(List<FromatDetailDto> items, List<Map<String,Object>> attrs,
|
||||
void insertYxStoreProductAttr(List<FromatDetailDto> items, List<ProductFormatDto> attrs,
|
||||
Long productId);
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ public class ProductDto
|
||||
|
||||
private List<FromatDetailDto> items;
|
||||
|
||||
private List<Map<String,Object>> attrs;
|
||||
private List<ProductFormatDto> attrs;
|
||||
|
||||
|
||||
|
||||
|
@ -140,7 +140,7 @@ public class StoreProductDto
|
||||
private List<FromatDetailDto> items;
|
||||
|
||||
//sku结果集
|
||||
private List<Map<String,Object>> attrs;
|
||||
private List<ProductFormatDto> attrs;
|
||||
|
||||
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class YxStoreProductAttrServiceImpl extends BaseServiceImpl<StoreProductA
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void insertYxStoreProductAttr(List<FromatDetailDto> items, List<Map<String,Object>> attrs,
|
||||
public void insertYxStoreProductAttr(List<FromatDetailDto> items, List<ProductFormatDto> attrs,
|
||||
Long productId)
|
||||
{
|
||||
List<YxStoreProductAttr> attrGroup = new ArrayList<>();
|
||||
@ -89,11 +89,8 @@ public class YxStoreProductAttrServiceImpl extends BaseServiceImpl<StoreProductA
|
||||
|
||||
|
||||
List<YxStoreProductAttrValue> valueGroup = new ArrayList<>();
|
||||
for (Map<String, Object> m : attrs) {
|
||||
ProductFormatDto productFormatDto = BeanUtil.mapToBean(m,ProductFormatDto.class,true);
|
||||
// List<String> stringList = productFormatDto.getDetail().values()
|
||||
// .stream()
|
||||
// .collect(Collectors.toList());
|
||||
for (ProductFormatDto productFormatDto : attrs) {
|
||||
|
||||
if(productFormatDto.getPinkStock()>productFormatDto.getStock() || productFormatDto.getSeckillStock()>productFormatDto.getStock()){
|
||||
throw new BadRequestException("活动商品库存不能大于原有商品库存");
|
||||
}
|
||||
|
@ -534,17 +534,17 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
|
||||
.attrHidden("")
|
||||
.detail(ListUtil.toList("默认"))
|
||||
.build();
|
||||
List<Map<String,Object>> attrs = storeProductDto.getAttrs();
|
||||
Map<String,Object> map = attrs.get(0);
|
||||
map.put("value1","规格");
|
||||
map.put("detail", MapUtil.of(new String[][] {
|
||||
{"规格", "默认"}
|
||||
}));
|
||||
List<ProductFormatDto> attrs = storeProductDto.getAttrs();
|
||||
ProductFormatDto productFormatDto = attrs.get(0);
|
||||
productFormatDto.setValue1("规格");
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("规格","默认");
|
||||
productFormatDto.setDetail(map);
|
||||
yxStoreProductAttrService.insertYxStoreProductAttr(ListUtil.toList(fromatDetailDto),
|
||||
ListUtil.toList(map),yxStoreProduct.getId());
|
||||
ListUtil.toList(productFormatDto),storeProductDto.getId());
|
||||
}else{
|
||||
yxStoreProductAttrService.insertYxStoreProductAttr(storeProductDto.getItems(),
|
||||
storeProductDto.getAttrs(),yxStoreProduct.getId());
|
||||
storeProductDto.getAttrs(),storeProductDto.getId());
|
||||
}
|
||||
|
||||
|
||||
@ -688,27 +688,27 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
|
||||
* @param attrs attrs
|
||||
* @return ProductResultDto
|
||||
*/
|
||||
private ProductResultDto computedProduct(List<Map<String,Object>> attrs){
|
||||
private ProductResultDto computedProduct(List<ProductFormatDto> attrs){
|
||||
//取最小价格
|
||||
Double minPrice = ListMapToListBean(attrs)
|
||||
Double minPrice = attrs
|
||||
.stream()
|
||||
.map(ProductFormatDto::getPrice)
|
||||
.min(Comparator.naturalOrder())
|
||||
.orElse(0d);
|
||||
|
||||
Double minOtPrice = ListMapToListBean(attrs)
|
||||
Double minOtPrice = attrs
|
||||
.stream()
|
||||
.map(ProductFormatDto::getOtPrice)
|
||||
.min(Comparator.naturalOrder())
|
||||
.orElse(0d);
|
||||
|
||||
Double minCost = ListMapToListBean(attrs)
|
||||
Double minCost = attrs
|
||||
.stream()
|
||||
.map(ProductFormatDto::getCost)
|
||||
.min(Comparator.naturalOrder())
|
||||
.orElse(0d);
|
||||
//计算库存
|
||||
Integer stock = ListMapToListBean(attrs)
|
||||
Integer stock = attrs
|
||||
.stream()
|
||||
.map(ProductFormatDto::getStock)
|
||||
.reduce(Integer::sum)
|
||||
|
@ -8,6 +8,7 @@ package co.yixiang.modules.activity.rest;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import co.yixiang.constant.ShopConstants;
|
||||
import co.yixiang.dozer.service.IGenerator;
|
||||
import co.yixiang.enums.SpecTypeEnum;
|
||||
import co.yixiang.logging.aop.log.Log;
|
||||
import co.yixiang.modules.activity.domain.YxStoreCombination;
|
||||
@ -16,13 +17,16 @@ import co.yixiang.modules.activity.service.dto.YxStoreCombinationDto;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreCombinationQueryCriteria;
|
||||
import co.yixiang.modules.aop.ForbidSubmit;
|
||||
import co.yixiang.modules.product.domain.YxStoreProductAttrResult;
|
||||
import co.yixiang.modules.product.domain.YxStoreProductAttrValue;
|
||||
import co.yixiang.modules.product.service.YxStoreProductAttrResultService;
|
||||
import co.yixiang.modules.product.service.YxStoreProductAttrValueService;
|
||||
import co.yixiang.modules.product.service.YxStoreProductRuleService;
|
||||
import co.yixiang.modules.product.service.dto.ProductFormatDto;
|
||||
import co.yixiang.modules.template.domain.YxShippingTemplates;
|
||||
import co.yixiang.modules.template.service.YxShippingTemplatesService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -60,11 +64,15 @@ public class StoreCombinationController {
|
||||
private final YxShippingTemplatesService yxShippingTemplatesService;
|
||||
private final YxStoreProductRuleService yxStoreProductRuleService;
|
||||
private final YxStoreProductAttrResultService yxStoreProductAttrResultService;
|
||||
public StoreCombinationController(YxStoreCombinationService yxStoreCombinationService, YxShippingTemplatesService yxShippingTemplatesService, YxStoreProductRuleService yxStoreProductRuleService, YxStoreProductAttrResultService yxStoreProductAttrResultService) {
|
||||
private final YxStoreProductAttrValueService storeProductAttrValueService;
|
||||
private final IGenerator generator;
|
||||
public StoreCombinationController(YxStoreCombinationService yxStoreCombinationService, YxShippingTemplatesService yxShippingTemplatesService, YxStoreProductRuleService yxStoreProductRuleService, YxStoreProductAttrResultService yxStoreProductAttrResultService, YxStoreProductAttrValueService storeProductAttrValueService, IGenerator generator) {
|
||||
this.yxStoreCombinationService = yxStoreCombinationService;
|
||||
this.yxShippingTemplatesService = yxShippingTemplatesService;
|
||||
this.yxStoreProductRuleService = yxStoreProductRuleService;
|
||||
this.yxStoreProductAttrResultService = yxStoreProductAttrResultService;
|
||||
this.storeProductAttrValueService = storeProductAttrValueService;
|
||||
this.generator = generator;
|
||||
}
|
||||
|
||||
@Log("查询拼团")
|
||||
@ -93,14 +101,6 @@ public class StoreCombinationController {
|
||||
List<YxShippingTemplates> shippingTemplatesList = yxShippingTemplatesService.list();
|
||||
map.put("tempList", shippingTemplatesList);
|
||||
|
||||
// //商品分类
|
||||
// List<YxStoreCategory> storeCategories = yxStoreCategoryService.lambdaQuery()
|
||||
// .eq(YxStoreCategory::getIsShow, ShopCommonEnum.SHOW_1.getValue())
|
||||
// .list();
|
||||
|
||||
// List<Map<String,Object>> cateList = new ArrayList<>();
|
||||
// map.put("cateList", this.makeCate(storeCategories,cateList,0,1));
|
||||
|
||||
//商品规格
|
||||
map.put("ruleList",yxStoreProductRuleService.list());
|
||||
|
||||
@ -118,33 +118,16 @@ public class StoreCombinationController {
|
||||
.getOne(Wrappers.<YxStoreProductAttrResult>lambdaQuery()
|
||||
.eq(YxStoreProductAttrResult::getProductId,yxStoreCombination.getProductId()).last("limit 1"));
|
||||
JSONObject result = JSON.parseObject(storeProductAttrResult.getResult());
|
||||
|
||||
List<YxStoreProductAttrValue> attrValues = storeProductAttrValueService.list(new LambdaQueryWrapper<YxStoreProductAttrValue>().eq(YxStoreProductAttrValue::getProductId, yxStoreCombination.getProductId()));
|
||||
List<ProductFormatDto> productFormatDtos = generator.convert(attrValues, ProductFormatDto.class);
|
||||
if(SpecTypeEnum.TYPE_1.getValue().equals(yxStoreCombination.getSpecType())){
|
||||
productDto.setAttr(new ProductFormatDto());
|
||||
productDto.setAttrs(result.getObject("value",ArrayList.class));
|
||||
productDto.setAttrs(productFormatDtos);
|
||||
productDto.setItems(result.getObject("attr",ArrayList.class));
|
||||
}else{
|
||||
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()))
|
||||
.pinkPrice(Double.valueOf(mapAttr.get("pink_price").toString()))
|
||||
.cost(Double.valueOf(mapAttr.get("cost").toString()))
|
||||
.otPrice(Double.valueOf(mapAttr.get("ot_price").toString()))
|
||||
.barCode(mapAttr.get("bar_code").toString())
|
||||
.weight(Double.valueOf(mapAttr.get("weight").toString()))
|
||||
.volume(Double.valueOf(mapAttr.get("volume").toString()))
|
||||
.brokerage(Double.valueOf(mapAttr.get("brokerage").toString()))
|
||||
.brokerageTwo(Double.valueOf(mapAttr.get("brokerage_two").toString()))
|
||||
.pinkPrice(Double.valueOf(mapAttr.get("pink_price").toString()))
|
||||
.pinkStock(Integer.valueOf(mapAttr.get("pink_stock").toString()))
|
||||
.stock(Integer.valueOf(mapAttr.get("stock").toString()))
|
||||
.seckillPrice(Double.valueOf(mapAttr.get("seckill_price").toString()))
|
||||
.seckillStock(Integer.valueOf(mapAttr.get("seckill_stock").toString()))
|
||||
.build();
|
||||
productDto.setAttr(productFormatDto);
|
||||
}
|
||||
|
||||
productDto.setAttr(productFormatDtos.get(0));
|
||||
}
|
||||
|
||||
map.put("productInfo",productDto);
|
||||
|
||||
|
@ -8,23 +8,25 @@ package co.yixiang.modules.activity.rest;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import co.yixiang.constant.ShopConstants;
|
||||
import co.yixiang.dozer.service.IGenerator;
|
||||
import co.yixiang.enums.SpecTypeEnum;
|
||||
import co.yixiang.logging.aop.log.Log;
|
||||
import co.yixiang.modules.activity.domain.YxStoreSeckill;
|
||||
import co.yixiang.modules.activity.domain.YxStoreSeckill;
|
||||
import co.yixiang.modules.activity.service.YxStoreSeckillService;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreSeckillDto;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreSeckillDto;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreSeckillQueryCriteria;
|
||||
import co.yixiang.modules.aop.ForbidSubmit;
|
||||
import co.yixiang.modules.product.domain.YxStoreProductAttrResult;
|
||||
import co.yixiang.modules.product.domain.YxStoreProductAttrValue;
|
||||
import co.yixiang.modules.product.service.YxStoreProductAttrResultService;
|
||||
import co.yixiang.modules.product.service.YxStoreProductAttrValueService;
|
||||
import co.yixiang.modules.product.service.YxStoreProductRuleService;
|
||||
import co.yixiang.modules.product.service.dto.ProductFormatDto;
|
||||
import co.yixiang.modules.template.domain.YxShippingTemplates;
|
||||
import co.yixiang.modules.template.service.YxShippingTemplatesService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -47,14 +49,20 @@ import java.util.*;
|
||||
@RequestMapping("api")
|
||||
public class StoreSeckillController {
|
||||
|
||||
private final IGenerator generator;
|
||||
private final YxStoreSeckillService yxStoreSeckillService;
|
||||
private final YxShippingTemplatesService yxShippingTemplatesService;
|
||||
private final YxStoreProductRuleService yxStoreProductRuleService;
|
||||
private final YxStoreProductAttrValueService storeProductAttrValueService;
|
||||
private final YxStoreProductAttrResultService yxStoreProductAttrResultService;
|
||||
public StoreSeckillController(YxStoreSeckillService yxStoreSeckillService, YxShippingTemplatesService yxShippingTemplatesService, YxStoreProductRuleService yxStoreProductRuleService, YxStoreProductAttrResultService yxStoreProductAttrResultService) {
|
||||
public StoreSeckillController(IGenerator generator, YxStoreSeckillService yxStoreSeckillService, YxShippingTemplatesService yxShippingTemplatesService,
|
||||
YxStoreProductRuleService yxStoreProductRuleService, YxStoreProductAttrValueService storeProductAttrValueService,
|
||||
YxStoreProductAttrResultService yxStoreProductAttrResultService) {
|
||||
this.generator = generator;
|
||||
this.yxStoreSeckillService = yxStoreSeckillService;
|
||||
this.yxShippingTemplatesService = yxShippingTemplatesService;
|
||||
this.yxStoreProductRuleService = yxStoreProductRuleService;
|
||||
this.storeProductAttrValueService = storeProductAttrValueService;
|
||||
this.yxStoreProductAttrResultService = yxStoreProductAttrResultService;
|
||||
}
|
||||
|
||||
@ -108,14 +116,6 @@ public class StoreSeckillController {
|
||||
List<YxShippingTemplates> shippingTemplatesList = yxShippingTemplatesService.list();
|
||||
map.put("tempList", shippingTemplatesList);
|
||||
|
||||
// //商品分类
|
||||
// List<YxStoreCategory> storeCategories = yxStoreCategoryService.lambdaQuery()
|
||||
// .eq(YxStoreCategory::getIsShow, ShopCommonEnum.SHOW_1.getValue())
|
||||
// .list();
|
||||
|
||||
// List<Map<String,Object>> cateList = new ArrayList<>();
|
||||
// map.put("cateList", this.makeCate(storeCategories,cateList,0,1));
|
||||
|
||||
//商品规格
|
||||
map.put("ruleList",yxStoreProductRuleService.list());
|
||||
|
||||
@ -134,30 +134,15 @@ public class StoreSeckillController {
|
||||
.eq(YxStoreProductAttrResult::getProductId,yxStoreSeckill.getProductId()).last("limit 1"));
|
||||
JSONObject result = JSON.parseObject(storeProductAttrResult.getResult());
|
||||
|
||||
List<YxStoreProductAttrValue> attrValues = storeProductAttrValueService.list(new LambdaQueryWrapper<YxStoreProductAttrValue>().eq(YxStoreProductAttrValue::getProductId, yxStoreSeckill.getProductId()));
|
||||
List<ProductFormatDto> productFormatDtos = generator.convert(attrValues, ProductFormatDto.class);
|
||||
|
||||
if(SpecTypeEnum.TYPE_1.getValue().equals(yxStoreSeckill.getSpecType())){
|
||||
productDto.setAttr(new ProductFormatDto());
|
||||
productDto.setAttrs(result.getObject("value", ArrayList.class));
|
||||
productDto.setAttrs(productFormatDtos);
|
||||
productDto.setItems(result.getObject("attr",ArrayList.class));
|
||||
}else{
|
||||
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()))
|
||||
.pinkPrice(Double.valueOf(mapAttr.get("pink_price").toString()))
|
||||
.cost(Double.valueOf(mapAttr.get("cost").toString()))
|
||||
.otPrice(Double.valueOf(mapAttr.get("ot_price").toString()))
|
||||
.barCode(mapAttr.get("bar_code").toString())
|
||||
.weight(Double.valueOf(mapAttr.get("weight").toString()))
|
||||
.volume(Double.valueOf(mapAttr.get("volume").toString()))
|
||||
.stock(Integer.valueOf(mapAttr.get("stock").toString()))
|
||||
.brokerage(Double.valueOf(mapAttr.get("brokerage").toString()))
|
||||
.brokerageTwo(Double.valueOf(mapAttr.get("brokerage_two").toString()))
|
||||
.pinkPrice(Double.valueOf(mapAttr.get("pink_price").toString()))
|
||||
.pinkStock(Integer.valueOf(mapAttr.get("pink_stock").toString()))
|
||||
.seckillPrice(Double.valueOf(mapAttr.get("seckill_price").toString()))
|
||||
.seckillStock(Integer.valueOf(mapAttr.get("seckill_stock").toString()))
|
||||
.build();
|
||||
productDto.setAttr(productFormatDto);
|
||||
productDto.setAttr(productFormatDtos.get(0));
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@ package co.yixiang.modules.product.rest;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import co.yixiang.constant.ShopConstants;
|
||||
import co.yixiang.dozer.service.IGenerator;
|
||||
import co.yixiang.enums.ShopCommonEnum;
|
||||
import co.yixiang.enums.SpecTypeEnum;
|
||||
import co.yixiang.logging.aop.log.Log;
|
||||
@ -18,7 +19,9 @@ import co.yixiang.modules.category.domain.YxStoreCategory;
|
||||
import co.yixiang.modules.category.service.YxStoreCategoryService;
|
||||
import co.yixiang.modules.product.domain.YxStoreProduct;
|
||||
import co.yixiang.modules.product.domain.YxStoreProductAttrResult;
|
||||
import co.yixiang.modules.product.domain.YxStoreProductAttrValue;
|
||||
import co.yixiang.modules.product.service.YxStoreProductAttrResultService;
|
||||
import co.yixiang.modules.product.service.YxStoreProductAttrValueService;
|
||||
import co.yixiang.modules.product.service.YxStoreProductRuleService;
|
||||
import co.yixiang.modules.product.service.YxStoreProductService;
|
||||
import co.yixiang.modules.product.service.dto.ProductDto;
|
||||
@ -29,6 +32,7 @@ import co.yixiang.modules.template.domain.YxShippingTemplates;
|
||||
import co.yixiang.modules.template.service.YxShippingTemplatesService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -68,17 +72,20 @@ public class StoreProductController {
|
||||
private final YxShippingTemplatesService yxShippingTemplatesService;
|
||||
private final YxStoreProductRuleService yxStoreProductRuleService;
|
||||
private final YxStoreProductAttrResultService yxStoreProductAttrResultService;
|
||||
|
||||
private final YxStoreProductAttrValueService storeProductAttrValueService;
|
||||
private final IGenerator generator;
|
||||
public StoreProductController(YxStoreProductService yxStoreProductService,
|
||||
YxStoreCategoryService yxStoreCategoryService,
|
||||
YxShippingTemplatesService yxShippingTemplatesService,
|
||||
YxStoreProductRuleService yxStoreProductRuleService,
|
||||
YxStoreProductAttrResultService yxStoreProductAttrResultService) {
|
||||
YxStoreProductAttrResultService yxStoreProductAttrResultService, YxStoreProductAttrValueService storeProductAttrValueService, IGenerator generator) {
|
||||
this.yxStoreProductService = yxStoreProductService;
|
||||
this.yxStoreCategoryService = yxStoreCategoryService;
|
||||
this.yxShippingTemplatesService = yxShippingTemplatesService;
|
||||
this.yxStoreProductRuleService = yxStoreProductRuleService;
|
||||
this.yxStoreProductAttrResultService = yxStoreProductAttrResultService;
|
||||
this.storeProductAttrValueService = storeProductAttrValueService;
|
||||
this.generator = generator;
|
||||
}
|
||||
|
||||
@Log("查询商品")
|
||||
@ -178,32 +185,16 @@ public class StoreProductController {
|
||||
.getOne(Wrappers.<YxStoreProductAttrResult>lambdaQuery()
|
||||
.eq(YxStoreProductAttrResult::getProductId,id).last("limit 1"));
|
||||
JSONObject result = JSON.parseObject(storeProductAttrResult.getResult());
|
||||
|
||||
List<YxStoreProductAttrValue> attrValues = storeProductAttrValueService.list(new LambdaQueryWrapper<YxStoreProductAttrValue>().eq(YxStoreProductAttrValue::getProductId, yxStoreProduct.getId()));
|
||||
List<ProductFormatDto> productFormatDtos = generator.convert(attrValues, ProductFormatDto.class);
|
||||
if(SpecTypeEnum.TYPE_1.getValue().equals(yxStoreProduct.getSpecType())){
|
||||
productDto.setAttr(new ProductFormatDto());
|
||||
productDto.setAttrs(result.getObject("value",ArrayList.class));
|
||||
productDto.setAttrs(productFormatDtos);
|
||||
productDto.setItems(result.getObject("attr",ArrayList.class));
|
||||
}else{
|
||||
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("ot_price").toString()))
|
||||
.stock(Integer.valueOf(mapAttr.get("stock").toString()))
|
||||
.barCode(mapAttr.get("bar_code").toString())
|
||||
.weight(Double.valueOf(mapAttr.get("weight").toString()))
|
||||
.volume(Double.valueOf(mapAttr.get("volume").toString()))
|
||||
.brokerage(Double.valueOf(mapAttr.get("brokerage").toString()))
|
||||
.brokerageTwo(Double.valueOf(mapAttr.get("brokerage_two").toString()))
|
||||
.pinkPrice(Double.valueOf(mapAttr.get("pink_price").toString()))
|
||||
.pinkStock(Integer.valueOf(mapAttr.get("pink_stock").toString()))
|
||||
.seckillPrice(Double.valueOf(mapAttr.get("seckill_price").toString()))
|
||||
.seckillStock(Integer.valueOf(mapAttr.get("seckill_stock").toString()))
|
||||
.build();
|
||||
productDto.setAttr(productFormatDto);
|
||||
}
|
||||
|
||||
productDto.setAttr(productFormatDtos.get(0));
|
||||
}
|
||||
|
||||
map.put("productInfo",productDto);
|
||||
|
||||
|
Reference in New Issue
Block a user