master:扫描条码 增加长度校验;

pull/1121/head
liujiang 2025-09-03 23:31:35 +08:00
parent 01f50d845c
commit 71c3099a28
14 changed files with 190 additions and 54 deletions

View File

@ -21,7 +21,7 @@ public class StorePrintSnVO {
@NotNull(message = "档口ID不能为空!")
@ApiModelProperty(value = "档口ID", required = true)
private String storeId;
private Long storeId;
@Valid
@NotNull(message = "打印颜色尺码列表不能为空!")
@ApiModelProperty(value = "打印颜色尺码列表", required = true)

View File

@ -19,7 +19,7 @@ public class StoreSaleSnVO {
@NotNull(message = "档口ID不能为空!")
@ApiModelProperty(value = "档口ID", required = true)
private String storeId;
private Long storeId;
@NotNull(message = "档口客户ID不能为空!")
@ApiModelProperty(value = "档口客户ID", required = true)
private Long storeCusId;

View File

@ -19,7 +19,7 @@ public class StoreStockTakingSnVO {
@NotNull(message = "档口ID不能为空!")
@ApiModelProperty(value = "档口ID", required = true)
private String storeId;
private Long storeId;
@NotNull(message = "条码列表不能为空!")
@ApiModelProperty(value = "条码列表", required = true)
private List<String> snList;

View File

@ -19,7 +19,7 @@ public class StoreStorageSnVO {
@NotNull(message = "档口ID不能为空!")
@ApiModelProperty(value = "档口ID", required = true)
private String storeId;
private Long storeId;
@NotNull(message = "条码列表不能为空!")
@ApiModelProperty(value = "条码列表", required = true)
private List<String> snList;

View File

@ -238,6 +238,21 @@ public class Constants
// %04d
public static final String VOUCHER_SEQ_FORMAT = "%04d";
// 步橘网条码长度
public static final Integer BU_JU_SN_LENGTH = 21;
// 天友条码长度
public static final Integer TIAN_YOU_SN_LENGTH = 13;
// 发货宝条码长度
public static final Integer FA_HUO_BAO_SN_LENGTH = 17;
// 步橘网条码前缀长度
public static final Integer BU_JU_SN_PREFIX_LENGTH = 13;
// 天友条码前缀长度
public static final Integer TIAN_YOU_SN_PREFIX_LENGTH = 6;
// 发货宝条码前缀长度
public static final Integer FA_HUO_BAO_SN_PREFIX_LENGTH = 10;
/**
*
*/

View File

@ -140,4 +140,9 @@ public class Store extends XktBaseEntity {
*/
private Integer storeWeight;
/**
* 1 2 3
*/
private Integer stockSys;
}

View File

@ -18,7 +18,7 @@ import java.util.List;
public class StorePrintSnDTO {
@ApiModelProperty(value = "档口ID")
private String storeId;
private Long storeId;
@ApiModelProperty(value = "打印颜色尺码列表")
private List<SPColorSizeVO> colorSizeList;

View File

@ -15,7 +15,7 @@ import java.util.List;
public class StoreProdSnDTO {
@ApiModelProperty(value = "档口ID")
private String storeId;
private Long storeId;
@ApiModelProperty(value = "条码列表")
private List<String> snList;

View File

@ -13,7 +13,7 @@ import lombok.Data;
public class StoreSaleSnDTO {
@ApiModelProperty(value = "档口ID")
private String storeId;
private Long storeId;
@ApiModelProperty(value = "档口客户ID")
private Long storeCusId;
@ApiModelProperty(value = "是否退货")

View File

@ -17,7 +17,7 @@ import java.util.List;
public class StoreStockTakingSnDTO {
@ApiModelProperty(value = "档口ID")
private String storeId;
private Long storeId;
@ApiModelProperty(value = "条码列表")
private List<String> snList;

View File

@ -0,0 +1,38 @@
package com.ruoyi.xkt.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 广
*
* @author liujiang
* @date 2025-04-02 23:42
*/
@Getter
@AllArgsConstructor
public enum StockSysType {
// 步橘网
BU_JU(1, "步橘网"),
// 天友
TIAN_YOU(2, "天友"),
// 发货宝
FA_HUO_BAO(3, "发货宝"),
;
private final Integer value;
private final String label;
public static StockSysType of(Integer value) {
for (StockSysType e : StockSysType.values()) {
if (e.getValue().equals(value)) {
return e;
}
}
// 默认库存
return StockSysType.BU_JU;
}
}

View File

@ -43,7 +43,7 @@ public interface StoreProductColorSizeMapper extends BaseMapper<StoreProductColo
* @param storeCusId ID
* @return StoreSaleBarcodeResDTO
*/
StoreSaleSnResDTO selectSn(@Param("snPrefix") String snPrefix, @Param("storeId") String storeId, @Param("storeCusId") Long storeCusId);
StoreSaleSnResDTO selectSn(@Param("snPrefix") String snPrefix, @Param("storeId") Long storeId, @Param("storeCusId") Long storeCusId);
/**
*
@ -53,41 +53,44 @@ public interface StoreProductColorSizeMapper extends BaseMapper<StoreProductColo
* @param storeCusId ID
* @return StoreSaleBarcodeResDTO
*/
StoreSaleSnResDTO selectOtherSn(@Param("snPrefix") String snPrefix, @Param("storeId") String storeId, @Param("storeCusId") Long storeCusId);
StoreSaleSnResDTO selectOtherSn(@Param("snPrefix") String snPrefix, @Param("storeId") Long storeId, @Param("storeCusId") Long storeCusId);
/**
*
* @param storeId ID
*
* @param storeId ID
* @param buJuPrefixSnList
* @return
*/
List<StoreStorageSnDTO.SSSDetailDTO> selectStorageBuJuSnList(@Param("storeId") String storeId, @Param("buJuPrefixSnList") List<String> buJuPrefixSnList);
List<StoreStorageSnDTO.SSSDetailDTO> selectStorageBuJuSnList(@Param("storeId") Long storeId, @Param("buJuPrefixSnList") List<String> buJuPrefixSnList);
/**
*
* @param storeId id
*
* @param storeId id
* @param otherPrefixSnList
* @return List<StoreStorageSnDTO.SSSDetailDTO>
* @return List<StoreStorageSnDTO.SSSDetailDTO>
*/
List<StoreStorageSnDTO.SSSDetailDTO> selectStorageOtherSnList(@Param("storeId") String storeId, @Param("otherPrefixSnList") List<String> otherPrefixSnList);
List<StoreStorageSnDTO.SSSDetailDTO> selectStorageOtherSnList(@Param("storeId") Long storeId, @Param("otherPrefixSnList") List<String> otherPrefixSnList);
/**
*
*
* @param storeId ID
* @param buJuPrefixSnList
* @param storeId ID
* @param buJuPrefixSnList
* @return List<StoreStockTakingSnTempDTO.SSTSTDetailDTO>
*/
List<StoreStockTakingSnTempDTO.SSTSTDetailDTO> selectStockBuJuSnList(@Param("storeId") String storeId, @Param("buJuPrefixSnList") List<String> buJuPrefixSnList);
List<StoreStockTakingSnTempDTO.SSTSTDetailDTO> selectStockBuJuSnList(@Param("storeId") Long storeId, @Param("buJuPrefixSnList") List<String> buJuPrefixSnList);
/**
*
* @param storeId ID
*
* @param storeId ID
* @param otherPrefixSnList
* @return List<StoreStockTakingSnTempDTO.SSTSTDetailDTO>
*/
List<StoreStockTakingSnTempDTO.SSTSTDetailDTO> selectStockOtherSnList(@Param("storeId") String storeId, @Param("otherPrefixSnList") List<String> otherPrefixSnList);
List<StoreStockTakingSnTempDTO.SSTSTDetailDTO> selectStockOtherSnList(@Param("storeId") Long storeId, @Param("otherPrefixSnList") List<String> otherPrefixSnList);
}

View File

@ -19,6 +19,7 @@ import com.ruoyi.xkt.dto.storeCertificate.StoreCertDTO;
import com.ruoyi.xkt.dto.storeCertificate.StoreCertResDTO;
import com.ruoyi.xkt.dto.storeCertificate.StoreCertStepResDTO;
import com.ruoyi.xkt.enums.FileType;
import com.ruoyi.xkt.enums.StockSysType;
import com.ruoyi.xkt.enums.StoreStatus;
import com.ruoyi.xkt.mapper.*;
import com.ruoyi.xkt.service.IAssetService;
@ -224,6 +225,8 @@ public class StoreCertificateServiceImpl implements IStoreCertificateService {
store.setTrialEndTime(oneYearAfter);
// 设置档口默认权重 0
store.setStoreWeight(Constants.STORE_WEIGHT_DEFAULT_ZERO);
// 设置默认的库存系统为 步橘 ,后续可在条码迁移之处修改
store.setStockSys(StockSysType.BU_JU.getValue());
// 已使用的档口空间
BigDecimal storageUsage = certDTO.getStoreCert().getFileList().stream().map(x -> ObjectUtils.defaultIfNull(x.getFileSize(), BigDecimal.ZERO))
.reduce(BigDecimal.ZERO, BigDecimal::add);

View File

@ -2,13 +2,18 @@ package com.ruoyi.xkt.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.xkt.domain.Store;
import com.ruoyi.xkt.domain.StoreProductColorSize;
import com.ruoyi.xkt.domain.StoreProductStock;
import com.ruoyi.xkt.dto.storeProdColorSize.*;
import com.ruoyi.xkt.enums.StockSysType;
import com.ruoyi.xkt.mapper.StoreMapper;
import com.ruoyi.xkt.mapper.StoreProductColorSizeMapper;
import com.ruoyi.xkt.mapper.StoreProductStockMapper;
import com.ruoyi.xkt.mapper.StoreSaleDetailMapper;
@ -38,13 +43,36 @@ public class StoreProductColorSizeServiceImpl implements IStoreProductColorSizeS
final StoreProductColorSizeMapper prodColorSizeMapper;
final StoreSaleDetailMapper saleDetailMapper;
final StoreProductStockMapper prodStockMapper;
final StoreMapper storeMapper;
final RedisCache redisCache;
// 纯数字
private static final Pattern POSITIVE_PATTERN = Pattern.compile("^\\d+$");
// 步橘系统条码截止索引
/* // 步橘系统条码截止索引
private static final Integer buJuEndIndex = 13;
// 其它系统的条码截止索引
private static final Integer otherSysEndIndex = 10;
private static final Integer otherSysEndIndex = 10;*/
// 当前库存系统的条码前缀长度
private static final Map<Integer, Integer> STOCK_PREFIX_LENGTH_MAP = new HashMap<>();
// 当前库存系统的条码长度
private static final Map<Integer, Set<Integer>> STOCK_FIXED_LENGTHS_MAP = new HashMap<>();
static {
STOCK_PREFIX_LENGTH_MAP.put(StockSysType.BU_JU.getValue(), Constants.BU_JU_SN_PREFIX_LENGTH);
STOCK_PREFIX_LENGTH_MAP.put(StockSysType.TIAN_YOU.getValue(), Constants.TIAN_YOU_SN_PREFIX_LENGTH);
STOCK_PREFIX_LENGTH_MAP.put(StockSysType.FA_HUO_BAO.getValue(), Constants.FA_HUO_BAO_SN_PREFIX_LENGTH);
}
static {
STOCK_FIXED_LENGTHS_MAP.put(StockSysType.BU_JU.getValue(), Collections
.unmodifiableSet(new HashSet<>(Collections.singletonList(Constants.BU_JU_SN_LENGTH))));
STOCK_FIXED_LENGTHS_MAP.put(StockSysType.TIAN_YOU.getValue(), Collections
.unmodifiableSet(new HashSet<>(Arrays.asList(Constants.TIAN_YOU_SN_LENGTH, Constants.BU_JU_SN_LENGTH))));
STOCK_FIXED_LENGTHS_MAP.put(StockSysType.FA_HUO_BAO.getValue(), Collections
.unmodifiableSet(new HashSet<>(Arrays.asList(Constants.FA_HUO_BAO_SN_LENGTH, Constants.BU_JU_SN_LENGTH))));
}
/**
*
@ -56,11 +84,13 @@ public class StoreProductColorSizeServiceImpl implements IStoreProductColorSizeS
@Transactional(readOnly = true)
public StoreSaleSnResDTO storeSaleSn(StoreSaleSnDTO snDTO) {
// 用户是否为档口管理者或子账户
if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(Long.valueOf(snDTO.getStoreId()))) {
if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(snDTO.getStoreId())) {
throw new ServiceException("当前用户非档口管理者或子账号,无权限操作!", HttpStatus.ERROR);
}
// 非纯数字,则直接返回
if (!POSITIVE_PATTERN.matcher(snDTO.getSn()).matches()) {
final Integer stockSys = this.stockSys(snDTO.getStoreId());
// 非纯数字 且 条码长度不合法
if (!POSITIVE_PATTERN.matcher(snDTO.getSn()).matches()
&& !STOCK_FIXED_LENGTHS_MAP.get(stockSys).contains(snDTO.getSn().length())) {
return new StoreSaleSnResDTO().setSuccess(Boolean.FALSE).setSn(snDTO.getSn());
}
// 销售出库[退货]
@ -71,14 +101,15 @@ public class StoreProductColorSizeServiceImpl implements IStoreProductColorSizeS
return barcodeResDTO.setSuccess(Boolean.TRUE);
} else {
// 若是没查询到数据,则走正常条码查询流程
return this.getSnInfo(snDTO);
return this.getSnInfo(snDTO, stockSys);
}
// 销售出库[销售] 正常条码查询流程
} else {
return this.getSnInfo(snDTO);
return this.getSnInfo(snDTO, stockSys);
}
}
/**
*
*
@ -89,26 +120,36 @@ public class StoreProductColorSizeServiceImpl implements IStoreProductColorSizeS
@Transactional(readOnly = true)
public StoreStorageSnResDTO storageSnList(StoreProdSnDTO snDTO) {
// 用户是否为档口管理者或子账户
if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(Long.valueOf(snDTO.getStoreId()))) {
if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(snDTO.getStoreId())) {
throw new ServiceException("当前用户非档口管理者或子账号,无权限操作!", HttpStatus.ERROR);
}
List<String> snList = snDTO.getSnList().stream().filter(s -> POSITIVE_PATTERN.matcher(s).matches()).collect(Collectors.toList());
if (CollectionUtils.isEmpty(snList)) {
// 校验条码长度是否合法
final Integer stockSys = this.stockSys(snDTO.getStoreId());
// 符合规则的条码列表
List<String> validSnList = snDTO.getSnList().stream()
// 为纯数字 且 条码长度合法
.filter(s -> POSITIVE_PATTERN.matcher(s).matches() && STOCK_FIXED_LENGTHS_MAP.get(stockSys).contains(s.length()))
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(validSnList)) {
// 全部都是错误条码
return new StoreStorageSnResDTO().setFailList(snDTO.getSnList());
}
// 非纯数字的条码
List<String> failList = snDTO.getSnList().stream().filter(s -> !POSITIVE_PATTERN.matcher(s).matches()).collect(Collectors.toList());
// 非的条码
List<String> failList = snDTO.getSnList().stream().filter(s -> !validSnList.contains(s)).collect(Collectors.toList());
// 步橘网条码
Set<String> buJuPrefixSnSet = snList.stream().filter(x -> x.startsWith(snDTO.getStoreId())).map(x -> x.substring(0, buJuEndIndex)).collect(Collectors.toSet());
Set<String> buJuPrefixSnSet = validSnList.stream().filter(x -> x.startsWith(snDTO.getStoreId().toString()))
.map(x -> x.substring(0, STOCK_PREFIX_LENGTH_MAP.get(StockSysType.BU_JU.getValue()))).collect(Collectors.toSet());
// 其它系统条码
Set<String> otherPrefixSnSet = snList.stream().filter(x -> !x.startsWith(snDTO.getStoreId())).map(x -> x.substring(0, otherSysEndIndex)).collect(Collectors.toSet());
Set<String> otherPrefixSnSet = Objects.equals(StockSysType.BU_JU.getValue(), stockSys) ? new HashSet<>()
: validSnList.stream().filter(x -> !x.startsWith(snDTO.getStoreId().toString()))
.map(x -> x.substring(0, STOCK_PREFIX_LENGTH_MAP.get(stockSys))).collect(Collectors.toSet());
List<StoreStorageSnDTO.SSSDetailDTO> existList = new ArrayList<>();
// 根据条码查询数据库数据
if (CollectionUtils.isNotEmpty(buJuPrefixSnSet)) {
List<StoreStorageSnDTO.SSSDetailDTO> buJuExistList = this.prodColorSizeMapper.selectStorageBuJuSnList(snDTO.getStoreId(), new ArrayList<>(buJuPrefixSnSet));
CollectionUtils.addAll(existList, buJuExistList);
} else if (CollectionUtils.isNotEmpty(otherPrefixSnSet)) {
}
if (CollectionUtils.isNotEmpty(otherPrefixSnSet)) {
List<StoreStorageSnDTO.SSSDetailDTO> otherExistList = this.prodColorSizeMapper.selectStorageOtherSnList(snDTO.getStoreId(), new ArrayList<>(otherPrefixSnSet));
CollectionUtils.addAll(existList, otherExistList);
}
@ -121,8 +162,10 @@ public class StoreProductColorSizeServiceImpl implements IStoreProductColorSizeS
Set<StoreStorageSnResDTO.SSSDetailDTO> successSet = new HashSet<>();
// 临时用来计数的list
List<StoreStorageSnDTO.SSSDetailDTO> tempList = new ArrayList<>();
snList.forEach(sn -> {
String prefixPart = sn.startsWith(snDTO.getStoreId()) ? sn.substring(0, buJuEndIndex) : sn.substring(0, otherSysEndIndex);
validSnList.forEach(sn -> {
String prefixPart = sn.startsWith(snDTO.getStoreId().toString())
? sn.substring(0, STOCK_PREFIX_LENGTH_MAP.get(StockSysType.BU_JU.getValue()))
: sn.substring(0, STOCK_PREFIX_LENGTH_MAP.get(stockSys));
StoreStorageSnDTO.SSSDetailDTO exist = existMap.get(prefixPart);
if (ObjectUtils.isNotEmpty(exist)) {
tempList.add(exist);
@ -153,26 +196,36 @@ public class StoreProductColorSizeServiceImpl implements IStoreProductColorSizeS
@Transactional(readOnly = true)
public StoreStockTakingSnResDTO stockTakingSnList(StoreStockTakingSnDTO snDTO) {
// 用户是否为档口管理者或子账户
if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(Long.valueOf(snDTO.getStoreId()))) {
if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(snDTO.getStoreId())) {
throw new ServiceException("当前用户非档口管理者或子账号,无权限操作!", HttpStatus.ERROR);
}
List<String> snList = snDTO.getSnList().stream().filter(s -> POSITIVE_PATTERN.matcher(s).matches()).collect(Collectors.toList());
if (CollectionUtils.isEmpty(snList)) {
// 校验条码长度是否合法
final Integer stockSys = this.stockSys(snDTO.getStoreId());
// 符合规则的条码列表
List<String> validSnList = snDTO.getSnList().stream()
// 为纯数字 且 条码长度合法
.filter(s -> POSITIVE_PATTERN.matcher(s).matches() && STOCK_FIXED_LENGTHS_MAP.get(stockSys).contains(s.length()))
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(validSnList)) {
// 全部都是错误条码
return new StoreStockTakingSnResDTO().setFailList(snDTO.getSnList());
}
// 非纯数字的条码
List<String> failList = snDTO.getSnList().stream().filter(s -> !POSITIVE_PATTERN.matcher(s).matches()).collect(Collectors.toList());
// 非的条码
List<String> failList = snDTO.getSnList().stream().filter(s -> !validSnList.contains(s)).collect(Collectors.toList());
// 步橘网条码
Set<String> buJuPrefixSnSet = snList.stream().filter(x -> x.startsWith(snDTO.getStoreId())).map(x -> x.substring(0, buJuEndIndex)).collect(Collectors.toSet());
Set<String> buJuPrefixSnSet = validSnList.stream().filter(x -> x.startsWith(snDTO.getStoreId().toString()))
.map(x -> x.substring(0, STOCK_PREFIX_LENGTH_MAP.get(StockSysType.BU_JU.getValue()))).collect(Collectors.toSet());
// 其它系统条码
Set<String> otherPrefixSnSet = snList.stream().filter(x -> !x.startsWith(snDTO.getStoreId())).map(x -> x.substring(0, otherSysEndIndex)).collect(Collectors.toSet());
Set<String> otherPrefixSnSet = Objects.equals(StockSysType.BU_JU.getValue(), stockSys) ? new HashSet<>()
: validSnList.stream().filter(x -> !x.startsWith(snDTO.getStoreId().toString()))
.map(x -> x.substring(0, STOCK_PREFIX_LENGTH_MAP.get(stockSys))).collect(Collectors.toSet());
List<StoreStockTakingSnTempDTO.SSTSTDetailDTO> existList = new ArrayList<>();
// 查询出的所有条码
if (CollectionUtils.isNotEmpty(buJuPrefixSnSet)) {
List<StoreStockTakingSnTempDTO.SSTSTDetailDTO> buJuExistList = this.prodColorSizeMapper.selectStockBuJuSnList(snDTO.getStoreId(), new ArrayList<>(buJuPrefixSnSet));
CollectionUtils.addAll(existList, buJuExistList);
} else if (CollectionUtils.isNotEmpty(otherPrefixSnSet)) {
}
if (CollectionUtils.isNotEmpty(otherPrefixSnSet)) {
List<StoreStockTakingSnTempDTO.SSTSTDetailDTO> otherExistList = this.prodColorSizeMapper.selectStockOtherSnList(snDTO.getStoreId(), new ArrayList<>(otherPrefixSnSet));
CollectionUtils.addAll(existList, otherExistList);
}
@ -185,8 +238,10 @@ public class StoreProductColorSizeServiceImpl implements IStoreProductColorSizeS
Set<StoreStockTakingSnResDTO.SSTSDetailDTO> stockSet = new HashSet<>();
// 获取数量的列表
List<StoreStockTakingSnTempDTO.SSTSTDetailDTO> tempList = new ArrayList<>();
snList.forEach(sn -> {
String prefixPart = sn.startsWith(snDTO.getStoreId()) ? sn.substring(0, buJuEndIndex) : sn.substring(0, otherSysEndIndex);
validSnList.forEach(sn -> {
String prefixPart = sn.startsWith(snDTO.getStoreId().toString())
? sn.substring(0, STOCK_PREFIX_LENGTH_MAP.get(StockSysType.BU_JU.getValue()))
: sn.substring(0, STOCK_PREFIX_LENGTH_MAP.get(stockSys));
StoreStockTakingSnTempDTO.SSTSTDetailDTO exist = existMap.get(prefixPart);
if (ObjectUtils.isNotEmpty(exist)) {
tempList.add(exist);
@ -257,7 +312,7 @@ public class StoreProductColorSizeServiceImpl implements IStoreProductColorSizeS
@Transactional
public List<StorePrintSnResDTO> getPrintSnList(StorePrintSnDTO snDTO) {
// 用户是否为档口管理者或子账户
if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(Long.valueOf(snDTO.getStoreId()))) {
if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(snDTO.getStoreId())) {
throw new ServiceException("当前用户非档口管理者或子账号,无权限操作!", HttpStatus.ERROR);
}
// 获取商品颜色尺码基础数据
@ -313,20 +368,20 @@ public class StoreProductColorSizeServiceImpl implements IStoreProductColorSizeS
/**
*
*
* @param snDTO
* @param snDTO
* @param stockSys 使
* @return StoreSaleBarcodeResDTO
*/
private StoreSaleSnResDTO getSnInfo(StoreSaleSnDTO snDTO) {
private StoreSaleSnResDTO getSnInfo(StoreSaleSnDTO snDTO, Integer stockSys) {
StoreSaleSnResDTO barcodeResDTO;
// 步橘网生成的条码
if (snDTO.getSn().startsWith(snDTO.getStoreId())) {
final String prefixPart = snDTO.getSn().substring(0, buJuEndIndex);
if (snDTO.getSn().startsWith(snDTO.getStoreId().toString())) {
final String prefixPart = snDTO.getSn().substring(0, STOCK_PREFIX_LENGTH_MAP.get(StockSysType.BU_JU.getValue()));
// 查询数据库 获取条码对应的商品信息
barcodeResDTO = prodColorSizeMapper.selectSn(prefixPart, snDTO.getStoreId(), snDTO.getStoreCusId());
} else {
// 从系统设置中获取,根据系统迁移时的配置
final String prefixPart = snDTO.getSn().substring(0, otherSysEndIndex);
final String prefixPart = snDTO.getSn().substring(0, STOCK_PREFIX_LENGTH_MAP.get(stockSys));
// 查询数据库 获取条码对应的商品信息
barcodeResDTO = prodColorSizeMapper.selectOtherSn(prefixPart, snDTO.getStoreId(), snDTO.getStoreCusId());
}
@ -335,4 +390,21 @@ public class StoreProductColorSizeServiceImpl implements IStoreProductColorSizeS
}
/**
*
*
* @param storeId ID
* @return Set
*/
private Integer stockSys(Long storeId) {
// 获取当前档口的库存系统是:步橘网、天友、发货宝 的哪一个
Store store = this.redisCache.getCacheObject(CacheConstants.STORE_KEY + storeId);
if (ObjectUtils.isEmpty(store)) {
store = Optional.ofNullable(this.storeMapper.selectById(storeId)).orElseThrow(() -> new ServiceException("档口不存在!", HttpStatus.ERROR));
this.redisCache.setCacheObject(CacheConstants.STORE_KEY + storeId, store);
}
return store.getStockSys();
}
}