|
|
|
@@ -18,10 +18,7 @@ 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; |
|
|
|
import com.iformall.utils.HMACSHA256; |
|
|
|
import com.iformall.utils.HttpUtil; |
|
|
|
import com.iformall.utils.RsaUtil; |
|
|
|
import com.iformall.utils.*; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
@@ -113,7 +110,7 @@ public class WxMsgServiceImpl implements WxMsgService { |
|
|
|
for(String phone:phoneSet){ |
|
|
|
sb.append(phone).append(","); |
|
|
|
} |
|
|
|
wxMsg.setPhones(sb.toString()); |
|
|
|
wxMsg.setPhones(sb.deleteCharAt(sb.length()-1).toString()); |
|
|
|
|
|
|
|
//新增记录 |
|
|
|
if (wxMsg.getId() == null) { |
|
|
|
@@ -130,14 +127,16 @@ public class WxMsgServiceImpl implements WxMsgService { |
|
|
|
//是否立即发送 |
|
|
|
if (wxMsg.getIsright() == 1) { |
|
|
|
wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_SENDED.getCode()); |
|
|
|
sendmsg(wxMsg); |
|
|
|
wxMsg.setSendtime(DateUtils.getSystemTime("yyyy-MM-dd HH:mm:ss")); |
|
|
|
return sendmsg(wxMsg); |
|
|
|
} else { |
|
|
|
wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_NOT_SEND.getCode()); |
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
wxMsg.setId(idWorker.nextId()); |
|
|
|
long id = idWorker.nextId(); |
|
|
|
wxMsg.setId(id); |
|
|
|
wxMsg.setCreatetime(new Date()); |
|
|
|
wxMsgMapper.insertSelective(wxMsg); |
|
|
|
return new ResultData(Result.SUCCESS, "短信会在预设时间发送"); |
|
|
|
return new ResultData(Result.SUCCESS, "短信会在预设时间发送",id); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
@@ -150,7 +149,7 @@ public class WxMsgServiceImpl implements WxMsgService { |
|
|
|
//是否立即发送 |
|
|
|
if (wxMsg.getIsright() == 1) { |
|
|
|
wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_SENDED.getCode()); |
|
|
|
sendmsg(wxMsg); |
|
|
|
return sendmsg(wxMsg); |
|
|
|
} else { |
|
|
|
//定时 |
|
|
|
wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_NOT_SEND.getCode()); |
|
|
|
@@ -159,8 +158,6 @@ public class WxMsgServiceImpl implements WxMsgService { |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
|
|
|
|
private String parselabel(String tenantId, WxMsg wxmsg) { |
|
|
|
@@ -197,6 +194,17 @@ public class WxMsgServiceImpl implements WxMsgService { |
|
|
|
if (wxMsgConfigs.size() == 0) return new ResultData(ErrorCode.MSG_SERVER_NOT_FIND, "您还未接入短信运营商,请联系平台管理员"); |
|
|
|
wxMsgConfig = wxMsgConfigs.get(0); |
|
|
|
|
|
|
|
if(wxMsgConfig.getRemains()==0){ |
|
|
|
logger.info("短信数量为0"); |
|
|
|
return new ResultData(ErrorCode.MSG_SEND_ERROR.MSG_SUM_ZERO); |
|
|
|
} |
|
|
|
|
|
|
|
if(wxMsgConfig.getRemains()<wxMsg.getExpectSendNumber()){ |
|
|
|
logger.info("短信数量不足"); |
|
|
|
return new ResultData(ErrorCode.MSG_SUM_INSUFFICENT); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String secret = wxMsgConfig.getSecret(); |
|
|
|
String bid = wxMsgConfig.getBid(); |
|
|
|
String publickey = wxMsgConfig.getPublickey(); |
|
|
|
@@ -248,9 +256,10 @@ public class WxMsgServiceImpl implements WxMsgService { |
|
|
|
wxMsg.setSendstatus(EnumMsgStatus.MSG_SEND_FAIL.getCode()); |
|
|
|
} |
|
|
|
|
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
long id = idWorker.nextId(); |
|
|
|
if (wxMsg.getId() == null) { |
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
wxMsg.setId(idWorker.nextId()); |
|
|
|
wxMsg.setId(id); |
|
|
|
wxMsg.setCreatetime(new Date()); |
|
|
|
wxMsgMapper.insertSelective(wxMsg); |
|
|
|
} else { |
|
|
|
@@ -260,7 +269,7 @@ public class WxMsgServiceImpl implements WxMsgService { |
|
|
|
logger.info("发送短信结束..."); |
|
|
|
if (ret.equals("1")) { |
|
|
|
addMsgCallback(wxMsg,batchNo); |
|
|
|
return new ResultData(Result.SUCCESS, "短信发送中,您可在短信明细中查看发送状态"); |
|
|
|
return new ResultData(Result.SUCCESS, "短信发送中,您可在短信明细中查看发送状态",id); |
|
|
|
} else { |
|
|
|
return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(), "短信发送发败"); |
|
|
|
} |
|
|
|
|