|
@@ -1,6 +1,6 @@
|
|
|
package com.gree.mall.manager.logic.user;
|
|
package com.gree.mall.manager.logic.user;
|
|
|
|
|
|
|
|
-import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
@@ -14,17 +14,11 @@ import com.gree.mall.manager.bean.listvo.User2VO;
|
|
|
import com.gree.mall.manager.bean.listvo.UserCustomerVO;
|
|
import com.gree.mall.manager.bean.listvo.UserCustomerVO;
|
|
|
import com.gree.mall.manager.bean.listvo.UserVO;
|
|
import com.gree.mall.manager.bean.listvo.UserVO;
|
|
|
import com.gree.mall.manager.bean.listvo.workorder.UserWaitVO;
|
|
import com.gree.mall.manager.bean.listvo.workorder.UserWaitVO;
|
|
|
-import com.gree.mall.manager.bean.member.MemberSortBean;
|
|
|
|
|
-import com.gree.mall.manager.bean.member.UserApplyBean;
|
|
|
|
|
-import com.gree.mall.manager.bean.member.UserCompanyAttrBean;
|
|
|
|
|
-import com.gree.mall.manager.bean.member.UserCompanyDeliveryBean;
|
|
|
|
|
-import com.gree.mall.manager.bean.user.UserApplyWorkerBean;
|
|
|
|
|
-import com.gree.mall.manager.bean.user.UserDetailBean;
|
|
|
|
|
|
|
+import com.gree.mall.manager.bean.member.*;
|
|
|
import com.gree.mall.manager.bean.user.UserWxBean;
|
|
import com.gree.mall.manager.bean.user.UserWxBean;
|
|
|
import com.gree.mall.manager.commonmapper.*;
|
|
import com.gree.mall.manager.commonmapper.*;
|
|
|
import com.gree.mall.manager.enums.ExamineStatusEnum;
|
|
import com.gree.mall.manager.enums.ExamineStatusEnum;
|
|
|
import com.gree.mall.manager.enums.UserTypeEnum;
|
|
import com.gree.mall.manager.enums.UserTypeEnum;
|
|
|
-import com.gree.mall.manager.enums.admin.AdminWebsitTypeEnum;
|
|
|
|
|
import com.gree.mall.manager.exception.RemoteServiceException;
|
|
import com.gree.mall.manager.exception.RemoteServiceException;
|
|
|
import com.gree.mall.manager.logic.common.CommonLogic;
|
|
import com.gree.mall.manager.logic.common.CommonLogic;
|
|
|
import com.gree.mall.manager.logic.coupon.CouponLogic;
|
|
import com.gree.mall.manager.logic.coupon.CouponLogic;
|
|
@@ -32,9 +26,7 @@ import com.gree.mall.manager.logic.order.OrderShareLogic;
|
|
|
import com.gree.mall.manager.plus.entity.*;
|
|
import com.gree.mall.manager.plus.entity.*;
|
|
|
import com.gree.mall.manager.plus.service.*;
|
|
import com.gree.mall.manager.plus.service.*;
|
|
|
import com.gree.mall.manager.utils.CommonUtils;
|
|
import com.gree.mall.manager.utils.CommonUtils;
|
|
|
-import com.gree.mall.manager.utils.RedisUtil;
|
|
|
|
|
import com.gree.mall.manager.utils.StringUtil;
|
|
import com.gree.mall.manager.utils.StringUtil;
|
|
|
-import com.gree.mall.manager.utils.excel.ExcelUtils;
|
|
|
|
|
import com.gree.mall.manager.zfire.bean.WorkerParamBean;
|
|
import com.gree.mall.manager.zfire.bean.WorkerParamBean;
|
|
|
import com.gree.mall.manager.zfire.bean.ZfireParamBean;
|
|
import com.gree.mall.manager.zfire.bean.ZfireParamBean;
|
|
|
import com.gree.mall.manager.zfire.util.FieldUtils;
|
|
import com.gree.mall.manager.zfire.util.FieldUtils;
|
|
@@ -46,14 +38,10 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
-import java.io.IOException;
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
-import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -79,6 +67,7 @@ public class UserLogic {
|
|
|
private final UserCompanyDeliveryService userCompanyDeliveryService;
|
|
private final UserCompanyDeliveryService userCompanyDeliveryService;
|
|
|
private final UserCompanyAttrService userCompanyAttrService;
|
|
private final UserCompanyAttrService userCompanyAttrService;
|
|
|
private final StorageService storageService;
|
|
private final StorageService storageService;
|
|
|
|
|
+ private final UserCompanyDeliveryRelaService userCompanyDeliveryRelaService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 客户列表-v2
|
|
* 客户列表-v2
|
|
@@ -460,105 +449,109 @@ public class UserLogic {
|
|
|
.set(UserWait::getMobile,userWait.getMobile()).update();
|
|
.set(UserWait::getMobile,userWait.getMobile()).update();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public IPage<UserCompanyDeliveryBean> companyDelivery(String nickName, String mobile, Integer pageNum, Integer pageSize) {
|
|
|
|
|
- AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
|
|
- return commonMapper.companyDelivery(new Page<>(pageNum, pageSize), adminUser.getCompanyWechatId(), nickName, mobile);
|
|
|
|
|
|
|
+ public IPage<UserCompanyDeliveryVO> companyDelivery(ZfireParamBean zfireParamBean) {
|
|
|
|
|
+ FieldUtils.supplyParam(zfireParamBean, UserWaitVO.class, commonLogic.getAdminUser());
|
|
|
|
|
+ return commonMapper.companyDelivery(new Page<>(zfireParamBean.getPageNum(), zfireParamBean.getPageSize()), zfireParamBean);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void companyDeliveryImport(List<Object> datas) {
|
|
|
|
|
|
|
+ public UserCompanyDeliveryAddBean companyDeliveryDetail(String userId) {
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
- if (StringUtils.isBlank(adminUser.getCompanyWechatId())) {
|
|
|
|
|
- throw new RemoteServiceException("管理员账号不可操作");
|
|
|
|
|
- }
|
|
|
|
|
- int index = 1;
|
|
|
|
|
-
|
|
|
|
|
- final DateTime curDate = DateUtil.date();
|
|
|
|
|
-
|
|
|
|
|
- List<UserCompanyDelivery> userCompanyDeliveryList = new ArrayList<>();
|
|
|
|
|
- for (Object o : datas) {
|
|
|
|
|
- index++;
|
|
|
|
|
- String errPrefix = "第" + index + "行";
|
|
|
|
|
- List<Object> row = (List<Object>) o;
|
|
|
|
|
- CommonUtils.initList2(row, 10);
|
|
|
|
|
- String mobile = (String) row.get(0);
|
|
|
|
|
-
|
|
|
|
|
- if (StringUtils.isAnyBlank(mobile)) {
|
|
|
|
|
- throw new RemoteServiceException(errPrefix + "黄色区域为必填项");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- final User user = userService.lambdaQuery()
|
|
|
|
|
- .eq(User::getMobile, mobile)
|
|
|
|
|
- .one();
|
|
|
|
|
-
|
|
|
|
|
- if (Objects.isNull(user)) {
|
|
|
|
|
- throw new RemoteServiceException(errPrefix + " 没有找到对应师傅信息");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- final Integer count = userCompanyDeliveryService.lambdaQuery()
|
|
|
|
|
- .eq(UserCompanyDelivery::getUserId, user.getUserId())
|
|
|
|
|
- .eq(UserCompanyDelivery::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
|
|
- .count();
|
|
|
|
|
|
|
+ final User user = userService.getById(userId);
|
|
|
|
|
+ final List<UserCompanyDeliveryRela> relaList = userCompanyDeliveryRelaService.lambdaQuery()
|
|
|
|
|
+ .select(UserCompanyDeliveryRela::getStorageId)
|
|
|
|
|
+ .eq(UserCompanyDeliveryRela::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
|
|
+ .eq(UserCompanyDeliveryRela::getUserId, userId)
|
|
|
|
|
+ .list();
|
|
|
|
|
|
|
|
- if (count > 0) {
|
|
|
|
|
- throw new RemoteServiceException(errPrefix + " " + mobile + "已是配送员");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- UserCompanyDelivery delivery = new UserCompanyDelivery();
|
|
|
|
|
- delivery.setCompanyWechatId(adminUser.getCompanyWechatId())
|
|
|
|
|
- .setUserId(user.getUserId())
|
|
|
|
|
- .setId(IdWorker.getIdStr())
|
|
|
|
|
- .setCreateTime(curDate);
|
|
|
|
|
-
|
|
|
|
|
- userCompanyDeliveryList.add(delivery);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ UserCompanyDeliveryAddBean bean = new UserCompanyDeliveryAddBean();
|
|
|
|
|
|
|
|
|
|
+ bean.setUserId(userId)
|
|
|
|
|
+ .setNickName(user.getNickName())
|
|
|
|
|
+ .setMobile(user.getMobile())
|
|
|
|
|
+ .setStorageIds(relaList.stream().map(UserCompanyDeliveryRela::getStorageId).collect(Collectors.toList()));
|
|
|
|
|
|
|
|
- userCompanyDeliveryService.saveBatch(userCompanyDeliveryList);
|
|
|
|
|
|
|
+ return bean;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
|
- public void companyDeliveryAdd(String mobile, String nickName, String storageId) {
|
|
|
|
|
|
|
+ public void companyDeliveryAdd(UserCompanyDeliveryAddBean bean) {
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
- UserCompanyDelivery delivery = new UserCompanyDelivery();
|
|
|
|
|
-
|
|
|
|
|
- final Storage storage = storageService.getById(storageId);
|
|
|
|
|
-
|
|
|
|
|
- if (Objects.isNull(storage)) {
|
|
|
|
|
- throw new RemoteServiceException("仓储信息错误");
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
User user = userService.lambdaQuery()
|
|
User user = userService.lambdaQuery()
|
|
|
- .eq(User::getMobile, mobile)
|
|
|
|
|
|
|
+ .eq(User::getMobile, bean.getMobile())
|
|
|
.one();
|
|
.one();
|
|
|
|
|
|
|
|
if (Objects.isNull(user)) {
|
|
if (Objects.isNull(user)) {
|
|
|
|
|
+ // 没有生成数据到user表
|
|
|
final String userId = IdWorker.getIdStr();
|
|
final String userId = IdWorker.getIdStr();
|
|
|
user = new User()
|
|
user = new User()
|
|
|
.setUserId(userId)
|
|
.setUserId(userId)
|
|
|
- .setMobile(mobile)
|
|
|
|
|
- .setNickName(nickName)
|
|
|
|
|
|
|
+ .setMobile(bean.getMobile())
|
|
|
|
|
+ .setNickName(bean.getNickName())
|
|
|
.setWorkerNumber(userId)
|
|
.setWorkerNumber(userId)
|
|
|
.setOpenId(userId)
|
|
.setOpenId(userId)
|
|
|
.setType(UserTypeEnum.WORKER.getKey());
|
|
.setType(UserTypeEnum.WORKER.getKey());
|
|
|
|
|
|
|
|
user.insert();
|
|
user.insert();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ final Integer count = userCompanyDeliveryService.lambdaQuery()
|
|
|
|
|
+ .eq(UserCompanyDelivery::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
|
|
+ .eq(UserCompanyDelivery::getUserId, user.getUserId())
|
|
|
|
|
+ .count();
|
|
|
|
|
+
|
|
|
|
|
+ if (count > 0) {
|
|
|
|
|
+ throw new RemoteServiceException("配送员重复添加,请检查");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ UserCompanyDelivery delivery = new UserCompanyDelivery();
|
|
|
|
|
+
|
|
|
delivery.setCompanyWechatId(adminUser.getCompanyWechatId())
|
|
delivery.setCompanyWechatId(adminUser.getCompanyWechatId())
|
|
|
.setUserId(user.getUserId())
|
|
.setUserId(user.getUserId())
|
|
|
- .setId(IdWorker.getIdStr())
|
|
|
|
|
- .setCreateTime(DateUtil.date())
|
|
|
|
|
- .setStorageId(storageId)
|
|
|
|
|
|
|
+ .setAllStorage(CollectionUtil.isEmpty(bean.getStorageIds()))
|
|
|
.insert();
|
|
.insert();
|
|
|
|
|
+
|
|
|
|
|
+ List<UserCompanyDeliveryRela> relaList = new ArrayList<>();
|
|
|
|
|
+ if (delivery.getAllStorage()) {
|
|
|
|
|
+ // 全部仓储
|
|
|
|
|
+ final List<Storage> storages = storageService.lambdaQuery()
|
|
|
|
|
+ .eq(Storage::getCompanyWechatId, delivery.getCompanyWechatId())
|
|
|
|
|
+ .list();
|
|
|
|
|
+ for (Storage storage : storages) {
|
|
|
|
|
+ UserCompanyDeliveryRela rela = new UserCompanyDeliveryRela();
|
|
|
|
|
+ rela.setUserId(user.getUserId())
|
|
|
|
|
+ .setCompanyWechatId(delivery.getCompanyWechatId())
|
|
|
|
|
+ .setStorageId(storage.getStorageId());
|
|
|
|
|
+ relaList.add(rela);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ for (String storageId : bean.getStorageIds()) {
|
|
|
|
|
+ UserCompanyDeliveryRela rela = new UserCompanyDeliveryRela();
|
|
|
|
|
+ rela.setUserId(user.getUserId())
|
|
|
|
|
+ .setCompanyWechatId(delivery.getCompanyWechatId())
|
|
|
|
|
+ .setStorageId(storageId);
|
|
|
|
|
+ relaList.add(rela);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ userCompanyDeliveryRelaService.saveBatch(relaList);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Transactional
|
|
|
public void companyDeliveryDel(String userId) {
|
|
public void companyDeliveryDel(String userId) {
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
|
|
|
|
|
|
|
+ // 删除配送员记录
|
|
|
userCompanyDeliveryService.lambdaUpdate()
|
|
userCompanyDeliveryService.lambdaUpdate()
|
|
|
.eq(UserCompanyDelivery::getUserId, userId)
|
|
.eq(UserCompanyDelivery::getUserId, userId)
|
|
|
.eq(UserCompanyDelivery::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
.eq(UserCompanyDelivery::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
.remove();
|
|
.remove();
|
|
|
|
|
+
|
|
|
|
|
+ // 删除关系表
|
|
|
|
|
+ userCompanyDeliveryRelaService.lambdaUpdate()
|
|
|
|
|
+ .eq(UserCompanyDeliveryRela::getUserId, userId)
|
|
|
|
|
+ .eq(UserCompanyDeliveryRela::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
|
|
+ .remove();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public IPage<UserCompanyAttrBean> companyCredit(String nickName, String mobile, Integer pageNum, Integer pageSize) {
|
|
public IPage<UserCompanyAttrBean> companyCredit(String nickName, String mobile, Integer pageNum, Integer pageSize) {
|