Commit 468622df by 徐高华

Merge branch 'feature/社群' into 'developer'

新增群发

See merge request !621
parents a93ba511 95cf3b49
......@@ -38,6 +38,7 @@ public class GroupChatPlanDTO implements Serializable{
/**几天后失效*/
private Integer expireDays;
private String staffIdList;
private String delStaffIdList ;
/**群主数量*/
private Integer staffCount;
/**已完成任务的群主数量*/
......@@ -49,7 +50,15 @@ public class GroupChatPlanDTO implements Serializable{
// 1代发送 2已发送
private Integer sendFlag;
public Integer getSendFlag() {
public String getDelStaffIdList() {
return delStaffIdList;
}
public void setDelStaffIdList(String delStaffIdList) {
this.delStaffIdList = delStaffIdList;
}
public Integer getSendFlag() {
return sendFlag;
}
......
......@@ -23,16 +23,22 @@ public interface GroupChatPlanOwnerLogMapper {
public int insert(TabGroupChatPlanOwnerLog entity);
public int batchInsert(List<TabGroupChatPlanOwnerLog> entity);
public int update(TabGroupChatPlanOwnerLog entity);
public void deleteByStaffIds(@Param("planId") Long planId, @Param("staffIdList") List<String> staffIdList);
public TabGroupChatPlanOwnerLog selectById(Long ownerLogId);
public void updateSendCount(@Param("id") Long id, @Param("sendCount") int sendCount, @Param("failCount") int failCount,
@Param("sendTime") Date sendTime);
public void updateSendCount(@Param("id") Long id, @Param("sendCount") int sendCount,
@Param("failCount") int failCount, @Param("sendTime") Date sendTime);
public List<GroupChatPlanOwnerLogDTO> listPage(GroupChatPlanSearchQDTO qdto);
public List<TabGroupChatPlanOwnerLog> listForTimer();
public List<ChatOwnerTotalDTO> listOwnerLogPageForWxaTotal(GroupChatPlanSearchQDTO qdto);
public List<GroupChatPlanOwnerLogDTO> listOwnerLogPageForWxa(GroupChatPlanSearchQDTO qdto);
}
\ No newline at end of file
......@@ -35,7 +35,6 @@ public class TabGroupChatPlan implements Serializable {
private java.util.Date endTime;
/**几天后失效*/
private Integer expireDays;
private String staffIdList;
/**群主数量*/
private Integer staffCount;
/**已完成任务的群主数量*/
......@@ -202,14 +201,6 @@ public class TabGroupChatPlan implements Serializable {
return expireDays;
}
public void setStaffIdList(String staffIdList) {
this.staffIdList = staffIdList;
}
public String getStaffIdList() {
return staffIdList;
}
public void setStaffCount(Integer staffCount) {
this.staffCount = staffCount;
}
......
......@@ -8,11 +8,16 @@ import com.gic.api.base.commons.Page;
import com.gic.haoban.manage.api.dto.chat.ChatOwnerTotalDTO;
import com.gic.haoban.manage.api.dto.chat.GroupChatPlanOwnerLogDTO;
import com.gic.haoban.manage.api.dto.qdto.chat.GroupChatPlanSearchQDTO;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlan;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlanOwnerLog;
public interface GroupChatPlanOwnerLogService {
public GroupChatPlanOwnerLogDTO save(GroupChatPlanOwnerLogDTO dto);
public void batchAdd(String staffIdList, TabGroupChatPlan entity);
public void update(TabGroupChatPlanOwnerLog entity);
public void deleteByStaffIds(Long planId,List<String> staffIdList) ;
public void updateSendCount(Long id, int sendCount, Date sendTime, int failCount);
......
package com.gic.haoban.manage.service.service.chat.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -17,7 +18,7 @@ import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.DateUtil;
import com.gic.commons.util.PageHelperUtils;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.enterprise.api.dto.StoreDTO;
......@@ -26,8 +27,11 @@ import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.chat.ChatOwnerTotalDTO;
import com.gic.haoban.manage.api.dto.chat.GroupChatPlanOwnerLogDTO;
import com.gic.haoban.manage.api.dto.qdto.chat.GroupChatPlanSearchQDTO;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatOwnerMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatPlanOwnerLogMapper;
import com.gic.haoban.manage.service.entity.TabHaobanClerkMainStoreRelated;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatOwner;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlan;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlanOwnerLog;
import com.gic.haoban.manage.service.service.ClerkMainStoreRelatedService;
import com.gic.haoban.manage.service.service.StaffClerkRelationService;
......@@ -49,6 +53,8 @@ public class GroupChatPlanOwnerLogServiceImpl implements GroupChatPlanOwnerLogSe
private ClerkService clerkService;
@Autowired
private StoreService storeService;
@Autowired
private GroupChatOwnerMapper groupChatOwnerMapper;
public TabGroupChatPlanOwnerLog getById(Long ownerLogId) {
TabGroupChatPlanOwnerLog log = this.groupChatPlanOwnerLogMapper.selectById(ownerLogId);
......@@ -56,8 +62,8 @@ public class GroupChatPlanOwnerLogServiceImpl implements GroupChatPlanOwnerLogSe
}
@Override
public void updateSendCount(Long id, int sendCount, Date sendTime , int failCount) {
this.groupChatPlanOwnerLogMapper.updateSendCount(id, sendCount, failCount ,sendTime);
public void updateSendCount(Long id, int sendCount, Date sendTime, int failCount) {
this.groupChatPlanOwnerLogMapper.updateSendCount(id, sendCount, failCount, sendTime);
}
@Override
......@@ -108,32 +114,46 @@ public class GroupChatPlanOwnerLogServiceImpl implements GroupChatPlanOwnerLogSe
}
@Override
public GroupChatPlanOwnerLogDTO save(GroupChatPlanOwnerLogDTO dto) {
TabGroupChatPlanOwnerLog log = EntityUtil.changeEntityByJSON(TabGroupChatPlanOwnerLog.class, dto);
log.setOwnerLogId(UniqueIdUtils.uniqueLong());
log.setSendStatus(0);
log.setCreateTime(new Date());
log.setUpdateTime(new Date());
log.setSendCount(0);
String staffId = dto.getStaffId();
TabHaobanClerkMainStoreRelated mainStore = this.clerkMainStoreRelatedService.getMainStoreByStaffId(staffId,
dto.getWxEnterpriseId());
if (null == mainStore) {
log.setRemark("区经/未配置主门店");
} else {
StaffClerkRelationDTO clerk = this.staffClerkRelationService.getOneBindByStoreId(staffId,
mainStore.getStoreId());
if (null != clerk) {
log.setClerkId(clerk.getClerkId());
log.setStoreId(mainStore.getStoreId());
public void batchAdd(String staffIdList, TabGroupChatPlan entity) {
String[] arr = staffIdList.split(",");
List<TabGroupChatPlanOwnerLog> logList = new ArrayList<>();
for (int i = 0; i < arr.length; i++) {
String staffId = arr[i];
TabGroupChatPlanOwnerLog log = new TabGroupChatPlanOwnerLog();
log.setOwnerLogId(UniqueIdUtils.uniqueLong());
log.setWxEnterpriseId(entity.getWxEnterpriseId());
log.setEnterpriseId(entity.getEnterpriseId());
log.setPlanId(entity.getPlanId());
log.setSendStatus(1);
log.setCreateTime(new Date());
log.setUpdateTime(new Date());
log.setSendCount(0);
log.setStaffId(staffId);
TabGroupChatOwner owner = this.groupChatOwnerMapper.selectByStaffId(staffId);
log.setTotalCount(owner.getChatCount());
TabHaobanClerkMainStoreRelated mainStore = this.clerkMainStoreRelatedService.getMainStoreByStaffId(staffId,
entity.getWxEnterpriseId());
if (null == mainStore) {
log.setRemark("区经/未配置主门店");
} else {
log.setRemark("关联导购数据查不到");
logger.info("导购关联数据不存在,staffid={},storeid={}", staffId, mainStore.getStoreId());
StaffClerkRelationDTO clerk = this.staffClerkRelationService.getOneBindByStoreId(staffId,
mainStore.getStoreId());
if (null != clerk) {
log.setClerkId(clerk.getClerkId());
log.setStoreId(mainStore.getStoreId());
} else {
log.setRemark("无关联导购");
logger.info("导购关联数据不存在,staffid={},storeid={}", staffId, mainStore.getStoreId());
}
}
logList.add(log);
}
this.groupChatPlanOwnerLogMapper.insert(log);
return EntityUtil.changeEntityByJSON(GroupChatPlanOwnerLogDTO.class, log) ;
this.groupChatPlanOwnerLogMapper.batchInsert(logList);
}
@Override
public void update(TabGroupChatPlanOwnerLog entity) {
this.groupChatPlanOwnerLogMapper.update(entity);
}
@Override
......@@ -141,6 +161,11 @@ public class GroupChatPlanOwnerLogServiceImpl implements GroupChatPlanOwnerLogSe
List<TabGroupChatPlanOwnerLog> list = this.groupChatPlanOwnerLogMapper.listForTimer();
return list;
}
@Override
public void deleteByStaffIds(Long planId, List<String> staffIdList) {
this.groupChatPlanOwnerLogMapper.deleteByStaffIds(planId, staffIdList);
}
@Override
public Page<ChatOwnerTotalDTO> listOwnerLogPageForWxaTotal(GroupChatPlanSearchQDTO qdto,
......
package com.gic.haoban.manage.service.service.chat.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -37,11 +38,9 @@ import com.gic.haoban.manage.api.dto.qdto.chat.GroupChatPlanSearchQDTO;
import com.gic.haoban.manage.api.enums.PendingTaskTypeEnum;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatOwnerMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatPlanLogMapper;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatPlanMapper;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatOwner;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlan;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlanLog;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatPlanOwnerLog;
......@@ -91,8 +90,6 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
@Autowired
private QuartzService quartzService;
@Autowired
private GroupChatOwnerMapper groupChatOwnerMapper;
@Autowired
private PendingTaskService pendingTaskService;
private static GicMQClient mqClient = GICMQClientUtil.getClientInstance();
......@@ -118,6 +115,7 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
entity.setSendTime(new Date());
}
this.groupChatPlanMapper.insert(entity);
this.groupChatPlanOwnerLogService.batchAdd(dto.getStaffIdList(), entity);
// 立即发送
if (entity.getSendType() == 1) {
this.sendMQ(entity.getPlanId());
......@@ -126,6 +124,15 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
}
} else {
this.groupChatPlanMapper.updateById(entity);
if (StringUtils.isNotBlank(dto.getDelStaffIdList())) {
String arr = dto.getDelStaffIdList();
List<String> delStaffIdList = Arrays.asList(arr);
this.groupChatPlanOwnerLogService.deleteByStaffIds(planId, delStaffIdList);
}
if (StringUtils.isNoneBlank(dto.getStaffIdList())) {
String staffIdList = dto.getStaffIdList();
this.groupChatPlanOwnerLogService.batchAdd(staffIdList, entity);
}
// 立即发送
if (entity.getSendType() == 1) {
this.sendMQ(entity.getPlanId());
......@@ -164,40 +171,35 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
}
// 控制重复发送
this.groupChatPlanMapper.updateSendFlag(planId);
String[] staffIdList = plan.getStaffIdList().split(",");
String wxEnterpriseId = plan.getWxEnterpriseId();
String enterpriseId = plan.getEnterpriseId();
String chatContent = plan.getChatContent();
JSONArray jsonArr = JSONArray.parseArray(chatContent);
List<String> madidList = new ArrayList<>();
GroupChatPlanSearchQDTO qdto = new GroupChatPlanSearchQDTO();
BasePageInfo basePageInfo = new BasePageInfo();
Page<GroupChatPlanOwnerLogDTO> page = this.groupChatPlanOwnerLogService.listPage(planId, qdto, basePageInfo);
for (int i = 0; i < jsonArr.size(); i++) {
JSONObject json = jsonArr.getJSONObject(i);
madidList.add(json.getString("relation_id"));
}
for (int i = 0; i < staffIdList.length; i++) {
String staffId = staffIdList[i];
List<GroupChatPlanOwnerLogDTO> ownerList = page.getResult();
for (GroupChatPlanOwnerLogDTO dto : ownerList) {
String staffId = dto.getStaffId();
ServiceResponse<String> sendResp = qywxSendService.sendChatMessage(wxEnterpriseId, staffId, madidList);
// 群主群数量
TabGroupChatOwner owner = this.groupChatOwnerMapper.selectByStaffId(staffId);
GroupChatPlanOwnerLogDTO ownerDTO = new GroupChatPlanOwnerLogDTO();
TabGroupChatPlanOwnerLog ownerLog = EntityUtil.changeEntityByJSON(TabGroupChatPlanOwnerLog.class, dto);
if (sendResp.isSuccess()) {
String msgid = sendResp.getResult();
ownerDTO.setMsgid(msgid);
ownerDTO.setSendStatus(1);
ownerLog.setMsgid(msgid);
ownerLog.setSendStatus(2);
} else {
ownerDTO.setRemark(sendResp.getMessage());
ownerDTO.setSendStatus(0);
ownerLog.setRemark(sendResp.getMessage());
ownerLog.setSendStatus(0);
}
ownerDTO.setExpireDate(DateUtil.addDay(new Date(), plan.getExpireDays()));
ownerDTO.setTotalCount(owner.getChatCount());
ownerDTO.setWxEnterpriseId(wxEnterpriseId);
ownerDTO.setEnterpriseId(enterpriseId);
ownerDTO.setStaffId(staffId);
ownerDTO.setPlanId(planId);
ownerDTO = this.groupChatPlanOwnerLogService.save(ownerDTO);
ownerLog.setExpireDate(DateUtil.addDay(new Date(), plan.getExpireDays()));
this.groupChatPlanOwnerLogService.update(ownerLog);
// 代办
if (StringUtils.isNotBlank(ownerDTO.getClerkId())) {
this.savePendTask(ownerDTO, plan);
if (StringUtils.isNotBlank(ownerLog.getClerkId())) {
this.savePendTask(dto, plan);
}
}
}
......
......@@ -22,7 +22,6 @@
<result column="start_time" property="startTime" />
<result column="end_time" property="endTime" />
<result column="expire_days" property="expireDays" />
<result column="staff_id_list" property="staffIdList" />
<result column="staff_count" property="staffCount" />
<result column="send_count" property="sendCount" />
<result column="success_chat_count" property="successChatCount" />
......@@ -46,7 +45,6 @@
start_time,
end_time,
expire_days,
staff_id_list,
staff_count,
send_count,
success_chat_count,
......@@ -74,7 +72,6 @@
start_time,
end_time,
expire_days,
staff_id_list,
staff_count,
send_count,
success_chat_count,
......@@ -96,7 +93,6 @@
#{startTime},
#{endTime},
#{expireDays},
#{staffIdList},
#{staffCount},
#{sendCount},
#{successChatCount},
......@@ -137,8 +133,7 @@
send_time=#{sendTime},
start_time=#{startTime},
end_time=#{endTime},
expire_days=#{expireDays},
staff_id_list=#{staffIdList}
expire_days=#{expireDays}
where plan_id = #{planId}
]]>
</update>
......
......@@ -55,20 +55,79 @@
)VALUES(
#{ownerLogId,jdbcType=BIGINT},
#{planId,jdbcType=BIGINT},
#{wxEnterpriseId,jdbcType=CHAR},
#{enterpriseId,jdbcType=CHAR},
#{staffId,jdbcType=CHAR},
#{storeId,jdbcType=CHAR},
#{clerkId,jdbcType=CHAR},
#{sendStatus,jdbcType=INTEGER},
#{totalCount,jdbcType=INTEGER},
#{sendCount,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP} , #{remark} , #{msgid} , 0 , 0 , #{expireDate}
#{wxEnterpriseId},
#{enterpriseId},
#{staffId},
#{storeId},
#{clerkId},
#{sendStatus},
#{totalCount},
#{sendCount},
#{createTime},
#{updateTime} , #{remark} , #{msgid} , 0 , 0 , #{expireDate}
)
]]>
</insert>
<insert id="batchInsert">
INSERT INTO tab_haoban_group_chat_plan_owner_log(
owner_log_id,
plan_id,
wx_enterprise_id,
enterprise_id,
staff_id,
store_id,
clerk_id,
send_status,
total_count,
send_count,
create_time,
update_time , remark , msgid , delete_flag , done_flag , expire_date
)VALUES
<foreach collection="list" item="item" separator="," >
( #{item.ownerLogId,jdbcType=BIGINT},
#{item.planId,jdbcType=BIGINT},
#{item.wxEnterpriseId},
#{item.enterpriseId},
#{item.staffId},
#{item.storeId},
#{item.clerkId},
#{item.sendStatus},
#{item.totalCount},
#{item.sendCount},
#{item.createTime},
#{item.updateTime} , #{item.remark} , #{item.msgid} , 0 , 0 , #{item.expireDate}
)
</foreach>
</insert>
<update id="update" parameterType="com.gic.haoban.manage.service.entity.chat.TabGroupChatPlanOwnerLog">
<![CDATA[
UPDATE tab_haoban_group_chat_plan_owner_log SET
store_id=#{storeId},
clerk_id=#{clerkId},
send_status=#{sendStatus},
total_count=#{totalCount},
fail_count=#{failCount},
send_count=#{sendCount},
update_time=now(),
remark=#{remark},
msgid=#{msgid},
done_flag=#{doneFlag},
send_time=#{sendTime},
expire_date=#{expireDate}
owner_log_id = #{ownerLogId}
]]>
</update>
<update id="deleteByStaffIds">
update tab_haoban_group_chat_plan_owner_log set delete_flag = 1 , update_time =now() where plan_id=#{planId}
and staff_id in
<foreach collection="staffIdList" close=")" open="(" separator="," item="id">
#{id}
</foreach>
</update>
<!-- ==================更新 ========== -->
<update id="updateSendCount">
<![CDATA[
......
package com.gic.haoban.manage.web.controller.chat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import com.gic.haoban.common.utils.AuthWebRequestUtil;
import com.gic.haoban.manage.api.dto.MaterialDTO;
import com.gic.haoban.manage.api.dto.chat.GroupChatDTO;
import com.gic.haoban.manage.api.dto.chat.GroupChatOwnerDTO;
import com.gic.haoban.manage.api.dto.chat.GroupChatOwnerHistoryDTO;
......@@ -26,7 +20,6 @@ import com.gic.haoban.manage.api.dto.chat.GroupChatUserDTO;
import com.gic.haoban.manage.api.dto.qdto.chat.GroupChatSearchQDTO;
import com.gic.haoban.manage.api.dto.qdto.chat.GroupChatUserSearchQDTO;
import com.gic.haoban.manage.api.dto.qdto.chat.OwnerSearchQDTO;
import com.gic.haoban.manage.api.service.MaterialApiService;
import com.gic.haoban.manage.api.service.chat.GroupChatApiService;
/**
......@@ -43,8 +36,6 @@ public class GroupChatController {
@Autowired
private GroupChatApiService groupChatApiService;
@Autowired
private MaterialApiService materialApiService ;
@RequestMapping("get-set-gic-flag")
public RestResponse<Object> getFlag() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment