|
@@ -499,22 +499,23 @@ public class VendorsServiceImpl implements VendorService {
|
|
|
/**
|
|
/**
|
|
|
* 为用户分配供应商
|
|
* 为用户分配供应商
|
|
|
*
|
|
*
|
|
|
- * @param userUU 用户UU
|
|
|
|
|
- * @param vendors 供应商客户
|
|
|
|
|
|
|
+ * @param id 供应商Id
|
|
|
|
|
+ * @param userList 用户
|
|
|
* @return 分配结果 成功或失败
|
|
* @return 分配结果 成功或失败
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public boolean bindVendorToUser(Long userUU, List<Vendor> vendors) {
|
|
|
|
|
- if (!CollectionUtils.isEmpty(vendors)) {
|
|
|
|
|
|
|
+ public boolean bindVendorToUser(Long id, List<User> userList) {
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(userList)) {
|
|
|
List<VendorDistribute> needSaveOrUpdateList = new ArrayList<>();
|
|
List<VendorDistribute> needSaveOrUpdateList = new ArrayList<>();
|
|
|
List<VendorDistribute> needDeleteList = new ArrayList<>();
|
|
List<VendorDistribute> needDeleteList = new ArrayList<>();
|
|
|
- for (Vendor vendor : vendors) {
|
|
|
|
|
|
|
+ for (User user : userList) {
|
|
|
|
|
+ Long userUU = user.getUserUU();
|
|
|
VendorDistribute distribute = new VendorDistribute();
|
|
VendorDistribute distribute = new VendorDistribute();
|
|
|
- if (vendor.getDistribute()) {
|
|
|
|
|
- List<VendorDistribute> distributes = vendorDistributeDao.findByUserUUAndVendorId(userUU, vendor.getId());
|
|
|
|
|
|
|
+ if (user.getDistribute()) {
|
|
|
|
|
+ List<VendorDistribute> distributes = vendorDistributeDao.findByUserUUAndVendorId(userUU, id);
|
|
|
if (CollectionUtils.isEmpty(distributes)) {
|
|
if (CollectionUtils.isEmpty(distributes)) {
|
|
|
distribute.setUserUU(userUU);
|
|
distribute.setUserUU(userUU);
|
|
|
- distribute.setVendorId(vendor.getId());
|
|
|
|
|
|
|
+ distribute.setVendorId(id);
|
|
|
distribute.setDistribute(Constant.YES);
|
|
distribute.setDistribute(Constant.YES);
|
|
|
needSaveOrUpdateList.add(distribute);
|
|
needSaveOrUpdateList.add(distribute);
|
|
|
} else {
|
|
} else {
|
|
@@ -523,7 +524,7 @@ public class VendorsServiceImpl implements VendorService {
|
|
|
needSaveOrUpdateList.add(distribute);
|
|
needSaveOrUpdateList.add(distribute);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- List<VendorDistribute> distributes = vendorDistributeDao.findByUserUUAndVendorId(userUU, vendor.getId());
|
|
|
|
|
|
|
+ List<VendorDistribute> distributes = vendorDistributeDao.findByUserUUAndVendorId(userUU, id);
|
|
|
if (!CollectionUtils.isEmpty(distributes)) {
|
|
if (!CollectionUtils.isEmpty(distributes)) {
|
|
|
/*
|
|
/*
|
|
|
* 判断分配和权限转移关系
|
|
* 判断分配和权限转移关系
|
|
@@ -554,24 +555,24 @@ public class VendorsServiceImpl implements VendorService {
|
|
|
/**
|
|
/**
|
|
|
* 供应商权限转移
|
|
* 供应商权限转移
|
|
|
*
|
|
*
|
|
|
- * @param vendorUU 供应商UU
|
|
|
|
|
|
|
+ * @param id 供应商关系id
|
|
|
* @param users 前端选择用户信息
|
|
* @param users 前端选择用户信息
|
|
|
* @return 转移结果
|
|
* @return 转移结果
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public boolean transferVendorToUser(Long vendorUU, List<User> users) {
|
|
|
|
|
- List<Vendor> vendors = vendorDao.findByMyEnUUAndVendUU(SystemSession.getUser().getEnterprise().getUu(), vendorUU);
|
|
|
|
|
|
|
+ public boolean transferVendorToUser(Long id, List<User> users) {
|
|
|
|
|
+ Vendor vendor = vendorDao.findOne(id);
|
|
|
if (!CollectionUtils.isEmpty(users)) {
|
|
if (!CollectionUtils.isEmpty(users)) {
|
|
|
List<VendorDistribute> saveList = new ArrayList<>();
|
|
List<VendorDistribute> saveList = new ArrayList<>();
|
|
|
for (User u : users) {
|
|
for (User u : users) {
|
|
|
List<VendorDistribute> deleteList = new ArrayList<>();
|
|
List<VendorDistribute> deleteList = new ArrayList<>();
|
|
|
if (null != u.getUserUU()) {
|
|
if (null != u.getUserUU()) {
|
|
|
VendorDistribute distribute = new VendorDistribute();
|
|
VendorDistribute distribute = new VendorDistribute();
|
|
|
- List<VendorDistribute> distributes = vendorDistributeDao.findByUserUUAndVendorId(u.getUserUU(), vendors.get(0).getId());
|
|
|
|
|
|
|
+ List<VendorDistribute> distributes = vendorDistributeDao.findByUserUUAndVendorId(u.getUserUU(), vendor.getId());
|
|
|
if (u.getTransfer()) {
|
|
if (u.getTransfer()) {
|
|
|
if (CollectionUtils.isEmpty(distributes)) {
|
|
if (CollectionUtils.isEmpty(distributes)) {
|
|
|
distribute.setUserUU(u.getUserUU());
|
|
distribute.setUserUU(u.getUserUU());
|
|
|
- distribute.setVendorId(vendors.get(0).getId());
|
|
|
|
|
|
|
+ distribute.setVendorId(vendor.getId());
|
|
|
distribute.setLeaderUU(SystemSession.getUser().getUserUU());
|
|
distribute.setLeaderUU(SystemSession.getUser().getUserUU());
|
|
|
distribute.setIsTransfer(Constant.YES);
|
|
distribute.setIsTransfer(Constant.YES);
|
|
|
saveList.add(distribute);
|
|
saveList.add(distribute);
|
|
@@ -586,7 +587,7 @@ public class VendorsServiceImpl implements VendorService {
|
|
|
if (!CollectionUtils.isEmpty(distributes)) {
|
|
if (!CollectionUtils.isEmpty(distributes)) {
|
|
|
// 当前用户
|
|
// 当前用户
|
|
|
deleteList.add(distributes.get(0));
|
|
deleteList.add(distributes.get(0));
|
|
|
- Long vendorId = vendors.get(0).getId();
|
|
|
|
|
|
|
+ Long vendorId = vendor.getId();
|
|
|
Long userUU = u.getUserUU();
|
|
Long userUU = u.getUserUU();
|
|
|
if (null != distributes.get(0).getIsTransfer() && 1 == distributes.get(0).getIsTransfer()) {
|
|
if (null != distributes.get(0).getIsTransfer() && 1 == distributes.get(0).getIsTransfer()) {
|
|
|
deleteList = deleteChildrenDistributes(vendorId, userUU, deleteList);
|
|
deleteList = deleteChildrenDistributes(vendorId, userUU, deleteList);
|