Commit 6a086d5e by weijiguang

下单时校验订单中sku数量

parent 3f8740d0
......@@ -67,6 +67,11 @@ public class Goods extends BaseEntity {
*/
@Excel(name = "特惠标签")
private String recommendTag;
/**
* 特惠标签
*/
@Excel(name = "特惠标签")
private List<String> recommendTagList;
/**
* 制作用时 单位 秒
......
......@@ -8,6 +8,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 推荐和今日特惠对象 shop_recommend
......@@ -54,6 +55,11 @@ public class ShopRecommend extends BaseEntity
/**
* 特惠标签
*/
private List<String> recommendTagList;
/**
* 特惠标签
*/
private String recommendTag;
/** 描述 */
......@@ -203,6 +209,14 @@ public class ShopRecommend extends BaseEntity
return updatedAt;
}
public List<String> getRecommendTagList() {
return recommendTagList;
}
public void setRecommendTagList(List<String> recommendTagList) {
this.recommendTagList = recommendTagList;
}
public BigDecimal getRecommendPrice() {
return recommendPrice;
}
......
......@@ -30,7 +30,7 @@ public class GoodsVo {
private String isRecommend;
/** 特惠标签 */
private String recommendTag;
private List<String> recommendTagList;
private String category;
}
package com.soss.system.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.soss.common.exception.ServiceException;
......@@ -12,7 +13,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@Service
......@@ -40,6 +44,7 @@ public class OrderTakingServiceImpl {
/**
* 获取机器上的点单信息
*
* @param machineCode
* @return
*/
......@@ -178,7 +183,11 @@ public class OrderTakingServiceImpl {
goodsVo.setCategory(good.getCategory());
goodsVo.setSpecString(null);
goodsVo.setIsRecommend(good.getIsRecommend());
goodsVo.setRecommendTag(good.getRecommendTag());
if (!StringUtils.isEmpty(good.getRecommendTag())) {
goodsVo.setRecommendTagList(JSON.parseArray(good.getRecommendTag(), String.class));
// goodsVo.setRecommendTag(good.getRecommendTag());
}
// if(recommendGoodsId.contains(String.valueOf(good.getId()))){
// goodsVo.setIsRecommend("1");
// }else{
......@@ -207,13 +216,13 @@ public class OrderTakingServiceImpl {
}
private void buildSkuRules(List<SkuVo> skuVos) {
if(CollectionUtils.isEmpty(skuVos)){
if (CollectionUtils.isEmpty(skuVos)) {
return;
}
for (SkuVo skuVo : skuVos) {
String rules = skuVo.getRulesString();
List<SpecRule> specRuleList = JSONObject.parseArray(rules, SpecRule.class);
boolean boo =true;
boolean boo = true;
List<SkuRuleVo> skuRuleVos = new ArrayList<>();
for (SpecRule specRule : specRuleList) {
SkuRuleVo skuRuleVo = new SkuRuleVo();
......@@ -222,12 +231,12 @@ public class OrderTakingServiceImpl {
skuRuleVo.setRuleId(String.valueOf(specRule.getId()));
skuRuleVo.setSpecId(String.valueOf(specRule.getSpecId()));
skuRuleVo.setRuleName(specRule.getName());
if(0L == specRule.getIsDefault()){
boo =false;
if (0L == specRule.getIsDefault()) {
boo = false;
}
}
skuVo.setIsDefault("0");
if(boo){
if (boo) {
skuVo.setIsDefault("1");
}
skuVo.setRules(JSONObject.parseArray(JSONObject.toJSONString(skuRuleVos)));
......@@ -235,10 +244,9 @@ public class OrderTakingServiceImpl {
}
}
private JSONArray buildGoodsSpec(String specs) {
List<Spec> specList = JSONObject.parseArray(specs,Spec.class);
List<Spec> specList = JSONObject.parseArray(specs, Spec.class);
List<SpecVo> specVos = new ArrayList<>();
for (Spec spec : specList) {
SpecVo specVo = new SpecVo();
......
package com.soss.system.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.soss.common.exception.ServiceException;
import com.soss.common.utils.StringUtils;
......@@ -14,6 +15,7 @@ import com.soss.system.mapper.ShopRecommendMapper;
import com.soss.system.service.IShopRecommendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.List;
......@@ -61,6 +63,13 @@ public class ShopRecommendServiceImpl implements IShopRecommendService {
public List<Goods> selectShopRecommendList(ShopRecommend shopRecommend) {
List<Goods> goodsList = shopRecommendMapper.selectShopRecommendGoods(shopRecommend.getShopId(), shopRecommend.getType());
goodsList = goodsList.stream().distinct().collect(Collectors.toList());
if (!CollectionUtils.isEmpty(goodsList)) {
goodsList.forEach(goods -> {
if (!StringUtils.isEmpty(goods.getRecommendTag())) {
goods.setRecommendTagList(JSON.parseArray(goods.getRecommendTag(), String.class));
}
});
}
/*for (Goods goods : goodsList) {
goods.setCategoryName(goodsCategoryMapper.selectGoodsCategoryById(String.valueOf(goods.getCategory())).getName());
goods.setSalesVolume(orderMapper.selectSalesVolume(Long.parseLong(shopRecommend.getShopId()),goods.getId()));
......@@ -87,6 +96,9 @@ public class ShopRecommendServiceImpl implements IShopRecommendService {
machine.setShopId(Long.parseLong(shopRecommend.getShopId()));
shopRecommend.setCreatedAt(new Date());
shopRecommend.setRecDate(new Date());
if (!CollectionUtils.isEmpty(shopRecommend.getRecommendTagList())) {
shopRecommend.setRecommendTag(JSON.toJSONString(shopRecommend.getRecommendTagList()));
}
shopRecommendMapper.insertShopRecommend(shopRecommend);
updateApplication(Long.parseLong(shopRecommend.getShopId()));
shopRecommend.setTurn(shopRecommend.getId());
......
package com.soss.system.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.soss.common.core.domain.AjaxResult;
......@@ -293,6 +294,9 @@ public class ShopServiceImpl implements IShopService {
if (shopRecommends.size() > 0) {
goods.setRecommend("0");
}
if (!StringUtils.isEmpty(goods.getRecommendTag())) {
goods.setRecommendTagList(JSON.parseArray(goods.getRecommendTag(), String.class));
}
shopRecommend.setType("2");
shopRecommends = shopRecommendMapper.selectShopRecommendList(shopRecommend);
if (shopRecommends.size() > 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment