|
@@ -1,5 +1,6 @@
|
|
|
package com.fjhx.service.logistics.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -23,6 +24,7 @@ import com.fjhx.params.logistics.*;
|
|
|
import com.fjhx.params.stock.InStockAdd;
|
|
|
import com.fjhx.params.stock.StockChangeDto;
|
|
|
import com.fjhx.service.apply.ApplyPurchaseService;
|
|
|
+import com.fjhx.service.classify.ClassifyService;
|
|
|
import com.fjhx.service.logistics.LogisticsDetailsService;
|
|
|
import com.fjhx.service.logistics.LogisticsInfoService;
|
|
|
import com.fjhx.service.product.ProductInfoService;
|
|
@@ -82,6 +84,9 @@ public class LogisticsInfoServiceImpl extends ServiceImpl<LogisticsInfoMapper, L
|
|
|
@Autowired
|
|
|
private QualityDetailsService qualityDetailsService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ClassifyService classifyService;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<LogisticsInfo> getPage(Map<String, Object> condition) {
|
|
|
|
|
@@ -404,6 +409,42 @@ public class LogisticsInfoServiceImpl extends ServiceImpl<LogisticsInfoMapper, L
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public Page<JdBackPageVo> jdBackPage(JdBackPageDto dto) {
|
|
|
+ IWrapper<Object> wrapper = IWrapper.getWrapper(dto)
|
|
|
+ .keyword(new KeywordData("pi", ProductInfo::getName),
|
|
|
+ new KeywordData("pi", ProductInfo::getCode),
|
|
|
+ new KeywordData("li", LogisticsInfo::getJdBackOrderId));
|
|
|
+
|
|
|
+ return baseMapper.jdBackPage(dto.getPage(), wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JdBackDetailsVo jdBackDetails(Long id) {
|
|
|
+
|
|
|
+ LogisticsInfo logisticsInfo = getById(id);
|
|
|
+
|
|
|
+ List<LogisticsDetails> list = logisticsDetailsService.list(q -> q.eq(LogisticsDetails::getLogisticsInfoId, id));
|
|
|
+ List<LogisticsDetailsEx> logisticsDetailsExList = BeanUtil.copyToList(list, LogisticsDetailsEx.class);
|
|
|
+
|
|
|
+
|
|
|
+ productInfoService.attributeAssign(logisticsDetailsExList, LogisticsDetails::getJdBackProductId, (item, productInfo) -> {
|
|
|
+ item.setProductName(productInfo.getName());
|
|
|
+ item.setProductCode(productInfo.getCode());
|
|
|
+ item.setClassifyId(productInfo.getClassifyId());
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ classifyService.attributeAssign(logisticsDetailsExList, LogisticsDetailsEx::getClassifyId, (item, classify) -> {
|
|
|
+ item.setClassifyName(classify.getName());
|
|
|
+ });
|
|
|
+
|
|
|
+ JdBackDetailsVo jdBackDetailsVo = BeanUtil.toBean(logisticsInfo, JdBackDetailsVo.class);
|
|
|
+ jdBackDetailsVo.setLogisticsDetailsList(logisticsDetailsExList);
|
|
|
+ return jdBackDetailsVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
+ @Override
|
|
|
public void jdBackAdd(JdBackAddDto dto) {
|
|
|
|
|
|
List<LogisticsDetails> logisticsDetailsList = dto.getLogisticsDetailsList();
|
|
@@ -432,17 +473,12 @@ public class LogisticsInfoServiceImpl extends ServiceImpl<LogisticsInfoMapper, L
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- LogisticsInfo logisticsInfo = new LogisticsInfo();
|
|
|
- logisticsInfo.setId(id);
|
|
|
- logisticsInfo.setBusinessId(null);
|
|
|
- logisticsInfo.setBusinessType(4);
|
|
|
- logisticsInfo.setWarehouseId(dto.getWarehouseId());
|
|
|
- logisticsInfo.setJdBackCode(jdBackCode);
|
|
|
- logisticsInfo.setJdBackStatus(jdBackStatus);
|
|
|
- logisticsInfo.setJdBackOrderId(dto.getJdBackOrderId());
|
|
|
- logisticsInfo.setCode(code);
|
|
|
- logisticsInfo.setLogisticsCompanyCode(logisticsCompanyCode);
|
|
|
- logisticsInfo.setLogisticsStatus(state);
|
|
|
+ dto.setId(id);
|
|
|
+ dto.setBusinessId(null);
|
|
|
+ dto.setBusinessType(4);
|
|
|
+ dto.setJdBackCode(jdBackCode);
|
|
|
+ dto.setJdBackStatus(jdBackStatus);
|
|
|
+ dto.setLogisticsStatus(state);
|
|
|
|
|
|
for (LogisticsDetails logisticsDetails : logisticsDetailsList) {
|
|
|
logisticsDetails.setLogisticsInfoId(id);
|
|
@@ -450,12 +486,68 @@ public class LogisticsInfoServiceImpl extends ServiceImpl<LogisticsInfoMapper, L
|
|
|
logisticsDetails.setReceiptQuantity(BigDecimal.ZERO);
|
|
|
}
|
|
|
|
|
|
- save(logisticsInfo);
|
|
|
+ save(dto);
|
|
|
logisticsDetailsService.saveBatch(logisticsDetailsList);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
+ @Override
|
|
|
+ public void jdBackEdit(JdBackAddDto dto) {
|
|
|
+
|
|
|
+ List<LogisticsDetails> logisticsDetailsList = dto.getLogisticsDetailsList();
|
|
|
+ Assert.notEmpty(logisticsDetailsList, "京东退货明细不能为空");
|
|
|
+
|
|
|
+ LogisticsInfo logisticsInfo = getById(dto.getId());
|
|
|
+ Assert.eqTrue(ObjectUtil.isAllNotEmpty(logisticsInfo.getCode(), logisticsInfo.getLogisticsCompanyCode()), "退货已发起,无法编辑");
|
|
|
+
|
|
|
+ String code = dto.getCode();
|
|
|
+ String logisticsCompanyCode = dto.getLogisticsCompanyCode();
|
|
|
+ Integer state = null;
|
|
|
+ if (ObjectUtil.isAllNotEmpty(code, logisticsCompanyCode)) {
|
|
|
+ state = KD100Util.getStateAndMonitor(logisticsCompanyCode, code);
|
|
|
+ }
|
|
|
+
|
|
|
+ synchronized (this) {
|
|
|
+
|
|
|
+ int jdBackStatus = 1;
|
|
|
+ if (state != null) {
|
|
|
+ if (LogisticsConstant.KD100Status.STATUS_3.equals(state)) {
|
|
|
+ addJdBackQuality(logisticsDetailsList, dto.getWarehouseId(), dto.getId());
|
|
|
+ jdBackStatus = 3;
|
|
|
+ } else {
|
|
|
+ jdBackStatus = 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dto.setJdBackStatus(jdBackStatus);
|
|
|
+ dto.setLogisticsStatus(state);
|
|
|
+
|
|
|
+ for (LogisticsDetails logisticsDetails : logisticsDetailsList) {
|
|
|
+ logisticsDetails.setLogisticsInfoId(dto.getId());
|
|
|
+ logisticsDetails.setLogisticsInfoCode(code);
|
|
|
+ logisticsDetails.setReceiptQuantity(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+
|
|
|
+ updateById(dto);
|
|
|
+ List<Long> notDeleteId = logisticsDetailsList.stream().map(BaseIdEntity::getId).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList());
|
|
|
+ if (notDeleteId.size() > 0) {
|
|
|
+ logisticsDetailsService.remove(q -> q.eq(LogisticsDetails::getLogisticsInfoId, dto.getId()).notIn(BaseIdEntity::getId, notDeleteId));
|
|
|
+ }
|
|
|
+ logisticsDetailsService.saveOrUpdateBatch(logisticsDetailsList);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void jdBackDelete(Long id) {
|
|
|
+ LogisticsInfo logisticsInfo = getById(id);
|
|
|
+ Assert.eqTrue(ObjectUtil.isAllNotEmpty(logisticsInfo.getCode(), logisticsInfo.getLogisticsCompanyCode()), "退货已发起,无法删除");
|
|
|
+
|
|
|
+ removeById(id);
|
|
|
+ logisticsDetailsService.remove(LogisticsDetails::getLogisticsInfoId, id);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void addJdBackQuality(List<LogisticsDetails> logisticsDetailsList, Long warehouseId, Long logisticsInfoId) {
|
|
|
|
|
@@ -480,7 +572,7 @@ public class LogisticsInfoServiceImpl extends ServiceImpl<LogisticsInfoMapper, L
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
qualityDetailsService.saveBatch(qualityDetailsList);
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
}
|