Commit 558e6ff0 by leejoker

提交任务宝海报生成方法

1 parent 73f4533e
......@@ -20,7 +20,7 @@ public class WeConstans {
/**
* 自建应用token
*/
public static final String WE_THIRD_APP_TOKEN="we_third_app_token";
public static final String WE_THIRD_APP_TOKEN = "we_third_app_token";
/**
......@@ -250,6 +250,11 @@ public class WeConstans {
*/
public static final Integer SENSITIVE_USER_PIECE = 50;
/**
* 任务裂变用户活码state前缀
*/
public static final String FISSION_PREFIX = "fis-";
public static final String AppTicketKey = "ticket:AppGet";
public static final String AgentTicketKey = "ticket:AgentGet";
......@@ -322,9 +327,9 @@ public class WeConstans {
public static enum sendMessageStatusEnum {
NOT_SEND("0", "未发送"),
SEND("1","已发送"),
NOT_FRIEND_SEND("2","因客户不是好友导致发送失败"),
RECEIVE_OTHER_MESSAGE("3","-因客户已经收到其他群发消息导致发送失败"),
SEND("1", "已发送"),
NOT_FRIEND_SEND("2", "因客户不是好友导致发送失败"),
RECEIVE_OTHER_MESSAGE("3", "-因客户已经收到其他群发消息导致发送失败"),
;
private String status;
......@@ -360,7 +365,6 @@ public class WeConstans {
}
public static final String WECOM_FINANCE_INDEX = "finance";
public static final String WECOM_SENSITIVE_HIT_INDEX = "sensitive";
......@@ -374,5 +378,5 @@ public class WeConstans {
/**
* 第三方应用ID,参数标实
*/
public static final String THIRD_APP_PARAM_TIP="agentId";
public static final String THIRD_APP_PARAM_TIP = "agentId";
}
......@@ -12,14 +12,17 @@ import com.linkwechat.wecom.domain.dto.WeExternalContactDto;
**/
public interface WeExternalContactClient {
@Request(url="/externalcontact/add_contact_way",
@Request(url = "/externalcontact/add_contact_way",
type = "POST"
)
WeExternalContactDto addContactWay(@DataObject WeExternalContactDto.WeContactWay weContactWay);
@Request(url="/externalcontact/update_contact_way", type = "POST")
@Request(url = "/externalcontact/update_contact_way", type = "POST")
WeExternalContactDto updateContactWay(@DataObject WeExternalContactDto.WeContactWay weContactWay);
@Request(url = "/externalcontact/del_contact_way", type = "POST")
WeExternalContactDto delContactWay(@Query("configId") String configId);
@Request(url = "/externalcontact/get_contact_way", type = "POST")
WeExternalContactDto getContactWay(@Query("configId") String configId);
}
......@@ -6,10 +6,10 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.wecom.domain.WeTaskFission;
import com.linkwechat.wecom.domain.WeTaskFissionRecord;
import com.linkwechat.wecom.domain.WeTaskFissionStaff;
import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.client.WeExternalContactClient;
import com.linkwechat.wecom.domain.*;
import com.linkwechat.wecom.domain.dto.WeExternalContactDto;
import com.linkwechat.wecom.domain.dto.WeTaskFissionPosterDTO;
import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto;
import com.linkwechat.wecom.domain.dto.message.LinkMessageDto;
......@@ -22,6 +22,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
......@@ -45,6 +46,10 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService {
private IWeTaskFissionRecordService weTaskFissionRecordService;
@Autowired
private IWeUserService weUserService;
@Autowired
private WeExternalContactClient weExternalContactClient;
@Autowired
private IWePosterService wePosterService;
/**
* 查询任务宝
......@@ -176,29 +181,67 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService {
}
@Override
@Transactional
public String fissionPosterGenerate(WeTaskFissionPosterDTO weTaskFissionPosterDTO) {
WeUser user = weUserService.selectWeUserById(weTaskFissionPosterDTO.getUserId());
if (user != null) {
WeTaskFissionRecord record = getTaskFissionRecordId(weTaskFissionPosterDTO.getTaskFissionId(), user.getUserId(), user.getName());
String qrcode = getPosterQRCode(weTaskFissionPosterDTO.getFissStaffId(), record);
WePoster poster = wePosterService.selectOne(weTaskFissionPosterDTO.getPosterId());
poster.getPosterSubassemblyList().stream().filter(Objects::nonNull)
.filter(wePosterSubassembly -> wePosterSubassembly.getType() == 3).forEach(wePosterSubassembly -> {
wePosterSubassembly.setImgPath(qrcode);
});
return wePosterService.generateSimpleImg(poster);
} else {
throw new RuntimeException("客户信息不存在");
}
}
private String getPosterQRCode(String fissStaffId, WeTaskFissionRecord record) {
WeExternalContactDto dto = null;
if (StringUtils.isNotBlank(record.getConfigId())) {
dto = weExternalContactClient.getContactWay(record.getConfigId());
}
if (dto == null) {
//获取二维码
WeExternalContactDto.WeContactWay contactWay = posterContactWay(fissStaffId, record.getId());
dto = weExternalContactClient.addContactWay(contactWay);
record.setConfigId(dto.getConfig_id());
int updateResult = weTaskFissionRecordService.updateWeTaskFissionRecord(record);
if (updateResult <= 0) {
throw new RuntimeException("生成海报异常:更新裂变记录失败");
}
}
return dto.getQr_code();
}
private WeExternalContactDto.WeContactWay posterContactWay(String fissUserId, Long recordId) {
WeExternalContactDto.WeContactWay wcw = new WeExternalContactDto.WeContactWay();
wcw.setScene(2);
wcw.setType(1);
wcw.setUser(new String[]{fissUserId});
wcw.setState(WeConstans.FISSION_PREFIX + recordId);
return wcw;
}
private WeTaskFissionRecord getTaskFissionRecordId(Long taskFissionId, String customerId, String customerName) {
WeTaskFissionRecord record = WeTaskFissionRecord.builder()
.taskFissionId(weTaskFissionPosterDTO.getTaskFissionId())
.customerId(user.getUserId())
.customerName(user.getName()).build();
.taskFissionId(taskFissionId)
.customerId(customerId)
.customerName(customerName).build();
List<WeTaskFissionRecord> searchExists = weTaskFissionRecordService.selectWeTaskFissionRecordList(record);
Long recordId;
WeTaskFissionRecord recordInfo;
if (CollectionUtils.isNotEmpty(searchExists)) {
recordId = searchExists.get(0).getId();
recordInfo = searchExists.get(0);
} else {
int insertRows = weTaskFissionRecordService.insertWeTaskFissionRecord(record);
if (insertRows > 0) {
recordId = record.getId();
recordInfo = record;
} else {
throw new RuntimeException("生成海报异常:插入裂变记录失败");
}
}
return "";
} else {
throw new RuntimeException("客户信息不存在");
}
return recordInfo;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!