|
@@ -2,12 +2,17 @@ package com.fjhx.victoriatourist.service.excess.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
+import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.common.constant.SourceConstant;
|
|
|
import com.fjhx.common.utils.Assert;
|
|
|
import com.fjhx.item.entity.product.po.ProductInfo;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
+import com.fjhx.kd100.util.KD100Util;
|
|
|
import com.fjhx.victoriatourist.entity.excess.dto.ExcessGoodsDetailsDto;
|
|
|
import com.fjhx.victoriatourist.entity.excess.dto.ExcessGoodsDetailsSelectDto;
|
|
|
import com.fjhx.victoriatourist.entity.excess.po.ExcessGoodsDetails;
|
|
@@ -57,6 +62,8 @@ public class ExcessGoodsDetailsServiceImpl extends ServiceImpl<ExcessGoodsDetail
|
|
|
private IWrapper<ExcessGoodsDetails> getWrapper(ExcessGoodsDetailsSelectDto dto) {
|
|
|
IWrapper<ExcessGoodsDetails> wrapper = getWrapper();
|
|
|
wrapper.eq("egd", ExcessGoodsDetails::getStockWaitId, dto.getStockWaitId());
|
|
|
+
|
|
|
+ wrapper.orderByDesc("egd", ExcessGoodsDetails::getCreateTime);
|
|
|
wrapper.orderByDesc("egd", ExcessGoodsDetails::getId);
|
|
|
return wrapper;
|
|
|
}
|
|
@@ -92,6 +99,7 @@ public class ExcessGoodsDetailsServiceImpl extends ServiceImpl<ExcessGoodsDetail
|
|
|
.or().like("lis.logistics_company_code", keyword)
|
|
|
.or().like("lis.`code`", keyword)
|
|
|
.or().like("egd", ExcessGoodsDetails::getQuantity, keyword)
|
|
|
+ .or().like("egd", ExcessGoodsDetails::getBackLogisticsCode, keyword)
|
|
|
.or().in("egd", ExcessGoodsDetails::getProductId, productIds)
|
|
|
);
|
|
|
}
|
|
@@ -197,12 +205,8 @@ public class ExcessGoodsDetailsServiceImpl extends ServiceImpl<ExcessGoodsDetail
|
|
|
*/
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
- public void inStock(ExcessGoodsDetailsDto dto) {
|
|
|
- ExcessGoodsDetails byId = this.getById(dto.getId());
|
|
|
- Assert.notEmpty(byId, "查询不到多货信息!");
|
|
|
- dto.setProcessingMethod(20);//入库
|
|
|
- this.updateById(dto);
|
|
|
-
|
|
|
+ public void inStock(List<Long> excessGoodsDetailsIds) {
|
|
|
+ ExcessGoodsDetails byId = this.getById(excessGoodsDetailsIds.get(0));
|
|
|
StockWait byId1 = stockWaitService.getById(byId.getStockWaitId());
|
|
|
|
|
|
//添加一份待出库数据
|
|
@@ -210,20 +214,56 @@ public class ExcessGoodsDetailsServiceImpl extends ServiceImpl<ExcessGoodsDetail
|
|
|
stockWait.setType(1);
|
|
|
stockWait.setStatus(0);
|
|
|
stockWait.setBusinessId(byId.getId());
|
|
|
- stockWait.setBusinessType(StockWaitType.EXCESS_GOODS_IN.getDetailType());//退货出库
|
|
|
+ stockWait.setBusinessType(StockWaitType.EXCESS_GOODS_IN.getDetailType());
|
|
|
stockWait.setPurchaseId(byId.getPurchaseId());
|
|
|
stockWait.setBusinessCode(byId1.getBusinessCode());
|
|
|
- stockWait.setExcessGoodsId(byId.getId());
|
|
|
stockWaitService.save(stockWait);
|
|
|
|
|
|
- StockWaitDetails stockWaitDetails = new StockWaitDetails();
|
|
|
- stockWaitDetails.setStockWaitId(stockWait.getId());
|
|
|
- stockWaitDetails.setProductId(byId.getProductId());
|
|
|
- stockWaitDetails.setQuantity(byId.getQuantity());
|
|
|
|
|
|
- stockWaitDetails.setBusinessDetailsId(byId.getId());
|
|
|
- stockWaitDetails.setExcessGoodsDetailsId(byId.getId());
|
|
|
- stockWaitDetailsService.save(stockWaitDetails);
|
|
|
+ long logisticsInfosId = IdWorker.getId();
|
|
|
+
|
|
|
+ LogisticsInfos logisticsInfos = new LogisticsInfos();
|
|
|
+
|
|
|
+ LogisticsInfos byId2 = logisticsInfosService.getById(byId.getLogisticsInfosId());
|
|
|
+ if (ObjectUtil.isNotEmpty(byId2)) {
|
|
|
+ logisticsInfos.setLogisticsCompanyCode(byId2.getLogisticsCompanyCode());
|
|
|
+ logisticsInfos.setCode(byId2.getCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ logisticsInfos.setBusinessId(stockWait.getId());
|
|
|
+ logisticsInfos.setBusinessType(1);
|
|
|
+ logisticsInfos.setId(logisticsInfosId);
|
|
|
+ logisticsInfos.setIsKd100(1);
|
|
|
+ logisticsInfos.setStockWaitId(stockWait.getId());
|
|
|
+ logisticsInfos.setPurchaseId(stockWait.getPurchaseId());
|
|
|
+ //发起快递100订阅
|
|
|
+ String activeProfile = SpringUtil.getActiveProfile();
|
|
|
+ DynamicDataSourceContextHolder.push(SourceConstant.KD100);
|
|
|
+ Integer state = !"prod".equals(activeProfile) ? -1 : KD100Util.monitor(logisticsInfos.getLogisticsCompanyCode(), logisticsInfos.getCode(), logisticsInfosId, 1, LogisticsInfos.class).getState();
|
|
|
+ DynamicDataSourceContextHolder.poll();
|
|
|
+ logisticsInfos.setLogisticsStatus(state);
|
|
|
+ logisticsInfos.setIsKd100(1);
|
|
|
+ logisticsInfosService.save(logisticsInfos);
|
|
|
+
|
|
|
+
|
|
|
+ for (Long id : excessGoodsDetailsIds) {
|
|
|
+ ExcessGoodsDetails baseExcessGoodsDetails = this.getById(id);
|
|
|
+ Assert.notEmpty(baseExcessGoodsDetails, "查询不到多货信息!");
|
|
|
+ baseExcessGoodsDetails.setProcessingMethod(20);//入库
|
|
|
+ this.updateById(baseExcessGoodsDetails);
|
|
|
+
|
|
|
+
|
|
|
+ StockWaitDetails stockWaitDetails = new StockWaitDetails();
|
|
|
+ stockWaitDetails.setStockWaitId(stockWait.getId());
|
|
|
+ stockWaitDetails.setProductId(baseExcessGoodsDetails.getProductId());
|
|
|
+ stockWaitDetails.setQuantity(baseExcessGoodsDetails.getQuantity());
|
|
|
+
|
|
|
+ stockWaitDetails.setBusinessDetailsId(baseExcessGoodsDetails.getId());
|
|
|
+ stockWaitDetails.setExcessGoodsDetailsId(baseExcessGoodsDetails.getId());
|
|
|
+ stockWaitDetailsService.save(stockWaitDetails);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|