Authored by LiQZ

Merge branch 'channel' of http://git.yoho.cn/yoho30/yohobuy-union into channel

... ... @@ -115,8 +115,7 @@ public class ChannelGroupServiceImpl implements ChannelGroupService {
// (2)查询:总数和列表
int total = channelGroupDAO.selectListCountByParam(channelGroupRequestBO);
List<ChannelGroup> channelGroupList = channelGroupDAO.selectListByParam(channelGroupRequestBO);
List<ChannelGroupRspBO> channelGroupBOList = toRspBOList(channelGroupList);
List<ChannelGroupRspBO> channelGroupBOList = channelGroupDAO.selectListByParam(channelGroupRequestBO);
// (3)返回
PageChannelGroupRspBO pageChannelGroupRspBO = new PageChannelGroupRspBO();
... ... @@ -145,7 +144,7 @@ public class ChannelGroupServiceImpl implements ChannelGroupService {
return 0;
}
Set<String> mobileSet = Sets.newHashSet();
//2.1分批从数据库中查询,每次1000,使用mobileSet去重
//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());
... ... @@ -164,7 +163,17 @@ public class ChannelGroupServiceImpl implements ChannelGroupService {
//3.记录分组批次表
int sendTime = DateUtils.getCurrentTimeSecond();
ChannelGroupBatch channelGroupBatch = new ChannelGroupBatch(groupId, content, sendTime, sendUserId);
UserInfoBO userInfoBO = null;
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);
channelGroupBatchDAO.insertSelective(channelGroupBatch);
logger.info("sendMessage:insert channelGroupBatch,channelGroupBatch ={}",channelGroupBatch);
int groupBatchId = channelGroupBatch.getId();
... ... @@ -212,16 +221,13 @@ public class ChannelGroupServiceImpl implements ChannelGroupService {
//5.修改分组表的分组人数、发送时间、修改时间、内容、发送人
ChannelGroup channelGroup = new ChannelGroup();
channelGroup.setId(groupId);
channelGroup.setSendTime(sendTime);
channelGroup.setUpdateTime(sendTime);
channelGroup.setGroupNumber(mobileSet.size());
channelGroup.setContent(content);
channelGroup.setSendUser(sendUserId);
channelGroup.setSmsNumber(groupBatchId);
// Profile profile = profileDAO.selectByPrimaryKey(sendUserId);
// channelGroup.setSendUserName(profile!=null?profile.getAccount():"");
UserInfoBO userInfoBO = erpApiServiceHelper.getUserByPid(String.valueOf(sendUserId));
channelGroup.setSendUserName(userInfoBO!=null?userInfoBO.getAccount():"");
// channelGroup.setSendTime(sendTime);
// channelGroup.setContent(content);
// channelGroup.setSendUser(sendUserId);
// channelGroup.setSmsNumber(groupBatchId);
// channelGroup.setSendUserName(sendUserName);
channelGroupDAO.updateByPrimaryKeySelective(channelGroup);
logger.info("sendMessage:update channelGroup,channelGroup is {}",channelGroup);
return 1;
... ... @@ -265,7 +271,7 @@ public class ChannelGroupServiceImpl implements ChannelGroupService {
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("是否存在有货订单")){
}else 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{
... ... @@ -305,23 +311,6 @@ public class ChannelGroupServiceImpl implements ChannelGroupService {
}
}
private List<ChannelGroupRspBO> toRspBOList(List<ChannelGroup> channelGroupList) {
logger.info("enter toRspBOList. param channelGroupList={}", channelGroupList);
List<ChannelGroupRspBO> list = Lists.newArrayList();
if (CollectionUtils.isEmpty(channelGroupList)) {
return list;
}
for (int i = 0; i < channelGroupList.size(); i++) {
ChannelGroup channelGroup = channelGroupList.get(i);
ChannelGroupRspBO channelGroupRspBO = new ChannelGroupRspBO();
BeanUtils.copyProperties(channelGroup, channelGroupRspBO);
channelGroupRspBO.setCreateTime(DateUtils.int2DateStr(channelGroup.getCreateTime()==null?0:channelGroup.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
channelGroupRspBO.setSendTime(DateUtils.int2DateStr(channelGroup.getSendTime()==null?0:channelGroup.getSendTime(), "yyyy-MM-dd HH:mm:ss"));
list.add(channelGroupRspBO);
}
return list;
}
@Override
public void saveGroup(ChannelUserRequest request, UserInfoBO userInfo) {
... ...
package com.yoho.unions.dal;
import com.yoho.service.model.union.request.ChannelGroupRequestBO;
import com.yoho.service.model.union.response.ChannelGroupRspBO;
import com.yoho.unions.dal.model.ChannelGroup;
import java.util.List;
... ... @@ -20,5 +21,5 @@ public interface IChannelGroupDAO {
int selectListCountByParam(ChannelGroupRequestBO channelGroupRequestBO);
List<ChannelGroup> selectListByParam(ChannelGroupRequestBO channelGroupRequestBO);
List<ChannelGroupRspBO> selectListByParam(ChannelGroupRequestBO channelGroupRequestBO);
}
\ No newline at end of file
... ...
... ... @@ -13,38 +13,12 @@ public class ChannelGroup {
private String createUserName;
private Integer smsNumber;
private Integer sendTime;
private Integer sendUser;
private String sendUserName;
private String content;
private Integer updateTime;
public Integer getId() {
return id;
}
public String getCreateUserName() {
return createUserName;
}
public void setCreateUserName(String createUserName) {
this.createUserName = createUserName;
}
public String getSendUserName() {
return sendUserName;
}
public void setSendUserName(String sendUserName) {
this.sendUserName = sendUserName;
}
public void setId(Integer id) {
this.id = id;
}
... ... @@ -54,7 +28,7 @@ public class ChannelGroup {
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
this.name = name;
}
public Integer getGroupNumber() {
... ... @@ -81,39 +55,12 @@ public class ChannelGroup {
this.createUser = createUser;
}
public Integer getSmsNumber() {
return smsNumber;
}
public void setSmsNumber(Integer smsNumber) {
this.smsNumber = smsNumber;
}
public Integer getSendTime() {
return sendTime;
}
public void setSendTime(Integer sendTime) {
this.sendTime = sendTime;
}
public Integer getSendUser() {
return sendUser;
}
public void setSendUser(Integer sendUser) {
this.sendUser = sendUser;
}
public String getContent() {
return content;
public String getCreateUserName() {
return createUserName;
}
public void setContent(String content) {
this.content = content == null ? null : content.trim();
public void setCreateUserName(String createUserName) {
this.createUserName = createUserName;
}
public Integer getUpdateTime() {
... ...
... ... @@ -11,14 +11,24 @@ public class ChannelGroupBatch {
private Integer sendUser;
public ChannelGroupBatch(Integer groupId,String content,Integer sendTime,Integer sendUser){
private String sendUserName;
public String getSendUserName() {
return sendUserName;
}
public void setSendUserName(String sendUserName) {
this.sendUserName = sendUserName;
}
public ChannelGroupBatch(Integer groupId, String content, Integer sendTime, Integer sendUser, String sendUserName){
this.groupId = groupId;
this.content = content;
this.sendTime = sendTime;
this.sendUser = sendUser;
this.sendUserName = sendUserName;
}
public Integer getId() {
return id;
}
... ...
... ... @@ -7,9 +7,10 @@
<result column="content" property="content" jdbcType="VARCHAR" />
<result column="send_time" property="sendTime" jdbcType="INTEGER" />
<result column="send_user" property="sendUser" jdbcType="INTEGER" />
<result column="send_userName" property="sendUserName" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, group_id, content, send_time, send_user
id, group_id, content, send_time, send_user,send_userName
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
... ... @@ -23,9 +24,9 @@
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.ChannelGroupBatch" >
insert into channel_group_batch (id, group_id, content,
send_time, send_user)
send_time, send_user,send_userName)
values (#{id,jdbcType=INTEGER}, #{groupId,jdbcType=INTEGER}, #{content,jdbcType=VARCHAR},
#{sendTime,jdbcType=INTEGER}, #{sendUser,jdbcType=INTEGER})
#{sendTime,jdbcType=INTEGER}, #{sendUser,jdbcType=INTEGER},#{sendUserName,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.ChannelGroupBatch" useGeneratedKeys="true" keyProperty="id">
insert into channel_group_batch
... ... @@ -45,6 +46,9 @@
<if test="sendUser != null" >
send_user,
</if>
<if test="sendUserName != null" >
send_userName,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
... ... @@ -62,6 +66,9 @@
<if test="sendUser != null" >
#{sendUser,jdbcType=INTEGER},
</if>
<if test="sendUserName != null" >
#{sendUserName,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.ChannelGroupBatch" >
... ... @@ -79,6 +86,9 @@
<if test="sendUser != null" >
send_user = #{sendUser,jdbcType=INTEGER},
</if>
<if test="sendUserName != null" >
send_userName,
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
... ... @@ -87,7 +97,8 @@
set group_id = #{groupId,jdbcType=INTEGER},
content = #{content,jdbcType=VARCHAR},
send_time = #{sendTime,jdbcType=INTEGER},
send_user = #{sendUser,jdbcType=INTEGER}
send_user = #{sendUser,jdbcType=INTEGER},
send_userName = #{sendUserName,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -8,16 +8,17 @@
<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="sms_number" property="smsNumber" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<resultMap id="groupResultMap" type="com.yoho.service.model.union.response.ChannelGroupRspBO" extends="BaseResultMap">
<result column="group_id" property="smsNumber" jdbcType="INTEGER" />
<result column="send_time" property="sendTime" jdbcType="INTEGER" />
<result column="send_user" property="sendUser" jdbcType="INTEGER" />
<result column="send_userName" property="sendUserName" jdbcType="VARCHAR" />
<result column="content" property="content" jdbcType="VARCHAR" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, name, group_number, create_time, create_user, create_userName, sms_number, send_time,
send_user, send_userName, content, update_time
id, name, group_number, create_time, create_user, create_userName, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
... ... @@ -31,14 +32,10 @@
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.ChannelGroup" keyProperty="id" useGeneratedKeys="true" >
insert into channel_group (id, name, group_number,
create_time, create_user, create_userName,
sms_number, send_time, send_user,
send_userName, content, update_time
create_time, create_user, create_userName,update_time
)
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{groupNumber,jdbcType=INTEGER},
#{createTime,jdbcType=INTEGER}, #{createUser,jdbcType=INTEGER}, #{createUserName,jdbcType=VARCHAR},
#{smsNumber,jdbcType=INTEGER}, #{sendTime,jdbcType=INTEGER}, #{sendUser,jdbcType=INTEGER},
#{sendUserName,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, #{updateTime,jdbcType=INTEGER}
#{createTime,jdbcType=INTEGER}, #{createUser,jdbcType=INTEGER}, #{createUserName,jdbcType=VARCHAR}, #{updateTime,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.ChannelGroup" >
... ... @@ -62,21 +59,6 @@
<if test="createUserName != null" >
create_userName,
</if>
<if test="smsNumber != null" >
sms_number,
</if>
<if test="sendTime != null" >
send_time,
</if>
<if test="sendUser != null" >
send_user,
</if>
<if test="sendUserName != null" >
send_userName,
</if>
<if test="content != null" >
content,
</if>
<if test="updateTime != null" >
update_time,
</if>
... ... @@ -100,21 +82,6 @@
<if test="createUserName != null" >
#{createUserName,jdbcType=VARCHAR},
</if>
<if test="smsNumber != null" >
#{smsNumber,jdbcType=INTEGER},
</if>
<if test="sendTime != null" >
#{sendTime,jdbcType=INTEGER},
</if>
<if test="sendUser != null" >
#{sendUser,jdbcType=INTEGER},
</if>
<if test="sendUserName != null" >
#{sendUserName,jdbcType=VARCHAR},
</if>
<if test="content != null" >
#{content,jdbcType=VARCHAR},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=INTEGER},
</if>
... ... @@ -138,21 +105,6 @@
<if test="createUserName != null" >
create_userName = #{createUserName,jdbcType=VARCHAR},
</if>
<if test="smsNumber != null" >
sms_number = #{smsNumber,jdbcType=INTEGER},
</if>
<if test="sendTime != null" >
send_time = #{sendTime,jdbcType=INTEGER},
</if>
<if test="sendUser != null" >
send_user = #{sendUser,jdbcType=INTEGER},
</if>
<if test="sendUserName != null" >
send_userName = #{sendUserName,jdbcType=VARCHAR},
</if>
<if test="content != null" >
content = #{content,jdbcType=VARCHAR},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=INTEGER},
</if>
... ... @@ -166,16 +118,13 @@
create_time = #{createTime,jdbcType=INTEGER},
create_user = #{createUser,jdbcType=INTEGER},
create_userName = #{createUserName,jdbcType=VARCHAR},
sms_number = #{smsNumber,jdbcType=INTEGER},
send_time = #{sendTime,jdbcType=INTEGER},
send_user = #{sendUser,jdbcType=INTEGER},
send_userName = #{sendUserName,jdbcType=VARCHAR},
content = #{content,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id ="selectListCountByParam" parameterType="java.lang.Integer" resultType="java.lang.Integer">
select count(*) from channel_group
select count(*) from channel_group cg
left join channel_group_batch cgb
on cg.id = cgb.group_id
<where>
<if test="name != null" >
name LIKE CONCAT('%',#{name,jdbcType=VARCHAR},'%')
... ... @@ -190,7 +139,7 @@
and create_userName LIKE CONCAT('%',#{createUserName,jdbcType=VARCHAR},'%')
</if>
<if test="smsNumber != null" >
and sms_number = #{smsNumber,jdbcType=INTEGER}
and cgb.id = #{smsNumber,jdbcType=INTEGER}
</if>
<if test="sendTimeBegin != null" >
and send_time >= #{sendTimeBegin,jdbcType=INTEGER}
... ... @@ -203,8 +152,12 @@
</if>
</where>
</select>
<select id="selectListByParam" resultMap="BaseResultMap" parameterType="com.yoho.service.model.union.request.ChannelGroupRequestBO" >
select <include refid="Base_Column_List" /> from channel_group
<select id="selectListByParam" resultMap="groupResultMap" parameterType="com.yoho.service.model.union.response.ChannelGroupRspBO" >
select cg.id as id, name, group_number, create_time, create_user, create_userName, cgb.id as group_id, send_time,
send_user, send_userName, content
from channel_group cg
left join channel_group_batch cgb
on cg.id = cgb.group_id
<where>
<if test="name != null" >
name LIKE CONCAT('%',#{name,jdbcType=VARCHAR},'%')
... ... @@ -219,7 +172,7 @@
and create_userName LIKE CONCAT('%',#{createUserName,jdbcType=VARCHAR},'%')
</if>
<if test="smsNumber != null" >
and sms_number = #{smsNumber,jdbcType=INTEGER}
and cgb.id = #{smsNumber,jdbcType=INTEGER}
</if>
<if test="sendTimeBegin != null" >
and send_time >= #{sendTimeBegin,jdbcType=INTEGER}
... ...