添加思迅配置和商品分类搜索功能
This commit is contained in:
parent
cf2ad10fd3
commit
696027f3e8
@ -343,6 +343,11 @@ public class AccountController {
|
||||
return accountUserBaseService.existByNickname(nickname, storeId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/existByMobile", method = RequestMethod.POST)
|
||||
public Boolean existByMobile(@RequestParam(name = "moblie") String moblie, @RequestParam(name = "storeId") String storeId) {
|
||||
return accountUserBaseService.existByMobile(moblie, storeId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/editPassword", method = RequestMethod.POST)
|
||||
public CommonResult editPassword(@RequestParam(name = "user_id") Integer user_id,
|
||||
@RequestParam(name = "user_password") String user_password) {
|
||||
|
||||
@ -205,6 +205,14 @@ public interface AccountUserBaseService extends IBaseService<AccountUserBase> {
|
||||
*/
|
||||
Boolean existByNickname(String nickname, String storeId);
|
||||
|
||||
/**
|
||||
* 根据 userAccount 也就是手机号判断是否存在会员
|
||||
* @param userAccount
|
||||
* @param storeId
|
||||
* @return
|
||||
*/
|
||||
Boolean existByMobile(String userAccount, String storeId);
|
||||
|
||||
Pair<Boolean, AccountUserBase> saveOrUpdate2(AccountUserBase entity);
|
||||
|
||||
|
||||
|
||||
@ -1634,7 +1634,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
*
|
||||
* @return array 用户登录数据
|
||||
*/
|
||||
@GlobalTransactional
|
||||
// @GlobalTransactional
|
||||
@Override
|
||||
public AccountUserBase register(Map userInfo) {
|
||||
|
||||
@ -3412,6 +3412,23 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
return count(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断店铺某个手机是否存在
|
||||
* @param storeId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean existByMobile(String userAccount, String storeId) {
|
||||
if (StrUtil.isBlank(userAccount)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<AccountUserBase> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AccountUserBase::getUser_account, userAccount);
|
||||
queryWrapper.eq(AccountUserBase::getStore_ids, storeId);
|
||||
return count(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Boolean, AccountUserBase> saveOrUpdate2(AccountUserBase entity) {
|
||||
Boolean flag = false;
|
||||
|
||||
@ -27,6 +27,9 @@ public enum DicEnum {
|
||||
YESORNO_0("0", "否","yesOrno","是否","是否"),
|
||||
YESORNO_1("1", "是","yesOrno","是否","是否"),
|
||||
|
||||
PRIORITY_MODE_1("1", "手动优先","priorityMode","优先方式","根据平台给的商品自动切分上架"),
|
||||
PRIORITY_MODE_2("2", "自动优先","priorityMode","优先方式","更新时不做商品切割"),
|
||||
|
||||
GOODS_UN_SYNC_SX("1", "白条猪","unSyncGoodsSX","思迅非同步商品","白条猪"),
|
||||
;
|
||||
;
|
||||
|
||||
@ -16,7 +16,7 @@ import java.util.Map;
|
||||
* 认证服务远程调用
|
||||
* Created by Xinze on 2020/7/19.
|
||||
*/
|
||||
@FeignClient("mall-account")
|
||||
@FeignClient(value = "mall-account",url = "http://localhost:8088")
|
||||
public interface AccountService {
|
||||
|
||||
@GetMapping(value = "/admin/account/accountController/getUserBase")
|
||||
@ -146,6 +146,17 @@ public interface AccountService {
|
||||
@PostMapping(value = "/admin/account/accountController/existByNickname")
|
||||
boolean existByNickname(@RequestParam(name = "nickname") String nickname, @RequestParam(name = "storeId") String storeId);
|
||||
|
||||
|
||||
/**
|
||||
* 判断一个店铺是否存在某个手机
|
||||
*
|
||||
* @param moblie
|
||||
* @param storeId
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/admin/account/accountController/existByMobile")
|
||||
boolean existByMobile(@RequestParam(name = "moblie") String moblie, @RequestParam(name = "storeId") String storeId);
|
||||
|
||||
@PostMapping(value = "/admin/account/accountController/editPassword")
|
||||
CommonResult editPassword(@RequestParam(name = "user_id") Integer user_id,
|
||||
@RequestParam(name = "user_password") String user_password);
|
||||
|
||||
@ -118,4 +118,8 @@ public class StoreDbConfig implements Serializable {
|
||||
@NotBlank(message = "是否允许负库存售卖不能为空")
|
||||
private String isNegativeAllowed="1";
|
||||
|
||||
@TableField(value = "priority_mode",updateStrategy = FieldStrategy.NOT_EMPTY)
|
||||
@ApiModelProperty(value = "更新优先方式(1:手动优先,2:自动优先),自动优先时根据平台给的商品自动切分上架,更新是才发挥作用")
|
||||
@NotBlank(message = "更新优先方式不能为空")
|
||||
private String priorityMode="1";
|
||||
}
|
||||
@ -31,6 +31,9 @@ public class ProductCategoryListReq extends BaseListReq {
|
||||
@ApiModelProperty("是否启用(BOOL):0-不显示;1-显示")
|
||||
private Boolean categoryIsEnable;
|
||||
|
||||
@ApiModelProperty("店铺id")
|
||||
private String store_id;
|
||||
|
||||
public ProductCategoryListReq() {
|
||||
setSidx("category_order");
|
||||
}
|
||||
|
||||
@ -976,6 +976,10 @@ public class ShopBaseProductCategoryServiceImpl extends BaseServiceImpl<ShopBase
|
||||
if (CheckUtil.isNotEmpty(categoryName)) {
|
||||
objectQueryWrapper.like("category_name", categoryName);
|
||||
}
|
||||
String storeId=getParameter("store_id");
|
||||
if(CheckUtil.isNotEmpty(storeId)){
|
||||
objectQueryWrapper.eq("store_id", storeId);
|
||||
}
|
||||
|
||||
List<ShopBaseProductCategory> dataList = find(objectQueryWrapper);
|
||||
|
||||
|
||||
@ -6,7 +6,6 @@ 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.date.StopWatch;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@ -16,8 +15,6 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.Mapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
@ -27,6 +24,7 @@ import com.suisung.mall.common.constant.CommonConstant;
|
||||
import com.suisung.mall.common.constant.ConfigConstant;
|
||||
import com.suisung.mall.common.constant.MqConstant;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.enums.DicEnum;
|
||||
import com.suisung.mall.common.exception.ApiException;
|
||||
import com.suisung.mall.common.feignService.EduService;
|
||||
import com.suisung.mall.common.feignService.SearchService;
|
||||
@ -38,7 +36,6 @@ import com.suisung.mall.common.modules.sixun.SxSyncGoods;
|
||||
import com.suisung.mall.common.modules.store.ShopStoreActivityBase;
|
||||
import com.suisung.mall.common.modules.store.ShopStoreActivityItem;
|
||||
import com.suisung.mall.common.modules.store.ShopStoreBase;
|
||||
import com.suisung.mall.common.modules.sync.ProductMapping;
|
||||
import com.suisung.mall.common.modules.user.ShopUserCart;
|
||||
import com.suisung.mall.common.modules.user.ShopUserFavoritesItem;
|
||||
import com.suisung.mall.common.modules.user.ShopUserProductBrowse;
|
||||
@ -67,13 +64,11 @@ import com.suisung.mall.shop.product.pojo.vo.ProductVo;
|
||||
import com.suisung.mall.shop.product.service.*;
|
||||
import com.suisung.mall.shop.sixun.service.SxSyncGoodsService;
|
||||
import com.suisung.mall.shop.store.service.*;
|
||||
import com.suisung.mall.shop.sync.Utils.ProductPriceCalculator;
|
||||
import com.suisung.mall.shop.sync.Utils.ShopJsonUtils;
|
||||
import com.suisung.mall.shop.sync.keymanage.RedisKey;
|
||||
import com.suisung.mall.shop.sync.service.ProductMappingService;
|
||||
import com.suisung.mall.shop.sync.service.StoreDbConfigService;
|
||||
import com.suisung.mall.shop.user.service.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -92,9 +87,7 @@ import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
||||
@ -213,8 +206,12 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
|
||||
@Autowired
|
||||
private ProductMappingService productMappingService;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private StoreDbConfigService storeDbConfigService;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean trySaveProduct(String productObj, String productItems) {
|
||||
@ -5579,9 +5576,13 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
if(CollUtil.isNotEmpty(newProducts)){
|
||||
productMappingService.computeProductMapping(newProducts,newProducts.get(0).getStore_id(),false);
|
||||
}
|
||||
if(CollUtil.isNotEmpty(updateProducts)){
|
||||
if(CollUtil.isNotEmpty(updateProducts)){//如果时自动优先,则按平台规则切割商品
|
||||
Map map=storeDbConfigService.getPriorityModeCachByStoreId(newProducts.get(0).getStore_id());
|
||||
String priorityMode= (String) map.get(String.valueOf(newProducts.get(0).getStore_id()));
|
||||
if(DicEnum.PRIORITY_MODE_2.getCode().equals(priorityMode)){
|
||||
productMappingService.computeProductMapping(updateProducts,updateProducts.get(0).getStore_id(),true);
|
||||
}
|
||||
}
|
||||
return Pair.of(true, String.format("处理成功,新增%d条,更新%d条",
|
||||
newProducts.size(), updateProducts.size()));
|
||||
} catch (RuntimeException e) {
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
|
||||
package com.suisung.mall.shop.sync.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.pojo.req.SyncThirdMemberReq;
|
||||
@ -147,8 +148,9 @@ public class SyncThirdDataController {
|
||||
public ThirdApiRes uploudToCos(@RequestBody List<String> folders,
|
||||
@RequestParam String appKey,
|
||||
@RequestParam String sign,
|
||||
@RequestParam Date refreshDate,
|
||||
@RequestParam String refreshDateStr,
|
||||
@RequestParam String syncType) {
|
||||
Date refreshDate= DateUtil.parse(refreshDateStr,"yyyy-MM-dd HH:mm:ss");
|
||||
return syncThirdDataService.fileUploadToOss(appKey,sign,syncType,refreshDate,folders);
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
package com.suisung.mall.shop.sync.dto;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class BrandModel implements Serializable {
|
||||
@ApiModelProperty("品牌名称")
|
||||
private String brand_name;
|
||||
|
||||
@ApiModelProperty("品牌编号")
|
||||
private String codeId;
|
||||
|
||||
@ApiModelProperty("品牌描述")
|
||||
private String brand_desc;
|
||||
|
||||
@ApiModelProperty("品牌分类")
|
||||
private String category;
|
||||
|
||||
@ApiModelProperty("图片")
|
||||
private String brand_image;
|
||||
|
||||
@ApiModelProperty("是否推荐")
|
||||
private String brand_recommend;
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package com.suisung.mall.shop.sync.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 模型对应
|
||||
*/
|
||||
@Data
|
||||
public class SxCategoryModel {
|
||||
//模型对应ShopBaseProductCategory start
|
||||
private String parent_name;//暂时不用
|
||||
@ApiModelProperty(value = "商品分类名称")
|
||||
private String category_name;
|
||||
@ApiModelProperty(value = "分类图片")
|
||||
private String category_image;
|
||||
@ApiModelProperty(value = "是否允许虚拟商品(ENUM):1-是; 0-否")
|
||||
private Integer category_virtual_enable;
|
||||
@ApiModelProperty(value = "分佣比例-百分比")
|
||||
private BigDecimal category_commission_rate;
|
||||
// private String type_name;//todo 看代码没有用,使用的是product_type
|
||||
//模型对应ShopBaseProductCategory end
|
||||
@ApiModelProperty(value = "产品类型")
|
||||
private String product_type;
|
||||
@ApiModelProperty(value = "第一级父类")
|
||||
private String first_category_name;
|
||||
@ApiModelProperty(value = "第二级父类")
|
||||
private String second_category_name;
|
||||
|
||||
}
|
||||
@ -18,4 +18,6 @@ public class RedisKey {
|
||||
public static final String STORESHOPPRODUCTKEY="storedata:shopProductkey";
|
||||
|
||||
public static final String STORESHOPPRODUCITEMTKEY="storedata:shopProductItemKey";
|
||||
|
||||
public static final String STOREDBDATAPRIORITYMODEKEY="storedbdata:priorityModeKey";
|
||||
}
|
||||
|
||||
@ -13,6 +13,8 @@ import com.suisung.mall.common.modules.sync.StoreDbConfig;
|
||||
import com.suisung.mall.common.modules.sync.SyncApp;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public interface StoreDbConfigService extends IBaseService<StoreDbConfig> {
|
||||
|
||||
@ -27,4 +29,8 @@ public interface StoreDbConfigService extends IBaseService<StoreDbConfig> {
|
||||
|
||||
CommonResult delStoreDbConfig(StoreDbConfig storeDbConfig);
|
||||
String getPrimaryKey(SyncApp syncApp);
|
||||
|
||||
Map getPriorityModeCachByStoreId(Integer storeId);
|
||||
|
||||
void clearPriorityModeCachByStoreId(Integer storeId);
|
||||
}
|
||||
|
||||
@ -19,10 +19,12 @@ import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.api.StateCode;
|
||||
import com.suisung.mall.common.enums.DicEnum;
|
||||
import com.suisung.mall.common.modules.base.ShopBaseProductSpec;
|
||||
import com.suisung.mall.common.modules.product.*;
|
||||
import com.suisung.mall.common.modules.sync.ProductMapping;
|
||||
|
||||
import com.suisung.mall.common.modules.sync.StoreDbConfig;
|
||||
import com.suisung.mall.common.utils.ContextUtil;
|
||||
import com.suisung.mall.common.utils.StringUtils;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
@ -52,7 +54,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.ValidationException;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@ -95,6 +96,9 @@ public class ProductMappingServiceImpl extends BaseServiceImpl<ProductMappingMap
|
||||
@Autowired
|
||||
private ProductMappingService productMappingService;
|
||||
|
||||
@Autowired
|
||||
private StoreDbConfigService storeDbConfigService;
|
||||
|
||||
@Value("${file.upload-dir}")
|
||||
private String uploadDir;
|
||||
|
||||
@ -375,6 +379,16 @@ public class ProductMappingServiceImpl extends BaseServiceImpl<ProductMappingMap
|
||||
@Override
|
||||
public CommonResult syncAllProductMapping() {
|
||||
Integer storeId= Integer.valueOf(Objects.requireNonNull(ContextUtil.getCurrentUser()).getStore_id());
|
||||
QueryWrapper<StoreDbConfig> storeDbConfigQueryWrapper = new QueryWrapper<>();
|
||||
storeDbConfigQueryWrapper.select("priority_mode");
|
||||
storeDbConfigQueryWrapper.eq("store_id", storeId);
|
||||
StoreDbConfig storeDbConfig= storeDbConfigService.getOne(storeDbConfigQueryWrapper);
|
||||
if(null==storeDbConfig){
|
||||
return CommonResult.failed("同步数据库配置不能为空");
|
||||
}
|
||||
if(DicEnum.PRIORITY_MODE_1.getCode().equals(storeDbConfig.getPriorityMode())){
|
||||
return CommonResult.failed("请设置优先方式为自动更新");
|
||||
}
|
||||
//找出范围内的规格产品
|
||||
QueryWrapper<ShopProductBase> queryWrapper= new QueryWrapper<>();
|
||||
queryWrapper.eq("product_state_id", StateCode.PRODUCT_STATE_OFF_THE_SHELF_UNCHECK);
|
||||
|
||||
@ -12,16 +12,16 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.enums.DicEnum;
|
||||
import com.suisung.mall.common.modules.store.ShopStoreBase;
|
||||
import com.suisung.mall.common.modules.sync.StoreDbConfig;
|
||||
import com.suisung.mall.common.modules.sync.SyncApp;
|
||||
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
||||
import com.suisung.mall.common.utils.ContextUtil;
|
||||
import com.suisung.mall.common.utils.StringUtils;
|
||||
import com.suisung.mall.core.web.service.RedisService;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreBaseService;
|
||||
import com.suisung.mall.shop.sync.Utils.CryptoUtils;
|
||||
import com.suisung.mall.shop.sync.keymanage.RedisKey;
|
||||
import com.suisung.mall.shop.sync.mapper.StoreDbConfigMapper;
|
||||
import com.suisung.mall.shop.sync.service.StoreDbConfigService;
|
||||
|
||||
@ -29,7 +29,8 @@ import com.suisung.mall.shop.sync.service.SyncAppService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.suisung.mall.common.utils.ContextUtil.getStoreId;
|
||||
@ -43,6 +44,9 @@ public class StoreDbConfigServiceImpl extends BaseServiceImpl<StoreDbConfigMappe
|
||||
@Autowired
|
||||
private SyncAppService syncAppService;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Override
|
||||
public CommonResult findStoreDbConfigPageList(StoreDbConfig storeDbConfig,Integer pageNum,Integer pageSize) {
|
||||
|
||||
@ -193,4 +197,28 @@ public class StoreDbConfigServiceImpl extends BaseServiceImpl<StoreDbConfigMappe
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getPriorityModeCachByStoreId(Integer storeId) {
|
||||
String key= RedisKey.STOREDBDATAPRIORITYMODEKEY+":"+storeId;
|
||||
if(redisService.get(key)!=null){
|
||||
return (Map)redisService.get(key);
|
||||
}
|
||||
QueryWrapper<StoreDbConfig> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("store_id", storeId);
|
||||
queryWrapper.select("priority_mode");
|
||||
StoreDbConfig dbConfig= this.getOne(queryWrapper);
|
||||
Map map=new HashMap();
|
||||
map.put(String.valueOf(storeId),dbConfig.getPriorityMode());
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPriorityModeCachByStoreId(Integer storeId) {
|
||||
String key= RedisKey.STOREDBDATAPRIORITYMODEKEY+":"+storeId;
|
||||
if(redisService.get(key)!=null){
|
||||
redisService.del(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@ -36,24 +35,19 @@ import com.suisung.mall.common.pojo.dto.LibraryProductDTO;
|
||||
import com.suisung.mall.common.pojo.req.SyncThirdMemberReq;
|
||||
import com.suisung.mall.common.utils.DateTimeUtils;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import com.suisung.mall.common.utils.JsonUtil;
|
||||
import com.suisung.mall.common.utils.StringUtils;
|
||||
import com.suisung.mall.common.utils.phone.PhoneNumberUtils;
|
||||
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.base.service.ShopBaseProductTypeService;
|
||||
import com.suisung.mall.shop.library.service.LibraryProductImageService;
|
||||
import com.suisung.mall.shop.library.service.LibraryProductService;
|
||||
import com.suisung.mall.shop.number.service.ShopNumberSeqService;
|
||||
import com.suisung.mall.shop.number.service.impl.ShopNumberSeqServiceImpl;
|
||||
import com.suisung.mall.shop.product.service.ShopProductBaseService;
|
||||
import com.suisung.mall.shop.product.service.ShopProductItemService;
|
||||
import com.suisung.mall.shop.product.service.impl.ShopProductBaseServiceImpl;
|
||||
import com.suisung.mall.shop.product.service.impl.ShopProductItemServiceImpl;
|
||||
import com.suisung.mall.shop.sixun.dto.SxGoosModel;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreActivityBaseService;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreBaseService;
|
||||
import com.suisung.mall.shop.sync.service.ProductMappingService;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -67,7 +61,6 @@ import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.baomidou.mybatisplus.extension.toolkit.Db.list;
|
||||
|
||||
@Service
|
||||
public abstract class SyncBaseThirdSxAbstract{
|
||||
@ -391,6 +384,8 @@ public abstract class SyncBaseThirdSxAbstract{
|
||||
for (SyncThirdMemberReq member : memberList) {
|
||||
// account_user_base
|
||||
AccountUserBase accountUserBase = new AccountUserBase();
|
||||
String user_mobile = PhoneNumberUtils.convWithIDDCodePhoneNumber(member.getUser_mobile(), CommonConstant.IDD_ZH_CN);//+86
|
||||
accountUserBase.setUser_account(user_mobile);
|
||||
accountUserBase.setUser_account(StringUtils.generateUniqueCode(8));
|
||||
accountUserBase.setUser_nickname(member.getUser_nickname());
|
||||
accountUserBase.setUser_state(2);// 状态(ENUM):0-锁定;1-未激活;2-已激活;
|
||||
@ -409,7 +404,7 @@ public abstract class SyncBaseThirdSxAbstract{
|
||||
accountUserBase.setUser_password(SecureUtil.md5(user_salt + SecureUtil.md5(IdUtil.simpleUUID())));
|
||||
|
||||
// 判断店铺是不是存在该昵称的会员了?
|
||||
Boolean exists = accountService.existByNickname(member.getUser_nickname(), storeId);
|
||||
Boolean exists = accountService.existByMobile(user_mobile, storeId);
|
||||
if (exists) {
|
||||
continue;
|
||||
}
|
||||
@ -426,7 +421,7 @@ public abstract class SyncBaseThirdSxAbstract{
|
||||
AccountUserInfo accountUserInfo = new AccountUserInfo();
|
||||
accountUserInfo.setUser_id(userId);
|
||||
accountUserInfo.setUser_type_id(0);
|
||||
accountUserInfo.setUser_mobile(member.getUser_mobile());
|
||||
accountUserInfo.setUser_mobile(user_mobile);
|
||||
accountUserInfo.setUser_level_card(member.getUser_level_card());
|
||||
//user_level_id
|
||||
accountUserInfo.setUser_level_id(1); // todo select id
|
||||
@ -439,9 +434,9 @@ public abstract class SyncBaseThirdSxAbstract{
|
||||
// pay_user_resource 用户支付资源,积分,余额
|
||||
PayUserResource payUserResource = new PayUserResource();
|
||||
payUserResource.setUser_id(userId);
|
||||
payUserResource.setUser_money(member.getUser_money());
|
||||
payUserResource.setUser_money(BigDecimal.ZERO);
|
||||
payUserResource.setUser_money_frozen(BigDecimal.ZERO);
|
||||
payUserResource.setUser_points(member.getUser_points());
|
||||
payUserResource.setUser_points(BigDecimal.ZERO);
|
||||
payUserResource.setUser_points_frozen(BigDecimal.ZERO);
|
||||
success = payService.saveOrUpdatePayUserResource(payUserResource);
|
||||
}
|
||||
@ -693,13 +688,13 @@ public abstract class SyncBaseThirdSxAbstract{
|
||||
shopProductItem.setItem_market_price(BigDecimal.valueOf(jsonObj.getDouble("original_price")));
|
||||
//积分价
|
||||
shopProductItem.setItem_unit_points(new BigDecimal(jsonObj.getInt("points")));
|
||||
|
||||
shopProductItem.setItem_quantity(stock.intValue());
|
||||
//todo 特色商品切割
|
||||
//负数产品判断
|
||||
if(jsonObj.getInt("stock",99)<0){
|
||||
shopProductItem.setItem_quantity(99); // 库存
|
||||
shopProductItem.setItem_weight(new BigDecimal("0"));//切割重量
|
||||
}
|
||||
// if(jsonObj.getInt("stock",99)<0){
|
||||
// shopProductItem.setItem_quantity(99); // 库存
|
||||
// shopProductItem.setItem_weight(new BigDecimal("0"));//切割重量
|
||||
// }
|
||||
shopProductItem.setItem_quantity_frozen(0);
|
||||
shopProductItem.setItem_number(jsonObj.getStr("product_number"));// SKU商家编码
|
||||
shopProductItem.setItem_barcode(jsonObj.getStr("product_barcode")); // 条形码正常情况下就是货号
|
||||
|
||||
@ -22,6 +22,7 @@ import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.google.gson.Gson;
|
||||
import com.qcloud.cos.model.COSObjectSummary;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.api.StateCode;
|
||||
@ -60,6 +61,7 @@ import com.suisung.mall.shop.store.service.ShopStoreActivityBaseService;
|
||||
import com.suisung.mall.shop.sync.Utils.ActiveShopJsonUtils;
|
||||
import com.suisung.mall.shop.sync.Utils.BigDecimalFormatter;
|
||||
import com.suisung.mall.shop.sync.Utils.ThreadFileUtils;
|
||||
import com.suisung.mall.shop.sync.dto.BrandModel;
|
||||
import com.suisung.mall.shop.sync.keymanage.RedisKey;
|
||||
import com.suisung.mall.shop.sync.service.*;
|
||||
import org.slf4j.Logger;
|
||||
@ -167,9 +169,12 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
if (StrUtil.isBlank(appKey) || StrUtil.isBlank(sign) || ObjectUtil.isEmpty(categoryListJSON)) {
|
||||
return new ThirdApiRes().fail(1003, I18nUtil._("缺少必要参数!"));
|
||||
}
|
||||
|
||||
//用gson保证与客户端的顺序一致
|
||||
List<SxCategoryModel> sxCategoryModelList=categoryListJSON.toList(SxCategoryModel.class);
|
||||
Gson gson = new Gson();
|
||||
String jsonStr=gson.toJson(sxCategoryModelList);
|
||||
// 验签、appid,必要参数判断
|
||||
SyncApp syncApp = syncAppService.checkAppSign(appKey, sign, categoryListJSON.toString());
|
||||
SyncApp syncApp = syncAppService.checkAppSign(appKey, sign, jsonStr);
|
||||
if (syncApp == null) {
|
||||
return new ThirdApiRes().fail(1001, I18nUtil._("签名有误!"));
|
||||
}
|
||||
@ -202,9 +207,12 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
if (StrUtil.isBlank(appKey) || StrUtil.isBlank(sign) || ObjectUtil.isEmpty(brandListJSON)) {
|
||||
return new ThirdApiRes().fail(1003, I18nUtil._("缺少必要参数!"));
|
||||
}
|
||||
|
||||
//用gson保证与客户端的顺序一致
|
||||
List<BrandModel> brandModels=brandListJSON.toList(BrandModel.class);
|
||||
Gson gson = new Gson();
|
||||
String jsonStr=gson.toJson(brandModels);
|
||||
// 验签、appid,必要参数判断
|
||||
SyncApp syncApp = syncAppService.checkAppSign(appKey, sign, brandListJSON.toString());
|
||||
SyncApp syncApp = syncAppService.checkAppSign(appKey, sign, jsonStr);
|
||||
if (syncApp == null) {
|
||||
return new ThirdApiRes().fail(1001, I18nUtil._("签名有误!"));
|
||||
}
|
||||
@ -266,9 +274,11 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
if (StrUtil.isBlank(appKey) || StrUtil.isBlank(sign) || CollUtil.isEmpty(memberList)) {
|
||||
return new ThirdApiRes().fail(1003, I18nUtil._("缺少必要参数!"));
|
||||
}
|
||||
|
||||
//用gson保证与客户端的顺序一致
|
||||
Gson gson = new Gson();
|
||||
String jsonStr=gson.toJson(memberList);
|
||||
// 验签、appid,必要参数判断
|
||||
SyncApp syncApp = syncAppService.checkAppSign(appKey, sign, JSONUtil.toJsonStr(memberList));
|
||||
SyncApp syncApp = syncAppService.checkAppSign(appKey, sign, jsonStr);
|
||||
if (syncApp == null) {
|
||||
return new ThirdApiRes().fail(1001, I18nUtil._("签名有误!"));
|
||||
}
|
||||
@ -451,13 +461,11 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
}
|
||||
// 验签、appid,必要参数判断
|
||||
SyncApp syncAppO = 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));
|
||||
.select(SyncApp::getApp_key, SyncApp::getStore_id)
|
||||
.eq(SyncApp::getApp_key, appKey));
|
||||
if (syncAppO == null) {
|
||||
return new ThirdApiRes().fail(1001, I18nUtil._("签名有误!"));
|
||||
}
|
||||
|
||||
String storeId = syncAppO.getStore_id();
|
||||
try {
|
||||
if (multipartFile.isEmpty()) {
|
||||
@ -469,6 +477,13 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
String filePath = FileUtils.createFolderAndFileUsingFile(folder, filName);
|
||||
Path path = Paths.get(filePath);
|
||||
Files.write(path, bytes);
|
||||
String jsonStr = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
|
||||
//验证签名,签名不正确删除文件
|
||||
SyncApp syncApp = syncAppService.checkAppSign(appKey, sign, jsonStr);
|
||||
if(syncApp == null) {
|
||||
Files.delete(path);//删除文件
|
||||
return new ThirdApiRes().fail(500, "文件上传失败:签名验证失败");
|
||||
}
|
||||
logger.info("path-{},parent-{},filename-{},root-{}", path, path.getParent(), path.getFileName().toString(), path.getRoot());
|
||||
// String filaPath=path.toString();
|
||||
// if(filePath.contains(":")){
|
||||
@ -603,15 +618,15 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
||||
logger.info("执行成功{}个文件,失败{}个文件", success, fails);
|
||||
logger.info("同步商品数据执行结束");
|
||||
//更新当前的获取时间,用户客户端获取
|
||||
try {
|
||||
|
||||
if (ObjectUtil.isNotEmpty(storeDbConfig)) {
|
||||
storeDbConfig.setRefreshTime(date);
|
||||
storeDbConfigService.saveOrUpdate(storeDbConfig);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error("同步时间失败" + e.getMessage());
|
||||
}
|
||||
// try {
|
||||
//
|
||||
// if (ObjectUtil.isNotEmpty(storeDbConfig)) {
|
||||
// storeDbConfig.setRefreshTime(date);
|
||||
// storeDbConfigService.saveOrUpdate(storeDbConfig);
|
||||
// }
|
||||
// } catch (RuntimeException e) {
|
||||
// logger.error("同步时间失败" + e.getMessage());
|
||||
// }
|
||||
|
||||
syncShopImages(Integer.valueOf(storeId));//同时商品图库数据
|
||||
}
|
||||
|
||||
2
sql/shop/dev/20250630_ddl.sql
Normal file
2
sql/shop/dev/20250630_ddl.sql
Normal file
@ -0,0 +1,2 @@
|
||||
alter table store_db_config add priority_mode char(1) NOT NULL DEFAULT 1 COMMENT '更新优先方式(1:手动优先,2:自动优先),自动优先时根据平台给的商品自动切分上架,更新是才发挥作用';
|
||||
alter table store_db_config add index `index_priority_mode` (`priority_mode`) USING BTREE;
|
||||
Loading…
Reference in New Issue
Block a user