Authored by linlong

update

package com.yoho.unions.channel.restapi;
import com.yoho.service.model.union.request.ChannelBlackListRequestBO;
import com.yoho.service.model.union.request.ChannelGroupRequestBO;
import com.yoho.service.model.union.response.PageBlackListRspBO;
import com.yoho.service.model.union.response.PageChannelGroupRspBO;
import com.yoho.unions.channel.service.IChannelBlackListService;
import com.yoho.unions.common.ApiResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* Created by yoho on 2017/2/23.
*/
@Controller
@RequestMapping("/channel")
public class ChannelBlackListRest {
static Logger logger = LoggerFactory.getLogger(ChannelBlackListRest.class);
@Autowired
private IChannelBlackListService channelBlackListService;
@RequestMapping("/queryBlackList")
@ResponseBody
public ApiResponse queryBlackList(ChannelBlackListRequestBO channelBlackListRequestBO) {
logger.info("enter queryBlackList. param channelBlackListRequestBO={}", channelBlackListRequestBO);
try {
PageBlackListRspBO pageBlackListRspBO = channelBlackListService.queryBlackList(channelBlackListRequestBO);
return new ApiResponse.ApiResponseBuilder().code(200).message("成功").data(pageBlackListRspBO).build();
} catch (Exception e) {
logger.warn("queryBlackList occurs Exception e {}",e.getMessage());
return new ApiResponse.ApiResponseBuilder().code(500).message("失败").build();
}
}
@RequestMapping("/addBlack")
@ResponseBody
public ApiResponse addBlack(@RequestBody ChannelBlackListRequestBO channelBlackListRequestBO) {
logger.info("enter addBlack. param channelBlackListRequestBO={}", channelBlackListRequestBO);
int count = channelBlackListService.addBlack(channelBlackListRequestBO);
if (count>0){
return new ApiResponse.ApiResponseBuilder().code(200).message("成功").build();
}else{
return new ApiResponse.ApiResponseBuilder().code(500).message("失败").build();
}
}
@RequestMapping("/deleteBlack")
@ResponseBody
public ApiResponse deleteBlack(ChannelBlackListRequestBO channelBlackListRequestBO) {
logger.info("enter deleteBlack. param channelBlackListRequestBO={}", channelBlackListRequestBO);
int count = channelBlackListService.deleteBlack(channelBlackListRequestBO);
if (count>0){
return new ApiResponse.ApiResponseBuilder().code(200).message("成功").build();
}else{
return new ApiResponse.ApiResponseBuilder().code(500).message("失败").build();
}
}
}
... ...
... ... @@ -5,7 +5,7 @@ import com.yoho.service.model.union.request.ChannelMessageRequestBO;
import com.yoho.service.model.union.request.ChannelUserRequest;
import com.yoho.service.model.union.request.UserInfoBO;
import com.yoho.service.model.union.response.PageChannelGroupRspBO;
import com.yoho.unions.channel.service.ChannelGroupService;
import com.yoho.unions.channel.service.IChannelGroupService;
import com.yoho.unions.common.ApiResponse;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -30,7 +30,7 @@ public class ChannelGroupRest {
static Logger logger = LoggerFactory.getLogger(ChannelGroupRest.class);
@Autowired
private ChannelGroupService channelGroupService;
private IChannelGroupService channelGroupService;
@Autowired
private HttpSession session;
... ... @@ -68,6 +68,11 @@ public class ChannelGroupRest {
}
/**
* 批量添加黑名单,逗号分隔手机号
* @param mobiles
* @return
*/
@RequestMapping("/addBlackList")
@ResponseBody
public ApiResponse addBlackList(String mobiles){
... ... @@ -79,6 +84,22 @@ public class ChannelGroupRest {
return new ApiResponse.ApiResponseBuilder().code(200).message("成功").build();
}
@RequestMapping("/deleteGroup")
@ResponseBody
public ApiResponse deleteGroup(int groupId){
logger.info("enter deleteGroup. param groupId={}", groupId);
if(groupId<1){
return new ApiResponse.ApiResponseBuilder().code(500).message("缺少参数").build();
}
int count = channelGroupService.deleteGroup(groupId);
if (count>0){
return new ApiResponse.ApiResponseBuilder().code(200).message("成功").build();
}else{
return new ApiResponse.ApiResponseBuilder().code(500).message("删除失败").build();
}
}
@RequestMapping("/getCondition")
@ResponseBody
public ApiResponse getCondition(String ids){
... ...
package com.yoho.unions.channel.service;
import com.yoho.service.model.union.request.ChannelBlackListRequestBO;
import com.yoho.service.model.union.response.PageBlackListRspBO;
import com.yoho.service.model.union.response.PageChannelGroupRspBO;
/**
* Created by yoho on 2017/2/23.
*/
public interface IChannelBlackListService {
PageBlackListRspBO queryBlackList(ChannelBlackListRequestBO channelBlackListRequestBO);
int addBlack(ChannelBlackListRequestBO channelBlackListRequestBO);
int deleteBlack(ChannelBlackListRequestBO channelBlackListRequestBO);
}
... ...
... ... @@ -14,7 +14,7 @@ import java.util.Map;
/**
* Created by yoho on 2017/2/15.
*/
public interface ChannelGroupService {
public interface IChannelGroupService {
PageChannelGroupRspBO queryChannelGroupList(ChannelGroupRequestBO channelGroupRequestBO);
... ... @@ -28,4 +28,6 @@ public interface ChannelGroupService {
void saveGroup(ChannelUserRequest request, UserInfoBO userInfo);
void addBlackList(String mobiles);
int deleteGroup(int groupId);
}
... ...
package com.yoho.unions.channel.service.impl;
import com.yoho.service.model.union.request.ChannelBlackListRequestBO;
import com.yoho.service.model.union.response.BlackListRspBO;
import com.yoho.service.model.union.response.PageBlackListRspBO;
import com.yoho.unions.channel.service.IChannelBlackListService;
import com.yoho.unions.dal.IChannelSmsBlackDAO;
import com.yoho.unions.dal.model.ChannelSmsBlack;
import com.yoho.unions.utils.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Created by yoho on 2017/2/23.
*/
@Service
public class ChannelBlackListServiceImpl implements IChannelBlackListService{
static Logger logger = LoggerFactory.getLogger(ChannelBlackListServiceImpl.class);
@Autowired
IChannelSmsBlackDAO channelSmsBlackDAO;
@Override
public PageBlackListRspBO queryBlackList(ChannelBlackListRequestBO channelBlackListRequestBO) {
logger.info("enter queryBlackList. param channelBlackListRequestBO={}", channelBlackListRequestBO);
int total = channelSmsBlackDAO.selectListCountByParam(channelBlackListRequestBO);
List<BlackListRspBO> channelBlackList = channelSmsBlackDAO.selectListByParam(channelBlackListRequestBO);
PageBlackListRspBO pageBlackListRspBO = new PageBlackListRspBO();
pageBlackListRspBO.setList(channelBlackList);
pageBlackListRspBO.setTotal(total);
pageBlackListRspBO.setPage(pageBlackListRspBO.getPage());
return pageBlackListRspBO;
}
@Override
public int addBlack(ChannelBlackListRequestBO channelBlackListRequestBO) {
logger.info("enter addBlack. param channelBlackListRequestBO={}", channelBlackListRequestBO);
ChannelSmsBlack smsBlack = new ChannelSmsBlack();
smsBlack.setMobile(channelBlackListRequestBO.getMobile());
smsBlack.setCreateTime(DateUtils.getCurrentTimeSecond());
int count = channelSmsBlackDAO.insertSelective(smsBlack);
return count;
}
@Override
public int deleteBlack(ChannelBlackListRequestBO channelBlackListRequestBO) {
logger.info("enter deleteBlack. param channelBlackListRequestBO={}", channelBlackListRequestBO);
int count = channelSmsBlackDAO.deleteByPrimaryKey(channelBlackListRequestBO.getId());
return count;
}
}
... ...
... ... @@ -13,7 +13,7 @@ import com.yoho.service.model.union.request.ChannelUserRequest;
import com.yoho.service.model.union.request.UserInfoBO;
import com.yoho.service.model.union.response.ChannelGroupRspBO;
import com.yoho.service.model.union.response.PageChannelGroupRspBO;
import com.yoho.unions.channel.service.ChannelGroupService;
import com.yoho.unions.channel.service.IChannelGroupService;
import com.yoho.unions.common.utils.DateUtil;
import com.yoho.unions.common.utils.ErpApiServiceHelper;
import com.yoho.unions.dal.*;
... ... @@ -35,8 +35,8 @@ import java.util.stream.Collectors;
* Created by yoho on 2017/2/15.
*/
@Service
public class ChannelGroupServiceImpl implements ChannelGroupService {
static Logger logger = LoggerFactory.getLogger(ChannelGroupService.class);
public class ChannelGroupServiceImpl implements IChannelGroupService {
static Logger logger = LoggerFactory.getLogger(ChannelGroupServiceImpl.class);
@Autowired
private IChannelGroupDAO channelGroupDAO;
... ... @@ -88,7 +88,7 @@ public class ChannelGroupServiceImpl implements ChannelGroupService {
}};
public final static Map channelSourceMap = new HashedMap(){{
public final static Map channelSourceMap = new HashedMap() {{
put("5", "淘宝B店订单");
put("8", "淘宝C店订单");
put("9", "淘宝LAL店订单");
... ... @@ -113,6 +113,7 @@ public class ChannelGroupServiceImpl implements ChannelGroupService {
}
// (2)查询:总数和列表
channelGroupRequestBO.setStatus(1);
int total = channelGroupDAO.selectListCountByParam(channelGroupRequestBO);
List<ChannelGroupRspBO> channelGroupBOList = channelGroupDAO.selectListByParam(channelGroupRequestBO);
... ... @@ -126,19 +127,19 @@ public class ChannelGroupServiceImpl implements ChannelGroupService {
}
@Override
public int sendMessage(ChannelMessageRequestBO channelGroupRequestBO,int sendUserId) {
public int sendMessage(ChannelMessageRequestBO channelGroupRequestBO, int sendUserId) {
logger.info("enter sendMessage. param channelGroupRequestBO{}", channelGroupRequestBO);
int groupId = channelGroupRequestBO.getGroupId();
String content = channelGroupRequestBO.getContent();
//1.根据groupId查询条件
List<ChannelGroupCondition> conditions = channelGroupConditionDAO.selectByGroupId(groupId);
logger.info("sendMessage:conditions is {}",conditions);
Map<String, Object> params = conditions.stream().collect(Collectors.toMap(ChannelGroupCondition::getKey,ChannelGroupCondition::getValue));
logger.info("sendMessage:conditions is {}", conditions);
Map<String, Object> params = conditions.stream().collect(Collectors.toMap(ChannelGroupCondition::getKey, ChannelGroupCondition::getValue));
//2.根据条件分批查询手机号
int total = channelUserDAO.selectCount(params);
if(total==0){
if (total == 0) {
logger.info("not find users to send message,param channelGroupRequestBO{}", channelGroupRequestBO);
return 0;
}
... ... @@ -146,7 +147,7 @@ public class ChannelGroupServiceImpl implements ChannelGroupService {
//2.1分批从数据库中查询,每次1000,使用mobileSet去重
for (int i = 0; i < total; i += BATCH_MESSAGE_NUMBER) {
List<ChannelUser> channelUsers = channelUserDAO.selectPage(params, i, i + BATCH_MESSAGE_NUMBER);
Set<String> channelMobiles= channelUsers.stream().map(ChannelUser::getMobile).collect(Collectors.toSet());
Set<String> channelMobiles = channelUsers.stream().map(ChannelUser::getMobile).collect(Collectors.toSet());
mobileSet.addAll(channelMobiles);
}
... ... @@ -155,7 +156,7 @@ public class ChannelGroupServiceImpl implements ChannelGroupService {
mobileSet.removeAll(blackList);
//剔除黑名单后,发送手机号为空,返回
if(CollectionUtils.isEmpty(mobileSet)){
if (CollectionUtils.isEmpty(mobileSet)) {
logger.info("not find users to send message,param channelGroupRequestBO{}", channelGroupRequestBO);
return 0;
}
... ... @@ -165,43 +166,43 @@ public class ChannelGroupServiceImpl implements ChannelGroupService {
UserInfoBO userInfoBO = null;
try{
userInfoBO = erpApiServiceHelper.getUserByPid(String.valueOf(sendUserId));
}catch (Exception e){
logger.warn("call erpApiServiceHelper.getUserByPid occurs Exception,e is {}",e.getMessage());
try {
userInfoBO = erpApiServiceHelper.getUserByPid(String.valueOf(sendUserId));
} catch (Exception e) {
logger.warn("call erpApiServiceHelper.getUserByPid occurs Exception,e is {}", e.getMessage());
}
String sendUserName = userInfoBO!=null?userInfoBO.getAccount():"";
ChannelGroupBatch channelGroupBatch = new ChannelGroupBatch(groupId, content, sendTime, sendUserId,sendUserName);
String sendUserName = userInfoBO != null ? userInfoBO.getAccount() : "";
ChannelGroupBatch channelGroupBatch = new ChannelGroupBatch(groupId, content, sendTime, sendUserId, sendUserName);
channelGroupBatchDAO.insertSelective(channelGroupBatch);
logger.info("sendMessage:insert channelGroupBatch,channelGroupBatch ={}",channelGroupBatch);
logger.info("sendMessage:insert channelGroupBatch,channelGroupBatch ={}", channelGroupBatch);
int groupBatchId = channelGroupBatch.getId();
List<String> mobileList = Lists.newArrayList(mobileSet);
List<ChannelSmsDetail> smsDetails = Lists.newArrayList();
//4.用户去重、黑名单后,分批发送短信
List<String> mobiles = null;
int successCount = 0 ;
int successCount = 0;
for (int i = 0; i < mobileList.size(); i += BATCH_MESSAGE_NUMBER) {
if(i + BATCH_MESSAGE_NUMBER>mobileList.size()){
if (i + BATCH_MESSAGE_NUMBER > mobileList.size()) {
mobiles = mobileList.subList(i, mobileList.size());
}else{
} else {
mobiles = mobileList.subList(i, i + BATCH_MESSAGE_NUMBER);
}
String mobile = StringUtils.join(mobiles.toArray(), ",");
//调用SDK发送短信接口
SendMessageRspBo sendMessageRspBo = null;
try{
try {
sendMessageRspBo = sendCrmMessage.generalSceneMsg(mobile, content);
logger.info("sendMessage:call generalSceneMsg,sendMessageRspBo is {}",sendMessageRspBo);
}catch (Exception e){
logger.warn("sendMessage:call generalSceneMsg occurs Exception,e is {}",e.getMessage());
logger.info("sendMessage:call generalSceneMsg,sendMessageRspBo is {}", sendMessageRspBo);
} catch (Exception e) {
logger.warn("sendMessage:call generalSceneMsg occurs Exception,e is {}", e.getMessage());
}
//4.1短信发送成功,记录短信日志表(状态为1)
if (sendMessageRspBo!=null&&sendMessageRspBo.getCode() == 200 && sendMessageRspBo.getMessage().equals("SUCCESS")) {
if (sendMessageRspBo != null && sendMessageRspBo.getCode() == 200 && sendMessageRspBo.getMessage().equals("SUCCESS")) {
for (String sms : mobiles) {
ChannelSmsDetail channelSmsDetail = new ChannelSmsDetail(sms, groupBatchId, SMS_STATUS_SUCCESS, sendTime);
smsDetails.add(channelSmsDetail);
... ... @@ -217,7 +218,7 @@ public class ChannelGroupServiceImpl implements ChannelGroupService {
}
channelSmsDetailDAO.batchInsert(smsDetails);
logger.info("sendMessage:insert channelSmsDetai,smsDetails is {}",smsDetails);
logger.info("sendMessage:insert channelSmsDetai,smsDetails is {}", smsDetails);
//5.修改分组表的分组人数、发送时间、修改时间、内容、发送人
ChannelGroup channelGroup = new ChannelGroup();
... ... @@ -231,83 +232,111 @@ public class ChannelGroupServiceImpl implements ChannelGroupService {
// channelGroup.setSmsNumber(groupBatchId);
// channelGroup.setSendUserName(sendUserName);
channelGroupDAO.updateByPrimaryKeySelective(channelGroup);
logger.info("sendMessage:update channelGroup,channelGroup is {}",channelGroup);
logger.info("sendMessage:update channelGroup,channelGroup is {}", channelGroup);
return 1;
}
@Override
public Map<Integer,String> getCondition(String ids) {
public Map<Integer, String> getCondition(String ids) {
logger.info("enter getCondition. param ids={}", ids);
List groupIds = Arrays.asList(ids.split(","));
//1.查询出所有分组的条件
List<ChannelGroupCondition> channelGroupConditions = channelGroupConditionDAO.selectByGroupIds(groupIds);
Map<Integer,Map<String,String>> conditionMap = Maps.newHashMap();
Map<Integer, Map<String, String>> conditionMap = Maps.newHashMap();
//2.将查询出的条件按照groupId进行合并
if(!CollectionUtils.isEmpty(channelGroupConditions)){
for(int i=0;i<channelGroupConditions.size();i++){
if (!CollectionUtils.isEmpty(channelGroupConditions)) {
for (int i = 0; i < channelGroupConditions.size(); i++) {
ChannelGroupCondition channelGroupCondition = channelGroupConditions.get(i);
if(conditionMap.get(channelGroupCondition.getGroupId())!=null){
Map<String,String> condition = conditionMap.get(channelGroupCondition.getGroupId());
condition.put(channelGroupCondition.getKey(),channelGroupCondition.getValue());
conditionMap.put(channelGroupCondition.getGroupId(),condition);
}else{
Map<String,String> condition = Maps.newHashMap();
condition.put(channelGroupCondition.getKey(),channelGroupCondition.getValue());
conditionMap.put(channelGroupCondition.getGroupId(),condition);
if (conditionMap.get(channelGroupCondition.getGroupId()) != null) {
Map<String, String> condition = conditionMap.get(channelGroupCondition.getGroupId());
condition.put(channelGroupCondition.getKey(), channelGroupCondition.getValue());
conditionMap.put(channelGroupCondition.getGroupId(), condition);
} else {
Map<String, String> condition = Maps.newHashMap();
condition.put(channelGroupCondition.getKey(), channelGroupCondition.getValue());
conditionMap.put(channelGroupCondition.getGroupId(), condition);
}
}
}
logger.info("getCondition. conditionMap={}", conditionMap);
Map<Integer,String> result = Maps.newHashMap();
Map<Integer, String> result = Maps.newHashMap();
//3.将条件的key、value转为页面显示的名字
for (Map.Entry<Integer,Map<String,String>> entry : conditionMap .entrySet()) {
Map<String,String> map = entry.getValue();
for (Map.Entry<Integer, Map<String, String>> entry : conditionMap.entrySet()) {
Map<String, String> map = entry.getValue();
StringBuffer sb = new StringBuffer();
convertTime(map,"beginChannelOrderTime","endChannelOrderTime",sb);
convertTime(map,"beginYHOrderTime","endYHOrderTime",sb);
convertTime(map,"beginRegisterTime","endRegisterTime",sb);
convertTime(map,"beginSmsTime","endSmsTime",sb);
convertTime(map, "beginChannelOrderTime", "endChannelOrderTime", sb);
convertTime(map, "beginYHOrderTime", "endYHOrderTime", sb);
convertTime(map, "beginRegisterTime", "endRegisterTime", sb);
convertTime(map, "beginSmsTime", "endSmsTime", sb);
convertChannelSource(map,"channelSource",sb);
for(Map.Entry<String,String> entry1:map.entrySet()){
for (Map.Entry<String, String> entry1 : map.entrySet()) {
String key = entry1.getKey();
if(key.equals("channelSource")){
String channelSource = entry1.getValue();
sb.append("<div>").append(paramMap.get(key)).append(":").append(channelSourceMap.get(channelSource)).append("</div>");
}else if(key.equals("hasUid")||key.equals("hasYHOrder")){
if (key.equals("hasUid") || key.equals("hasYHOrder")) {
String has = entry1.getValue();
sb.append("<div>").append(paramMap.get(key)).append(":").append(has.equals("1")?"是":"否").append("</div>");
}else{
sb.append("<div>").append(paramMap.get(key)).append(":").append(has.equals("1") ? "是" : "否").append("</div>");
} else {
sb.append("<div>").append(paramMap.get(key)).append(":").append(entry1.getValue()).append("</div>");
}
}
result.put(entry.getKey(),sb.toString());
result.put(entry.getKey(), sb.toString());
}
return result;
}
private void convertChannelSource(Map<String, String> map, String channelSource, StringBuffer sb) {
if (map.get(channelSource) != null) {
String source = map.get(channelSource);
String[] sources = source.split(",");
StringBuffer sourceStr = new StringBuffer();
sourceStr.append("<div>").append(paramMap.get(channelSource)).append(":");
for(int i=0;i<sources.length;i++){
sourceStr.append(channelSourceMap.get(sources[i])).append(" ");
}
sb.append(sourceStr).append("</div>");
map.remove(channelSource);
}
}
@Override
public void addBlackList(String mobiles) {
logger.info("enter addBlackList. param mobiles={}", mobiles);
int creteTime = DateUtils.getCurrentTimeSecond();
List<String> list = Arrays.asList(mobiles.split(","));
channelSmsBlackDAO.batchInsert(list,creteTime);
channelSmsBlackDAO.batchInsert(list, creteTime);
}
@Override
public int deleteGroup(int groupId) {
logger.info("enter deleteGroup. param groupId={}", groupId);
ChannelGroup channelGroup = new ChannelGroup();
channelGroup.setId(groupId);
channelGroup.setStatus(0);
//逻辑删除,status状态置0
int count = channelGroupDAO.updateByPrimaryKeySelective(channelGroup);
if (count > 0) {
logger.info("deleteGroup success. param groupId={}", groupId);
} else {
logger.warn("deleteGroup fail. param groupId={}", groupId);
}
return count;
}
private void convertTime(Map<String, String> map, String beginTimeKey, String endTimeKey, StringBuffer sb) {
if(map.get(beginTimeKey)!=null || map.get(endTimeKey)!=null){
if (map.get(beginTimeKey) != null || map.get(endTimeKey) != null) {
String beginTime = map.get(beginTimeKey);
String endTime = map.get(endTimeKey);
if(beginTime!=null){
beginTime = DateUtils.int2DateStr(Integer.parseInt(beginTime),"yyyy-MM-dd HH:mm:ss");
}else{
if (beginTime != null) {
beginTime = DateUtils.int2DateStr(Integer.parseInt(beginTime), "yyyy-MM-dd HH:mm:ss");
} else {
beginTime = "未设置";
}
if(endTime!=null){
endTime = DateUtils.int2DateStr(Integer.parseInt(endTime),"yyyy-MM-dd HH:mm:ss");
}else{
if (endTime != null) {
endTime = DateUtils.int2DateStr(Integer.parseInt(endTime), "yyyy-MM-dd HH:mm:ss");
} else {
endTime = "未设置";
}
sb.append("<div>").append(paramMap.get("beginChannelOrderTime")).append(":").append( beginTime).append("----").append(endTime).append("</div>");
sb.append("<div>").append(paramMap.get("beginChannelOrderTime")).append(":").append(beginTime).append("----").append(endTime).append("</div>");
map.remove(beginTimeKey);
map.remove(endTimeKey);
}
... ...
... ... @@ -36,10 +36,14 @@
<value>/channel/queryChannelGroupList</value>
<value>/channel/sendMessage</value>
<value>/channel/addBlackList</value>
<value>/channel/queryBlackList</value>
<value>/channel/getCondition</value>
<value>/channel/user_list</value>
<value>/channel/addGroup</value>
<value>/channel/user_msg_list</value>
<value>/channel/addBlack</value>
<value>/channel/deleteBlack</value>
<value>/channel/deleteGroup</value>
<value>/LoginController/loginForPid.do</value>
<value>/batch/export.do</value>
</list>
... ...
package com.yoho.unions.dal;
import com.yoho.service.model.union.request.ChannelBlackListRequestBO;
import com.yoho.service.model.union.response.BlackListRspBO;
import com.yoho.unions.dal.model.ChannelSmsBlack;
import org.apache.ibatis.annotations.Param;
... ... @@ -30,4 +32,8 @@ public interface IChannelSmsBlackDAO {
* @return
*/
int batchInsert(@Param("list") List<String> list,@Param("createTime") int createTime);
int selectListCountByParam(ChannelBlackListRequestBO channelBlackListRequestBO);
List<BlackListRspBO> selectListByParam(ChannelBlackListRequestBO channelBlackListRequestBO);
}
\ No newline at end of file
... ...
... ... @@ -23,6 +23,16 @@ public class ChannelGroup {
private String createUserName;
private int status;
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
private Integer updateTime;
public Integer getId() {
... ...
... ... @@ -9,6 +9,7 @@
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="create_user" property="createUser" jdbcType="INTEGER" />
<result column="create_userName" property="createUserName" jdbcType="VARCHAR" />
<result column="status" property="status" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<resultMap id="groupResultMap" type="com.yoho.service.model.union.response.ChannelGroupRspBO" extends="BaseResultMap">
... ... @@ -19,7 +20,7 @@
<result column="content" property="content" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, name, group_number,success_count, create_time, create_user, create_userName, update_time
id, name, group_number,success_count, create_time, create_user, create_userName, status,update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
... ... @@ -33,10 +34,10 @@
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.ChannelGroup" keyProperty="id" useGeneratedKeys="true" >
insert into channel_group (id, name, group_number,success_count,
create_time, create_user, create_userName,update_time
create_time, create_user, create_userName,status,update_time
)
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{groupNumber,jdbcType=INTEGER},#{successCount,jdbcType=INTEGER},
#{createTime,jdbcType=INTEGER}, #{createUser,jdbcType=INTEGER}, #{createUserName,jdbcType=VARCHAR}, #{updateTime,jdbcType=INTEGER}
#{createTime,jdbcType=INTEGER}, #{createUser,jdbcType=INTEGER}, #{createUserName,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},#{updateTime,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.ChannelGroup" >
... ... @@ -63,6 +64,9 @@
<if test="createUserName != null" >
create_userName,
</if>
<if test="status != null" >
status,
</if>
<if test="updateTime != null" >
update_time,
</if>
... ... @@ -89,6 +93,9 @@
<if test="createUserName != null" >
#{createUserName,jdbcType=VARCHAR},
</if>
<if test="status != null" >
#{status,jdbcType=VARCHAR},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=INTEGER},
</if>
... ... @@ -115,6 +122,9 @@
<if test="createUserName != null" >
create_userName = #{createUserName,jdbcType=VARCHAR},
</if>
<if test="status != null" >
status = #{createUserName,jdbcType=VARCHAR},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=INTEGER},
</if>
... ... @@ -129,10 +139,11 @@
create_time = #{createTime,jdbcType=INTEGER},
create_user = #{createUser,jdbcType=INTEGER},
create_userName = #{createUserName,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id ="selectListCountByParam" parameterType="java.lang.Integer" resultType="java.lang.Integer">
<select id ="selectListCountByParam" resultType="java.lang.Integer">
select count(*) from channel_group cg
left join channel_group_batch cgb
on cg.id = cgb.group_id
... ... @@ -149,6 +160,9 @@
<if test="createUserName != null" >
and create_userName LIKE CONCAT('%',#{createUserName,jdbcType=VARCHAR},'%')
</if>
<if test="status != null" >
and status = #{status,jdbcType=INTEGER}
</if>
<if test="smsNumber != null" >
and cgb.id = #{smsNumber,jdbcType=INTEGER}
</if>
... ... @@ -182,6 +196,9 @@
<if test="createUserName != null" >
and create_userName LIKE CONCAT('%',#{createUserName,jdbcType=VARCHAR},'%')
</if>
<if test="status != null" >
and status = #{status,jdbcType=INTEGER}
</if>
<if test="smsNumber != null" >
and cgb.id = #{smsNumber,jdbcType=INTEGER}
</if>
... ...
... ... @@ -87,4 +87,21 @@
)
</foreach >
</insert >
<select id ="selectListCountByParam" parameterType="com.yoho.service.model.union.request.ChannelBlackListRequestBO" resultType="java.lang.Integer">
select count(*) from channel_sms_black
<where>
<if test="mobile!= null" >
mobile = #{mobile,jdbcType=VARCHAR}
</if>
</where>
</select>
<select id="selectListByParam" resultMap="BaseResultMap" parameterType="com.yoho.service.model.union.request.ChannelBlackListRequestBO">
SELECT <include refid="Base_Column_List" /> from channel_sms_black
<where>
<if test="mobile!= null" >
mobile = #{mobile,jdbcType=VARCHAR}
</if>
</where>
ORDER BY create_time DESC limit #{start,jdbcType=INTEGER}, #{size,jdbcType=INTEGER}
</select>
</mapper>
\ No newline at end of file
... ...
<div id="blackDialog">
<form id="blackAddForm" method="post" style="padding-left: 20px; padding-top: 20px;">
<div class="fitem" style="padding-top: 10px;">
<label for="mobile">手机号:</label>
<input class="easyui-validatebox" type="text" id="mobile" name="mobile" data-options="required:true" />
</div>
</form>
</div>
\ No newline at end of file
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Yoho!Buy运营平台</title>
<script src="/union/js/include.js"></script>
<script src="/union/js/ajaxfileupload.js"></script>
</head>
<body class="easyui-layout" fit="true">
<div id="search" region="north" style="padding-bottom: 35px;">
<!--<script>-->
<!--document.write(addHead('市场管理', '泛渠道用户管理'));-->
<!--</script>-->
<style>
.div_search input {
margin-top: 20px;
}
.div_search .textbox {
margin-top: 20px;
}
.div_search .easyui-linkbutton {
margin-top: 20px;
}
</style>
<div style="margin-left: 30px;" class="div_search">
<input type="text" id="phone"/>
<a id="searchBlack" class="easyui-linkbutton btn-info" style="margin-left: 30px; "></a>
<a id="addBlack" class="easyui-linkbutton btn-info" style="margin-left: 30px; "></a>
</div>
</div>
<div region="center">
<div style="margin-left: 30px;margin-top: 20px; height: 500px;">
<table id="blackListTalbe"></table>
</div>
</div>
<script>
$(function () {
$("#phone").textbox({
prompt: "手机号",
width: 180
});
$("#blackListTalbe").myDatagrid({
fit: true,
fitColumns: true,
//queryParams: param,
nowrap: false,
url: contextPath + "/channel/queryBlackList",
method: 'POST',
loadFilter: function (data) {
var temp = defaultLoadFilter(data);
temp.rows = temp.list;
return temp;
},
columns: [[{
title: "ID",
field: "id",
width: 70,
align: "center"
}, {
title: "手机号",
field: "mobile",
width: 170,
align: "center"
}, {
title: "创建时间",
field: "createTime",
width: 170,
align: "center"
}, {
title: "操作",
field: "asdf",
width: 200,
align: "center",
formatter: function (value, rowData, rowIndex) {
var str = "<a role='delete' dataId='" + rowData.id + "' style='margin-left:10px'>删除</a>";
return str;
}
}
]],
cache: false,
pagination: true,
pageSize: 10,
pageList: [10],
idField: "id",
singleSelect: false,
checkOnSelect: false,
onLoadSuccess: function (data) {
$(this).myDatagrid("getPanel").find("a[role='delete']").linkbutton({
iconCls: "icon-more",
onClick: function () {
deleteBlack($(this).attr("dataId"));
}
});
}
});
$("#searchBlack").linkbutton({
iconCls: "icon-search",
text: "查询",
onClick: function () {
var param = {};
if ($("#phone").val() != '') {
param.mobile = $("#phone").val();
}
$("#blackListTalbe").myDatagrid("load", param);
}
});
$("#addBlack").linkbutton({
iconCls: "icon-search",
text: "增加",
onClick: function () {
var param = {};
var div = $("<div>").appendTo($(window.self.document.body));
window.self.$(div).myDialog({
modal : true,
collapsible : true,
cache : false,
title : "短信列表",
width: 600,
height: 600,
href: contextPath + "/html/channel/blackAdd.html",
buttons : [{
text : "保存",
iconCls : "icon-save",
handler : function() {
var param = getParams();
var mobile = $.trim($("#mobile").val());
if (mobile.length == 0) {
window.self.$.messager.alert("提示消息", "请输入手机号");
return;
}
param['mobile'] = mobile ;
$.ajax({
type: "POST",
contentType: "application/json",
url: contextPath + '/channel/addBlack',
data: JSON.stringify(param),
dataType: 'json',
success: function(result) {
window.self.$.messager.alert("提示消息",result.message, "", function () {
window.location.href = contextPath + "/html/channel/channelGroupList.html";
});
window.self.$(div).dialog('close');
}
});
}
},{
id : "closeBtn",
text : "关闭",
iconCls : "icon-cancel",
handler : function() {
window.self.$(div).dialog('close');
}
}]
});
}
});
});
function deleteBlack(id) {
$.messager.confirm("确认", "确认删除该黑名单吗?", function (flag) {
if (flag) {
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后...",
interval: 500,
text: ""
});
$.post(contextPath + "/channel/deleteBlack", {id: id}, function (data) {
$.messager.progress("close");
if (data.code == 200) {
$("#blackListTalbe").myDatagrid("reload");
$.messager.show({
title: "提示",
msg: "删除黑名单成功!",
height: 120
});
} else {
$.messager.alert("失败", data.message, "error");
}
}, "json");
}
});
}
</script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -12,24 +12,32 @@
document.write(addHead('市场管理', '分组营销管理'));
</script>
<style>
.div_search input { margin-top: 20px; }
.div_search .textbox { margin-top: 20px; }
.div_search .easyui-linkbutton { margin-top: 20px; }
.div_search input {
margin-top: 20px;
}
.div_search .textbox {
margin-top: 20px;
}
.div_search .easyui-linkbutton {
margin-top: 20px;
}
</style>
<div style="margin-left: 30px;" class="div_search">
<input type="text" id="name"/>
<input id="createTimeBegin" type="text" class="easyui-datetimebox" editable="false" >
<input id="createTimeBegin" type="text" class="easyui-datetimebox" editable="false">
<label>~</label>
<input id="createTimeEnd" type="text" class="easyui-datetimebox" editable="false" >
<input id="createTimeEnd" type="text" class="easyui-datetimebox" editable="false">
<input type="text" id="createUserName"/>
<input type="text" id="smsNumber"/>
<input type="text" id="sendUserName"/>
<input id="sendTimeBegin" type="text" class="easyui-datetimebox" editable="false" >
<input id="sendTimeBegin" type="text" class="easyui-datetimebox" editable="false">
<label>~</label>
<input id="sendTimeEnd" type="text" class="easyui-datetimebox" editable="false" >
<a id="searchBtn" class="easyui-linkbutton btn-info" style="margin-left: 30px; "></a>
<input id="sendTimeEnd" type="text" class="easyui-datetimebox" editable="false">
<a id="searchBtn" class="easyui-linkbutton btn-info" style="margin-left: 30px; "></a>
<a id="searchBtnAll" class="easyui-linkbutton btn-primary" style="margin-left: 30px;"></a>
<a id="blackList" class="easyui-linkbutton btn-primary" style="margin-left: 30px;"></a>
</div>
</div>
<div region="center">
... ... @@ -118,70 +126,70 @@
width: 170,
align: "center",
formatter: function (value, rowData, rowIndex) {
return '<span id="condition-'+rowIndex+'" >条件筛选</span>';
return '<span id="condition-' + rowIndex + '" >条件筛选</span>';
}
},{
}, {
title: "创建时间",
field: "createTime",
width: 170,
align: "center"
},{
}, {
title: "创建人",
field: "createUserName",
width: 170,
align: "center"
},{
}, {
title: "发送批次",
field: "smsNumber",
width: 170,
align: "center"
},{
}, {
title: "发送时间",
field: "sendTime",
width: 170,
align: "center"
},{
}, {
title: "发送人",
field: "sendUserName",
width: 170,
align: "center"
},{
}, {
title: "发送内容",
field: "content",
width: 170,
align: "center"
},{
}, {
title: "发送结果分析",
field: "successCount",
width: 170,
width: 140,
align: "center",
formatter: function (value, rowData, rowIndex) {
if(rowData.content == null || rowData.content ==''){
if (rowData.content == null || rowData.content == '') {
return "";
}else{
var fail =rowData.groupNumber - value;
return "成功数"+value+",失败数"+fail;
} else {
var fail = rowData.groupNumber - value;
return "成功数" + value + ",失败数" + fail;
}
}
},{
}, {
title: "操作",
field: "asdf",
width: 170,
width: 200,
align: "center",
formatter: function (value, rowData, rowIndex) {
if(rowData.content == null || rowData.content ==''){
var str = "<a role='send' dataId='" + rowData.id + "' style='margin-left:10px'>发送短信</a>";
return str;
}else{
return "-"
var str = "";
if (rowData.content == null || rowData.content == '') {
str = "<a role='send' dataId='" + rowData.id + "' style='margin-left:10px'>发送短信</a>";
}
str += "<a role='delete' dataId='" + rowData.id + "' style='margin-left:10px'>删除</a>";
return str;
}
}
]],
cache: false,
pagination: true,
pageSize: 10,
pageList : [10],
pageList: [10],
idField: "id",
singleSelect: false,
checkOnSelect: false,
... ... @@ -195,6 +203,13 @@
}
});
$(this).myDatagrid("getPanel").find("a[role='delete']").linkbutton({
iconCls: "icon-more",
onClick: function () {
deleteGroup($(this).attr("dataId"));
}
});
}
});
... ... @@ -205,28 +220,28 @@
onClick: function () {
var param = {};
if ($("#name").val()!='') {
if ($("#name").val() != '') {
param.name = $("#name").val();
}
if ($("#createTimeBegin").datetimebox('getValue')!='') {
if ($("#createTimeBegin").datetimebox('getValue') != '') {
param.createTimeBegin = parseInt(new Date($("#createTimeBegin").datetimebox('getValue')).getTime() / 1000);
}
if ($("#createTimeEnd").datetimebox('getValue')!='') {
if ($("#createTimeEnd").datetimebox('getValue') != '') {
param.createTimeEnd = parseInt(new Date($("#createTimeEnd").datetimebox('getValue')).getTime() / 1000);
}
if ($("#createUserName").val()!='') {
if ($("#createUserName").val() != '') {
param.createUserName = $("#createUserName").val();
}
if ($("#smsNumber").val()!='') {
if ($("#smsNumber").val() != '') {
param.smsNumber = $("#smsNumber").val();
}
if ($("#sendUserName").val()!='') {
if ($("#sendUserName").val() != '') {
param.sendUserName = $("#sendUserName").val();
}
if ($("#sendTimeBegin").datetimebox('getValue')!='') {
if ($("#sendTimeBegin").datetimebox('getValue') != '') {
param.sendTimeBegin = parseInt(new Date($("#sendTimeBegin").datetimebox('getValue')).getTime() / 1000);
}
if ($("#sendTimeEnd").datetimebox('getValue')!='') {
if ($("#sendTimeEnd").datetimebox('getValue') != '') {
param.sendTimeEnd = parseInt(new Date($("#sendTimeEnd").datetimebox('getValue')).getTime() / 1000);
}
$("#channelGroupTalbe").myDatagrid("load", param);
... ... @@ -242,8 +257,63 @@
}
});
$("#blackList").linkbutton({
iconCls: "icon-search",
text: "黑名单",
onClick: function () {
showblackList();
}
});
});
function showblackList() {
var div = $("<div>").appendTo($(window.self.document.body));
window.self.$(div).myDialog({
modal : true,
collapsible : true,
cache : false,
title : "黑名单列表",
width: 600,
height: 600,
href: contextPath + "/html/channel/blackList.html",
buttons : [{
id : "closeBtn",
text : "关闭",
iconCls : "icon-cancel",
handler : function() {
window.self.$(div).dialog('close');
}
}]
});
}
function deleteGroup(id) {
$.messager.confirm("确认", "确认删除该分组吗?", function (flag) {
if (flag) {
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后...",
interval: 500,
text: ""
});
$.post(contextPath + "/channel/deleteGroup", {groupId: id}, function (data) {
$.messager.progress("close");
if (data.code == 200) {
$("#channelGroupTalbe").myDatagrid("reload");
$.messager.show({
title: "提示",
msg: "删除分组成功!",
height: 120
});
} else {
$.messager.alert("失败", data.message, "error");
}
}, "json");
}
});
}
function sendMessage(id) {
var div = $("<div>").appendTo($(document.body));
var title = "发送短信";
... ... @@ -251,7 +321,7 @@
width: "500px",
height: "40%",
title: title,
href : contextPath+"/html/channel/sendMessage.html",
href: contextPath + "/html/channel/sendMessage.html",
queryParams: {
id: id
},
... ... @@ -259,13 +329,16 @@
collapsible: true,
cache: false,
buttons: [{
id : "saveBtn",
id: "saveBtn",
text: "发送",
id: "saveVideoBtn",
iconCls: "icon-save",
handler: function () {
var content = $("#content").val();
$.post(contextPath + "/channel/sendMessage", {groupId: id,content:content}, function (data) {
if(content.length>200){
window.self.$.messager.alert("提示消息", "短信字数不能超过200!");
}
$.post(contextPath + "/channel/sendMessage", {groupId: id, content: content}, function (data) {
$.messager.progress("close");
// data = JSON.parse(data);
if (data.code == 200) {
... ... @@ -274,7 +347,7 @@
$.messager.show({
title: "提示",
msg: title + "成功!",
height:120
height: 120
});
} else {
$.messager.alert("失败", data.message, "error");
... ... @@ -282,15 +355,15 @@
}, "json");
}
}, {
id : "closeBtn",
id: "closeBtn",
text: " 取消",
iconCls: "icon-cancel",
handler: function () {
$(div).dialog("close");
}
}],
onOpen : function() {
window.setTimeout(function() {
onOpen: function () {
window.setTimeout(function () {
$("#saveBtn").addClass("btn-success");
$("#closeBtn").addClass("btn-danger");
}, 100);
... ... @@ -300,12 +373,12 @@
}
function addTooltip(content,tootipId){
function addTooltip(content, tootipId) {
//添加相应的tooltip
$('#'+tootipId).tooltip({
$('#' + tootipId).tooltip({
position: 'right',
content: content,
onShow: function(){
onShow: function () {
$(this).tooltip('tip').css({
backgroundColor: '#5bc0de',
borderColor: '#46b8da'
... ... @@ -314,17 +387,27 @@
});
}
function getCondition(data1){
function getParams() {
var paramsArray = $("#searchForm").serializeArray();
console.log(paramsArray);
var params = {};
for (var i = 0; i < paramsArray.length; i++ ) {
params[paramsArray[i].name] = paramsArray[i].value;
}
return params;
}
function getCondition(data1) {
var ids = [];
for ( var i = 0; i < data1.rows.length; i++) {
for (var i = 0; i < data1.rows.length; i++) {
ids.push(data1.rows[i].id);
}
var groupIds = ids.join(",");
$.post(contextPath + "/channel/getCondition", {ids:groupIds},function (data) {
$.post(contextPath + "/channel/getCondition", {ids: groupIds}, function (data) {
var content = data.data;
for ( var i = 0; i < data1.rows.length; i++) {
for (var i = 0; i < data1.rows.length; i++) {
var id = data1.rows[i].id;
addTooltip(content[id],'condition-' + i);
addTooltip(content[id], 'condition-' + i);
}
});
... ...
... ... @@ -278,7 +278,6 @@
href: contextPath + "/html/channel/createGroup.html",
buttons : [{
text : "保存",
id : "saveUserBtn",
iconCls : "icon-save",
handler : function() {
var param = getParams();
... ...