Commit ff25bb1b by 徐高华

通知

parent 90e081ee
......@@ -17,6 +17,16 @@ public class NoticeMessageQDTO implements Serializable {
private int messageType;
private String templateCode;
private Map<String, String> contentMap;
// 是否校验gic企业
private boolean checkFlag =false ;
public boolean isCheckFlag() {
return checkFlag;
}
public void setCheckFlag(boolean checkFlag) {
this.checkFlag = checkFlag;
}
public NoticeMessageQDTO() {
}
......
......@@ -10,6 +10,8 @@ public enum NoticeMessageCategoryTypeEnum {
CUSTOMER(0, "客户相关"),
TASK(1, "任务相关"),
ACTIVITY(2, "活动相关"),
ORDER(4, "订单相关"),
REFUND(5, "售后相关"),
OTHER(3, "其它"),;
private int type;
private String name;
......
......@@ -57,6 +57,16 @@ public enum NoticeMessageTypeEnum {
CUSTOMER_GET_COUPON(4004, "客户领券通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_get_coupon", "/pages/route/index?pageType=", "hbapp_customer_detail"),
CUSTOMER_APPLY_ORDER_REFUND(4005, "客户申请退单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_apply_order_refund", "/pages/route/index?pageType=", "hbapp_customer_order_detail"),
CUSTOMER_SUCCESS_ORDER_REFUND(4006, "客户成功退单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_success_order_refund", "/pages/route/index?pageType=", "hbapp_user_bill_detail"),
// 订单- 待发货订单提醒
ORDER_TAKE(5000, "待自提订单提醒", NoticeMessageCategoryTypeEnum.ORDER.getType(), "order_take", "/pages/route/index?pageType=", "hbapp_order_verfication"),
ORDER_PAY(5001, "待发货订单提醒", NoticeMessageCategoryTypeEnum.ORDER.getType(), "order_pay", "/pages/route/index?pageType=", "hbapp_order_send"),
REFUND_AUDIT(5010, "售后待审核提醒", NoticeMessageCategoryTypeEnum.REFUND.getType(), "refund_audit", "/pages/route/index?pageType=", "hbapp_order_send"),
REFUND_MEMBER_CANCEL(5011, "买家取消售后提醒", NoticeMessageCategoryTypeEnum.REFUND.getType(), "refund_member_cancel", "/pages/route/index?pageType=", "hbapp_order_send"),
REFUND_EXCHANGE(5012, "换货待发货提醒", NoticeMessageCategoryTypeEnum.REFUND.getType(), "refund_exchange", "/pages/route/index?pageType=", "hbapp_order_send"),
REFUND_DELIVER(5013, "买家寄出退换货提醒", NoticeMessageCategoryTypeEnum.REFUND.getType(), "refund_deliver", "/pages/route/index?pageType=", "hbapp_order_send"),
;
/**
* 消息类型
......
package com.gic.haoban.manage.api.service;
import java.util.List;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.dto.QywxCallBackDTO;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
/**
* Created by tgs on 2020/2/20.
......@@ -24,40 +27,6 @@ public interface MessageApiService {
void dealWxMessage(String param);
/**
* 发送消费消息
*
* @param clerkId
* @param memberId
* @param memberName
* @param arrivalTime
* @param storeId
* @return
*/
Boolean sendFaceMessage(String clerkId, String memberId, String memberName, String arrivalTime, String storeId);
/**
* 发送完善标签信息
*
* @param clerkId
* @param clerkId
* @param memberName
* @param customerTime
* @param orderId
* @param storeId
*/
Boolean sendPerfectRemarkMessage(String clerkId, String memberId, String memberName, String customerTime, String orderId, String storeId);
/**
* 通用发送企业微信消息
*
* @param param 参数
* @author xuwenqian
* @date 2021-07-16 10:09:00
*/
void sendWxMessage(String param);
/**
* 获取新的微信用户id
*
* @param wxEnterpriseId 微信企业id
......@@ -67,7 +36,7 @@ public interface MessageApiService {
* @date 2022-03-10 13:48:10
*/
String getNewWxUserIdByStaffId(String wxEnterpriseId, String staffId);
/**
*
* @Title: sendPreMessage
......@@ -79,6 +48,22 @@ public interface MessageApiService {
* @return
* @throws
*/
ServiceResponse<Void> sendPreMessage(String enterpriseId ,String storeId , String message) ;
ServiceResponse<Void> sendPreMessage(String enterpriseId, String storeId, String message);
/**
*
* @Title: sendOrderMessage
* @Description: TODO(这里用一句话描述这个方法的作用)
* @author xugh
* @param enterpriseId
* @param templateCode
* @param clerkId
* @param memberId
* @param valueList
* @return
* @throws
*/
ServiceResponse<Void> sendOrderMessage(String enterpriseId, NoticeMessageTypeEnum noticeType, String orderId, String clerkId, String memberId,
List<String> valueList);
}
......@@ -43,9 +43,11 @@ public class NoticeMessageServiceImpl implements NoticeMessageService {
}
@Override
public Page<NoticeMessageBO> pageNoticeMessage(String enterpriseId, String storeId, String clerkId, int categoryType, BasePageInfo pageInfo) {
public Page<NoticeMessageBO> pageNoticeMessage(String enterpriseId, String storeId, String clerkId,
int categoryType, BasePageInfo pageInfo) {
PageHelper.startPage(pageInfo);
List<TabNoticeMessage> list = noticeMessageMapper.listNoticeMessage(enterpriseId, storeId, clerkId, categoryType);
List<TabNoticeMessage> list = noticeMessageMapper.listNoticeMessage(enterpriseId, storeId, clerkId,
categoryType);
Page<NoticeMessageBO> retPage = PageHelperUtils.changePageHelperToCurrentPage(list, NoticeMessageBO.class);
return retPage;
}
......
package com.gic.haoban.manage.service.service.out.impl;
import cn.hutool.core.convert.Convert;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
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.alibaba.fastjson.JSONObject;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.dto.ClerkQwDTO;
import com.gic.clerk.api.service.ClerkService;
......@@ -12,17 +27,41 @@ import com.gic.commons.util.ImageUtil;
import com.gic.haoban.app.customer.service.api.service.InnerApiService;
import com.gic.haoban.base.api.common.Constant;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.enums.*;
import com.gic.haoban.manage.api.service.*;
import com.gic.haoban.manage.api.dto.CommonMQDTO;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.QywxCallBackDTO;
import com.gic.haoban.manage.api.dto.SecretSettingDTO;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.dto.notify.qdto.NoticeMessageQDTO;
import com.gic.haoban.manage.api.enums.ChannelCodeEnum;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.api.enums.WxEditType;
import com.gic.haoban.manage.api.service.HaobanCommonMQApiService;
import com.gic.haoban.manage.api.service.MessageApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.entity.*;
import com.gic.haoban.manage.service.service.*;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
import com.gic.haoban.manage.service.entity.TabHaobanWxApplication;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated;
import com.gic.haoban.manage.service.service.DepartmentService;
import com.gic.haoban.manage.service.service.SecretSettingService;
import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.WxApplicationService;
import com.gic.haoban.manage.service.service.WxEnterpriseRelatedService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.chat.GroupChatService;
import com.gic.member.api.dto.MemberDTO;
import com.gic.member.api.service.MemberService;
import com.gic.mq.sdk.GicMQClient;
import com.gic.redis.data.util.RedisUtil;
import com.gic.thirdparty.api.service.QQCloudPicService;
import com.gic.thirdparty.cloudfile.CloudFileUtil;
import com.gic.thirdparty.cloudfile.enums.CloudFileBusinessOptEnum;
import com.gic.thirdparty.cloudfile.enums.CloudFileTypeEnum;
......@@ -34,16 +73,8 @@ import com.gic.wechat.api.service.qywx.QywxDepartmentApiService;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import com.google.common.collect.Sets;
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 java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import cn.hutool.core.convert.Convert;
/**
* 接收企业微信或者gic推送消息进行处理
......@@ -77,8 +108,6 @@ public class MessageApiServiceImpl implements MessageApiService {
@Autowired
private WxEnterpriseService wxEnterpriseService;
@Autowired
private StaffDepartmentRelatedApiService staffDepartmentRelatedApiService;
@Autowired
private WxEnterpriseRelatedService wxEnterpriseRelatedService;
@Autowired
private ClerkService clerkService;
......@@ -89,9 +118,11 @@ public class MessageApiServiceImpl implements MessageApiService {
@Autowired
private QywxUserApiService qywxUserApiService;
@Autowired
private HaobanCommonMQApiService haobanCommonMQApiService ;
private HaobanCommonMQApiService haobanCommonMQApiService;
@Autowired
private GroupChatService groupChatService;
@Autowired
private MemberService memberService ;
@Override
public void wxMessageReceive(QywxCallBackDTO qywxCallBackDTO) {
......@@ -113,9 +144,9 @@ public class MessageApiServiceImpl implements MessageApiService {
log.info("通讯录只处理自建应用回调 dto={}", JSON.toJSONString(param));
return;
}
//处理部门
// 处理部门
dealQywxDepartment(dto);
//处理成员
// 处理成员
dealQywxUser(dto);
}
......@@ -144,13 +175,12 @@ public class MessageApiServiceImpl implements MessageApiService {
Set<String> wxSet = Sets.newHashSet(
// 鸿星尔克
"e034e2bd5d0b44d3bf553c9f8204094c",
//润臣测试环境
// 润臣测试环境
"ca66a01b79474c40b3e7c7f93daf1a3b",
//尊兴
// 尊兴
"c0c2186a947440aa8c0afbdd869ec043",
//金华悦行
"ac451a350eed4a96958dd5c7377f8bd9"
);
// 金华悦行
"ac451a350eed4a96958dd5c7377f8bd9");
return wxSet.contains(wxEnterpriseId);
}
......@@ -165,13 +195,14 @@ public class MessageApiServiceImpl implements MessageApiService {
ClerkQwDTO clerkQwDTO = new ClerkQwDTO();
clerkQwDTO.setEnterpriseId(enterpriseId);
String mainDeptId = dto.getMainDepartment();
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> departments = qywxDepartmentApiService.listSelfDepartment(dto.getAuthCorpId(), secret, Integer.valueOf(mainDeptId));
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> departments = qywxDepartmentApiService
.listSelfDepartment(dto.getAuthCorpId(), secret, Integer.valueOf(mainDeptId));
if (CollectionUtils.isEmpty(departments)) {
log.info("通过主部门查询部门列表为空 mainDeptId:{}", mainDeptId);
return;
}
Map<Integer, com.gic.wechat.api.dto.qywx.DepartmentDTO> departmentIdMap = departments.stream()
.collect(Collectors.toMap(com.gic.wechat.api.dto.qywx.DepartmentDTO::getId, Function.identity(), (a, b) -> a));
Map<Integer, com.gic.wechat.api.dto.qywx.DepartmentDTO> departmentIdMap = departments.stream().collect(
Collectors.toMap(com.gic.wechat.api.dto.qywx.DepartmentDTO::getId, Function.identity(), (a, b) -> a));
com.gic.wechat.api.dto.qywx.DepartmentDTO mainDept = departmentIdMap.get(Integer.valueOf(mainDeptId));
String deptName = mainDept.getName();
clerkQwDTO.setStoreName(deptName);
......@@ -210,18 +241,18 @@ public class MessageApiServiceImpl implements MessageApiService {
if (changeType.equals(WxEditType.ADD_USER.getCode())) {
log.info("成员同步新增,userid:{}", userid);
//新增
// 新增
ServiceResponse serviceResponse = this.staffApiService.wxGetAdd(userid, wxEnterpriseId);
// 校验适用企业-定制
boolean suitWxEnterpriseIid = checkSuitEnterpriseId(wxEnterpriseId);
if (suitWxEnterpriseIid) {
String staffName = Convert.toStr(serviceResponse.getResult());
//鸿星尔克定制
// 鸿星尔克定制
dealErKe(qywxCallBackDTO, wxEnterpriseId, staffName);
}
} else if (changeType.equals(WxEditType.UPDATE_USER.getCode())) {
log.info("成员同步修改,userid:{}", userid);
//修改
// 修改
TabHaobanStaff oldStaff = this.staffService.selectByUserIdAndEnterpriseId(userid, wxEnterpriseId);
if (oldStaff == null) {
log.error("成员同步更新失败,无历史员工数据:userid:{},wxEnterpriseId:{}", userid, wxEnterpriseId);
......@@ -238,20 +269,20 @@ public class MessageApiServiceImpl implements MessageApiService {
staff.setHeadImg(changeHeaderImageUrl(qywxCallBackDTO.getAvatar()));
}
staff.setNationCode("86");
//激活状态
// 激活状态
if (qywxCallBackDTO.getStatus() != null && qywxCallBackDTO.getStatus() == 1) {
staff.setActiveFlag(1);
}
String[] departArr = qywxCallBackDTO.getDepartment();
StringBuilder departmentIds = new StringBuilder();
//部门修改了
// 部门修改了
if (departArr != null) {
for (String s : departArr) {
TabHaobanDepartment department = this.departmentService.getByWxId(s, wxEnterpriseId);
if (department == null) {
log.info("成员同步,部门不存在");
Map<String,Object> map = new HashMap<>() ;
map.put("staffId", staff.getStaffId()) ;
Map<String, Object> map = new HashMap<>();
map.put("staffId", staff.getStaffId());
CommonMQDTO dto = new CommonMQDTO();
dto.setType(2);
dto.setParams(map);
......@@ -264,8 +295,9 @@ public class MessageApiServiceImpl implements MessageApiService {
departmentIds = new StringBuilder(departmentIds.substring(0, departmentIds.length() - 1));
}
} else {
//部门没有修改
List<TabHaobanStaffDepartmentRelated> list = staffDepartmentRelatedService.listStaffDepartmentByStaffId(staff.getStaffId());
// 部门没有修改
List<TabHaobanStaffDepartmentRelated> list = staffDepartmentRelatedService
.listStaffDepartmentByStaffId(staff.getStaffId());
if (CollectionUtils.isNotEmpty(list)) {
for (TabHaobanStaffDepartmentRelated tabHaobanStaffDepartmentRelated : list) {
departmentIds.append(tabHaobanStaffDepartmentRelated.getDepartmentId()).append(",");
......@@ -279,7 +311,8 @@ public class MessageApiServiceImpl implements MessageApiService {
staffApiService.staffEdit(staffDTO, departmentIds.toString());
} else if (changeType.equals(WxEditType.DELETE_USER.getCode())) {
log.info("成员同步删除,userid:{}", userid);
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.CUSTOMIZED_APP.getVal());
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId,
SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
log.info("没有配置secret,wxEnterpriseId:{}", wxEnterpriseId);
return;
......@@ -295,27 +328,29 @@ public class MessageApiServiceImpl implements MessageApiService {
return;
}
}
//删除
// 删除
TabHaobanStaff oldStaff = this.staffService.selectByUserIdAndEnterpriseId(userid, wxEnterpriseId);
if (oldStaff == null) {
log.info("微信成员同步删除的门店不存在,{}", userid);
return;
}
String staffId = oldStaff.getStaffId();
//销毁卡券
// 销毁卡券
innerApiService.delCardByStaffId(staffId);
//删除导购好友关联关系表
// 删除导购好友关联关系表
this.staffDepartmentRelatedService.delByStaffid(staffId);
//员工解绑
List<StaffClerkRelationDTO> staffClerkRelationDTOS = staffClerkRelationApiService.listByStaffId(wxEnterpriseId, staffId);
// 员工解绑
List<StaffClerkRelationDTO> staffClerkRelationDTOS = staffClerkRelationApiService
.listByStaffId(wxEnterpriseId, staffId);
if (CollectionUtils.isNotEmpty(staffClerkRelationDTOS)) {
for (StaffClerkRelationDTO staffClerkRelationDTO : staffClerkRelationDTOS) {
staffClerkRelationApiService.unbindByStaffAndClerkId(staffId, staffClerkRelationDTO.getClerkId(), ChannelCodeEnum.ADMIN_UNBIND.getCode(),wxEnterpriseId);
staffClerkRelationApiService.unbindByStaffAndClerkId(staffId, staffClerkRelationDTO.getClerkId(),
ChannelCodeEnum.ADMIN_UNBIND.getCode(), wxEnterpriseId);
}
}
//群状态刷新
// 群状态刷新
this.groupChatService.ownerDimission(staffId);
//删除员工表-注意顺序
// 删除员工表-注意顺序
this.staffService.delByStaffId(staffId);
}
log.error("成员同步结束");
......@@ -342,7 +377,8 @@ public class MessageApiServiceImpl implements MessageApiService {
return;
}
String wxEnterpriseId = wxApplication.getWxEnterpriseId();
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.CUSTOMIZED_APP.getVal());
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId,
SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
log.info("没有配置secret:{}", wxEnterpriseId);
return;
......@@ -363,23 +399,27 @@ public class MessageApiServiceImpl implements MessageApiService {
log.info("企微同步父部门不存在");
return;
}
com.gic.wechat.api.dto.qywx.DepartmentDTO deptDetail = qywxDepartmentApiService.getSelfDepartmentById(authCorpId, secret, wxDeptId);
com.gic.wechat.api.dto.qywx.DepartmentDTO deptDetail = qywxDepartmentApiService
.getSelfDepartmentById(authCorpId, secret, wxDeptId);
departmentDTO.setDepartmentName(deptDetail.getName());
departmentDTO.setParentDepartmentId(parentDepartment.getDepartmentId());
departmentDTO.setChainId(parentDepartment.getChainId() + Constant.ID_SEPARATOR + parentDepartment.getDepartmentId());
departmentDTO.setChainId(
parentDepartment.getChainId() + Constant.ID_SEPARATOR + parentDepartment.getDepartmentId());
departmentDTO.setChainName(parentDepartment.getChainName() + parentDepartment.getChainName());
departmentDTO.setLevel(parentDepartment.getLevel() + 1);
}
departmentDTO.setWxEnterpriseId(wxEnterpriseId);
departmentDTO.setWxDepartmentId(wxDeptId + "");
if (qywxCallBackDTO.getParentId() != null) {
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService.listSelfDepartment(authCorpId, secret, qywxCallBackDTO.getParentId());
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService
.listSelfDepartment(authCorpId, secret, qywxCallBackDTO.getParentId());
if (CollectionUtils.isNotEmpty(list)) {
for (com.gic.wechat.api.dto.qywx.DepartmentDTO wxDepartmentDTO : list) {
if (Convert.toStr(wxDepartmentDTO.getId()).equals(departmentDTO.getDepartmentId())) {
departmentDTO.setSort(qywxCallBackDTO.getOrder());
} else {
TabHaobanDepartment tab = this.departmentService.getByWxId(wxDepartmentDTO.getId() + "", wxEnterpriseId);
TabHaobanDepartment tab = this.departmentService.getByWxId(wxDepartmentDTO.getId() + "",
wxEnterpriseId);
if (tab != null) {
tab.setSort(wxDepartmentDTO.getOrder());
this.departmentService.edit(EntityUtil.changeEntityByJSON(DepartmentDTO.class, tab));
......@@ -436,7 +476,8 @@ public class MessageApiServiceImpl implements MessageApiService {
log.info("未查询到企业关联企业 wxEnt");
return;
}
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.CUSTOMIZED_APP.getVal());
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId,
SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
log.info("没有配置secret:{}", wxEnterpriseId);
return;
......@@ -452,12 +493,15 @@ public class MessageApiServiceImpl implements MessageApiService {
return headImgUrl;
}
byte[] data = ImageUtil.getImgbyte(headImgUrl);
// PicUploadResDTO uploadPic = qqCloudPicService.uploadPic(GlobalVar.ctxPropertiesMap.get(GlobalInfo.QQPIC_KEY_ENTERPRISE), data);
//默认后缀为jpg,企业factoryCode取gic内部使用的factoryCode
String suffix="jpg";
String factoryCode="gic_inner";
// PicUploadResDTO uploadPic =
// qqCloudPicService.uploadPic(GlobalVar.ctxPropertiesMap.get(GlobalInfo.QQPIC_KEY_ENTERPRISE),
// data);
// 默认后缀为jpg,企业factoryCode取gic内部使用的factoryCode
String suffix = "jpg";
String factoryCode = "gic_inner";
CloudFileTypeEnum cloudFileTypeEnum = CloudFileTypeEnum.IMAGE;
CloudFileInfo cloudFileInfo = CloudFileUtil.uploadFile(data, suffix, cloudFileTypeEnum,factoryCode, CloudFileBusinessOptEnum.HAOBAN_COMMON);
CloudFileInfo cloudFileInfo = CloudFileUtil.uploadFile(data, suffix, cloudFileTypeEnum, factoryCode,
CloudFileBusinessOptEnum.HAOBAN_COMMON);
log.info("腾讯云万象优图返回" + JSON.toJSONString(cloudFileInfo));
return cloudFileInfo.getOrgFileUrl();
} catch (Exception e) {
......@@ -466,47 +510,6 @@ public class MessageApiServiceImpl implements MessageApiService {
}
}
@Override
public Boolean sendFaceMessage(String clerkId, String memberId, String memberName, String arrivalTime, String storeId) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("memberId", memberId);
jsonObject.put("storeId", storeId);
String data = jsonObject.toJSONString();
String pageUrl = staffDepartmentRelatedApiService.getPageUrl(AppPageType.FACE_ARRIVAL.getCode(), data);
StaffClerkRelationDTO relation = staffClerkRelationApiService.getByClerkId(clerkId);
if (relation == null) {
log.info("clerkId未绑定:clerkId={}", clerkId);
return false;
}
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(relation.getWxEnterpriseId());
if (qwDTO == null) {
log.info("企业为空");
return false;
}
StaffDTO staffDTO = staffApiService.selectById(relation.getStaffId());
String corpid = qwDTO.getThirdCorpid();
String wxUserId = "";
if (qwDTO.needOpenUserId3th()) {
wxUserId = staffDTO.getWxOpenUseId();
} else {
wxUserId = staffDTO.getWxUserId();
}
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
Map<String, String> map = new HashMap<>();
map.put("事件", "人脸匹配");
map.put("会员", memberName);
map.put("到店时间", arrivalTime);
List<ItemDTO> items = getItemsList(map);
ArrayList<String> list = new ArrayList<>();
list.add(wxUserId);
messageDTO.setAppid(config.getAppid());
messageDTO.setUserIds(list);
messageDTO.setPage(pageUrl);
messageDTO.setTitle("我的顾客通知");
messageDTO.setItems(items);
return qywxSuiteApiService.sendMessage(corpid, config.getWxSuiteid(), messageDTO);
}
private List<ItemDTO> getItemsList(Map<String, String> map) {
List<ItemDTO> items = new ArrayList();
map.keySet().forEach(key -> {
......@@ -520,71 +523,6 @@ public class MessageApiServiceImpl implements MessageApiService {
}
@Override
public Boolean sendPerfectRemarkMessage(String clerkId, String memberId, String memberName, String customerTime, String orderId, String storeId) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("memberId", memberId);
jsonObject.put("storeId", storeId);
jsonObject.put("currentTab", 1);
StaffClerkRelationDTO relation = staffClerkRelationApiService.getByClerkId(clerkId);
if (relation == null) {
log.info("clerkId未绑定:clerkId={}", clerkId);
return false;
}
WxEnterpriseDTO wxEnterprise = wxEnterpriseService.selectById(relation.getWxEnterpriseId());
if (wxEnterprise == null) {
log.info("企业为空");
return false;
}
StaffDTO staffDTO = staffApiService.selectById(relation.getStaffId());
if (staffDTO == null) {
return false;
}
Map<String, String> params = new HashMap<>();
params.put("memberName", memberName);
params.put("orderId", orderId);
params.put("customerTime", customerTime);
NoticeMessageUtil.sendNoticeMessage(relation.getEnterpriseId(), relation.getClerkId(), NoticeMessageTypeEnum.MEMBER_FACE.getType(), null, params, jsonObject);
return true;
}
@Override
public void sendWxMessage(String param) {
log.info("发送企业微信消息:{}", param);
if (StringUtils.isBlank(param)) {
log.info("param参数为空");
return;
}
JSONObject jsonObject = JSON.parseObject(param);
String wxEnterpriseId = jsonObject.getString("wxEnterpriseId");
String wxUserId = jsonObject.getString("wxUserId");
String pageUrl = jsonObject.getString("pageUrl");
String title = jsonObject.getString("title");
String content = jsonObject.getString("content");
String memberName = jsonObject.getString("memberName");
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
if (qwDTO == null) {
log.info("企业为空");
return;
}
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
//后续map加判断可加参数
Map<String, String> map = new HashMap<>();
map.put("接收事件", content);
map.put("接收人", memberName);
List<ItemDTO> items = getItemsList(map);
List<String> userList = new ArrayList<>();
userList.add(wxUserId);
messageDTO.setAppid(config.getAppid());
messageDTO.setUserIds(userList);
messageDTO.setPage(pageUrl);
messageDTO.setTitle(title);
messageDTO.setItems(items);
qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(), messageDTO);
}
@Override
public String getNewWxUserIdByStaffId(String wxEnterpriseId, String staffId) {
log.info("请求wxEnterpriseId:{},staffId:{}", wxEnterpriseId, staffId);
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
......@@ -597,49 +535,112 @@ public class MessageApiServiceImpl implements MessageApiService {
}
return qwDTO.needOpenUserId3th() ? tabHaobanStaff.getWxOpenUseId() : tabHaobanStaff.getWxUserId();
}
@Override
public com.gic.api.base.commons.ServiceResponse<Void> sendPreMessage(String enterpriseId ,String storeId, String message) {
log.info("线下预约通知,storeId={}",storeId);
ClerkDTO clerkDTO = this.clerkService.getClerkLeaderByStoreId(storeId) ;
if(null == clerkDTO) {
public com.gic.api.base.commons.ServiceResponse<Void> sendPreMessage(String enterpriseId, String storeId,
String message) {
log.info("线下预约通知,storeId={}", storeId);
ClerkDTO clerkDTO = this.clerkService.getClerkLeaderByStoreId(storeId);
if (null == clerkDTO) {
log.info("店长查不到");
return com.gic.api.base.commons.ServiceResponse.success() ;
return com.gic.api.base.commons.ServiceResponse.success();
}
String clerkId = clerkDTO.getClerkId() ;
StaffClerkRelationDTO dto = this.staffClerkRelationApiService.getOneByClerkId(clerkId) ;
if(null == dto) {
String clerkId = clerkDTO.getClerkId();
StaffClerkRelationDTO dto = this.staffClerkRelationApiService.getOneByClerkId(clerkId);
if (null == dto) {
log.info("导购成员未关联");
return com.gic.api.base.commons.ServiceResponse.success() ;
return com.gic.api.base.commons.ServiceResponse.success();
}
String eid = dto.getEnterpriseId() ;
if(!enterpriseId.equals(eid)) {
String eid = dto.getEnterpriseId();
if (!enterpriseId.equals(eid)) {
log.info("导购成员关联多个");
return com.gic.api.base.commons.ServiceResponse.success() ;
return com.gic.api.base.commons.ServiceResponse.success();
}
String wxEnterpriseId = dto.getWxEnterpriseId() ;
String staffId = dto.getStaffId() ;
String wxEnterpriseId = dto.getWxEnterpriseId();
String staffId = dto.getStaffId();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
if (qwDTO == null) {
log.info("企业为空");
return com.gic.api.base.commons.ServiceResponse.success() ;
return com.gic.api.base.commons.ServiceResponse.success();
}
StaffDTO staff = this.staffApiService.selectById(staffId) ;
StaffDTO staff = this.staffApiService.selectById(staffId);
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
String wxUserId = staff.getWxUserId() ;
if(qwDTO.needOpenUserId3th()) {
wxUserId = staff.getWxOpenUseId() ;
String wxUserId = staff.getWxUserId();
if (qwDTO.needOpenUserId3th()) {
wxUserId = staff.getWxOpenUseId();
}
messageDTO.setAppid(config.getAppid());
messageDTO.setUserIds(Arrays.asList(wxUserId));
messageDTO.setPage(NoticeMessageTypeEnum.OFFLINE_PRE.getPageUrl()+NoticeMessageTypeEnum.OFFLINE_PRE.getPageType());
messageDTO.setPage(
NoticeMessageTypeEnum.OFFLINE_PRE.getPageUrl() + NoticeMessageTypeEnum.OFFLINE_PRE.getPageType());
messageDTO.setTitle(NoticeMessageTypeEnum.OFFLINE_PRE.getName());
Map<String, String> map = new HashMap<>();
map.put("事件", message);
List<ItemDTO> items = getItemsList(map);
messageDTO.setItems(items);
qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(), messageDTO);
return com.gic.api.base.commons.ServiceResponse.success() ;
return com.gic.api.base.commons.ServiceResponse.success();
}
@Override
public com.gic.api.base.commons.ServiceResponse<Void> sendOrderMessage(String enterpriseId,
NoticeMessageTypeEnum noticeType, String orderId, String clerkId, String memberId, List<String> valueList) {
log.info("订单消息通知={},{},{}",memberId,clerkId,orderId);
List<NoticeMessageQDTO> list = new ArrayList<>();
if (StringUtils.isAnyBlank(enterpriseId, clerkId, memberId)) {
return com.gic.api.base.commons.ServiceResponse.failure("9999","必传参数没传");
}
NoticeMessageTypeEnum messageTypeEnum = NoticeMessageTypeEnum.getByType(noticeType.getType());
if (messageTypeEnum == null) {
return com.gic.api.base.commons.ServiceResponse.failure("9999","消息类型不存在");
}
ClerkDTO clerkDTO = this.clerkService.getclerkById(clerkId) ;
if (null == clerkDTO) {
return com.gic.api.base.commons.ServiceResponse.failure("9999","导购查不到");
}
Map<String, Object> extendContent = new HashMap<>();
if(messageTypeEnum.getCategory()==5) {
if(messageTypeEnum.equals(NoticeMessageTypeEnum.ORDER_PAY)) {
extendContent.put("currentTab ", 0) ;
}else {
extendContent.put("currentTab ", 1) ;
}
}
Map<String,String> map = this.toMapValue(memberId,valueList);
NoticeMessageQDTO qdto = this.getDTO(enterpriseId, clerkId, orderId, noticeType, map , extendContent) ;
list.add(qdto);
String storeId = clerkDTO.getStoreId() ;
ClerkDTO dz = this.clerkService.getClerkLeaderByStoreId(storeId);
if (null != dz && !dz.getClerkId().equals(clerkId)) {
NoticeMessageQDTO dzQdto = this.getDTO(enterpriseId, dz.getClerkId(), orderId, noticeType, map , extendContent) ;
list.add(dzQdto);
}
NoticeMessageUtil.sendNoticeMessageBatch(list);
return com.gic.api.base.commons.ServiceResponse.success();
}
private NoticeMessageQDTO getDTO(String enterpriseId , String clerkId , String orderId , NoticeMessageTypeEnum noticeType , Map<String,String> map,Map<String, Object> extendContent) {
NoticeMessageQDTO qdto = new NoticeMessageQDTO();
qdto.setEnterpriseId(enterpriseId);
qdto.setClerkId(clerkId);
qdto.setMessageType(noticeType.getType());
qdto.setContentMap(map);
qdto.setOptTargetId(orderId);
qdto.setCheckFlag(true);
qdto.setExtendContent(extendContent);
return qdto ;
}
private Map<String,String> toMapValue(String memberId ,List<String> valueList) {
Map<String,String> map = new HashMap<>() ;
if(CollectionUtils.isNotEmpty(valueList)) {
for(int i=0;i<valueList.size();i++) {
map.put(""+(i + 1), valueList.get(i)) ;
}
}
MemberDTO member = this.memberService.getMember(memberId) ;
String name = member.getThirdNickname() ;
map.put("memberName", name) ;
return map ;
}
}
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