...
|
...
|
@@ -56,6 +56,7 @@ import com.yohobuy.ufo.model.common.PageResponseBO; |
|
|
import com.yohobuy.ufo.model.order.req.BatchImportPrdReq;
|
|
|
import com.yohobuy.ufo.model.order.req.SellerReq;
|
|
|
import com.yohobuy.ufo.model.order.vo.AddressInfo;
|
|
|
import com.yohobuy.ufo.model.request.product.ProductImportTranItemBo;
|
|
|
import com.yohobuy.ufo.model.request.product.ProductRequestBatchBo;
|
|
|
import com.yohobuy.ufo.model.request.product.ProductRequestBo;
|
|
|
import com.yohobuy.ufo.model.resp.product.ProductEditResponceBo;
|
...
|
...
|
@@ -176,23 +177,55 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw |
|
|
String limit = limitSaleInfo.get(i);
|
|
|
String[] array0 = limit.split(" ");
|
|
|
Integer uid = new Integer(array0[0]);
|
|
|
BigDecimal percent = new BigDecimal(array0[1]);
|
|
|
BigDecimal percent = null;
|
|
|
if (array0.length == 2 && StringUtils.isNotBlank(array0[1])) {
|
|
|
percent = new BigDecimal(array0[1]);
|
|
|
}
|
|
|
map.put(uid, percent);
|
|
|
}
|
|
|
}
|
|
|
List<ProductLimitSale> exist = productLimitSaleMapper.selectByProductId(productId);
|
|
|
Map<Integer, BigDecimal> existMap = CollectionUtil.extractMap(exist, ProductLimitSale::getUid, ProductLimitSale::getProfitRate);
|
|
|
|
|
|
LOGGER.info("商品:{} 限制出售配置更新前为:{}", productId, exist);
|
|
|
LOGGER.info("商品:{} 限制出售配置更新参数为:{}", productId, map);
|
|
|
|
|
|
boolean hasDiff = false;
|
|
|
List<Integer> updateOrInsertOrRemove = new ArrayList<>();
|
|
|
for (ProductLimitSale s : exist) {
|
|
|
BigDecimal percent = map.get(s.getUid());
|
|
|
if (percent == null || percent.compareTo(s.getProfitRate()) != 0) {
|
|
|
if (!map.containsKey(s.getUid())) {
|
|
|
hasDiff = true;
|
|
|
break;
|
|
|
updateOrInsertOrRemove.add(s.getUid());
|
|
|
} else {
|
|
|
BigDecimal percent = map.get(s.getUid());
|
|
|
if (percent == null && s.getProfitRate() == null) {
|
|
|
continue;
|
|
|
}
|
|
|
if (percent != null && s.getProfitRate() != null) {
|
|
|
if (percent.compareTo(s.getProfitRate()) != 0) {
|
|
|
hasDiff = true;
|
|
|
updateOrInsertOrRemove.add(s.getUid());
|
|
|
}
|
|
|
} else {
|
|
|
hasDiff = true;
|
|
|
updateOrInsertOrRemove.add(s.getUid());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// add
|
|
|
for (Integer uidOld : map.keySet()) {
|
|
|
if(!existMap.containsKey(uidOld)) {
|
|
|
updateOrInsertOrRemove.add(uidOld);
|
|
|
}
|
|
|
}
|
|
|
if(!updateOrInsertOrRemove.isEmpty()) {
|
|
|
if(map.isEmpty() || exist.isEmpty()) {
|
|
|
checkStorage(productId, null);
|
|
|
} else {
|
|
|
checkStorage(productId, updateOrInsertOrRemove);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 包含
|
|
|
if (!hasDiff) {
|
|
|
for (ProductLimitSale s : exist) {
|
...
|
...
|
@@ -216,6 +249,17 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw |
|
|
});
|
|
|
}
|
|
|
|
|
|
private void checkStorage(Integer productId, List<Integer> updateOrInsertOrRemove) {
|
|
|
Integer uid = storagePriceMapper.selectFirstUidByProductIdAndUidList(productId, updateOrInsertOrRemove);
|
|
|
if (uid != null) {
|
|
|
if (updateOrInsertOrRemove == null) {
|
|
|
throw new CommonException(400, "该商品存在出售中的SKUP,请先下架所有SKUP后,再进行变更");
|
|
|
} else {
|
|
|
throw new CommonException(400, "UID:" + uid + "存在出售中的SKUP,请先下架所有SKUP后,再进行变更");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private List<GoodsImages> getGoodsImagesFromBo(ProductRequestBo bo) {
|
|
|
if (CollectionUtils.isEmpty(bo.getImageUrlList())) {
|
|
|
return null;
|
...
|
...
|
@@ -337,15 +381,19 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw |
|
|
Set<Integer> uids = new HashSet<>();
|
|
|
for (String s : limitInfo) {
|
|
|
String[] array = s.split(" ");
|
|
|
if (array.length != 2) {
|
|
|
if (array.length > 2) {
|
|
|
throw new CommonException(400, "请输入正确的可售用户信息!");
|
|
|
}
|
|
|
try {
|
|
|
Integer uid = new Integer(array[0]);
|
|
|
BigDecimal percent = new BigDecimal(array[1]);
|
|
|
if (uid < 1 || percent.compareTo(BigDecimal.ZERO) < 0
|
|
|
|| percent.compareTo(new BigDecimal("100")) > 0 || uids.contains(uid)) {
|
|
|
throw new CommonException(400, "请输入正确的可售用户信息!");
|
|
|
if (uid < 1 || uids.contains(uid)) {
|
|
|
throw new CommonException(400, "用户id错误或者有重复行!");
|
|
|
}
|
|
|
if (array.length == 2 && StringUtils.isNotBlank(array[1])) {
|
|
|
BigDecimal percent = new BigDecimal(array[1]);
|
|
|
if (percent.compareTo(BigDecimal.ZERO) < 0 || percent.compareTo(new BigDecimal("100")) > 0) {
|
|
|
throw new CommonException(400, "请输入(uid:" + uid + ")正确的百分比信息!");
|
|
|
}
|
|
|
}
|
|
|
uids.add(uid);
|
|
|
} catch (NumberFormatException e) {
|
...
|
...
|
@@ -967,8 +1015,7 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw |
|
|
BigDecimal rate = userHasPermissionMap.get(productId);
|
|
|
if (rate == null) {
|
|
|
sb.append(",").append(productId);
|
|
|
}
|
|
|
if (rate.compareTo(BigDecimal.ZERO) < 0 || rate.compareTo(new BigDecimal("100")) > 0) {
|
|
|
} else if (rate.compareTo(BigDecimal.ZERO) < 0 || rate.compareTo(new BigDecimal("100")) > 0) {
|
|
|
LOGGER.error("用户" + uid + ",商品" + productId + "的rate配置有误:" + rate);
|
|
|
throw new PlatformException("用户" + uid + ",商品" + productId + "的rate配置有误:" + rate, 400);
|
|
|
}
|
...
|
...
|
@@ -1044,10 +1091,19 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw |
|
|
for (int i = 0; i < batchLists.size(); i++) {
|
|
|
LOGGER.info("一共{}行,每批次{}行,一共{}批,处理批次{}...", items.size(), batchNum, batchLists.size(), i + 1);
|
|
|
List<ProductImportTranItem> batch = batchLists.get(i);
|
|
|
BatchImportPrdReq<ProductImportTranItem> batchReq = new BatchImportPrdReq<>();
|
|
|
BatchImportPrdReq<ProductImportTranItemBo> batchReq = new BatchImportPrdReq<>();
|
|
|
batchReq.setHiddenBackAddress(addressHidden);
|
|
|
batchReq.setNoHiddenBackAddress(address);
|
|
|
batchReq.setProductList(batch);
|
|
|
|
|
|
List<ProductImportTranItemBo> batchBo = new ArrayList<>();
|
|
|
for(ProductImportTranItem it : batch) {
|
|
|
ProductImportTranItemBo bo = new ProductImportTranItemBo();
|
|
|
BeanUtils.copyProperties(it, bo);
|
|
|
bo.setGoodsPaymentRate(it.getSellerServiceFeeRate());
|
|
|
batchBo.add(bo);
|
|
|
}
|
|
|
|
|
|
batchReq.setProductList(batchBo);
|
|
|
batchReq.setTaskId(tran.getId());
|
|
|
batch.forEach(b -> b.setTranId(tran.getId()));
|
|
|
|
...
|
...
|
|