新增批量删除和库存查询统计,优化部分查询统计
This commit is contained in:
parent
1e181a7638
commit
ec9ec45cb0
@ -30,4 +30,5 @@ public class RedisConstant {
|
|||||||
|
|
||||||
public static final String Product_Cate_Key = ConstantRedis.Cache_NameSpace + "product_cate_Key";
|
public static final String Product_Cate_Key = ConstantRedis.Cache_NameSpace + "product_cate_Key";
|
||||||
|
|
||||||
|
public static final String Store_Brand_Key = ConstantRedis.Cache_NameSpace + "store_brand_key";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,6 @@
|
|||||||
package com.suisung.mall.common.modules.product;
|
package com.suisung.mall.common.modules.product;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.Version;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -212,4 +209,8 @@ public class ShopProductIndex implements Serializable {
|
|||||||
|
|
||||||
@ApiModelProperty("是否特价商品,0否,1是")
|
@ApiModelProperty("是否特价商品,0否,1是")
|
||||||
private String is_special="0";
|
private String is_special="0";
|
||||||
|
|
||||||
|
@ApiModelProperty("统计库存")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Integer item_quantity=0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,6 +103,9 @@ public class ShopProductInfo implements Serializable {
|
|||||||
@TableField(updateStrategy=NOT_EMPTY)
|
@TableField(updateStrategy=NOT_EMPTY)
|
||||||
private Integer product_shop_card_discount;
|
private Integer product_shop_card_discount;
|
||||||
|
|
||||||
|
@ApiModelProperty("统计库存")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Integer item_quantity=0;
|
||||||
// @ApiModelProperty(value = "产品名称")
|
// @ApiModelProperty(value = "产品名称")
|
||||||
// @TableField(exist=false)
|
// @TableField(exist=false)
|
||||||
// private String productName;
|
// private String productName;
|
||||||
|
|||||||
@ -50,4 +50,8 @@ public interface ShopBaseProductBrandService extends IBaseService<ShopBaseProduc
|
|||||||
|
|
||||||
Map brand();
|
Map brand();
|
||||||
|
|
||||||
|
Map<String,Integer> getBrandMapByStoreId(String storeId);
|
||||||
|
|
||||||
|
void clearBrandMapByStoreId(String storeId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.suisung.mall.common.constant.RedisConstant;
|
||||||
import com.suisung.mall.common.domain.UserDto;
|
import com.suisung.mall.common.domain.UserDto;
|
||||||
import com.suisung.mall.common.exception.ApiException;
|
import com.suisung.mall.common.exception.ApiException;
|
||||||
import com.suisung.mall.common.modules.base.ShopBaseProductBrand;
|
import com.suisung.mall.common.modules.base.ShopBaseProductBrand;
|
||||||
@ -15,6 +16,7 @@ import com.suisung.mall.common.utils.CheckUtil;
|
|||||||
import com.suisung.mall.common.utils.FilterUtils;
|
import com.suisung.mall.common.utils.FilterUtils;
|
||||||
import com.suisung.mall.common.utils.I18nUtil;
|
import com.suisung.mall.common.utils.I18nUtil;
|
||||||
import com.suisung.mall.common.utils.TinyPinyinUtils;
|
import com.suisung.mall.common.utils.TinyPinyinUtils;
|
||||||
|
import com.suisung.mall.core.web.service.RedisService;
|
||||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||||
import com.suisung.mall.shop.base.mapper.ShopBaseProductBrandMapper;
|
import com.suisung.mall.shop.base.mapper.ShopBaseProductBrandMapper;
|
||||||
import com.suisung.mall.shop.base.service.ShopBaseProductBrandService;
|
import com.suisung.mall.shop.base.service.ShopBaseProductBrandService;
|
||||||
@ -51,6 +53,9 @@ public class ShopBaseProductBrandServiceImpl extends BaseServiceImpl<ShopBasePro
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ShopBaseProductCategoryService categoryService;
|
private ShopBaseProductCategoryService categoryService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisService redisService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, List<ShopBaseProductBrand>> brandMap() {
|
public Map<String, List<ShopBaseProductBrand>> brandMap() {
|
||||||
QueryWrapper<ShopBaseProductBrand> queryWrapper= new QueryWrapper<>();
|
QueryWrapper<ShopBaseProductBrand> queryWrapper= new QueryWrapper<>();
|
||||||
@ -261,4 +266,29 @@ public class ShopBaseProductBrandServiceImpl extends BaseServiceImpl<ShopBasePro
|
|||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String,Integer> getBrandMapByStoreId(String storeId) {
|
||||||
|
String key= RedisConstant.Store_Brand_Key+":"+storeId;
|
||||||
|
if(redisService.hasKey(key)){
|
||||||
|
Object o= redisService.hGetAll(key);
|
||||||
|
return Convert.toMap(String.class, Integer.class, o);
|
||||||
|
}
|
||||||
|
Map<String,Integer> resultMap=new HashMap<>();
|
||||||
|
QueryWrapper<ShopBaseProductBrand> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("store_id", Integer.valueOf(storeId));
|
||||||
|
List<ShopBaseProductBrand> list=this.list(queryWrapper);
|
||||||
|
if(CollUtil.isNotEmpty(list)){
|
||||||
|
resultMap= list.stream().collect(Collectors.toMap(ShopBaseProductBrand::getBrand_name, ShopBaseProductBrand::getBrand_id));
|
||||||
|
}
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void clearBrandMapByStoreId(String storeId) {
|
||||||
|
String key= RedisConstant.Store_Brand_Key+":"+storeId;
|
||||||
|
if(redisService.hasKey(key)){
|
||||||
|
redisService.del(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,6 +92,14 @@ public class ShopProductBaseController extends BaseControllerImpl {
|
|||||||
return CommonResult.success(shopProductBaseService.removeByProductId(product_id));
|
return CommonResult.success(shopProductBaseService.removeByProductId(product_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "商品批量删除", notes = "商品批量删除")
|
||||||
|
@RequestMapping(value = "/deleteBatch", method = RequestMethod.POST)
|
||||||
|
public CommonResult deleteBatch(@RequestParam(name = "product_ids") String product_ids) {
|
||||||
|
return CommonResult.success(shopProductBaseService.removeByProductIds(product_ids));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "商品基础表-商品审核", notes = "商品基础表-商品审核")
|
@ApiOperation(value = "商品基础表-商品审核", notes = "商品基础表-商品审核")
|
||||||
@RequestMapping(value = "/verify", method = RequestMethod.POST)
|
@RequestMapping(value = "/verify", method = RequestMethod.POST)
|
||||||
public CommonResult verify(@RequestParam(name = "product_id") Long product_id,
|
public CommonResult verify(@RequestParam(name = "product_id") Long product_id,
|
||||||
|
|||||||
@ -202,6 +202,8 @@ public interface ShopProductBaseService extends IBaseService<ShopProductBase> {
|
|||||||
|
|
||||||
boolean removeByProductId(Long product_id);
|
boolean removeByProductId(Long product_id);
|
||||||
|
|
||||||
|
boolean removeByProductIds(String product_ids);
|
||||||
|
|
||||||
CommonResult enable();
|
CommonResult enable();
|
||||||
|
|
||||||
long getOrderNum(Integer product_state_id, Integer store_id, Boolean day_flag, Integer subsite_id);
|
long getOrderNum(Integer product_state_id, Integer store_id, Boolean day_flag, Integer subsite_id);
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
|||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
@ -88,7 +89,6 @@ import java.math.RoundingMode;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
||||||
@ -213,11 +213,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
@Autowired
|
@Autowired
|
||||||
private StoreDbConfigService storeDbConfigService;
|
private StoreDbConfigService storeDbConfigService;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
private final static int delate_batch_limit=100;//删除最大限制
|
||||||
AtomicInteger count1 = new AtomicInteger(0);//全部
|
|
||||||
System.out.println(count1.addAndGet(10));
|
|
||||||
System.out.println(count1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean trySaveProduct(String productObj, String productItems) {
|
public boolean trySaveProduct(String productObj, String productItems) {
|
||||||
@ -831,6 +827,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
BigDecimal max_item_market_price = shopProductItemList.stream().map(ShopProductItem::getItem_market_price).max(BigDecimal::compareTo).get();
|
BigDecimal max_item_market_price = shopProductItemList.stream().map(ShopProductItem::getItem_market_price).max(BigDecimal::compareTo).get();
|
||||||
BigDecimal product_market_price = NumberUtil.max(max_item_unit_price, max_item_market_price);
|
BigDecimal product_market_price = NumberUtil.max(max_item_unit_price, max_item_market_price);
|
||||||
shopProductBase.setProduct_market_price(product_market_price);
|
shopProductBase.setProduct_market_price(product_market_price);
|
||||||
|
shopProductBase.setProduct_src_id(productId);
|
||||||
// 注:保存商品基本信息
|
// 注:保存商品基本信息
|
||||||
if (!saveOrUpdate(shopProductBase)) {
|
if (!saveOrUpdate(shopProductBase)) {
|
||||||
return Pair.of(false, I18nUtil._("保存 productBase 商品信息出错!"));
|
return Pair.of(false, I18nUtil._("保存 productBase 商品信息出错!"));
|
||||||
@ -865,7 +862,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
shopProductIndex.setProduct_unit_sp(Convert.toBigDecimal(shopProductBase.getProduct_unit_sp()));
|
shopProductIndex.setProduct_unit_sp(Convert.toBigDecimal(shopProductBase.getProduct_unit_sp()));
|
||||||
shopProductIndex.setProduct_state_id(shopProductBase.getProduct_state_id());
|
shopProductIndex.setProduct_state_id(shopProductBase.getProduct_state_id());
|
||||||
shopProductIndex.setProduct_verify_id(shopProductBase.getProduct_verify_id());
|
shopProductIndex.setProduct_verify_id(shopProductBase.getProduct_verify_id());
|
||||||
|
shopProductIndex.setProduct_src_id(productId);
|
||||||
// 判断店铺是否开启
|
// 判断店铺是否开启
|
||||||
shopProductIndex.setStore_is_open(storeBase.getStore_is_open());
|
shopProductIndex.setStore_is_open(storeBase.getStore_is_open());
|
||||||
shopProductIndex.setStore_is_selfsupport(storeBase.getStore_is_selfsupport());
|
shopProductIndex.setStore_is_selfsupport(storeBase.getStore_is_selfsupport());
|
||||||
@ -1067,11 +1064,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Serializable> item_ids_all = (List<Serializable>) CollUtil.union(item_ids_new, item_ids_old);
|
List<Serializable> item_ids_all = (List<Serializable>) CollUtil.union(item_ids_new, item_ids_old);
|
||||||
|
|
||||||
|
|
||||||
List<Serializable> item_ids_deprecate = (List<Serializable>) CollUtil.disjunction(item_ids_all, item_ids_new);
|
List<Serializable> item_ids_deprecate = (List<Serializable>) CollUtil.disjunction(item_ids_all, item_ids_new);
|
||||||
// item_ids_deprecate 的值如:[40,41,42] 商品 SKU ID 集合
|
|
||||||
// logger.info("商品 SKU ID item_ids_deprecate: {}", item_ids_deprecate);
|
|
||||||
|
|
||||||
//start 清理sku相关数据
|
//start 清理sku相关数据
|
||||||
if (CollUtil.isNotEmpty(item_ids_deprecate)) {
|
if (CollUtil.isNotEmpty(item_ids_deprecate)) {
|
||||||
@ -2742,9 +2735,9 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
public Map getList(QueryWrapper<ShopProductBase> wrapper, Integer pageNum, Integer pageSize) {
|
public Map getList(QueryWrapper<ShopProductBase> wrapper, Integer pageNum, Integer pageSize) {
|
||||||
|
|
||||||
Map map = new HashMap();
|
Map map = new HashMap();
|
||||||
Integer store_id = Convert.toInt(getCurrentUser().getStore_id(), 1);
|
Integer store_id = Convert.toInt(getCurrentUser().getStore_id(),1);
|
||||||
Integer nodeid = Convert.toInt(getParameter("nodeid"), 0);
|
Integer nodeid = Convert.toInt(getParameter("nodeid"), 0);
|
||||||
|
boolean openCount=getParameter("openCount",false);//1是开启,0是不开启
|
||||||
if (CheckUtil.isNotEmpty(nodeid)) {
|
if (CheckUtil.isNotEmpty(nodeid)) {
|
||||||
IPage<Long> listItem = shopProductBaseMapper.listItem(new Page<>(1, 9999), nodeid);
|
IPage<Long> listItem = shopProductBaseMapper.listItem(new Page<>(1, 9999), nodeid);
|
||||||
List<Long> item_ids = Convert.toList(Long.class, listItem.getRecords());
|
List<Long> item_ids = Convert.toList(Long.class, listItem.getRecords());
|
||||||
@ -2774,10 +2767,9 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
Integer category_id = Convert.toInt(getParameter("category_id"));
|
Integer category_id = Convert.toInt(getParameter("category_id"));
|
||||||
QueryWrapper<ShopProductIndex> cond_row = new QueryWrapper<>();
|
QueryWrapper<ShopProductIndex> cond_row = new QueryWrapper<>();
|
||||||
cond_row.orderByDesc("product_id");
|
cond_row.orderByDesc("product_id");
|
||||||
|
List<Integer> category_ids = new ArrayList<>();
|
||||||
if (CheckUtil.isNotEmpty(category_id)) {
|
if (CheckUtil.isNotEmpty(category_id)) {
|
||||||
List<Map> categoryList = shopBaseProductCategoryService.getCategoryByParentId(category_id, true, true);
|
List<Map> categoryList = shopBaseProductCategoryService.getCategoryByParentId(category_id, true, true);
|
||||||
List<Integer> category_ids = new ArrayList<>();
|
|
||||||
|
|
||||||
if (CollUtil.isNotEmpty(categoryList)) {
|
if (CollUtil.isNotEmpty(categoryList)) {
|
||||||
category_ids = categoryList.stream().map(s -> Convert.toInt(s.get("category_id"))).distinct().collect(Collectors.toList());
|
category_ids = categoryList.stream().map(s -> Convert.toInt(s.get("category_id"))).distinct().collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@ -2910,7 +2902,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
|
|
||||||
//判断是否为商家,且开启供应商,判断是否已经加入分销中
|
//判断是否为商家,且开启供应商,判断是否已经加入分销中
|
||||||
if (CollUtil.isNotEmpty(product_ids)) {
|
if (CollUtil.isNotEmpty(product_ids)) {
|
||||||
|
|
||||||
data.put("items", getProduct(product_ids));
|
data.put("items", getProduct(product_ids));
|
||||||
List<Map> items = (List<Map>) data.get("items");
|
List<Map> items = (List<Map>) data.get("items");
|
||||||
|
|
||||||
@ -2980,17 +2971,16 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean openCount = getParameter("openCount", false);//1是开启,0是不开启
|
|
||||||
if (openCount) {
|
if(openCount){
|
||||||
ShopProductIndex shopProductIndex = new ShopProductIndex();
|
Integer[] countArrays= countShopIndex(category_ids,store_id);
|
||||||
shopProductIndex.setCategory_id(category_id);
|
List<Map> itemsMap= (List<Map>) data.get("items");
|
||||||
shopProductIndex.setStore_id(store_id);
|
data.put("items", countItemQuantity(itemsMap));//统计存储
|
||||||
Integer[] countArrays = countShopIndex(shopProductIndex);
|
data.put("allRecords",countArrays[0]);//全部
|
||||||
data.put("allRecords", countArrays[0]);//全部
|
data.put("normalRecords",countArrays[1]);//销售中
|
||||||
data.put("normalRecords", countArrays[1]);//销售中
|
data.put("offRecords",countArrays[2]);//仓库中
|
||||||
data.put("offRecords", countArrays[2]);//仓库中
|
data.put("illegalRecords",countArrays[3]);//违规禁售
|
||||||
data.put("illegalRecords", countArrays[3]);//违规禁售
|
data.put("unCheckedRecords",countArrays[4]);//未分配或者待审核
|
||||||
data.put("unCheckedRecords", countArrays[4]);//未分配或者待审核
|
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -3146,20 +3136,17 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean removeByProductId(Long product_id) {
|
public boolean removeByProductId(Long product_id) {
|
||||||
|
|
||||||
UserDto user = getCurrentUser();
|
UserDto user = getCurrentUser();
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new ApiException(ResultCode.NEED_LOGIN);
|
throw new ApiException(ResultCode.NEED_LOGIN);
|
||||||
}
|
}
|
||||||
Integer storeId = Convert.toInt(user.getStore_id());
|
Integer storeId = Convert.toInt(user.getStore_id());
|
||||||
|
|
||||||
QueryWrapper<ShopOrderItem> itemQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<ShopOrderItem> itemQueryWrapper = new QueryWrapper<>();
|
||||||
itemQueryWrapper.eq("product_id", product_id);
|
itemQueryWrapper.eq("product_id", product_id);
|
||||||
if (shopOrderItemService.findOne(itemQueryWrapper) != null) {
|
if (shopOrderItemService.findOne(itemQueryWrapper) != null) {
|
||||||
throw new ApiException(I18nUtil._("不能删除被购买的商品!"));
|
throw new ApiException(I18nUtil._("不能删除被购买的商品!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 不使用缓存
|
// 不使用缓存
|
||||||
ShopProductBase shopProductBase = getById(product_id);
|
ShopProductBase shopProductBase = getById(product_id);
|
||||||
Map row = Convert.toMap(Object.class, Object.class, shopProductBase);
|
Map row = Convert.toMap(Object.class, Object.class, shopProductBase);
|
||||||
@ -3602,6 +3589,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改商品状态
|
* 修改商品状态
|
||||||
*/
|
*/
|
||||||
@ -5340,6 +5328,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
// 已存在商品,设置ID并加入更新列表
|
// 已存在商品,设置ID并加入更新列表
|
||||||
Long existId = existingProducts.get(key);
|
Long existId = existingProducts.get(key);
|
||||||
base.setProduct_id(existId);
|
base.setProduct_id(existId);
|
||||||
|
base.setProduct_src_id(existId);
|
||||||
shopProductBaseList.get(i).setProduct_id(existId);
|
shopProductBaseList.get(i).setProduct_id(existId);
|
||||||
//shopProductIndexList.get(i).setProduct_id(existId);
|
//shopProductIndexList.get(i).setProduct_id(existId);
|
||||||
// shopProductIndexList.get(i).setProduct_unit_points(BigDecimal.ZERO);
|
// shopProductIndexList.get(i).setProduct_unit_points(BigDecimal.ZERO);
|
||||||
@ -5348,6 +5337,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
shopProductIndexList.get(i).setProduct_sale_time(base.getProduct_sale_time().getTime());
|
shopProductIndexList.get(i).setProduct_sale_time(base.getProduct_sale_time().getTime());
|
||||||
shopProductIndexList.get(i).setProduct_verify_id(base.getProduct_verify_id());
|
shopProductIndexList.get(i).setProduct_verify_id(base.getProduct_verify_id());
|
||||||
shopProductIndexList.get(i).setProduct_state_id(base.getProduct_state_id());
|
shopProductIndexList.get(i).setProduct_state_id(base.getProduct_state_id());
|
||||||
|
shopProductIndexList.get(i).setProduct_src_id(existId);
|
||||||
// 判断店铺是否开启
|
// 判断店铺是否开启
|
||||||
// shopProductIndexList.get(i).setStore_is_open(1);
|
// shopProductIndexList.get(i).setStore_is_open(1);
|
||||||
// shopProductIndexList.get(i).setStore_is_selfsupport(1);
|
// shopProductIndexList.get(i).setStore_is_selfsupport(1);
|
||||||
@ -5489,12 +5479,15 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
Long productId = newIds.get(i);
|
Long productId = newIds.get(i);
|
||||||
ShopProductBase base = newProducts.get(i);
|
ShopProductBase base = newProducts.get(i);
|
||||||
base.setProduct_id(productId);
|
base.setProduct_id(productId);
|
||||||
|
base.setProduct_src_id(productId);
|
||||||
// 设置关联ID
|
// 设置关联ID
|
||||||
newProducts.get(i).setProduct_id(productId);
|
newProducts.get(i).setProduct_id(productId);
|
||||||
newShopProductIndexList.get(i).setProduct_id(productId);
|
newShopProductIndexList.get(i).setProduct_id(productId);
|
||||||
|
newShopProductIndexList.get(i).setProduct_src_id(productId);
|
||||||
newShopProductDataList.get(i).setProduct_id(productId);
|
newShopProductDataList.get(i).setProduct_id(productId);
|
||||||
newShopProductDetailList.get(i).setProduct_id(productId);
|
newShopProductDetailList.get(i).setProduct_id(productId);
|
||||||
newShopProductInfoList.get(i).setProduct_id(productId);
|
newShopProductInfoList.get(i).setProduct_id(productId);
|
||||||
|
|
||||||
// 处理商品项
|
// 处理商品项
|
||||||
List<ShopProductItem> items = newShopProductItemList.get(i);
|
List<ShopProductItem> items = newShopProductItemList.get(i);
|
||||||
processProductItems(items, productId, addItemSeqs);
|
processProductItems(items, productId, addItemSeqs);
|
||||||
@ -6143,51 +6136,51 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
}
|
}
|
||||||
|
|
||||||
//计算全部,销售中,仓库中,违规禁销,未分配商品的数量
|
//计算全部,销售中,仓库中,违规禁销,未分配商品的数量
|
||||||
public Integer[] countShopIndex(ShopProductIndex shopProductIndex) {
|
public Integer[] countShopIndex(List<Integer> category_ids,Integer storeId) {
|
||||||
//商品状态:1001-正常;1002-下架仓库中;1003-待审核; 1000-违规禁售,1003
|
//商品状态:1001-正常;1002-下架仓库中;1003-待审核; 1000-违规禁售,1003
|
||||||
int taskCount = 5;
|
int taskCount = 5;
|
||||||
CompletableFuture<Integer> count1 = CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Integer> count1 = CompletableFuture.supplyAsync(() -> {
|
||||||
QueryWrapper<ShopProductIndex> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||||
if (ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())) {
|
if(CollectionUtil.isNotEmpty(category_ids)){
|
||||||
queryWrapper.eq("category_id", shopProductIndex.getCategory_id());
|
queryWrapper.in("category_id",category_ids);
|
||||||
}
|
}
|
||||||
queryWrapper.eq("store_id", shopProductIndex.getStore_id());
|
queryWrapper.eq("store_id",storeId);
|
||||||
return ((int) shopProductIndexService.count(queryWrapper));
|
return ((int) shopProductIndexService.count(queryWrapper));
|
||||||
});
|
});
|
||||||
CompletableFuture<Integer> count2 = CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Integer> count2 = CompletableFuture.supplyAsync(() -> {
|
||||||
QueryWrapper<ShopProductIndex> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||||
if (ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())) {
|
if(CollectionUtil.isNotEmpty(category_ids)){
|
||||||
queryWrapper.eq("category_id", shopProductIndex.getCategory_id());
|
queryWrapper.in("category_id",category_ids);
|
||||||
}
|
}
|
||||||
queryWrapper.eq("store_id", shopProductIndex.getStore_id());
|
queryWrapper.eq("store_id",storeId);
|
||||||
queryWrapper.eq("product_state_id", StateCode.PRODUCT_STATE_NORMAL);
|
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_NORMAL);
|
||||||
return ((int) shopProductIndexService.count(queryWrapper));
|
return ((int) shopProductIndexService.count(queryWrapper));
|
||||||
});
|
});
|
||||||
CompletableFuture<Integer> count3 = CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Integer> count3 = CompletableFuture.supplyAsync(() -> {
|
||||||
QueryWrapper<ShopProductIndex> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||||
if (ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())) {
|
if(CollectionUtil.isNotEmpty(category_ids)){
|
||||||
queryWrapper.eq("category_id", shopProductIndex.getCategory_id());
|
queryWrapper.in("category_id",category_ids);
|
||||||
}
|
}
|
||||||
queryWrapper.eq("store_id", shopProductIndex.getStore_id());
|
queryWrapper.eq("store_id",storeId);
|
||||||
queryWrapper.eq("product_state_id", StateCode.PRODUCT_STATE_OFF_THE_SHELF);
|
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_OFF_THE_SHELF);
|
||||||
return ((int) shopProductIndexService.count(queryWrapper));
|
return ((int) shopProductIndexService.count(queryWrapper));
|
||||||
});
|
});
|
||||||
CompletableFuture<Integer> count4 = CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Integer> count4 = CompletableFuture.supplyAsync(() -> {
|
||||||
QueryWrapper<ShopProductIndex> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||||
if (ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())) {
|
if(CollectionUtil.isNotEmpty(category_ids)){
|
||||||
queryWrapper.eq("category_id", shopProductIndex.getCategory_id());
|
queryWrapper.in("category_id",category_ids);
|
||||||
}
|
}
|
||||||
queryWrapper.eq("store_id", shopProductIndex.getStore_id());
|
queryWrapper.eq("store_id",storeId);
|
||||||
queryWrapper.eq("product_state_id", StateCode.PRODUCT_STATE_ILLEGAL);
|
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_ILLEGAL);
|
||||||
return ((int) shopProductIndexService.count(queryWrapper));
|
return ((int) shopProductIndexService.count(queryWrapper));
|
||||||
});
|
});
|
||||||
CompletableFuture<Integer> count5 = CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Integer> count5 = CompletableFuture.supplyAsync(() -> {
|
||||||
QueryWrapper<ShopProductIndex> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||||
if (ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())) {
|
if(CollectionUtil.isNotEmpty(category_ids)){
|
||||||
queryWrapper.eq("category_id", shopProductIndex.getCategory_id());
|
queryWrapper.in("category_id",category_ids);
|
||||||
}
|
}
|
||||||
queryWrapper.eq("store_id", shopProductIndex.getStore_id());
|
queryWrapper.eq("store_id",storeId);
|
||||||
queryWrapper.eq("product_state_id", StateCode.PRODUCT_STATE_OFF_THE_SHELF_UNCHECK);
|
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_OFF_THE_SHELF_UNCHECK);
|
||||||
return ((int) shopProductIndexService.count(queryWrapper));
|
return ((int) shopProductIndexService.count(queryWrapper));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -6209,4 +6202,53 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
return resultInt;
|
return resultInt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*统计商品的库存
|
||||||
|
* @param items
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private List<Map> countItemQuantity(List<Map> items){
|
||||||
|
if(items.isEmpty()){
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
List<Long> prductIds=items.stream().map(map -> {
|
||||||
|
return (Long)map.get("product_id");
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
Integer storId= MapUtil.getInt(items.get(0),"store_id",1);
|
||||||
|
QueryWrapper<ShopProductItem> queryWrapper=new QueryWrapper<>();
|
||||||
|
queryWrapper.select("product_id,sum(item_quantity) as item_quantity");
|
||||||
|
queryWrapper.in("product_id",prductIds);
|
||||||
|
queryWrapper.eq("store_id",storId);
|
||||||
|
queryWrapper.groupBy("product_id");
|
||||||
|
List<ShopProductItem> shopProductItems= shopProductItemService.list(queryWrapper);
|
||||||
|
Map<Long,Integer> countMap=shopProductItems.stream().collect(Collectors.toMap(ShopProductItem::getProduct_id,ShopProductItem::getItem_quantity));
|
||||||
|
items.forEach(shopProductIndex -> {
|
||||||
|
shopProductIndex.put("item_quantity",MapUtil.getLong(countMap,shopProductIndex.get("product_id")));
|
||||||
|
});
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public boolean removeByProductIds(String product_ids) {
|
||||||
|
if(product_ids.contains(",")){
|
||||||
|
String[] productIds= product_ids.split(",");
|
||||||
|
if(productIds.length>delate_batch_limit){
|
||||||
|
throw new ApiException("最大删除数量为100");
|
||||||
|
}
|
||||||
|
Arrays.stream(productIds)
|
||||||
|
.filter(Objects::nonNull) // 先过滤null
|
||||||
|
.distinct().forEach(productId->{
|
||||||
|
try {
|
||||||
|
removeByProductId(Long.valueOf(productId));
|
||||||
|
}catch (RuntimeException e){
|
||||||
|
throw new ApiException(e.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else {
|
||||||
|
removeByProductId(Long.valueOf(product_ids));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,5 +30,6 @@ public class SxCategoryModel {
|
|||||||
private String first_category_name;
|
private String first_category_name;
|
||||||
@ApiModelProperty(value = "第二级父类")
|
@ApiModelProperty(value = "第二级父类")
|
||||||
private String second_category_name;
|
private String second_category_name;
|
||||||
|
@ApiModelProperty(value = "品牌名称")
|
||||||
|
private String brandName;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -166,7 +166,6 @@ public class SyncThirdDataController {
|
|||||||
return new ThirdApiRes().success("服务器已执行活动数据操作");
|
return new ThirdApiRes().success("服务器已执行活动数据操作");
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo test
|
|
||||||
@ApiOperation(value = "同步活动商品数据", notes = "同步活动商品数据")
|
@ApiOperation(value = "同步活动商品数据", notes = "同步活动商品数据")
|
||||||
@RequestMapping(value = "/syncAtiveShop", method = RequestMethod.POST)
|
@RequestMapping(value = "/syncAtiveShop", method = RequestMethod.POST)
|
||||||
public ThirdApiRes syncAtiveShop(@RequestParam String appKey,
|
public ThirdApiRes syncAtiveShop(@RequestParam String appKey,
|
||||||
@ -176,4 +175,13 @@ public class SyncThirdDataController {
|
|||||||
return new ThirdApiRes().success("服务器已执行活动数据操作");
|
return new ThirdApiRes().success("服务器已执行活动数据操作");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//todo test
|
||||||
|
@ApiOperation(value = "刷新时间", notes = "刷新时间")
|
||||||
|
@RequestMapping(value = "/syncRefreshTime", method = RequestMethod.POST)
|
||||||
|
public ThirdApiRes syncRefreshTime(@RequestParam String appKey,
|
||||||
|
@RequestParam String sign) {
|
||||||
|
|
||||||
|
return syncThirdDataService.syncRefreshTime(appKey,sign);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import com.suisung.mall.common.pojo.req.SyncThirdMemberReq;
|
|||||||
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -161,4 +162,9 @@ public interface SyncThirdDataService {
|
|||||||
* 同步匹配商品图库数据
|
* 同步匹配商品图库数据
|
||||||
*/
|
*/
|
||||||
void syncShopImages(Integer storeId);
|
void syncShopImages(Integer storeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷新时间
|
||||||
|
*/
|
||||||
|
ThirdApiRes syncRefreshTime(@RequestParam String appKey, @RequestParam String sign);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -116,6 +116,7 @@ public abstract class SyncBaseThirdSxAbstract{
|
|||||||
ShopBaseProductType productType=new ShopBaseProductType();
|
ShopBaseProductType productType=new ShopBaseProductType();
|
||||||
productType.setType_is_draft(1);//发布
|
productType.setType_is_draft(1);//发布
|
||||||
productType.setStore_id(Integer.valueOf(storeId));
|
productType.setStore_id(Integer.valueOf(storeId));
|
||||||
|
String brandName=o.getStr("brandName","其他品牌");
|
||||||
if (o != null) {
|
if (o != null) {
|
||||||
// 重要:分类类型处理(强调共性)
|
// 重要:分类类型处理(强调共性)
|
||||||
Integer typeId = 1001;
|
Integer typeId = 1001;
|
||||||
@ -125,11 +126,19 @@ public abstract class SyncBaseThirdSxAbstract{
|
|||||||
if (productType != null) {
|
if (productType != null) {
|
||||||
typeId = productType.getType_id();
|
typeId = productType.getType_id();
|
||||||
} else {
|
} else {
|
||||||
|
QueryWrapper<ShopBaseProductBrand> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("store_id",Integer.valueOf(storeId));
|
||||||
|
queryWrapper.eq("brand_name",brandName);
|
||||||
|
ShopBaseProductBrand shopBaseProductBrand=productBrandService.findOne(queryWrapper);
|
||||||
// 新增一个类型
|
// 新增一个类型
|
||||||
ShopBaseProductType newProductType = new ShopBaseProductType();
|
ShopBaseProductType newProductType = new ShopBaseProductType();
|
||||||
newProductType.setType_name(o.getStr("product_type"));
|
newProductType.setType_name(o.getStr("product_type"));
|
||||||
newProductType.setType_buildin(0);
|
newProductType.setType_buildin(0);
|
||||||
|
newProductType.setType_is_draft(0);//发布
|
||||||
newProductType.setStore_id(Integer.valueOf(storeId));
|
newProductType.setStore_id(Integer.valueOf(storeId));
|
||||||
|
if(null!=shopBaseProductBrand){
|
||||||
|
newProductType.setType_brand_ids(String.valueOf(shopBaseProductBrand.getBrand_id()));
|
||||||
|
}
|
||||||
if (productTypeService.save(newProductType)) {
|
if (productTypeService.save(newProductType)) {
|
||||||
typeId = newProductType.getType_id();
|
typeId = newProductType.getType_id();
|
||||||
}
|
}
|
||||||
@ -510,6 +519,7 @@ public abstract class SyncBaseThirdSxAbstract{
|
|||||||
accountUserInfo.setUser_id(userId);
|
accountUserInfo.setUser_id(userId);
|
||||||
accountUserInfo.setUser_type_id(0);
|
accountUserInfo.setUser_type_id(0);
|
||||||
accountUserInfo.setUser_mobile(user_mobile);
|
accountUserInfo.setUser_mobile(user_mobile);
|
||||||
|
accountUserInfo.setUser_realname(syncThirdMemberReq.getUser_realname());
|
||||||
accountUserInfo.setUser_level_card(syncThirdMemberReq.getUser_level_card());
|
accountUserInfo.setUser_level_card(syncThirdMemberReq.getUser_level_card());
|
||||||
//user_level_id
|
//user_level_id
|
||||||
accountUserInfo.setUser_level_id(1); // todo select id
|
accountUserInfo.setUser_level_id(1); // todo select id
|
||||||
@ -655,7 +665,7 @@ public abstract class SyncBaseThirdSxAbstract{
|
|||||||
* @param storeId
|
* @param storeId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int baseSaveOrUpdateGoodsBatch(JSONArray goodsListJSON,String storeId,String isNegativeAllowed,String priorityMode){
|
public int baseSaveOrUpdateGoodsBatch(JSONArray goodsListJSON,String storeId,String isNegativeAllowed,String priorityMode,Map<String,Integer> brandMaps){
|
||||||
AtomicInteger resultCount = new AtomicInteger();
|
AtomicInteger resultCount = new AtomicInteger();
|
||||||
Map categoryMap= productCategoryService.getCategoryListByStoreId(storeId);//热数据加载
|
Map categoryMap= productCategoryService.getCategoryListByStoreId(storeId);//热数据加载
|
||||||
List<ShopProductBase> shopProductBaseList=new ArrayList<>();
|
List<ShopProductBase> shopProductBaseList=new ArrayList<>();
|
||||||
@ -751,6 +761,7 @@ public abstract class SyncBaseThirdSxAbstract{
|
|||||||
shopProductIndex.setCoupon_type_id(0);// product_assist_data // 辅助属性值列(DOT)
|
shopProductIndex.setCoupon_type_id(0);// product_assist_data // 辅助属性值列(DOT)
|
||||||
shopProductIndex.setProduct_transport_id(String.valueOf(StateCode.DELIVERY_TYPE_SAME_CITY));
|
shopProductIndex.setProduct_transport_id(String.valueOf(StateCode.DELIVERY_TYPE_SAME_CITY));
|
||||||
shopProductIndex.setIs_special(shopProductBase.getIs_special());
|
shopProductIndex.setIs_special(shopProductBase.getIs_special());
|
||||||
|
shopProductIndex.setBrand_id(brandMaps.get(jsonObj.getStr("brand_name")));
|
||||||
if(categoryId!=0){
|
if(categoryId!=0){
|
||||||
Integer typeId = (Integer) categoryMap.get(categoryId.toString());
|
Integer typeId = (Integer) categoryMap.get(categoryId.toString());
|
||||||
if (ObjectUtil.isNotEmpty(typeId)) {
|
if (ObjectUtil.isNotEmpty(typeId)) {
|
||||||
|
|||||||
@ -46,6 +46,7 @@ import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
|||||||
import com.suisung.mall.common.utils.I18nUtil;
|
import com.suisung.mall.common.utils.I18nUtil;
|
||||||
import com.suisung.mall.common.utils.StringUtils;
|
import com.suisung.mall.common.utils.StringUtils;
|
||||||
import com.suisung.mall.core.web.service.RedisService;
|
import com.suisung.mall.core.web.service.RedisService;
|
||||||
|
import com.suisung.mall.shop.base.service.ShopBaseProductBrandService;
|
||||||
import com.suisung.mall.shop.base.service.ShopBaseProductCategoryService;
|
import com.suisung.mall.shop.base.service.ShopBaseProductCategoryService;
|
||||||
import com.suisung.mall.shop.base.service.ShopBaseProductSpecService;
|
import com.suisung.mall.shop.base.service.ShopBaseProductSpecService;
|
||||||
import com.suisung.mall.shop.number.service.ShopNumberSeqService;
|
import com.suisung.mall.shop.number.service.ShopNumberSeqService;
|
||||||
@ -88,6 +89,7 @@ import org.springframework.http.ResponseEntity;
|
|||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -135,9 +137,6 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
|||||||
@Autowired
|
@Autowired
|
||||||
private OssService ossService;
|
private OssService ossService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RedisService redisService;
|
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisTemplate redisTemplate;
|
private RedisTemplate redisTemplate;
|
||||||
@ -171,6 +170,9 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
|||||||
@Autowired
|
@Autowired
|
||||||
private AccountService accountService;
|
private AccountService accountService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ShopBaseProductBrandService productBrandService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量保存商品的分类
|
* 批量保存商品的分类
|
||||||
*
|
*
|
||||||
@ -570,6 +572,8 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
|||||||
List<String> failFolders = new ArrayList<>();
|
List<String> failFolders = new ArrayList<>();
|
||||||
List<String> failMessage = new ArrayList<>();
|
List<String> failMessage = new ArrayList<>();
|
||||||
shopBaseProductCategoryService.getCategoryListByStoreId(storeId);
|
shopBaseProductCategoryService.getCategoryListByStoreId(storeId);
|
||||||
|
// getBrandMapByStoreId()
|
||||||
|
Map<String,Integer> brandMaps= productBrandService.getBrandMapByStoreId(storeId);
|
||||||
QueryWrapper<StoreDbConfig> storeDbConfigQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<StoreDbConfig> storeDbConfigQueryWrapper = new QueryWrapper<>();
|
||||||
storeDbConfigQueryWrapper.eq("store_id", storeId);
|
storeDbConfigQueryWrapper.eq("store_id", storeId);
|
||||||
StoreDbConfig storeDbConfig = storeDbConfigService.getOne(storeDbConfigQueryWrapper);
|
StoreDbConfig storeDbConfig = storeDbConfigService.getOne(storeDbConfigQueryWrapper);
|
||||||
@ -586,7 +590,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
|||||||
String fileName = "good_" + (taskId + 1) + ".txt";
|
String fileName = "good_" + (taskId + 1) + ".txt";
|
||||||
JSONArray jsonArray = new ThreadFileUtils().processFolder(taskName, newFolders.get(taskId));
|
JSONArray jsonArray = new ThreadFileUtils().processFolder(taskName, newFolders.get(taskId));
|
||||||
try {
|
try {
|
||||||
baseSaveOrUpdateGoodsBatch(jsonArray, storeId,isNegativeAllowed,priorityMode);
|
baseSaveOrUpdateGoodsBatch(jsonArray, storeId,isNegativeAllowed,priorityMode,brandMaps);
|
||||||
success.getAndIncrement();
|
success.getAndIncrement();
|
||||||
threadNum.decrementAndGet();
|
threadNum.decrementAndGet();
|
||||||
return "成功" + taskId;
|
return "成功" + taskId;
|
||||||
@ -618,6 +622,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
|||||||
shopBaseProductCategoryService.clearCategoryCache(storeId);
|
shopBaseProductCategoryService.clearCategoryCache(storeId);
|
||||||
shopProductSpecItemService.clearExistItem(Integer.valueOf(storeId));
|
shopProductSpecItemService.clearExistItem(Integer.valueOf(storeId));
|
||||||
baseProductSpecService.clearShopBaseProductSpecMap(Integer.valueOf(storeId));
|
baseProductSpecService.clearShopBaseProductSpecMap(Integer.valueOf(storeId));
|
||||||
|
productBrandService.clearBrandMapByStoreId(storeId);
|
||||||
List<SyncFileLog> syncFileLogs = new ArrayList<>();
|
List<SyncFileLog> syncFileLogs = new ArrayList<>();
|
||||||
for (int i = 0; i < failFolders.size(); i++) {
|
for (int i = 0; i < failFolders.size(); i++) {
|
||||||
String path = failFolders.get(i);
|
String path = failFolders.get(i);
|
||||||
@ -659,6 +664,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
|||||||
syncShopImageService.syncMapingShopImages(storeId);
|
syncShopImageService.syncMapingShopImages(storeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Resource> downloadToClient(String primaryKey, String clienVersionName) {
|
public ResponseEntity<Resource> downloadToClient(String primaryKey, String clienVersionName) {
|
||||||
logger.info("primaryKey:{}", primaryKey);
|
logger.info("primaryKey:{}", primaryKey);
|
||||||
@ -917,18 +923,6 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
|||||||
|
|
||||||
String newfolder=new FileUtils().getSyncTypeFlag(syncType,clientPath)+storeId+FileUtils.pathSeparator+folders.get(0)+FileUtils.pathSeparator;
|
String newfolder=new FileUtils().getSyncTypeFlag(syncType,clientPath)+storeId+FileUtils.pathSeparator+folders.get(0)+FileUtils.pathSeparator;
|
||||||
upLoadZipToOss(newfolder);//上传文件到cos
|
upLoadZipToOss(newfolder);//上传文件到cos
|
||||||
//更新当前的获取时间,用户客户端获取
|
|
||||||
try {
|
|
||||||
QueryWrapper<StoreDbConfig> storeDbConfigQueryWrapper = new QueryWrapper<>();
|
|
||||||
storeDbConfigQueryWrapper.eq("store_id", storeId);
|
|
||||||
StoreDbConfig storeDbConfig=storeDbConfigService.getOne(storeDbConfigQueryWrapper);
|
|
||||||
if(ObjectUtil.isNotEmpty(storeDbConfig)){
|
|
||||||
storeDbConfig.setRefreshTime(refreshDate);
|
|
||||||
storeDbConfigService.saveOrUpdate(storeDbConfig);
|
|
||||||
}
|
|
||||||
}catch (RuntimeException e){
|
|
||||||
logger.error("同步时间失败"+e.getMessage());
|
|
||||||
}
|
|
||||||
return new ThirdApiRes().success("上传成功");
|
return new ThirdApiRes().success("上传成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1233,4 +1227,33 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ThirdApiRes syncRefreshTime(@RequestParam String appKey, @RequestParam String sign) {
|
||||||
|
if (StrUtil.isBlank(appKey) || StrUtil.isBlank(sign) ) {
|
||||||
|
return new ThirdApiRes().fail(1003, I18nUtil._("缺少必要参数!"));
|
||||||
|
}
|
||||||
|
// 验签、appid,必要参数判断
|
||||||
|
SyncApp syncApp = syncAppService.getOne(new LambdaQueryWrapper<SyncApp>()
|
||||||
|
.select(SyncApp::getApp_key, SyncApp::getApp_secret,SyncApp::getStore_id)
|
||||||
|
.eq(SyncApp::getApp_key, appKey)
|
||||||
|
.eq(SyncApp::getApp_secret,sign));
|
||||||
|
if (syncApp == null) {
|
||||||
|
return new ThirdApiRes().fail(1001, I18nUtil._("签名有误!"));
|
||||||
|
}
|
||||||
|
Date tenMinutesAgo = Date.from(Instant.now().minus(Duration.ofMinutes(30)));//校准误差
|
||||||
|
Date refreshDate = DateUtil.date(tenMinutesAgo);
|
||||||
|
//更新当前的获取时间,用户客户端获取
|
||||||
|
try {
|
||||||
|
QueryWrapper<StoreDbConfig> storeDbConfigQueryWrapper = new QueryWrapper<>();
|
||||||
|
storeDbConfigQueryWrapper.eq("store_id", syncApp.getStore_id());
|
||||||
|
StoreDbConfig storeDbConfig=storeDbConfigService.getOne(storeDbConfigQueryWrapper);
|
||||||
|
if(ObjectUtil.isNotEmpty(storeDbConfig)){
|
||||||
|
storeDbConfig.setRefreshTime(refreshDate);
|
||||||
|
storeDbConfigService.saveOrUpdate(storeDbConfig);
|
||||||
|
}
|
||||||
|
}catch (RuntimeException e){
|
||||||
|
logger.error("同步时间失败"+e.getMessage());
|
||||||
|
}
|
||||||
|
return new ThirdApiRes().success("时间同步完成");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user