|
|
@@ -18,7 +18,6 @@ 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.external.erp.commodity.util.ModelConverter;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.DoubleConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.IntegerConstant;
|
|
|
@@ -243,18 +242,23 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
// if(!PatternUtil.matchChineseAndEnglish(goods.getTag())) {
|
|
|
// throw new IllegalOperatorException("自定义标签的信息只能包含中文和英文");
|
|
|
// }
|
|
|
- if (goods.getPackaging() == null) {
|
|
|
+ /*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.getProduceDate())) {
|
|
|
+ throw new IllegalOperatorException("型号" + goods.getCode()+"品牌" + goods.getBrandNameEn() +"的产品生产日期为空");
|
|
|
+ } else {
|
|
|
+ if (goods.getProduceDate().length() > 12) {
|
|
|
+ throw new IllegalOperatorException("产品生产日期不能超过12个字符");
|
|
|
+ }
|
|
|
}
|
|
|
- if (goods.getPackaging().length() > 10) {
|
|
|
- throw new IllegalOperatorException("包装信息操作约定的10个字符");
|
|
|
- }
|
|
|
- if (!PatternUtil.matchChineseAndEnglish(goods.getPackaging())) {
|
|
|
- throw new IllegalOperatorException("包装信息只能包含中文和英文");
|
|
|
- }
|
|
|
- if (goods.getProduceDate().length() > 11) {
|
|
|
- throw new IllegalOperatorException("产品生产日期不能超过11个字符");
|
|
|
- }
|
|
|
+
|
|
|
if (goods.getOriginal() == null) {
|
|
|
throw new IllegalOperatorException("必须选择库存类型");
|
|
|
}
|
|
|
@@ -491,7 +495,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());
|
|
|
+ GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.DeductReserve.getPhrase(),false);
|
|
|
goodsHistoryService.save(goodsHistory);
|
|
|
// 更新器件属性的库存
|
|
|
updateComponentTradeInfos(goods.getUuid());
|
|
|
@@ -529,7 +533,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());
|
|
|
+ GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.ReleaseReserve.getPhrase(),false);
|
|
|
goodsHistoryService.save(goodsHistory);
|
|
|
// 更新器件属性的库存
|
|
|
updateComponentTradeInfos(goods.getUuid());
|
|
|
@@ -715,7 +719,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return null;
|
|
|
}
|
|
|
// updateGoodTransactional(goods);
|
|
|
- GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase());
|
|
|
+ GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(),false);
|
|
|
//仅保存商品信息,不上架
|
|
|
if (goods.getId() == null || goods.getSold() == null) {
|
|
|
goods.setSold(IntegerConstant.NO_INT);
|
|
|
@@ -779,7 +783,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
if (resultMap.getCode() != CodeType.OK.code()) {
|
|
|
continue;
|
|
|
}
|
|
|
- GoodsHistory g = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase());
|
|
|
+ GoodsHistory g = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(),false);
|
|
|
goodsHistorys.add(g);
|
|
|
list.add(goods);
|
|
|
if (goods.getUuid() != null) {
|
|
|
@@ -812,7 +816,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
if (resultMap.getCode() != CodeType.OK.code()) {
|
|
|
continue;
|
|
|
}
|
|
|
- GoodsHistory g = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase());
|
|
|
+ GoodsHistory g = goodsHistoryService.converTGoodsHist(goods, GoodsHistory.OperateType.Publish.getPhrase(),false);
|
|
|
goodsHistorys.add(g);
|
|
|
list.add(goods);
|
|
|
if (goods.getUuid() != null) {
|
|
|
@@ -1379,7 +1383,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return resultMap;
|
|
|
}
|
|
|
// updateGoodTransactional(goods);
|
|
|
- GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, OperateType.Publish.getPhrase());
|
|
|
+ GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, OperateType.Publish.getPhrase(),false);
|
|
|
Goods persistGoods = goodsDao.save(goods);
|
|
|
goodsHistoryDao.save(goodsHistory);
|
|
|
// TODO huxz 添加或修改商品价格信息
|
|
|
@@ -1440,7 +1444,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
}
|
|
|
goods.setStatus(Status.NO_SHELVE.value());
|
|
|
// updateGoodTransactional(goods);
|
|
|
- GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, OperateType.ADD_GOODS.getPhrase());
|
|
|
+ GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, OperateType.ADD_GOODS.getPhrase(),false);
|
|
|
Goods persistGoods = goodsDao.save(goods);
|
|
|
if(product != null) {
|
|
|
ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
|
|
|
@@ -1505,8 +1509,8 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
if (StringConstant.ERP.equals(product.getSourceApp())) {
|
|
|
List<Goods> goodses = goodsDao.findByProductId(product.getId());
|
|
|
Double reserve = productService.getGoodsReserveByErpReserve(product.getErpReserve(), goodses);
|
|
|
- reserve = NumberUtil.add(reserve, nowGoods.getReserve());
|
|
|
- reserve = NumberUtil.sub(reserve, oldGoods.getReserve());
|
|
|
+ reserve = NumberUtil.add(reserve, oldGoods.getReserve());
|
|
|
+ reserve = NumberUtil.sub(reserve, nowGoods.getReserve());
|
|
|
if (NumberUtil.compare(reserve, DoubleConstant.zero) < 0) {
|
|
|
throw new IllegalOperatorException("总在售库存量超过空闲库存量");
|
|
|
}
|
|
|
@@ -1554,7 +1558,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goodsHistoryService
|
|
|
.converTGoodsHist
|
|
|
(nowGoods,
|
|
|
- OperateType.Update.getPhrase());
|
|
|
+ OperateType.Update.getPhrase(),false);
|
|
|
List<Order> orders = detailService.updateOrderDetailsByGoods(nowGoods);
|
|
|
//更新购物车信息
|
|
|
List<Cart> cartList = cartService.updateCartByGoods(nowGoods);
|
|
|
@@ -1574,6 +1578,112 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return nowGoods;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Goods updateGoodsByERP(Goods nowGoods, Goods oldGoods) {
|
|
|
+ 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;
|
|
|
+ String storeuuid = oldGoods.getStoreid();
|
|
|
+ if (Integer.valueOf(oldGoods.getSelfSale()).equals(IntegerConstant.B2C_SALE)) {
|
|
|
+ if(!sysConf.getStoreid().equals(nowGoods.getStoreid())) {
|
|
|
+ isChangeSaleType = true;
|
|
|
+ }
|
|
|
+ nowGoods.setStoreid(sysConf.getStoreid());
|
|
|
+ nowGoods.setStoreName(sysConf.getEnName());
|
|
|
+ } else if (Integer.valueOf(oldGoods.getSelfSale()).equals(IntegerConstant.SELF_SALE)) {
|
|
|
+ StoreIn storeIn = storeInService.findByEnUU(nowGoods.getEnUU());
|
|
|
+ if (storeIn != null && storeIn.getStatus() == StoreStatus.OPENED) {
|
|
|
+ if(!storeIn.getUuid().equals(nowGoods.getStoreid())) {
|
|
|
+ isChangeSaleType = true;
|
|
|
+ }
|
|
|
+ nowGoods.setStoreid(storeIn.getUuid());
|
|
|
+ nowGoods.setStoreName(storeIn.getStoreName());
|
|
|
+ } else {
|
|
|
+ throw new IllegalOperatorException("您还未开店铺,不能选择自营");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new IllegalOperatorException("您选择的销售方式不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(nowGoods.getProductid() != null) {
|
|
|
+ Product product = productDao.findOne(nowGoods.getProductid());
|
|
|
+ if(product != null) {
|
|
|
+ if (StringConstant.ERP.equals(product.getSourceApp())) {
|
|
|
+ List<Goods> goodses = goodsDao.findByProductId(product.getId());
|
|
|
+ Double reserve = productService.getGoodsReserveByErpReserve(product.getErpReserve(), goodses);
|
|
|
+ reserve = NumberUtil.add(reserve, oldGoods.getReserve());
|
|
|
+ reserve = NumberUtil.sub(reserve, nowGoods.getReserve());
|
|
|
+ if (NumberUtil.compare(reserve, DoubleConstant.zero) < 0) {
|
|
|
+ // 下架这部分的库存
|
|
|
+ //throw new IllegalOperatorException("总在售库存量超过空闲库存量");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置货到香港,货到大陆的延长时间
|
|
|
+ setB2CDelayTime(nowGoods);
|
|
|
+
|
|
|
+ nowGoods.setUpdateDate(new Date());
|
|
|
+ nowGoods.setImg(oldGoods.getImg());
|
|
|
+ nowGoods.setMinBuyQty(oldGoods.getMinBuyQty());
|
|
|
+ nowGoods.setMinPackQty(oldGoods.getMinPackQty());
|
|
|
+ nowGoods.setBreakUp(oldGoods.getBreakUp());
|
|
|
+ nowGoods.setPerQty();
|
|
|
+ nowGoods.setReserve(oldGoods);
|
|
|
+ nowGoods.setPackaging(oldGoods.getPackaging());
|
|
|
+ nowGoods.setProduceDate(oldGoods.getProduceDate());
|
|
|
+ // 用含税单价同步未含税单价
|
|
|
+ oldGoods.setWithOutTaxRMBPrice();
|
|
|
+ oldGoods.setWithOutTaxUSDPrice();
|
|
|
+ //保留六位有效数字
|
|
|
+ oldGoods.setSixFraction();
|
|
|
+ nowGoods.setQtyPrice(oldGoods.getQtyPrice());
|
|
|
+ // 更新本批次最小最大价格信息
|
|
|
+ nowGoods.setMinPriceRMB(GoodsUtil.getMinPriceRMB(nowGoods.getPrices()));
|
|
|
+ nowGoods.setMaxPriceRMB(GoodsUtil.getMaxPriceRMB(nowGoods.getPrices()));
|
|
|
+ nowGoods.setMinPriceUSD(GoodsUtil.getMinPriceUSD(nowGoods.getPrices()));
|
|
|
+ nowGoods.setMaxPriceUSD(GoodsUtil.getMaxPriceUSD(nowGoods.getPrices()));
|
|
|
+ if((nowGoods.getStatus().intValue() != Status.REMOVED.value()) && (nowGoods.getStatus().intValue() != Status.NO_SHELVE.value())) {
|
|
|
+ if (NumberUtil.compare(nowGoods.getReserve(), nowGoods.getMinBuyQty()) > -1) {
|
|
|
+ nowGoods.setStatus(Status.AVAILABLE.value());
|
|
|
+ } else {
|
|
|
+ nowGoods.setStatus(Status.UNAVAILABLE.value());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ GoodsHistory history =
|
|
|
+ goodsHistoryService
|
|
|
+ .converTGoodsHist
|
|
|
+ (nowGoods,
|
|
|
+ OperateType.Update.getPhrase(),true);
|
|
|
+ List<Order> orders = detailService.updateOrderDetailsByGoods(nowGoods);
|
|
|
+ //更新购物车信息
|
|
|
+ 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(isChangeSaleType) { // 如果切换了销售方式
|
|
|
+ Set<String> uuids = new HashSet<>();
|
|
|
+ uuids.add(nowGoods.getBatchCode());
|
|
|
+ recommendProductService.deleteProductsWhenSellerUpdateReserve(storeuuid, uuids);
|
|
|
+ } else {
|
|
|
+ recommendProductService.updateRecommendProductInfo(nowGoods);
|
|
|
+ }
|
|
|
+ return nowGoods;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 添加商品操作记录,保存商品信息
|
|
|
*
|
|
|
@@ -1646,7 +1756,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goodsDao.deleteByBatchCode(batchCode);
|
|
|
|
|
|
GoodsHistory goodsHist = goodsHistoryService.converTGoodsHist(goods,
|
|
|
- GoodsHistory.OperateType.Down.getPhrase());
|
|
|
+ GoodsHistory.OperateType.Down.getPhrase(),false);
|
|
|
goodsHist.setMessage(goodsHist.getMessage() + "该批次下架");
|
|
|
goodsHistoryService.save(goodsHist);
|
|
|
uuids.add(goods.getUuid());
|
|
|
@@ -1832,7 +1942,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
} else {
|
|
|
goods.setStatus(Status.UNAVAILABLE.value());
|
|
|
}
|
|
|
- GoodsHistory converTGoodsHist = goodsHistoryService.converTGoodsHist(goods, OperateType.Update.getPhrase());
|
|
|
+ GoodsHistory converTGoodsHist = goodsHistoryService.converTGoodsHist(goods, OperateType.Update.getPhrase(),true);
|
|
|
goodsHistoryService.save(converTGoodsHist);
|
|
|
Goods good = goodsDao.save(goods);
|
|
|
if (good == null) {
|
|
|
@@ -1855,7 +1965,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goods.setStatus(Status.UNAVAILABLE.value());
|
|
|
}
|
|
|
// 每次批次保存同时保存一遍历史信息
|
|
|
- GoodsHistory goodsHist = goodsHistoryService.converTGoodsHist(goods, OperateType.OrderPaied.getPhrase());
|
|
|
+ GoodsHistory goodsHist = goodsHistoryService.converTGoodsHist(goods, OperateType.OrderPaied.getPhrase(),true);
|
|
|
goodsHist.setMessage(goodsHist.getMessage() + "接口变更库存之后,扣除意向采购单 和正式采购单的购买数量");
|
|
|
goodsHistoryService.save(goodsHist);
|
|
|
good = goodsDao.save(goods);
|
|
|
@@ -2021,7 +2131,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
|
|
|
} else {
|
|
|
goods.setStatus(Status.REMOVED.value());
|
|
|
- GoodsHistory goodsHist = goodsHistoryService.converTGoodsHist(goods, OperateType.Down.getPhrase());
|
|
|
+ GoodsHistory goodsHist = goodsHistoryService.converTGoodsHist(goods, OperateType.Down.getPhrase(),false);
|
|
|
goodsHist.setMessage(goodsHist.getMessage() + "该批次产品下架(UAS接口)");
|
|
|
goodsHistoryService.save(goodsHist);
|
|
|
goodsDao.delete(goods);
|
|
|
@@ -2168,13 +2278,22 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
if (StringUtils.hasText(code)) {
|
|
|
pageInfo.expression(like("code", code, false));
|
|
|
}
|
|
|
- return goodsDao.findAll(new Specification<Goods>() {
|
|
|
+ Page<Goods> goodsPage = 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;
|
|
|
}
|
|
|
}, pageInfo);
|
|
|
+ for (Goods goods : goodsPage.getContent()) {
|
|
|
+ if (goods.getUuid() != null) {
|
|
|
+ Component component = componentDao.findByUuid(goods.getUuid());
|
|
|
+ if (component != null) {
|
|
|
+ goods.setAttach(component.getAttach());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return goodsPage;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -2265,7 +2384,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ResultMap offShelfGoodsByProvider(String batchCodes) {
|
|
|
+ public ResultMap offShelfGoodsByProvider(String batchCodes, 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)) {
|
|
|
@@ -2282,7 +2401,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);
|
|
|
+ ResultMap resultMap = offShelfOneGoodsByProvider(batchCode,isERP);
|
|
|
logger.info(String.format("%s 商城测试下架时间记录 调用下架方法结束", dateFormat.format(new Date())));
|
|
|
if (resultMap.isSuccess()) {
|
|
|
Goods goods = (Goods) resultMap.getData();
|
|
|
@@ -2321,7 +2440,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
* @param batchCode 商品批次号
|
|
|
*/
|
|
|
@Transactional
|
|
|
- public ResultMap offShelfOneGoodsByProvider(String batchCode) {
|
|
|
+ public ResultMap offShelfOneGoodsByProvider(String batchCode, 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)) {
|
|
|
@@ -2343,31 +2462,18 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goods.setStatus(Status.REMOVED.value());
|
|
|
|
|
|
//检查对应产品库信息
|
|
|
- Product product = productDao.findOne(goods.getProductid());
|
|
|
- if (product == null) {
|
|
|
- throw new IllegalOperatorException("产品库信息丢失");
|
|
|
- }
|
|
|
+// Product product = productDao.findOne(goods.getProductid());
|
|
|
+// if (product == null) {
|
|
|
+// throw new IllegalOperatorException("产品库信息丢失");
|
|
|
+// }
|
|
|
|
|
|
logger.info(String.format("%s 商城测试下架时间记录 转历史库存 开始", dateFormat.format(new Date())));
|
|
|
GoodsHistory goodsHist = goodsHistoryService.converTGoodsHist(goods,
|
|
|
- GoodsHistory.OperateType.Down.getPhrase());
|
|
|
+ GoodsHistory.OperateType.Down.getPhrase(), isERP);
|
|
|
logger.info(String.format("%s 商城测试下架时间记录 转历史库存 结束", dateFormat.format(new Date())));
|
|
|
goodsHist.setMessage(goodsHist.getMessage() + "该批次下架");
|
|
|
goodsHistoryService.save(goodsHist);
|
|
|
|
|
|
-// ProductStandardPutOnInfo standardPutOnInfo = productStandardPutOnInfoDao.findOne(goods.getStandprodid());
|
|
|
-// if(standardPutOnInfo != null) {
|
|
|
-// standardPutOnInfo.setStatus(Status.REMOVED.value());
|
|
|
-// standardPutOnInfo.setAvailableOnSale(NumberUtil.add(standardPutOnInfo.getAvailableOnSale(), standardPutOnInfo.getOnSaleQty()));
|
|
|
-// standardPutOnInfo.setOnSaleQty(0.0d);
|
|
|
-// productStandardPutOnInfoDao.save(standardPutOnInfo);
|
|
|
-//
|
|
|
-// Product product = productDao.findOne(standardPutOnInfo.getProductid());
|
|
|
-// product.setAvailableOnSale(standardPutOnInfo.getAvailableOnSale());
|
|
|
-// product.setOnSaleQty(standardPutOnInfo.getOnSaleQty());
|
|
|
-// productDao.save(product);
|
|
|
-// }
|
|
|
-
|
|
|
Goods updateGoods = goodsDao.save(goods);
|
|
|
//下架对应的批次 目前确定下架之后不做删除动作。
|
|
|
// goodsDao.deleteByBatchCode(goods.getBatchCode());
|
|
|
@@ -2509,6 +2615,68 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return goods;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<Goods> getGoodsByEnuu(String keyword, Boolean isSelfSupport) {
|
|
|
+ final PageInfo page = new PageInfo();
|
|
|
+ page.setPageNumber(1);
|
|
|
+ page.setPageSize(10);
|
|
|
+ Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
+ page.expression(PredicateUtils.eq("enUU", enUU, true));
|
|
|
+ page.sorting("createdDate", Sort.Direction.DESC);
|
|
|
+
|
|
|
+ SimpleExpression status1 = PredicateUtils.eq("status", Status.AVAILABLE.value(), true);
|
|
|
+ SimpleExpression status2 = PredicateUtils.eq("status", Status.UNAVAILABLE.value(), true);
|
|
|
+ SimpleExpression[] expressions2 = new SimpleExpression[] {status1, status2};
|
|
|
+ LogicalExpression logicalExpression2 = PredicateUtils.or(expressions2);
|
|
|
+ page.expression(logicalExpression2);
|
|
|
+
|
|
|
+ List<StoreIn> storeIns = storeInDao.findByEnUU(enUU);
|
|
|
+ String uuid = null;
|
|
|
+ if (!CollectionUtils.isEmpty(storeIns)) {
|
|
|
+ uuid = storeIns.get(0).getUuid();
|
|
|
+ } else {
|
|
|
+ uuid = "null";
|
|
|
+ }
|
|
|
+ // 过滤自营店铺上架商品
|
|
|
+ if (isSelfSupport != null && isSelfSupport && StringUtils.hasText(uuid)) {
|
|
|
+ SimpleExpression[] simpleExpressions = new SimpleExpression[3];
|
|
|
+ simpleExpressions[0] = PredicateUtils.eq("storeid", uuid, true);
|
|
|
+ simpleExpressions[1] = PredicateUtils.ne("storeName", "优软测试二", true);
|
|
|
+ simpleExpressions[2] = PredicateUtils.ne("storeName", "优软商城", true);
|
|
|
+ page.expression(PredicateUtils.and(simpleExpressions));
|
|
|
+ }
|
|
|
+ // 过滤寄售商品
|
|
|
+ if (isSelfSupport != null && !isSelfSupport && StringUtils.hasText(uuid)) {
|
|
|
+ String[] storeNames = new String[]{"优软测试二", "优软商城"};
|
|
|
+ LogicalExpression logicalExpression = PredicateUtils.in("storeName", storeNames, true);
|
|
|
+ if (!"null".equals(uuid)) {
|
|
|
+ SimpleExpression simpleExpression = PredicateUtils.ne("storeid", uuid, true);
|
|
|
+ page.expression(PredicateUtils.or(simpleExpression, logicalExpression));
|
|
|
+ } else {
|
|
|
+ page.expression(logicalExpression);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 过滤关键词
|
|
|
+ if (StringUtils.hasText(keyword)) {
|
|
|
+ SimpleExpression code = like("code", keyword, true, true);
|
|
|
+ SimpleExpression brandNameEn = like("brandNameEn", keyword, true, true);
|
|
|
+ SimpleExpression batchCode = PredicateUtils.like("prodNum", keyword, true, true);
|
|
|
+ SimpleExpression[] expressions3 = new SimpleExpression[]{code, brandNameEn, batchCode};
|
|
|
+ LogicalExpression logicalExpression3 = PredicateUtils.or(expressions3);
|
|
|
+ page.expression(logicalExpression2);
|
|
|
+ }
|
|
|
+
|
|
|
+ return goodsDao.findAll(new Specification<Goods>() {
|
|
|
+ @Override
|
|
|
+ public Predicate toPredicate(Root<Goods> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
|
|
+ query.where(page.getPredicates(root, query, cb));
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }, page.getSort());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public String isSelfSupport(String storeid) {
|
|
|
if(StringUtils.isEmpty(storeid)) {
|
|
|
return "";
|
|
|
@@ -2682,6 +2850,112 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return ResultMap.success(false);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ResultMap downNowEnterpriseGoods(Long enUU) {
|
|
|
+ List<Integer> statusList = Arrays.asList(Status.AVAILABLE.value(), Status.UNAVAILABLE.value());
|
|
|
+ List<Goods> goodsList = goodsDao.findByEnUUAndInStatus(enUU, statusList);
|
|
|
+ List<GoodsHistory> histories = new ArrayList<>(goodsList.size());
|
|
|
+ List<Goods> goodsUpdate = new ArrayList<>(goodsList.size());
|
|
|
+ List<String> uuids = new ArrayList<>(goodsList.size());
|
|
|
+ for (Goods goods : goodsList) {
|
|
|
+ goods.setStatus(Status.REMOVED.value());
|
|
|
+
|
|
|
+ GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, "批量下架公司产品",false);
|
|
|
+ goodsHistory.setMessage(goodsHistory.getMessage() + "该批次下架");
|
|
|
+ goodsHistoryService.save(goodsHistory);
|
|
|
+ histories.add(goodsHistory);
|
|
|
+ goodsUpdate.add(goods);
|
|
|
+
|
|
|
+ uuids.add(goods.getUuid());
|
|
|
+ }
|
|
|
+
|
|
|
+ goodsDao.save(goodsUpdate);
|
|
|
+ goodsHistoryDao.save(histories);
|
|
|
+ for (String uuid : uuids) {
|
|
|
+ updateComponentTradeInfos(uuid);
|
|
|
+ }
|
|
|
+ return ResultMap.success(goodsUpdate.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<Object, Object> deleteGoodsList(List<Goods> goodsList) {
|
|
|
+ Map<Object, Object> map = new HashMap<>();
|
|
|
+ int fail = 0;
|
|
|
+ // 保存批次号,以便下架推荐产品
|
|
|
+ Set<String> set = new HashSet<>();
|
|
|
+ String storeId = null;
|
|
|
+ for (Goods goods : goodsList) {
|
|
|
+ boolean isExistOrder = validateExistOrder(goods.getBatchCode());
|
|
|
+
|
|
|
+ if (isExistOrder) {
|
|
|
+ fail++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (storeId == null) {
|
|
|
+ storeId = goods.getStoreid();
|
|
|
+ }
|
|
|
+ set.add(goods.getBatchCode());
|
|
|
+
|
|
|
+ List<Order> orders = detailService.updateOrderDetailsByGoods(goods);
|
|
|
+ orderService.save(orders);
|
|
|
+
|
|
|
+ Boolean aBoolean = floorsService.updateHomeInfo(goods.getBatchCode());
|
|
|
+ List<GoodsHistory> histories = new ArrayList<>();
|
|
|
+ if (goods.getStatus().equals(Status.AVAILABLE.value()) || goods.getStatus().equals(Status.UNAVAILABLE.value())) {
|
|
|
+ //先做下架记录
|
|
|
+ goods.setStatus(Status.REMOVED.value());
|
|
|
+ GoodsHistory goodsHistoryRemoved = goodsHistoryService.converTGoodsHist(goods, OperateType.Down.getPhrase(),false);
|
|
|
+ histories.add(goodsHistoryRemoved);
|
|
|
+ }
|
|
|
+
|
|
|
+ goods.setStatus(Status.GOODS_DELETE.value());
|
|
|
+ //删除库存信息
|
|
|
+ GoodsHistory goodsHistoryDelete = goodsHistoryService.converTGoodsHist(goods, OperateType.DELETE.getPhrase(),false);
|
|
|
+ histories.add(goodsHistoryDelete);
|
|
|
+ goodsHistoryService.save(histories);
|
|
|
+
|
|
|
+ goodsDao.deleteByBatchCode(goods.getBatchCode());
|
|
|
+ if (goods.getProductid() != null) {
|
|
|
+ Product product = productDao.findOne(goods.getProductid());
|
|
|
+ if (product != null) {
|
|
|
+ ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
|
|
|
+ if (productPrivate == null) {
|
|
|
+ productPrivate = new ProductPrivate();
|
|
|
+ }
|
|
|
+ Integer count = productPrivate.getBatchCount();
|
|
|
+ productPrivate.setBatchCount(--count);
|
|
|
+ productPrivateDao.save(productPrivate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //统计器件的信息
|
|
|
+ if (!StringUtils.isEmpty(goods.getUuid())) {
|
|
|
+ updateComponentTradeInfos(goods.getUuid());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ recommendProductService.deleteProductsWhenSellerUpdateReserve(storeId, set);
|
|
|
+ map.put("total", goodsList.size());
|
|
|
+ map.put("success", goodsList.size() - fail);
|
|
|
+ map.put("fail", fail);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public ResultMap batchDeleteGoods(List<Long> idList) {
|
|
|
+ List<Goods> goodsList = goodsDao.findGoodsInIdList(idList);
|
|
|
+ Map<Object, Object> map = deleteGoodsList(goodsList);
|
|
|
+ return ResultMap.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public ResultMap deleteGoodsByEnUU(Long enUU) {
|
|
|
+ List<Integer> statusList = Arrays.asList(Status.AVAILABLE.value(), Status.UNAVAILABLE.value());
|
|
|
+ List<Goods> goodsList = goodsDao.findByEnUUAndInStatus(enUU, statusList);
|
|
|
+ Map<Object, Object> map = deleteGoodsList(goodsList);
|
|
|
+ return ResultMap.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 下架该公司所有的商品信息
|
|
|
*
|
|
|
@@ -2714,7 +2988,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
}
|
|
|
goods.setStatus(Status.REMOVED.value());
|
|
|
|
|
|
- GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, "批量下架公司产品");
|
|
|
+ GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, "批量下架公司产品",false);
|
|
|
goodsHistory.setMessage(goodsHistory.getMessage() + "该批次下架");
|
|
|
goodsHistoryService.save(goodsHistory);
|
|
|
histories.add(goodsHistory);
|
|
|
@@ -2832,7 +3106,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goods.setStatus(Status.AVAILABLE.value());
|
|
|
}
|
|
|
GoodsHistory goodsHist = goodsHistoryService.converTGoodsHist(goods,
|
|
|
- GoodsHistory.OperateType.Publish.getPhrase());
|
|
|
+ GoodsHistory.OperateType.Publish.getPhrase(),false);
|
|
|
goodsHist.setMessage(goodsHist.getMessage() + "该批次上架");
|
|
|
goodsHistoryService.save(goodsHist);
|
|
|
Product product = productDao.findOne(id);
|
|
|
@@ -2904,19 +3178,8 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
if(goods == null) {
|
|
|
return null;
|
|
|
}
|
|
|
- boolean isExistOrder = false;
|
|
|
- List<OrderDetail> orderList = orderDetailService.findOrderDetailByBatchCode(goods.getBatchCode());
|
|
|
- String codes = OrderStatus.UNAVAILABLE.getCodes() + "-" + Status.TOBECONFIRMED.value();
|
|
|
- for (OrderDetail detail : orderList) {
|
|
|
- Order order = detail.getOrder();
|
|
|
- int status = order.getStatus() == null ? detail.getStatus() : order.getStatus();
|
|
|
- if (codes.indexOf(String.valueOf(status)) < 0) {
|
|
|
- if (StringUtils.isEmpty(order.getOrderids())) {
|
|
|
- isExistOrder = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ boolean isExistOrder = validateExistOrder(goods.getBatchCode());
|
|
|
+
|
|
|
if (isExistOrder) {
|
|
|
throw new IllegalOperatorException("该商品已经被购买了,不能删除");
|
|
|
}
|
|
|
@@ -2932,20 +3195,20 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
if (goods.getStatus().equals(Status.AVAILABLE.value()) || goods.getStatus().equals(Status.UNAVAILABLE.value())) {
|
|
|
//先做下架记录
|
|
|
goods.setStatus(Status.REMOVED.value());
|
|
|
- GoodsHistory goodsHistoryRemoved = goodsHistoryService.converTGoodsHist(goods, OperateType.Down.getPhrase());
|
|
|
+ GoodsHistory goodsHistoryRemoved = goodsHistoryService.converTGoodsHist(goods, OperateType.Down.getPhrase(),false);
|
|
|
histories.add(goodsHistoryRemoved);
|
|
|
}
|
|
|
|
|
|
goods.setStatus(Status.GOODS_DELETE.value());
|
|
|
//删除库存信息
|
|
|
- GoodsHistory goodsHistoryDelete = goodsHistoryService.converTGoodsHist(goods, OperateType.DELETE.getPhrase());
|
|
|
+ GoodsHistory goodsHistoryDelete = goodsHistoryService.converTGoodsHist(goods, OperateType.DELETE.getPhrase(),false);
|
|
|
histories.add(goodsHistoryDelete);
|
|
|
goodsHistoryService.save(histories);
|
|
|
|
|
|
goodsDao.deleteByBatchCode(goods.getBatchCode());
|
|
|
- if(goods.getProductid() != null) {
|
|
|
+ if (goods.getProductid() != null) {
|
|
|
Product product = productDao.findOne(goods.getProductid());
|
|
|
- if(product != null) {
|
|
|
+ if (product != null) {
|
|
|
ProductPrivate productPrivate = releaseProductByBatchService.findByPrId(product.getId());
|
|
|
if (productPrivate == null) {
|
|
|
productPrivate = new ProductPrivate();
|
|
|
@@ -2963,6 +3226,28 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return goods;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据批次号查询是否有订单
|
|
|
+ * @param batchCode
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private boolean validateExistOrder(String batchCode) {
|
|
|
+ boolean isExistOrder = false;
|
|
|
+ List<OrderDetail> orderList = orderDetailService.findOrderDetailByBatchCode(batchCode);
|
|
|
+ String codes = OrderStatus.UNAVAILABLE.getCodes() + "-" + Status.TOBECONFIRMED.value();
|
|
|
+ for (OrderDetail detail : orderList) {
|
|
|
+ Order order = detail.getOrder();
|
|
|
+ int status = order.getStatus() == null ? detail.getStatus() : order.getStatus();
|
|
|
+ if (codes.indexOf(String.valueOf(status)) < 0) {
|
|
|
+ if (StringUtils.isEmpty(order.getOrderids())) {
|
|
|
+ isExistOrder = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return isExistOrder;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<Goods> deleteGoods(List<Goods> goodses) {
|
|
|
List<Order> orders = new ArrayList<>();
|
|
|
@@ -2976,19 +3261,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
if (goods == null) {
|
|
|
return null;
|
|
|
}
|
|
|
- boolean isExistOrder = false;
|
|
|
- List<OrderDetail> orderList = orderDetailService.findOrderDetailByBatchCode(goods.getBatchCode());
|
|
|
- String codes = OrderStatus.UNAVAILABLE.getCodes() + "-" + Status.TOBECONFIRMED.value();
|
|
|
- for (OrderDetail detail : orderList) {
|
|
|
- Order order = detail.getOrder();
|
|
|
- int status = order.getStatus() == null ? detail.getStatus() : order.getStatus();
|
|
|
- if (codes.indexOf(String.valueOf(status)) < 0) {
|
|
|
- if (StringUtils.isEmpty(order.getOrderids())) {
|
|
|
- isExistOrder = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ boolean isExistOrder = validateExistOrder(goods.getBatchCode());
|
|
|
if (isExistOrder) {
|
|
|
throw new IllegalOperatorException("存在商品已经被购买了,不能删除");
|
|
|
}
|
|
|
@@ -3003,12 +3276,12 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
|
|
|
if (goods.getStatus().equals(Status.AVAILABLE.value()) || goods.getStatus().equals(Status.UNAVAILABLE.value())) {
|
|
|
goods.setStatus(Status.REMOVED.value());
|
|
|
- GoodsHistory goodsHistoryRemoved = goodsHistoryService.converTGoodsHist(goods, OperateType.Down.getPhrase());
|
|
|
+ GoodsHistory goodsHistoryRemoved = goodsHistoryService.converTGoodsHist(goods, OperateType.Down.getPhrase(),false);
|
|
|
histories.add(goodsHistoryRemoved);
|
|
|
}
|
|
|
//删除库存信息
|
|
|
goods.setStatus(Status.GOODS_DELETE.value());
|
|
|
- GoodsHistory goodsHistoryDelete = goodsHistoryService.converTGoodsHist(goods, OperateType.DELETE.getPhrase());
|
|
|
+ GoodsHistory goodsHistoryDelete = goodsHistoryService.converTGoodsHist(goods, OperateType.DELETE.getPhrase(),false);
|
|
|
histories.add(goodsHistoryDelete);
|
|
|
goodses1.add(goods);
|
|
|
gids.add(goods.getId());
|
|
|
@@ -3246,7 +3519,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
}
|
|
|
if (isModify) {
|
|
|
goods.setQtyPrice(FastjsonUtils.toJson(list));
|
|
|
- GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, OperateType.MODIFY_PRICE.getPhrase());
|
|
|
+ GoodsHistory goodsHistory = goodsHistoryService.converTGoodsHist(goods, OperateType.MODIFY_PRICE.getPhrase(),false);
|
|
|
histories.add(goodsHistory);
|
|
|
goodses.add(goods);
|
|
|
}
|