Commit 7840fb1d by 徐高华

Merge branch 'xgh_内容中台' into 'developer'

Xgh 内容中台

See merge request !426
parents a79c36fa cd89b7e1
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
public class ContentMaterialDTO implements Serializable {
private static final long serialVersionUID = -8114034921530488238L;
// 素材类型, 1文本, 2图片, 3网页, 4视频, 5文件,6小程序
private int materialType;
private String imgUrl;
public String getImgUrl() {
return imgUrl;
}
public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
}
public int getMaterialType() {
return materialType;
}
public void setMaterialType(int materialType) {
this.materialType = materialType;
}
}
......@@ -59,7 +59,6 @@ public interface ExternalClerkRelatedApiService {
@Deprecated
List<ExternalClerkRelatedDTO> listByEnterpriseIdAndDate(String enterpriseId, Date date);
@Deprecated
Page<ExternalClerkRelatedDTO> pageMemberUnionByParams(List<String> userIdList, List<String> sendMemberIds,
String enterpriseId, BasePageInfo pageInfo);
......
......@@ -60,17 +60,17 @@ public interface MemberUnionidRelatedApiService {
List<MemberStoreDTO> listByExTernalUseridAndWxUserId(String externalUserid, String staffId, String storeId);
/**
* 群发助手发送企业微信消息
* 创建企业群发, 支出素材批量发送
*
* @param wxEnterpriseId
* @param staffId
* @param extendUserList
* @param materialId
* @return {@link String }
* @author mozhu
* @date 2022-01-13 10:50:44
* @param wxEnterpriseId : 微信企业id
* @param staffId : 用户id
* @param extendUserList : 发送的用户id
* @param materialIdList : 素材id列表
* @return : 返回群发执行结果
*/
String sendMessage(String wxEnterpriseId, String staffId, List<String> extendUserList, String materialId);
JSONResponse sendMessage(String wxEnterpriseId, String staffId, List<String> extendUserList, List<String> materialIdList , String planId);
JSONResponse sendMessageShare(String wxEnterpriseId, String staffId, List<String> extendUserList, String message ,List<ContentMaterialDTO> imgList);
/**
* 创建企业群发, 支出素材批量发送
......@@ -81,10 +81,7 @@ public interface MemberUnionidRelatedApiService {
* @param materialIdList : 素材id列表
* @return : 返回群发执行结果
*/
JSONResponse sendMessage(String wxEnterpriseId, String staffId, List<String> extendUserList, List<String> materialIdList);
JSONResponse sendMessage(String wxEnterpriseId, String staffId, List<String> extendUserList, List<String> materialIdList , String ecmPlanId);
JSONResponse share(String wxEnterpriseId, List<String> clerkIdList, String message , List<ContentMaterialDTO> imgList);
/**
* 获取群发成员发送任务列表
......
......@@ -7,22 +7,17 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TabHaobanMaterialMapper {
int deleteByPrimaryKey(String materialId);
int insert(TabHaobanMaterial record);
int batchInsert(@Param("records") List<TabHaobanMaterial> records);
int insertSelective(TabHaobanMaterial record);
TabHaobanMaterial selectByPrimaryKey(String materialId);
List<TabHaobanMaterial> listByids(@Param("materialIds") List<String> materialIds);
int updateByPrimaryKeySelective(TabHaobanMaterial record);
int updateByPrimaryKey(TabHaobanMaterial record);
List<TabHaobanMaterial> listMaterialByCategoryId(String categoryId);
Page<TabHaobanMaterial> listMaterial(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("keyword") String keyword, @Param("categoryId") String categoryId, @Param("materialType") Integer materialType);
......@@ -35,9 +30,6 @@ public interface TabHaobanMaterialMapper {
/**
* 删除
*
* @param ids
* @return
*/
int delMaterialByIds(@Param("ids") List<String> ids);
}
\ No newline at end of file
package com.gic.haoban.manage.service.dao.mapper;
import org.apache.ibatis.annotations.Param;
import com.gic.haoban.manage.service.entity.TabMaterialContent;
/**
*
* @ClassName: 内容中台-素材
* @Description: TODO
* @Author 徐高华
* @Date 2022年11月08日 15:24:22
* @Modify
* @CopyRight
*/
public interface TabMaterialContentMapper {
public int insert(TabMaterialContent entity);
public int updateByPrimaryKey(TabMaterialContent entity);
public TabMaterialContent selectByUrl(@Param("wxEnterpriseId") String wxEnterpriesId,
@Param("urlMd5") String urlMd5);
public TabMaterialContent selectById(String id) ;
}
\ No newline at end of file
package com.gic.haoban.manage.service.entity;
import java.io.Serializable;
/**
*
* @ClassName: TabHaobanMaterialContent
* @Description: TODO
* @Author 徐高华
* @Date 2022年11月08日 15:24:22
* @Modify
* @CopyRight
*/
public class TabMaterialContent implements Serializable {
private static final long serialVersionUID = 9984223961500L;
/**素材id*/
private String materialId;
/**素材类型, 1文本, 2图片, 3网页, 4视频, 5文件,6小程序*/
private Integer materialType;
/**微信最后更新时间*/
private java.util.Date wxLastUploadTime;
/**企业微信mediaid*/
private String mediaId;
private String wxEnterpriseId;
private String imgUrl;
private String urlMd5;
/**0删除1正常*/
private Integer statusFlag;
/**创建时间*/
private java.util.Date createTime;
/**修改时间*/
private java.util.Date updateTime;
private int mediaType ;
public int getMediaType() {
return mediaType;
}
public void setMediaType(int mediaType) {
this.mediaType = mediaType;
}
public void setMaterialId(String materialId) {
this.materialId = materialId;
}
public String getMaterialId() {
return materialId;
}
public void setMaterialType(Integer materialType) {
this.materialType = materialType;
}
public Integer getMaterialType() {
return materialType;
}
public void setWxLastUploadTime(java.util.Date wxLastUploadTime) {
this.wxLastUploadTime = wxLastUploadTime;
}
public java.util.Date getWxLastUploadTime() {
return wxLastUploadTime;
}
public void setMediaId(String mediaId) {
this.mediaId = mediaId;
}
public String getMediaId() {
return mediaId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
}
public String getImgUrl() {
return imgUrl;
}
public void setUrlMd5(String urlMd5) {
this.urlMd5 = urlMd5;
}
public String getUrlMd5() {
return urlMd5;
}
public void setStatusFlag(Integer statusFlag) {
this.statusFlag = statusFlag;
}
public Integer getStatusFlag() {
return statusFlag;
}
public void setCreateTime(java.util.Date createTime) {
this.createTime = createTime;
}
public java.util.Date getCreateTime() {
return createTime;
}
public void setUpdateTime(java.util.Date updateTime) {
this.updateTime = updateTime;
}
public java.util.Date getUpdateTime() {
return updateTime;
}
}
\ No newline at end of file
......@@ -49,5 +49,7 @@ public interface MaterialService {
* @param ids
*/
void delmaterialByIds(List<String> ids);
public MaterialDTO getHasChangeMadieMaterialById(String materialId,int from) ;
}
package com.gic.haoban.manage.service.service;
import java.util.List;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.dto.ContentMaterialDTO;
public interface QywxSendService {
/**
* 企微群发-传入素材(ecm、群发助手)
*/
public ServiceResponse<String> sendMessage(String wxEnterpriseId, String staffId, List<String> extendUserList,
List<String> materialIdList);
/**
* 素材-分享
*/
public ServiceResponse<String> sendMessage(String wxEnterpriseId, String staffId, List<String> extendUserList,
List<ContentMaterialDTO> imageList, String message);
/**
* 分享朋友圈
*/
public ServiceResponse<String> share(String wxEnterpriseId, List<String> clerkIdList, String message,
List<ContentMaterialDTO> imageList);
}
package com.gic.haoban.manage.service.service.impl;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gic.api.base.commons.JSONResponse;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.MaterialDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanMaterialMapper;
import com.gic.haoban.manage.service.dao.mapper.TabMaterialContentMapper;
import com.gic.haoban.manage.service.entity.TabHaobanMaterial;
import com.gic.haoban.manage.service.entity.TabMaterialContent;
import com.gic.haoban.manage.service.service.MaterialService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.util.CommonUtil;
import com.gic.wechat.api.enums.QywxMediaTypeEnum;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service
public class MaterialServiceImpl implements MaterialService {
private static final Logger logger = getLogger(MaterialService.class);
@Autowired
private TabHaobanMaterialMapper mapper;
@Autowired
private TabMaterialContentMapper materialContentMapper ;
@Autowired
private WxEnterpriseService wxEnterpriseService ;
@Autowired
private QywxSuiteApiService qywxSuiteApiService ;
@Autowired
private Config config;
@Override
public List<MaterialDTO> listMaterialByCategoryId(String categoryId) {
......@@ -82,4 +108,105 @@ public class MaterialServiceImpl implements MaterialService {
public void delmaterialByIds(List<String> ids) {
mapper.delMaterialByIds(ids);
}
@Override
public MaterialDTO getHasChangeMadieMaterialById(String materialId, int from) {
MaterialDTO materialDTO = null ;
TabMaterialContent entity =null ;
if(from == 1) {
materialDTO = this.selectMaterialById(materialId);
}
if(from == 2) {
entity =this.materialContentMapper.selectById(materialId) ;
if(null != entity) {
materialDTO = EntityUtil.changeEntityByJSON(MaterialDTO.class, entity) ;
}
}
if (null == materialDTO) {
return null;
}
Date lastUploadTime = materialDTO.getWxLastUploadTime();
Date date = new Date();
Date compareDate = DateUtils.addDays(date, -3);
if (lastUploadTime != null && lastUploadTime.after(compareDate) && StringUtils.isNotBlank(materialDTO.getMediaId())) {
return materialDTO;
}
Integer materialType = materialDTO.getMaterialType();
String madiaId = materialDTO.getMediaId();
//需要上传的类型
List<Integer> typeList = Arrays.asList(2, 4, 5, 6);
if (typeList.contains(materialType)) {
madiaId = this.reUpdalodMetail(materialId,from);
}
materialDTO.setMediaId(madiaId);
materialDTO.setWxLastUploadTime(date);
return materialDTO;
}
private String reUpdalodMetail(String materialId,int from) {
MaterialDTO old = null ;
TabMaterialContent entity =null ;
if(from == 1) {
old = this.selectMaterialById(materialId);
}
if(from == 2) {
entity =this.materialContentMapper.selectById(materialId) ;
if(null != entity) {
old = EntityUtil.changeEntityByJSON(MaterialDTO.class, entity) ;
}
}
Integer type = old.getMaterialType();
if (type == null) {
return "";
}
String wxEnterpriseId = old.getWxEnterpriseId();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if (qwDTO == null) {
logger.info("qwDTO is null");
return "";
}
String url = "";
QywxMediaTypeEnum fileType = null;
if (type == 2) {
fileType = QywxMediaTypeEnum.IMAGE;
url = old.getImgUrl();
}
if (type == 4) {
fileType = QywxMediaTypeEnum.VIDEO;
url = old.getLink();
}
if (type == 5) {
fileType = QywxMediaTypeEnum.FILE;
url = old.getLink();
} else if (type == 6) {
fileType = QywxMediaTypeEnum.IMAGE;
url = old.getImgUrl();
}
if (fileType == null) {
logger.error("materialId无类型,materialId:{}", materialId);
return "";
}
String[] arr = url.split("/");
int count = arr.length;
JSONResponse jp = null ;
if(from==2 && entity.getMediaType()==2) {
jp = qywxSuiteApiService.uploadAttachment(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode());
}else {
jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode());
}
if (jp.getErrorCode() == 0) {
if(from==1) {
old.setWxLastUploadTime(new Date());
old.setMediaId(jp.getResult().toString());
this.edit(old);
}
if(from==2) {
entity.setWxLastUploadTime(new Date());
entity.setMediaId(jp.getResult().toString());
this.materialContentMapper.updateByPrimaryKey(entity) ;
}
}
return old.getMediaId();
}
}
......@@ -27,7 +27,6 @@ import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.BatchAddMaterialDTO;
import com.gic.haoban.manage.api.dto.MaterialCategoryDTO;
import com.gic.haoban.manage.api.dto.MaterialDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.service.MaterialApiService;
import com.gic.haoban.manage.service.config.Config;
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gic.haoban.manage.service.dao.mapper.TabMaterialContentMapper">
<resultMap type="com.gic.haoban.manage.service.entity.TabMaterialContent" id="result-map-tabHaobanMaterialContent">
<result column="material_id" property="materialId"/>
<result column="material_type" property="materialType"/>
<result column="wx_last_upload_time" property="wxLastUploadTime"/>
<result column="media_id" property="mediaId"/>
<result column="wx_enterprise_id" property="wxEnterpriseId"/>
<result column="img_url" property="imgUrl"/>
<result column="url_md5" property="urlMd5"/>
<result column="status_flag" property="statusFlag"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="media_type" property="mediaType" />
</resultMap>
<sql id="Base_Column_List">
material_id,
material_type,
wx_last_upload_time,
media_id,
wx_enterprise_id,
img_url,
url_md5,
status_flag,
create_time,
update_time , media_type
</sql>
<!-- ===================== 新增 ======================== -->
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabMaterialContent" useGeneratedKeys="true" keyProperty="id">
<![CDATA[
INSERT INTO tab_haoban_material_content(
material_id,
material_type,
wx_last_upload_time,
media_id,
wx_enterprise_id,
img_url,
url_md5,
status_flag,
create_time,
update_time ,
media_type
)VALUES(
#{materialId,jdbcType=VARCHAR},
#{materialType,jdbcType=INTEGER},
#{wxLastUploadTime,jdbcType=TIMESTAMP},
#{mediaId,jdbcType=VARCHAR},
#{wxEnterpriseId,jdbcType=VARCHAR},
#{imgUrl,jdbcType=VARCHAR},
#{urlMd5,jdbcType=VARCHAR},
1,
now(),
now() , #{mediaType}
)
]]>
</insert>
<!-- ==================更新 ========== -->
<update id="updateByPrimaryKey" parameterType="com.gic.haoban.manage.service.entity.TabMaterialContent">
<![CDATA[
UPDATE tab_haoban_material_content SET
wx_last_upload_time=#{wxLastUploadTime,jdbcType=TIMESTAMP},
media_id=#{mediaId,jdbcType=VARCHAR},
wx_enterprise_id=#{wxEnterpriseId,jdbcType=VARCHAR},
status_flag=#{statusFlag,jdbcType=INTEGER},
update_time= now()
where material_id = #{materialId}
]]>
</update>
<!-- ============ 查询=============-->
<select id="selectById" parameterType="String" resultMap="result-map-tabHaobanMaterialContent">
SELECT
<include refid="Base_Column_List"/>
FROM tab_haoban_material_content WHERE material_id=#{id} and status_flag = 1
</select>
<select id="selectByUrl" resultMap="result-map-tabHaobanMaterialContent">
SELECT
<include refid="Base_Column_List"/>
FROM tab_haoban_material_content WHERE wx_enterprise_id=#{wxEnterpriseId} and url_md5=#{urlMd5} and status_flag = 1
</select>
</mapper>
\ No newline at end of file
......@@ -44,10 +44,6 @@
</foreach>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from tab_haoban_material
where material_id = #{materialId,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabHaobanMaterial" >
insert into tab_haoban_material (material_id, from_material_id, material_title, material_type,
category_id, material_content, wx_last_upload_time,
......@@ -64,115 +60,7 @@
#{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanMaterial" >
insert into tab_haoban_material
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="materialId != null" >
material_id,
</if>
<if test="materialTitle != null" >
material_title,
</if>
<if test="materialType != null" >
material_type,
</if>
<if test="categoryId != null" >
category_id,
</if>
<if test="materialContent != null" >
material_content,
</if>
<if test="wxLastUploadTime != null" >
wx_last_upload_time,
</if>
<if test="mediaId != null" >
media_id,
</if>
<if test="wxEnterpriseId != null" >
wx_enterprise_id,
</if>
<if test="staffId != null" >
staff_id,
</if>
<if test="staffName != null" >
staff_name,
</if>
<if test="imgUrl != null" >
img_url,
</if>
<if test="wxImgUrl != null" >
wx_img_url,
</if>
<if test="materialDesc != null" >
material_desc,
</if>
<if test="statusFlag != null" >
status_flag,
</if>
<if test="link != null" >
link,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="materialId != null" >
#{materialId,jdbcType=VARCHAR},
</if>
<if test="materialTitle != null" >
#{materialTitle,jdbcType=VARCHAR},
</if>
<if test="materialType != null" >
#{materialType,jdbcType=INTEGER},
</if>
<if test="categoryId != null" >
#{categoryId,jdbcType=VARCHAR},
</if>
<if test="materialContent != null" >
#{materialContent,jdbcType=VARCHAR},
</if>
<if test="wxLastUploadTime != null" >
#{wxLastUploadTime,jdbcType=TIMESTAMP},
</if>
<if test="mediaId != null" >
#{mediaId,jdbcType=VARCHAR},
</if>
<if test="wxEnterpriseId != null" >
#{wxEnterpriseId,jdbcType=VARCHAR},
</if>
<if test="staffId != null" >
#{staffId,jdbcType=VARCHAR},
</if>
<if test="staffName != null" >
#{staffName,jdbcType=VARCHAR},
</if>
<if test="imgUrl != null" >
#{imgUrl,jdbcType=VARCHAR},
</if>
<if test="wxImgUrl != null" >
#{wxImgUrl,jdbcType=VARCHAR},
</if>
<if test="materialDesc != null" >
#{materialDesc,jdbcType=VARCHAR},
</if>
<if test="statusFlag != null" >
#{statusFlag,jdbcType=INTEGER},
</if>
<if test="link != null" >
#{link,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<insert id="batchInsert" parameterType="com.gic.haoban.manage.service.entity.TabHaobanMaterial">
insert into tab_haoban_material
......@@ -280,26 +168,6 @@
</set>
where material_id = #{materialId,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.haoban.manage.service.entity.TabHaobanMaterial" >
update tab_haoban_material
set material_title = #{materialTitle,jdbcType=VARCHAR},
material_type = #{materialType,jdbcType=INTEGER},
category_id = #{categoryId,jdbcType=VARCHAR},
material_content = #{materialContent,jdbcType=VARCHAR},
wx_last_upload_time = #{wxLastUploadTime,jdbcType=TIMESTAMP},
media_id = #{mediaId,jdbcType=VARCHAR},
wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
staff_id = #{staffId,jdbcType=VARCHAR},
staff_name = #{staffName,jdbcType=VARCHAR},
img_url = #{imgUrl,jdbcType=VARCHAR},
wx_img_url = #{wxImgUrl,jdbcType=VARCHAR},
material_desc = #{materialDesc,jdbcType=VARCHAR},
status_flag = #{statusFlag,jdbcType=INTEGER},
link = #{link,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where material_id = #{materialId,jdbcType=VARCHAR}
</update>
<select id="listMaterialByCategoryId" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
......
package com.gic.haoban.manage.web.controller.content;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.haoban.app.customer.dto.CustomerDTO;
import com.gic.haoban.app.customer.dto.MemberInfoListParamsDTO;
import com.gic.haoban.app.customer.service.api.service.DistributeApiService;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.web.controller.WebBaseController;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.CustomerQO;
import com.gic.haoban.manage.web.utils.ClerkUtils;
@RestController
public class QwMessageController extends WebBaseController {
private final Logger logger = LogManager.getLogger(QwMessageController.class);
@Autowired
private DistributeApiService distributeApiService;
@Autowired
private StaffApiService staffApiService;
@Autowired
private ClerkService clerkService;
/**
* 群发-分享
*/
@RequestMapping("/message-send")
public HaobanResponse messageSend(CustomerQO qo, String imgJson, String selectedStoreId) {
CustomerDTO params = EntityUtil.changeEntityByJSON(CustomerDTO.class, qo);
String clerkId = qo.getClerkId();
String wxEnterpriseId = qo.getWxEnterpriseId();
String enterpriseId = qo.getEnterpriseId();
String searchParams = qo.getSearchParams();
String staffId = qo.getStaffId();
List<String> memberIdList = qo.getMemberIdList();
ClerkDTO clerk = this.clerkService.getclerkById(clerkId);
String storeId = ClerkUtils.getClerkStore(clerk, clerkId, selectedStoreId);
// 店长参数
params.setStoreId(storeId);
params.setEnterpriseId(enterpriseId);
params.setClerkId(clerkId);
MemberInfoListParamsDTO memberInfoListParamsDTO = com.gic.haoban.common.utils.StringUtil.getBean(searchParams,
MemberInfoListParamsDTO.class);
params.setQwFriendFlag(true);
List<String> sendMemberIds = distributeApiService.getMemberIds(params, memberIdList, memberInfoListParamsDTO);
if (CollectionUtils.isEmpty(sendMemberIds)) {
return this.fail("无会员数据");
}
List<String> userIdList = new ArrayList<>();
if (clerk.getClerkType() > 0) {
userIdList = staffApiService.listBindStaffId(storeId);
} else {
userIdList.add(clerkId);
}
JSONObject json = new JSONObject();
json.put("userIdList", userIdList);
json.put("sendMemberIds", sendMemberIds);
json.put("enterpriseId", enterpriseId);
json.put("imgJson", imgJson);
json.put("storeId", storeId);
json.put("staffId", staffId);
// 群发-分享
json.put("sendType", 2);
json.put("wxEnterpriseId", wxEnterpriseId);
String ret = json.toJSONString();
try {
GICMQClientUtil.getClientInstance().sendCommonMessage("haobanCommonRouter", ret,
"com.gic.haoban.app.customer.service.api.service.MessageLogApiService", "callBackSendMessage");
} catch (Exception e) {
logger.info(e.getMessage(), e);
}
return resultResponse(HaoBanErrCode.ERR_1);
}
// 朋友圈任务
@RequestMapping("/add_moment_task")
public HaobanResponse share(CustomerQO qo, String imgJson) {
String clerkId = qo.getClerkId();
String wxEnterpriseId = qo.getWxEnterpriseId();
String enterpriseId = qo.getEnterpriseId();
String staffId = qo.getStaffId();
List<String> clerkIdList = qo.getClerkIdList() ;
ClerkDTO clerk = this.clerkService.getclerkById(clerkId);
// 查询所有门店-导购
if(StringUtils.isNotBlank(qo.getChooseAll()) && "1".equals(qo.getChooseAll())) {
if (clerk.getClerkType() > 0) {
String storeId = clerk.getStoreId() ;
clerkIdList = staffApiService.listBindStaffId(storeId);
} else {
clerkIdList.add(clerkId);
}
}
JSONObject json = new JSONObject();
json.put("clerkIdList", clerkIdList);
json.put("enterpriseId", enterpriseId);
json.put("imgJson", imgJson);
json.put("staffId", staffId);
// 朋友圈-分享
json.put("sendType", 3);
json.put("wxEnterpriseId", wxEnterpriseId);
String ret = json.toJSONString();
try {
GICMQClientUtil.getClientInstance().sendCommonMessage("commonRouter", ret,
"com.gic.haoban.app.customer.service.api.service.MessageLogApiService", "callBackSendMessage");
} catch (Exception e) {
logger.info(e.getMessage(), e);
}
return resultResponse(HaoBanErrCode.ERR_1);
}
}
package com.gic.haoban.manage.web.qo;
import java.io.Serializable;
import java.util.List;
public class CustomerQO implements Serializable{
private static final long serialVersionUID = 1L;
private String chooseAll;
private String searchParams;
private String clerkId;
private String enterpriseId;
private String wxEnterpriseId ;
private String staffId;
private List<String> memberIdList ;
private List<String> clerkIdList ;
private String content ;
private boolean qwFriendFlag = false ;
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getStaffId() {
return staffId;
}
public List<String> getMemberIdList() {
return memberIdList;
}
public List<String> getClerkIdList() {
return clerkIdList;
}
public void setStaffId(String staffId) {
this.staffId = staffId;
}
public void setMemberIdList(List<String> memberIdList) {
this.memberIdList = memberIdList;
}
public void setClerkIdList(List<String> clerkIdList) {
this.clerkIdList = clerkIdList;
}
public String getChooseAll() {
return chooseAll;
}
public String getSearchParams() {
return searchParams;
}
public String getClerkId() {
return clerkId;
}
public String getEnterpriseId() {
return enterpriseId;
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public boolean isQwFriendFlag() {
return qwFriendFlag;
}
public void setChooseAll(String chooseAll) {
this.chooseAll = chooseAll;
}
public void setSearchParams(String searchParams) {
this.searchParams = searchParams;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public void setQwFriendFlag(boolean qwFriendFlag) {
this.qwFriendFlag = qwFriendFlag;
}
}
package com.gic.haoban.manage.web.utils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
@Component
public class ClerkUtils {
private static ClerkService clerkService;
@Autowired
public void setClerkService(ClerkService clerkService) {
ClerkUtils.clerkService = clerkService;
}
public static String getClerkStore(ClerkDTO clerk, String clerkId) {
if (null == clerk) {
clerk = clerkService.getclerkById(clerkId);
}
if (null == clerk) {
return null;
}
if (clerk.getClerkType() != 0 && clerk.getClerkType() != 1) {
return null;
}
return clerk.getStoreId();
}
public static String getClerkStore(ClerkDTO clerk , String clerkId , String selectedStoreId) {
String storeId = getClerkStore(clerk, clerkId) ;
if(StringUtils.isNotBlank(storeId)) {
selectedStoreId = storeId ;
}
return selectedStoreId ;
}
}
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