Compare commits
2 Commits
1e181a7638
...
f097de7733
| Author | SHA1 | Date | |
|---|---|---|---|
| f097de7733 | |||
| ec9ec45cb0 |
@ -1,19 +1,14 @@
|
||||
package com.small.client.Utils;
|
||||
|
||||
import cn.hutool.json.JSON;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.small.client.dto.StoreDbConfig;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class HttpUtils {
|
||||
@ -47,6 +42,9 @@ public class HttpUtils {
|
||||
|
||||
public static final String URL_SYNC_ACTIVE_SHOP="/shop/sync/third/syncAtiveShop";//同步活动商品到服务器
|
||||
|
||||
public static final String URL_SYNC_REFRESH="/shop/sync/third/syncRefreshTime";//同步记录刷新时间
|
||||
|
||||
|
||||
public static String postData(RestTemplate restTemplate, String url,Object modelObject){
|
||||
// 创建表单参数
|
||||
// MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
|
||||
|
||||
@ -2,8 +2,6 @@ package com.small.client.dao;
|
||||
|
||||
import com.microsoft.sqlserver.jdbc.SQLServerDataSource;
|
||||
import com.microsoft.sqlserver.jdbc.SQLServerException;
|
||||
|
||||
import com.small.client.dto.DataBaseInfo;
|
||||
import com.small.client.dto.ResultDto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@ -488,4 +486,34 @@ public class BaseDao {
|
||||
}
|
||||
|
||||
|
||||
public ResultDto getclsMapBrand(String ip, String username, String password,Integer portNumber, String dataBaseName){
|
||||
Connection connection=getConnection(ip,username,password,portNumber,dataBaseName);
|
||||
String sql= "select tb.code_name,cls.item_clsname\n" +
|
||||
"from\n" +
|
||||
"(\n" +
|
||||
"select * \n" +
|
||||
" from(\n" +
|
||||
" select \n" +
|
||||
" ROW_NUMBER() OVER(partition by b.item_clsno order by item_no) as rn,b.item_clsno,b.item_brand\n" +
|
||||
" from t_bd_item_info b\n" +
|
||||
" )t where rn=1\n" +
|
||||
")cb left join T_BD_BASE_CODE tb on cb.item_brand=tb.code_id\n" +
|
||||
"left join t_bd_item_cls cls on cb.item_clsno=cls.item_clsno" ;
|
||||
sql=String.format(sql);
|
||||
log.info(sql);
|
||||
ResultDto resultDto=new ResultDto();
|
||||
ResultSet rs=null;
|
||||
try {
|
||||
PreparedStatement ps= connection.prepareStatement(sql);
|
||||
rs = ps.executeQuery();
|
||||
} catch (SQLException e) {
|
||||
log.info("数据库查询异常方法{},异常信息{}","com.suisung.mall.shop.sixun.dao.BaseDao.baseFindListJoin",e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
resultDto.setResultSet(rs);
|
||||
resultDto.setConnection(connection);
|
||||
return resultDto;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -2,20 +2,17 @@ package com.small.client.dao;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.small.client.Utils.BigDecimalFormatter;
|
||||
import com.small.client.dto.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 考虑到每个思迅软件都是自己的数据,所以采用动态获取的方式获取数据
|
||||
@ -228,7 +225,7 @@ public class SxDataDao extends BaseDao{
|
||||
sxSyncGoods.setValid_days(getStopDate(rs));//保质期 todo stop_date-build_date?
|
||||
|
||||
sxSyncGoods.setItem_brand_name(rs.getString("item_brandname"));
|
||||
sxSyncGoods.setItemBrand(rs.getString("item_brand"));
|
||||
sxSyncGoods.setItemBrand(rs.getString("item_brand").trim());
|
||||
sxSyncGoods.setItem_clsno(rs.getString("item_clsno").trim());
|
||||
sxSyncGoods.setItem_size(rs.getString("item_size"));
|
||||
|
||||
@ -269,8 +266,8 @@ public class SxDataDao extends BaseDao{
|
||||
int cardStatus=rs.getInt("card_status");
|
||||
if(cardStatus!=1){
|
||||
sxSyncVip.setVip_name(rs.getString("vip_name"));//会员名称
|
||||
sxSyncVip.setVip_sex(rs.getString("vip_sex"));//会员名称
|
||||
sxSyncVip.setMobile(rs.getString("mobile"));//会员名称
|
||||
sxSyncVip.setVip_sex(rs.getString("vip_sex").trim());//性别
|
||||
sxSyncVip.setMobile(rs.getString("mobile"));//手机号
|
||||
sxSyncVip.setBirthday(rs.getString("birthday"));//会员生日
|
||||
sxSyncVip.setCard_type(rs.getString("card_type")==null?"v1":rs.getString("card_type"));//会员生日
|
||||
sxSyncVip.setCard_no(rs.getString("card_id"));//会员卡号
|
||||
@ -325,11 +322,11 @@ public class SxDataDao extends BaseDao{
|
||||
try {
|
||||
while (rs.next()) {
|
||||
BrandModel brandModel=new BrandModel();
|
||||
brandModel.setBrand_name(rs.getString("code_name"));
|
||||
brandModel.setBrand_desc(rs.getString("code_name"));
|
||||
brandModel.setCodeId(rs.getString("code_id"));
|
||||
brandModel.setBrand_name(rs.getString("code_name").trim());
|
||||
brandModel.setBrand_desc(rs.getString("code_name").trim());
|
||||
brandModel.setCodeId(rs.getString("code_id").trim());
|
||||
brandModel.setBrand_image("");
|
||||
brandModel.setCategory("0");
|
||||
//brandModel.setCategory("0");
|
||||
brandModel.setBrand_recommend("0");//是否推荐
|
||||
brandModels.add(brandModel);
|
||||
// log.info(rs.getString("type_no")+"--"+rs.getString("code_name"));//分类编码-分类名称
|
||||
@ -682,4 +679,36 @@ public class SxDataDao extends BaseDao{
|
||||
return activeShopInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
*获取分类品牌映射
|
||||
* @param dataBaseInfo
|
||||
* @return
|
||||
*/
|
||||
public List<ClsBrandDto> getclsMapBrand(DataBaseInfo dataBaseInfo){
|
||||
ResultDto resultDto=getclsMapBrand(dataBaseInfo.getIp()
|
||||
,dataBaseInfo.getUserName()
|
||||
,dataBaseInfo.getPassword()
|
||||
,dataBaseInfo.getDbPort()
|
||||
,dataBaseInfo.getDataBaseName());
|
||||
ResultSet rs= resultDto.getResultSet();
|
||||
List<ClsBrandDto> clsBrandDtos=new ArrayList<>();
|
||||
try {
|
||||
while (rs.next()) {
|
||||
ClsBrandDto clsBrandDto=new ClsBrandDto();
|
||||
clsBrandDto.setItemClsname(rs.getString("item_clsname").trim());
|
||||
clsBrandDto.setCodeName(rs.getString("code_name").trim());
|
||||
clsBrandDtos.add(clsBrandDto);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
resultDto.getConnection().close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return clsBrandDtos;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
19
client/src/main/java/com/small/client/dto/ClsBrandDto.java
Normal file
19
client/src/main/java/com/small/client/dto/ClsBrandDto.java
Normal file
@ -0,0 +1,19 @@
|
||||
package com.small.client.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ClsBrandDto implements Serializable {
|
||||
|
||||
|
||||
@ApiModelProperty(value = "分类名称")
|
||||
private String itemClsname;
|
||||
|
||||
@ApiModelProperty(value = "品牌名称")
|
||||
private String codeName;
|
||||
|
||||
|
||||
}
|
||||
@ -29,4 +29,6 @@ public class SxCategoryModel {
|
||||
@ApiModelProperty(value = "第二级父类")
|
||||
private String second_category_name;
|
||||
|
||||
@ApiModelProperty(value = "品牌名称")
|
||||
private String brandName;
|
||||
}
|
||||
|
||||
@ -7,12 +7,10 @@ import com.small.client.dao.SxDataDao;
|
||||
import com.small.client.dto.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -35,10 +33,10 @@ public abstract class SxDataAbstService {
|
||||
syncThirdMemberReq = new SyncThirdMemberReq();
|
||||
syncThirdMemberReq.setUser_nickname(sxSyncVip.getVip_name());
|
||||
syncThirdMemberReq.setUser_realname(sxSyncVip.getVip_name());
|
||||
if ("男".equals(sxSyncVip.getVip_name())) {//todo 需要确认数据是不是这样判断
|
||||
if ("男".equals(sxSyncVip.getVip_sex())) {//todo 需要确认数据是不是这样判断
|
||||
syncThirdMemberReq.setUser_gender(1);
|
||||
}
|
||||
if ("男".equals(sxSyncVip.getVip_name())) {
|
||||
if ("女".equals(sxSyncVip.getVip_sex())) {
|
||||
syncThirdMemberReq.setUser_gender(2);
|
||||
}
|
||||
syncThirdMemberReq.setUser_mobile(sxSyncVip.getMobile());
|
||||
@ -48,12 +46,7 @@ public abstract class SxDataAbstService {
|
||||
syncThirdMemberReq.setUser_points(sxSyncVip.getNow_acc_num());
|
||||
syncThirdMemberReq.setUser_money(sxSyncVip.getResidual_amt());
|
||||
if(sxSyncVip.getVip_date()!=null){
|
||||
try {
|
||||
syncThirdMemberReq.setJoin_time(DateUtils.parseDate(sxSyncVip.getVip_date()));
|
||||
} catch (ParseException e) {
|
||||
log.info("时间转换异常{0}",e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
syncThirdMemberReq.setJoin_time(sxSyncVip.getVip_date());
|
||||
}
|
||||
syncThirdMemberReqList.add(syncThirdMemberReq);
|
||||
}
|
||||
@ -67,7 +60,7 @@ public abstract class SxDataAbstService {
|
||||
* @param allSxSyncCategories 所有分类
|
||||
* @return
|
||||
*/
|
||||
public List<SxCategoryModel> ConVToSxCategoryModel(List<SxSyncCategory> sxSyncCategories,List<SxSyncCategory> allSxSyncCategories) {
|
||||
public List<SxCategoryModel> ConVToSxCategoryModel(List<SxSyncCategory> sxSyncCategories,List<SxSyncCategory> allSxSyncCategories, Map<String,String> clsBrandMap) {
|
||||
if(CollectionUtil.isEmpty(sxSyncCategories)){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
@ -79,6 +72,7 @@ public abstract class SxDataAbstService {
|
||||
sxCategoryModel=new SxCategoryModel();
|
||||
sxCategoryModel.setCategory_image(SxDataDao.DEFAULT_IMG);
|
||||
sxCategoryModel.setCategory_name(sxSyncCategory.getItem_clsname());
|
||||
sxCategoryModel.setBrandName(clsBrandMap.get(sxSyncCategory.getItem_clsname()));
|
||||
//寻找父级
|
||||
if(null!=sxSyncCategory.getCls_parent()){
|
||||
SxSyncCategory firstNode=getParentNode(allSxSyncCategories,sxSyncCategory.getCls_parent());
|
||||
|
||||
@ -30,4 +30,5 @@ public class RedisConstant {
|
||||
|
||||
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;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.Version;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@ -212,4 +209,8 @@ public class ShopProductIndex implements Serializable {
|
||||
|
||||
@ApiModelProperty("是否特价商品,0否,1是")
|
||||
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)
|
||||
private Integer product_shop_card_discount;
|
||||
|
||||
@ApiModelProperty("统计库存")
|
||||
@TableField(exist = false)
|
||||
private Integer item_quantity=0;
|
||||
// @ApiModelProperty(value = "产品名称")
|
||||
// @TableField(exist=false)
|
||||
// private String productName;
|
||||
|
||||
@ -50,4 +50,8 @@ public interface ShopBaseProductBrandService extends IBaseService<ShopBaseProduc
|
||||
|
||||
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 com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
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.exception.ApiException;
|
||||
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.I18nUtil;
|
||||
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.shop.base.mapper.ShopBaseProductBrandMapper;
|
||||
import com.suisung.mall.shop.base.service.ShopBaseProductBrandService;
|
||||
@ -51,6 +53,9 @@ public class ShopBaseProductBrandServiceImpl extends BaseServiceImpl<ShopBasePro
|
||||
@Autowired
|
||||
private ShopBaseProductCategoryService categoryService;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Override
|
||||
public Map<String, List<ShopBaseProductBrand>> brandMap() {
|
||||
QueryWrapper<ShopBaseProductBrand> queryWrapper= new QueryWrapper<>();
|
||||
@ -261,4 +266,29 @@ public class ShopBaseProductBrandServiceImpl extends BaseServiceImpl<ShopBasePro
|
||||
}
|
||||
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));
|
||||
}
|
||||
|
||||
@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 = "商品基础表-商品审核")
|
||||
@RequestMapping(value = "/verify", method = RequestMethod.POST)
|
||||
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 removeByProductIds(String product_ids);
|
||||
|
||||
CommonResult enable();
|
||||
|
||||
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.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@ -88,7 +89,6 @@ import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
||||
@ -213,11 +213,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
@Autowired
|
||||
private StoreDbConfigService storeDbConfigService;
|
||||
|
||||
public static void main(String[] args) {
|
||||
AtomicInteger count1 = new AtomicInteger(0);//全部
|
||||
System.out.println(count1.addAndGet(10));
|
||||
System.out.println(count1);
|
||||
}
|
||||
private final static int delate_batch_limit=100;//删除最大限制
|
||||
|
||||
@Override
|
||||
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 product_market_price = NumberUtil.max(max_item_unit_price, max_item_market_price);
|
||||
shopProductBase.setProduct_market_price(product_market_price);
|
||||
shopProductBase.setProduct_src_id(productId);
|
||||
// 注:保存商品基本信息
|
||||
if (!saveOrUpdate(shopProductBase)) {
|
||||
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_state_id(shopProductBase.getProduct_state_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_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_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相关数据
|
||||
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) {
|
||||
|
||||
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);
|
||||
|
||||
boolean openCount=getParameter("openCount",false);//1是开启,0是不开启
|
||||
if (CheckUtil.isNotEmpty(nodeid)) {
|
||||
IPage<Long> listItem = shopProductBaseMapper.listItem(new Page<>(1, 9999), nodeid);
|
||||
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"));
|
||||
QueryWrapper<ShopProductIndex> cond_row = new QueryWrapper<>();
|
||||
cond_row.orderByDesc("product_id");
|
||||
List<Integer> category_ids = new ArrayList<>();
|
||||
if (CheckUtil.isNotEmpty(category_id)) {
|
||||
List<Map> categoryList = shopBaseProductCategoryService.getCategoryByParentId(category_id, true, true);
|
||||
List<Integer> category_ids = new ArrayList<>();
|
||||
|
||||
if (CollUtil.isNotEmpty(categoryList)) {
|
||||
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)) {
|
||||
|
||||
data.put("items", getProduct(product_ids));
|
||||
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) {
|
||||
ShopProductIndex shopProductIndex = new ShopProductIndex();
|
||||
shopProductIndex.setCategory_id(category_id);
|
||||
shopProductIndex.setStore_id(store_id);
|
||||
Integer[] countArrays = countShopIndex(shopProductIndex);
|
||||
data.put("allRecords", countArrays[0]);//全部
|
||||
data.put("normalRecords", countArrays[1]);//销售中
|
||||
data.put("offRecords", countArrays[2]);//仓库中
|
||||
data.put("illegalRecords", countArrays[3]);//违规禁售
|
||||
data.put("unCheckedRecords", countArrays[4]);//未分配或者待审核
|
||||
|
||||
if(openCount){
|
||||
Integer[] countArrays= countShopIndex(category_ids,store_id);
|
||||
List<Map> itemsMap= (List<Map>) data.get("items");
|
||||
data.put("items", countItemQuantity(itemsMap));//统计存储
|
||||
data.put("allRecords",countArrays[0]);//全部
|
||||
data.put("normalRecords",countArrays[1]);//销售中
|
||||
data.put("offRecords",countArrays[2]);//仓库中
|
||||
data.put("illegalRecords",countArrays[3]);//违规禁售
|
||||
data.put("unCheckedRecords",countArrays[4]);//未分配或者待审核
|
||||
}
|
||||
return data;
|
||||
}
|
||||
@ -3146,20 +3136,17 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean removeByProductId(Long product_id) {
|
||||
|
||||
UserDto user = getCurrentUser();
|
||||
if (user == null) {
|
||||
throw new ApiException(ResultCode.NEED_LOGIN);
|
||||
}
|
||||
Integer storeId = Convert.toInt(user.getStore_id());
|
||||
|
||||
QueryWrapper<ShopOrderItem> itemQueryWrapper = new QueryWrapper<>();
|
||||
itemQueryWrapper.eq("product_id", product_id);
|
||||
if (shopOrderItemService.findOne(itemQueryWrapper) != null) {
|
||||
throw new ApiException(I18nUtil._("不能删除被购买的商品!"));
|
||||
}
|
||||
|
||||
|
||||
// 不使用缓存
|
||||
ShopProductBase shopProductBase = getById(product_id);
|
||||
Map row = Convert.toMap(Object.class, Object.class, shopProductBase);
|
||||
@ -3602,6 +3589,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改商品状态
|
||||
*/
|
||||
@ -5340,6 +5328,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
// 已存在商品,设置ID并加入更新列表
|
||||
Long existId = existingProducts.get(key);
|
||||
base.setProduct_id(existId);
|
||||
base.setProduct_src_id(existId);
|
||||
shopProductBaseList.get(i).setProduct_id(existId);
|
||||
//shopProductIndexList.get(i).setProduct_id(existId);
|
||||
// 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_verify_id(base.getProduct_verify_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_selfsupport(1);
|
||||
@ -5489,12 +5479,15 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
Long productId = newIds.get(i);
|
||||
ShopProductBase base = newProducts.get(i);
|
||||
base.setProduct_id(productId);
|
||||
base.setProduct_src_id(productId);
|
||||
// 设置关联ID
|
||||
newProducts.get(i).setProduct_id(productId);
|
||||
newShopProductIndexList.get(i).setProduct_id(productId);
|
||||
newShopProductIndexList.get(i).setProduct_src_id(productId);
|
||||
newShopProductDataList.get(i).setProduct_id(productId);
|
||||
newShopProductDetailList.get(i).setProduct_id(productId);
|
||||
newShopProductInfoList.get(i).setProduct_id(productId);
|
||||
|
||||
// 处理商品项
|
||||
List<ShopProductItem> items = newShopProductItemList.get(i);
|
||||
processProductItems(items, productId, addItemSeqs);
|
||||
@ -6143,51 +6136,51 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
}
|
||||
|
||||
//计算全部,销售中,仓库中,违规禁销,未分配商品的数量
|
||||
public Integer[] countShopIndex(ShopProductIndex shopProductIndex) {
|
||||
//商品状态:1001-正常;1002-下架仓库中;1003-待审核; 1000-违规禁售,1003
|
||||
public Integer[] countShopIndex(List<Integer> category_ids,Integer storeId) {
|
||||
//商品状态:1001-正常;1002-下架仓库中;1003-待审核; 1000-违规禁售,1003
|
||||
int taskCount = 5;
|
||||
CompletableFuture<Integer> count1 = CompletableFuture.supplyAsync(() -> {
|
||||
QueryWrapper<ShopProductIndex> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())) {
|
||||
queryWrapper.eq("category_id", shopProductIndex.getCategory_id());
|
||||
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||
if(CollectionUtil.isNotEmpty(category_ids)){
|
||||
queryWrapper.in("category_id",category_ids);
|
||||
}
|
||||
queryWrapper.eq("store_id", shopProductIndex.getStore_id());
|
||||
queryWrapper.eq("store_id",storeId);
|
||||
return ((int) shopProductIndexService.count(queryWrapper));
|
||||
});
|
||||
CompletableFuture<Integer> count2 = CompletableFuture.supplyAsync(() -> {
|
||||
QueryWrapper<ShopProductIndex> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())) {
|
||||
queryWrapper.eq("category_id", shopProductIndex.getCategory_id());
|
||||
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||
if(CollectionUtil.isNotEmpty(category_ids)){
|
||||
queryWrapper.in("category_id",category_ids);
|
||||
}
|
||||
queryWrapper.eq("store_id", shopProductIndex.getStore_id());
|
||||
queryWrapper.eq("product_state_id", StateCode.PRODUCT_STATE_NORMAL);
|
||||
queryWrapper.eq("store_id",storeId);
|
||||
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_NORMAL);
|
||||
return ((int) shopProductIndexService.count(queryWrapper));
|
||||
});
|
||||
CompletableFuture<Integer> count3 = CompletableFuture.supplyAsync(() -> {
|
||||
QueryWrapper<ShopProductIndex> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())) {
|
||||
queryWrapper.eq("category_id", shopProductIndex.getCategory_id());
|
||||
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||
if(CollectionUtil.isNotEmpty(category_ids)){
|
||||
queryWrapper.in("category_id",category_ids);
|
||||
}
|
||||
queryWrapper.eq("store_id", shopProductIndex.getStore_id());
|
||||
queryWrapper.eq("product_state_id", StateCode.PRODUCT_STATE_OFF_THE_SHELF);
|
||||
queryWrapper.eq("store_id",storeId);
|
||||
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_OFF_THE_SHELF);
|
||||
return ((int) shopProductIndexService.count(queryWrapper));
|
||||
});
|
||||
CompletableFuture<Integer> count4 = CompletableFuture.supplyAsync(() -> {
|
||||
QueryWrapper<ShopProductIndex> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())) {
|
||||
queryWrapper.eq("category_id", shopProductIndex.getCategory_id());
|
||||
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||
if(CollectionUtil.isNotEmpty(category_ids)){
|
||||
queryWrapper.in("category_id",category_ids);
|
||||
}
|
||||
queryWrapper.eq("store_id", shopProductIndex.getStore_id());
|
||||
queryWrapper.eq("product_state_id", StateCode.PRODUCT_STATE_ILLEGAL);
|
||||
queryWrapper.eq("store_id",storeId);
|
||||
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_ILLEGAL);
|
||||
return ((int) shopProductIndexService.count(queryWrapper));
|
||||
});
|
||||
CompletableFuture<Integer> count5 = CompletableFuture.supplyAsync(() -> {
|
||||
QueryWrapper<ShopProductIndex> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())) {
|
||||
queryWrapper.eq("category_id", shopProductIndex.getCategory_id());
|
||||
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
|
||||
if(CollectionUtil.isNotEmpty(category_ids)){
|
||||
queryWrapper.in("category_id",category_ids);
|
||||
}
|
||||
queryWrapper.eq("store_id", shopProductIndex.getStore_id());
|
||||
queryWrapper.eq("product_state_id", StateCode.PRODUCT_STATE_OFF_THE_SHELF_UNCHECK);
|
||||
queryWrapper.eq("store_id",storeId);
|
||||
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_OFF_THE_SHELF_UNCHECK);
|
||||
return ((int) shopProductIndexService.count(queryWrapper));
|
||||
});
|
||||
|
||||
@ -6209,4 +6202,53 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
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;
|
||||
@ApiModelProperty(value = "第二级父类")
|
||||
private String second_category_name;
|
||||
|
||||
@ApiModelProperty(value = "品牌名称")
|
||||
private String brandName;
|
||||
}
|
||||
|
||||
@ -166,7 +166,6 @@ public class SyncThirdDataController {
|
||||
return new ThirdApiRes().success("服务器已执行活动数据操作");
|
||||
}
|
||||
|
||||
//todo test
|
||||
@ApiOperation(value = "同步活动商品数据", notes = "同步活动商品数据")
|
||||
@RequestMapping(value = "/syncAtiveShop", method = RequestMethod.POST)
|
||||
public ThirdApiRes syncAtiveShop(@RequestParam String appKey,
|
||||
@ -176,4 +175,13 @@ public class SyncThirdDataController {
|
||||
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 org.springframework.core.io.Resource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Date;
|
||||
@ -161,4 +162,9 @@ public interface SyncThirdDataService {
|
||||
* 同步匹配商品图库数据
|
||||
*/
|
||||
void syncShopImages(Integer storeId);
|
||||
|
||||
/**
|
||||
* 刷新时间
|
||||
*/
|
||||
ThirdApiRes syncRefreshTime(@RequestParam String appKey, @RequestParam String sign);
|
||||
}
|
||||
|
||||
@ -116,6 +116,7 @@ public abstract class SyncBaseThirdSxAbstract{
|
||||
ShopBaseProductType productType=new ShopBaseProductType();
|
||||
productType.setType_is_draft(1);//发布
|
||||
productType.setStore_id(Integer.valueOf(storeId));
|
||||
String brandName=o.getStr("brandName","其他品牌");
|
||||
if (o != null) {
|
||||
// 重要:分类类型处理(强调共性)
|
||||
Integer typeId = 1001;
|
||||
@ -125,11 +126,19 @@ public abstract class SyncBaseThirdSxAbstract{
|
||||
if (productType != null) {
|
||||
typeId = productType.getType_id();
|
||||
} 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();
|
||||
newProductType.setType_name(o.getStr("product_type"));
|
||||
newProductType.setType_buildin(0);
|
||||
newProductType.setType_is_draft(0);//发布
|
||||
newProductType.setStore_id(Integer.valueOf(storeId));
|
||||
if(null!=shopBaseProductBrand){
|
||||
newProductType.setType_brand_ids(String.valueOf(shopBaseProductBrand.getBrand_id()));
|
||||
}
|
||||
if (productTypeService.save(newProductType)) {
|
||||
typeId = newProductType.getType_id();
|
||||
}
|
||||
@ -510,6 +519,7 @@ public abstract class SyncBaseThirdSxAbstract{
|
||||
accountUserInfo.setUser_id(userId);
|
||||
accountUserInfo.setUser_type_id(0);
|
||||
accountUserInfo.setUser_mobile(user_mobile);
|
||||
accountUserInfo.setUser_realname(syncThirdMemberReq.getUser_realname());
|
||||
accountUserInfo.setUser_level_card(syncThirdMemberReq.getUser_level_card());
|
||||
//user_level_id
|
||||
accountUserInfo.setUser_level_id(1); // todo select id
|
||||
@ -655,7 +665,7 @@ public abstract class SyncBaseThirdSxAbstract{
|
||||
* @param storeId
|
||||
* @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();
|
||||
Map categoryMap= productCategoryService.getCategoryListByStoreId(storeId);//热数据加载
|
||||
List<ShopProductBase> shopProductBaseList=new ArrayList<>();
|
||||
@ -751,6 +761,7 @@ public abstract class SyncBaseThirdSxAbstract{
|
||||
shopProductIndex.setCoupon_type_id(0);// product_assist_data // 辅助属性值列(DOT)
|
||||
shopProductIndex.setProduct_transport_id(String.valueOf(StateCode.DELIVERY_TYPE_SAME_CITY));
|
||||
shopProductIndex.setIs_special(shopProductBase.getIs_special());
|
||||
shopProductIndex.setBrand_id(brandMaps.get(jsonObj.getStr("brand_name")));
|
||||
if(categoryId!=0){
|
||||
Integer typeId = (Integer) categoryMap.get(categoryId.toString());
|
||||
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.StringUtils;
|
||||
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.ShopBaseProductSpecService;
|
||||
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.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
@ -135,9 +137,6 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
@Autowired
|
||||
private OssService ossService;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
@ -171,6 +170,9 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
@Autowired
|
||||
private AccountService accountService;
|
||||
|
||||
@Autowired
|
||||
private ShopBaseProductBrandService productBrandService;
|
||||
|
||||
/**
|
||||
* 批量保存商品的分类
|
||||
*
|
||||
@ -570,6 +572,8 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
List<String> failFolders = new ArrayList<>();
|
||||
List<String> failMessage = new ArrayList<>();
|
||||
shopBaseProductCategoryService.getCategoryListByStoreId(storeId);
|
||||
// getBrandMapByStoreId()
|
||||
Map<String,Integer> brandMaps= productBrandService.getBrandMapByStoreId(storeId);
|
||||
QueryWrapper<StoreDbConfig> storeDbConfigQueryWrapper = new QueryWrapper<>();
|
||||
storeDbConfigQueryWrapper.eq("store_id", storeId);
|
||||
StoreDbConfig storeDbConfig = storeDbConfigService.getOne(storeDbConfigQueryWrapper);
|
||||
@ -586,7 +590,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
String fileName = "good_" + (taskId + 1) + ".txt";
|
||||
JSONArray jsonArray = new ThreadFileUtils().processFolder(taskName, newFolders.get(taskId));
|
||||
try {
|
||||
baseSaveOrUpdateGoodsBatch(jsonArray, storeId,isNegativeAllowed,priorityMode);
|
||||
baseSaveOrUpdateGoodsBatch(jsonArray, storeId,isNegativeAllowed,priorityMode,brandMaps);
|
||||
success.getAndIncrement();
|
||||
threadNum.decrementAndGet();
|
||||
return "成功" + taskId;
|
||||
@ -618,6 +622,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
shopBaseProductCategoryService.clearCategoryCache(storeId);
|
||||
shopProductSpecItemService.clearExistItem(Integer.valueOf(storeId));
|
||||
baseProductSpecService.clearShopBaseProductSpecMap(Integer.valueOf(storeId));
|
||||
productBrandService.clearBrandMapByStoreId(storeId);
|
||||
List<SyncFileLog> syncFileLogs = new ArrayList<>();
|
||||
for (int i = 0; i < failFolders.size(); i++) {
|
||||
String path = failFolders.get(i);
|
||||
@ -659,6 +664,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
syncShopImageService.syncMapingShopImages(storeId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Resource> downloadToClient(String primaryKey, String clienVersionName) {
|
||||
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;
|
||||
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("上传成功");
|
||||
}
|
||||
|
||||
@ -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