|
@@ -1,10 +1,12 @@
|
|
|
package com.kmall.admin.service.impl;
|
|
|
|
|
|
import com.kmall.admin.dto.StoreTransferInventoryOrderImportDto;
|
|
|
+import com.kmall.admin.entity.ProductStoreRelaEntity;
|
|
|
import com.kmall.admin.entity.StoreTransferInventoryOrderDetailEntity;
|
|
|
import com.kmall.admin.fromcomm.entity.SysUserEntity;
|
|
|
import com.kmall.admin.service.StoreTransferInventoryOrderDetailService;
|
|
|
import com.kmall.admin.utils.ShiroUtils;
|
|
|
+import com.kmall.common.utils.R;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -15,6 +17,7 @@ import java.util.Map;
|
|
|
import com.kmall.admin.dao.StoreTransferInventoryOrderDao;
|
|
|
import com.kmall.admin.entity.StoreTransferInventoryOrderEntity;
|
|
|
import com.kmall.admin.service.StoreTransferInventoryOrderService;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
/**
|
|
@@ -31,6 +34,10 @@ public class StoreTransferInventoryOrderServiceImpl implements StoreTransferInve
|
|
|
@Autowired
|
|
|
private StoreTransferInventoryOrderDetailService storeTransferInventoryOrderDetailService;
|
|
|
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProductStoreRelaServiceImpl productStoreRelaService;
|
|
|
+
|
|
|
@Override
|
|
|
public StoreTransferInventoryOrderEntity queryObject(Integer id) {
|
|
|
return storeTransferInventoryOrderDao.queryObject(id);
|
|
@@ -75,10 +82,17 @@ public class StoreTransferInventoryOrderServiceImpl implements StoreTransferInve
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void uploadExcel(List<StoreTransferInventoryOrderImportDto> dtoList) {
|
|
|
+ @Transactional
|
|
|
+ public R uploadExcel(List<StoreTransferInventoryOrderImportDto> dtoList) {
|
|
|
if (CollectionUtils.isEmpty(dtoList)) {
|
|
|
- return;
|
|
|
+ return R.error("列表为空");
|
|
|
}
|
|
|
+ try {
|
|
|
+ checkExcelData(dtoList);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return R.error(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
StoreTransferInventoryOrderImportDto base = dtoList.get(0);
|
|
|
String merchSn = base.getMerchSn();
|
|
|
String merchName = base.getMerchName();
|
|
@@ -105,5 +119,33 @@ public class StoreTransferInventoryOrderServiceImpl implements StoreTransferInve
|
|
|
tmp.setRemark(dto.getRemark());
|
|
|
storeTransferInventoryOrderDetailService.save(tmp);
|
|
|
}
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkExcelData(List<StoreTransferInventoryOrderImportDto> dtoList) {
|
|
|
+ for (StoreTransferInventoryOrderImportDto dto : dtoList) {
|
|
|
+ String inStoreSn = dto.getInStoreSn();
|
|
|
+ String outStoreSn = dto.getOutStoreSn();
|
|
|
+ String sku = dto.getSku();
|
|
|
+ // 查询转入门店是否有该sku
|
|
|
+ ProductStoreRelaEntity inProductStoreRelaEntity = productStoreRelaService.getByStoreSnAndSku(inStoreSn, sku);
|
|
|
+ if (inProductStoreRelaEntity == null) {
|
|
|
+ throw new RuntimeException("转入门店中无该sku:" + sku);
|
|
|
+ }
|
|
|
+ // 查询转出门店sku数量是否足够
|
|
|
+ ProductStoreRelaEntity outProductStoreRelaEntity = productStoreRelaService.getByStoreSnAndSku(outStoreSn, sku);
|
|
|
+ if (outProductStoreRelaEntity == null) {
|
|
|
+ throw new RuntimeException("转出门店中无该sku:" + sku);
|
|
|
+ } else {
|
|
|
+ Integer stockNum = outProductStoreRelaEntity.getStockNum();
|
|
|
+ Integer num = dto.getNum();
|
|
|
+ if (stockNum < num) {
|
|
|
+ throw new RuntimeException("转出门店该sku数量不足,sku:" + sku);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|