14 changed files with 374 additions and 3 deletions
Unified View
Diff Options
-
37dating-agency-mall-constant/src/main/java/com/qniao/dam/domian/aggregate/pcur/constant/CardUsageTyepEnum.java
-
31dating-agency-mall-server/src/main/java/com/qniao/dam/api/command/pcur/user/ProfileCardUsageRecordUserCommandController.java
-
19dating-agency-mall-server/src/main/java/com/qniao/dam/api/command/pcur/user/request/UserUseProfileCardDto.java
-
15dating-agency-mall-server/src/main/java/com/qniao/dam/api/command/pcur/user/response/UserUseProfileCardVo.java
-
2dating-agency-mall-server/src/main/java/com/qniao/dam/api/command/right/user/RightUserCommandController.java
-
66dating-agency-mall-server/src/main/java/com/qniao/dam/application/service/pcur/ProfileCardUsageRecordApplicationService.java
-
21dating-agency-mall-server/src/main/java/com/qniao/dam/application/service/right/RightApplicationService.java
-
31dating-agency-mall-server/src/main/java/com/qniao/dam/domain/aggregate/pcur/ProfileCardUsageRecordAggregate.java
-
46dating-agency-mall-server/src/main/java/com/qniao/dam/domain/aggregate/pcur/entity/ProfileCardUsageRecord.java
-
12dating-agency-mall-server/src/main/java/com/qniao/dam/domain/aggregate/pcur/repository/ProfileCardUsageRecordRepository.java
-
12dating-agency-mall-server/src/main/java/com/qniao/dam/infrastructure/persistent/dao/pcur/ProfileCardUsageRecordDao.java
-
41dating-agency-mall-server/src/main/java/com/qniao/dam/infrastructure/persistent/repository/impl/ProfileCardUsageRecordRepositoryImpl.java
-
10dating-agency-mall-server/src/main/java/com/qniao/dam/query/pcur/ProfileCardUsageRecordQueryService.java
-
34dating-agency-mall-server/src/main/java/com/qniao/dam/query/pcur/impl/ProfileCardUsageRecordQueryServiceImpl.java
@ -0,0 +1,37 @@ |
|||||
|
package com.qniao.dam.domian.aggregate.pcur.constant; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.EnumValue; |
||||
|
import com.fasterxml.jackson.annotation.JsonCreator; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.fasterxml.jackson.annotation.JsonValue; |
||||
|
import lombok.Getter; |
||||
|
|
||||
|
@Getter |
||||
|
@JsonFormat(shape = JsonFormat.Shape.OBJECT) |
||||
|
public enum CardUsageTyepEnum { |
||||
|
|
||||
|
FREE(1, "免费"), |
||||
|
|
||||
|
CARD(2, "卡片"); |
||||
|
|
||||
|
@EnumValue |
||||
|
@JsonValue |
||||
|
private final Integer value; |
||||
|
private final String desc; |
||||
|
|
||||
|
CardUsageTyepEnum(Integer value, String desc) { |
||||
|
this.value = value; |
||||
|
this.desc = desc; |
||||
|
} |
||||
|
|
||||
|
@JsonCreator |
||||
|
public static CardUsageTyepEnum get(Object code) { |
||||
|
for (CardUsageTyepEnum e : CardUsageTyepEnum.values()) { |
||||
|
if (e.getValue().equals(code)) { |
||||
|
return e; |
||||
|
} |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
package com.qniao.dam.api.command.pcur.user; |
||||
|
|
||||
|
import com.qniao.dam.api.command.pcur.user.request.*; |
||||
|
import com.qniao.dam.api.command.pcur.user.response.UserUseProfileCardVo; |
||||
|
import com.qniao.dam.application.service.pcur.ProfileCardUsageRecordApplicationService; |
||||
|
import com.qniao.dam.domain.aggregate.pcur.entity.ProfileCardUsageRecord; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import javax.validation.Valid; |
||||
|
|
||||
|
@Api(tags = "资料卡使用记录") |
||||
|
@RestController |
||||
|
@RequestMapping("user") |
||||
|
public class ProfileCardUsageRecordUserCommandController { |
||||
|
|
||||
|
@Resource |
||||
|
private ProfileCardUsageRecordApplicationService profileCardUsageRecordApplicationService; |
||||
|
|
||||
|
@ApiOperation("用户使用资料卡") |
||||
|
@PostMapping("user/profile-card") |
||||
|
public UserUseProfileCardVo userCreateProfileCardUsageRecord(@RequestBody @Valid UserUseProfileCardDto dto, |
||||
|
@RequestParam("userId") Long userId) { |
||||
|
ProfileCardUsageRecord usageRecord = dto.trans2Domain(); |
||||
|
usageRecord.setUserId(userId); |
||||
|
return profileCardUsageRecordApplicationService.use(usageRecord); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
package com.qniao.dam.api.command.pcur.user.request; |
||||
|
|
||||
|
import com.qniao.dam.domain.aggregate.pcur.entity.ProfileCardUsageRecord; |
||||
|
import com.qniao.domain.Trans2DomainAssembler; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import com.qniao.framework.utils.TypeConvertUtils; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class UserUseProfileCardDto implements Trans2DomainAssembler<ProfileCardUsageRecord> { |
||||
|
|
||||
|
@ApiModelProperty("目标资料标识") |
||||
|
private Long targetMiId; |
||||
|
|
||||
|
@Override |
||||
|
public ProfileCardUsageRecord trans2Domain() { |
||||
|
return TypeConvertUtils.convert(this, ProfileCardUsageRecord.class); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
package com.qniao.dam.api.command.pcur.user.response; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class UserUseProfileCardVo { |
||||
|
|
||||
|
@ApiModelProperty("是否成功") |
||||
|
private Boolean success = false; |
||||
|
|
||||
|
@ApiModelProperty("是否实名认证") |
||||
|
private Boolean realNameAuthenticated = false; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,66 @@ |
|||||
|
package com.qniao.dam.application.service.pcur; |
||||
|
|
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import com.qniao.dam.api.command.pcur.user.response.UserUseProfileCardVo; |
||||
|
import com.qniao.dam.application.service.right.RightApplicationService; |
||||
|
import com.qniao.dam.domain.aggregate.pcur.ProfileCardUsageRecordAggregate; |
||||
|
import com.qniao.dam.domain.aggregate.pcur.entity.ProfileCardUsageRecord; |
||||
|
import com.qniao.dam.domian.aggregate.pcur.constant.CardUsageTyepEnum; |
||||
|
import com.qniao.dam.domian.aggregate.right.constant.RightTypeEnum; |
||||
|
import com.qniao.dam.infrastructure.persistent.dao.domain.MarriageInformationDao; |
||||
|
import com.qniao.dam.infrastructure.persistent.dao.pcur.ProfileCardUsageRecordDao; |
||||
|
import com.qniao.dam.query.marriageinformation.MarriageInformationQueryService; |
||||
|
import com.qniao.dam.query.pcur.ProfileCardUsageRecordQueryService; |
||||
|
import com.qniao.das.domian.aggregate.marriageinformation.MarriageInformation; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.util.Objects; |
||||
|
|
||||
|
@Service |
||||
|
public class ProfileCardUsageRecordApplicationService { |
||||
|
|
||||
|
@Resource |
||||
|
private ProfileCardUsageRecordDao profileCardUsageRecordDao; |
||||
|
@Resource |
||||
|
private ProfileCardUsageRecordQueryService profileCardUsageRecordQueryService; |
||||
|
@Resource |
||||
|
private MarriageInformationQueryService marriageInformationQueryService; |
||||
|
@Resource |
||||
|
private RightApplicationService rightApplicationService; |
||||
|
|
||||
|
public UserUseProfileCardVo use(ProfileCardUsageRecord usageRecord) { |
||||
|
UserUseProfileCardVo vo = new UserUseProfileCardVo(); |
||||
|
//查看今天是否解锁过 |
||||
|
if (profileCardUsageRecordQueryService.existUsageRecord(usageRecord.getUserId(), usageRecord.getTargetMiId())) { |
||||
|
vo.setSuccess(true); |
||||
|
} else { |
||||
|
int freeCount = profileCardUsageRecordQueryService.countUsageRecord(usageRecord.getUserId(), CardUsageTyepEnum.FREE); |
||||
|
if (freeCount < 3) { |
||||
|
ProfileCardUsageRecord record = ProfileCardUsageRecord.build(usageRecord.getUserId(), usageRecord.getTargetMiId(), CardUsageTyepEnum.FREE); |
||||
|
profileCardUsageRecordDao.insert(record); |
||||
|
} else { |
||||
|
MarriageInformation marriageInformation = marriageInformationQueryService.queryByUserId(usageRecord.getUserId()); |
||||
|
vo.setRealNameAuthenticated(StrUtil.isNotBlank(marriageInformation.getIdentityCard())); |
||||
|
if (!vo.getRealNameAuthenticated()) { |
||||
|
//未实名是有3次 |
||||
|
vo.setSuccess(false); |
||||
|
} else { |
||||
|
if (freeCount < 20) { |
||||
|
ProfileCardUsageRecord record = ProfileCardUsageRecord.build(usageRecord.getUserId(), usageRecord.getTargetMiId(), CardUsageTyepEnum.FREE); |
||||
|
profileCardUsageRecordDao.insert(record); |
||||
|
} else { |
||||
|
//免费使用完后,看看有没有资料卡使用 |
||||
|
if (rightApplicationService.consumeRight(usageRecord.getUserId(), marriageInformation.getId(), RightTypeEnum.PROFILE_CARD, null)) { |
||||
|
ProfileCardUsageRecord record = ProfileCardUsageRecord.build(usageRecord.getUserId(), usageRecord.getTargetMiId(), CardUsageTyepEnum.CARD); |
||||
|
profileCardUsageRecordDao.insert(record); |
||||
|
} else { |
||||
|
vo.setSuccess(false); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return vo; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
package com.qniao.dam.domain.aggregate.pcur; |
||||
|
|
||||
|
import com.qniao.dam.domain.aggregate.pcur.entity.ProfileCardUsageRecord; |
||||
|
import com.qniao.dam.domain.aggregate.pcur.repository.ProfileCardUsageRecordRepository; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
|
||||
|
/** |
||||
|
* 资料卡使用记录 |
||||
|
* |
||||
|
* @date 2026/02/04 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class ProfileCardUsageRecordAggregate { |
||||
|
|
||||
|
@Resource |
||||
|
private ProfileCardUsageRecordRepository repository; |
||||
|
|
||||
|
public void create(ProfileCardUsageRecord entity) { |
||||
|
repository.save(entity); |
||||
|
} |
||||
|
|
||||
|
public void edit(ProfileCardUsageRecord entity) { |
||||
|
repository.save(entity); |
||||
|
} |
||||
|
|
||||
|
public void delete(Long id) { |
||||
|
repository.delete(id); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,46 @@ |
|||||
|
package com.qniao.dam.domain.aggregate.pcur.entity; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import com.qniao.dam.domian.aggregate.pcur.constant.CardUsageTyepEnum; |
||||
|
import com.qniao.domain.ValueObject; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
import com.qniao.domain.Entity; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
|
||||
|
/** |
||||
|
* 资料卡使用记录 |
||||
|
* |
||||
|
* @date 2026/02/04 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@TableName("da_profile_card_usage_record") |
||||
|
public class ProfileCardUsageRecord extends ValueObject<ProfileCardUsageRecord> { |
||||
|
|
||||
|
@ApiModelProperty("用户标识") |
||||
|
private Long userId; |
||||
|
|
||||
|
@ApiModelProperty("目标资料标识") |
||||
|
private Long targetMiId; |
||||
|
|
||||
|
@ApiModelProperty("使用类型") |
||||
|
private CardUsageTyepEnum usageType; |
||||
|
|
||||
|
@ApiModelProperty("使用日期") |
||||
|
private LocalDate usageDate; |
||||
|
|
||||
|
public static ProfileCardUsageRecord build(Long userId, |
||||
|
Long targetMiId, |
||||
|
CardUsageTyepEnum usageType) { |
||||
|
ProfileCardUsageRecord profileCardUsageRecord = new ProfileCardUsageRecord(); |
||||
|
profileCardUsageRecord.setUserId(userId); |
||||
|
profileCardUsageRecord.setTargetMiId(targetMiId); |
||||
|
profileCardUsageRecord.setUsageType(usageType); |
||||
|
profileCardUsageRecord.setUsageDate(LocalDate.now()); |
||||
|
return profileCardUsageRecord; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
package com.qniao.dam.domain.aggregate.pcur.repository; |
||||
|
|
||||
|
import com.qniao.dam.domain.aggregate.pcur.entity.ProfileCardUsageRecord; |
||||
|
import com.qniao.domain.Repository; |
||||
|
|
||||
|
/** |
||||
|
* 资料卡使用记录 |
||||
|
* |
||||
|
* @date 2026/02/04 |
||||
|
*/ |
||||
|
public interface ProfileCardUsageRecordRepository extends Repository<ProfileCardUsageRecord, Long> { |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
package com.qniao.dam.infrastructure.persistent.dao.pcur; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.qniao.dam.domain.aggregate.pcur.entity.ProfileCardUsageRecord; |
||||
|
|
||||
|
/** |
||||
|
* 资料卡使用记录 |
||||
|
* |
||||
|
* @date 2026/02/04 |
||||
|
*/ |
||||
|
public interface ProfileCardUsageRecordDao extends BaseMapper<ProfileCardUsageRecord> { |
||||
|
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
package com.qniao.dam.infrastructure.persistent.repository.impl; |
||||
|
|
||||
|
import com.qniao.dam.domain.aggregate.pcur.entity.ProfileCardUsageRecord; |
||||
|
import com.qniao.dam.domain.aggregate.pcur.repository.ProfileCardUsageRecordRepository; |
||||
|
import com.qniao.dam.infrastructure.persistent.dao.pcur.ProfileCardUsageRecordDao; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.util.Objects; |
||||
|
|
||||
|
/** |
||||
|
* 资料卡使用记录 |
||||
|
* |
||||
|
* @date 2026/02/04 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class ProfileCardUsageRecordRepositoryImpl implements ProfileCardUsageRecordRepository { |
||||
|
|
||||
|
@Resource |
||||
|
private ProfileCardUsageRecordDao dao; |
||||
|
|
||||
|
@Override |
||||
|
public ProfileCardUsageRecord load(Long id) { |
||||
|
return dao.selectById(id); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Long save(ProfileCardUsageRecord entity) { |
||||
|
if (Objects.isNull(entity) || Objects.isNull(dao.selectById(entity.getId()))) { |
||||
|
dao.insert(entity); |
||||
|
} else { |
||||
|
dao.updateById(entity); |
||||
|
} |
||||
|
return entity.getId(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void delete(Long id) { |
||||
|
dao.deleteById(id); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,10 @@ |
|||||
|
package com.qniao.dam.query.pcur; |
||||
|
|
||||
|
import com.qniao.dam.domian.aggregate.pcur.constant.CardUsageTyepEnum; |
||||
|
|
||||
|
public interface ProfileCardUsageRecordQueryService { |
||||
|
|
||||
|
boolean existUsageRecord(Long userId, Long targetMiId); |
||||
|
|
||||
|
int countUsageRecord(Long userId, CardUsageTyepEnum usageType); |
||||
|
} |
||||
@ -0,0 +1,34 @@ |
|||||
|
package com.qniao.dam.query.pcur.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.qniao.dam.domain.aggregate.pcur.entity.ProfileCardUsageRecord; |
||||
|
import com.qniao.dam.domian.aggregate.pcur.constant.CardUsageTyepEnum; |
||||
|
import com.qniao.dam.infrastructure.persistent.dao.pcur.ProfileCardUsageRecordDao; |
||||
|
import com.qniao.dam.query.pcur.ProfileCardUsageRecordQueryService; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.time.LocalDate; |
||||
|
|
||||
|
@Service |
||||
|
public class ProfileCardUsageRecordQueryServiceImpl implements ProfileCardUsageRecordQueryService { |
||||
|
|
||||
|
@Resource |
||||
|
private ProfileCardUsageRecordDao profileCardUsageRecordDao; |
||||
|
|
||||
|
@Override |
||||
|
public boolean existUsageRecord(Long userId, Long targetMiId) { |
||||
|
return profileCardUsageRecordDao.selectCount(new LambdaQueryWrapper<ProfileCardUsageRecord>() |
||||
|
.eq(ProfileCardUsageRecord::getUserId, userId) |
||||
|
.eq(ProfileCardUsageRecord::getUsageDate, LocalDate.now()) |
||||
|
.eq(ProfileCardUsageRecord::getTargetMiId, targetMiId)) > 0; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int countUsageRecord(Long userId, CardUsageTyepEnum usageType) { |
||||
|
return profileCardUsageRecordDao.selectCount(new LambdaQueryWrapper<ProfileCardUsageRecord>() |
||||
|
.eq(ProfileCardUsageRecord::getUserId, userId) |
||||
|
.eq(ProfileCardUsageRecord::getUsageDate, LocalDate.now()) |
||||
|
.eq(ProfileCardUsageRecord::getUsageType, usageType)); |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save