合并问题

20230922-ljl-fixBug
daixiaogang 1 year ago
parent 8bf9aad346
commit 7999ece378

@ -71,7 +71,7 @@ public class MoveShopSettingBO {
/**
* price_tail
*/
private int priceTail;
private Integer priceTail;
/**
* price_decimal

@ -4,6 +4,7 @@ import lombok.Data;
@Data
public class SkuDetailBO {
private Long skuId;
private double price;
private String code;
private int stockNum;

@ -1483,20 +1483,115 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
if (price == null) {
price = 0;
}
String cnaliDsDetailId = queueMsg.getCnaliDsDetailId();
Double hasImportPrice = queueMsg.getHasImportPrice();
//skuMap = appendSkuCode(moveBaseData, queueMsg, skuMap, itemNum); // TODO 跳过
Map<String, SkuDetailBO> skuList = buildSkuListAndSkuImages(mSkus.getJSONObject("skuMap"), mSkus.getJSONObject("colorMap"), mSkus.getJSONObject("sizeMap"));
// skuList = buildSkuListAndSkuImages(mSkus.getJSONObject() ['skuMap'], mSkus['colorMap'], mSkus['sizeMap'], condition, (price > 0 ? price : queueMsg.getPrice()), queueMsg.getShopId());
// skuList = calSkuPriceByCondition($isFastMode, $skuList, $condition['price'], $moveBaseData, $cnaliDsDetailId, $hasImportPrice);
// updateSkuMinPriceInfo = getUpdateSkuMinPriceInfo($condition['price'], $skuList);
skuList = calSkuPriceByCondition(isFastMode, skuList, condition.getPrice(), moveBaseData, cnaliDsDetailId, hasImportPrice);
List<StrObjMap> updateSkuMinPriceInfo = getUpdateSkuMinPriceInfo(condition.getPrice(), skuList);
mSkus.put("skus", skuMap);
StrObjMap result = new StrObjMap();
result.put("skuList", skuList);
// result.put("updateSkuMinPriceInfo", "");
result.put("updateSkuMinPriceInfo", updateSkuMinPriceInfo);
return result;
}
private List<StrObjMap> getUpdateSkuMinPriceInfo(JSONObject priceCondition, Map<String, SkuDetailBO> skuList) {
if (!priceCondition.containsKey("skuMinPriceStatus") || !priceCondition.get("skuMinPriceType").equals(MoveConst.skuMinPriceTypeUpdate)) {
return new ArrayList<>();
}
return skuList.values().stream().filter(x -> ObjectUtil.isNotNull(x.getUpdateSkuMinPriceInfo())).map(x -> (StrObjMap) x.getUpdateSkuMinPriceInfo()).collect(Collectors.toList());
}
private Map<String, SkuDetailBO> calSkuPriceByCondition(int isFastMode, Map<String, SkuDetailBO> skuList, JSONObject priceCondition, JSONObject moveBaseData, String cnaliDsDetailId, Double hasImportPrice) {
double maxPrice = 0;
double minPrice = 0;
int skuTotal = skuList.size();
Integer addSkuPriceSource = priceCondition.getInteger("addSkuPriceSource");
double sourceMinPrice = 0;
double sourcePostFeePriceAddValue = (double) priceCondition.get("sourcePostFeePriceAddValue");
for (Map.Entry<String, SkuDetailBO> stringSkuDetailBOEntry : skuList.entrySet()) {
SkuDetailBO skuDetail = stringSkuDetailBOEntry.getValue();
String isSkuMinPrice = skuDetail.getIsSkuMinPrice();
skuDetail.setIsSkuMinPrice(null);
if (isFastMode != 0 && (ObjectUtil.isNull(hasImportPrice) || hasImportPrice == 0)) {
double skuDetailPrice = skuDetail.getPrice();
double newPrice = moveService.processConditionPrice(JSON.toJavaObject(priceCondition, MoveShopSettingBO.class), skuDetailPrice);
sourceMinPrice = ((sourceMinPrice < skuDetailPrice) && (sourceMinPrice > 0)) ? sourceMinPrice : skuDetailPrice;
if (StrUtil.isNotBlank(isSkuMinPrice)) {
if (addSkuPriceSource.equals(MoveConst.skuMinPriceSkuPriceSourceFromSource)) {
newPrice = skuDetailPrice;
}
MoveShopSettingBO moveShopSettingBO = new MoveShopSettingBO();
moveShopSettingBO.setPricePercent(priceCondition.getBigDecimal("addSkuMinPricePricePercent"));
moveShopSettingBO.setPriceAdd(priceCondition.getBigDecimal("addSkuMinPricePriceAdd"));
moveShopSettingBO.setPriceSub(priceCondition.getBigDecimal("addSkuMinPricePriceSub"));
moveShopSettingBO.setPriceTail(priceCondition.getInteger("addSkuMinPricePriceTail"));
moveShopSettingBO.setPriceDecimal(priceCondition.getString("addSkuMinPricePriceDecimal"));
moveShopSettingBO.setPriceDecimalDiyValue(priceCondition.getString("addSkuMinPricePriceDecimalDiyValue"));
newPrice = moveService.processConditionPrice(moveShopSettingBO, newPrice);
}
skuDetail.setPrice(newPrice);
maxPrice = Math.max(maxPrice, newPrice);
minPrice = ((minPrice < newPrice) && (minPrice > 0)) ? minPrice : newPrice;
}
}
if (isFastMode != 0 && (ObjectUtil.isNull(hasImportPrice) || hasImportPrice != 0) && (priceCondition.containsKey("skuMinPriceType") && Objects.equals(priceCondition.getInteger("skuMinPriceType"), MoveConst.skuMinPriceTypeUpdate))) {
for (Map.Entry<String, SkuDetailBO> entry : skuList.entrySet()) {
String skuPropStr = entry.getKey();
SkuDetailBO skuDetail = entry.getValue();
if (skuDetail.getPrice() == minPrice) {
if (Objects.equals(priceCondition.getInteger("updateSkuPriceSource"), MoveConst.skuMinPriceSkuPriceSourceFromSource)) {
minPrice = sourceMinPrice;
}
MoveShopSettingBO moveShopSettingBO = new MoveShopSettingBO();
moveShopSettingBO.setPricePercent(priceCondition.getBigDecimal("addSkuMinPricePricePercent"));
moveShopSettingBO.setPriceAdd(priceCondition.getBigDecimal("addSkuMinPricePriceAdd"));
moveShopSettingBO.setPriceSub(priceCondition.getBigDecimal("addSkuMinPricePriceSub"));
moveShopSettingBO.setPriceTail(priceCondition.getInteger("addSkuMinPricePriceTail"));
moveShopSettingBO.setPriceDecimal(priceCondition.getString("addSkuMinPricePriceDecimal"));
moveShopSettingBO.setPriceDecimalDiyValue(priceCondition.getString("addSkuMinPricePriceDecimalDiyValue"));
double newPrice = moveService.processConditionPrice(moveShopSettingBO, minPrice);
if (priceCondition.containsKey("updateSkuMinPriceQuantity") && priceCondition.getInteger("updateSkuMinPriceQuantity") > 0) {
skuDetail.setStockNum(priceCondition.getInteger("updateSkuMinPriceQuantity"));
}
skuDetail.setPrice(newPrice);
StrObjMap temp = new StrObjMap();
temp.put("skuId", skuDetail.getSkuId());
temp.put("skuPropStr", skuPropStr);
skuDetail.setUpdateSkuMinPriceInfo(temp);
break;
}
}
}
skuList = processSourcePostFeePrice(isFastMode, sourcePostFeePriceAddValue, skuList, cnaliDsDetailId, moveBaseData);
return skuList;
}
private Map<String, SkuDetailBO> processSourcePostFeePrice(int isFastMode, double sourcePostFeePriceAddValue, Map<String, SkuDetailBO> skuList, String cnaliDsDetailId, JSONObject moveBaseData) {
if (isFastMode != 0) {
return skuList;
}
if (sourcePostFeePriceAddValue <= 0) {
return skuList;
}
if (!(Boolean) moveBaseData.get("hasPostFee") && StrUtil.isBlank(cnaliDsDetailId)) {
return skuList;
}
for (Map.Entry<String, SkuDetailBO> entry : skuList.entrySet()) {
double price = entry.getValue().getPrice();
entry.getValue().setPrice(price + sourcePostFeePriceAddValue);
}
return skuList;
}
public Map<String, SkuDetailBO> buildSkuListAndSkuImages(JSONObject skuMap, JSONObject colorMap, JSONObject sizeMap) {
double defaultPrice = getSkuDefaultPrice(skuMap);
Map<String, SkuDetailBO> skuList = new HashMap<>();

Loading…
Cancel
Save