Commit 270c8321 by 徐高华

朋友圈

parent 02f9d1bc
......@@ -23,7 +23,7 @@ public interface QwMomentPlanAttendMapper {
*/
List<String> listExistClerkIds(@Param("planId") Long planId , @Param("list") List<String> clerkIdList) ;
List<QwMomentPlanAttendDTO> listClerk(@Param("planId")Long planId);
List<QwMomentPlanAttendDTO> listClerk(@Param("planId")Long planId , @Param("planId")Integer statusFlag);
List<TabQwMomentPlanAttend> listForData(@Param("planId")Long planId);
......@@ -45,4 +45,10 @@ public interface QwMomentPlanAttendMapper {
void updateMomentId(@Param("id") Long id, @Param("momentId") String jobId);
void updateFail(@Param("planId") Long planId, @Param("list") List<String> clerkIdList , String reason) ;
void updateSuccess(@Param("planId") Long planId, @Param("list") List<String> clerkIdList) ;
void updateSuccessStaff(@Param("planId") Long planId, @Param("clerkId") String clerkId , @Param("staffId") String staffId) ;
}
......@@ -7,6 +7,17 @@ public class ClerkStaffBO implements Serializable {
private String clerkId ;
private String staffId ;
// 0成功 1导购已删除 2未绑定成员
private int code ;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getClerkId() {
return clerkId;
}
......
......@@ -8,6 +8,7 @@ import com.gic.haoban.manage.api.dto.moment.TaskListWxaDTO;
import com.gic.haoban.manage.api.qdto.moment.PlanClerkListQDTO;
import com.gic.haoban.manage.api.qdto.moment.SendResultQDTO;
import com.gic.haoban.manage.api.qdto.moment.TaskListWxaQDTO;
import com.gic.haoban.manage.service.entity.moment.TabQwMomentPlan;
import com.gic.haoban.manage.service.pojo.ClerkStaffBO;
import java.util.List;
......@@ -21,11 +22,13 @@ public interface QwMomentPlanAttendService {
* @param enterpriseId
* @param planId
*/
void saveClerk(String wxEnterpriseId , String enterpriseId, Long planId , List<ClerkStaffBO> clerkStaffList) ;
void saveClerk(String wxEnterpriseId , String enterpriseId, Long planId , List<ClerkStaffBO> clerkStaffList , int statusFlag) ;
ServiceResponse<TaskDetailDTO> taskDetail(Long planId, String execClerkId);
ServiceResponse<Page<TaskListWxaDTO>> taskListWxa(TaskListWxaQDTO qdto);
ServiceResponse<Void> finishTask(SendResultQDTO qdto);
void updateStatusFlag(TabQwMomentPlan plan) ;
}
......@@ -8,6 +8,7 @@ import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.DateUtil;
import com.gic.commons.util.PageHelperUtils;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.dto.moment.QwMomentPlanAttendDTO;
import com.gic.haoban.manage.api.dto.moment.TaskDetailDTO;
......@@ -15,10 +16,12 @@ import com.gic.haoban.manage.api.dto.moment.TaskListWxaDTO;
import com.gic.haoban.manage.api.qdto.moment.PlanClerkListQDTO;
import com.gic.haoban.manage.api.qdto.moment.SendResultQDTO;
import com.gic.haoban.manage.api.qdto.moment.TaskListWxaQDTO;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
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.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.moment.TabQwMomentPlan;
import com.gic.haoban.manage.service.entity.moment.TabQwMomentPlanAttend;
import com.gic.haoban.manage.service.pojo.ClerkStaffBO;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
......@@ -36,6 +39,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service("qwMomentPlanAttendService")
......@@ -55,6 +59,8 @@ public class QwMomentPlanAttendServiceImpl implements QwMomentPlanAttendService
private StaffMapper staffMapper ;
@Autowired
private QwMomentPlanMapper qwMomentPlanMapper ;
@Autowired
private StaffClerkRelationApiService staffClerkRelationApiService ;
@Override
public ServiceResponse<Page<QwMomentPlanAttendDTO>> attendList(PlanClerkListQDTO qdto) {
......@@ -77,7 +83,7 @@ public class QwMomentPlanAttendServiceImpl implements QwMomentPlanAttendService
}
@Override
public void saveClerk(String wxEnterpriseId , String enterpriseId, Long planId , List<ClerkStaffBO> clerkStaffList) {
public void saveClerk(String wxEnterpriseId , String enterpriseId, Long planId , List<ClerkStaffBO> clerkStaffList , int statusFlag) {
List<String> clerkIdList = clerkStaffList.stream().map(o->o.getClerkId()).collect(Collectors.toList());
List<String> existClerkIdList = this.qwMomentPlanAttendMapper.listExistClerkIds(planId,clerkIdList) ;
if(CollectionUtils.isNotEmpty(existClerkIdList)) {
......@@ -103,11 +109,52 @@ public class QwMomentPlanAttendServiceImpl implements QwMomentPlanAttendService
attend.setClerkName(clerkDTO.getClerkName());
attend.setStoreId(clerkDTO.getStoreId());
attend.setTaskStatus(1);
attend.setStatusFlag(0);
attend.setStatusFlag(statusFlag);
list.add(attend) ;
}
}
this.qwMomentPlanAttendMapper.batchInsert(list);
if(statusFlag == 1) {
this.qwMomentPlanMapper.updateClerkNum(planId,list.size(), list.size(), -1);
}else {
this.qwMomentPlanMapper.updateClerkNum(planId,list.size(), -1, -1);
}
}
@Override
public void updateStatusFlag(TabQwMomentPlan plan) {
List<QwMomentPlanAttendDTO> allList = this.qwMomentPlanAttendMapper.listClerk(plan.getPlanId(),null) ;
int totalSize = allList.size() ;
List<String> clerkIdList = allList.stream().map(o->o.getClerkId()).collect(Collectors.toList());
List<StaffClerkRelationDTO> list = this.staffClerkRelationApiService.listByClerkIdsWxEnterpriseId(clerkIdList,plan.getWxEnterpriseId()) ;
Map<String,String> map = list.stream().collect(Collectors.toMap(o->o.getClerkId(),StaffClerkRelationDTO::getStaffId,(k1, k2)->k1)) ;
if(CollectionUtils.isEmpty(list)) {
this.qwMomentPlanAttendMapper.updateFail(plan.getPlanId(), clerkIdList,"任务下发时未绑定企微号");
}else {
List<String> noStaff = allList.stream().filter(o->map.keySet().contains(o.getClerkId())).map(o->o.getClerkId()).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(noStaff)) {
this.qwMomentPlanAttendMapper.updateFail(plan.getPlanId(), clerkIdList,"任务下发时未绑定企微号");
}
List<String> successList = new ArrayList<>() ;
for(QwMomentPlanAttendDTO dto : allList) {
String cid = dto.getClerkId() ;
String sid = dto.getStaffId() ;
if(map.get(cid) != null && map.get(cid).equals(sid)) {
successList.add(cid) ;
}else {
this.qwMomentPlanAttendMapper.updateSuccessStaff(plan.getPlanId(),cid,map.get(cid));
}
}
if(CollectionUtils.isNotEmpty(successList)) {
this.qwMomentPlanAttendMapper.updateSuccess(plan.getPlanId(), successList);
}
}
int failCount = 0 ;
List<QwMomentPlanAttendDTO> failList = this.qwMomentPlanAttendMapper.listClerk(plan.getPlanId(),2) ;
if(CollectionUtils.isNotEmpty(failList)) {
failCount = failList.size() ;
}
this.qwMomentPlanMapper.updateClerkNum(plan.getPlanId(), totalSize, totalSize-failCount,-1);
}
......
......@@ -167,9 +167,13 @@ public class QwMomentPlanServiceImpl implements QwMomentPlanService {
bo.setStaffId(o.getStaffId());
return bo ;
}).collect(Collectors.toList()) ;
this.qwMomentPlanAttendService.saveClerk(wxEnterpriseId,enterpriseId, planId,clerkStaffList);
int statusFlag = 0 ;
if(publishFlag) {
statusFlag = 1 ;
}
this.qwMomentPlanAttendService.saveClerk(wxEnterpriseId,enterpriseId, planId, clerkStaffList , statusFlag);
} else {
List<String> oldList = this.qwMomentPlanAttendMapper.listClerk(planId).stream().map(o -> o.getClerkId()).collect(Collectors.toList());
List<String> oldList = this.qwMomentPlanAttendMapper.listClerk(planId , null).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());
......@@ -180,7 +184,7 @@ public class QwMomentPlanServiceImpl implements QwMomentPlanService {
bo.setStaffId(o.getStaffId());
return bo ;
}).collect(Collectors.toList()) ;
this.qwMomentPlanAttendService.saveClerk(wxEnterpriseId,enterpriseId, planId , clerkStaffList);
this.qwMomentPlanAttendService.saveClerk(wxEnterpriseId,enterpriseId, planId , clerkStaffList , 0);
if (CollectionUtils.isNotEmpty(delList)) {
this.qwMomentPlanAttendMapper.delClerks(planId, delList);
}
......@@ -248,7 +252,7 @@ public class QwMomentPlanServiceImpl implements QwMomentPlanService {
QwMomentPlanDTO dto = EntityUtil.changeEntityByJSON(QwMomentPlanDTO.class,plan) ;
// 获取参与导购
if(dto.getPlanClerkType()==1) {
List<QwMomentPlanAttendDTO> clerkList = this.qwMomentPlanAttendMapper.listClerk(planId) ;
List<QwMomentPlanAttendDTO> clerkList = this.qwMomentPlanAttendMapper.listClerk(planId,null) ;
dto.setClerkList(clerkList);
}
return ServiceResponse.success(dto);
......@@ -313,7 +317,7 @@ public class QwMomentPlanServiceImpl implements QwMomentPlanService {
logger.info("管理员列表={}",userIdList);
clerkIdList.stream().filter(o->!userIdList.contains(o)).collect(Collectors.toList()) ;
logger.info("导购数量={}",clerkIdList.size());
this.qwMomentPlanAttendService.saveClerk(plan.getWxEnterpriseId(),plan.getEnterpriseId(),planId, clerkIdList);
this.qwMomentPlanAttendService.saveClerk(plan.getWxEnterpriseId(),plan.getEnterpriseId(),planId, clerkIdList , 1);
this.qwMomentPlanMapper.updateClerkNum(planId,clerkIdList.size(),-1,-1);
}
......@@ -351,6 +355,9 @@ public class QwMomentPlanServiceImpl implements QwMomentPlanService {
// 0全部导购 1部分导购
if(plan.getPlanClerkType()==0) {
this.saveAttendClerkForTask(plan) ;
}else {
// 下发失败
this.qwMomentPlanAttendService.updateStatusFlag(plan);
}
this.sendPlanNotice(plan);
}
......@@ -361,7 +368,7 @@ public class QwMomentPlanServiceImpl implements QwMomentPlanService {
long planId = plan.getPlanId();
if(plan.getExecType()==1) {
// 好办小程序
List<QwMomentPlanAttendDTO> list = this.qwMomentPlanAttendMapper.listClerk(planId);
List<QwMomentPlanAttendDTO> list = this.qwMomentPlanAttendMapper.listClerk(planId , 1);
if (CollectionUtils.isNotEmpty(list)) {
for (QwMomentPlanAttendDTO dto : list) {
this.sendTaskToClerk(dto.getClerkId(),plan);
......@@ -398,7 +405,7 @@ public class QwMomentPlanServiceImpl implements QwMomentPlanService {
vo.setMaterialDesc(obj.getString("contentText"));
imageList.add(vo);
}
List<QwMomentPlanAttendDTO> clerkList = this.qwMomentPlanAttendMapper.listClerk(plan.getPlanId()) ;
List<QwMomentPlanAttendDTO> clerkList = this.qwMomentPlanAttendMapper.listClerk(plan.getPlanId(),1) ;
List<String> clerkIdList = clerkList.stream().map(o->o.getClerkId()).collect(Collectors.toList());
ServiceResponse<String> resp = this.qywxSendService.share(plan.getWxEnterpriseId(),clerkIdList,msg,imageList) ;
logger.info("发企微朋友={}",JSONObject.toJSONString(resp));
......
......@@ -86,8 +86,11 @@
<select id="listClerk" resultType="com.gic.haoban.manage.api.dto.moment.QwMomentPlanAttendDTO">
select clerk_id clerkId , clerk_code clerkCode , clerk_name clerkName
select clerk_id clerkId , clerk_code clerkCode , clerk_name clerkName , staff_id staffId
from tab_haoban_qw_moment_plan_attend where plan_id = #{planId}
<if test="null != statusFlag">
and status_flag = #{statusFlag}
</if>
and delete_flag = 0
</select>
......@@ -169,6 +172,28 @@
update tab_haoban_qw_moment_plan_attend set moment_id = #{momentId} where attend_id = #{id}
</update>
<update id="updateFail">
update tab_haoban_qw_moment_plan_attend set status_flag = 2 , reason = #{reason} where plan_id = #{planId}
and clerk_id in (
<foreach collection="list" item="item" separator=",">
#{item}
</foreach>
)
</update>
<update id="updateSuccess">
update tab_haoban_qw_moment_plan_attend set status_flag = 1 where plan_id = #{planId}
and clerk_id in (
<foreach collection="list" item="item" separator=",">
#{item}
</foreach>
)
</update>
<update id="updateSuccessStaff">
update tab_haoban_qw_moment_plan_attend set status_flag = 1 , staff_id=#{staffId} where plan_id = #{planId} and clerk_id = #{clerkId}
</update>
<!-- ===================== 新增 ======================== -->
<insert id="batchInsert">
INSERT INTO tab_haoban_qw_moment_plan_attend(
......
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