|
|
@@ -134,8 +134,8 @@ public class KeyPersonService {
|
|
|
}
|
|
|
|
|
|
public Result<OctopusEffectRecord> addEffect(Long userId, Long memberOrderId, Integer effectType,
|
|
|
- BigDecimal effectAmount, String effectDesc) {
|
|
|
- // memberOrderId 为可选关联(MemberSubscriptionOrder 为家庭维度表,无 userId 字段,仅记录关联不校验归属)
|
|
|
+ BigDecimal effectAmount, String effectDesc,
|
|
|
+ List<Map<String, Object>> keyPersons) {
|
|
|
OctopusEffectRecord r = new OctopusEffectRecord();
|
|
|
r.setUserId(userId);
|
|
|
r.setMemberOrderId(memberOrderId);
|
|
|
@@ -145,6 +145,33 @@ public class KeyPersonService {
|
|
|
r.setStatus(1);
|
|
|
r.setCreatedAt(new Date());
|
|
|
effectRecordMapper.insert(r);
|
|
|
+
|
|
|
+ // 保存关键人关联
|
|
|
+ if (keyPersons != null) {
|
|
|
+ for (Map<String, Object> kp : keyPersons) {
|
|
|
+ Long keyPersonId = kp.get("keyPersonId") != null
|
|
|
+ ? Long.valueOf(kp.get("keyPersonId").toString()) : null;
|
|
|
+ Integer role = kp.get("role") != null
|
|
|
+ ? Integer.valueOf(kp.get("role").toString()) : 3;
|
|
|
+ if (keyPersonId == null) continue;
|
|
|
+ // 校验关键人归属
|
|
|
+ OctopusKeyPerson kpEntity = keyPersonMapper.selectById(keyPersonId);
|
|
|
+ if (kpEntity == null || !kpEntity.getUserId().equals(userId)) continue;
|
|
|
+ // 避免重复关联
|
|
|
+ Long exists = ekpMapper.selectCount(
|
|
|
+ new LambdaQueryWrapper<OctopusEffectKeyPerson>()
|
|
|
+ .eq(OctopusEffectKeyPerson::getEffectId, r.getId())
|
|
|
+ .eq(OctopusEffectKeyPerson::getKeyPersonId, keyPersonId)
|
|
|
+ );
|
|
|
+ if (exists != null && exists > 0) continue;
|
|
|
+ OctopusEffectKeyPerson rel = new OctopusEffectKeyPerson();
|
|
|
+ rel.setEffectId(r.getId());
|
|
|
+ rel.setKeyPersonId(keyPersonId);
|
|
|
+ rel.setRole(role);
|
|
|
+ rel.setCreatedAt(new Date());
|
|
|
+ ekpMapper.insert(rel);
|
|
|
+ }
|
|
|
+ }
|
|
|
return Result.success(r);
|
|
|
}
|
|
|
|
|
|
@@ -161,6 +188,30 @@ public class KeyPersonService {
|
|
|
|
|
|
// ========== 2. 找关键人 ==========
|
|
|
|
|
|
+ /** 列出当前用户的全部关键人(供成效录入时选择关联) */
|
|
|
+ public Result<List<Map<String, Object>>> listKeyPersons(Long userId) {
|
|
|
+ List<OctopusKeyPerson> kps = keyPersonMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<OctopusKeyPerson>()
|
|
|
+ .eq(OctopusKeyPerson::getUserId, userId)
|
|
|
+ .orderByDesc(OctopusKeyPerson::getCreatedAt)
|
|
|
+ );
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ for (OctopusKeyPerson kp : kps) {
|
|
|
+ Map<String, Object> m = new LinkedHashMap<>();
|
|
|
+ m.put("id", kp.getId());
|
|
|
+ m.put("name", kp.getName());
|
|
|
+ m.put("organization", kp.getOrganization());
|
|
|
+ m.put("department", kp.getDepartment());
|
|
|
+ m.put("title", kp.getTitle());
|
|
|
+ m.put("firstMeetScene", kp.getFirstMeetScene());
|
|
|
+ m.put("knowWay", kp.getKnowWay());
|
|
|
+ m.put("contactInfo", kp.getContactInfo());
|
|
|
+ m.put("createdAt", kp.getCreatedAt() != null ? kp.getCreatedAt().toString() : "");
|
|
|
+ list.add(m);
|
|
|
+ }
|
|
|
+ return Result.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
public Result<OctopusKeyPerson> addKeyPerson(Long userId, String name, String organization,
|
|
|
String department, String title,
|
|
|
String firstMeetScene, String knowWay,
|