Commit ea7c429b by 徐高华

朋友圈

parent 8133a953
......@@ -73,6 +73,8 @@ public class QwMomentPlanDTO implements Serializable{
/**完成率*/
private Integer execRate;
public Long getPlanId() {
return planId;
}
......
......@@ -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.QwMomentPlanDTO;
import com.gic.haoban.manage.service.entity.moment.TabQwMomentPlanAttend;
import org.apache.ibatis.annotations.Param;
import java.util.List;
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;
import com.gic.haoban.manage.api.dto.moment.QwMomentPlanAttendDTO;
import com.gic.haoban.manage.api.qdto.moment.PlanClerkListQDTO;
import java.util.List;
public interface QwMomentPlanAttendService {
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;
import com.gic.api.base.commons.Page;
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.qdto.moment.PlanClerkListQDTO;
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 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.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service("qwMomentPlanAttendService")
public class QwMomentPlanAttendServiceImpl implements QwMomentPlanAttendService {
private final Logger logger = LogManager.getLogger(this.getClass());
@Autowired
private QwMomentPlanAttendMapper qwMomentPlanAttendMapper ;
@Autowired
private ClerkService clerkService ;
@Override
public ServiceResponse<Page<QwMomentPlanAttendDTO>> attendList(PlanClerkListQDTO qdto) {
......@@ -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;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.UniqueIdUtils;
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.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.entity.moment.TabQwMomentPlan;
import com.gic.haoban.manage.service.service.moment.QwMomentPlanAttendService;
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.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service("qwMomentPlanService")
public class QwMomentPlanServiceImpl implements QwMomentPlanService {
......@@ -24,10 +33,15 @@ public class QwMomentPlanServiceImpl implements QwMomentPlanService {
private final Logger logger = LogManager.getLogger(this.getClass());
@Autowired
private QwMomentPlanMapper qwMomentPlanMapper ;
@Autowired
private QwMomentPlanAttendService qwMomentPlanAttendService ;
@Autowired
private QwMomentPlanAttendMapper qwMomentPlanAttendMapper ;
@Override
public ServiceResponse<QwMomentPlanDTO> save(QwMomentPlanDTO dto) {
logger.info("保存朋友圈活动={}", JSONObject.toJSONString(dto));
String enterpriseId = dto.getEnterpriseId() ;
Long planId = dto.getPlanId() ;
TabQwMomentPlan plan = EntityUtil.changeEntity(TabQwMomentPlan.class,dto) ;
Date now = new Date() ;
......@@ -49,10 +63,41 @@ public class QwMomentPlanServiceImpl implements QwMomentPlanService {
}else {
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);
}
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
public ServiceResponse<Void> del(Long planId) {
this.qwMomentPlanMapper.del(planId);
......
......@@ -41,8 +41,39 @@
qw_data_time,
store_id
</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[
INSERT INTO tab_haoban_qw_moment_plan_attend(
attend_id,
......@@ -53,8 +84,6 @@
clerk_id,
clerk_code,
clerk_name,
create_time,
update_time,
delete_flag,
comment_count,
like_count,
......@@ -63,30 +92,32 @@
moment_id,
qw_data_time,
store_id
)VALUES(
#{attendId,jdbcType=BIGINT},
#{planId,jdbcType=BIGINT},
#{wxEnterpriseId,jdbcType=CHAR},
#{enterpriseId,jdbcType=CHAR},
#{staffId,jdbcType=CHAR},
#{clerkId,jdbcType=CHAR},
#{clerkCode,jdbcType=VARCHAR},
#{clerkName,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP},
#{deleteFlag,jdbcType=INTEGER},
#{commentCount,jdbcType=INTEGER},
#{likeCount,jdbcType=INTEGER},
#{taskStatus,jdbcType=INTEGER},
#{sendTime,jdbcType=TIMESTAMP},
#{momentId,jdbcType=VARCHAR},
#{qwDataTime,jdbcType=TIMESTAMP},
#{storeId,jdbcType=VARCHAR}
)VALUES
<foreach collection="list" item="item" separator="," index="index">
(
#{item.attendId,jdbcType=BIGINT},
#{item.planId,jdbcType=BIGINT},
#{item.wxEnterpriseId,jdbcType=CHAR},
#{item.enterpriseId,jdbcType=CHAR},
#{item.staffId,jdbcType=CHAR},
#{item.clerkId,jdbcType=CHAR},
#{item.clerkCode,jdbcType=VARCHAR},
#{item.clerkName,jdbcType=VARCHAR},
#{item.deleteFlag,jdbcType=INTEGER},
#{item.commentCount,jdbcType=INTEGER},
#{item.likeCount,jdbcType=INTEGER},
#{item.taskStatus,jdbcType=INTEGER},
#{item.sendTime,jdbcType=TIMESTAMP},
#{item.momentId,jdbcType=VARCHAR},
#{item.qwDataTime,jdbcType=TIMESTAMP},
#{item.storeId,jdbcType=VARCHAR}
</foreach>
)
]]>
</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[
UPDATE tab_haoban_qw_moment_plan_attend SET
<if test="null != attendId">
......
......@@ -32,6 +32,11 @@ public class MomentTest {
dto.setPublishType(2);
dto.setPublishTime(new Date());
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 {
* 总任务数
*/
private Integer totalNum;
/**
* 成功下发导购数据
*/
private Integer taskClerkNum ;
/**
* 执行任务数
*/
......@@ -122,6 +128,15 @@ public class HaobanQwMomentPlanVO implements Serializable {
*/
private Integer totalCommentCount;
public Integer getTaskClerkNum() {
return taskClerkNum;
}
public void setTaskClerkNum(Integer taskClerkNum) {
this.taskClerkNum = taskClerkNum;
}
public Double getExecRateFloat() {
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