|
@@ -76,6 +76,7 @@ public class WebsitSalesLogic {
|
|
|
private final WorkerGoodsRelaService workerGoodsRelaService;
|
|
|
private final WorkerGoodsService workerGoodsService;
|
|
|
private final MaterialConfigService materialConfigService;
|
|
|
+ private final WebsitUserService websitUserService;
|
|
|
|
|
|
public IPage<WebsitSalesVO> page(WebsitSalesParamBean zfireParamBean) {
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
@@ -791,28 +792,30 @@ public class WebsitSalesLogic {
|
|
|
// .eq(User::getStatus, true)
|
|
|
.list();
|
|
|
|
|
|
+ List<WebsitUser> websitUserList = websitUserService.lambdaQuery()
|
|
|
+ .eq(WebsitUser::getUserId, userList.stream().map(User::getUserId).collect(Collectors.toList()))
|
|
|
+ .list();
|
|
|
+
|
|
|
List<WebsitGoodsCategory> categoryList = websitGoodsCategoryService.lambdaQuery()
|
|
|
.eq(WebsitGoodsCategory::getCompanyWechatId, companyWechatId)
|
|
|
.list();
|
|
|
|
|
|
- Map<String, WebsitGoods> goodsMap;
|
|
|
-
|
|
|
- try {
|
|
|
- goodsMap = websitGoods.stream()
|
|
|
- .collect(Collectors.toMap(WebsitGoods::getGoodsName, Function.identity()));
|
|
|
- } catch (Exception e) {
|
|
|
- throw new RemoteServiceException("系统里的辅材名称信息有重复");
|
|
|
- }
|
|
|
+ Map<String, WebsitGoods> goodsMap = websitGoods.stream()
|
|
|
+ .collect(Collectors.toMap(WebsitGoods::getGoodsId, Function.identity()));
|
|
|
|
|
|
Map<String, AdminWebsit> websitMap = websitList.stream()
|
|
|
- .collect(Collectors.toMap(AdminWebsit::getName, Function.identity()));
|
|
|
+ .collect(Collectors.toMap(AdminWebsit::getWebsitId, Function.identity()));
|
|
|
|
|
|
Map<String, User> userMap = userList.stream()
|
|
|
.collect(Collectors.toMap(User::getMobile, Function.identity(), (k1, k2) -> k2));
|
|
|
|
|
|
+ Map<String, WebsitUser> websitUserMap = websitUserList.stream()
|
|
|
+ .collect(Collectors.toMap(v -> v.getWebsitId() + v.getUserId(), Function.identity()));
|
|
|
+
|
|
|
Map<String, User> existUserMap = userList.stream()
|
|
|
.collect(Collectors.toMap(User::getUserId, Function.identity()));
|
|
|
|
|
|
+
|
|
|
Map<String, WebsitGoodsCategory> categoryMap = categoryList.stream()
|
|
|
.collect(Collectors.toMap(WebsitGoodsCategory::getCategoryId, Function.identity()));
|
|
|
|
|
@@ -844,37 +847,38 @@ public class WebsitSalesLogic {
|
|
|
throw new RemoteServiceException("第" + (i + 1) + "行, 网点名称不能为空");
|
|
|
}
|
|
|
if (Objects.isNull(row.get(1))) {
|
|
|
- throw new RemoteServiceException("第" + (i + 1) + "行, 师傅联系电话不能为空");
|
|
|
+ throw new RemoteServiceException("第" + (i + 1) + "行, 辅材编号不能为空");
|
|
|
}
|
|
|
if (Objects.isNull(row.get(2))) {
|
|
|
- throw new RemoteServiceException("第" + (i + 1) + "行, 辅材名称不能为空");
|
|
|
- }
|
|
|
- if (Objects.isNull(row.get(3))) {
|
|
|
throw new RemoteServiceException("第" + (i + 1) + "行, 数量不能为空");
|
|
|
}
|
|
|
- if (Objects.isNull(row.get(4))) {
|
|
|
+ if (Objects.isNull(row.get(3))) {
|
|
|
throw new RemoteServiceException("第" + (i + 1) + "行, 销售价格不能为空");
|
|
|
}
|
|
|
+// if (Objects.isNull(row.get(4))) {
|
|
|
+// throw new RemoteServiceException("第" + (i + 1) + "行, 师傅所属网点编号不能为空");
|
|
|
+// }
|
|
|
// if (Objects.isNull(row.get(5))) {
|
|
|
-// throw new RemoteServiceException("第" + (i+1) + "行, 销售时间不能为空");
|
|
|
+// throw new RemoteServiceException("第" + (i + 1) + "行, 师傅联系电话不能为空");
|
|
|
// }
|
|
|
|
|
|
- String websitStr = (String) row.get(0);
|
|
|
- String mobileStr = (String) row.get(1);
|
|
|
- String goodsNameStr = (String) row.get(2);
|
|
|
- String qtyStr = (String) row.get(3);
|
|
|
- String salesPriceStr = (String) row.get(4);
|
|
|
- String customerStr = (String) row.get(5);
|
|
|
- String storageStr = (String) row.get(6);
|
|
|
-
|
|
|
- if (!websitMap.containsKey(websitStr)) {
|
|
|
- throw new RemoteServiceException("第" + (i + 1) + "行, 网点名称不存在");
|
|
|
+ String websitId = StrUtil.trim((String) row.get(0));
|
|
|
+ String goodsId = StrUtil.trim((String) row.get(1));
|
|
|
+ String qtyStr = StrUtil.trim((String) row.get(2));
|
|
|
+ String salesPriceStr = StrUtil.trim((String) row.get(3));
|
|
|
+ String workerWebsitId = StrUtil.trim((String) row.get(4));
|
|
|
+ String mobileStr = StrUtil.trim((String) row.get(5));
|
|
|
+ String customerStr = StrUtil.trim((String) row.get(6));
|
|
|
+ String storageStr = StrUtil.trim((String) row.get(7));
|
|
|
+
|
|
|
+ if (!websitMap.containsKey(websitId)) {
|
|
|
+ throw new RemoteServiceException("第" + (i + 1) + "行, 网点编号不存在");
|
|
|
}
|
|
|
+ if (StringUtils.isBlank(mobileStr)) {
|
|
|
+ throw new RemoteServiceException("第" + (i + 1) + "行, 手机号不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
if (!userMap.containsKey(mobileStr)) {
|
|
|
-// throw new RemoteServiceException("第" + (i+1) + "行, 师傅联系电话不存在");
|
|
|
- if (StringUtils.isBlank(mobileStr)) {
|
|
|
- throw new RemoteServiceException("第" + (i + 1) + "行, 手机号不能为空");
|
|
|
- }
|
|
|
if (StringUtils.isBlank(customerStr)) {
|
|
|
throw new RemoteServiceException("第" + (i + 1) + "行, 客户名称不能为空");
|
|
|
}
|
|
@@ -885,9 +889,18 @@ public class WebsitSalesLogic {
|
|
|
.setMobile(mobileStr);
|
|
|
userMap.put(customerStr + mobileStr, user);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ final User user = userMap.get(mobileStr);
|
|
|
+ if (!websitMap.containsKey(workerWebsitId)) {
|
|
|
+ throw new RemoteServiceException("第" + (i + 1) + "行, 师傅所属网点编号不存在");
|
|
|
+ }
|
|
|
+ if (!websitUserMap.containsKey(workerWebsitId + user.getUserId())) {
|
|
|
+ throw new RemoteServiceException("第" + (i + 1) + "行, 师傅不存在");
|
|
|
+ }
|
|
|
}
|
|
|
- if (!goodsMap.containsKey(goodsNameStr)) {
|
|
|
- throw new RemoteServiceException("第" + (i + 1) + "行, 辅材名称不存在");
|
|
|
+
|
|
|
+ if (!goodsMap.containsKey(goodsId)) {
|
|
|
+ throw new RemoteServiceException("第" + (i + 1) + "行, 辅材编号不存在");
|
|
|
}
|
|
|
BigDecimal qty;
|
|
|
try {
|
|
@@ -911,11 +924,12 @@ public class WebsitSalesLogic {
|
|
|
ImportMaterialSalesBean bean = new ImportMaterialSalesBean();
|
|
|
|
|
|
bean.setIndex(i + 1);
|
|
|
- bean.setAdminWebsit(websitMap.get(websitStr));
|
|
|
+ bean.setAdminWebsit(websitMap.get(websitId));
|
|
|
bean.setUser(userMap.containsKey(mobileStr) ? userMap.get(mobileStr) : userMap.get(customerStr + mobileStr));
|
|
|
- bean.setGoods(goodsMap.get(goodsNameStr));
|
|
|
+ bean.setGoods(goodsMap.get(goodsId));
|
|
|
bean.setQty(qty);
|
|
|
bean.setPrice(salesPrice);
|
|
|
+ bean.setWebsitUser(websitUserMap.getOrDefault(workerWebsitId + bean.getUser().getUserId(), null));
|
|
|
|
|
|
if (StringUtils.isNotBlank(storageStr) && storageMap.containsKey(bean.getAdminWebsit().getWebsitId() + storageStr)) {
|
|
|
bean.setStorageId(storageMap.get(bean.getAdminWebsit().getWebsitId() + storageStr).getStorageId());
|
|
@@ -964,6 +978,8 @@ public class WebsitSalesLogic {
|
|
|
salesBean.setSubmitTime(curDate);
|
|
|
salesBean.setConfirmBy(adminUser.getNickName());
|
|
|
salesBean.setConfirmTime(curDate);
|
|
|
+ salesBean.setWorkerWebsitId(isUser ? importMaterialSalesBean.getWebsitUser().getWebsitId() : null);
|
|
|
+ salesBean.setWorkerWebsitName(isUser ? websitMap.get(salesBean.getWorkerWebsitId()).getName() : null);
|
|
|
|
|
|
if (StringUtils.isNotBlank(importMaterialSalesBean.getStorageId())) {
|
|
|
// 有仓库id
|