Commit 1d6635b7 by 徐高华

Merge branch 'master' into 'feature/计费中心-视频'

# Conflicts:
#   haoban-manage3-wx/src/main/webapp/WEB-INF/dubbo-haoban-manage-wx.xml
parents 0eb8eab5 e240e151
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;
// 1群发 2朋友圈
private int mediaType ;
public int getMediaType() {
return mediaType;
}
public void setMediaType(int mediaType) {
this.mediaType = mediaType;
}
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);
......
......@@ -4,6 +4,7 @@ import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.manage.api.dto.BatchAddMaterialDTO;
import com.gic.haoban.manage.api.dto.ContentMaterialDTO;
import com.gic.haoban.manage.api.dto.MaterialCategoryDTO;
import com.gic.haoban.manage.api.dto.MaterialDTO;
......@@ -75,5 +76,7 @@ public interface MaterialApiService {
* @author: YongEn
*/
void batchInsertMaterial(BatchAddMaterialDTO dto);
public com.gic.api.base.commons.ServiceResponse<String> getMaterialId(String wxEnterpriseId, ContentMaterialDTO dto) ;
}
......@@ -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);
/**
* 获取群发成员发送任务列表
......
......@@ -92,6 +92,8 @@ public interface StaffApiService {
void wxFristAdd(String userJson, String wxEnterpriseId);
List<String> listBindStaffId(String storeId);
List<String> listBindClerkId(String storeId);
List<StaffClerkRelationDTO> listBindRelationUserId(String storeId);
......
......@@ -81,6 +81,8 @@ public interface StaffClerkRelationApiService {
* @return
*/
List<StaffClerkRelationDTO> listByStoreId(String storeId);
List<StaffClerkRelationDTO> listByStoreIds(String wxEnterpriseId, List<String> storeIds) ;
/**
* 查询导购信息
......
......@@ -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 , @Param("mediaType")int mediaType);
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
package com.gic.haoban.manage.service.service;
import com.gic.api.base.commons.JSONResponse;
import com.gic.haoban.manage.api.dto.ContentMaterialDTO;
import com.gic.haoban.manage.api.dto.MaterialDTO;
import java.util.List;
......@@ -49,5 +51,11 @@ public interface MaterialService {
* @param ids
*/
void delmaterialByIds(List<String> ids);
public MaterialDTO getHasChangeMadieMaterialById(String materialId,int from) ;
public JSONResponse reUpdalodMetailJson(String materialId,int from) ;
public List<String> getImageMediaId(String wxEnterpriseId, List<ContentMaterialDTO> imageList, int mediaType) ;
}
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> sendMessageShare(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.ArrayList;
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.ContentMaterialDTO;
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.gic.weimob.common.Md5Util;
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 +111,150 @@ 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) {
JSONResponse jp = this.reUpdalodMetailJson(materialId, from) ;
if(null == jp) {
return "";
}
if (jp.getErrorCode() == 0) {
return jp.getResult().toString() ;
}
return "";
}
public JSONResponse reUpdalodMetailJson(String materialId,int from) {
JSONResponse jp = new JSONResponse() ;
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) ;
}
// 1群发 2朋友圈
from = entity.getMediaType() ;
}
Integer type = old.getMaterialType();
if (type == null) {
return jp;
}
String wxEnterpriseId = old.getWxEnterpriseId();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if (qwDTO == null) {
logger.info("qwDTO is null");
return jp;
}
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 jp;
}
if(from == 2) {
url = entity.getImgUrl() ;
}
String[] arr = url.split("/");
int count = arr.length;
if(from==2) {
// 朋友圈上传接口
if (type == 2) {
url+= "?imageView2/2/w/1440/h/1080" ;
}
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 jp;
}
public List<String> getImageMediaId(String wxEnterpriseId, List<ContentMaterialDTO> imageList, int mediaType) {
List<String> materialIdList = new ArrayList<>();
imageList.forEach(dto -> {
String imageUrl = dto.getImgUrl();
int type = dto.getMaterialType();
String md5 = Md5Util.MD5(imageUrl);
TabMaterialContent tab = this.materialContentMapper.selectByUrl(wxEnterpriseId, md5, mediaType);
if (null != tab) {
materialIdList.add(tab.getMaterialId());
} else {
String id = StringUtil.randomUUID();
tab = new TabMaterialContent();
tab.setMaterialId(id);
tab.setMaterialType(type);
tab.setImgUrl(imageUrl);
tab.setUrlMd5(md5);
tab.setMediaType(mediaType);
tab.setWxEnterpriseId(wxEnterpriseId);
this.materialContentMapper.insert(tab);
materialIdList.add(id);
}
});
return materialIdList;
}
}
package com.gic.haoban.manage.service.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
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.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.JSONResponse;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.haoban.manage.api.dto.ContentMaterialDTO;
import com.gic.haoban.manage.api.dto.MaterialDTO;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanStaffClerkRelationMapper;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.service.MaterialService;
import com.gic.haoban.manage.service.service.QywxSendService;
import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.wechat.api.dto.qywx.QywxExternalMessageDTO;
import com.gic.wechat.api.dto.qywx.QywxImageMaterialDTO;
import com.gic.wechat.api.dto.qywx.QywxLinkMaterialDTO;
import com.gic.wechat.api.dto.qywx.QywxMessageMaterialDTO;
import com.gic.wechat.api.dto.qywx.QywxMiniprogramMaterialDTO;
import com.gic.wechat.api.dto.qywx.QywxVideoMaterialDTO;
import com.gic.wechat.api.dto.qywx.moment.MomentTaskDTO;
import com.gic.wechat.api.dto.qywx.moment.SenderList;
import com.gic.wechat.api.dto.qywx.moment.Text;
import com.gic.wechat.api.dto.qywx.moment.VisibleRange;
import com.gic.wechat.api.enums.QywxMediaTypeEnum;
import com.gic.wechat.api.service.qywx.QywxExternalUserService;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
/**
*
* @ClassName: QywxSendApiServiceImpl
* @Description: 企业微信消息发送(群发、朋友圈)
* @author xugh
* @date 2022年11月8日 下午2:39:10
*
*/
@Service
public class QywxSendServiceImpl implements QywxSendService {
private static final Logger log = LogManager.getLogger(QywxSendServiceImpl.class);
@Autowired
private WxEnterpriseService wxEnterpriseService;
@Autowired
private MaterialService materialService;
@Autowired
private Config config;
@Autowired
private StaffService staffService;
@Autowired
private QywxSuiteApiService qywxSuiteApiService;
@Autowired
private QywxExternalUserService qywxExternalUserService;
@Autowired
private TabHaobanStaffClerkRelationMapper tabHaobanStaffClerkRelationMapper;
@Override
public ServiceResponse<String> sendMessage(String wxEnterpriseId, String staffId, List<String> extendUserList,
List<String> materialIdList) {
return this.send(wxEnterpriseId, staffId, extendUserList, materialIdList, null, 1);
}
@Override
public ServiceResponse<String> sendMessageShare(String wxEnterpriseId, String staffId, List<String> extendUserList,
List<ContentMaterialDTO> imageList, String message) {
List<String> materialIdList = this.materialService.getImageMediaId(wxEnterpriseId, imageList, 1);
return this.send(wxEnterpriseId, staffId, extendUserList, materialIdList, message, 2);
}
// 群发发送
private ServiceResponse<String> send(String wxEnterpriseId, String staffId, List<String> extendUserList,
List<String> materialIdList, String message, int from) {
TabHaobanStaff tabHaobanStaff = staffService.selectById(staffId);
if (null == tabHaobanStaff) {
log.info("staff不存在,staffId={}", staffId);
return ServiceResponse.failure("9999", "群发失败,成员不存在");
}
// 群发请求参数
QywxExternalMessageDTO messageDTO = this.getMessage(from, message, materialIdList);
log.info("群发信息={}",JSON.toJSONString(messageDTO));
if (messageDTO.getAttachments().isEmpty() && StringUtils.isBlank(messageDTO.getContent())) {
log.info("群发素材不存在, 群发创建失败");
return ServiceResponse.failure("9999", "群发素材不存在, 群发创建失败");
}
messageDTO.setExternalUserid(extendUserList);
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
if (qwDTO.needOpenUserId3th()) {
messageDTO.setSenderUserId(tabHaobanStaff.getWxOpenUseId());
} else {
messageDTO.setSenderUserId(tabHaobanStaff.getWxUserId());
}
// 调接口执行创建群发
JSONResponse respon = qywxSuiteApiService.sendExternalMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(),
messageDTO);
log.info("群发返回={}", JSON.toJSONString(respon));
Map<String, Object> returnMap = respon.getReturnMap();
String msgIdKey = "msgid";
String msgId = returnMap.get(msgIdKey) == null ? "" : returnMap.get(msgIdKey).toString();
if (StringUtils.isNotEmpty(msgId)) {
return ServiceResponse.success(msgId);
}
String error = respon.getErrorMessage();
return ServiceResponse.failure("9999", error);
}
// 分享朋友圈
@Override
public ServiceResponse<String> share(String wxEnterpriseId, List<String> clerkIdList, String message,
List<ContentMaterialDTO> imageList) {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
List<String> materialIdList = this.materialService.getImageMediaId(wxEnterpriseId, imageList, 2);
QywxExternalMessageDTO dto = this.getMessage(2, message, materialIdList);
MomentTaskDTO moment = EntityUtil.changeEntity(MomentTaskDTO.class, dto);
Text text = new Text();
text.setContent(dto.getContent());
moment.setText(text);
List<String> sendUser = new ArrayList<>();
if (CollectionUtils.isEmpty(clerkIdList)) {
return ServiceResponse.failure("9999", "无导购");
}
List<StaffClerkRelationDTO> clerkList = this.tabHaobanStaffClerkRelationMapper.listByClerkIds(clerkIdList,
wxEnterpriseId);
if (CollectionUtils.isEmpty(clerkList)) {
log.info("无发送成员");
return ServiceResponse.failure("9999", "无发送成员");
}
for (StaffClerkRelationDTO item : clerkList) {
if (qwDTO.needOpenUserId3th()) {
sendUser.add(item.getOpenUserId());
} else {
sendUser.add(item.getQwUserId());
}
}
SenderList senderList = new SenderList();
senderList.setUser_list(sendUser);
VisibleRange range = new VisibleRange();
range.setSender_list(senderList);
moment.setVisible_range(range);
ServiceResponse<String> resp = this.qywxExternalUserService.addMomentTask(qwDTO.getThirdCorpid(),
config.getWxSuiteid(), moment);
log.info("朋友圈消息={},返回={}", JSON.toJSONString(moment), JSON.toJSONString(resp));
return resp;
}
// from 1好办素材 2内容中台
private QywxExternalMessageDTO getMessage(int from, String message, List<String> materialIdList) {
QywxExternalMessageDTO messageDTO = new QywxExternalMessageDTO();
messageDTO.setChatType("single");
List<QywxMessageMaterialDTO> attachList = new ArrayList<>();
if (from == 2) {
if (StringUtils.isNotBlank(message)) {
messageDTO.setContent(message);
}
}
if (CollectionUtils.isNotEmpty(materialIdList)) {
materialIdList.forEach(materialId -> {
MaterialDTO material = materialService.getHasChangeMadieMaterialById(materialId, from);
log.info("JSON={}", JSON.toJSONString(material));
if (material == null) {
return;
}
if (material.getMaterialType() == 1) {
messageDTO.setContent(material.getMaterialContent());
} else {
attachList.add(this.getMessageMaterial(material));
}
});
}
messageDTO.setAttachments(attachList);
return messageDTO;
}
/**
* 素材发送对象构造
*/
private QywxMessageMaterialDTO getMessageMaterial(MaterialDTO material) {
// 素材类型
Integer materialType = material.getMaterialType();
// 企微对应的id
String maerialId = material.getMediaId();
// 素材对象
QywxMessageMaterialDTO dto = new QywxMessageMaterialDTO();
if (materialType == 2) {
QywxImageMaterialDTO imageMaterialDTO = new QywxImageMaterialDTO();
imageMaterialDTO.setMediaId(maerialId);
dto.setMsgType(QywxMediaTypeEnum.IMAGE.getName());
dto.setImage(imageMaterialDTO);
} else if (materialType == 3) {
QywxLinkMaterialDTO linkMaterialDTO = new QywxLinkMaterialDTO();
linkMaterialDTO.setTitle(material.getMaterialTitle());
linkMaterialDTO.setPicUrl(material.getWxImgUrl());
linkMaterialDTO.setDesc(material.getMaterialDesc());
linkMaterialDTO.setUrl(material.getLink());
dto.setMsgType(QywxMediaTypeEnum.LINK.getName());
dto.setLink(linkMaterialDTO);
} else if (materialType == 4) {
QywxVideoMaterialDTO videoMaterialDTO = new QywxVideoMaterialDTO();
videoMaterialDTO.setMediaId(maerialId);
dto.setMsgType(QywxMediaTypeEnum.VIDEO.getName());
dto.setVideo(videoMaterialDTO);
} else if (materialType == 6) {
QywxMiniprogramMaterialDTO miniprogramMaterialDTO = new QywxMiniprogramMaterialDTO();
miniprogramMaterialDTO.setTitle(material.getMaterialTitle());
miniprogramMaterialDTO.setPicMediaId(maerialId);
miniprogramMaterialDTO.setAppid(material.getAppId());
miniprogramMaterialDTO.setPage(material.getLink());
dto.setMsgType(QywxMediaTypeEnum.MINIPROGRAM.getName());
dto.setMiniprogram(miniprogramMaterialDTO);
}
return dto;
}
}
......@@ -25,13 +25,15 @@ import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.BatchAddMaterialDTO;
import com.gic.haoban.manage.api.dto.ContentMaterialDTO;
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;
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.entity.TabMiniprogramSetting;
import com.gic.haoban.manage.service.service.MaterialCategoryService;
import com.gic.haoban.manage.service.service.MaterialService;
......@@ -62,6 +64,8 @@ public class MaterialApiServiceImpl implements MaterialApiService {
@Autowired
private MiniprogramSettingService miniprogramSettingService;
@Autowired
private TabMaterialContentMapper materialContentMapper ;
private static Logger logger = LoggerFactory.getLogger(MaterialApiServiceImpl.class);
......@@ -445,4 +449,34 @@ public class MaterialApiServiceImpl implements MaterialApiService {
}
return null;
}
public com.gic.api.base.commons.ServiceResponse<String> getMaterialId(String wxEnterpriseId, ContentMaterialDTO dto) {
List<ContentMaterialDTO> imageList = Arrays.asList(dto) ;
List<String> materialIdList = this.materialService.getImageMediaId(wxEnterpriseId, imageList, dto.getMediaType());
if (CollectionUtils.isEmpty(materialIdList)) {
com.gic.api.base.commons.ServiceResponse.failure("9999", "素材记录不存") ;
}
String materialId = materialIdList.get(0) ;
TabMaterialContent entity = this.materialContentMapper.selectById(materialId) ;
if(null == entity) {
com.gic.api.base.commons.ServiceResponse.failure("9999", "素材记录不存") ;
}
Date lastUploadTime = entity.getWxLastUploadTime();
Date date = new Date();
Date compareDate = DateUtils.addDays(date, -3);
String madiaId= entity.getMediaId() ;
if (lastUploadTime != null && lastUploadTime.after(compareDate) && StringUtils.isNotBlank(madiaId)) {
return com.gic.api.base.commons.ServiceResponse.success(madiaId) ;
}
JSONResponse json = this.materialService.reUpdalodMetailJson(materialId,2) ;
if (json.getErrorCode() == 0) {
madiaId= json.getResult().toString() ;
return com.gic.api.base.commons.ServiceResponse.success(madiaId) ;
}else {
return com.gic.api.base.commons.ServiceResponse.failure("9999",json.getErrorMessage()) ;
}
}
}
......@@ -631,6 +631,15 @@ public class StaffApiServiceImpl implements StaffApiService {
@Override
public List<String> listBindStaffId(String storeId) {
return this.listBind(storeId, 1) ;
}
@Override
public List<String> listBindClerkId(String storeId) {
return this.listBind(storeId, 2) ;
}
private List<String> listBind(String storeId , int type) {
List<String> userIdList = new ArrayList<String>();
List<String> storeIds = new ArrayList<String>();
storeIds.add(storeId);
......@@ -639,15 +648,21 @@ public class StaffApiServiceImpl implements StaffApiService {
if (CollectionUtils.isEmpty(staffRelationList)) {
return Collections.EMPTY_LIST;
}
Map<String, StaffClerkRelationDTO> clerkIdMap = staffRelationList.stream().filter(s -> s.getClerkId() != null).collect(Collectors.toMap(StaffClerkRelationDTO::getClerkId, s -> s));
Set<String> keySet = clerkIdMap.keySet();
for (String clerkId : clerkList) {
if (keySet.contains(clerkId)) {
userIdList.add(clerkIdMap.get(clerkId).getStaffId());
if(type==1) {
Map<String, StaffClerkRelationDTO> clerkIdMap = staffRelationList.stream().filter(s -> s.getClerkId() != null).collect(Collectors.toMap(StaffClerkRelationDTO::getClerkId, s -> s));
Set<String> keySet = clerkIdMap.keySet();
for (String clerkId : clerkList) {
if (keySet.contains(clerkId)) {
userIdList.add(clerkIdMap.get(clerkId).getStaffId());
}
}
}
if(type==2) {
userIdList = staffRelationList.stream().filter(s -> s.getClerkId() != null).map(dto->dto.getClerkId()).collect(Collectors.toList());
}
return userIdList;
}
@Override
public List<StaffClerkRelationDTO> listBindRelationUserId(String storeId) {
......
......@@ -248,6 +248,11 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
public List<StaffClerkRelationDTO> listByStoreId(String storeId) {
return tabHaobanStaffClerkRelationMapper.listByStoreIds(null,Arrays.asList(storeId));
}
@Override
public List<StaffClerkRelationDTO> listByStoreIds(String wxEnterpriseId, List<String> storeIds) {
return tabHaobanStaffClerkRelationMapper.listByStoreIds(wxEnterpriseId,storeIds);
}
@Override
public boolean unbindByStaffAndClerkId(String staffId, String clerkId, int channelCode,String wxEnterpriseId) {
......
......@@ -272,7 +272,8 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
List<TabHaobanWxEnterpriseRelated> list = this.wxEnterpriseRelatedMapper.listByWxenterpriseId(wxEnterpriseId);
if (CollectionUtils.isEmpty(list)) {
log.info("企微无关联gic商户,wxEnterpriseId={}",wxEnterpriseId);
return ServiceResponse.failure("1000", "无关联商户");
//return ServiceResponse.failure("1000", "无关联商户");
return ServiceResponse.success() ;
}
int count = list.size();
log.info("企微关联数={},{}", count, JSON.toJSONString(list));
......
<?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 media_type = #{mediaType} 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
......
......@@ -329,7 +329,7 @@
</if>
<if test="type==2">
and b.wx_open_user_id in
<foreach collection="wxOpenUserIds" item="id" index="index" open="(" close=")" separator=",">
<foreach collection="wxUserIds" item="id" index="index" open="(" close=")" separator=",">
#{id,jdbcType=VARCHAR}
</foreach>
</if>
......
......@@ -78,21 +78,6 @@
<version>2.6.12</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>haoban-data-api</artifactId>
<version>${haoban-data-api}</version>
......@@ -219,6 +204,17 @@
<artifactId>gic-integral-mall-api</artifactId>
<version>${gic-integral-mall-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-content-api</artifactId>
<version>${gic-content-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>haoban-app-aggregation-api</artifactId>
<version>${haoban-app-aggregation-api}</version>
</dependency>
</dependencies>
<build>
......
......@@ -159,14 +159,16 @@ public class StoreController extends WebBaseController {
}
List<String> storeIdList = list.stream().map(dto -> dto.getStoreId()).collect(Collectors.toList());
// 处理主门店
ClerkMainStoreRelatedDTO mainDTO = clerkMainStoreRelatedApiService.getWxEnterpriseIdAndStaffId(wxEnterpriseId, staffId, storeIdList);
String mainStoreId = mainDTO == null ? "" : mainDTO.getStoreId();
if (null != mainStoreId) {
list.forEach(item -> {
if (item.getStoreId().equals(mainStoreId)) {
item.setMainStoreFlag(1);
}
});
if(StringUtils.isBlank(gicEnterpriseId)) {
ClerkMainStoreRelatedDTO mainDTO = clerkMainStoreRelatedApiService.getWxEnterpriseIdAndStaffId(wxEnterpriseId, staffId, storeIdList);
String mainStoreId = mainDTO == null ? "" : mainDTO.getStoreId();
if (null != mainStoreId) {
list.forEach(item -> {
if (item.getStoreId().equals(mainStoreId)) {
item.setMainStoreFlag(1);
}
});
}
}
return resultResponse(HaoBanErrCode.ERR_1, list);
}
......
package com.gic.haoban.manage.web.controller;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import com.gic.commons.util.GlobalInfo;
import com.gic.commons.util.GlobalVar;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.haoban.common.anno.IgnoreLogin;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.thirdparty.api.dto.PicUploadResDTO;
import com.gic.thirdparty.api.service.QQCloudPicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.util.*;
import com.gic.thirdparty.cloudfile.CloudFileUtil;
import com.gic.thirdparty.cloudfile.enums.CloudFileBusinessOptEnum;
import com.gic.thirdparty.cloudfile.enums.CloudFileTypeEnum;
import com.gic.thirdparty.cloudfile.pojo.CloudFileInfo;
import com.gic.thirdparty.cloudfile.pojo.ImageCloudFileInfo;
@RestController
public class UploadController extends WebBaseController {
private static org.apache.logging.log4j.Logger logger = LogManager.getLogger(UploadController.class);
@Autowired
private QQCloudPicService qqCloudPicService;
@Autowired
private EnterpriseService enterpriseService ;
@RequestMapping("upload-img")
......@@ -56,5 +75,67 @@ public class UploadController extends WebBaseController {
}
return resultResponse(HaoBanErrCode.ERR_1, picList);
}
// fileType image:图片 video:视频 file:文件 audio音频 other:其它
@RequestMapping("upload-img-fee")
public RestResponse<Object> imgUploadFee(HttpServletRequest request , String fileType , String enterpriseId) throws Exception {
if(StringUtils.isEmpty(enterpriseId)) {
return RestResponse.failure("9999", "企业未传") ;
}
EnterpriseDTO enterprise = this.enterpriseService.getEnterpriseById(enterpriseId) ;
if(null == enterprise) {
return RestResponse.failure("9999", "商户不存在") ;
}
String factoryCode = enterprise.getFactoryCode() ;
MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
Iterator<String> iter = multiRequest.getFileNames();
java.util.List<Map<String, Object>> picList = new ArrayList<>();
while (iter.hasNext()) {
String fileName = iter.next();
List<MultipartFile> list = multiRequest.getMultiFileMap().get(fileName);
Map<String, Object> map = null;
for (int i = 0; i < list.size(); i++) {
map = new HashMap<>();
MultipartFile mf = list.get(i);
CloudFileTypeEnum type = getType(fileType) ;
File file = File.createTempFile("tmp", null);
mf.transferTo(file);
try {
String name = mf.getOriginalFilename() ;
if(name.contains(".")) {
name = name.substring(name.lastIndexOf(".")+1) ;
}
CloudFileInfo uploadInfo = CloudFileUtil.uploadTempFile(file, name, type, factoryCode , CloudFileBusinessOptEnum.COMMON, 7*24L) ;
if (uploadInfo != null) {
map.put("qcloudImageUrl", uploadInfo.getOrgFileUrl());
map.put("imageFiledCode", "imageFiledCode");
if(uploadInfo instanceof ImageCloudFileInfo) {
ImageCloudFileInfo info = (ImageCloudFileInfo) uploadInfo ;
map.put("compressFileUrl", info.getCompressFileUrl());
}
}
}catch(Exception e) {
return RestResponse.failure("9999", e.getMessage()) ;
}
picList.add(map);
file.deleteOnExit();
}
}
return RestResponse.successResult(picList);
}
private CloudFileTypeEnum getType(String fileType) {
if(StringUtils.isBlank(fileType)) {
return CloudFileTypeEnum.IMAGE ;
}
CloudFileTypeEnum[] arr = CloudFileTypeEnum.values() ;
for(int i=0;i<arr.length;i++) {
if(arr[i].getType().equals(fileType)) {
return arr[i];
}
}
return CloudFileTypeEnum.IMAGE ;
}
}
......@@ -32,7 +32,6 @@ 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.dto.ClerkListDTO;
import com.gic.clerk.api.dto.ClerkStoreListDTO;
import com.gic.clerk.api.service.ClerkNewService;
import com.gic.clerk.api.service.ClerkService;
import com.gic.clerk.api.service.PowerService;
......@@ -45,7 +44,6 @@ import com.gic.enterprise.api.dto.StoreSearchDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.enterprise.api.service.StoreService;
import com.gic.enterprise.api.service.StoreWidgetService;
import com.gic.haoban.app.customer.dto.ChildrenListDTO;
import com.gic.haoban.app.customer.service.api.service.CustomerApiService;
import com.gic.haoban.app.customer.service.api.service.DistributeApiService;
import com.gic.haoban.base.api.common.BasePageInfo;
......@@ -1591,14 +1589,16 @@ public class WxStaffController extends WebBaseController {
}
List<String> storeIdList = list.stream().map(dto -> dto.getStoreId()).collect(Collectors.toList());
// 处理主门店
ClerkMainStoreRelatedDTO mainDTO = clerkMainStoreRelatedApiService.getWxEnterpriseIdAndStaffId(wxEnterpriseId, staffId, storeIdList);
String mainStoreId = mainDTO == null ? "" : mainDTO.getStoreId();
if (null != mainStoreId) {
list.forEach(item -> {
if (item.getStoreId().equals(mainStoreId)) {
item.setMainStoreFlag(1);
}
});
if(StringUtils.isBlank(gicEnterpriseId)) {
ClerkMainStoreRelatedDTO mainDTO = clerkMainStoreRelatedApiService.getWxEnterpriseIdAndStaffId(wxEnterpriseId, staffId, storeIdList);
String mainStoreId = mainDTO == null ? "" : mainDTO.getStoreId();
if (null != mainStoreId) {
list.forEach(item -> {
if (item.getStoreId().equals(mainStoreId)) {
item.setMainStoreFlag(1);
}
});
}
}
return RestResponse.successResult(list);
}
......@@ -1619,7 +1619,7 @@ public class WxStaffController extends WebBaseController {
// 区经门店列表
@RequestMapping("/list-clerk-store")
public RestResponse<Object> listClerkStore(String wxEnterpriseId , String enterpriseId,String clerkId, @RequestParam(defaultValue="20")int pageSize , @RequestParam(defaultValue="1")int currentPage) {
public RestResponse<Object> listClerkStore(String wxEnterpriseId , String enterpriseId,String clerkId, @RequestParam(defaultValue="20")int pageSize , @RequestParam(defaultValue="1")int currentPage , String storeSearchParams) {
List<String> storeIdList = this.staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId, wxEnterpriseId) ;
if (CollectionUtils.isEmpty(storeIdList)) {
return RestResponse.failure("-1", "无授权门店");
......@@ -1676,17 +1676,29 @@ public class WxStaffController extends WebBaseController {
return RestResponse.successResult(page);
}
//区经门店查询
@RequestMapping("search-clerk-store")
public RestResponse<Object> listClerkStoreByParams(String wxEnterpriseId, String enterpriseId, String clerkId, String storeSearchParams) {
if(StringUtils.isEmpty(storeSearchParams)) {
return RestResponse.failure("-1", "查询条件为空") ;
}
@RequestMapping("/search-clerk-store-page")
public RestResponse<Object> listClerkStorePage(String wxEnterpriseId , String enterpriseId,String clerkId, @RequestParam(defaultValue="20")int pageSize , @RequestParam(defaultValue="1")int currentPage , String storeSearchParams) {
// 如果有权限控制,进行管辖门店过0滤
List<String> authStoreIdList = this.staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId, wxEnterpriseId);
if (CollectionUtils.isEmpty(authStoreIdList)) {
return RestResponse.failure("-1", "无授权门店");
}
Page page = this.page(wxEnterpriseId, enterpriseId, clerkId, pageSize, currentPage, storeSearchParams, authStoreIdList) ;
List<StoreDTO> storeList = (List<StoreDTO>) page.getResult();
List<StoreListVO> retList = this.toList(storeList) ;
Page<StoreListVO> retPage = new Page<>();
retPage.setResult(retList);
retPage.setTotalCount(page.getTotalCount());
retPage.setCurrentPage(currentPage);
retPage.setPageSize(pageSize);
return RestResponse.successResult(retPage);
}
private Page page(String wxEnterpriseId , String enterpriseId,String clerkId, @RequestParam(defaultValue="20")int pageSize , @RequestParam(defaultValue="1")int currentPage , String storeSearchParams , List<String> authStoreIdList) {
StoreSearchDTO searchDTO = new StoreSearchDTO();
searchDTO.setRecycleStoreCount(0);
searchDTO.setMemberCountFlag(0);
......@@ -1698,24 +1710,44 @@ public class WxStaffController extends WebBaseController {
}
// 门店参数
Page page = new Page();
page.setPageSize(20);
page.setCurrentPage(1);
page.setPageSize(pageSize);
page.setCurrentPage(currentPage);
Map<String, Object> params = new HashMap<>();
params.put("searchDto", searchDTO);
page.setParams(params);
logger.info("查询条件={}", JSON.toJSONString(page));
Map<String, Object> result = storeService.getStoreListPage(page);
page = (Page) result.get("page");
List<StoreDTO> storeList = (List<StoreDTO>) result.get("list");
return page ;
}
private List<StoreListVO> toList(List<StoreDTO> storeList){
List<StoreListVO> retList = new ArrayList<StoreListVO>();
StoreListVO vo = null;
for (StoreDTO dto : storeList) {
vo = new StoreListVO();
vo.setStoreId(dto.getStoreId());
vo.setStoreName(dto.getStoreName());
vo.setStoreCode(dto.getStoreCode());
retList.add(vo);
}
return RestResponse.successResult(retList);
return retList ;
}
//区经门店查询
@RequestMapping("search-clerk-store")
public RestResponse<Object> listClerkStoreByParams(String wxEnterpriseId, String enterpriseId, String clerkId, String storeSearchParams) {
if(StringUtils.isEmpty(storeSearchParams)) {
return RestResponse.failure("-1", "查询条件为空") ;
}
// 如果有权限控制,进行管辖门店过0滤
List<String> authStoreIdList = this.staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId, wxEnterpriseId);
if (CollectionUtils.isEmpty(authStoreIdList)) {
return RestResponse.failure("-1", "无授权门店");
}
Page page = this.page(wxEnterpriseId, enterpriseId, clerkId, 20, 1, storeSearchParams, authStoreIdList) ;
List<StoreDTO> storeList = (List<StoreDTO>) page.getResult();
return RestResponse.successResult(toList(storeList));
}
/**
......@@ -1726,43 +1758,22 @@ public class WxStaffController extends WebBaseController {
ClerkDTO clerk = this.clerkService.getclerkById(clerkId) ;
int clerkType = clerk.getClerkType() ;
List<ClerkListVO> resultList = null ;
if(clerkType==0) {
return RestResponse.failure("-1", "无权访问");
}else if(clerkType==1) {
List<ClerkListDTO> clerkList = clerkService.getClerkByStoreId(enterpriseId, clerk.getStoreId());
if (CollectionUtils.isNotEmpty(clerkList) && StringUtils.isNotEmpty(clerkSearchParams)) {
clerkList = clerkList.stream().filter(dto->dto.getClerkCode().contains(clerkSearchParams) || dto.getClerkName().contains(clerkSearchParams)).collect(Collectors.toList()) ;
}
if (CollectionUtils.isEmpty(clerkList)) {
return RestResponse.failure("-1", "无导购");
}
resultList = EntityUtil.changeEntityListByJSON(ClerkListVO.class, clerkList);
}else if(clerkType==2) {
Map<String, Object> params = new HashMap<>();
params.put("enterpriseId", enterpriseId);
// 只获取导购和店长
params.put("clerkTypeList", Arrays.asList(1));
if (StringUtils.isNotBlank(clerkSearchParams)) {
params.put("clerkSearchParams", "%" + clerkSearchParams + "%");
}
// 如果有权限控制,进行管辖门店过0滤
List<String> authStoreIdList = this.staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId,wxEnterpriseId);
if (CollectionUtils.isEmpty(authStoreIdList)) {
return RestResponse.failure("-1", "无授权门店");
}
if (!(authStoreIdList.size() == 1 && authStoreIdList.contains("-1"))) {
params.put("storeIdList", authStoreIdList);
}
Page<ClerkStoreListDTO> page = new Page<>();
page.setPageSize(basePageInfo.getPageSize());
page.setCurrentPage(basePageInfo.getPageNum());
page.setParams(params);
logger.info("查询条件:{}", JSON.toJSONString(params));
page = this.clerkService.listStoreClerkByPage(page);
resultList = EntityUtil.changeEntityListByJSON(ClerkListVO.class, page.getResult());
if(clerkType != 1) {
return RestResponse.failure("-1", "非店长身份");
}
List<ClerkListDTO> clerkList = clerkService.getClerkByStoreId(enterpriseId, clerk.getStoreId());
if (CollectionUtils.isNotEmpty(clerkList) && StringUtils.isNotEmpty(clerkSearchParams)) {
clerkList = clerkList.stream().filter(dto->dto.getClerkCode().contains(clerkSearchParams) || dto.getClerkName().contains(clerkSearchParams)).collect(Collectors.toList()) ;
}
if (CollectionUtils.isEmpty(clerkList)) {
return RestResponse.failure("-1", "无导购");
}
resultList = EntityUtil.changeEntityListByJSON(ClerkListVO.class, clerkList);
List<String> clerkIdList = resultList.stream().map(dto->dto.getClerkId()).collect(Collectors.toList()) ;
List<StaffClerkRelationDTO> relationList = this.staffClerkRelationApiService.listByClerkIdsWxEnterpriseId(clerkIdList, wxEnterpriseId) ;
if(CollectionUtils.isEmpty(relationList)) {
return RestResponse.failure("-1", "无导购");
}
List<String> retlationIdList = relationList.stream().map(dto->dto.getClerkId()).collect(Collectors.toList()) ;
resultList.removeIf(item->{
return !retlationIdList.contains(item.getClerkId()) ;
......
package com.gic.haoban.manage.web.controller.content;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.content.api.dto.column.ContentColumnListDTO;
import com.gic.content.api.dto.material.ContentMaterialFrontDTO;
import com.gic.content.api.dto.material.ContentMaterialShareInfoDTO;
import com.gic.content.api.enums.ColumnEnum;
import com.gic.content.api.qdto.material.ContentMaterialPageFrontQDTO;
import com.gic.content.api.qdto.material.ContentMaterialShareQDTO;
import com.gic.content.api.service.ContentColumnApiService;
import com.gic.content.api.service.ContentMaterialApiService;
import com.gic.content.api.service.ContentMaterialShareApiService;
import com.gic.haoban.app.aggregation.api.dto.GoodsSettingDTO;
import com.gic.haoban.app.aggregation.api.service.SettingApiService;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.web.qo.content.ContentMaterialQO;
import com.gic.haoban.manage.web.qo.content.ContentMaterialShareQO;
import com.gic.haoban.manage.web.vo.content.ContentColumnInfoVO;
import com.gic.haoban.manage.web.vo.content.ContentMaterialInfoVO;
import com.gic.haoban.manage.web.vo.content.ContentMaterialShareInfoVO;
import com.gic.haoban.manage.web.vo.content.SimpleGoodsInfoVO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author MUSI
* @Date 2022/11/14 6:06 PM
* @Description
* @Version
**/
@RestController
public class ContentMaterialController {
private static final Logger log = LoggerFactory.getLogger(ContentMaterialController.class);
@Autowired
private ContentColumnApiService contentColumnApiService;
@Autowired
private ContentMaterialApiService contentMaterialApiService;
@Autowired
private ContentMaterialShareApiService contentMaterialShareApiService;
@Autowired
private StaffApiService staffApiService;
@Autowired
private SettingApiService settingApiService;
/**
* 获取栏目筛选条件
* @param enterpriseId
* @return
*/
@RequestMapping(path = "/column-list")
public RestResponse<List<ContentColumnInfoVO>> queryContentColumn(String enterpriseId,String storeId,String wxEnterpriseId,String clerkId){
List<String> storeIdList = new ArrayList<>();
if (StringUtils.isBlank(storeId)){
// 区经 获取管辖的权限
List<String> storeIds = this.queryClerkStoreIds(clerkId, wxEnterpriseId);
storeIdList.addAll(storeIds);
}else {
storeIdList.add(storeId);
}
ServiceResponse<List<ContentColumnListDTO>> serviceResponse = contentColumnApiService.listColumnFront(enterpriseId, ColumnEnum.MATERIAL.value, storeIdList);
if (!serviceResponse.isSuccess() || CollectionUtils.isEmpty(serviceResponse.getResult())){
return RestResponse.successResult(Collections.emptyList());
}
List<ContentColumnInfoVO> contentColumnInfos = EntityUtil.changeEntityListByJSON(ContentColumnInfoVO.class, serviceResponse.getResult());
return RestResponse.successResult(contentColumnInfos);
}
/**
*
* 素材列表
*
* @return
*/
@RequestMapping(path = "/content-material-list")
public RestResponse<Page<ContentMaterialInfoVO>> queryContentMaterialList(@RequestBody ContentMaterialQO contentMaterialQO){
if (StringUtils.isBlank(contentMaterialQO.getEnterpriseId())){
log.info("企业id未传 {}", JSON.toJSONString(contentMaterialQO));
return RestResponse.failure("-777", "参数异常");
}
List<Integer> goodsShowStatus = this.getGoodsShowStatus(contentMaterialQO);
ContentMaterialPageFrontQDTO contentMaterialPageFrontQDTO = new ContentMaterialPageFrontQDTO();
contentMaterialPageFrontQDTO.setEnterpriseId(contentMaterialQO.getEnterpriseId());
contentMaterialPageFrontQDTO.setKeyWord(contentMaterialQO.getSearch());
contentMaterialPageFrontQDTO.setContentColumnId(contentMaterialQO.getContentColumnId());
contentMaterialPageFrontQDTO.setMaterialType(contentMaterialQO.getMaterialType());
if (contentMaterialQO.getSortType() != null){
if (contentMaterialQO.getSortType() == 2){
contentMaterialPageFrontQDTO.setHotFlag(1);
}
}
if (StringUtils.isBlank(contentMaterialQO.getStoreId())){
// 区经 获取管辖的权限
List<String> storeIds = this.queryClerkStoreIds(contentMaterialQO.getClerkId(), contentMaterialQO.getWxEnterpriseId());
contentMaterialPageFrontQDTO.setStoreIdList(storeIds);
}else {
contentMaterialPageFrontQDTO.setStoreIdList(Collections.singletonList(contentMaterialQO.getStoreId()));
}
BasePageInfo pageInfo = new BasePageInfo();
pageInfo.setPageNum(contentMaterialQO.getPageNum());
pageInfo.setPageSize(contentMaterialQO.getPageSize());
ServiceResponse<Page<ContentMaterialFrontDTO>> serviceResponse = contentMaterialApiService.pageMaterialFront(contentMaterialPageFrontQDTO, pageInfo);
if (!serviceResponse.isSuccess() || CollectionUtils.isEmpty(serviceResponse.getResult().getResult())){
return RestResponse.successResult(new Page<>());
}
Page<ContentMaterialFrontDTO> responseResult = serviceResponse.getResult();
Page<ContentMaterialInfoVO> result = new Page<>();
result.setTotalCount(responseResult.getTotalCount());
List<ContentMaterialInfoVO> contentMaterialInfos = responseResult.getResult().stream()
.map(item -> {
ContentMaterialInfoVO contentMaterialInfoVO = new ContentMaterialInfoVO();
BeanUtils.copyProperties(item, contentMaterialInfoVO);
if (CollectionUtils.isNotEmpty(item.getContentGoodsList())){
List<SimpleGoodsInfoVO> goodsInfoVOS = item.getContentGoodsList()
.stream()
.filter(temp -> goodsShowStatus.contains(temp.getStatus()))
.map(temp -> {
SimpleGoodsInfoVO simpleGoodsInfoVO = new SimpleGoodsInfoVO();
BeanUtils.copyProperties(temp, simpleGoodsInfoVO);
simpleGoodsInfoVO.setGoodsImg(temp.getGoodsImageUrl());
return simpleGoodsInfoVO;
}).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(goodsInfoVOS)) {
contentMaterialInfoVO.setContentGoodsList(goodsInfoVOS);
}
}
contentMaterialInfoVO.setPublishTime(item.getPublishBeginTime());
if (StringUtils.isNotBlank(item.getMaterialImageUrls())) {
String[] split = StringUtils.split(item.getMaterialImageUrls(), ",");
List<String> imageUrls = Arrays.stream(split).collect(Collectors.toList());
contentMaterialInfoVO.setMaterialImageUrls(imageUrls);
}
if (StringUtils.isNotBlank(item.getMaterialThumbnailImageUrls())) {
String[] split = StringUtils.split(item.getMaterialThumbnailImageUrls(), ",");
List<String> imageUrls = Arrays.stream(split).collect(Collectors.toList());
contentMaterialInfoVO.setMaterialThumbnailImageUrls(imageUrls);
}
return contentMaterialInfoVO;
}).collect(Collectors.toList());
result.setResult(contentMaterialInfos);
result.setCurrentPage(contentMaterialQO.getPageNum());
result.setPageSize(contentMaterialQO.getPageSize());
return RestResponse.successResult(result);
}
private List<Integer> getGoodsShowStatus(ContentMaterialQO contentMaterialQO) {
GoodsSettingDTO goodsSettingDTO = settingApiService.getSetting(contentMaterialQO.getEnterpriseId());
List<Integer> showStatus = new ArrayList<>();
if (goodsSettingDTO != null){
int salesGoodsFlag = goodsSettingDTO.getSalesGoodsFlag();
int notSalesGoodsFlag = goodsSettingDTO.getNotSalesGoodsFlag();
if (salesGoodsFlag == 1 && notSalesGoodsFlag == 1) {
//已上架和未上架
showStatus.add(1);
showStatus.add(2);
} else if (salesGoodsFlag == 1) {
//已上架
showStatus.add(1);
} else if (notSalesGoodsFlag == 1) {
//未上架
showStatus.add(2);
} else {
//啥都未打开
showStatus.add(-99);
}
}else {
// 默认展示已上架和未上架的数据
showStatus.add(1);
showStatus.add(2);
}
return showStatus;
}
/**
* 分享商品素材
* @param contentMaterialShareQO
* @return
*/
@RequestMapping(path = "/share-content-material")
public RestResponse<ContentMaterialShareInfoVO> shareContentMaterial(ContentMaterialShareQO contentMaterialShareQO){
if (StringUtils.isBlank(contentMaterialShareQO.getEnterpriseId())){
return RestResponse.failure("-777", "企业参数异常");
}
if (StringUtils.isBlank(contentMaterialShareQO.getGoodsId())){
// 无商品id 不生成参数
return RestResponse.successResult();
}
ContentMaterialShareQDTO contentMaterialShareQDTO = new ContentMaterialShareQDTO();
contentMaterialShareQDTO.setEnterpriseId(contentMaterialShareQO.getEnterpriseId());
contentMaterialShareQDTO.setGoodsId(contentMaterialShareQO.getGoodsId());
contentMaterialShareQDTO.setContentMaterialId(contentMaterialShareQO.getContentMaterialId());
contentMaterialShareQDTO.setClerkId(contentMaterialShareQO.getClerkId());
contentMaterialShareQDTO.setStoreId(contentMaterialShareQO.getStoreId());
ServiceResponse<ContentMaterialShareInfoDTO> serviceResponse = contentMaterialShareApiService.shareContentMaterial(contentMaterialShareQDTO);
if (!serviceResponse.isSuccess()){
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
ContentMaterialShareInfoVO shareInfoVO = new ContentMaterialShareInfoVO();
BeanUtils.copyProperties(serviceResponse.getResult(), shareInfoVO);
return RestResponse.successResult(shareInfoVO);
}
/**
* 查询区经角色下管辖的门店权限
* @param clerkId
* @param wxEnterpriseId
* @return
*/
public List<String> queryClerkStoreIds(String clerkId, String wxEnterpriseId){
List<String> storeIds = staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId, wxEnterpriseId);
if (CollectionUtils.isEmpty(storeIds)){
log.info("根据区经id查询管辖的门店为空 {} {}", clerkId, wxEnterpriseId);
return Collections.singletonList("-100");
}
if (storeIds.size() == 1 && StringUtils.equals(storeIds.get(0), "-1")){
// 全部门店权限
log.info("区经有全部门店权限 {}", clerkId);
return Collections.emptyList();
}
return storeIds;
}
}
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
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.GICMQClientUtil;
import com.gic.commons.webapi.reponse.RestResponse;
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.manage.api.dto.ContentMaterialDTO;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.service.MaterialApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.web.controller.WebBaseController;
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;
@Autowired
private StaffClerkRelationApiService staffClerkRelationApiService ;
@Autowired
private MaterialApiService materialApiService ;
/**
* 群发-分享 - 店员和店长
*/
@RequestMapping("/message-send")
public RestResponse<Object> messageSend(CustomerQO qo, String imgJson, String selectedStoreId , Long contentMaterialId) {
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 RestResponse.failure("-1","无会员数据");
}
List<String> staffIdList = new ArrayList<>();
if (clerk.getClerkType() == 1) {
staffIdList = staffApiService.listBindStaffId(storeId);
logger.info("店长,成员数={}",staffIdList);
} else if(clerk.getClerkType()==0) {
StaffClerkRelationDTO dto = this.staffClerkRelationApiService.getOneByClerkId(clerkId) ;
if(null != dto) {
logger.info("店员关联的成员={}",dto.getStaffId());
staffIdList.add(dto.getStaffId());
}
}
if(CollectionUtils.isEmpty(staffIdList)) {
return RestResponse.failure("-1","无成员数据");
}
JSONObject json = new JSONObject();
json.put("userIdList", staffIdList);
json.put("sendMemberIds", sendMemberIds);
json.put("enterpriseId", enterpriseId);
json.put("imgJson", imgJson);
json.put("storeId", storeId);
json.put("staffId", staffId);
json.put("content", qo.getContent()) ;
json.put("contentMaterialId", contentMaterialId) ;
json.put("sendClerkId", clerkId);
// 群发-分享
json.put("sendType", 1);
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 RestResponse.successResult();
}
// 朋友圈任务 - 店长和区经
@RequestMapping("/add_moment_task")
public RestResponse<Object> share(CustomerQO qo, String imgJson ,Long contentMaterialId , String searchParams) {
String clerkId = qo.getClerkId();
String wxEnterpriseId = qo.getWxEnterpriseId();
String enterpriseId = qo.getEnterpriseId();
String staffId = qo.getStaffId();
List<String> clerkIdList = qo.getClerkIdList() ;
List<String> storeIdList = qo.getStoreIdList() ;
ClerkDTO clerk = this.clerkService.getclerkById(clerkId);
logger.info("clerkType={},ChooseAll={}",clerk.getClerkType(),qo.getChooseAll());
int clerkType = clerk.getClerkType() ;
if(clerkType==0) {
return RestResponse.failure("-1","非店长、区经");
}
String chooseAll = qo.getChooseAll() ;
if(StringUtils.isBlank(chooseAll) || !"1".equals(chooseAll)) {
if(clerkType==1 && CollectionUtils.isEmpty(clerkIdList)) {
return RestResponse.failure("-1","请选择导购");
}
if(clerkType==2 && CollectionUtils.isEmpty(storeIdList)) {
return RestResponse.failure("-1","请选择门店");
}
}
JSONObject json = new JSONObject();
json.put("clerkIdList", clerkIdList);
json.put("storeIdList", storeIdList) ;
json.put("searchParams", searchParams) ;
json.put("enterpriseId", enterpriseId);
json.put("imgJson", imgJson);
json.put("staffId", staffId);
json.put("sendClerkId", clerkId);
json.put("sendClerkType", clerkType) ;
json.put("sendClerkStoreId", clerk.getStoreId());
// 朋友圈-分享
json.put("sendType", 2);
json.put("wxEnterpriseId", wxEnterpriseId);
json.put("content", qo.getContent()) ;
json.put("contentMaterialId", contentMaterialId) ;
String params = json.toJSONString();
try {
GICMQClientUtil.getClientInstance().sendCommonMessage("haobanCommonRouter", params,
"com.gic.haoban.app.customer.service.api.service.MessageLogApiService", "callBackSendMessage");
} catch (Exception e) {
logger.info(e.getMessage(), e);
}
return RestResponse.successResult();
}
// 1群发 2朋友圈
@RequestMapping("get-qw-materialid")
public RestResponse<Object> getMaterialId(String wxEnterpriseId,String imgUrl , int materialType , @RequestParam(defaultValue="2")int mediaType) {
ContentMaterialDTO dto = new ContentMaterialDTO();
dto.setImgUrl(imgUrl);
dto.setMediaType(mediaType);
dto.setMaterialType(materialType);
ServiceResponse<String> resp = this.materialApiService.getMaterialId(wxEnterpriseId, dto) ;
if(resp.isSuccess()) {
return RestResponse.successResult(resp.getResult()) ;
}
return RestResponse.failure("-1", resp.getMessage()) ;
}
}
......@@ -32,12 +32,6 @@ public class GlobalExceptionHandler extends WebBaseController {
/**
* 控制器运行异常
*
* @param response 响应
* @param ex 前女友
* @return {@link HaobanResponse }
* @author mozhu
* @date 2021-12-15 14:55:50
*/
@ResponseBody
@ExceptionHandler(RuntimeException.class)
......@@ -60,12 +54,6 @@ public class GlobalExceptionHandler extends WebBaseController {
/**
* 全局异常
*
* @param response 响应
* @param ex
* @return {@link HaobanResponse }
* @author mozhu
* @date 2021-12-15 14:54:25
*/
@ResponseBody
@ExceptionHandler(Exception.class)
......
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 = "0";
private String searchParams;
private String clerkId;
private String enterpriseId;
private String wxEnterpriseId ;
private String staffId;
private List<String> memberIdList ;
private List<String> clerkIdList ;
private List<String> storeIdList ;
private String content ;
private boolean qwFriendFlag = false ;
public List<String> getStoreIdList() {
return storeIdList;
}
public void setStoreIdList(List<String> storeIdList) {
this.storeIdList = storeIdList;
}
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.qo.content;
import com.gic.commons.web.qo.PageQo;
/**
* @Author MUSI
* @Date 2022/10/28 1:38 PM
* @Description
* @Version
**/
public class ContentMaterialQO extends PageQo {
/**
* 企业id
*/
private String enterpriseId;
/**
* 微信企业id
*/
private String wxEnterpriseId;
/**
* 门店id
*/
private String storeId;
/**
* 导购id
*/
private String clerkId;
/**
* 1 最新; 2 最热;
*/
private Integer sortType;
/**
* 素材类型1图文2纯文字3纯图片4视频
*/
private Integer materialType;
/**
* 素材搜索
*/
private String search;
/**
* 栏目id
*/
private Long contentColumnId;
public Integer getSortType() {
return sortType;
}
public void setSortType(Integer sortType) {
this.sortType = sortType;
}
public String getSearch() {
return search;
}
public void setSearch(String search) {
this.search = search;
}
public Long getContentColumnId() {
return contentColumnId;
}
public void setContentColumnId(Long contentColumnId) {
this.contentColumnId = contentColumnId;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public String getStoreId() {
return storeId;
}
public void setStoreId(String storeId) {
this.storeId = storeId;
}
public String getClerkId() {
return clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
public Integer getMaterialType() {
return materialType;
}
public void setMaterialType(Integer materialType) {
this.materialType = materialType;
}
}
package com.gic.haoban.manage.web.qo.content;
import java.io.Serializable;
/**
* @Author MUSI
* @Date 2022/10/28 4:09 PM
* @Description
* @Version
**/
public class ContentMaterialShareQO implements Serializable {
private static final long serialVersionUID = -3604528577220428693L;
/**
* 企业id
*/
private String enterpriseId;
/**
* 商品id
*/
private String goodsId;
/**
* 商品货号
*/
private String goodsCode;
/**
* 素材id
*/
private Long contentMaterialId;
/**
* 导购id
*/
private String clerkId;
/**
* 门店id
*/
private String storeId;
/**
* 门店code
*/
private String storeCode;
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getGoodsId() {
return goodsId;
}
public void setGoodsId(String goodsId) {
this.goodsId = goodsId;
}
public Long getContentMaterialId() {
return contentMaterialId;
}
public void setContentMaterialId(Long contentMaterialId) {
this.contentMaterialId = contentMaterialId;
}
public String getClerkId() {
return clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
public String getStoreId() {
return storeId;
}
public void setStoreId(String storeId) {
this.storeId = storeId;
}
public String getStoreCode() {
return storeCode;
}
public void setStoreCode(String storeCode) {
this.storeCode = storeCode;
}
public String getGoodsCode() {
return goodsCode;
}
public void setGoodsCode(String goodsCode) {
this.goodsCode = goodsCode;
}
}
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 ;
}
}
......@@ -6,6 +6,7 @@ public class StoreListVO implements Serializable{
private String storeId ;
private String storeName ;
private String storeCode ;
public String getStoreId() {
return storeId;
}
......@@ -18,5 +19,10 @@ public class StoreListVO implements Serializable{
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public String getStoreCode() {
return storeCode;
}
public void setStoreCode(String storeCode) {
this.storeCode = storeCode;
}
}
package com.gic.haoban.manage.web.vo.content;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import java.io.Serializable;
import java.util.List;
/**
* 栏目基础信息对象
* @Author MUSI
* @Date 2022/10/27 5:00 PM
* @Description
* @Version
**/
public class ContentColumnInfoVO implements Serializable {
/**
* 栏目id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long contentColumnId;
/**
* 栏目名称
*/
private String contentColumnName;
/**
* 子级栏目
*/
private List<ContentColumnInfoVO> childrenColumn;
public Long getContentColumnId() {
return contentColumnId;
}
public void setContentColumnId(Long contentColumnId) {
this.contentColumnId = contentColumnId;
}
public String getContentColumnName() {
return contentColumnName;
}
public void setContentColumnName(String contentColumnName) {
this.contentColumnName = contentColumnName;
}
public List<ContentColumnInfoVO> getChildrenColumn() {
return childrenColumn;
}
public void setChildrenColumn(List<ContentColumnInfoVO> childrenColumn) {
this.childrenColumn = childrenColumn;
}
}
package com.gic.haoban.manage.web.vo.content;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* @Author MUSI
* @Date 2022/10/28 1:52 PM
* @Description
* @Version
**/
public class ContentMaterialInfoVO implements Serializable {
private static final long serialVersionUID = 3274097803200172473L;
/**
* 素材id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long contentMaterialId;
/**
* 素材标题
*/
private String materialTitle;
/**
* 素材内容
*/
private String materialContent;
/**
* 素材类型1图文2纯文字3纯图片4视频
*/
private Integer materialType;
/**
* 发布时间
*/
private Date publishTime;
/**
* 素材图片
*/
private List<String> materialImageUrls;
/**
* 缩略图
*/
private List<String> materialThumbnailImageUrls;
/**
* 素材视频链接
*/
private String materialVideoUrl;
/**
* 素材视频封面链接
*/
private String materialVideoImageUrl;
/**
* 素材视频第一帧url
*/
private String materialVideoFirstImageUrl;
/**
* 分享次数
*/
private Long shareCount;
/**
* 发布人id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long producerId;
/**
* 发布人头像
*/
private String avatar;
/**
* 发布人昵称
*/
private String nickName;
/**
* 商品列表
*/
private List<SimpleGoodsInfoVO> contentGoodsList;
/**
* 视频时长
*/
private Integer duration;
public Long getContentMaterialId() {
return contentMaterialId;
}
public void setContentMaterialId(Long contentMaterialId) {
this.contentMaterialId = contentMaterialId;
}
public String getMaterialTitle() {
return materialTitle;
}
public void setMaterialTitle(String materialTitle) {
this.materialTitle = materialTitle;
}
public String getMaterialContent() {
return materialContent;
}
public void setMaterialContent(String materialContent) {
this.materialContent = materialContent;
}
public Integer getMaterialType() {
return materialType;
}
public void setMaterialType(Integer materialType) {
this.materialType = materialType;
}
public Date getPublishTime() {
return publishTime;
}
public void setPublishTime(Date publishTime) {
this.publishTime = publishTime;
}
public List<String> getMaterialImageUrls() {
return materialImageUrls;
}
public void setMaterialImageUrls(List<String> materialImageUrls) {
this.materialImageUrls = materialImageUrls;
}
public String getMaterialVideoUrl() {
return materialVideoUrl;
}
public void setMaterialVideoUrl(String materialVideoUrl) {
this.materialVideoUrl = materialVideoUrl;
}
public String getMaterialVideoImageUrl() {
return materialVideoImageUrl;
}
public void setMaterialVideoImageUrl(String materialVideoImageUrl) {
this.materialVideoImageUrl = materialVideoImageUrl;
}
public String getMaterialVideoFirstImageUrl() {
return materialVideoFirstImageUrl;
}
public void setMaterialVideoFirstImageUrl(String materialVideoFirstImageUrl) {
this.materialVideoFirstImageUrl = materialVideoFirstImageUrl;
}
public Long getShareCount() {
return shareCount;
}
public void setShareCount(Long shareCount) {
this.shareCount = shareCount;
}
public Long getProducerId() {
return producerId;
}
public void setProducerId(Long producerId) {
this.producerId = producerId;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public List<SimpleGoodsInfoVO> getContentGoodsList() {
return contentGoodsList;
}
public void setContentGoodsList(List<SimpleGoodsInfoVO> contentGoodsList) {
this.contentGoodsList = contentGoodsList;
}
public List<String> getMaterialThumbnailImageUrls() {
return materialThumbnailImageUrls;
}
public void setMaterialThumbnailImageUrls(List<String> materialThumbnailImageUrls) {
this.materialThumbnailImageUrls = materialThumbnailImageUrls;
}
public Integer getDuration() {
return duration;
}
public void setDuration(Integer duration) {
this.duration = duration;
}
}
package com.gic.haoban.manage.web.vo.content;
import java.io.Serializable;
/**
* @Author MUSI
* @Date 2022/10/28 4:12 PM
* @Description
* @Version
**/
public class ContentMaterialShareInfoVO implements Serializable {
/**
* 素材文案
*/
private String materialContentWithLink;
/**
* 商品短链
*/
private String goodsShortLink;
/**
* 商品二维码
*/
private String goodsQrcode;
public String getMaterialContentWithLink() {
return materialContentWithLink;
}
public void setMaterialContentWithLink(String materialContentWithLink) {
this.materialContentWithLink = materialContentWithLink;
}
public String getGoodsShortLink() {
return goodsShortLink;
}
public void setGoodsShortLink(String goodsShortLink) {
this.goodsShortLink = goodsShortLink;
}
public String getGoodsQrcode() {
return goodsQrcode;
}
public void setGoodsQrcode(String goodsQrcode) {
this.goodsQrcode = goodsQrcode;
}
}
package com.gic.haoban.manage.web.vo.content;
import java.io.Serializable;
/**
* @Author MUSI
* @Date 2022/10/28 2:00 PM
* @Description
* @Version
**/
public class SimpleGoodsInfoVO implements Serializable {
/**
* 商品id
*/
private String goodsId;
/**
* 商品图片
*/
private String goodsImg;
/**
* 商品货号
*/
private String goodsCode;
/**
* 商品名称
*/
private String goodsName;
/**
* 商品库存
*/
private Integer spuStock;
/**
* 商品分类
*/
private String goodsCategory;
/**
* 品牌名称
*/
private String brandName;
public String getGoodsId() {
return goodsId;
}
public void setGoodsId(String goodsId) {
this.goodsId = goodsId;
}
public String getGoodsCode() {
return goodsCode;
}
public void setGoodsCode(String goodsCode) {
this.goodsCode = goodsCode;
}
public String getGoodsName() {
return goodsName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
public Integer getSpuStock() {
return spuStock;
}
public void setSpuStock(Integer spuStock) {
this.spuStock = spuStock;
}
public String getGoodsImg() {
return goodsImg;
}
public void setGoodsImg(String goodsImg) {
this.goodsImg = goodsImg;
}
public String getGoodsCategory() {
return goodsCategory;
}
public void setGoodsCategory(String goodsCategory) {
this.goodsCategory = goodsCategory;
}
public String getBrandName() {
return brandName;
}
public void setBrandName(String brandName) {
this.brandName = brandName;
}
}
......@@ -111,5 +111,14 @@
timeout="10000" retries="0" check="false"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.role.HaobanRoleApiService" id="haobanRoleApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.role.HaobanMenuApiService" id="haobanMenuApiService"/>
<dubbo:reference interface="com.gic.enterprise.api.service.AccountService" id="accountService"/>
<dubbo:reference interface="com.gic.content.api.service.ContentColumnApiService" id="contentColumnApiService" timeout="10000" retries="0" check="false"/>
<dubbo:reference interface="com.gic.content.api.service.ContentMaterialApiService" id="contentMaterialApiService" timeout="10000" retries="0" check="false"/>
<dubbo:reference interface="com.gic.content.api.service.ContentMaterialShareApiService" id="contentMaterialShareApiService" timeout="10000" retries="0" check="false"/>
<dubbo:reference id="settingApiService" interface="com.gic.haoban.app.aggregation.api.service.SettingApiService" timeout="10000" retries="0" check="false"/>
</beans>
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