|
|
@@ -7,6 +7,7 @@ import com.iformall.common.ErrorCode; |
|
|
import com.iformall.common.IdWorker; |
|
|
import com.iformall.common.IdWorker; |
|
|
import com.iformall.common.Result; |
|
|
import com.iformall.common.Result; |
|
|
import com.iformall.common.ResultData; |
|
|
import com.iformall.common.ResultData; |
|
|
|
|
|
import com.iformall.domain.po.WxCouponInject; |
|
|
import com.iformall.domain.po.WxMsg; |
|
|
import com.iformall.domain.po.WxMsg; |
|
|
import com.iformall.domain.po.WxMsgCallback; |
|
|
import com.iformall.domain.po.WxMsgCallback; |
|
|
import com.iformall.domain.po.WxMsgConfig; |
|
|
import com.iformall.domain.po.WxMsgConfig; |
|
|
@@ -15,10 +16,7 @@ import com.iformall.enums.EnumMsgSendStatus; |
|
|
import com.iformall.enums.EnumMsgStatus; |
|
|
import com.iformall.enums.EnumMsgStatus; |
|
|
import com.iformall.enums.EnumVerifyCode; |
|
|
import com.iformall.enums.EnumVerifyCode; |
|
|
import com.iformall.exception.MallinkException; |
|
|
import com.iformall.exception.MallinkException; |
|
|
import com.iformall.mapper.WxCUserBasicInfoMapper; |
|
|
|
|
|
import com.iformall.mapper.WxMsgCallbackMapper; |
|
|
|
|
|
import com.iformall.mapper.WxMsgConfigMapper; |
|
|
|
|
|
import com.iformall.mapper.WxMsgMapper; |
|
|
|
|
|
|
|
|
import com.iformall.mapper.*; |
|
|
import com.iformall.service.PushLimitService; |
|
|
import com.iformall.service.PushLimitService; |
|
|
import com.iformall.service.WxCUserTagsService; |
|
|
import com.iformall.service.WxCUserTagsService; |
|
|
import com.iformall.service.WxMsgService; |
|
|
import com.iformall.service.WxMsgService; |
|
|
@@ -34,6 +32,9 @@ import org.springframework.stereotype.Service; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @author gongbiao |
|
|
|
|
|
*/ |
|
|
@Service |
|
|
@Service |
|
|
public class WxMsgServiceImpl implements WxMsgService { |
|
|
public class WxMsgServiceImpl implements WxMsgService { |
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
|
|
@@ -118,9 +119,9 @@ public class WxMsgServiceImpl implements WxMsgService { |
|
|
return new ResultData(e.getErrorCode(),e.getMessage()); |
|
|
return new ResultData(e.getErrorCode(),e.getMessage()); |
|
|
} |
|
|
} |
|
|
if(wxMsg.getExpectSendNumber().intValue()>1000){ |
|
|
if(wxMsg.getExpectSendNumber().intValue()>1000){ |
|
|
batchSendMsg(wxMsg,wxMsgConfig); |
|
|
|
|
|
|
|
|
batchSendMsg(wxMsg,wxMsgConfig,null); |
|
|
}else{ |
|
|
}else{ |
|
|
sendmsg(wxMsg,wxMsgConfig); |
|
|
|
|
|
|
|
|
sendmsg(wxMsg,wxMsgConfig,null); |
|
|
} |
|
|
} |
|
|
return new ResultData(Result.SUCCESS, "短信已发送"); |
|
|
return new ResultData(Result.SUCCESS, "短信已发送"); |
|
|
} else { |
|
|
} else { |
|
|
@@ -150,9 +151,9 @@ public class WxMsgServiceImpl implements WxMsgService { |
|
|
return new ResultData(e.getErrorCode(),e.getMessage()); |
|
|
return new ResultData(e.getErrorCode(),e.getMessage()); |
|
|
} |
|
|
} |
|
|
if(wxMsg.getExpectSendNumber().intValue()>1000){ |
|
|
if(wxMsg.getExpectSendNumber().intValue()>1000){ |
|
|
batchSendMsg(wxMsg,wxMsgConfig); |
|
|
|
|
|
|
|
|
batchSendMsg(wxMsg,wxMsgConfig,null); |
|
|
}else{ |
|
|
}else{ |
|
|
sendmsg(wxMsg,wxMsgConfig); |
|
|
|
|
|
|
|
|
sendmsg(wxMsg,wxMsgConfig,null); |
|
|
} |
|
|
} |
|
|
return new ResultData(Result.SUCCESS, "短信已发送"); |
|
|
return new ResultData(Result.SUCCESS, "短信已发送"); |
|
|
} else { |
|
|
} else { |
|
|
@@ -172,8 +173,14 @@ public class WxMsgServiceImpl implements WxMsgService { |
|
|
wxMsgMapper.deleteByPrimaryKey(id); |
|
|
wxMsgMapper.deleteByPrimaryKey(id); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Async |
|
|
|
|
|
@Override |
|
|
|
|
|
public void sendMsgFromCouponInject(WxMsg wxmsg, WxMsgConfig wxMsgConfig, WxCouponInject couponInject) { |
|
|
|
|
|
batchSendMsg(wxmsg,wxMsgConfig,couponInject); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void batchSendMsg(WxMsg wxMsg,WxMsgConfig wxMsgConfig){ |
|
|
|
|
|
|
|
|
public void batchSendMsg(WxMsg wxMsg,WxMsgConfig wxMsgConfig,WxCouponInject couponInject){ |
|
|
|
|
|
|
|
|
String[] split = wxMsg.getPhones().split(","); |
|
|
String[] split = wxMsg.getPhones().split(","); |
|
|
int length=split.length; |
|
|
int length=split.length; |
|
|
@@ -186,20 +193,20 @@ public class WxMsgServiceImpl implements WxMsgService { |
|
|
String phones = StringUtils.join(phoneList, ","); |
|
|
String phones = StringUtils.join(phoneList, ","); |
|
|
wxMsg.setPhones(phones); |
|
|
wxMsg.setPhones(phones); |
|
|
wxMsg.setExpectSendNumber(extra); |
|
|
wxMsg.setExpectSendNumber(extra); |
|
|
sendmsg(wxMsg,wxMsgConfig); |
|
|
|
|
|
|
|
|
sendmsg(wxMsg,wxMsgConfig,couponInject); |
|
|
}else{ |
|
|
}else{ |
|
|
List<String> phoneList = Arrays.asList(split).subList(i * 1000, (i+1) * 1000); |
|
|
List<String> phoneList = Arrays.asList(split).subList(i * 1000, (i+1) * 1000); |
|
|
String phones = StringUtils.join(phoneList, ","); |
|
|
String phones = StringUtils.join(phoneList, ","); |
|
|
wxMsg.setExpectSendNumber(1000); |
|
|
wxMsg.setExpectSendNumber(1000); |
|
|
wxMsg.setPhones(phones); |
|
|
wxMsg.setPhones(phones); |
|
|
sendmsg(wxMsg,wxMsgConfig); |
|
|
|
|
|
|
|
|
sendmsg(wxMsg,wxMsgConfig,couponInject); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public ResultData sendmsg(WxMsg record,WxMsgConfig wxMsgConfig) { |
|
|
|
|
|
|
|
|
public ResultData sendmsg(WxMsg record,WxMsgConfig wxMsgConfig,WxCouponInject couponInject) { |
|
|
logger.info("发送短信开始..."); |
|
|
logger.info("发送短信开始..."); |
|
|
|
|
|
|
|
|
|
|
|
logger.info("couponInject:"+couponInject); |
|
|
String secret = wxMsgConfig.getSecret(); |
|
|
String secret = wxMsgConfig.getSecret(); |
|
|
String bid = wxMsgConfig.getBid(); |
|
|
String bid = wxMsgConfig.getBid(); |
|
|
String publickey = wxMsgConfig.getPublickey(); |
|
|
String publickey = wxMsgConfig.getPublickey(); |
|
|
@@ -241,9 +248,12 @@ public class WxMsgServiceImpl implements WxMsgService { |
|
|
String systemTime = DateUtils.getSystemTime("yyyy-MM-dd HH:mm:ss"); |
|
|
String systemTime = DateUtils.getSystemTime("yyyy-MM-dd HH:mm:ss"); |
|
|
wxMsg.setSendtime(systemTime); |
|
|
wxMsg.setSendtime(systemTime); |
|
|
wxMsg.setCreatetime(DateUtils.stringToDate(systemTime,"yyyy-MM-dd HH:mm:ss")); |
|
|
wxMsg.setCreatetime(DateUtils.stringToDate(systemTime,"yyyy-MM-dd HH:mm:ss")); |
|
|
|
|
|
//精准投放 |
|
|
|
|
|
if(couponInject!=null){ |
|
|
|
|
|
wxMsg.setCouponInjectId(couponInject.getId()); |
|
|
|
|
|
} |
|
|
wxMsgMapper.insertSelective(wxMsg); |
|
|
wxMsgMapper.insertSelective(wxMsg); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger.info("发送短信结束..."); |
|
|
logger.info("发送短信结束..."); |
|
|
if (ret.equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode().toString())) { |
|
|
if (ret.equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode().toString())) { |
|
|
addMsgCallback(wxMsg,batchNo); |
|
|
addMsgCallback(wxMsg,batchNo); |
|
|
|