|
|
@@ -12,12 +12,15 @@ import com.uas.platform.b2c.common.account.dao.EnterpriseDao;
|
|
|
import com.uas.platform.b2c.common.account.model.Enterprise;
|
|
|
import com.uas.platform.b2c.common.account.model.User;
|
|
|
import com.uas.platform.b2c.core.config.SysConf;
|
|
|
+import com.uas.platform.b2c.core.constant.ShortConstant;
|
|
|
import com.uas.platform.b2c.core.constant.SplitChar;
|
|
|
import com.uas.platform.b2c.core.constant.Status;
|
|
|
import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
import com.uas.platform.b2c.core.utils.DoubleArith;
|
|
|
import com.uas.platform.b2c.core.utils.FastjsonUtils;
|
|
|
import com.uas.platform.b2c.core.utils.NumberUtil;
|
|
|
+import com.uas.platform.b2c.core.utils.PatternUtil;
|
|
|
+import com.uas.platform.b2c.core.utils.RegexConstant;
|
|
|
import com.uas.platform.b2c.external.erp.commodity.util.ModelConverter;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.DoubleConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.IntegerConstant;
|
|
|
@@ -26,6 +29,8 @@ import com.uas.platform.b2c.prod.commodity.dao.*;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.*;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.GoodsHistory.OperateType;
|
|
|
import com.uas.platform.b2c.prod.commodity.service.*;
|
|
|
+import com.uas.platform.b2c.prod.commodity.status.ModifyInfoStatus;
|
|
|
+import com.uas.platform.b2c.prod.commodity.type.ModifyConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.util.GoodsUtil;
|
|
|
import com.uas.platform.b2c.prod.product.common.service.CreateNumberService;
|
|
|
import com.uas.platform.b2c.prod.product.component.dao.ComponentDao;
|
|
|
@@ -208,6 +213,9 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
@Autowired
|
|
|
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private GoodsModifyInfoDao goodsModifyInfoDao;
|
|
|
+
|
|
|
private final Logger logger = Logger.getLogger(getClass());
|
|
|
|
|
|
@Autowired
|
|
|
@@ -495,7 +503,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
}
|
|
|
goodsDao.modifyReserve(goods.getBatchCode(), goods.getUuid(), goods.getReserve(), goods.getStatus().intValue());
|
|
|
// 每次批次保存同时保存一遍历史信息
|
|
|
- GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.DeductReserve.getPhrase(),false);
|
|
|
+ GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.DeductReserve.getPhrase(), false);
|
|
|
goodsHistoryService.save(goodsHistory);
|
|
|
// 更新器件属性的库存
|
|
|
updateComponentTradeInfos(goods.getUuid());
|
|
|
@@ -533,7 +541,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
|
|
|
goodsDao.modifyReserve(goods.getBatchCode(), goods.getUuid(), goods.getReserve(), goods.getStatus().intValue());
|
|
|
// 每次批次保存同时保存一遍历史信息
|
|
|
- GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.ReleaseReserve.getPhrase(),false);
|
|
|
+ GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.ReleaseReserve.getPhrase(), false);
|
|
|
goodsHistoryService.save(goodsHistory);
|
|
|
// 更新器件属性的库存
|
|
|
updateComponentTradeInfos(goods.getUuid());
|
|
|
@@ -719,7 +727,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return null;
|
|
|
}
|
|
|
// updateGoodTransactional(goods);
|
|
|
- GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(),false);
|
|
|
+ GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(), false);
|
|
|
//仅保存商品信息,不上架
|
|
|
if (goods.getId() == null || goods.getSold() == null) {
|
|
|
goods.setSold(IntegerConstant.NO_INT);
|
|
|
@@ -783,7 +791,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
if (resultMap.getCode() != CodeType.OK.code()) {
|
|
|
continue;
|
|
|
}
|
|
|
- GoodsHistory g = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(),false);
|
|
|
+ GoodsHistory g = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(), false);
|
|
|
goodsHistorys.add(g);
|
|
|
list.add(goods);
|
|
|
if (goods.getUuid() != null) {
|
|
|
@@ -816,7 +824,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
if (resultMap.getCode() != CodeType.OK.code()) {
|
|
|
continue;
|
|
|
}
|
|
|
- GoodsHistory g = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(),false);
|
|
|
+ GoodsHistory g = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(), false);
|
|
|
goodsHistorys.add(g);
|
|
|
list.add(goods);
|
|
|
if (goods.getUuid() != null) {
|
|
|
@@ -1257,6 +1265,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
pageInfo.expression(logical);
|
|
|
}
|
|
|
Page<Goods> pageGoods = goodsDao.findAll(new Specification<Goods>() {
|
|
|
+ @Override
|
|
|
public Predicate toPredicate(Root<Goods> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
query.where(pageInfo.getPredicates(root, query, builder));
|
|
|
return null;
|
|
|
@@ -1350,11 +1359,209 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
throw new IllegalOperatorException("该物料已存在(包装、日期、最小包装量、最小起订量、交期、单位、价格)相同的信息");
|
|
|
}
|
|
|
}
|
|
|
+ // 比较两个goods编辑信息
|
|
|
+ compareGoodsWithModify(nowGoods, goods);
|
|
|
resultGoods = updateGoods(nowGoods, goods);
|
|
|
updateComponentTradeInfos(nowGoods.getUuid());
|
|
|
return ResultMap.success(resultGoods);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 比较两个Goods,得出修改后的信息
|
|
|
+ * @param beforeGoods 原有的Goods
|
|
|
+ * @param afterGoods 修改的Goods
|
|
|
+ */
|
|
|
+ private void compareGoodsWithModify(Goods beforeGoods, Goods afterGoods) {
|
|
|
+ List<ModifyInfo> infoList = new ArrayList<>();
|
|
|
+ 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());
|
|
|
+ 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());
|
|
|
+ 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());
|
|
|
+ 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());
|
|
|
+ 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());
|
|
|
+ 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());
|
|
|
+ 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());
|
|
|
+ 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());
|
|
|
+ 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());
|
|
|
+ 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());
|
|
|
+ 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());
|
|
|
+ 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());
|
|
|
+ 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());
|
|
|
+ infoList.add(priceInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(infoList)) {
|
|
|
+ beforeGoods.setAudited(ShortConstant.NO_SHORT);
|
|
|
+ GoodsModifyInfo modifyInfo = new GoodsModifyInfo();
|
|
|
+ modifyInfo.setEnuu(SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ modifyInfo.setUseruu(SystemSession.getUser().getUserUU());
|
|
|
+ modifyInfo.setOperateName(SystemSession.getUser().getUserName());
|
|
|
+ modifyInfo.setBatchCode(beforeGoods.getBatchCode());
|
|
|
+ modifyInfo.setStatus(ModifyInfoStatus.TO_BE_AUDITED.getCode());
|
|
|
+ modifyInfo.setUpdateTime(new Date());
|
|
|
+ modifyInfo.setInfoList(infoList);
|
|
|
+ goodsModifyInfoDao.save(modifyInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分析分段价格获取数量字符串
|
|
|
+ * @param qtyPriceList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String analyzeQtyNumber(List<GoodsQtyPrice> qtyPriceList) {
|
|
|
+ StringBuilder builder = new StringBuilder();
|
|
|
+ for (GoodsQtyPrice qtyPrice : qtyPriceList) {
|
|
|
+ builder.append(SplitChar.SLASH);
|
|
|
+ builder.append(qtyPrice.getStart());
|
|
|
+ }
|
|
|
+ return builder.substring(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分析分段价格获取价格字符串
|
|
|
+ * @param qtyPriceList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String analyzeQtyPrice(List<GoodsQtyPrice> qtyPriceList) {
|
|
|
+ StringBuilder builder = new StringBuilder();
|
|
|
+ Double price = null;
|
|
|
+ for (GoodsQtyPrice qtyPrice : qtyPriceList) {
|
|
|
+ builder.append(SplitChar.SLASH);
|
|
|
+ price = qtyPrice.getRMBPrice() != null ? qtyPrice.getRMBPrice() : qtyPrice.getUSDPrice();
|
|
|
+ builder.append(price);
|
|
|
+ }
|
|
|
+ return builder.substring(1);
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public ResultMap putOn(Long id) {
|
|
|
@@ -1383,7 +1590,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return resultMap;
|
|
|
}
|
|
|
// updateGoodTransactional(goods);
|
|
|
- GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, OperateType.Publish.getPhrase(),false);
|
|
|
+ GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, OperateType.Publish.getPhrase(), false);
|
|
|
Goods persistGoods = goodsDao.save(goods);
|
|
|
goodsHistoryDao.save(goodsHistory);
|
|
|
// TODO huxz 添加或修改商品价格信息
|
|
|
@@ -1397,7 +1604,6 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 添加保存的产品信息
|
|
|
* @param goods
|
|
|
@@ -1444,7 +1650,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
}
|
|
|
goods.setStatus(Status.NO_SHELVE.value());
|
|
|
// updateGoodTransactional(goods);
|
|
|
- GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, OperateType.ADD_GOODS.getPhrase(),false);
|
|
|
+ GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, OperateType.ADD_GOODS.getPhrase(), false);
|
|
|
Goods persistGoods = goodsDao.save(goods);
|
|
|
if(product != null) {
|
|
|
ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
|
|
|
@@ -1756,7 +1962,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goodsDao.deleteByBatchCode(batchCode);
|
|
|
|
|
|
GoodsHistory goodsHist = goodsHistoryService.converTGoodsHist(goods,
|
|
|
- GoodsHistory.OperateType.Down.getPhrase(),false);
|
|
|
+ GoodsHistory.OperateType.Down.getPhrase(), false);
|
|
|
goodsHist.setMessage(goodsHist.getMessage() + "该批次下架");
|
|
|
goodsHistoryService.save(goodsHist);
|
|
|
uuids.add(goods.getUuid());
|
|
|
@@ -1942,7 +2148,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
} else {
|
|
|
goods.setStatus(Status.UNAVAILABLE.value());
|
|
|
}
|
|
|
- GoodsHistory converTGoodsHist = goodsHistoryService.converTGoodsHist(goods, OperateType.Update.getPhrase(),true);
|
|
|
+ GoodsHistory converTGoodsHist = goodsHistoryService.converTGoodsHist(goods, OperateType.Update.getPhrase(), true);
|
|
|
goodsHistoryService.save(converTGoodsHist);
|
|
|
Goods good = goodsDao.save(goods);
|
|
|
if (good == null) {
|
|
|
@@ -1965,7 +2171,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goods.setStatus(Status.UNAVAILABLE.value());
|
|
|
}
|
|
|
// 每次批次保存同时保存一遍历史信息
|
|
|
- GoodsHistory goodsHist = goodsHistoryService.converTGoodsHist(goods, OperateType.OrderPaied.getPhrase(),true);
|
|
|
+ GoodsHistory goodsHist = goodsHistoryService.converTGoodsHist(goods, OperateType.OrderPaied.getPhrase(), true);
|
|
|
goodsHist.setMessage(goodsHist.getMessage() + "接口变更库存之后,扣除意向采购单 和正式采购单的购买数量");
|
|
|
goodsHistoryService.save(goodsHist);
|
|
|
good = goodsDao.save(goods);
|
|
|
@@ -2131,7 +2337,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
|
|
|
} else {
|
|
|
goods.setStatus(Status.REMOVED.value());
|
|
|
- GoodsHistory goodsHist = goodsHistoryService.converTGoodsHist(goods, OperateType.Down.getPhrase(),false);
|
|
|
+ GoodsHistory goodsHist = goodsHistoryService.converTGoodsHist(goods, OperateType.Down.getPhrase(), false);
|
|
|
goodsHist.setMessage(goodsHist.getMessage() + "该批次产品下架(UAS接口)");
|
|
|
goodsHistoryService.save(goodsHist);
|
|
|
goodsDao.delete(goods);
|
|
|
@@ -2384,7 +2590,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ResultMap offShelfGoodsByProvider(String batchCodes, Boolean isERP) {
|
|
|
+ public ResultMap offShelfGoodsByProvider(String batchCodes, String downMsg, Boolean isERP) {
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
logger.info(String.format("%s 商城测试下架时间记录1", dateFormat.format(new Date())));
|
|
|
if (StringUtils.isEmpty(batchCodes)) {
|
|
|
@@ -2401,7 +2607,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
logger.info(String.format("%s 商城测试下架时间记录2", dateFormat.format(new Date())));
|
|
|
for (String batchCode : batchCodeArr) {
|
|
|
logger.info(String.format("%s 商城测试下架时间记录 调用下架方法开始", dateFormat.format(new Date())));
|
|
|
- ResultMap resultMap = offShelfOneGoodsByProvider(batchCode,isERP);
|
|
|
+ ResultMap resultMap = offShelfOneGoodsByProvider(batchCode, downMsg, isERP);
|
|
|
logger.info(String.format("%s 商城测试下架时间记录 调用下架方法结束", dateFormat.format(new Date())));
|
|
|
if (resultMap.isSuccess()) {
|
|
|
Goods goods = (Goods) resultMap.getData();
|
|
|
@@ -2438,9 +2644,10 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
* 下架单个批次商品
|
|
|
*
|
|
|
* @param batchCode 商品批次号
|
|
|
+ * @param downMsg 下架信息
|
|
|
*/
|
|
|
@Transactional
|
|
|
- public ResultMap offShelfOneGoodsByProvider(String batchCode, Boolean isERP) {
|
|
|
+ public ResultMap offShelfOneGoodsByProvider(String batchCode, String downMsg, Boolean isERP) {
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
logger.info(String.format("%s 商城测试下架时间记录 进入下架方法", dateFormat.format(new Date())));
|
|
|
if (StringUtils.isEmpty(batchCode)) {
|
|
|
@@ -2453,9 +2660,12 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
if (goods == null) {
|
|
|
return new ResultMap(CodeType.NOT_EXiST.code(), "对应的批次号" + batchCode + "不存在,请刷新界面再操作");
|
|
|
}
|
|
|
- if (!goods.getEnUU().equals(enUU)) {
|
|
|
- return new ResultMap(CodeType.NOT_PERMIT.code(), "您提交的批次号不属于您当前登陆公司");
|
|
|
+ if (Status.AVAILABLE.value() != goods.getStatus() && Status.UNAVAILABLE.value() != goods.getStatus()) {
|
|
|
+ return new ResultMap(CodeType.NOT_EXiST.code(), "对应的批次号" + batchCode + "未上架,不要下架");
|
|
|
}
|
|
|
+// if (!goods.getEnUU().equals(enUU)) {
|
|
|
+// return new ResultMap(CodeType.NOT_PERMIT.code(), "您提交的批次号不属于您当前登陆公司");
|
|
|
+// }
|
|
|
if (goods.getSourceId() != null) {
|
|
|
return new ResultMap(CodeType.NOT_PERMIT.code(), "批次号" + batchCode + "来自接口,b2c不能进行操作");
|
|
|
}
|
|
|
@@ -2472,6 +2682,9 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
GoodsHistory.OperateType.Down.getPhrase(), isERP);
|
|
|
logger.info(String.format("%s 商城测试下架时间记录 转历史库存 结束", dateFormat.format(new Date())));
|
|
|
goodsHist.setMessage(goodsHist.getMessage() + "该批次下架");
|
|
|
+ if (StringUtils.hasText(downMsg)) {
|
|
|
+ goodsHist.setDownMsg(downMsg);
|
|
|
+ }
|
|
|
goodsHistoryService.save(goodsHist);
|
|
|
|
|
|
Goods updateGoods = goodsDao.save(goods);
|
|
|
@@ -3486,6 +3699,26 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return ResultMap.success(null);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Goods getGoodsById(Long id) {
|
|
|
+ Goods goods = goodsDao.findOne(id);
|
|
|
+ if (goods != null) {
|
|
|
+ if (sysConf.getStoreid().equals(goods.getStoreid())) {
|
|
|
+ goods.setSelfSale("寄售");
|
|
|
+ } else {
|
|
|
+ goods.setSelfSale("自营");
|
|
|
+ }
|
|
|
+ goods.setFrozen(getFrozenCount(goods.getBatchCode()));
|
|
|
+ }
|
|
|
+ if (goods.getUuid() != null) {
|
|
|
+ Component component = componentDao.findByUuid(goods.getUuid());
|
|
|
+ if (component != null) {
|
|
|
+ goods.setAttach(component.getAttach());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return goods;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 修正测试的数据
|
|
|
*
|
|
|
@@ -3532,35 +3765,139 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return String.valueOf(goodses.size());
|
|
|
}
|
|
|
|
|
|
- public ResultMap batchOnSale(List<Long> idList) {
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
- List<Integer> statusList = Arrays.asList(Status.AVAILABLE.value(), Status.UNAVAILABLE.value());
|
|
|
- for (Long id : idList) {
|
|
|
- Product aProduct = productDao.findOne(id);
|
|
|
- if (aProduct == null) {
|
|
|
- continue;
|
|
|
+ @Override
|
|
|
+ public Page<Goods> getPageDataOfBackground(final PageInfo info, GoodsFilter goodsFilter) {
|
|
|
+ if (info == null) {
|
|
|
+ throw new IllegalOperatorException("分页参数丢失");
|
|
|
+ }
|
|
|
+ if (goodsFilter != null) {
|
|
|
+ convertPageInfo(info, goodsFilter);
|
|
|
+ }
|
|
|
+ Page<Goods> page = goodsDao.findAll(new Specification<Goods>() {
|
|
|
+ @Override
|
|
|
+ public Predicate toPredicate(Root<Goods> root, CriteriaQuery<?> query,
|
|
|
+ CriteriaBuilder builder) {
|
|
|
+ query.where(info.getPredicates(root, query, builder));
|
|
|
+ return null;
|
|
|
}
|
|
|
- ProductDetail detail = productDetailDao.findByProductId(id);
|
|
|
- if (detail != null) {
|
|
|
- // 判断是否已有上架商品
|
|
|
- List<Goods> goodsList = goodsDao.findByProductIdInStatus(id, statusList);
|
|
|
- if (CollectionUtils.isEmpty(goodsList)) {
|
|
|
- // 生成Goods信息
|
|
|
- Goods goods = fillDataInGoods(detail);
|
|
|
- ResultMap resultMap = putOnGoods(goods);
|
|
|
- }
|
|
|
+ }, info);
|
|
|
+ List<Goods> goodsList = page.getContent();
|
|
|
+ for (Goods goods : goodsList) {
|
|
|
+ if (sysConf.getStoreid().equals(goods.getStoreid())) {
|
|
|
+ goods.setSelfSale(StringConstant.CONSIGNMENT);
|
|
|
+ } else {
|
|
|
+ goods.setSelfSale(StringConstant.SALE_SELF);
|
|
|
}
|
|
|
+ goods.setFrozen(getFrozenCount(goods.getBatchCode()));
|
|
|
}
|
|
|
- return ResultMap.success(result);
|
|
|
- }
|
|
|
+ return page;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
- * 填充相应字段
|
|
|
- * @param detail
|
|
|
+ * 获取未发货前订单的库存数
|
|
|
+ * @param batchCode
|
|
|
* @return
|
|
|
*/
|
|
|
- private Goods fillDataInGoods(ProductDetail detail) {
|
|
|
- Goods goods = new Goods();
|
|
|
- return goods;
|
|
|
+ private int getFrozenCount(String batchCode) {
|
|
|
+ String statusStr = OrderStatus.TOBEPAID.getCodes() + SplitChar.HYPHEN + OrderStatus.TOBEDELIVER.getCodes();
|
|
|
+ List<Integer> statusList = new ArrayList<>();
|
|
|
+ for (String str : statusStr.split(SplitChar.HYPHEN)) {
|
|
|
+ statusList.add(Integer.valueOf(str));
|
|
|
+ }
|
|
|
+ List<OrderDetail> detailList = orderDetailDao.findByBatchInStatus(batchCode, statusList);
|
|
|
+ int stock = 0;
|
|
|
+ for (OrderDetail detail : detailList) {
|
|
|
+ stock += detail.getNumber();
|
|
|
+ }
|
|
|
+ return stock;
|
|
|
}
|
|
|
+
|
|
|
+ private void convertPageInfo(PageInfo info, GoodsFilter goodsFilter) {
|
|
|
+ if (!StringUtils.isEmpty(goodsFilter.getCode())) {
|
|
|
+ info.filter("code", goodsFilter.getCode());
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(goodsFilter.getBrand())) {
|
|
|
+ SimpleExpression[] brandExpression = new SimpleExpression[2];
|
|
|
+ brandExpression[0] = PredicateUtils.like("brandNameCn", goodsFilter.getBrand(), false, true);
|
|
|
+ brandExpression[1] = PredicateUtils.like("brandNameEn", goodsFilter.getBrand(), false, true);
|
|
|
+ info.expression(PredicateUtils.or((CriterionExpression[]) brandExpression));
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(goodsFilter.getStore())) {
|
|
|
+ if (RegexConstant.onlyHaveNumber(goodsFilter.getStore())) {
|
|
|
+ SimpleExpression[] storeExpression = new SimpleExpression[2];
|
|
|
+ storeExpression[0] = PredicateUtils.eq("enUU", goodsFilter.getStore(), true);
|
|
|
+ storeExpression[1] = PredicateUtils.like("storeName", goodsFilter.getStore(), false, true);
|
|
|
+ info.expression(PredicateUtils.or((CriterionExpression[]) storeExpression));
|
|
|
+ } else {
|
|
|
+ info.filter("storeName", goodsFilter.getStore());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(goodsFilter.getKindUuid())) {
|
|
|
+ // 如果包含多个叶子类目ID,则获取所有的叶子类目对应的商品信息
|
|
|
+ if (goodsFilter.getKindUuid().contains(SplitChar.COMMA)) {
|
|
|
+ String[] kindIds = goodsFilter.getKindUuid().split(SplitChar.COMMA);
|
|
|
+ info.expression(PredicateUtils.in("kindUuid", kindIds, false));
|
|
|
+ } else {
|
|
|
+ info.expression(PredicateUtils.eq("kindUuid", goodsFilter.getKindUuid(), false));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(goodsFilter.getCurrency())) {
|
|
|
+ info.expression(PredicateUtils.eq("currencyName", goodsFilter.getCurrency(), false));
|
|
|
+ }
|
|
|
+ if (goodsFilter.getSaleSelf() != null) {
|
|
|
+ if (goodsFilter.getSaleSelf()) {
|
|
|
+ info.expression(PredicateUtils.ne("storeid", sysConf.getStoreid(), false));
|
|
|
+ } else {
|
|
|
+ info.expression(PredicateUtils.eq("storeid", sysConf.getStoreid(), false));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (goodsFilter.getBreakUp() != null) {
|
|
|
+ int breakUp = goodsFilter.getBreakUp() ? 1 : 0;
|
|
|
+ info.filter("breakUp", breakUp, false);
|
|
|
+ }
|
|
|
+ if (goodsFilter.getHaveImg() != null) {
|
|
|
+ if (goodsFilter.getHaveImg()) {
|
|
|
+ info.expression(PredicateUtils.isNotNull("img"));
|
|
|
+ } else {
|
|
|
+ info.expression(PredicateUtils.isNull("img"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (goodsFilter.getStandard() != null) {
|
|
|
+ if (goodsFilter.getStandard()) {
|
|
|
+ info.expression(PredicateUtils.isNotNull("uuid"));
|
|
|
+ } else {
|
|
|
+ info.expression(PredicateUtils.isNull("uuid"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (goodsFilter.getAudited() != null) {
|
|
|
+ info.expression(PredicateUtils.isNotNull("audited"));
|
|
|
+ info.expression(PredicateUtils.eq("audited", goodsFilter.getAudited(), true));
|
|
|
+ }
|
|
|
+ if (goodsFilter.getSaleStatus() != null || goodsFilter.getSaleNum() != null) {
|
|
|
+ Set<Integer> statusSet = new HashSet<>();
|
|
|
+ if (goodsFilter.getSaleStatus() != null) {
|
|
|
+ // 已上架状态
|
|
|
+ if (Status.AVAILABLE.value() == goodsFilter.getSaleStatus()) {
|
|
|
+ statusSet.add(Status.AVAILABLE.value());
|
|
|
+ statusSet.add(Status.UNAVAILABLE.value());
|
|
|
+ } else {
|
|
|
+ statusSet.add(goodsFilter.getSaleStatus());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (goodsFilter.getSaleNum() != null && 603 != goodsFilter.getSaleNum()) {
|
|
|
+ statusSet.add(goodsFilter.getSaleNum());
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(statusSet)) {
|
|
|
+ SimpleExpression[] statusExpression = new SimpleExpression[statusSet.size()];
|
|
|
+ int i = 0;
|
|
|
+ for (Integer status : statusSet) {
|
|
|
+ statusExpression[i++] = PredicateUtils.eq("status", status, true);
|
|
|
+ }
|
|
|
+ info.expression(PredicateUtils.or((CriterionExpression[]) statusExpression));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (goodsFilter.getSaleNum() != null && 603 == goodsFilter.getSaleNum()) {
|
|
|
+ info.expression(PredicateUtils.eq("reserve", 0, true));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|