|
|
@ -19,6 +19,7 @@ import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.doudian.open.api.material_batchUploadImageSync.MaterialBatchUploadImageSyncRequest;
|
|
|
|
import com.doudian.open.api.material_batchUploadImageSync.MaterialBatchUploadImageSyncRequest;
|
|
|
|
import com.doudian.open.api.material_batchUploadImageSync.MaterialBatchUploadImageSyncResponse;
|
|
|
|
import com.doudian.open.api.material_batchUploadImageSync.MaterialBatchUploadImageSyncResponse;
|
|
|
@ -42,6 +43,7 @@ import com.ms.api.common.StrStrMap;
|
|
|
|
import com.ms.api.common.TaskBaseService;
|
|
|
|
import com.ms.api.common.TaskBaseService;
|
|
|
|
import com.ms.api.consts.CommonConst;
|
|
|
|
import com.ms.api.consts.CommonConst;
|
|
|
|
import com.ms.api.consts.MaterialConst;
|
|
|
|
import com.ms.api.consts.MaterialConst;
|
|
|
|
|
|
|
|
import com.ms.api.consts.MoveConst;
|
|
|
|
import com.ms.api.consts.RedisKeyConst;
|
|
|
|
import com.ms.api.consts.RedisKeyConst;
|
|
|
|
import com.ms.api.consts.StatusConst;
|
|
|
|
import com.ms.api.consts.StatusConst;
|
|
|
|
import com.ms.api.paas.RedisService;
|
|
|
|
import com.ms.api.paas.RedisService;
|
|
|
@ -575,6 +577,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
productDetailBase = processSpuPriceMaybeOutRange(productDetailBase);
|
|
|
|
productDetailBase = processSpuPriceMaybeOutRange(productDetailBase);
|
|
|
|
productDetailBase = processSpuMarketPriceMaybeOutRange(productDetailBase, condition);
|
|
|
|
productDetailBase = processSpuMarketPriceMaybeOutRange(productDetailBase, condition);
|
|
|
|
|
|
|
|
moveBaseData.put("publishTips", publishTips);
|
|
|
|
Ret mRet = CommonTool.successResult();
|
|
|
|
Ret mRet = CommonTool.successResult();
|
|
|
|
StrObjMap mData = new StrObjMap();
|
|
|
|
StrObjMap mData = new StrObjMap();
|
|
|
|
mData.put("productDetailBase", productDetailBase);
|
|
|
|
mData.put("productDetailBase", productDetailBase);
|
|
|
@ -585,23 +588,109 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private JSONObject processSpuMarketPriceMaybeOutRange(JSONObject productDetailBase, MoveShopSettingBO condition) {
|
|
|
|
private JSONObject processSpuMarketPriceMaybeOutRange(JSONObject productDetailBase, MoveShopSettingBO condition) {
|
|
|
|
return null;
|
|
|
|
if (condition.getIsFastMode() != 0 && (condition.getBaseMarketPriceType() == MoveConst.baseMarketPriceTypeDdPrice)) {
|
|
|
|
|
|
|
|
// TODO: 2023/9/12 condition 缺少太多参数了 转成
|
|
|
|
|
|
|
|
productDetailBase.put("marketPrice", processConditionMarketPrice((JSONObject) JSONObject.toJSON(condition), productDetailBase.getDouble("price") / 100, productDetailBase.getDouble("marketPrice") / 100));
|
|
|
|
|
|
|
|
productDetailBase.put("marketPrice", productDetailBase.getDouble("marketPrice") * 100);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONArray specPrices = productDetailBase.getJSONArray("specPrices");
|
|
|
|
|
|
|
|
double[] priceList = new double[specPrices.size()];
|
|
|
|
|
|
|
|
double maxSkuPrice = Double.NEGATIVE_INFINITY;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < specPrices.size(); i++) {
|
|
|
|
|
|
|
|
JSONObject specPrice = specPrices.getJSONObject(i);
|
|
|
|
|
|
|
|
double price = specPrice.getDouble("price");
|
|
|
|
|
|
|
|
priceList[i] = price;
|
|
|
|
|
|
|
|
maxSkuPrice = Math.max(maxSkuPrice, price);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (productDetailBase.getDouble("marketPrice") < maxSkuPrice) {
|
|
|
|
|
|
|
|
productDetailBase.put("marketPrice", maxSkuPrice);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double maxMarketPrice = MoveConst.maxMarketPrice * 100;
|
|
|
|
|
|
|
|
if (productDetailBase.getDouble("marketPrice") > maxMarketPrice) {
|
|
|
|
|
|
|
|
productDetailBase.put("marketPrice", maxMarketPrice);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return productDetailBase;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Object processConditionMarketPrice(JSONObject condition, double price, double marketPrice) {
|
|
|
|
|
|
|
|
if (condition.getIntValue("baseMarketPriceType") == (MoveConst.baseMarketPriceTypeDdPrice)) {
|
|
|
|
|
|
|
|
marketPrice = price;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String[] sourcePriceDecimalDigits = String.valueOf(marketPrice).replaceAll("0+$", "").split("\\.");
|
|
|
|
|
|
|
|
if (condition.containsKey("marketPricePercent")) {
|
|
|
|
|
|
|
|
marketPrice = CommonTool.numFormat((condition.getDouble("marketPricePercent") * marketPrice) / 100,2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (condition.containsKey("marketPriceAdd")) {
|
|
|
|
|
|
|
|
marketPrice = CommonTool.numFormat(condition.getDouble("marketPriceAdd") + marketPrice,2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (condition.containsKey("marketPriceSub") && marketPrice > condition.getDouble("marketPriceSub")) {
|
|
|
|
|
|
|
|
marketPrice = CommonTool.numFormat(marketPrice - condition.getDouble("marketPriceSub"),2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (condition.containsKey("marketPriceTail")) {
|
|
|
|
|
|
|
|
marketPrice = ((int) (marketPrice / 10) * 10) + condition.getIntValue("marketPriceTail");
|
|
|
|
|
|
|
|
marketPrice = CommonTool.numFormat(marketPrice,2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!condition.containsKey("marketPriceTail")) {
|
|
|
|
|
|
|
|
if (Objects.equals(condition.getString("marketPriceDecimal"), MoveConst.priceDecimalTypeClearFenJiao)) {
|
|
|
|
|
|
|
|
marketPrice = CommonTool.numFormat(marketPrice, 0);
|
|
|
|
|
|
|
|
} else if (Objects.equals(condition.getString("marketPriceDecimal"), MoveConst.priceDecimalTypeClearFen)) {
|
|
|
|
|
|
|
|
marketPrice = CommonTool.numFormat(marketPrice, 1);
|
|
|
|
|
|
|
|
} else if (Objects.equals(condition.getString("marketPriceDecimal"), MoveConst.priceDecimalTypeKeepSource)) {
|
|
|
|
|
|
|
|
if (sourcePriceDecimalDigits[1].isEmpty()) {
|
|
|
|
|
|
|
|
marketPrice = CommonTool.numFormat(marketPrice, 0);
|
|
|
|
|
|
|
|
} else if (sourcePriceDecimalDigits[1].length() == 2) {
|
|
|
|
|
|
|
|
marketPrice = CommonTool.numFormat(marketPrice, 2);
|
|
|
|
|
|
|
|
} else if (sourcePriceDecimalDigits[1].length() == 1) {
|
|
|
|
|
|
|
|
marketPrice = CommonTool.numFormat(marketPrice, 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (Objects.equals(condition.getString("marketPriceDecimal"), MoveConst.priceDecimalTypeDiy)) {
|
|
|
|
|
|
|
|
marketPrice = processPriceDecimalDiyValue(marketPrice, condition.getDouble("marketPriceDecimalDiyValue"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (marketPrice < price) {
|
|
|
|
|
|
|
|
marketPrice = price;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return marketPrice;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private double processPriceDecimalDiyValue(double price, Double priceDecimalDiyValue) {
|
|
|
|
|
|
|
|
String strPriceDecimalDiyValue = String.valueOf(priceDecimalDiyValue.intValue());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (strPriceDecimalDiyValue.length() > 2) {
|
|
|
|
|
|
|
|
strPriceDecimalDiyValue = strPriceDecimalDiyValue.substring(0, 2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return CommonTool.numFormat(price,0) + Double.parseDouble("." + strPriceDecimalDiyValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private JSONObject processSpuPriceMaybeOutRange(JSONObject productDetailBase) {
|
|
|
|
private JSONObject processSpuPriceMaybeOutRange(JSONObject productDetailBase) {
|
|
|
|
// JSONArray specPrices = productDetailBase.getJSONArray("specPrices");
|
|
|
|
JSONArray specPrices = productDetailBase.getJSONArray("specPrices");
|
|
|
|
//
|
|
|
|
|
|
|
|
// double minSkuPrice = specPrices.stream().map(x->x.);
|
|
|
|
double minSkuPrice = Double.POSITIVE_INFINITY;
|
|
|
|
// double maxSkuPrice = Double.NEGATIVE_INFINITY;
|
|
|
|
double maxSkuPrice = Double.NEGATIVE_INFINITY;
|
|
|
|
//
|
|
|
|
|
|
|
|
// for (int i = 0; i < specPrices.length(); i++) {
|
|
|
|
for (int i = 0; i < specPrices.size(); i++) {
|
|
|
|
// JSONObject specPrice = specPrices.getJSONObject(i);
|
|
|
|
JSONObject specPrice = specPrices.getJSONObject(i);
|
|
|
|
// double price = specPrice.getDouble("price");
|
|
|
|
double price = specPrice.getDouble("price");
|
|
|
|
// minSkuPrice = Math.min(minSkuPrice, price);
|
|
|
|
minSkuPrice = Math.min(minSkuPrice, price);
|
|
|
|
// maxSkuPrice = Math.max(maxSkuPrice, price);
|
|
|
|
maxSkuPrice = Math.max(maxSkuPrice, price);
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
if (minSkuPrice <= 0) {
|
|
|
|
|
|
|
|
return productDetailBase;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double productPrice = productDetailBase.getDouble("price");
|
|
|
|
|
|
|
|
if (productPrice < minSkuPrice || productPrice > maxSkuPrice) {
|
|
|
|
|
|
|
|
productDetailBase.put("price", minSkuPrice);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return productDetailBase;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private StrObjMap checkHasRepeatSpec(StrObjMap colorSpecArrCalc, StrObjMap sizeSpecArrCalc) {
|
|
|
|
private StrObjMap checkHasRepeatSpec(StrObjMap colorSpecArrCalc, StrObjMap sizeSpecArrCalc) {
|
|
|
|