Commit cefe8e46 by 徐高华

朋友圈

parent 7661d54b
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.clerk.api.dto.AuthorizedUser;
import com.gic.commons.util.DateUtil;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.PageHelperUtils;
import com.gic.commons.webapi.reponse.RestResponse;
......@@ -32,6 +33,7 @@ import com.gic.log.record.util.GicLogRecordEvaluationContext;
import com.gic.log.record.util.GicLogRecordOptTypeEnum;
import com.gic.web.common.utils.SessionContextUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -40,6 +42,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
......@@ -88,18 +91,102 @@ public class QwMomentController {
GicLogRecordEvaluationContext.noWriteLog();
return RestResponse.failure("9999","活动id为空") ;
}
ServiceResponse<QwMomentPlanDTO> planResp = this.qwMomentApiService.detail(qo.getPlanId()) ;
if(null == planResp.getResult()) {
GicLogRecordEvaluationContext.noWriteLog();
return RestResponse.failure("9999","导购任务不存在") ;
}
QwMomentPlanDTO oldPlan = planResp.getResult() ;
QwMomentPlanDTO plan = EntityUtil.changeEntityByJSON(QwMomentPlanDTO.class,qo) ;
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
plan.setEnterpriseId(loginUser.getEnterpriseId());
plan.setWxEnterpriseId(loginUser.getWxEnterpriseId());
plan.setCreatorId(loginUser.getClerkId());
plan.setCreatorName(loginUser.getClerkName());
ServiceResponse<QwMomentPlanDTO> resp = this.qwMomentApiService.save(plan) ;
String logContent = "编辑企微朋友圈活动【" + resp.getResult().getTitle() + "-" + resp.getResult().getPlanId() + "】";
GicLogRecordEvaluationContext.putAttribute("logValue", logContent);
String logTitle = "编辑企微朋友圈活动【" + resp.getResult().getTitle() + "-" + resp.getResult().getPlanId() + "】";
ServiceResponse<QwMomentPlanDTO> newPlanResp = this.qwMomentApiService.detail(qo.getPlanId()) ;
String logContent = this.getLogContent(loginUser.getEnterpriseId(), oldPlan, newPlanResp.getResult());
logger.info("日志内容logContent={}",logContent);
if(StringUtils.isBlank(logContent.trim())) {
GicLogRecordEvaluationContext.noWriteLog();
}else {
GicLogRecordEvaluationContext.putAttribute("logValue", logTitle + logContent);
}
return RestResponse.successResult(resp.getResult().getPlanId()+"") ;
}
private String getLogContent(String enterpriseId ,QwMomentPlanDTO oldDTO , QwMomentPlanDTO newDTO) {
List<String> logList = new ArrayList<>();
this.otherLog("活动标题",oldDTO.getTitle(),newDTO.getTitle() , logList) ;
this.otherLog("活动描述",oldDTO.getRemark(),newDTO.getRemark() , logList) ;
this.otherLog("执行方式",oldDTO.getRemark(),newDTO.getRemark() , logList) ;
this.otherLog("变更任务时间", DateUtil.dateToStr(oldDTO.getBeginDate(),"yyyy-MM-dd")+"至"+DateUtil.dateToStr(oldDTO.getEndDate(),"yyyy-MM-dd"),
DateUtil.dateToStr(newDTO.getBeginDate(),"yyyy-MM-dd")+"至"+DateUtil.dateToStr(newDTO.getEndDate(),"yyyy-MM-dd"),logList) ;
// this.otherLog2("修改了任务图片",oldDTO.getImg(),newDTO.getImg(),logList) ;
this.otherLog("任务说明",oldDTO.getRemark(),newDTO.getRemark(),logList) ;
if(!oldDTO.getMediaInfo().equals(newDTO.getMediaInfo())) {
logList.add("变更朋友圈配置");
}
if(newDTO.getPublishType()==1) {
if(oldDTO.getPublishType()==2) {
this.otherLog("发布时间", "定时发布", "立即发布", logList);
}
}else {
if(oldDTO.getPublishType()==1) {
this.otherLog("发布时间","立即发布",DateUtil.dateToStr(newDTO.getPublishTime(),"yyyy-MM-dd HH:mm"),logList) ;
}else {
this.otherLog("发布时间",DateUtil.dateToStr(oldDTO.getPublishTime(),"yyyy-MM-dd HH:mm"),DateUtil.dateToStr(oldDTO.getPublishTime(),"yyyy-MM-dd HH:mm"),logList) ;
}
}
/* // 指定人群
if(oldDTO.getTaskType()!= ClerkTaskTypeEnum.CONTENT.getType()) {
this.otherLog("指定人群",this.rqLogTitle(oldDTO.getMemberType()),this.rqLogTitle(newDTO.getMemberType()),logList) ;
}
// 召回规则订单渠道
if(oldDTO.getTaskType() == ClerkTaskTypeEnum.ORDER.getType()) {
this.otherLog("召回规则订单渠道",this.channelName(enterpriseId,oldDTO.getOrderChannels()),this.channelName(enterpriseId,newDTO.getOrderChannels()),logList) ;
}
// 添加规则
if(oldDTO.getTaskType() == ClerkTaskTypeEnum.QW.getType()) {
String s = this.otherLog("添加规则",this.qwRule(oldDTO.getQwRule()),this.qwRule(newDTO.getQwRule()),logList) ;
String s1= this.qwNotMemberFlag(oldDTO.getQwNotMemberFlag(),newDTO.getQwNotMemberFlag(),StringUtils.isBlank(s)) ;
logList.add(s1) ;
}
// 指定导购
if(oldDTO.getTaskMode() == 2) {
List<String> oldClerkIdList = oldDTO.getClerkList().stream().map(o->o.getClerkId()).collect(Collectors.toList());
List<String> newClerkIdList = newDTO.getClerkList().stream().map(o->o.getClerkId()).collect(Collectors.toList());
this.otherLog("指定导购",oldClerkIdList.size()+"个",newClerkIdList.size()+"个",logList) ;
*//*if(CollectionUtils.isNotEmpty(differenceList(oldClerkIdList,newClerkIdList)) &&
CollectionUtils.isNotEmpty(differenceList(newClerkIdList,oldClerkIdList))) {
String s1 = oldDTO.getClerkList().stream().map(o->o.getClerkName()).collect(Collectors.joining("、")) ;
String s2 = newDTO.getClerkList().stream().map(o->o.getClerkName()).collect(Collectors.joining("、")) ;
this.otherLog("指定导购",s1,s2,logList) ;
}*//*
}*/
return logList.stream().filter(o->StringUtils.isNotBlank(o)).collect(Collectors.joining(";"));
}
private String otherLog(String s1, String s2, String s3 , List<String> logList) {
if(null == s2) {
s2 = "" ;
}
if(null == s3) {
s3 = "" ;
}
if (!s2.equals(s3)) {
String s = new StringBuilder(s1).append("从【").append(s2).append("】修改为【").append(s3).append("】").toString() ;
if(null != logList) {
logList.add(s);
}
return s ;
}
return "";
}
/**
* 删除
* @return
......
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