From d2756b998df9faa20412b48ba81a7d9fbf00a4e6 Mon Sep 17 00:00:00 2001 From: gongbiao Date: Thu, 27 Sep 2018 18:17:25 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=A0=87=E7=AD=BE=E7=9F=AD=E4=BF=A1][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9][=E4=BF=9D=E5=AD=98=E8=8D=89=E7=A8=BF]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/WxMsgServiceImpl.java | 83 +++++++++++++------ 1 file changed, 56 insertions(+), 27 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMsgServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMsgServiceImpl.java index aa260b3a5..ac451b009 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMsgServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMsgServiceImpl.java @@ -84,33 +84,6 @@ public class WxMsgServiceImpl implements WxMsgService { @Override public ResultData saveOrUpdate(WxMsg wxMsg) { - //1、手机多条以逗号分隔,直接通过实体得到wxmsg.getphones - //2、通过标签 - String phones=wxMsg.getPhones(); - String label = wxMsg.getLabel(); - if(!phones.equals("") && !label.equals("")){//两种方式只能选其一 - return new ResultData(ErrorCode.MSG_SEND_WAY_CHOOSE_ERROR); - } - - if(phones.equals("")){//没有手工输入手机号时解析标签,有,继续流转 - phones=parselabel(wxMsg.getTenantId(), wxMsg); - if(phones.equals("")){//解析之后手机号依然不存在时返回 - return new ResultData(ErrorCode.MSG_PHONE_NOT_FOUND); - } - } - - //保证手机号惟一 - String[] phoneSplit = phones.split(","); - Set phoneSet=new HashSet<>(); - for(String phone:phoneSplit){ - phoneSet.add(phone); - } - wxMsg.setExpectSendNumber(phoneSet.size());//预计发送数量 - StringBuffer sb=new StringBuffer(); - for(String phone:phoneSet){ - sb.append(phone).append(","); - } - wxMsg.setPhones(sb.deleteCharAt(sb.length()-1).toString()); //新增记录 if (wxMsg.getId() == null) { @@ -124,6 +97,34 @@ public class WxMsgServiceImpl implements WxMsgService { } + //1、手机多条以逗号分隔,直接通过实体得到wxmsg.getphones + //2、通过标签 + String phones=wxMsg.getPhones(); + String label = wxMsg.getLabel(); + if(!phones.equals("") && !label.equals("")){//两种方式只能选其一 + return new ResultData(ErrorCode.MSG_SEND_WAY_CHOOSE_ERROR); + } + + if(phones.equals("")){//没有手工输入手机号时解析标签,有,继续流转 + phones=parselabel(wxMsg.getTenantId(), wxMsg); + if(phones.equals("")){//解析之后手机号依然不存在时返回 + return new ResultData(ErrorCode.MSG_PHONE_NOT_FOUND); + } + } + + //保证手机号惟一 + String[] phoneSplit = phones.split(","); + Set phoneSet=new HashSet<>(); + for(String phone:phoneSplit){ + phoneSet.add(phone); + } + wxMsg.setExpectSendNumber(phoneSet.size());//预计发送数量 + StringBuffer sb=new StringBuffer(); + for(String phone:phoneSet){ + sb.append(phone).append(","); + } + wxMsg.setPhones(sb.deleteCharAt(sb.length()-1).toString()); + //是否立即发送 if (wxMsg.getIsright() == 1) { wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_SENDED.getCode()); @@ -146,6 +147,34 @@ public class WxMsgServiceImpl implements WxMsgService { return new ResultData(Result.SUCCESS, "已保存到草稿箱"); } + //1、手机多条以逗号分隔,直接通过实体得到wxmsg.getphones + //2、通过标签 + String phones=wxMsg.getPhones(); + String label = wxMsg.getLabel(); + if(!phones.equals("") && !label.equals("")){//两种方式只能选其一 + return new ResultData(ErrorCode.MSG_SEND_WAY_CHOOSE_ERROR); + } + + if(phones.equals("")){//没有手工输入手机号时解析标签,有,继续流转 + phones=parselabel(wxMsg.getTenantId(), wxMsg); + if(phones.equals("")){//解析之后手机号依然不存在时返回 + return new ResultData(ErrorCode.MSG_PHONE_NOT_FOUND); + } + } + + //保证手机号惟一 + String[] phoneSplit = phones.split(","); + Set phoneSet=new HashSet<>(); + for(String phone:phoneSplit){ + phoneSet.add(phone); + } + wxMsg.setExpectSendNumber(phoneSet.size());//预计发送数量 + StringBuffer sb=new StringBuffer(); + for(String phone:phoneSet){ + sb.append(phone).append(","); + } + wxMsg.setPhones(sb.deleteCharAt(sb.length()-1).toString()); + //是否立即发送 if (wxMsg.getIsright() == 1) { wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_SENDED.getCode());