TASK:获取affiliate的用户名和id;BUGFIX:模特无法保存
This commit is contained in:
@@ -22,6 +22,7 @@ import javax.annotation.Resource;
|
|||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@@ -100,7 +101,7 @@ public class AffiliateController {
|
|||||||
return Response.success(affiliateService.getEachAffiliateGeneratedRevenue(affiliateQueryDTO));
|
return Response.success(affiliateService.getEachAffiliateGeneratedRevenue(affiliateQueryDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "获取所有的referral")
|
@ApiOperation(value = "分页获取所有的referral")
|
||||||
@PostMapping("/getReferrals")
|
@PostMapping("/getReferrals")
|
||||||
public Response<IPage<ReferralPageQueryVO>> getReferrals(@RequestBody ReferralPageQueryDTO referralPageQueryDTO) {
|
public Response<IPage<ReferralPageQueryVO>> getReferrals(@RequestBody ReferralPageQueryDTO referralPageQueryDTO) {
|
||||||
return Response.success(referralService.queryByPage(referralPageQueryDTO));
|
return Response.success(referralService.queryByPage(referralPageQueryDTO));
|
||||||
@@ -120,5 +121,11 @@ public class AffiliateController {
|
|||||||
return Response.success();
|
return Response.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取所有affiliate用户名")
|
||||||
|
@GetMapping("/getAllAffiliateUsername")
|
||||||
|
public Response<List<Map<String, Object>>> getAllAffiliateUsername() {
|
||||||
|
return Response.success(affiliateService.getAllAffiliateUsername());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,4 +16,6 @@ public interface AffiliateMapper extends BaseMapper<Affiliate> {
|
|||||||
|
|
||||||
int queryAffiliateTotalCount(String status, String startTime, String endTime, Long affiliateId);
|
int queryAffiliateTotalCount(String status, String startTime, String endTime, Long affiliateId);
|
||||||
|
|
||||||
|
List<Map<String, Object>> selectAllAffiliateUsername();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public interface AffiliateService extends IService<Affiliate> {
|
public interface AffiliateService extends IService<Affiliate> {
|
||||||
|
|
||||||
@@ -37,4 +39,6 @@ public interface AffiliateService extends IService<Affiliate> {
|
|||||||
void commissionCalculation(Integer year, Integer month);
|
void commissionCalculation(Integer year, Integer month);
|
||||||
|
|
||||||
void calcCouponsCommission();
|
void calcCouponsCommission();
|
||||||
|
|
||||||
|
List<Map<String, Object>> getAllAffiliateUsername();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -439,5 +439,10 @@ public class AffiliateServiceImpl extends ServiceImpl<AffiliateMapper, Affiliate
|
|||||||
redisUtil.addToString(RedisUtil.PAYMENT_INFO_LAST_SCAN_TIME, currentTime);
|
redisUtil.addToString(RedisUtil.PAYMENT_INFO_LAST_SCAN_TIME, currentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> getAllAffiliateUsername(){
|
||||||
|
return baseMapper.selectAllAffiliateUsername();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2555,47 +2555,62 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (CollectionUtil.isNotEmpty(moduleSaveDTO.getMannequin())) {
|
if (CollectionUtil.isNotEmpty(moduleSaveDTO.getMannequin())) {
|
||||||
|
// 目前已有的模特
|
||||||
List<CollectionElementRelModel> collectionElementRelModels = collectionElementMapper.selectByProject(projectId);
|
List<CollectionElementRelModel> collectionElementRelModels = collectionElementMapper.selectByProject(projectId);
|
||||||
|
// 入参中的模特
|
||||||
List<MannequinDTO> mannequin = moduleSaveDTO.getMannequin();
|
List<MannequinDTO> mannequin = moduleSaveDTO.getMannequin();
|
||||||
List<Long> inputMannequinId = mannequin.stream().map(MannequinDTO::getCollectionElementId).collect(Collectors.toList());
|
|
||||||
|
// 新增的模特只有id,没有collectionElementId
|
||||||
|
List<Long> inputMannequinIds = mannequin.stream().map(MannequinDTO::getId).collect(Collectors.toList());
|
||||||
|
// 既有id又有collectionElementId的,为保持原状的模特(都没有的且又存在于数据库的,即为被删除的模特)
|
||||||
|
List<Long> inputCollectionElementIds = mannequin.stream().map(MannequinDTO::getCollectionElementId).collect(Collectors.toList());
|
||||||
|
|
||||||
// 创建relationId到Model的映射
|
// 创建relationId到Model的映射
|
||||||
Map<Long, CollectionElementRelModel> relationIdToModelMap = collectionElementRelModels.stream()
|
Map<Long, CollectionElementRelModel> relationIdToModelMap = collectionElementRelModels.stream()
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
CollectionElementRelModel::getRelationId,
|
||||||
|
java.util.function.Function.identity(),
|
||||||
|
(existing, replacement) -> existing
|
||||||
|
));
|
||||||
|
// 创建collectionElementId到Model的映射
|
||||||
|
Map<Long, CollectionElementRelModel> collectionElementToModelMap = collectionElementRelModels.stream()
|
||||||
.collect(Collectors.toMap(
|
.collect(Collectors.toMap(
|
||||||
CollectionElementRelModel::getCollectionElementId,
|
CollectionElementRelModel::getCollectionElementId,
|
||||||
java.util.function.Function.identity(),
|
java.util.function.Function.identity(),
|
||||||
(existing, replacement) -> existing
|
(existing, replacement) -> existing
|
||||||
));
|
));
|
||||||
List<Long> newReletionIds = new ArrayList<>();
|
List<Long> newReletionIds = new ArrayList<>();
|
||||||
List<Long> toBeDeletedRelationIds = new ArrayList<>();
|
List<Long> toBeDeletedCollectionElementIds = new ArrayList<>();
|
||||||
|
|
||||||
if (collectionElementRelModels.isEmpty()) {
|
if (collectionElementRelModels.isEmpty()) {
|
||||||
// 如果原本没有记录,所有输入的Mannequin都是新的
|
// 如果原本没有记录,所有输入的Mannequin都是新的
|
||||||
newReletionIds = inputMannequinId;
|
newReletionIds = inputMannequinIds;
|
||||||
} else {
|
} else {
|
||||||
// 获取所有已有的relationId集合
|
// 获取db中所有的relationId集合
|
||||||
Set<Long> relationIds = relationIdToModelMap.keySet();
|
Set<Long> relationIds = relationIdToModelMap.keySet();
|
||||||
|
// 获取db中所有的collectionElementId集合
|
||||||
|
Set<Long> collectionElementIds = collectionElementToModelMap.keySet();
|
||||||
|
|
||||||
// 1. 找出需要删除的:relationIds中有但inputMannequinId中没有的
|
// 1. 找出需要删除的:collectionElementIds中有但inputCollectionElementIds中没有的
|
||||||
toBeDeletedRelationIds = relationIds.stream()
|
toBeDeletedCollectionElementIds = collectionElementIds.stream()
|
||||||
.filter(id -> !inputMannequinId.contains(id))
|
.filter(id -> !inputCollectionElementIds.contains(id))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
// 2. 找出新增的:inputMannequinId中有但relationIds中没有的
|
// 2. 找出新增的:inputMannequinId中有但relationIds中没有的(一定程度避免重复)
|
||||||
newReletionIds = inputMannequinId.stream()
|
newReletionIds = inputMannequinIds.stream()
|
||||||
.filter(id -> !relationIds.contains(id))
|
.filter(id -> !relationIds.contains(id))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!toBeDeletedRelationIds.isEmpty()){
|
if (!toBeDeletedCollectionElementIds.isEmpty()){
|
||||||
Set<Long> toBeDeletedElementIdList = toBeDeletedRelationIds.stream()
|
/*Set<Long> toBeDeletedElementIdList = toBeDeletedCollectionElementIds.stream()
|
||||||
.map(relationIdToModelMap::get) // 获取对应的Model
|
.map(relationIdToModelMap::get) // 获取对应的Model
|
||||||
.filter(Objects::nonNull) // 过滤掉可能为null的情况
|
.filter(Objects::nonNull) // 过滤掉可能为null的情况
|
||||||
.map(CollectionElementRelModel::getCollectionElementId) // 提取collectionElementId
|
.map(CollectionElementRelModel::getCollectionElementId) // 提取collectionElementId
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());*/
|
||||||
collectionElementMapper.deleteBatchIds(toBeDeletedElementIdList);
|
collectionElementMapper.deleteBatchIds(toBeDeletedCollectionElementIds);
|
||||||
// 删除关联关系
|
// 删除关联关系
|
||||||
deleteByCollectionElementIdList(toBeDeletedElementIdList);
|
deleteByCollectionElementIdList(toBeDeletedCollectionElementIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MannequinDTO dto : mannequin) {
|
for (MannequinDTO dto : mannequin) {
|
||||||
@@ -2678,7 +2693,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteByCollectionElementIdList(Set<Long> old) {
|
private void deleteByCollectionElementIdList(java.util.Collection<Long> old) {
|
||||||
QueryWrapper<CollectionElementRelModel> qw = new QueryWrapper<>();
|
QueryWrapper<CollectionElementRelModel> qw = new QueryWrapper<>();
|
||||||
qw.lambda().in(CollectionElementRelModel::getCollectionElementId, old);
|
qw.lambda().in(CollectionElementRelModel::getCollectionElementId, old);
|
||||||
collectionElementRelModelMapper.delete(qw);
|
collectionElementRelModelMapper.delete(qw);
|
||||||
|
|||||||
@@ -84,4 +84,13 @@
|
|||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectAllAffiliateUsername" resultType="java.util.Map">
|
||||||
|
SELECT
|
||||||
|
af.id,
|
||||||
|
ac.user_name as username
|
||||||
|
FROM t_affiliate af
|
||||||
|
LEFT JOIN t_account ac ON af.account_id = ac.id
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user