|
@@ -24,6 +24,7 @@ import com.etotem.cfc.mapper.ProductMapper;
|
|
|
import com.etotem.cfc.mapper.TaskMapper;
|
|
import com.etotem.cfc.mapper.TaskMapper;
|
|
|
import com.etotem.cfc.mapper.UserMapper;
|
|
import com.etotem.cfc.mapper.UserMapper;
|
|
|
import com.etotem.cfc.dto.CartItemDTO;
|
|
import com.etotem.cfc.dto.CartItemDTO;
|
|
|
|
|
+import com.etotem.cfc.dto.FamilyPlanCreateDTO;
|
|
|
import com.etotem.cfc.service.AttributionAnalysisService;
|
|
import com.etotem.cfc.service.AttributionAnalysisService;
|
|
|
import com.etotem.cfc.service.CartService;
|
|
import com.etotem.cfc.service.CartService;
|
|
|
import com.etotem.cfc.service.HealthPlanService;
|
|
import com.etotem.cfc.service.HealthPlanService;
|
|
@@ -2397,4 +2398,46 @@ public class HealthPlanServiceImpl implements HealthPlanService {
|
|
|
cal.set(Calendar.MILLISECOND, 0);
|
|
cal.set(Calendar.MILLISECOND, 0);
|
|
|
return cal.getTime();
|
|
return cal.getTime();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Long createFamilyPlan(Long familyId, Long adminUserId, FamilyPlanCreateDTO dto) {
|
|
|
|
|
+ HealthPlan p = new HealthPlan();
|
|
|
|
|
+ p.setFamilyId(familyId);
|
|
|
|
|
+ p.setPlanType(dto.getPlanType());
|
|
|
|
|
+ p.setMemberName(dto.getMemberName());
|
|
|
|
|
+ p.setMemberIds(dto.getMemberIds());
|
|
|
|
|
+ p.setDimensions(dto.getDimensions());
|
|
|
|
|
+ p.setGoal(dto.getGoal());
|
|
|
|
|
+ p.setPlanContent(dto.getPlanContent());
|
|
|
|
|
+ p.setPlanJson(dto.getPlanJson());
|
|
|
|
|
+ p.setTotalDays(dto.getTotalDays());
|
|
|
|
|
+ p.setTeacherId(dto.getTeacherId());
|
|
|
|
|
+ p.setStatus(dto.getStatus() != null && !dto.getStatus().isEmpty() ? dto.getStatus() : "active");
|
|
|
|
|
+ p.setCreatedAt(new Date());
|
|
|
|
|
+ p.setUpdatedAt(new Date());
|
|
|
|
|
+ healthPlanMapper.insert(p);
|
|
|
|
|
+ return p.getId();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean updateFamilyPlan(Long planId, Long familyId, FamilyPlanCreateDTO dto) {
|
|
|
|
|
+ HealthPlan p = healthPlanMapper.selectById(planId);
|
|
|
|
|
+ if (p == null) throw new RuntimeException("方案不存在");
|
|
|
|
|
+ if (p.getFamilyId() == null || !p.getFamilyId().equals(familyId)) {
|
|
|
|
|
+ throw new RuntimeException("方案不属于该家庭");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (dto.getPlanType() != null) p.setPlanType(dto.getPlanType());
|
|
|
|
|
+ if (dto.getMemberName() != null) p.setMemberName(dto.getMemberName());
|
|
|
|
|
+ if (dto.getMemberIds() != null) p.setMemberIds(dto.getMemberIds());
|
|
|
|
|
+ if (dto.getDimensions() != null) p.setDimensions(dto.getDimensions());
|
|
|
|
|
+ if (dto.getGoal() != null) p.setGoal(dto.getGoal());
|
|
|
|
|
+ if (dto.getPlanContent() != null) p.setPlanContent(dto.getPlanContent());
|
|
|
|
|
+ if (dto.getPlanJson() != null) p.setPlanJson(dto.getPlanJson());
|
|
|
|
|
+ if (dto.getTotalDays() != null) p.setTotalDays(dto.getTotalDays());
|
|
|
|
|
+ if (dto.getTeacherId() != null) p.setTeacherId(dto.getTeacherId());
|
|
|
|
|
+ if (dto.getStatus() != null) p.setStatus(dto.getStatus());
|
|
|
|
|
+ p.setUpdatedAt(new Date());
|
|
|
|
|
+ return healthPlanMapper.updateById(p) > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|