|
@@ -14,7 +14,6 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
@Service
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
|
public class CompanyCollectionService {
|
|
public class CompanyCollectionService {
|
|
@@ -22,8 +21,8 @@ public class CompanyCollectionService {
|
|
|
private CompanyCollectionRepo companyCollectionRepo;
|
|
private CompanyCollectionRepo companyCollectionRepo;
|
|
|
private CollectionRepo collectionRepo;
|
|
private CollectionRepo collectionRepo;
|
|
|
private UserRepo userRepo;
|
|
private UserRepo userRepo;
|
|
|
- private ShowroomRepo showroomRepo;
|
|
|
|
|
private CollectionPrivilegeRepo collectionPrivilegeRepo;
|
|
private CollectionPrivilegeRepo collectionPrivilegeRepo;
|
|
|
|
|
+ private SysConfigService sysConfigService;
|
|
|
|
|
|
|
|
public Page<CompanyCollection> all(PageQuery pageQuery) {
|
|
public Page<CompanyCollection> all(PageQuery pageQuery) {
|
|
|
return companyCollectionRepo.findAll(JpaUtils.toSpecification(pageQuery, CompanyCollection.class), JpaUtils.toPageRequest(pageQuery));
|
|
return companyCollectionRepo.findAll(JpaUtils.toSpecification(pageQuery, CompanyCollection.class), JpaUtils.toPageRequest(pageQuery));
|
|
@@ -33,14 +32,17 @@ public class CompanyCollectionService {
|
|
|
CompanyCollection companyCollection = companyCollectionRepo.findById(id)
|
|
CompanyCollection companyCollection = companyCollectionRepo.findById(id)
|
|
|
.orElseThrow(new BusinessException("无申请"));
|
|
.orElseThrow(new BusinessException("无申请"));
|
|
|
|
|
|
|
|
|
|
+
|
|
|
if (!CollectionStatus.PENDING.equals(companyCollection.getStatus())) {
|
|
if (!CollectionStatus.PENDING.equals(companyCollection.getStatus())) {
|
|
|
throw new BusinessException("已审核");
|
|
throw new BusinessException("已审核");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
companyCollection.setStatus(status);
|
|
companyCollection.setStatus(status);
|
|
|
companyCollection.setReason(reason);
|
|
companyCollection.setReason(reason);
|
|
|
- companyCollectionRepo.save(companyCollection);
|
|
|
|
|
|
|
+
|
|
|
if (CollectionStatus.FAIL.equals(status)) {
|
|
if (CollectionStatus.FAIL.equals(status)) {
|
|
|
|
|
+ //存状态
|
|
|
|
|
+ companyCollectionRepo.save(companyCollection);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -50,7 +52,7 @@ public class CompanyCollectionService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Collection collection = new Collection();
|
|
Collection collection = new Collection();
|
|
|
- BeanUtils.copyProperties(collection, companyCollection);
|
|
|
|
|
|
|
+ BeanUtils.copyProperties(companyCollection, collection);
|
|
|
collection.setSource(CollectionSource.COMPANY);
|
|
collection.setSource(CollectionSource.COMPANY);
|
|
|
collection.setType(CollectionType.DEFAULT);
|
|
collection.setType(CollectionType.DEFAULT);
|
|
|
collection.setStock(companyCollection.getTotal());
|
|
collection.setStock(companyCollection.getTotal());
|
|
@@ -65,16 +67,22 @@ public class CompanyCollectionService {
|
|
|
collection.setOwnerId(userId);
|
|
collection.setOwnerId(userId);
|
|
|
collection.setOwnerAvatar(user.getAvatar());
|
|
collection.setOwnerAvatar(user.getAvatar());
|
|
|
|
|
|
|
|
- Showroom showroom = showroomRepo.findFirstByUserId(userId);
|
|
|
|
|
- collection.setRoyalties(showroom.getRoyalties());
|
|
|
|
|
- collection.setServiceCharge(showroom.getServiceCharge());
|
|
|
|
|
|
|
+// Showroom showroom = showroomRepo.findFirstByUserId(userId);
|
|
|
|
|
+ int royalties = sysConfigService.getInt("royalties");
|
|
|
|
|
+ int serviceCharge = sysConfigService.getInt("serviceCharge");
|
|
|
|
|
+ collection.setRoyalties(royalties);
|
|
|
|
|
+ collection.setServiceCharge(serviceCharge);
|
|
|
|
|
+ collection.setId(null);
|
|
|
collection = collectionRepo.save(collection);
|
|
collection = collectionRepo.save(collection);
|
|
|
|
|
|
|
|
|
|
+ //企业属性
|
|
|
collectionPrivilegeRepo.save(CollectionPrivilege.builder()
|
|
collectionPrivilegeRepo.save(CollectionPrivilege.builder()
|
|
|
.collectionId(collection.getId())
|
|
.collectionId(collection.getId())
|
|
|
.companyCollectionId(id)
|
|
.companyCollectionId(id)
|
|
|
.build());
|
|
.build());
|
|
|
|
|
|
|
|
|
|
+ //存状态
|
|
|
|
|
+ companyCollectionRepo.save(companyCollection);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|