Commit ea7c429b by 徐高华

朋友圈

parent 8133a953
...@@ -73,6 +73,8 @@ public class QwMomentPlanDTO implements Serializable{ ...@@ -73,6 +73,8 @@ public class QwMomentPlanDTO implements Serializable{
/**完成率*/ /**完成率*/
private Integer execRate; private Integer execRate;
public Long getPlanId() { public Long getPlanId() {
return planId; return planId;
} }
......
...@@ -2,12 +2,34 @@ package com.gic.haoban.manage.service.dao.mapper.moment; ...@@ -2,12 +2,34 @@ package com.gic.haoban.manage.service.dao.mapper.moment;
import com.gic.haoban.manage.api.dto.moment.QwMomentPlanAttendDTO; import com.gic.haoban.manage.api.dto.moment.QwMomentPlanAttendDTO;
import com.gic.haoban.manage.api.dto.moment.QwMomentPlanDTO; import com.gic.haoban.manage.api.dto.moment.QwMomentPlanDTO;
import com.gic.haoban.manage.service.entity.moment.TabQwMomentPlanAttend;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface QwMomentPlanAttendMapper { public interface QwMomentPlanAttendMapper {
void insert(QwMomentPlanAttendDTO dto) ; void batchInsert(List<TabQwMomentPlanAttend> list) ;
void update(TabQwMomentPlanAttend dto) ;
/**
* 查询已经存在的导购
* @param planId
* @param clerkIdList
* @return
*/
List<String> listExistClerkIds(@Param("planId") Long planId , @Param("list") List<String> clerkIdList) ;
List<QwMomentPlanAttendDTO> listClerk(@Param("planId")Long planId, @Param("doneFlag") int doneFlag);
void update(QwMomentPlanAttendDTO dto) ; /**
* 删除
* @param planId
* @param clerkIdList
*/
void delClerks(@Param("planId") Long planId , @Param("list") List<String> clerkIdList) ;
} }
...@@ -5,8 +5,17 @@ import com.gic.api.base.commons.ServiceResponse; ...@@ -5,8 +5,17 @@ import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.dto.moment.QwMomentPlanAttendDTO; import com.gic.haoban.manage.api.dto.moment.QwMomentPlanAttendDTO;
import com.gic.haoban.manage.api.qdto.moment.PlanClerkListQDTO; import com.gic.haoban.manage.api.qdto.moment.PlanClerkListQDTO;
import java.util.List;
public interface QwMomentPlanAttendService { public interface QwMomentPlanAttendService {
ServiceResponse<Page<QwMomentPlanAttendDTO>> attendList(PlanClerkListQDTO qdto) ; ServiceResponse<Page<QwMomentPlanAttendDTO>> attendList(PlanClerkListQDTO qdto) ;
/**
* 导购
* @param enterpriseId
* @param planId
*/
void saveClerk(String enterpriseId, List<String> clerkIdList , Long planId) ;
} }
...@@ -2,18 +2,33 @@ package com.gic.haoban.manage.service.service.moment.impl; ...@@ -2,18 +2,33 @@ package com.gic.haoban.manage.service.service.moment.impl;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse; import com.gic.api.base.commons.ServiceResponse;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.manage.api.dto.moment.QwMomentPlanAttendDTO; import com.gic.haoban.manage.api.dto.moment.QwMomentPlanAttendDTO;
import com.gic.haoban.manage.api.qdto.moment.PlanClerkListQDTO; import com.gic.haoban.manage.api.qdto.moment.PlanClerkListQDTO;
import com.gic.haoban.manage.service.dao.mapper.moment.QwMomentPlanAttendMapper; import com.gic.haoban.manage.service.dao.mapper.moment.QwMomentPlanAttendMapper;
import com.gic.haoban.manage.service.entity.moment.TabQwMomentPlanAttend;
import com.gic.haoban.manage.service.service.moment.QwMomentPlanAttendService; import com.gic.haoban.manage.service.service.moment.QwMomentPlanAttendService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service("qwMomentPlanAttendService") @Service("qwMomentPlanAttendService")
public class QwMomentPlanAttendServiceImpl implements QwMomentPlanAttendService { public class QwMomentPlanAttendServiceImpl implements QwMomentPlanAttendService {
private final Logger logger = LogManager.getLogger(this.getClass());
@Autowired @Autowired
private QwMomentPlanAttendMapper qwMomentPlanAttendMapper ; private QwMomentPlanAttendMapper qwMomentPlanAttendMapper ;
@Autowired
private ClerkService clerkService ;
@Override @Override
public ServiceResponse<Page<QwMomentPlanAttendDTO>> attendList(PlanClerkListQDTO qdto) { public ServiceResponse<Page<QwMomentPlanAttendDTO>> attendList(PlanClerkListQDTO qdto) {
...@@ -21,4 +36,31 @@ public class QwMomentPlanAttendServiceImpl implements QwMomentPlanAttendService ...@@ -21,4 +36,31 @@ public class QwMomentPlanAttendServiceImpl implements QwMomentPlanAttendService
} }
public void saveClerk(String enterpriseId,Long planId , List<String> clerkIdList) {
List<String> existClerkIdList = this.qwMomentPlanAttendMapper.listExistClerkIds(planId,clerkIdList) ;
if(CollectionUtils.isNotEmpty(existClerkIdList)) {
clerkIdList = clerkIdList.stream().filter(o->!existClerkIdList.contains(o)).collect(Collectors.toList());
}
if(CollectionUtils.isEmpty(clerkIdList)) {
logger.info("所有导购都已添加过");
return ;
}
List<TabQwMomentPlanAttend> list = new ArrayList<>() ;
for(String clerkId : clerkIdList) {
ClerkDTO clerkDTO = this.clerkService.getclerkById(clerkId) ;
if(null != clerkDTO) {
TabQwMomentPlanAttend attend = new TabQwMomentPlanAttend() ;
attend.setAttendId(UniqueIdUtils.uniqueLong());
attend.setPlanId(planId);
attend.setEnterpriseId(enterpriseId);
attend.setClerkId(clerkId);
attend.setClerkCode(clerkDTO.getClerkCode());
attend.setClerkName(clerkDTO.getClerkName());
list.add(attend) ;
}
}
this.qwMomentPlanAttendMapper.batchInsert(list);
}
} }
...@@ -7,16 +7,25 @@ import com.gic.commons.util.DateUtil; ...@@ -7,16 +7,25 @@ import com.gic.commons.util.DateUtil;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.UniqueIdUtils; import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.manage.api.dto.moment.QwMomentPlanDTO; import com.gic.haoban.manage.api.dto.moment.QwMomentPlanDTO;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import com.gic.haoban.manage.api.qdto.moment.QwMomentPlanQDTO; import com.gic.haoban.manage.api.qdto.moment.QwMomentPlanQDTO;
import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil;
import com.gic.haoban.manage.service.dao.mapper.moment.QwMomentPlanAttendMapper;
import com.gic.haoban.manage.service.dao.mapper.moment.QwMomentPlanMapper; import com.gic.haoban.manage.service.dao.mapper.moment.QwMomentPlanMapper;
import com.gic.haoban.manage.service.entity.moment.TabQwMomentPlan; import com.gic.haoban.manage.service.entity.moment.TabQwMomentPlan;
import com.gic.haoban.manage.service.service.moment.QwMomentPlanAttendService;
import com.gic.haoban.manage.service.service.moment.QwMomentPlanService; import com.gic.haoban.manage.service.service.moment.QwMomentPlanService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service("qwMomentPlanService") @Service("qwMomentPlanService")
public class QwMomentPlanServiceImpl implements QwMomentPlanService { public class QwMomentPlanServiceImpl implements QwMomentPlanService {
...@@ -24,10 +33,15 @@ public class QwMomentPlanServiceImpl implements QwMomentPlanService { ...@@ -24,10 +33,15 @@ public class QwMomentPlanServiceImpl implements QwMomentPlanService {
private final Logger logger = LogManager.getLogger(this.getClass()); private final Logger logger = LogManager.getLogger(this.getClass());
@Autowired @Autowired
private QwMomentPlanMapper qwMomentPlanMapper ; private QwMomentPlanMapper qwMomentPlanMapper ;
@Autowired
private QwMomentPlanAttendService qwMomentPlanAttendService ;
@Autowired
private QwMomentPlanAttendMapper qwMomentPlanAttendMapper ;
@Override @Override
public ServiceResponse<QwMomentPlanDTO> save(QwMomentPlanDTO dto) { public ServiceResponse<QwMomentPlanDTO> save(QwMomentPlanDTO dto) {
logger.info("保存朋友圈活动={}", JSONObject.toJSONString(dto)); logger.info("保存朋友圈活动={}", JSONObject.toJSONString(dto));
String enterpriseId = dto.getEnterpriseId() ;
Long planId = dto.getPlanId() ; Long planId = dto.getPlanId() ;
TabQwMomentPlan plan = EntityUtil.changeEntity(TabQwMomentPlan.class,dto) ; TabQwMomentPlan plan = EntityUtil.changeEntity(TabQwMomentPlan.class,dto) ;
Date now = new Date() ; Date now = new Date() ;
...@@ -49,10 +63,41 @@ public class QwMomentPlanServiceImpl implements QwMomentPlanService { ...@@ -49,10 +63,41 @@ public class QwMomentPlanServiceImpl implements QwMomentPlanService {
}else { }else {
this.qwMomentPlanMapper.update(plan); this.qwMomentPlanMapper.update(plan);
} }
// 参与导购
if(dto.getPlanClerkType()==1) {
if (createFlag) {
this.qwMomentPlanAttendService.saveClerk(enterpriseId, dto.getSelectClerkIdList(), planId);
} else {
List<String> oldList = this.qwMomentPlanAttendMapper.listClerk(planId,0).stream().map(o -> o.getClerkId()).collect(Collectors.toList());
List<String> newList = dto.getSelectClerkIdList();
List<String> addList = newList.stream().filter(o -> !oldList.contains(o)).distinct().collect(Collectors.toList());
List<String> delList = oldList.stream().filter(o -> !newList.contains(o)).distinct().collect(Collectors.toList());
this.qwMomentPlanAttendService.saveClerk(enterpriseId, addList, planId);
if (CollectionUtils.isNotEmpty(delList)) {
this.qwMomentPlanAttendMapper.delClerks(planId, delList);
}
if(CollectionUtils.isNotEmpty(addList)) {
for(String clerkId : addList) {
this.sendTaskToClerk(plan.getEnterpriseId(),clerkId,plan.getPlanId());
}
}
}
}
return ServiceResponse.success(dto); return ServiceResponse.success(dto);
} }
private void sendTaskToClerk(String enterpriseId,String clerkId , Long planId) {
logger.info("发送任务通知,clerkId={}",clerkId);
// 发送通知
Map<String, String> map = new HashMap<String, String>();
int messageType = 0 ; // NoticeMessageTypeEnum.CLERK_TASK_SEND_NOTICE.getType();
JSONObject jsonObject = new JSONObject();
jsonObject.put("planId",planId) ;
NoticeMessageUtil.sendNoticeMessage(enterpriseId,clerkId,messageType,null,map,jsonObject);
}
@Override @Override
public ServiceResponse<Void> del(Long planId) { public ServiceResponse<Void> del(Long planId) {
this.qwMomentPlanMapper.del(planId); this.qwMomentPlanMapper.del(planId);
......
...@@ -41,8 +41,39 @@ ...@@ -41,8 +41,39 @@
qw_data_time, qw_data_time,
store_id store_id
</sql> </sql>
<select id="listExistClerkIds" resultType="java.lang.String">
select clerk_id from tab_haoban_qw_moment_plan_attend where plan_id = #{planId} and clerk_id in (
<foreach collection="list" separator="," item="item">
#{item}
</foreach>
) and delete_flag = 0
</select>
<select id="listClerk" resultType="com.gic.marketing.pro.api.dto.clerktask.ClerkTaskPlanAttendDTO">
select clerk_id clerkId , clerk_code clerkCode , clerk_name clerkName
from tab_haoban_qw_moment_plan_attend where plan_id = #{planId}
<if test="doneFlag==1">
and attend_flag = 1
</if>
and delete_flag = 0
</select>
<update id="delClerks">
update tab_haoban_qw_moment_plan_attend set delete_flag = 1 , update_time=now() where plan_id = #{planId}
<if test="null != list">
and clerk_id in (
<foreach collection="list" item="item" separator=",">
#{item}
</foreach>
)
</if>
</update>
<!-- ===================== 新增 ======================== --> <!-- ===================== 新增 ======================== -->
<insert id="insert"> <insert id="batchInsert">
<![CDATA[ <![CDATA[
INSERT INTO tab_haoban_qw_moment_plan_attend( INSERT INTO tab_haoban_qw_moment_plan_attend(
attend_id, attend_id,
...@@ -53,8 +84,6 @@ ...@@ -53,8 +84,6 @@
clerk_id, clerk_id,
clerk_code, clerk_code,
clerk_name, clerk_name,
create_time,
update_time,
delete_flag, delete_flag,
comment_count, comment_count,
like_count, like_count,
...@@ -63,30 +92,32 @@ ...@@ -63,30 +92,32 @@
moment_id, moment_id,
qw_data_time, qw_data_time,
store_id store_id
)VALUES( )VALUES
#{attendId,jdbcType=BIGINT}, <foreach collection="list" item="item" separator="," index="index">
#{planId,jdbcType=BIGINT}, (
#{wxEnterpriseId,jdbcType=CHAR}, #{item.attendId,jdbcType=BIGINT},
#{enterpriseId,jdbcType=CHAR}, #{item.planId,jdbcType=BIGINT},
#{staffId,jdbcType=CHAR}, #{item.wxEnterpriseId,jdbcType=CHAR},
#{clerkId,jdbcType=CHAR}, #{item.enterpriseId,jdbcType=CHAR},
#{clerkCode,jdbcType=VARCHAR}, #{item.staffId,jdbcType=CHAR},
#{clerkName,jdbcType=VARCHAR}, #{item.clerkId,jdbcType=CHAR},
#{createTime,jdbcType=TIMESTAMP}, #{item.clerkCode,jdbcType=VARCHAR},
#{updateTime,jdbcType=TIMESTAMP}, #{item.clerkName,jdbcType=VARCHAR},
#{deleteFlag,jdbcType=INTEGER}, #{item.deleteFlag,jdbcType=INTEGER},
#{commentCount,jdbcType=INTEGER}, #{item.commentCount,jdbcType=INTEGER},
#{likeCount,jdbcType=INTEGER}, #{item.likeCount,jdbcType=INTEGER},
#{taskStatus,jdbcType=INTEGER}, #{item.taskStatus,jdbcType=INTEGER},
#{sendTime,jdbcType=TIMESTAMP}, #{item.sendTime,jdbcType=TIMESTAMP},
#{momentId,jdbcType=VARCHAR}, #{item.momentId,jdbcType=VARCHAR},
#{qwDataTime,jdbcType=TIMESTAMP}, #{item.qwDataTime,jdbcType=TIMESTAMP},
#{storeId,jdbcType=VARCHAR} #{item.storeId,jdbcType=VARCHAR}
</foreach>
) )
]]> ]]>
</insert> </insert>
<update id="update" parameterType="com.gic.haoban.manage.api.dto.moment.QwMomentPlanAttendDTO"> <update id="update" parameterType="com.gic.haoban.manage.service.entity.moment.TabQwMomentPlanAttend">
<![CDATA[ <![CDATA[
UPDATE tab_haoban_qw_moment_plan_attend SET UPDATE tab_haoban_qw_moment_plan_attend SET
<if test="null != attendId"> <if test="null != attendId">
......
...@@ -32,6 +32,11 @@ public class MomentTest { ...@@ -32,6 +32,11 @@ public class MomentTest {
dto.setPublishType(2); dto.setPublishType(2);
dto.setPublishTime(new Date()); dto.setPublishTime(new Date());
dto.setWxEnterpriseId("123"); dto.setWxEnterpriseId("123");
dto.setCreatorId("11");
dto.setCreatorName("222");
dto.setEnterpriseId("123");
dto.setExecType(1);
dto.setExpireDays(10);
......
...@@ -80,6 +80,12 @@ public class HaobanQwMomentPlanVO implements Serializable { ...@@ -80,6 +80,12 @@ public class HaobanQwMomentPlanVO implements Serializable {
* 总任务数 * 总任务数
*/ */
private Integer totalNum; private Integer totalNum;
/**
* 成功下发导购数据
*/
private Integer taskClerkNum ;
/** /**
* 执行任务数 * 执行任务数
*/ */
...@@ -122,6 +128,15 @@ public class HaobanQwMomentPlanVO implements Serializable { ...@@ -122,6 +128,15 @@ public class HaobanQwMomentPlanVO implements Serializable {
*/ */
private Integer totalCommentCount; private Integer totalCommentCount;
public Integer getTaskClerkNum() {
return taskClerkNum;
}
public void setTaskClerkNum(Integer taskClerkNum) {
this.taskClerkNum = taskClerkNum;
}
public Double getExecRateFloat() { public Double getExecRateFloat() {
return execRateFloat; return execRateFloat;
} }
......
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