|
|
|
@@ -1,6 +1,5 @@ |
|
|
|
package com.iformall.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
@@ -8,13 +7,15 @@ import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.IdWorker; |
|
|
|
import com.iformall.common.Result; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.domain.po.WxCUser; |
|
|
|
import com.iformall.domain.po.WxCUserBasicInfo; |
|
|
|
import com.iformall.domain.po.WxMsg; |
|
|
|
import com.iformall.domain.po.WxMsgCallback; |
|
|
|
import com.iformall.domain.po.WxMsgConfig; |
|
|
|
import com.iformall.enums.EnumMsgStatus; |
|
|
|
import com.iformall.mapper.*; |
|
|
|
import com.iformall.service.WxCUserService; |
|
|
|
import com.iformall.mapper.WxCUserBasicInfoMapper; |
|
|
|
import com.iformall.mapper.WxMsgCallbackMapper; |
|
|
|
import com.iformall.mapper.WxMsgConfigMapper; |
|
|
|
import com.iformall.mapper.WxMsgMapper; |
|
|
|
import com.iformall.service.WxCUserTagsService; |
|
|
|
import com.iformall.service.WxMsgService; |
|
|
|
import com.iformall.utils.AesUtil; |
|
|
|
@@ -26,7 +27,6 @@ import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.beans.Encoder; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
@Service |
|
|
|
@@ -45,6 +45,9 @@ public class WxMsgServiceImpl implements WxMsgService { |
|
|
|
@Autowired |
|
|
|
WxCUserBasicInfoMapper wxCUserBasicInfoMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxMsgCallbackMapper wxMsgCallbackMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<WxMsg> listAsPage(WxMsg record, Integer pageIndex, Integer pageSize) { |
|
|
|
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMsgMapper.findList(record)); |
|
|
|
@@ -58,24 +61,34 @@ public class WxMsgServiceImpl implements WxMsgService { |
|
|
|
@Override |
|
|
|
public ResultData saveOrUpdate(WxMsg wxMsg) { |
|
|
|
|
|
|
|
//3种方式得到手机号,三种只能有一种 |
|
|
|
//1通过excel |
|
|
|
//2手机多条以逗号分隔,直接通过实体得到wxmsg.getphones |
|
|
|
//3通过标签 |
|
|
|
//1、手机多条以逗号分隔,直接通过实体得到wxmsg.getphones |
|
|
|
//2、通过标签 |
|
|
|
String phones=wxMsg.getPhones(); |
|
|
|
if(phones.equals("")){ |
|
|
|
if(null!=wxMsg.getExcelpath() && !wxMsg.getExcelpath().equals("")) |
|
|
|
phones=parseexcle(wxMsg.getTenantId(), wxMsg.getExcelpath()); |
|
|
|
else |
|
|
|
phones=parselabel(wxMsg.getTenantId(), wxMsg.getLabel()); |
|
|
|
String label = wxMsg.getLabel(); |
|
|
|
if(!phones.equals("") && !label.equals("")){//两种方式只能选其一 |
|
|
|
return new ResultData(ErrorCode.MSG_SEND_WAY_CHOOSE_ERROR); |
|
|
|
} |
|
|
|
|
|
|
|
if(phones.equals("")){ |
|
|
|
return new ResultData(ErrorCode.MSG_PHONE_NOT_FOUND, "请输入手机号"); |
|
|
|
} else { |
|
|
|
wxMsg.setPhones(phones); |
|
|
|
if(phones.equals("")){//没有手工输入手机号时解析标签,有,继续流转 |
|
|
|
phones=parselabel(wxMsg.getTenantId(), wxMsg); |
|
|
|
if(phones.equals("")){//解析之后手机号依然不存在时返回 |
|
|
|
return new ResultData(ErrorCode.MSG_PHONE_NOT_FOUND); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//保证手机号惟一 |
|
|
|
String[] phoneSplit = phones.split(","); |
|
|
|
Set<String> phoneSet=new HashSet<>(); |
|
|
|
for(String phone:phoneSplit){ |
|
|
|
phoneSet.add(phone); |
|
|
|
} |
|
|
|
StringBuffer sb=new StringBuffer(); |
|
|
|
for(String phone:phoneSet){ |
|
|
|
sb.append(phone).append(","); |
|
|
|
} |
|
|
|
wxMsg.setPhones(sb.toString()); |
|
|
|
|
|
|
|
//新增记录 |
|
|
|
if (wxMsg.getId() == null) { |
|
|
|
//草稿 |
|
|
|
if (wxMsg.getStatus() == 2) { |
|
|
|
@@ -116,8 +129,6 @@ public class WxMsgServiceImpl implements WxMsgService { |
|
|
|
wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_NOT_SEND.getCode()); |
|
|
|
wxMsgMapper.updateByPrimaryKeySelective(wxMsg); |
|
|
|
return new ResultData(Result.SUCCESS, "短信会在预设时间发送"); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
@@ -125,7 +136,8 @@ public class WxMsgServiceImpl implements WxMsgService { |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
|
|
|
|
private String parselabel(String tenantId, String label) { |
|
|
|
private String parselabel(String tenantId, WxMsg wxmsg) { |
|
|
|
String label = wxmsg.getLabel(); |
|
|
|
String[] arys = label.split(","); |
|
|
|
List<Long> tagids = new ArrayList<>(); |
|
|
|
for (int i = 0; i < arys.length; i++) { |
|
|
|
@@ -143,7 +155,7 @@ public class WxMsgServiceImpl implements WxMsgService { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
private String parseexcle(String tenantId, String excelpath) { |
|
|
|
private String parseexcle(String tenantId, WxMsg excelpath) { |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
@@ -230,4 +242,23 @@ public class WxMsgServiceImpl implements WxMsgService { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void addMsgCallback(WxMsg wxmsg){ |
|
|
|
|
|
|
|
String phones = wxmsg.getPhones(); |
|
|
|
String[] split = phones.split(","); |
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
for(String phone:split){ |
|
|
|
WxMsgCallback wxMsgCallback = new WxMsgCallback(); |
|
|
|
wxMsgCallback.setId(idWorker.nextId()); |
|
|
|
wxMsgCallback.setPhone(phone); |
|
|
|
//批次号或任务ID |
|
|
|
wxMsgCallbackMapper.insertSelective(wxMsgCallback); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |