|
|
@@ -238,6 +238,9 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
@Autowired
|
|
|
private ProductAttachService productAttachService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private V_ProductPrivateService v_productPrivateService;
|
|
|
+
|
|
|
private final Logger logger = Logger.getLogger(getClass());
|
|
|
|
|
|
@Autowired
|
|
|
@@ -265,80 +268,32 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
if (goods == null) {
|
|
|
throw new IllegalOperatorException("商品信息Goods不能为空");
|
|
|
}
|
|
|
- if (goods.getTag() == null) {
|
|
|
- throw new IllegalOperatorException("自定义标签信息为空");
|
|
|
- }
|
|
|
- if (goods.getTag().length() > 20) {
|
|
|
- throw new IllegalOperatorException("自定义标签的信息超过约定的20个字符");
|
|
|
- }
|
|
|
-// if(!PatternUtil.matchChineseAndEnglish(goods.getTag())) {
|
|
|
-// throw new IllegalOperatorException("自定义标签的信息只能包含中文和英文");
|
|
|
-// }
|
|
|
- /*if (goods.getPackaging() == null) {
|
|
|
- throw new IllegalOperatorException("包装信息为空");
|
|
|
- }*/
|
|
|
-// if (goods.getPackaging().length() > 10) {
|
|
|
-// throw new IllegalOperatorException("包装信息操作约定的10个字符");
|
|
|
-// }
|
|
|
-// if (!PatternUtil.matchChineseAndEnglish(goods.getPackaging())) {
|
|
|
-// throw new IllegalOperatorException("包装信息只能包含中文和英文");
|
|
|
-// }
|
|
|
if (!StringUtils.isEmpty(goods.getSpec())) {
|
|
|
String spec = com.uas.platform.b2c.fa.payment.utils.StringUtils.cutOutStringIgnoreEncode(goods.getSpec().toString(), UploadConstant.SPEC_MAX_BYTE);
|
|
|
goods.setSpec(spec);
|
|
|
}
|
|
|
- if (StringUtils.isEmpty(goods.getProduceDate())) {
|
|
|
- throw new IllegalOperatorException("型号" + goods.getCode()+"品牌" + goods.getBrandNameEn() +"的产品生产日期为空");
|
|
|
- } else {
|
|
|
- if (goods.getProduceDate().length() > 12) {
|
|
|
- throw new IllegalOperatorException("产品生产日期不能超过12个字符");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (goods.getOriginal() == null) {
|
|
|
- throw new IllegalOperatorException("必须选择库存类型");
|
|
|
- }
|
|
|
if (goods.getCurrencyName() == null) {
|
|
|
throw new IllegalOperatorException("必须选择一种币别");
|
|
|
}
|
|
|
- if ("RMB".equals(goods.getCurrencyName()) && goods.getTax() != (short) 17) {
|
|
|
- goods.setTax((short) 17);
|
|
|
- }
|
|
|
- if (!"RMB".equals(goods.getCurrencyName())) {
|
|
|
- goods.setTax((short) 0);
|
|
|
- }
|
|
|
- if (goods.getReserve() < 0 || goods.getReserve() > 999999999) {
|
|
|
+ if (NumberUtil.compare(goods.getReserve(), DoubleConstant.zero) < 0 || NumberUtil.compare(goods.getReserve(), DoubleConstant.maxReserve) > 0) {
|
|
|
throw new IllegalOperatorException("库存数量必须在1~99999999之间");
|
|
|
}
|
|
|
- if (goods.getMinPackQty() < 1 || goods.getMinPackQty() > 999999) {
|
|
|
+ if ((NumberUtil.compare(goods.getMinPackQty(), DoubleConstant.minReserve) < 0) || NumberUtil.compare(goods.getMinPackQty(), DoubleConstant.maxMinPackageQty) > 0) {
|
|
|
throw new IllegalOperatorException("最小包装量必须在1~999999之间");
|
|
|
}
|
|
|
-// if (goods.getMinBuyQty() < 1 || (NumberUtil.compare(goods.getMinBuyQty(), goods.getReserve()) > 0)) {
|
|
|
-// throw new IllegalOperatorException("最小起订量必须在1~" + goods.getReserve() + "之间");
|
|
|
-// }
|
|
|
if (!goods.getBreakUp()) {
|
|
|
- if (goods.getMinBuyQty() % goods.getMinPackQty() != 0) {
|
|
|
- throw new IllegalOperatorException("最小起订量必须为最小包装量的整数倍");
|
|
|
+ if (goods.getMinPackQty() != null) {
|
|
|
+ if (goods.getMinBuyQty() % goods.getMinPackQty() != 0) {
|
|
|
+ throw new IllegalOperatorException("最小起订量必须为最小包装量的整数倍");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 验证交货周期信息
|
|
|
- validDeliveryTime(goods);
|
|
|
-
|
|
|
//验证分段价格的有效性。
|
|
|
ResultMap resultMap = validFragmentPrice(goods);
|
|
|
if (resultMap.getCode() != CodeType.OK.code()) {
|
|
|
return resultMap;
|
|
|
}
|
|
|
-
|
|
|
- // 检验分段价格是否有效
|
|
|
- for (GoodsQtyPrice price : goods.getPrices()) {
|
|
|
- if (price == null || (price.getRMBPrice() == null && price.getUSDPrice() == null)) {
|
|
|
- throw new IllegalOperatorException(
|
|
|
- "[com.uas.platform.b2c.prod.commodity.service.impl.GoodsServiceImpl.checkGoods] "
|
|
|
- + "分段价格中人民币价格和美元价格不能同时为空");
|
|
|
- }
|
|
|
- }
|
|
|
if (goods.getProductid() == null) {
|
|
|
throw new IllegalOperatorException("型号" + goods.getCode() + "品牌" + goods.getBrandNameEn() +"的物料库信息丢失");
|
|
|
}
|
|
|
@@ -367,12 +322,12 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
if (NumberUtil.compare(end, price.getStart()) > -1) {
|
|
|
throw new IllegalOperatorException("分段价格中存在前一个分段结束值大于等于分段起始值");
|
|
|
}
|
|
|
- if (currencyName.contains("USD")) {
|
|
|
+ if (currencyName.contains(StringConstant.USD)) {
|
|
|
if (price.getUSDPrice() == null || price.getUSDPrice() < 0) {
|
|
|
throw new IllegalOperatorException("库存的币别信息包含美金,而分段价格中的美金价格不存在或小于0");
|
|
|
}
|
|
|
}
|
|
|
- if (currencyName.contains("RMB")) {
|
|
|
+ if (currencyName.contains(StringConstant.RMB)) {
|
|
|
if (price.getRMBPrice() == null || price.getRMBPrice() < 0) {
|
|
|
throw new IllegalOperatorException("库存的币别信息包含人民币,而分段价格中的人民币价格不存在或小于0");
|
|
|
}
|
|
|
@@ -589,8 +544,6 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
}
|
|
|
goods.setCreatedDate(new Date());
|
|
|
goods.setUpdateDate(goods.getCreatedDate());
|
|
|
- goods.setReserve(goods);
|
|
|
- goods.setPerQty();
|
|
|
goods.setEnUU(SystemSession.getUser().getEnterprise().getUu());
|
|
|
goods.setEnterpriseName(SystemSession.getUser().getEnterprise().getEnName());
|
|
|
if (StringUtils.isEmpty(goods.getPublisherName())) {
|
|
|
@@ -598,20 +551,63 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goods.setPublisherUU(SystemSession.getUser().getUserUU());
|
|
|
goods.setPublishPhone(SystemSession.getUser().getUserTel());
|
|
|
}
|
|
|
- if (NumberUtil.compare(goods.getReserve(), goods.getMinBuyQty()) == -1) {
|
|
|
- goods.setStatus(Status.UNAVAILABLE.value());
|
|
|
+ if (goods.getBreakUp() == null) {
|
|
|
+ goods.setBreakUp(Boolean.TRUE);
|
|
|
+ }
|
|
|
+ if (goods.getAutoPublish() == null) {
|
|
|
+ goods.setAutoPublish(Boolean.TRUE);
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(goods.getUnit())) {
|
|
|
+ goods.setUnit(StringConstant.UNIT);
|
|
|
+ }
|
|
|
+ if (goods.getReturnInWeek() == null) {
|
|
|
+ goods.setReturnInWeek(ShortConstant.NO_SHORT);
|
|
|
+ }
|
|
|
+ if (goods.getProductid() == null) {
|
|
|
+ bindGoodsToProduct(goods);
|
|
|
+ }
|
|
|
+ Product product = productDao.findOne(goods.getProductid());
|
|
|
+ if (product == null) {
|
|
|
+ bindGoodsToProduct(goods);
|
|
|
+ product = productDao.findOne(goods.getProductid());
|
|
|
+ }
|
|
|
+
|
|
|
+ //如果信息未被填充
|
|
|
+ if (StringUtils.isEmpty(goods.getCode())) {
|
|
|
+ goods.setProductInfo(product);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(goods.getImg())) {
|
|
|
+ String cmpUuId = product.getCmpUuId();
|
|
|
+ if (!StringUtils.isEmpty(cmpUuId)) {
|
|
|
+ Component component = componentDao.findByUuid(cmpUuId);
|
|
|
+ if (component != null) {
|
|
|
+ goods.setImg(component.getImg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ goods.setReserve(goods);
|
|
|
+ if (NumberUtil.compare(goods.getMinPackQty(), DoubleConstant.zero) < 1) {
|
|
|
+ goods.setMinPackQty(DoubleConstant.minReserve);
|
|
|
+ goods.setMinBuyQty();
|
|
|
+ }
|
|
|
+ goods.setPerQty();
|
|
|
+ goods.setStatus();
|
|
|
+ if (goods.getAutoPublish()) {
|
|
|
+ if (NumberUtil.compare(goods.getReserve(), goods.getMinBuyQty()) == -1) {
|
|
|
+ goods.setStatus(Status.UNAVAILABLE.value());
|
|
|
+ } else {
|
|
|
+ goods.setStatus(Status.AVAILABLE.value());
|
|
|
+ }
|
|
|
} else {
|
|
|
- goods.setStatus(Status.AVAILABLE.value());
|
|
|
+ goods.setStatus(Status.NO_SHELVE.value());
|
|
|
}
|
|
|
// 设置货到香港,货到大陆的延长时间
|
|
|
- setB2CDelayTime(goods);
|
|
|
+ if (goods.getMinDelivery() != null || goods.getMaxDelivery() != null) {
|
|
|
+ setB2CDelayTime(goods);
|
|
|
+ }
|
|
|
// 设置默认税率
|
|
|
goods.setTaxRate();
|
|
|
-
|
|
|
- if (goods.getReturnInWeek() == null) {
|
|
|
- // 若无设置,默认不支持7天无理由退货
|
|
|
- goods.setReturnInWeek((short) 0);
|
|
|
- }
|
|
|
// 若B2C上架的商品必须有发布人姓名和发布人联系电话
|
|
|
if (goods.getSourceId() == null) {
|
|
|
if (goods.getPublisherName() == null || goods.getPublishPhone() == null) {
|
|
|
@@ -626,77 +622,14 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goods.setMaxPriceRMB(GoodsUtil.getMaxPriceRMB(goods.getPrices()));
|
|
|
goods.setMinPriceUSD(GoodsUtil.getMinPriceUSD(goods.getPrices()));
|
|
|
goods.setMaxPriceUSD(GoodsUtil.getMaxPriceUSD(goods.getPrices()));
|
|
|
- if (StringUtils.isEmpty(goods.getUnit())) {
|
|
|
- goods.setUnit(StringConstant.UNIT);
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(goods.getImg())) {
|
|
|
- Long goodsProductid = goods.getProductid();
|
|
|
- if (goodsProductid != null) {
|
|
|
- Product product = productDao.findOne(goodsProductid);
|
|
|
- if (product != null) {
|
|
|
- if (StringUtils.isEmpty(product.getCmpImg())) {
|
|
|
- String cmpUuId = product.getCmpUuId();
|
|
|
- if (!StringUtils.isEmpty(cmpUuId)) {
|
|
|
- Component component = componentDao.findByUuid(cmpUuId);
|
|
|
- if (component != null) {
|
|
|
- goods.setImg(component.getImg());
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- goods.setImg(product.getCmpImg());
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
if (!StringUtils.isEmpty(goods.getStoreid())) {
|
|
|
StoreIn storeIn = storeInDao.findByUuid(goods.getStoreid());
|
|
|
- if (storeIn.getStatus() == StoreStatus.OPENED) {
|
|
|
- goods.setStoreName(storeIn.getStoreName());
|
|
|
- } else {
|
|
|
+ if (storeIn == null || storeIn.getStatus() != StoreStatus.OPENED) {
|
|
|
throw new IllegalOperatorException("该公司还为开店铺,不能选择自营销售");
|
|
|
- }
|
|
|
- }
|
|
|
- if (goods.getProductid() != null) {
|
|
|
- Product product = productDao.findOne(goods.getProductid());
|
|
|
- if (product == null) {
|
|
|
- throw new IllegalOperatorException("器件" + goods.getCode() + "品牌" + goods.getBrandNameEn() + "关联的物料库信息丢失");
|
|
|
- }
|
|
|
- List<Goods> goodses = goodsDao.findRepeatGoodsInProductId(goods.getProductid(), goods.getProduceDate(), goods.getPackaging(), goods.getMinPackQty(), goods.getMinBuyQty(), goods.getMaxDelivery(), goods.getMinDelivery(), goods.getUnit());
|
|
|
- if (!CollectionUtils.isEmpty(goodses)) {
|
|
|
- for (Goods goods1 : goodses) {
|
|
|
- if (!goods1.getId().equals(goods.getId())
|
|
|
- && GoodsUtil.compareWithQtyPrice(goods1.getPrices(), goods.getPrices(), goods.getCurrencyName())) {
|
|
|
- throw new IllegalOperatorException("该物料已存在(包装、日期、最小包装量、最小起订量、交期、单位、价格)相同的信息");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //判断自定义标签是否重复
|
|
|
- if (StringUtils.isEmpty(goods.getTag())) {
|
|
|
- throw new IllegalArgumentException("自定义标签信息为空");
|
|
|
- }
|
|
|
- if (goods.getProductid() == null) {
|
|
|
- throw new IllegalOperatorException("传入的产品信息缺失,请重新操作");
|
|
|
- }
|
|
|
- List<Goods> goodsList = goodsDao.findGoodsByProductidAndTag(goods.getProductid(), goods.getTag());
|
|
|
- if ((goods.getId() == null) && (goodsList.size() > 0)) {
|
|
|
- throw new IllegalOperatorException("该产品下已存在相同的自定义标签");
|
|
|
} else {
|
|
|
- for (Goods goods1 : goodsList) {
|
|
|
- if (goods.getTag().equals(goods1.getTag())
|
|
|
- && (goods1.getId().longValue() != goods.getId().longValue())) {
|
|
|
- throw new IllegalOperatorException("该产品下已存在相同的自定义标签");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //如果信息未被填充
|
|
|
- if (StringUtils.isEmpty(goods.getCode())) {
|
|
|
- goods.setProductInfo(product);
|
|
|
+ goods.setStoreName(storeIn.getStoreName());
|
|
|
}
|
|
|
- } else {
|
|
|
- throw new IllegalOperatorException("器件" + goods.getCode() + "品牌" + goods.getBrandNameEn() + "关联的物料库信息丢失");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -753,7 +686,6 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
if (resultMap.getCode() != CodeType.OK.code()) {
|
|
|
return null;
|
|
|
}
|
|
|
-// updateGoodTransactional(goods);
|
|
|
GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(), false);
|
|
|
//仅保存商品信息,不上架
|
|
|
if (goods.getId() == null || goods.getSold() == null) {
|
|
|
@@ -761,11 +693,6 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
}
|
|
|
Goods backGoods = goodsDao.save(goods);
|
|
|
goodsHistoryDao.save(goodsHistory);
|
|
|
- // TODO huxz 添加或修改商品价格信息
|
|
|
- if (goods.getUuid() != null) {
|
|
|
-// saveOrUpdatePriceInfos(goods, deviceInfo);
|
|
|
- updateComponentTradeInfos(goods.getUuid());
|
|
|
- }
|
|
|
return backGoods;
|
|
|
}
|
|
|
|
|
|
@@ -985,61 +912,61 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
|
|
|
@Override
|
|
|
public void updateComponentTradeInfos(final String uuid) {
|
|
|
- final Runnable updateComponentRunnable = new Runnable() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- Date startDate = new Date();
|
|
|
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- Component component = componentDao.findByUuid(uuid);
|
|
|
- if (component != null) {
|
|
|
- Double totalReserve = goodsDao.findTotalReserveByUuid(uuid, Status.AVAILABLE.value());
|
|
|
- component.setReserve(totalReserve);
|
|
|
- // 设置最小最大价格
|
|
|
- Double minPriceRMB = goodsDao.findMinPriceRMBByUuid(uuid, Status.AVAILABLE.value());
|
|
|
- component.setMinPriceRMB(minPriceRMB != null ? minPriceRMB : 0);
|
|
|
- Double maxPriceRMB = goodsDao.findMaxPriceRMBByUuid(uuid, Status.AVAILABLE.value());
|
|
|
- component.setMaxPriceRMB(maxPriceRMB != null ? maxPriceRMB : 0);
|
|
|
- Double minPriceUSD = goodsDao.findMinPriceUSDByUuid(uuid, Status.AVAILABLE.value());
|
|
|
- component.setMinPriceUSD(minPriceUSD != null ? minPriceUSD : 0);
|
|
|
- Double maxPriceUSD = goodsDao.findMaxPriceUSDByUuid(uuid, Status.AVAILABLE.value());
|
|
|
- component.setMaxPriceUSD(maxPriceUSD != null ? maxPriceUSD : 0);
|
|
|
- // 设置最小购买量
|
|
|
- Double minBuyQty = goodsDao.findMinBuyQtyByUuid(uuid, Status.AVAILABLE.value());
|
|
|
- component.setMinBuyQty(minBuyQty != null ? minBuyQty : 0);
|
|
|
- // 设置最小最大发布周期
|
|
|
- Short minDemDelivery = goodsDao.findMinDemDeliveryByUuid(uuid, Status.AVAILABLE.value());
|
|
|
- component.setMinDemDelivery(minDemDelivery != null ? minDemDelivery : 0);
|
|
|
- Short maxDemDelivery = goodsDao.findMaxDemDeliveryByUuid(uuid, Status.AVAILABLE.value());
|
|
|
- component.setMaxDemDelivery(maxDemDelivery != null ? maxDemDelivery : 0);
|
|
|
- Short minHKDelivery = goodsDao.findMinHKDeliveryByUuid(uuid, Status.AVAILABLE.value());
|
|
|
- component.setMinHKDelivery(minHKDelivery != null ? minHKDelivery : 0);
|
|
|
- Short maxHKDelivery = goodsDao.findMaxHKDeliveryByUuid(uuid, Status.AVAILABLE.value());
|
|
|
- component.setMaxHKDelivery(maxHKDelivery != null ? maxHKDelivery : 0);
|
|
|
- // 剩余样品数
|
|
|
- Double availableSampleQty = goodsDao.findAvailableSampleQtyByUuid(uuid, Status.AVAILABLE.value());
|
|
|
- component.setSampleQty(availableSampleQty != null ? availableSampleQty : 0);
|
|
|
- //已申请的样品数
|
|
|
- Double applyedSampleQty = goodsDao.findApplyedSampleQty(uuid, Status.AVAILABLE.value());
|
|
|
- component.setApplySampleQty(applyedSampleQty != null ? applyedSampleQty : 0);
|
|
|
- // 现货
|
|
|
- Double originalQty = goodsDao.findOriginalQtyByUuid(uuid, Status.AVAILABLE.value());
|
|
|
- component.setOriginalQty(originalQty != null ? originalQty : 0);
|
|
|
- // 呆滞库存
|
|
|
- Double inactionStockQty = goodsDao.findInactionStockQtyByUuid(uuid, Status.AVAILABLE.value());
|
|
|
- component.setInactionStockQty(inactionStockQty != null ? inactionStockQty : 0);
|
|
|
- componentDao.save(component);
|
|
|
- }
|
|
|
- Date endDate = new Date();
|
|
|
- System.out.println(uuid + " execute time " + formatter.format(startDate) + " -> " + formatter.format(endDate) +
|
|
|
- ", using mill seconds: " + (endDate.getTime() - startDate.getTime()));
|
|
|
- }
|
|
|
- };
|
|
|
- try {
|
|
|
- executor.submitTask(updateComponentRunnable);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+// final Runnable updateComponentRunnable = new Runnable() {
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// Date startDate = new Date();
|
|
|
+// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+// Component component = componentDao.findByUuid(uuid);
|
|
|
+// if (component != null) {
|
|
|
+// Double totalReserve = goodsDao.findTotalReserveByUuid(uuid, Status.AVAILABLE.value());
|
|
|
+// component.setReserve(totalReserve);
|
|
|
+// // 设置最小最大价格
|
|
|
+// Double minPriceRMB = goodsDao.findMinPriceRMBByUuid(uuid, Status.AVAILABLE.value());
|
|
|
+// component.setMinPriceRMB(minPriceRMB != null ? minPriceRMB : 0);
|
|
|
+// Double maxPriceRMB = goodsDao.findMaxPriceRMBByUuid(uuid, Status.AVAILABLE.value());
|
|
|
+// component.setMaxPriceRMB(maxPriceRMB != null ? maxPriceRMB : 0);
|
|
|
+// Double minPriceUSD = goodsDao.findMinPriceUSDByUuid(uuid, Status.AVAILABLE.value());
|
|
|
+// component.setMinPriceUSD(minPriceUSD != null ? minPriceUSD : 0);
|
|
|
+// Double maxPriceUSD = goodsDao.findMaxPriceUSDByUuid(uuid, Status.AVAILABLE.value());
|
|
|
+// component.setMaxPriceUSD(maxPriceUSD != null ? maxPriceUSD : 0);
|
|
|
+// // 设置最小购买量
|
|
|
+// Double minBuyQty = goodsDao.findMinBuyQtyByUuid(uuid, Status.AVAILABLE.value());
|
|
|
+// component.setMinBuyQty(minBuyQty != null ? minBuyQty : 0);
|
|
|
+// // 设置最小最大发布周期
|
|
|
+// Short minDemDelivery = goodsDao.findMinDemDeliveryByUuid(uuid, Status.AVAILABLE.value());
|
|
|
+// component.setMinDemDelivery(minDemDelivery != null ? minDemDelivery : 0);
|
|
|
+// Short maxDemDelivery = goodsDao.findMaxDemDeliveryByUuid(uuid, Status.AVAILABLE.value());
|
|
|
+// component.setMaxDemDelivery(maxDemDelivery != null ? maxDemDelivery : 0);
|
|
|
+// Short minHKDelivery = goodsDao.findMinHKDeliveryByUuid(uuid, Status.AVAILABLE.value());
|
|
|
+// component.setMinHKDelivery(minHKDelivery != null ? minHKDelivery : 0);
|
|
|
+// Short maxHKDelivery = goodsDao.findMaxHKDeliveryByUuid(uuid, Status.AVAILABLE.value());
|
|
|
+// component.setMaxHKDelivery(maxHKDelivery != null ? maxHKDelivery : 0);
|
|
|
+// // 剩余样品数
|
|
|
+// Double availableSampleQty = goodsDao.findAvailableSampleQtyByUuid(uuid, Status.AVAILABLE.value());
|
|
|
+// component.setSampleQty(availableSampleQty != null ? availableSampleQty : 0);
|
|
|
+// //已申请的样品数
|
|
|
+// Double applyedSampleQty = goodsDao.findApplyedSampleQty(uuid, Status.AVAILABLE.value());
|
|
|
+// component.setApplySampleQty(applyedSampleQty != null ? applyedSampleQty : 0);
|
|
|
+// // 现货
|
|
|
+// Double originalQty = goodsDao.findOriginalQtyByUuid(uuid, Status.AVAILABLE.value());
|
|
|
+// component.setOriginalQty(originalQty != null ? originalQty : 0);
|
|
|
+// // 呆滞库存
|
|
|
+// Double inactionStockQty = goodsDao.findInactionStockQtyByUuid(uuid, Status.AVAILABLE.value());
|
|
|
+// component.setInactionStockQty(inactionStockQty != null ? inactionStockQty : 0);
|
|
|
+// componentDao.save(component);
|
|
|
+// }
|
|
|
+// Date endDate = new Date();
|
|
|
+// System.out.println(uuid + " execute time " + formatter.format(startDate) + " -> " + formatter.format(endDate) +
|
|
|
+// ", using mill seconds: " + (endDate.getTime() - startDate.getTime()));
|
|
|
+// }
|
|
|
+// };
|
|
|
+// try {
|
|
|
+// executor.submitTask(updateComponentRunnable);
|
|
|
+// } catch (InterruptedException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1360,33 +1287,25 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
public ResultMap updateGoods(Goods goods) {
|
|
|
Goods resultGoods = null;
|
|
|
Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
- Goods nowGoods = goodsDao.findByBatchCode(goods.getBatchCode());
|
|
|
- if (nowGoods == null) {
|
|
|
- return new ResultMap(CodeType.NO_INFO.code(), "您提交的批次号无效");
|
|
|
- }
|
|
|
- // 检查身份
|
|
|
- if (!nowGoods.getEnUU().equals(enUU)) {
|
|
|
- return new ResultMap(CodeType.NOT_PERMIT.code(), "您提交的批次号不属于您当前登陆公司");
|
|
|
- }
|
|
|
- if (nowGoods.getSourceId() != null) {
|
|
|
- return new ResultMap(CodeType.NOT_PERMIT.code(), "该库存的信息属于UAS上架,平台不能修改。");
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(goods.getTag())) {
|
|
|
- return new ResultMap(CodeType.NOT_PERMIT.code(), "产品自定义标签必须填写");
|
|
|
- }
|
|
|
- if ((!StringUtils.isEmpty(goods.getAttach())) && StringUtils.isEmpty(nowGoods.getAttach())) {
|
|
|
- productAttachService.submit(goods.getProductid(), goods.getAttach());
|
|
|
- }
|
|
|
- ResultMap resultMap = compareGoodsIfModifyProductInfo(goods, nowGoods);
|
|
|
- if (resultMap.getCode() == CodeType.OK.code()) {
|
|
|
- nowGoods = goodsDao.findByBatchCode(nowGoods.getBatchCode());
|
|
|
- } else if (resultMap.getCode() != CodeType.OK.code()) {
|
|
|
- return resultMap;
|
|
|
+ if (!StringUtils.isEmpty(goods.getBatchCode())) {
|
|
|
+ Goods nowGoods = goodsDao.findByBatchCode(goods.getBatchCode());
|
|
|
+ if (nowGoods == null) {
|
|
|
+ return new ResultMap(CodeType.NOT_PERMIT.code(), "找不到对应的在售信息");
|
|
|
+ }
|
|
|
+ // 检查身份
|
|
|
+ if (!nowGoods.getEnUU().equals(enUU)) {
|
|
|
+ return new ResultMap(CodeType.NOT_PERMIT.code(), "您提交的批次号不属于您当前登陆公司");
|
|
|
+ }
|
|
|
+ if (nowGoods.getSourceId() != null) {
|
|
|
+ return new ResultMap(CodeType.NOT_PERMIT.code(), "该库存的信息属于UAS上架,平台不能修改。");
|
|
|
+ }
|
|
|
+ // 比较两个goods编辑信息
|
|
|
+ compareGoodsWithModify(nowGoods, goods);
|
|
|
+ resultGoods = updateGoods(nowGoods, goods);
|
|
|
+ } else {
|
|
|
+ //根据物料信息,生成在售产品
|
|
|
+ publish(goods, "NORMAL");
|
|
|
}
|
|
|
- // 比较两个goods编辑信息
|
|
|
- compareGoodsWithModify(nowGoods, goods);
|
|
|
- resultGoods = updateGoods(nowGoods, goods);
|
|
|
- updateComponentTradeInfos(nowGoods.getUuid());
|
|
|
return ResultMap.success(resultGoods);
|
|
|
}
|
|
|
|
|
|
@@ -1426,156 +1345,86 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
String beforeImg = beforeGoods.getImg();
|
|
|
String afterImg = afterGoods.getImg();
|
|
|
if (StringUtils.isEmpty(beforeImg) && StringUtils.hasText(afterImg)) {
|
|
|
- ModifyInfo info = new ModifyInfo();
|
|
|
- info.setModifyField(ModifyConstant.MODIFY_IMG.getPhrase());
|
|
|
- info.setBefore(StringConstant.DEFAULT_IMG);
|
|
|
- info.setAfter(StringConstant.NEW_IMG);
|
|
|
- info.setType(ModifyInfo.TYPE_BASIC);
|
|
|
- info.setBatchCode(beforeGoods.getBatchCode());
|
|
|
+ ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_IMG.getPhrase(), beforeGoods.getBatchCode(), StringConstant.DEFAULT_IMG, StringConstant.NEW_IMG, ModifyInfo.TYPE_BASIC);
|
|
|
infoList.add(info);
|
|
|
}
|
|
|
if (StringUtils.hasText(beforeImg) && !beforeImg.equals(afterImg)) {
|
|
|
- ModifyInfo info = new ModifyInfo();
|
|
|
- info.setModifyField(ModifyConstant.MODIFY_IMG.getPhrase());
|
|
|
- info.setBefore(StringConstant.OLD_IMG);
|
|
|
- info.setAfter(StringConstant.NEW_IMG);
|
|
|
- info.setType(ModifyInfo.TYPE_BASIC);
|
|
|
- info.setBatchCode(beforeGoods.getBatchCode());
|
|
|
+ ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_IMG.getPhrase(), beforeGoods.getBatchCode(), StringConstant.OLD_IMG, StringConstant.NEW_IMG, ModifyInfo.TYPE_BASIC);
|
|
|
infoList.add(info);
|
|
|
}
|
|
|
String beforePackage = beforeGoods.getPackaging();
|
|
|
String afterPackage = afterGoods.getPackaging();
|
|
|
- if (!beforePackage.equals(afterPackage)) {
|
|
|
- ModifyInfo info = new ModifyInfo();
|
|
|
- info.setModifyField(ModifyConstant.MODIFY_PACKAGE.getPhrase());
|
|
|
- info.setBefore(beforePackage);
|
|
|
- info.setAfter(afterPackage);
|
|
|
- info.setType(ModifyInfo.TYPE_BASIC);
|
|
|
- info.setBatchCode(beforeGoods.getBatchCode());
|
|
|
+ if (!StringUtilB2C.equals(beforePackage, afterPackage)) {
|
|
|
+ ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_PACKAGE.getPhrase(),beforeGoods.getBatchCode(), beforePackage, afterPackage, ModifyInfo.TYPE_BASIC);
|
|
|
infoList.add(info);
|
|
|
}
|
|
|
String beforeProduce = beforeGoods.getProduceDate();
|
|
|
String afterProduce = afterGoods.getProduceDate();
|
|
|
- if (!beforeProduce.equals(afterProduce)) {
|
|
|
- ModifyInfo info = new ModifyInfo();
|
|
|
- info.setModifyField(ModifyConstant.MODIFY_PRODUCE_DATE.getPhrase());
|
|
|
- info.setBefore(beforeProduce);
|
|
|
- info.setAfter(afterProduce);
|
|
|
- info.setType(ModifyInfo.TYPE_BASIC);
|
|
|
- info.setBatchCode(beforeGoods.getBatchCode());
|
|
|
+ if (!StringUtilB2C.equals(beforeProduce, afterProduce)) {
|
|
|
+ ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_PRODUCE_DATE.getPhrase(), beforeGoods.getBatchCode(), StringUtilB2C.valueOf(beforeProduce), StringUtilB2C.valueOf(beforeProduce), ModifyInfo.TYPE_BASIC);
|
|
|
infoList.add(info);
|
|
|
}
|
|
|
Boolean beforeBreak = beforeGoods.getBreakUp();
|
|
|
Boolean afterBreak = afterGoods.getBreakUp();
|
|
|
if (!beforeBreak.equals(afterBreak)) {
|
|
|
- ModifyInfo info = new ModifyInfo();
|
|
|
- info.setModifyField(ModifyConstant.MODIFY_BREAK_UP.getPhrase());
|
|
|
- info.setBefore(beforeBreak.toString());
|
|
|
- info.setAfter(afterBreak.toString());
|
|
|
- info.setType(ModifyInfo.TYPE_SALE);
|
|
|
- info.setBatchCode(beforeGoods.getBatchCode());
|
|
|
+ ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_BREAK_UP.getPhrase(),beforeGoods.getBatchCode(), StringUtilB2C.valueOf(beforeBreak),StringUtilB2C.valueOf(afterBreak), ModifyInfo.TYPE_SALE);
|
|
|
infoList.add(info);
|
|
|
}
|
|
|
Double beforeReserve = beforeGoods.getReserve();
|
|
|
Double afterReserve = afterGoods.getReserve();
|
|
|
if (!beforeReserve.equals(afterReserve)) {
|
|
|
- ModifyInfo info = new ModifyInfo();
|
|
|
- info.setModifyField(ModifyConstant.MODIFY_RESERVE.getPhrase());
|
|
|
- info.setBefore(beforeReserve.toString());
|
|
|
- info.setAfter(afterReserve.toString());
|
|
|
-// info.setType(ModifyInfo.TYPE_SALE);
|
|
|
- info.setBatchCode(beforeGoods.getBatchCode());
|
|
|
+ ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_RESERVE.getPhrase(), beforeGoods.getBatchCode(), StringUtilB2C.valueOf(beforeReserve), StringUtilB2C.valueOf(afterReserve), ModifyInfo.TYPE_SALE);
|
|
|
infoList.add(info);
|
|
|
}
|
|
|
Double beforePackQty = beforeGoods.getMinPackQty();
|
|
|
Double afterPackQty = afterGoods.getMinPackQty();
|
|
|
- if (!beforePackQty.equals(afterPackQty)) {
|
|
|
- ModifyInfo info = new ModifyInfo();
|
|
|
- info.setModifyField(ModifyConstant.MODIFY_PACKAGE_QTY.getPhrase());
|
|
|
- info.setBefore(beforePackQty.toString());
|
|
|
- info.setAfter(afterPackQty.toString());
|
|
|
- info.setType(ModifyInfo.TYPE_BASIC);
|
|
|
- info.setBatchCode(beforeGoods.getBatchCode());
|
|
|
+ if (NumberUtil.compare(beforePackQty, afterPackQty) != 0) {
|
|
|
+ ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_PACKAGE_QTY.getPhrase(), beforeGoods.getBatchCode(), StringUtilB2C.valueOf(beforePackQty), StringUtilB2C.valueOf(afterPackQty), ModifyInfo.TYPE_BASIC);
|
|
|
infoList.add(info);
|
|
|
}
|
|
|
Double beforeBuyQty = beforeGoods.getMinBuyQty();
|
|
|
Double afterBuyQty = afterGoods.getMinBuyQty();
|
|
|
- if (!beforeBuyQty.equals(afterBuyQty)) {
|
|
|
- ModifyInfo info = new ModifyInfo();
|
|
|
- info.setModifyField(ModifyConstant.MODIFY_BUY_QTY.getPhrase());
|
|
|
- info.setBefore(beforeBuyQty.toString());
|
|
|
- info.setAfter(afterBuyQty.toString());
|
|
|
- info.setType(ModifyInfo.TYPE_SALE);
|
|
|
- info.setBatchCode(beforeGoods.getBatchCode());
|
|
|
+ if (NumberUtil.compare(beforeBuyQty, afterBuyQty) != 0) {
|
|
|
+ ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_BUY_QTY.getPhrase(), beforeGoods.getBatchCode(), StringUtilB2C.valueOf(beforeBuyQty), StringUtilB2C.valueOf(afterBuyQty), ModifyInfo.TYPE_SALE);
|
|
|
infoList.add(info);
|
|
|
}
|
|
|
Short beforeMinDelivery = beforeGoods.getMinDelivery();
|
|
|
Short afterMinDelivery = afterGoods.getMinDelivery();
|
|
|
- if (!beforeMinDelivery.equals(afterMinDelivery)) {
|
|
|
- ModifyInfo info = new ModifyInfo();
|
|
|
- info.setModifyField(ModifyConstant.MODIFY_MIN_DELIVERY.getPhrase());
|
|
|
- info.setBefore(beforeMinDelivery.toString());
|
|
|
- info.setAfter(afterMinDelivery.toString());
|
|
|
- info.setType(ModifyInfo.TYPE_SALE);
|
|
|
- info.setBatchCode(beforeGoods.getBatchCode());
|
|
|
+ if (!StringUtilB2C.equals(StringUtilB2C.valueOf(beforeMinDelivery), StringUtilB2C.valueOf(afterMinDelivery))) {
|
|
|
+ ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_MIN_DELIVERY.getPhrase(), beforeGoods.getBatchCode(), StringUtilB2C.valueOf(beforeMinDelivery), StringUtilB2C.valueOf(afterMinDelivery), ModifyInfo.TYPE_SALE);
|
|
|
infoList.add(info);
|
|
|
}
|
|
|
Integer beforeGoodsStatus = beforeGoods.getStatus();
|
|
|
Integer afterGoodsStatus = afterGoods.getStatus();
|
|
|
if (!beforeGoodsStatus.equals(afterGoodsStatus)) {
|
|
|
- ModifyInfo info = new ModifyInfo();
|
|
|
- info.setModifyField(ModifyConstant.MODIFY_GOODS_STATUS.getPhrase());
|
|
|
- info.setBefore(Status.valueStringOf(beforeGoodsStatus));
|
|
|
- info.setAfter(Status.valueStringOf(afterGoodsStatus));
|
|
|
- info.setType(ModifyInfo.TYPE_SALE);
|
|
|
- info.setBatchCode(beforeGoods.getBatchCode());
|
|
|
+ ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_GOODS_STATUS.getPhrase(), beforeGoods.getBatchCode(), Status.valueStringOf(beforeGoodsStatus), Status.valueStringOf(afterGoodsStatus), ModifyInfo.TYPE_SALE);
|
|
|
infoList.add(info);
|
|
|
}
|
|
|
Short beforeMaxDelivery = beforeGoods.getMaxDelivery();
|
|
|
Short afterMaxDelivery = afterGoods.getMaxDelivery();
|
|
|
- if (!beforeMaxDelivery.equals(afterMaxDelivery)) {
|
|
|
- ModifyInfo info = new ModifyInfo();
|
|
|
- info.setModifyField(ModifyConstant.MODIFY_MAX_DELIVERY.getPhrase());
|
|
|
- info.setBefore(beforeMaxDelivery.toString());
|
|
|
- info.setAfter(afterMaxDelivery.toString());
|
|
|
- info.setType(ModifyInfo.TYPE_SALE);
|
|
|
- info.setBatchCode(beforeGoods.getBatchCode());
|
|
|
+ if (!StringUtilB2C.equals(StringUtilB2C.valueOf(beforeMaxDelivery), StringUtilB2C.valueOf(afterMaxDelivery))) {
|
|
|
+ ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_MAX_DELIVERY.getPhrase(), beforeGoods.getBatchCode(), StringUtilB2C.valueOf(beforeMaxDelivery), StringUtilB2C.valueOf(afterMaxDelivery), ModifyInfo.TYPE_SALE);
|
|
|
infoList.add(info);
|
|
|
}
|
|
|
+
|
|
|
Integer beforeSale = sysConf.getStoreid().equals(beforeGoods.getStoreid()) ? IntegerConstant.B2C_SALE : IntegerConstant.SELF_SALE;
|
|
|
String beforeStore = beforeSale.toString();
|
|
|
String afterStore = afterGoods.getSelfSale();
|
|
|
if (!beforeStore.equals(afterStore)) {
|
|
|
- ModifyInfo info = new ModifyInfo();
|
|
|
- info.setModifyField(ModifyConstant.MODIFY_SALE_METHOD.getPhrase());
|
|
|
+ ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_SALE_METHOD.getPhrase(),beforeGoods.getBatchCode(), StringConstant.SALE_SELF, StringConstant.CONSIGNMENT, ModifyInfo.TYPE_SALE);
|
|
|
if (beforeStore.equals(IntegerConstant.B2C_SALE.toString())) {
|
|
|
info.setBefore(StringConstant.CONSIGNMENT);
|
|
|
info.setAfter(StringConstant.SALE_SELF);
|
|
|
- } else {
|
|
|
- info.setBefore(StringConstant.SALE_SELF);
|
|
|
- info.setAfter(StringConstant.CONSIGNMENT);
|
|
|
}
|
|
|
- info.setType(ModifyInfo.TYPE_SALE);
|
|
|
- info.setBatchCode(beforeGoods.getBatchCode());
|
|
|
infoList.add(info);
|
|
|
}
|
|
|
if (beforeGoods.getCurrencyName().equals(afterGoods.getCurrencyName())) {
|
|
|
if (!GoodsUtil.compareWithQtyPrice(beforeGoods.getPrices(), afterGoods.getPrices(), beforeGoods.getCurrencyName())) {
|
|
|
// 生成分段数量修改记录
|
|
|
- ModifyInfo qtyInfo = new ModifyInfo();
|
|
|
- qtyInfo.setModifyField(ModifyConstant.MODIFY_QTY_NUMBER.getPhrase());
|
|
|
- qtyInfo.setBefore(analyzeQtyNumber(beforeGoods.getPrices()));
|
|
|
- qtyInfo.setAfter(analyzeQtyNumber(afterGoods.getPrices()));
|
|
|
- qtyInfo.setType(ModifyInfo.TYPE_SALE);
|
|
|
- qtyInfo.setBatchCode(beforeGoods.getBatchCode());
|
|
|
+ ModifyInfo qtyInfo = new ModifyInfo(ModifyConstant.MODIFY_QTY_NUMBER.getPhrase(), beforeGoods.getBatchCode(), analyzeQtyNumber(beforeGoods.getPrices()), analyzeQtyNumber(afterGoods.getPrices()), ModifyInfo.TYPE_SALE);
|
|
|
infoList.add(qtyInfo);
|
|
|
// 生成分段价格修改记录
|
|
|
- ModifyInfo priceInfo = new ModifyInfo();
|
|
|
- priceInfo.setModifyField(ModifyConstant.MODIFY_QTY_PRICE.getPhrase());
|
|
|
- priceInfo.setBefore(analyzeQtyPrice(beforeGoods.getPrices()));
|
|
|
- priceInfo.setAfter(analyzeQtyPrice(afterGoods.getPrices()));
|
|
|
- priceInfo.setType(ModifyInfo.TYPE_SALE);
|
|
|
- priceInfo.setBatchCode(beforeGoods.getBatchCode());
|
|
|
+ ModifyInfo priceInfo = new ModifyInfo(ModifyConstant.MODIFY_QTY_PRICE.getPhrase(), beforeGoods.getBatchCode(), analyzeQtyPrice(beforeGoods.getPrices()), analyzeQtyPrice(afterGoods.getPrices()), ModifyInfo.TYPE_SALE);
|
|
|
infoList.add(priceInfo);
|
|
|
}
|
|
|
}
|
|
|
@@ -1742,10 +1591,6 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
public Goods updateGoods(Goods nowGoods, Goods oldGoods) {
|
|
|
nowGoods.setMaxDelivery(oldGoods.getMaxDelivery());
|
|
|
nowGoods.setMinDelivery(oldGoods.getMinDelivery());
|
|
|
- nowGoods.setSelfDeliveryDemMaxTime(oldGoods.getSelfDeliveryDemMaxTime());
|
|
|
- nowGoods.setSelfDeliveryDemMinTime(oldGoods.getSelfDeliveryDemMinTime());
|
|
|
- nowGoods.setSelfDeliveryHKMaxTime(oldGoods.getSelfDeliveryHKMaxTime());
|
|
|
- nowGoods.setSelfDeliveryHKMinTime(oldGoods.getSelfDeliveryHKMinTime());
|
|
|
nowGoods.setTag(oldGoods.getTag());
|
|
|
//判断是否切换了销售方式
|
|
|
Boolean isChangeSaleType = false;
|
|
|
@@ -1822,6 +1667,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
nowGoods.setStatus((NumberUtil.compare(nowGoods.getReserve(), nowGoods.getMinBuyQty()) > -1) ? Status.AVAILABLE.value() : Status.UNAVAILABLE.value());
|
|
|
}
|
|
|
} else {
|
|
|
+ nowGoods.setAutoPublish(Boolean.FALSE);
|
|
|
nowGoods.setStatus(Status.NO_SHELVE.value());
|
|
|
}
|
|
|
|
|
|
@@ -1846,8 +1692,6 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
List<Cart> cartList = cartService.updateCartByGoods(nowGoods);
|
|
|
//更新浏览历史
|
|
|
List<GoodsBrowsingHistory> browsingHistories = browsingHistoryService.updateGoodsBrowsingHistoryByGoods(nowGoods);
|
|
|
-// ProductStandardPutOnInfo putOnInfo = productStandardPutOnInfoService.updateProductStandardPutOnInfoByGoods(nowGoods);
|
|
|
-// Product product = productService.updateProduct(putOnInfo);
|
|
|
updateGoodsRelateInfo(orders, cartList, browsingHistories, null, null, history, nowGoods);
|
|
|
if (null != goodsHistory) {
|
|
|
goodsHistoryService.save(goodsHistory);
|
|
|
@@ -1869,10 +1713,6 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
Goods resultGoods = null;
|
|
|
nowGoods.setMaxDelivery(oldGoods.getMaxDelivery());
|
|
|
nowGoods.setMinDelivery(oldGoods.getMinDelivery());
|
|
|
- nowGoods.setSelfDeliveryDemMaxTime(oldGoods.getSelfDeliveryDemMaxTime());
|
|
|
- nowGoods.setSelfDeliveryDemMinTime(oldGoods.getSelfDeliveryDemMinTime());
|
|
|
- nowGoods.setSelfDeliveryHKMaxTime(oldGoods.getSelfDeliveryHKMaxTime());
|
|
|
- nowGoods.setSelfDeliveryHKMinTime(oldGoods.getSelfDeliveryHKMinTime());
|
|
|
nowGoods.setTag(oldGoods.getTag());
|
|
|
//判断是否切换了销售方式
|
|
|
Boolean isChangeSaleType = false;
|
|
|
@@ -2177,32 +2017,34 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
*/
|
|
|
@Override
|
|
|
public void setB2CDelayTime(Goods goods) {
|
|
|
+ if (goods.getMaxDelivery() == null && goods.getMinDelivery() == null) {
|
|
|
+ return ;
|
|
|
+ } else if ((goods.getMaxDelivery() != null) || (goods.getMinDelivery() != null)) {
|
|
|
+ if (goods.getMaxDelivery() == null) {
|
|
|
+ goods.setMaxDelivery(goods.getMinDelivery());
|
|
|
+ }
|
|
|
+ if (goods.getMinDelivery() == null) {
|
|
|
+ goods.setMinDelivery(goods.getMaxDelivery());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ TradeDeliveryDelayTime deliveryDelayTime = null;
|
|
|
if (goods.getStoreid().equals(sysConf.getStoreid())) { //如果是库存寄售
|
|
|
- if (goods.getCurrencyName().indexOf("RMB") > -1) {
|
|
|
+ if (goods.getCurrencyName().indexOf(StringConstant.RMB) > -1) {
|
|
|
List<TradeDeliveryDelayTime> delayTime3 = tradeDeliveryDelayTimeDao.getByType(3);
|
|
|
if (CollectionUtils.isEmpty(delayTime3)) {
|
|
|
throw new IllegalOperatorException("请联系商城,您供应商交货延长时间 国内发往国内没设置。");
|
|
|
}
|
|
|
- goods.setB2cDeliveryDemMaxTime((short) (delayTime3.get(0).getMaxTime() + Short.valueOf(goods.getSelfDeliveryDemMaxTime() == null ? 0 : goods.getSelfDeliveryDemMaxTime())));
|
|
|
- goods.setB2cDeliveryDemMinTime((short) (delayTime3.get(0).getMinTime() + Short.valueOf(goods.getSelfDeliveryDemMinTime() == null ? 0 : goods.getSelfDeliveryDemMinTime())));
|
|
|
- goods.setB2cMaxDelivery((short) (delayTime3.get(0).getMaxTime() + Short.valueOf(goods.getMaxDelivery() == null ? 0 : goods.getMaxDelivery())));
|
|
|
- goods.setB2cMinDelivery((short) (delayTime3.get(0).getMinTime() + Short.valueOf(goods.getMinDelivery() == null ? 0 : goods.getMinDelivery())));
|
|
|
- }
|
|
|
- if (goods.getCurrencyName().indexOf("USD") > -1) {
|
|
|
+ deliveryDelayTime = delayTime3.get(0);
|
|
|
+ }else {
|
|
|
List<TradeDeliveryDelayTime> delayTime1 = tradeDeliveryDelayTimeDao.getByType(2);
|
|
|
if (CollectionUtils.isEmpty(delayTime1)) {
|
|
|
throw new IllegalOperatorException("请联系商城,您供应商交货延长时间 国外发往国外没设置。");
|
|
|
}
|
|
|
- goods.setB2cDeliveryHKMaxTime((short) (delayTime1.get(0).getMaxTime() + Short.valueOf(goods.getSelfDeliveryHKMaxTime() == null ? 0 : goods.getSelfDeliveryHKMaxTime())));
|
|
|
- goods.setB2cDeliveryHKMinTime((short) (delayTime1.get(0).getMinTime() + Short.valueOf(goods.getSelfDeliveryHKMinTime() == null ? 0 : goods.getSelfDeliveryHKMinTime())));
|
|
|
- goods.setB2cMaxDelivery((short) (delayTime1.get(0).getMaxTime() + Short.valueOf(goods.getMaxDelivery() == null ? 0 : goods.getMaxDelivery())));
|
|
|
- goods.setB2cMinDelivery((short) (delayTime1.get(0).getMinTime() + Short.valueOf(goods.getMinDelivery() == null ? 0 : goods.getMinDelivery())));
|
|
|
+ deliveryDelayTime = delayTime1.get(0);
|
|
|
}
|
|
|
+ goods.setB2cMaxDelivery((short) (deliveryDelayTime.getMaxTime() + Short.valueOf(goods.getMaxDelivery() == null ? 0 : goods.getMaxDelivery())));
|
|
|
+ goods.setB2cMinDelivery((short) (deliveryDelayTime.getMinTime() + Short.valueOf(goods.getMinDelivery() == null ? 0 : goods.getMinDelivery())));
|
|
|
} else { //如果是店铺自营
|
|
|
- goods.setB2cDeliveryDemMaxTime(goods.getSelfDeliveryDemMaxTime());
|
|
|
- goods.setB2cDeliveryDemMinTime(goods.getSelfDeliveryDemMinTime());
|
|
|
- goods.setB2cDeliveryHKMaxTime(goods.getSelfDeliveryHKMaxTime());
|
|
|
- goods.setB2cDeliveryHKMinTime(goods.getSelfDeliveryHKMinTime());
|
|
|
goods.setB2cMaxDelivery(goods.getMaxDelivery());
|
|
|
goods.setB2cMinDelivery(goods.getMinDelivery());
|
|
|
}
|
|
|
@@ -2924,13 +2766,13 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
}
|
|
|
|
|
|
public static void validDeliveryTime(Goods goods) {
|
|
|
- if (goods.getCurrencyName().indexOf("RMB") > -1) {
|
|
|
- if ((goods.getB2cDeliveryDemMaxTime() == null || goods.getB2cDeliveryDemMinTime() == null) && (goods.getMaxDelivery() == null || goods.getMinDelivery() == null)) {
|
|
|
+ if (goods.getCurrencyName().indexOf(StringConstant.RMB) > -1) {
|
|
|
+ if ((goods.getMaxDelivery() == null || goods.getMinDelivery() == null)) {
|
|
|
throw new IllegalOperatorException("产品包含人民币,但是大陆交期为空");
|
|
|
}
|
|
|
}
|
|
|
- if (goods.getCurrencyName().indexOf("USD") > -1) {
|
|
|
- if ((goods.getB2cDeliveryHKMaxTime() == null || goods.getB2cDeliveryHKMinTime() == null) && (goods.getMaxDelivery() == null || goods.getMinDelivery() == null)) {
|
|
|
+ if (goods.getCurrencyName().indexOf(StringConstant.USD) > -1) {
|
|
|
+ if ((goods.getMaxDelivery() == null || goods.getMinDelivery() == null)) {
|
|
|
throw new IllegalOperatorException("产品包含美金,但是香港交期为空");
|
|
|
}
|
|
|
}
|
|
|
@@ -4359,4 +4201,78 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将在售产品关联到物料,如果物料信息不存在,生成对应的物料信息
|
|
|
+ *
|
|
|
+ * @param goods 物料信息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void bindGoodsToProduct(Goods goods) {
|
|
|
+ if (goods == null || StringUtils.isEmpty(goods.getCode()) || StringUtils.isEmpty(goods.getBrandNameEn()) ) {
|
|
|
+ throw new IllegalOperatorException("在售信息为空或在售信息的型号或品牌为空");
|
|
|
+ }
|
|
|
+ List<V_ProductPrivate> v_productPrivates = v_productPrivateService.findProductByPcmpcodeAndPbrandenAndEnUU(goods.getCode(), goods.getBrandNameEn(), goods.getEnUU());
|
|
|
+ if (CollectionUtils.isNotEmpty(v_productPrivates)) {
|
|
|
+ V_ProductPrivate v_productPrivate = v_productPrivates.get(0);
|
|
|
+ goods.setProductid(v_productPrivate.getId());
|
|
|
+ if (IntegerConstant.YES_INT != v_productPrivate.getB2cEnabled()) {
|
|
|
+ ProductPrivate productPrivate = productPrivateService.findByPrId(v_productPrivate.getId());
|
|
|
+ productPrivate.setB2cEnabled(com.uas.platform.b2c.core.constant.IntegerConstant.YES_SHORT);
|
|
|
+ productPrivate.setBatchCount(com.uas.platform.b2c.core.constant.IntegerConstant.YES_SHORT);
|
|
|
+ productPrivateService.saveProductPrivate(productPrivate);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 如果没有物料信息,则声称对应的物料
|
|
|
+ Product product = new Product();
|
|
|
+ product.setByGoods(goods);
|
|
|
+ if (StringUtils.isEmpty(product.getProduceDate())) {
|
|
|
+ product.setProduceDate(StringConstant.DEFAULT_PRODUCEDATE);
|
|
|
+ }
|
|
|
+ List<Brand> brandList = brandDao.findByName(goods.getBrandNameEn());
|
|
|
+ if (CollectionUtils.isEmpty(brandList)) {
|
|
|
+ product.setStandard(IntegerConstant.NO_INT);
|
|
|
+ } else {
|
|
|
+ List<Component> components = componentDao.findByBrandidAndCode(brandList.get(0).getId(), goods.getCode());
|
|
|
+ if (CollectionUtils.isNotEmpty(components)) {
|
|
|
+ Component component = components.get(0);
|
|
|
+ if (component != null) {
|
|
|
+ product.setStandard(IntegerConstant.YES_INT);
|
|
|
+ if (StringUtilB2C.isEmpty(goods.getAttach())) {
|
|
|
+ goods.setAttach(component.getAttach());
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(goods.getImg())) {
|
|
|
+ goods.setImg(component.getImg());
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(goods.getSpec())) {
|
|
|
+ goods.setSpec(component.getDescription());
|
|
|
+ }
|
|
|
+ product.setCmpUuId(component.getUuid());
|
|
|
+ product.setPcmpcode(component.getCode());
|
|
|
+ product.setPbranden(component.getBrand().getNameEn());
|
|
|
+ product.setPbrand(component.getBrand().getNameCn());
|
|
|
+ product.setPbrandid(component.getBrandid());
|
|
|
+ product.setPbranduuid(component.getBrand().getUuid());
|
|
|
+ product.setKind(component.getKind().getNameCn());
|
|
|
+ product.setKindid(component.getKindid());
|
|
|
+ goods.setCode(component.getCode());
|
|
|
+ goods.setBrandNameCn(product.getPbrand());
|
|
|
+ goods.setBrandNameEn(product.getPbranden());
|
|
|
+ goods.setBrandid(product.getPbrandid());
|
|
|
+ goods.setBranduuid(product.getPbranduuid());
|
|
|
+ goods.setUuid(product.getCmpUuId());
|
|
|
+ goods.setKindNameCn(product.getKind());
|
|
|
+ goods.setKindUuid(product.getKindid());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Product product1 = productService.save(product);
|
|
|
+ ProductPrivate productPrivate = new ProductPrivate(product1.getId());
|
|
|
+ productPrivate.setBatchCount(IntegerConstant.YES_INT);
|
|
|
+ productPrivateDao.save(productPrivate);
|
|
|
+ goods.setProductid(product1.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|