|
@@ -130,6 +130,10 @@ public class CommodityProcureServiceImpl implements CommodityProcureService {
|
|
|
private static final Pattern IMG_SRC_PATTERN =
|
|
private static final Pattern IMG_SRC_PATTERN =
|
|
|
Pattern.compile("<img[^>]*?src\\s*=\\s*[\"']([^\"']+)[\"']", Pattern.CASE_INSENSITIVE);
|
|
Pattern.compile("<img[^>]*?src\\s*=\\s*[\"']([^\"']+)[\"']", Pattern.CASE_INSENSITIVE);
|
|
|
|
|
|
|
|
|
|
+ /** 提取 PHP 序列化数组中的字符串值 s:len:"value";(对应 PHP unserialize(thumb_url)) */
|
|
|
|
|
+ private static final Pattern PHP_SERIALIZE_STR_PATTERN =
|
|
|
|
|
+ Pattern.compile("s:\\d+:\"(.*?)\";", Pattern.DOTALL);
|
|
|
|
|
+
|
|
|
private static final BigDecimal HUNDRED = new BigDecimal("100");
|
|
private static final BigDecimal HUNDRED = new BigDecimal("100");
|
|
|
private static final BigDecimal COMMISSION_DEFAULT_RATE = new BigDecimal("0.01");
|
|
private static final BigDecimal COMMISSION_DEFAULT_RATE = new BigDecimal("0.01");
|
|
|
private static final Integer JD_SHOP_ID = 11507;
|
|
private static final Integer JD_SHOP_ID = 11507;
|
|
@@ -282,6 +286,7 @@ public class CommodityProcureServiceImpl implements CommodityProcureService {
|
|
|
if (keyWord != null && !keyWord.trim().isEmpty()) {
|
|
if (keyWord != null && !keyWord.trim().isEmpty()) {
|
|
|
criteria.and("gd_name").regex(".*" + keyWord.trim() + ".*", "i");
|
|
criteria.and("gd_name").regex(".*" + keyWord.trim() + ".*", "i");
|
|
|
}
|
|
}
|
|
|
|
|
+// criteria.and("gd_id").is(430184);
|
|
|
|
|
|
|
|
Query query = new Query(criteria);
|
|
Query query = new Query(criteria);
|
|
|
// 只查gd_id字段,提高查询效率
|
|
// 只查gd_id字段,提高查询效率
|
|
@@ -824,6 +829,8 @@ public class CommodityProcureServiceImpl implements CommodityProcureService {
|
|
|
.eq(ImsEweiShopGoods::getMerchid, 0)
|
|
.eq(ImsEweiShopGoods::getMerchid, 0)
|
|
|
.eq(ImsEweiShopGoods::getDeleted, 0)
|
|
.eq(ImsEweiShopGoods::getDeleted, 0)
|
|
|
.gt(ImsEweiShopGoods::getCostprice, 0)
|
|
.gt(ImsEweiShopGoods::getCostprice, 0)
|
|
|
|
|
+ //库存要大于0
|
|
|
|
|
+ .gt(ImsEweiShopGoods::getTotal,0)
|
|
|
.ne(ImsEweiShopGoods::getCatchSource, "xinglian");
|
|
.ne(ImsEweiShopGoods::getCatchSource, "xinglian");
|
|
|
// 关键字过滤(商品ID或标题模糊匹配)
|
|
// 关键字过滤(商品ID或标题模糊匹配)
|
|
|
if (req.getKeyword() != null && !req.getKeyword().trim().isEmpty()) {
|
|
if (req.getKeyword() != null && !req.getKeyword().trim().isEmpty()) {
|
|
@@ -831,7 +838,7 @@ public class CommodityProcureServiceImpl implements CommodityProcureService {
|
|
|
goodsQuery.and(w -> w.eq(ImsEweiShopGoods::getId, kw)
|
|
goodsQuery.and(w -> w.eq(ImsEweiShopGoods::getId, kw)
|
|
|
.or().like(ImsEweiShopGoods::getTitle, kw));
|
|
.or().like(ImsEweiShopGoods::getTitle, kw));
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+// goodsQuery.last("limit 1");
|
|
|
List<ImsEweiShopGoods> items = goodsService.list(goodsQuery);
|
|
List<ImsEweiShopGoods> items = goodsService.list(goodsQuery);
|
|
|
|
|
|
|
|
int submitCount = 0;
|
|
int submitCount = 0;
|
|
@@ -868,8 +875,9 @@ public class CommodityProcureServiceImpl implements CommodityProcureService {
|
|
|
private void supplyGoodsToMall(ImsEweiShopGoods item, Integer storeid, Integer cate, Integer uniacid) {
|
|
private void supplyGoodsToMall(ImsEweiShopGoods item, Integer storeid, Integer cate, Integer uniacid) {
|
|
|
Long goodsId = item.getId();
|
|
Long goodsId = item.getId();
|
|
|
|
|
|
|
|
- // 【Bug修复】查重前置:是否已在云商城供货(通过gd_id判断),避免无效查询
|
|
|
|
|
- if (item.getGdId() != null && item.getGdId() > 0) {
|
|
|
|
|
|
|
+ // 查重前置:是否已在云商城供货(对齐PHP getYmallQiyungoods,查云商城侧 goodsid+shop_id 有效记录)
|
|
|
|
|
+ // 注意:不能用本地 gd_id>0 判断——停供只软删云商城记录、不清本地 gd_id,那样会误拦「停供后重新供货」
|
|
|
|
|
+ if (b2cGoodsSpuInOnlineMapper.countSuppliedByGoodsid(item.getId().intValue(), storeid) > 0) {
|
|
|
throw new ApiException("商品已经供货");
|
|
throw new ApiException("商品已经供货");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -929,21 +937,53 @@ public class CommodityProcureServiceImpl implements CommodityProcureService {
|
|
|
* 构建商品图片列表:thumb首图 + thumb_url扩展图
|
|
* 构建商品图片列表:thumb首图 + thumb_url扩展图
|
|
|
*/
|
|
*/
|
|
|
private List<String> buildGoodsImages(ImsEweiShopGoods item, Long goodsId) {
|
|
private List<String> buildGoodsImages(ImsEweiShopGoods item, Long goodsId) {
|
|
|
- List<String> imgsInfo = new ArrayList<>();
|
|
|
|
|
- if (item.getThumb() != null) {
|
|
|
|
|
- imgsInfo.add(item.getThumb());
|
|
|
|
|
|
|
+ // 对齐 PHP supply():先解析 thumb_url 扩展图并转全路径,再用主图 thumb 覆盖下标 0
|
|
|
|
|
+ List<String> imgsInfo = parseThumbUrl(item.getThumbUrl(), goodsId);
|
|
|
|
|
+ for (int i = 0; i < imgsInfo.size(); i++) {
|
|
|
|
|
+ imgsInfo.set(i, toMedia(imgsInfo.get(i)));
|
|
|
|
|
+ }
|
|
|
|
|
+ String mainThumb = toMedia(item.getThumb());
|
|
|
|
|
+ if (StringUtils.isNotBlank(mainThumb)) {
|
|
|
|
|
+ if (imgsInfo.isEmpty()) {
|
|
|
|
|
+ imgsInfo.add(mainThumb);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // PHP:$thumb_url[0] = 主图,扩展图的原下标 0 被覆盖丢弃
|
|
|
|
|
+ imgsInfo.set(0, mainThumb);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- if (item.getThumbUrl() != null && !item.getThumbUrl().isEmpty()) {
|
|
|
|
|
|
|
+ return imgsInfo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 解析 ims_ewei_shop_goods.thumb_url(对应 PHP unserialize):
|
|
|
|
|
+ * 兼容 JSON 数组与 PHP 序列化数组两种存储格式,返回相对/全路径图片列表。
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<String> parseThumbUrl(String thumbUrl, Long goodsId) {
|
|
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
|
|
+ if (StringUtils.isBlank(thumbUrl)) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ String s = thumbUrl.trim();
|
|
|
|
|
+ if (s.startsWith("[")) {
|
|
|
try {
|
|
try {
|
|
|
- List<String> extraImgs = JSON.parseArray(item.getThumbUrl(), String.class);
|
|
|
|
|
- if (extraImgs != null) {
|
|
|
|
|
- imgsInfo.addAll(extraImgs);
|
|
|
|
|
|
|
+ List<String> arr = JSON.parseArray(s, String.class);
|
|
|
|
|
+ if (arr != null) {
|
|
|
|
|
+ list.addAll(arr);
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- log.warn("thumb_url解析失败 goodsId={}", goodsId, e);
|
|
|
|
|
|
|
+ log.warn("thumb_url(JSON)解析失败 goodsId={}, thumbUrl={}", goodsId, thumbUrl, e);
|
|
|
}
|
|
}
|
|
|
|
|
+ return list;
|
|
|
}
|
|
}
|
|
|
- return imgsInfo;
|
|
|
|
|
|
|
+ if (s.startsWith("a:")) {
|
|
|
|
|
+ Matcher m = PHP_SERIALIZE_STR_PATTERN.matcher(s);
|
|
|
|
|
+ while (m.find()) {
|
|
|
|
|
+ list.add(m.group(1));
|
|
|
|
|
+ }
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ log.warn("thumb_url未知格式,已忽略 goodsId={}, thumbUrl={}", goodsId, thumbUrl);
|
|
|
|
|
+ return list;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|