|
|
@@ -4,14 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.etotem.cfc.common.Result;
|
|
|
import com.etotem.cfc.dto.ApplyPackageDTO;
|
|
|
import com.etotem.cfc.entity.ProblemDomain;
|
|
|
-import com.etotem.cfc.entity.TaskPlanInstance;
|
|
|
import com.etotem.cfc.entity.TaskTemplateItem;
|
|
|
import com.etotem.cfc.entity.TaskTemplatePackage;
|
|
|
import com.etotem.cfc.entity.UserIntent;
|
|
|
import com.etotem.cfc.entity.PackageOrder;
|
|
|
import com.etotem.cfc.mapper.PackageOrderMapper;
|
|
|
import com.etotem.cfc.mapper.ProblemDomainMapper;
|
|
|
-import com.etotem.cfc.mapper.TaskPlanInstanceMapper;
|
|
|
import com.etotem.cfc.mapper.UserIntentMapper;
|
|
|
import com.etotem.cfc.service.MembershipService;
|
|
|
import com.etotem.cfc.service.TaskPlanService;
|
|
|
@@ -45,9 +43,6 @@ public class ProblemPackageController {
|
|
|
@Resource
|
|
|
private TaskPlanService taskPlanService;
|
|
|
|
|
|
- @Resource
|
|
|
- private TaskPlanInstanceMapper planInstanceMapper;
|
|
|
-
|
|
|
@Resource
|
|
|
private UserIntentMapper userIntentMapper;
|
|
|
|
|
|
@@ -132,25 +127,12 @@ public class ProblemPackageController {
|
|
|
return Result.error("请先购买套餐后再确认方案");
|
|
|
}
|
|
|
|
|
|
- // 幂等:同一家庭同一套餐已有激活中的方案实例则复用
|
|
|
- TaskPlanInstance plan = planInstanceMapper.selectOne(
|
|
|
- new LambdaQueryWrapper<TaskPlanInstance>()
|
|
|
- .eq(TaskPlanInstance::getFamilyId, familyId)
|
|
|
- .eq(TaskPlanInstance::getPackageId, packageId)
|
|
|
- .eq(TaskPlanInstance::getStatus, "active")
|
|
|
- .last("LIMIT 1"));
|
|
|
- Long planId;
|
|
|
- if (plan == null) {
|
|
|
- ApplyPackageDTO dto = new ApplyPackageDTO();
|
|
|
- dto.setPackageId(packageId);
|
|
|
- TaskPlanInstance created = taskPlanService.applyPackage(dto, familyId);
|
|
|
- planId = created.getId();
|
|
|
- } else {
|
|
|
- planId = plan.getId();
|
|
|
- }
|
|
|
-
|
|
|
- // 生成方案任务(memberOnly=1,幂等)
|
|
|
- int taskCount = taskPlanService.generatePlanTasks(planId, familyId, userId);
|
|
|
+ // 应用套餐并激活(幂等复用 + 自助置 active + 统一生成任务)
|
|
|
+ ApplyPackageDTO dto = new ApplyPackageDTO();
|
|
|
+ dto.setPackageId(packageId);
|
|
|
+ Map<String, Object> applied = taskPlanService.applyAndActivate(dto, familyId, userId);
|
|
|
+ Long planId = (Long) applied.get("planId");
|
|
|
+ int taskCount = (Integer) applied.get("taskCount");
|
|
|
|
|
|
// 推进旅程 stage=6(方案已确认,任务已生成)
|
|
|
UserIntent intent = findIntent(userId);
|