Commit 32f14a6f by zhangzhendong

Merge branch 'master' into feature-消息中心

# Conflicts:
#	haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/content/adaptor/MaterialReportBuilder.java
#	haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/content/adaptor/PotentialCustomerNotifyBuilder.java
#	haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/content/impl/MaterialReportServiceImpl.java
#	haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/notify/out/NoticeMessageApiServiceImpl.java
parents 189c88fd 10bb0c1f
......@@ -44,6 +44,17 @@ public class MemberUnionidRelatedDTO implements Serializable{
private String state;
private String staffId ;
// 是否从自建应用下的回调
private int selfCallback = 0;
public int getSelfCallback() {
return selfCallback;
}
public void setSelfCallback(int selfCallback) {
this.selfCallback = selfCallback;
}
public String getStaffId() {
return staffId;
......
......@@ -48,6 +48,16 @@ public class QwFrientNoticeDTO implements Serializable {
private String staffId;
private String changeType;
// 是否从自建应用下的回调
private int selfCallback = 0;
public int getSelfCallback() {
return selfCallback;
}
public void setSelfCallback(int selfCallback) {
this.selfCallback = selfCallback;
}
public String getStaffId() {
return staffId;
......
......@@ -37,7 +37,17 @@ public class QywxCallBackDTO implements Serializable{
/**部门创建:create_party;部门修改:update_party;部门删除:delete_party*
* 成员创建:create_user;成员修改:update_user;成员删除:delete_user*/
private String changeType;
// 是否自建应用的回调
private int selfCallback = 0 ;
public int getSelfCallback() {
return selfCallback;
}
public void setSelfCallback(int selfCallback) {
this.selfCallback = selfCallback;
}
public String getAvatar() {
return avatar;
}
......
......@@ -108,6 +108,24 @@ public class WxEnterpriseDTO implements Serializable {
private Integer wxSecurityType ;
private String wxCorpid ;
private String openCorpid ;
private String wxaAppid ;
private String urlHost ;
public String getUrlHost() {
return urlHost;
}
public void setUrlHost(String urlHost) {
this.urlHost = urlHost;
}
public String getWxaAppid() {
return wxaAppid;
}
public void setWxaAppid(String wxaAppid) {
this.wxaAppid = wxaAppid;
}
public Integer getWxSecurityType() {
return wxSecurityType;
......
......@@ -14,10 +14,62 @@ public class WxEnterpriseQwDTO implements Serializable {
private String memberCorpid;
// 第三方
private String thirdCorpid;
private String selfSecret ;
// 自建请求地址
private String urlHost ;
private String selfAppid ;
// 好办小程序的appid(根据第三方或自建返回)
private String hbWxaAppid ;
// 自建/第三方
private String self3thSecret ;
public String getHbWxaAppid() {
return hbWxaAppid;
}
public String getSelf3thSecret() {
return self3thSecret;
}
public void setHbWxaAppid(String hbWxaAppid) {
this.hbWxaAppid = hbWxaAppid;
}
public void setSelf3thSecret(String self3thSecret) {
this.self3thSecret = self3thSecret;
}
public String getSelfAppid() {
return selfAppid;
}
public void setSelfAppid(String selfAppid) {
this.selfAppid = selfAppid;
}
public String getUrlHost() {
return urlHost;
}
public void setUrlHost(String urlHost) {
this.urlHost = urlHost;
}
public String getSelfSecret() {
return selfSecret;
}
public void setSelfSecret(String selfSecret) {
this.selfSecret = selfSecret;
}
// 好办小程序应用id
private String agentId;
// 好办小程序名称
private String agentName;
// 第三方使用的加密的userid
public boolean needOpenUserId3th() {
......@@ -27,6 +79,10 @@ public class WxEnterpriseQwDTO implements Serializable {
public boolean needOpenUserIdDk() {
return this.wxSecurityType == 2 || this.wxSecurityType == 4;
}
public boolean isSelf() {
return this.wxSecurityType == 5 ;
}
public int getWxSecurityType() {
return wxSecurityType;
......
......@@ -16,6 +16,15 @@ public class ChatEventDTO implements Serializable {
private Integer quitScene;
private Integer memChangeCnt;
private String corpid;
// 是否自建应用的回调
private int selfCallback = 0 ;
public int getSelfCallback() {
return selfCallback;
}
public void setSelfCallback(int selfCallback) {
this.selfCallback = selfCallback;
}
public String getChangeType() {
return changeType;
......
......@@ -69,7 +69,19 @@ public class GroupChatDTO implements Serializable {
private int hmAddStatus = 1 ;
private String chatRemark ;
private int initFlag ;
private String clerkRelationExcel;
public String getClerkRelationExcel() {
if (clerkRelationFlag == 0){
clerkRelationExcel="未关联";
}else {
clerkRelationExcel="已关联";
}
return clerkRelationExcel;
}
public void setClerkRelationExcel(String clerkRelationExcel) {
this.clerkRelationExcel = clerkRelationExcel;
}
public int getInitFlag() {
return initFlag;
}
......
......@@ -153,6 +153,18 @@ public class LicenceOrderDTO implements Serializable {
* 微信url
*/
private String wxUrl;
/**
* 企业微信订单过期时间
*/
private Date qywxExpireTime;
public Date getQywxExpireTime() {
return qywxExpireTime;
}
public void setQywxExpireTime(Date qywxExpireTime) {
this.qywxExpireTime = qywxExpireTime;
}
public String getWxUrl() {
return wxUrl;
......
......@@ -131,6 +131,18 @@ public class LicenceOrderPageDTO implements Serializable {
* 微信订单id
*/
private String wxOrderId;
/**
* 企业微信订单过期时间
*/
private Date qywxExpireTime;
public Date getQywxExpireTime() {
return qywxExpireTime;
}
public void setQywxExpireTime(Date qywxExpireTime) {
this.qywxExpireTime = qywxExpireTime;
}
public String getWxOrderId() {
return wxOrderId;
......
......@@ -101,6 +101,18 @@ public class LicenceOrderQDTO implements Serializable {
* 创建人名称
*/
private String creatorName;
/**
* 企业微信订单id
*/
private String qywxOrderId;
public String getQywxOrderId() {
return qywxOrderId;
}
public void setQywxOrderId(String qywxOrderId) {
this.qywxOrderId = qywxOrderId;
}
public Long getOrderId() {
return orderId;
......
......@@ -4,8 +4,9 @@ package com.gic.haoban.manage.api.enums;
* Created by hua on 2020/6/3.
*/
public enum SecretTypeEnum {
CONTACT_CUSTOMER(1, "顾客联系"),
MEMBER_WAPP(4, "会员小程序"),
SELF_APP(1, "好办自建"),
CONTACT_CUSTOMER(8, "顾客联系(目前无用)"),
MEMBER_WAPP(4, "会员工具"),
CUSTOMIZED_APP(5, "自建代开发"),
WEWORK_PAY(6, "企业支付"),
;
......
......@@ -195,6 +195,10 @@ public interface ExternalClerkRelatedApiService {
com.gic.api.base.commons.ServiceResponse<Boolean> isQwFriend(String enterpriseId, String staffId, String memberId) ;
List<String> listMemberAndStaff(List<String> memberIdList , String StaffId , String enterpriseId) ;
/**
*
* @param enterpriseId
......@@ -204,12 +208,8 @@ public interface ExternalClerkRelatedApiService {
*/
com.gic.api.base.commons.ServiceResponse<Boolean> isQwFriendWithUnionId(String enterpriseId, String clerkId, String unionId) ;
//无效接口
// com.gic.api.base.commons.ServiceResponse<String> getExternalUseridForWxa(String enterpriseId, String staffId, String memberId) ;
List<String> listMemberAndClerk(List<String> memberIdList , List<String> clerkIdList , String enterpriseId) ;
/**
/**
* 批量查询会员与导购好友关系
*
* @param memberIdList 会员id列表
......
......@@ -146,14 +146,7 @@ public interface MemberUnionidRelatedApiService {
ExternalUserDTO getCorpSelfExternalUseridInfoForMember(String wxEnterpriseId, String wxUserId, String externalUserId,String enterpriseId);
/**
* 添加企微好友关联关系表-无需触达
*
* @param dto
* @return
*/
String addExternal(ExternalUserDTO dto);
public String dealMergeForReflsh(ExternalUserDTO externalUserDTO, String wxEnterpriseId , String staffId) ;
/**
* 获取客户详情-第三方
*
......
......@@ -46,6 +46,8 @@ public interface WxEnterpriseApiService {
*/
WxEnterpriseDTO getOne(String wxEnterpriseId);
WxEnterpriseDTO selectByWxaAppid(String appid);
WxEnterpriseQwDTO getQwInfo(String wxEnterpriseId);
/**
......
......@@ -151,5 +151,11 @@ public interface LicenceOrderApiService {
*/
ServiceResponse<HashMap<String, Integer>> hasPopup(String wxEnterpriseId);
/**
* 查询企业微信订单状态是否过期
* @return
*/
ServiceResponse<Boolean> checkQywxOrderStatus(Long orderId);
}
......@@ -32,6 +32,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
......@@ -92,6 +93,7 @@ public class LicenceOrderController {
if (ObjectUtil.isNotNull(wxEnterpriseDTO)) {
vo.setWxEnterpriseName(wxEnterpriseDTO.getCorpName());
}
vo.setNowTime(new Date());
}
}
return RestResponse.successResult(result);
......@@ -193,6 +195,18 @@ public class LicenceOrderController {
}
return RestResponse.failure(response.getCode(), response.getMessage());
}
/**
* 获取当前系统时间
*/
@RequestMapping("get-system-date")
public RestResponse<Date> getSystemDate(HttpServletRequest request) {
AuthcenterUserDetails loginUser = (AuthcenterUserDetails) SessionContextUtil.getUser(request);
if (loginUser == null) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()), HaoBanErrCode.ERR_4.getMsg());
}
return RestResponse.successResult(new Date());
}
}
......
......@@ -132,6 +132,14 @@ public class LicenceOrderPageVO implements Serializable {
* 微信订单id
*/
private String wxOrderId;
/**
* 企业微信订单过期时间
*/
private Date qywxExpireTime;
/**
* 当前时间
*/
private Date nowTime;
}
......@@ -154,5 +154,9 @@ public class LicenceOrderVO implements Serializable {
* 订单进度list
*/
private List<LicenceOrderProgressVO> OrderProgressList;
/**
* 企业微信订单过期时间
*/
private Date qywxExpireTime;
}
......@@ -186,7 +186,7 @@ public interface PreDealLogMapper {
* @param relationKey
* @return
*/
TabHaobanPreDealLog getByRelationKey(@Param("taskId") String taskId, @Param("dataType") int dataType, @Param("relationKey") String relationKey);
List<TabHaobanPreDealLog> getByRelationKey(@Param("taskId") String taskId, @Param("dataType") int dataType, @Param("relationKey") String relationKey);
/**
* 校验任务
......
......@@ -365,7 +365,7 @@ public interface TabHaobanExternalClerkRelatedMapper {
@Param("staffId") String staffId);
List<String> listMemberAndClerk(@Param("memberIdList")List<String> memberIdList, @Param("clerkIdList")List<String> clerkIdList, @Param("enterpriseId")String enterpriseId);
int getCountExternalClerk(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("staffId") String staffId,
@Param("statusFlags") List<Integer> statusFlags);
......@@ -373,7 +373,9 @@ public interface TabHaobanExternalClerkRelatedMapper {
int getCountByMemberId(@Param("memberId") String memberId);
void updateClerkInfo(@Param("staffId")String staffId, @Param("oldClerkId")String oldClerkId, @Param("newClerkId")String newClerkId, @Param("storeId")String storeId);
List<String> listByClerkId(@Param("staffId")String staffId, @Param("clerkId")String clerkId) ;
int updateExternalStatus(@Param("wxEnterpriseId")String wxEnterpriseId, @Param("externalUserid")String externalUserid, @Param("status")int status);
/**
......@@ -381,6 +383,8 @@ public interface TabHaobanExternalClerkRelatedMapper {
*/
TabHaobanExternalClerkRelated getMemberForExternalId(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("externalUserId") String externalUserId);
List<String> listMemberAndStaff(@Param("memberIdList")List<String> memberIdList, @Param("staffId")String staffId, @Param("enterpriseId")String enterpriseId);
/**
* 查询成员的好友列表
......
......@@ -13,7 +13,9 @@ public interface WxEnterpriseMapper {
int insertSelective(TabHaobanWxEnterprise record);
TabHaobanWxEnterprise selectByPrimaryKey(String wxEnterpriseId);
TabHaobanWxEnterprise selectByWxaAppid(@Param("appid")String appid);
int updateByPrimaryKeySelective(TabHaobanWxEnterprise record);
Page<TabHaobanWxEnterprise> list(@Param("keyword") String keyword,
......
......@@ -109,7 +109,7 @@ public interface TabHaobanLicenceOrderMapper {
* @param qywxOrderId
* @return
*/
Integer saveQywxOrderId(@Param("orderId") Long orderId, @Param("qywxOrderId") String qywxOrderId);
Integer saveQywxOrderId(@Param("orderId") Long orderId, @Param("qywxOrderId") String qywxOrderId,@Param("qywxExpireTime") Date qywxExpireTime);
List<String> getTransactionIdList(@Param("orderNumber") String orderNumber, @Param("wxEnterpriseId") String wxEnterpriseId);
......
......@@ -52,7 +52,7 @@ public class TabHaobanStaff implements Serializable {
@Transient
private String departmentIds;
private int openConcatFlag ;
private Integer openConcatFlag ;
private Date activeTime;
private Date expireTime;
......@@ -82,11 +82,11 @@ public class TabHaobanStaff implements Serializable {
this.activeCode = activeCode;
}
public int getOpenConcatFlag() {
public Integer getOpenConcatFlag() {
return openConcatFlag;
}
public void setOpenConcatFlag(int openConcatFlag) {
public void setOpenConcatFlag(Integer openConcatFlag) {
this.openConcatFlag = openConcatFlag;
}
......
......@@ -91,6 +91,24 @@ public class TabHaobanWxEnterprise implements Serializable {
private String wxCorpid ;
private String openCorpid ;
private String wxaAppid ;
private String urlHost ;
public String getUrlHost() {
return urlHost;
}
public void setUrlHost(String urlHost) {
this.urlHost = urlHost;
}
public String getWxaAppid() {
return wxaAppid;
}
public void setWxaAppid(String wxaAppid) {
this.wxaAppid = wxaAppid;
}
public String getWxCorpid() {
return wxCorpid;
......
......@@ -66,6 +66,25 @@ public class TabSecretSetting implements Serializable {
*
*/
private Date updateTime;
private String agentName ;
private String agentId ;
public String getAgentName() {
return agentName;
}
public String getAgentId() {
return agentId;
}
public void setAgentName(String agentName) {
this.agentName = agentName;
}
public void setAgentId(String agentId) {
this.agentId = agentId;
}
/**
*/
......
......@@ -170,6 +170,10 @@ public class TabHaobanLicenceOrder implements Serializable {
* 微信url
*/
private String wxUrl;
/**
* 企业微信订单过期时间
*/
private Date qywxExpireTime;
}
package com.gic.haoban.manage.service.pojo.bo.content.binlog;
import com.alibaba.fastjson.annotation.JSONField;
import com.gic.haoban.manage.service.pojo.BinlogBasePojo;
/**
* @Author MUSI
* @Date 2023/5/10 9:43 AM
* @Description
* @Version
**/
public class MaterialMemberUnionIdPoJo extends BinlogBasePojo {
/**
* 会员unionId
*
*/
@JSONField(name = "third_unionid")
private String unionId;
/**
* memberId
*/
@JSONField(name = "member_id")
private String memberId;
public String getUnionId() {
return unionId;
}
public void setUnionId(String unionId) {
this.unionId = unionId;
}
public String getMemberId() {
return memberId;
}
public void setMemberId(String memberId) {
this.memberId = memberId;
}
}
......@@ -64,6 +64,11 @@ public class MaterialReportContext {
private String clerkId;
/**
* 是否是区经
*/
private boolean isManager;
/**
* 主门店
*/
private String mainStoreId;
......@@ -99,8 +104,8 @@ public class MaterialReportContext {
log.info("成员未绑定导购, staffId: {}", this.staffId);
return Collections.emptyList();
}
if (StringUtils.isBlank(this.mainStoreId)) {
log.info("成员 {} 没有主门店数据, 区经角色不发送小程序消息通知 ", this.staffId);
if (this.isManager) {
log.info("成员{}为区经角色, 不发送小程序消息通知 ", this.staffId);
return Collections.emptyList();
}
......
......@@ -8,8 +8,13 @@ import java.util.Set;
public interface ClerkMainStoreRelatedService {
void setMainStore(String staffId, String storeId, String wxEnterpriseId);
// 自动刷新好友列表
void reflushExternal(String wxEnterpriseId ,String staffId) ;
TabHaobanClerkMainStoreRelated selectByWxEnterpriseIdAndStoreId(String staffId, String wxEnterpriseId);
TabHaobanClerkMainStoreRelated selectStaffMainStore(String staffId, String wxEnterpriseId);
/**
* 获取主门店 如果没有主门店设置主门店
......
......@@ -173,7 +173,7 @@ public interface PreDealService {
* @param relationKey
* @return
*/
public TabHaobanPreDealLog getByRelationKey(String taskId, Integer dataType, String relationKey);
public List<TabHaobanPreDealLog> getByRelationKey(String taskId, Integer dataType, String relationKey);
/**
* 获取任务是否有在同步中 好友
......
......@@ -128,8 +128,7 @@ public class GroupChatDataServiceImpl implements GroupChatDataService {
Date date = DateUtil.addDay(DateUtil.getStartTimeOfDay(), -1);
Long time = date.getTime() / 1000;
ServiceResponse<List<GroupChatQwDataDTO>> resp = this.qywxChatApiService.statistic(qwDTO.getThirdCorpid(),
config.getWxSuiteid(), userIdList, time, time);
ServiceResponse<List<GroupChatQwDataDTO>> resp = this.qywxChatApiService.statistic(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), userIdList, time, time , qwDTO.isSelf() , qwDTO.getUrlHost());
List<GroupChatQwDataDTO> dataList = resp.getResult();
if (CollectionUtils.isEmpty(dataList)) {
if (list.size() < pageSize) {
......
......@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
......@@ -143,7 +144,7 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
if (null != secretSetting) {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
ServiceResponse<Void> resp = this.qywxChatApiService.delJoinWay(qwDTO.getDkCorpid(),
secretSetting.getSecretVal(), hm.getWxConfigId());
secretSetting.getSecretVal(), hm.getWxConfigId(),qwDTO.getUrlHost());
logger.info("删除群活码={}", JSON.toJSON(resp));
}
}
......@@ -190,7 +191,7 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
String configId = hm.getWxConfigId();
ServiceResponse<AddJoinWayDTO> joinResp = this.qywxChatApiService.getJoinWay(qwDTO.getDkCorpid(), secret,
configId);
configId,qwDTO.getUrlHost());
logger.info("查询群活码={}", JSON.toJSON(joinResp));
if (joinResp.isSuccess()) {
AddJoinWayDTO join = joinResp.getResult();
......@@ -213,45 +214,57 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
this.saveChatFullNotice(wxEnterpriseId, thisGroupChatId);
return;
}
if (CollectionUtils.isNotEmpty(qwChatIdList)) {
// 处理要踢的
for (String wxChatId : qwChatIdList) {
TabGroupChat chat = this.groupChatMapper.selectByWxChatIdDk(wxEnterpriseId, wxChatId);
if (null == chat) {
continue;
}
TabGroupChat cid = null;
String staffId = chat.getStaffId();
for (TabGroupChat obj : chatList) {
if (obj.getStaffId().equals(staffId)) {
if (null == cid) {
// 处理要踢的
List<String> bakQwChatIdList = EntityUtil.changeEntityListByJSON(String.class, qwChatIdList);
for (String wxChatId : bakQwChatIdList) {
TabGroupChat chat = this.groupChatMapper.selectByWxChatIdDk(wxEnterpriseId, wxChatId);
if (null == chat) {
continue;
}
TabGroupChat cid = null;
String staffId = chat.getStaffId();
for (TabGroupChat obj : chatList) {
if (obj.getStaffId().equals(staffId)) {
if (null == cid) {
cid = obj;
} else {
if (obj.getTotalCount() > cid.getTotalCount()) {
cid = obj;
} else {
if (obj.getTotalCount() > cid.getTotalCount()) {
cid = obj;
}
}
}
}
if (null != cid) {
logger.info("hm={},群={},要删={}", wxChatId, qwChatIdList, cid.getWxChatId());
qwChatIdList.remove(cid.getWxChatIdDk());
// 保存活码
List<TabGroupChat> list = this.groupChatMapper.listByWxWxChatIdListDk(wxEnterpriseId,
qwChatIdList);
if (CollectionUtils.isEmpty(list)) {
logger.info("查询群列表空,dkList={}", qwChatIdList);
return;
}
boolean flag = false ;
if (null != cid) {
logger.info("hm={},群={},要删={}", wxChatId, qwChatIdList, cid.getWxChatId());
Iterator<String> it = qwChatIdList.iterator() ;
while(it.hasNext()) {
if(it.next().equals(cid.getWxChatIdDk())) {
it.remove();
flag = true ;
break ;
}
List<Long> groupChatIdList = list.stream().map(dto -> dto.getGroupChatId())
.collect(Collectors.toList());
GroupChatHmDTO hmDTO = EntityUtil.changeEntityByJSON(GroupChatHmDTO.class, hm);
hmDTO.setChatIdList(groupChatIdList);
this.saveHm(hmDTO, 2);
}
}
if(flag) {
break ;
}
}
}
logger.info("处理后群活码应有的群={}", qwChatIdList);
// 保存活码
List<TabGroupChat> list = this.groupChatMapper.listByWxWxChatIdListDk(wxEnterpriseId,
qwChatIdList);
if (CollectionUtils.isEmpty(list) || list.size() != qwChatIdList.size()) {
this.saveChatFullNotice(wxEnterpriseId, thisGroupChatId);
logger.info("查询群列表空,或数量不一致,dkList={}", qwChatIdList);
return;
}
List<Long> groupChatIdList = list.stream().map(dto -> dto.getGroupChatId())
.collect(Collectors.toList());
GroupChatHmDTO hmDTO = EntityUtil.changeEntityByJSON(GroupChatHmDTO.class, hm);
hmDTO.setChatIdList(groupChatIdList);
this.saveHm(hmDTO, 2);
}
}
}
......@@ -303,7 +316,7 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
if (updateFlag) {
joinDTO.setConfig_id(hm.getWxConfigId());
ServiceResponse<Void> updateResp = this.qywxChatApiService.updateJoinWay(qwDTO.getDkCorpid(),
secretSetting.getSecretVal(), joinDTO);
secretSetting.getSecretVal(), joinDTO,qwDTO.getUrlHost());
if (!updateResp.isSuccess()) {
return ServiceResponse.failure("9999", updateResp.getMessage());
}
......@@ -339,14 +352,14 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
} else {
ServiceResponse<String> addResp = this.qywxChatApiService.addJoinWay(qwDTO.getDkCorpid(),
secretSetting.getSecretVal(), joinDTO);
secretSetting.getSecretVal(), joinDTO,qwDTO.getUrlHost());
logger.info("addResp={}", JSON.toJSONString(addResp));
if (!addResp.isSuccess()) {
return ServiceResponse.failure("9999", addResp.getMessage());
}
String configId = addResp.getResult();
ServiceResponse<AddJoinWayDTO> getResp = this.qywxChatApiService.getJoinWay(qwDTO.getDkCorpid(),
secretSetting.getSecretVal(), configId);
secretSetting.getSecretVal(), configId,qwDTO.getUrlHost());
logger.info("getResp={}", JSON.toJSONString(getResp));
if (!getResp.isSuccess()) {
return ServiceResponse.failure("9999", getResp.getMessage());
......
......@@ -346,6 +346,7 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
sendResp = qywxSendService.sendChatMessage(wxEnterpriseId, staffId,
materialList,message);
}
logger.info("sendResp={}",JSON.toJSONString(sendResp));
if (sendResp.isSuccess()) {
String msgid = sendResp.getResult();
ownerLog.setMsgid(msgid);
......@@ -363,7 +364,7 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
this.savePendTask(ownerLog, plan);
}
} catch (Exception e) {
logger.info("群群发任务异常,ownerLog={}", ownerLog.getOwnerLogId());
logger.info("群群发任务异常,ownerLog={},{}", ownerLog.getOwnerLogId(),e.getMessage());
}
}
}
......@@ -429,8 +430,14 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
if (qwDTO.needOpenUserId3th()) {
userid = staff.getWxOpenUseId();
}
JSONResponse respon = qywxSuiteApiService.resultExternalMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(),
msgid, null, userid);
JSONResponse respon = null ;
if(qwDTO.isSelf()) {
respon = qywxSuiteApiService.resultExternalMessageSelf(qwDTO.getThirdCorpid(), qwDTO.getSelfSecret(),
msgid, null, userid , qwDTO.getUrlHost());
}else {
respon = qywxSuiteApiService.resultExternalMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(),
msgid, null, userid);
}
logger.info("统计企微返回={}", JSON.toJSONString(respon));
if (respon.getErrorCode() != 0) {
return;
......
......@@ -530,8 +530,8 @@ public class GroupChatServiceImpl implements GroupChatService {
private void syncGroupChatList(WxEnterpriseQwDTO qwDTO, List<String> userIdList, String cursor,
boolean syncDetailFlag) {
logger.info("同步群列表={},idlist={},cursor={}", JSON.toJSONString(qwDTO), JSON.toJSONString(userIdList), cursor);
ServiceResponse<GroupChatListDTO> resp = this.qywxChatApiService.groupchatList3th(qwDTO.getThirdCorpid(),
config.getWxSuiteid(), userIdList, limit, cursor);
ServiceResponse<GroupChatListDTO> resp = this.qywxChatApiService.groupchatList(qwDTO.getThirdCorpid(),
qwDTO.getSelf3thSecret() , userIdList, limit, cursor , qwDTO.isSelf(), qwDTO.getUrlHost());
if (!resp.isSuccess()) {
logger.info("拉取群列表异常={}", JSON.toJSON(resp));
return;
......@@ -581,6 +581,9 @@ public class GroupChatServiceImpl implements GroupChatService {
chat.setGicFlag(1);
}
chat.setWxChatId(wxChatId);
if(qwDTO.isSelf()) {
chat.setWxChatIdDk(wxChatId);
}
chat.setChatStatus(chatStatus);
chat.setCreateTime(new Date());
chat.setUpdateTime(new Date());
......@@ -615,7 +618,8 @@ public class GroupChatServiceImpl implements GroupChatService {
String wxEnterpriseId = chat.getWxEnterpriseId();
String enterpriseId = chat.getEnterpriseId();
ServiceResponse<GroupChatDetailDTO> detailResp = this.qywxChatApiService
.groupchatDetail3th(qwDTO.getThirdCorpid(), config.getWxSuiteid(), chat.getWxChatId(), 1);
.groupchatDetail(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), chat.getWxChatId(), 1 , qwDTO.isSelf() , qwDTO.getUrlHost());
logger.info("从企微获取群详情{}={}", chat.getWxChatId(), JSON.toJSON(detailResp));
if (!detailResp.isSuccess()) {
logger.info("从企微获取群详情失败");
......@@ -983,7 +987,7 @@ public class GroupChatServiceImpl implements GroupChatService {
private void updateWxChatIdDk(WxEnterpriseQwDTO qwDTO, List<String> userIdList, String cursor, String staffId,
String secret) {
ServiceResponse<GroupChatListDTO> resp = this.qywxChatApiService.groupchatList(qwDTO.getDkCorpid(), secret,
userIdList, limit, cursor);
userIdList, limit, cursor ,true , qwDTO.getUrlHost());
if (!resp.isSuccess()) {
logger.info("拉取群异常={}", JSON.toJSON(resp));
return;
......@@ -994,7 +998,7 @@ public class GroupChatServiceImpl implements GroupChatService {
for (GroupChatListItemDTO item : list) {
String wxChatIdDk = item.getChat_id();
ServiceResponse<GroupChatDetailDTO> detailResp = this.qywxChatApiService
.groupchatDetail(qwDTO.getDkCorpid(), secret, wxChatIdDk, 1);
.groupchatDetail(qwDTO.getDkCorpid(), secret, wxChatIdDk, 1 , true , qwDTO.getUrlHost());
if (detailResp.isSuccess()) {
GroupChatDetailDTO detail = detailResp.getResult();
Long createTimeLong = detail.getCreate_time() * 1000;
......@@ -1092,8 +1096,8 @@ public class GroupChatServiceImpl implements GroupChatService {
}
List<TabGroupChat> list = this.groupChatMapper.listByIdSet(new HashSet<>(groupChatIdList));
List<String> wxChatIdList = list.stream().map(dto -> dto.getWxChatId()).collect(Collectors.toList());
ServiceResponse<List<FailChatListDTO>> resp = this.qywxChatApiService.transfer(qwDTO.getThirdCorpid(),
config.getWxSuiteid(), wxChatIdList, userid);
ServiceResponse<List<FailChatListDTO>> resp = this.qywxChatApiService.transfer(qwDTO.getThirdCorpid(),
qwDTO.getSelf3thSecret(), wxChatIdList, userid,qwDTO.isSelf(),qwDTO.getUrlHost());
logger.info("群继承,继承人={}", JSON.toJSONString(resp), userid);
if (!resp.isSuccess()) {
return ServiceResponse.failure("9999", resp.getMessage());
......
......@@ -83,12 +83,17 @@ public class MaterialReportBuilder {
if (context.getStaffClerkRelations().size() == 1) {
StaffClerkRelationDTO staffClerkRelationDTO = context.getStaffClerkRelations().get(0);
if (staffClerkRelationDTO.getClerkType() != null && staffClerkRelationDTO.getClerkType() == 2) {
log.info("成员clerId:{}, staffId: {} 为区经角色", staffClerkRelationDTO.getClerkId(), staffClerkRelationDTO.getStaffId());
log.info("成员clerkId:{}, staffId: {} 为区经角色", staffClerkRelationDTO.getClerkId(), staffClerkRelationDTO.getStaffId());
// 区经无主门店
context.setClerkId(staffClerkRelationDTO.getClerkId());
// 是区经角色
context.setManager(true);
return;
}
}
log.info("成员{}为导购角色", context.getStaffId());
context.setManager(false);
// 获取成员主门店
TabHaobanClerkMainStoreRelated mainStoreInfo = clerkMainStoreRelatedService.getMainStoreByStaffId(context.getStaffId(), context.getStaffInfo().getWxEnterpriseId());
if (mainStoreInfo != null) {
context.setMainStoreId(mainStoreInfo.getStoreId());
......@@ -97,7 +102,7 @@ public class MaterialReportBuilder {
.filter(item -> StringUtils.equals(item.getStoreId(), mainStoreInfo.getStoreId()))
.findFirst();
if (!mainClerkInfo.isPresent()) {
log.info("成员{}与主门店{}不存在导购关联关系", context.getStaffId(), context.getMainStoreId());
log.info("成员{}的主门店{}不在当前企业{}的绑定关系中", context.getStaffId(), context.getMainStoreId(), context.getEnterpriseId());
return;
}
// 成员在主门店时的clerkId
......@@ -112,6 +117,10 @@ public class MaterialReportBuilder {
*/
public void buildMaterialReportData(MaterialReportContext context) {
// 获取该导购/店长/区经 的周报/月报数据
if (StringUtils.isBlank(context.getClerkId())) {
log.info("成员{} 默认主门店的clerkId不存在 不发送应用消息", context.getStaffId());
return;
}
String clerkId = context.getClerkId();
String enterpriseId = context.getEnterpriseId();
MaterialDataAdaptor.MaterialDataResult materialDataResult;
......@@ -187,12 +196,13 @@ public class MaterialReportBuilder {
newsSendMessage.setAgentId(Integer.parseInt(wxEnterpriseQwDTO.getAgentId()));
newsSendMessage.setUserIds(Collections.singletonList(wxUserId));
QywxNewsArticleMessageDTO articleInfo = new QywxNewsArticleMessageDTO();
articleInfo.setAppid(config.getAppid());
articleInfo.setAppid(wxEnterpriseQwDTO.getHbWxaAppid());
articleInfo.setTitle(context.getMessageTitle());
articleInfo.setDescription(context.getMessageDesc());
final NoticeMessageTypeEnum noticeMessageTypeEnum = MaterialReportType.WEEK.getCode().equals(context.getReportType()) ? NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY_WEEK : NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY_MONTH;
String extendParams = StringUtils.isNotBlank(context.getMainStoreId()) ? context.getMainStoreId() : context.getEnterpriseId();
articleInfo.setPagepath(NoticeMessageUtil.buildMiniAppUrl(noticeMessageTypeEnum, context.extendParams(context.getMainStoreId())));
final NoticeMessageTypeEnum noticeMessageTypeEnum = MaterialReportType.WEEK.getCode().equals(context.getReportType()) ? NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY_WEEK : NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY_MONTH;
articleInfo.setPagepath(NoticeMessageUtil.buildMiniAppUrl(noticeMessageTypeEnum, context.extendParams(extendParams)));
articleInfo.setPicurl(context.getMaterialReportUrl());
newsSendMessage.setArticleMessages(Collections.singletonList(articleInfo));
return newsSendMessage;
......
......@@ -198,7 +198,7 @@ public class PotentialCustomerNotifyBuilder {
/* 消息中心修改此处
QywxXcxSendMessageDTO messageDTO = this.buildApplicationMessage(staffClerkRelation, wxEnterpriseQwDTO,
customerStaticsBOMap.get(staffClerkRelation.getClerkId()).getNum(), context.buildExtendParams(staffClerkRelation.getStoreId(), staffClerkRelation.getClerkId()));
boolean sendMessage = qywxSuiteApiService.sendMessage(wxEnterpriseQwDTO.getThirdCorpid(), config.getWxSuiteid(), messageDTO);
boolean sendMessage = qywxSuiteApiService.sendMessage(wxEnterpriseQwDTO.getThirdCorpid(), wxEnterpriseQwDTO.getSelf3thSecret(), messageDTO,wxEnterpriseQwDTO.isSelf(),wxEnterpriseQwDTO.getUrlHost());
log.info("发送销售线索应用消息结果 {}", sendMessage);*/
Map<String, String> variableMap = new HashMap<>();
variableMap.put("memberNum", customerStaticsBOMap.get(staffClerkRelation.getClerkId()).getNum().toString());
......@@ -228,7 +228,7 @@ public class PotentialCustomerNotifyBuilder {
itemDTO.setValue(String.format("新增%s个客户的销售线索,请及时跟进", count));
ArrayList<String> list = new ArrayList<>();
list.add(wxUserId);
messageDTO.setAppid(config.getAppid());
messageDTO.setAppid(wxEnterpriseQwDTO.getHbWxaAppid());
messageDTO.setUserIds(list);
messageDTO.setPage(NoticeMessageUtil.buildMiniAppUrl(NoticeMessageTypeEnum.POTENTIAL_CUSTOMER_NOTIFY, extendParams));
messageDTO.setTitle("销售线索通知");
......
......@@ -20,12 +20,14 @@ import com.gic.haoban.manage.service.service.content.MaterialReportService;
import com.gic.haoban.manage.service.service.content.adaptor.MaterialReportBuilder;
import com.gic.haoban.manage.service.service.message.NoticeMessageHandler;
import com.gic.haoban.manage.service.service.notify.NoticeMessageService;
import com.gic.haoban.manage.service.util.ApolloUtils;
import com.gic.message.center.api.subscribe.model.NoticeMessageForm;
import com.gic.wechat.api.dto.qywx.QywxNewsArticleMessageDTO;
import com.gic.wechat.api.dto.qywx.QywxNewsSendMessageDTO;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -107,6 +109,11 @@ public class MaterialReportServiceImpl implements MaterialReportService {
if (CollectionUtils.isNotEmpty(noticeMessageBos)) {
noticeMessageService.addNoticeMessageBatch(noticeMessageBos);
}*/
}
if (StringUtils.isBlank(context.getClerkId())) {
log.info("成员{}在企业{}中不存在主门店, 不推送企微应用消息", staffId, enterpriseId);
return;
}
// 发送企微消息
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(staffInfo.getWxEnterpriseId());
QywxNewsSendMessageDTO newsSendMessageDTO = materialReportBuilder.buildQywxNewsMessage(context, qwDTO);
......@@ -116,9 +123,16 @@ public class MaterialReportServiceImpl implements MaterialReportService {
}
log.info("发送企业图文消息参数{}", JSON.toJSONString(newsSendMessageDTO));
/*消息中心修改此处
/*消息中心修改此处*/
if (!ApolloUtils.useMessageCenter()){
log.info("消息中心-走老版消息通知");
/*消息中心修改此处*/
if (CollectionUtils.isNotEmpty(noticeMessageBos)) {
noticeMessageService.addNoticeMessageBatch(noticeMessageBos);
}
}
boolean result = qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(), newsSendMessageDTO);
log.info("成员{}发送素材企微使用报告结果 {}", staffId, result);*/
log.info("成员{}发送素材企微使用报告结果 {}", staffId, result);
Map<String, String> variableMap = new HashMap<>();
QywxNewsArticleMessageDTO qywxNewsArticleMessageDTO = newsSendMessageDTO.getArticleMessages().get(0);
variableMap.put("image", qywxNewsArticleMessageDTO.getPicurl());
......@@ -147,5 +161,7 @@ public class MaterialReportServiceImpl implements MaterialReportService {
.userIdList(context.getClerkId() == null ? new ArrayList<>() : Collections.singletonList(context.getClerkId()))
.variableMap(variableMap).build());
boolean result = qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), newsSendMessageDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
log.info("成员{}发送素材企微使用报告结果 {}", staffId, result);
}
}
......@@ -11,10 +11,12 @@ import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.hm.HmQrcodeTempMapper;
import com.gic.haoban.manage.service.entity.hm.TabHmQrcodeTemp;
import com.gic.haoban.manage.service.pojo.qo.HmQrcodeTempQO;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.hm.HmQrcodeTempService;
import com.gic.wechat.api.dto.qywx.response.QywxResponseDTO;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
......@@ -30,6 +32,8 @@ public class HmQrcodeTempServiceImpl implements HmQrcodeTempService {
private QywxUserApiService qywxUserApiService;
@Autowired
private Config config;
@Autowired
private WxEnterpriseService wxEnterpriseService ;
@Override
public void save(HmQrcodeTempQO qo) {
......@@ -54,10 +58,10 @@ public class HmQrcodeTempServiceImpl implements HmQrcodeTempService {
private void del(TabHmQrcodeTemp item) {
try {
String suiteId = config.getWxSuiteid();
String corpid = item.getCorpid();
String configId = item.getWxConfigId();
QywxResponseDTO resp = this.qywxUserApiService.delContactWay(corpid, suiteId, configId);
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(item.getWxEnterpriseId());
QywxResponseDTO resp = qywxUserApiService.delContactWay(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), configId,qwDTO.isSelf(),qwDTO.getUrlHost());
log.info("删除临时活码={}{},返回={}", configId, corpid, JSON.toJSONString(resp));
this.hmQrcodeTempMapper.deleteByPrimaryKey(item.getId());
} catch (Exception e) {
......
......@@ -42,11 +42,16 @@ public class ClerkMainStoreRelatedServiceImpl implements ClerkMainStoreRelatedSe
@Autowired
private StaffService staffService;
@Override
public TabHaobanClerkMainStoreRelated selectByWxEnterpriseIdAndStoreId(String staffId, String wxEnterpriseId) {
return mapper.selectByWxEnterpriseIdAndStoreId(staffId, wxEnterpriseId, null);
}
@Override
public TabHaobanClerkMainStoreRelated selectStaffMainStore(String staffId, String wxEnterpriseId) {
return mapper.selectByWxEnterpriseIdAndStoreId(staffId, wxEnterpriseId, null);
}
@Override
public void setMainStore(String staffId, String storeId, String wxEnterpriseId) {
......@@ -55,7 +60,6 @@ public class ClerkMainStoreRelatedServiceImpl implements ClerkMainStoreRelatedSe
logger.info("区经无需设置主门店:{}", staffId);
return;
}
String uuId = com.gic.haoban.common.utils.StringUtil.randomUUID();
Date now = new Date();
TabHaobanClerkMainStoreRelated t = new TabHaobanClerkMainStoreRelated();
......@@ -68,9 +72,10 @@ public class ClerkMainStoreRelatedServiceImpl implements ClerkMainStoreRelatedSe
t.setFreshFriendFlag(1);
t.setClerkMainStoreRelatedId(uuId);
mapper.insert(t);
logger.info("切换主门店-刷新企业微信好友:{},{}", staffId, storeId);
//主门店切换需要刷新企业微信好友
}
@Override
public void reflushExternal(String wxEnterpriseId ,String staffId) {
TabHaobanStaff staff = staffService.selectById(staffId);
if (staff == null) {
logger.info("员工不存在:{}", staffId);
......@@ -79,21 +84,16 @@ public class ClerkMainStoreRelatedServiceImpl implements ClerkMainStoreRelatedSe
String taskName = "自动刷新企业微信好友(" + staff.getStaffName() + ")";
String taskId = dealSyncOperationApiService.createWxFriendTaskSingle(wxEnterpriseId, taskName, staffId, staff.getStaffName(), SyncTaskTypeEnum.FRIEND_SINGLE.getType());
if (StringUtils.isBlank(taskId)) {
logger.info("刷新好友失败或正在刷新:{},{}", staffId, storeId);
logger.info("刷新好友失败或正在刷新:{},{}", staffId);
return;
}
dealSyncOperationApiService.dealWxFriendClerkSingle(taskId, staffId, staffId, wxEnterpriseId);
logger.info("任务id:{}", taskId);
logger.info("开始自动刷新好友任务id={},staffId={}", taskId,staffId);
}
@Override
public TabHaobanClerkMainStoreRelated getMainStoreByStaffId(String staffId, String wxEnterpriseId) {
TabHaobanClerkMainStoreRelated mainStoreRelated = mapper.selectByWxEnterpriseIdAndStoreId(staffId, wxEnterpriseId, null);
if (null != mainStoreRelated) {
return mainStoreRelated;
}
return setStaffMainStore(staffId, wxEnterpriseId, null);
return this.getMainStoreByStaffId(staffId, wxEnterpriseId,null);
}
@Override
......
......@@ -96,7 +96,7 @@ public class HandoverServiceImpl implements HandoverService {
Map<String, List<QywxUnassignedInfoDTO>> handoverUserMap = infoList.stream().collect(Collectors.groupingBy(dto -> dto.getHandoverUserid()));
handoverUserMap.forEach((userId, list) -> {
boolean checkFlag = checkStaffOver(secretSetting, userId, qwDTO.getDkCorpid());
boolean checkFlag = checkStaffOver(secretSetting, userId, qwDTO.getDkCorpid() ,qwDTO);
if (checkFlag) {
logger.info("该用户存在,不需要离职基础:{},{}", userId, wxEnterpriseId);
return;
......@@ -144,8 +144,8 @@ public class HandoverServiceImpl implements HandoverService {
return false;
}
private boolean checkStaffOver(SecretSettingDTO secretSetting, String userId, String corpId) {
UserDTO user = qywxUserApiService.getSelfWorkWxUser(corpId, secretSetting.getSecretVal(), userId);
private boolean checkStaffOver(SecretSettingDTO secretSetting, String userId, String corpId,WxEnterpriseQwDTO qwDTO) {
UserDTO user = qywxUserApiService.getSelfWorkWxUser(corpId, secretSetting.getSecretVal(), userId , qwDTO.getUrlHost());
if (null == user) {
return false;
}
......
......@@ -27,7 +27,6 @@ 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;
......@@ -216,6 +215,7 @@ public class MaterialServiceImpl implements MaterialService {
arr = url.split("/");
}
int count = arr.length;
boolean selfFlag = qwDTO.isSelf() ;
if(qwUploadFrom==2) {
// 朋友圈上传接口
if (type == 2) {
......@@ -226,10 +226,10 @@ public class MaterialServiceImpl implements MaterialService {
url+= "?imageView2/2/w/1440/h/1080" ;
logger.info("url={}",url);
}
jp = qywxSuiteApiService.uploadAttachment(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode());
jp = qywxSuiteApiService.uploadAttachment(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), url, arr[count - 1], fileType.getCode() , selfFlag , qwDTO.getUrlHost());
}else {
// 群发上传
jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode());
jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), url, arr[count - 1], fileType.getCode() , selfFlag , qwDTO.getUrlHost());
}
if (jp.getErrorCode() == 0) {
if(from==1) {
......
......@@ -164,7 +164,7 @@ public class PreDealServiceImpl implements PreDealService {
}
@Override
public TabHaobanPreDealLog getByRelationKey(String taskId, Integer dataType, String relationKey) {
public List<TabHaobanPreDealLog> getByRelationKey(String taskId, Integer dataType, String relationKey) {
return preDealLogMapper.getByRelationKey(taskId, dataType, relationKey);
}
......
......@@ -107,8 +107,14 @@ public class QywxSendServiceImpl implements QywxSendService {
messageDTO.setSenderUserId(tabHaobanStaff.getWxUserId());
}
// 调接口执行创建群发
JSONResponse respon = qywxSuiteApiService.sendExternalMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(),
messageDTO);
JSONResponse respon = null ;
if(qwDTO.isSelf()) {
respon = qywxSuiteApiService.sendExternalMessageSelf(qwDTO.getThirdCorpid(), qwDTO.getSelfSecret(),
messageDTO , qwDTO.getUrlHost());
}else {
respon = qywxSuiteApiService.sendExternalMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(),
messageDTO);
}
log.info("群发返回={}", JSON.toJSONString(respon));
Map<String, Object> returnMap = respon.getReturnMap();
String msgIdKey = "msgid";
......@@ -154,7 +160,7 @@ public class QywxSendServiceImpl implements QywxSendService {
range.setSender_list(senderList);
moment.setVisible_range(range);
ServiceResponse<String> resp = this.qywxExternalUserService.addMomentTask(qwDTO.getThirdCorpid(),
config.getWxSuiteid(), moment);
qwDTO.getSelf3thSecret(), moment,qwDTO.isSelf(),qwDTO.getUrlHost());
log.info("朋友圈消息={},返回={}", JSON.toJSONString(moment), JSON.toJSONString(resp));
return resp;
}
......
package com.gic.haoban.manage.service.service.impl;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.ToolUtil;
import com.gic.haoban.manage.api.dto.SecretSettingDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.service.dao.mapper.SecretSettingMapper;
import com.gic.haoban.manage.service.entity.TabSecretSetting;
import com.gic.haoban.manage.service.service.SecretSettingService;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
/**
* Created 2020/6/3.
......@@ -29,6 +31,8 @@ public class SecretSettingServiceImpl implements SecretSettingService {
@Autowired
private SecretSettingMapper secretSettingMapper;
@Autowired
private WxEnterpriseService wxEnterpriseService ;
@Override
public boolean saveSecretSetting(SecretSettingDTO secretSetting) {
......@@ -68,6 +72,11 @@ public class SecretSettingServiceImpl implements SecretSettingService {
logger.info("会员小程序配置使用getMemberSecretSetting接口");
return null;
}
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
// 如果是纯自建,使用自建的token
if(qwDTO.isSelf()) {
secretType = SecretTypeEnum.SELF_APP.getVal() ;
}
TabSecretSetting secretSetting = secretSettingMapper.getSecretSetting(wxEnterpriseId, secretType, null);
return EntityUtil.changeEntityByJSON(SecretSettingDTO.class, secretSetting);
}
......
......@@ -147,7 +147,7 @@ public class StaffDepartmentRelatedServiceImpl implements StaffDepartmentRelated
}
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(qwDTO.getWxEnterpriseId(), SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (null != secretSetting && StringUtils.isNotBlank(secretSetting.getSecretVal())) {
UserDTO user = qywxUserApiService.getSelfWorkWxUser(qwDTO.getDkCorpid(), secretSetting.getSecretVal(), wxUserId);
UserDTO user = qywxUserApiService.getSelfWorkWxUser(qwDTO.getDkCorpid(), secretSetting.getSecretVal(), wxUserId, qwDTO.getUrlHost());
logger.info("成员详情(代开)={}",JSON.toJSONString(user)) ;
if(null != user && null != user.getDepartment()) {
this.staffDepartChange(staff, wxEnterpriseId, user.getDepartment(),false); ;
......
package com.gic.haoban.manage.service.service.impl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
......@@ -20,6 +19,9 @@ import com.gic.haoban.common.utils.DingUtils;
import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.SecretSettingMapper;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanStaffClerkRelationMapper;
import com.gic.haoban.manage.service.dao.mapper.WxApplicationMapper;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper;
......@@ -27,6 +29,7 @@ import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseRelatedMapper;
import com.gic.haoban.manage.service.entity.TabHaobanWxApplication;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated;
import com.gic.haoban.manage.service.entity.TabSecretSetting;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
@Service
......@@ -41,6 +44,10 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService {
private WxApplicationMapper wxApplicationMapper ;
@Autowired
private TabHaobanStaffClerkRelationMapper tabHaobanStaffClerkRelationMapper ;
@Autowired
private SecretSettingMapper secretSettingMapper;
@Autowired
private Config config;
@Override
public String add(WxEnterpriseDTO wxDTO) {
......@@ -98,10 +105,41 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService {
qw.setMemberCorpid(wxEnterprise.getWxCorpid());
}
}
if(qw.getWxSecurityType()==5) {
qw.setUrlHost(wxEnterprise.getUrlHost());
qw.setDkCorpid(wxEnterprise.getWxCorpid());
qw.setThirdCorpid(wxEnterprise.getWxCorpid());
qw.setMemberCorpid(wxEnterprise.getWxCorpid());
TabSecretSetting secret = secretSettingMapper.getSecretSetting(wxEnterpriseId, SecretTypeEnum.SELF_APP.getVal(), null);
if(null != secret) {
qw.setSelfSecret(secret.getSecretVal());
qw.setAgentId(secret.getAgentId());
qw.setAgentName(secret.getAgentName());
}
qw.setSelfAppid(wxEnterprise.getWxaAppid());
}
qw.setHbWxaAppid(this.getHbAppid(qw, config.getAppid()));
qw.setSelf3thSecret(this.getSecret(qw, config.getWxSuiteid()));
logger.info("企微所有corpid信息={}",JSON.toJSON(qw));
return qw;
}
public String getSecret(WxEnterpriseQwDTO qwDTO, String suiteId) {
String secret = suiteId;
if (qwDTO.isSelf()) {
secret = qwDTO.getSelfSecret();
}
return secret;
}
public String getHbAppid(WxEnterpriseQwDTO qwDTO, String thirdAppid) {
String appid = thirdAppid;
if (qwDTO.isSelf()) {
appid = qwDTO.getSelfAppid();
}
return appid;
}
@Override
public TabHaobanWxEnterprise getEnterpriseBycorpId(String corpId) {
if (StringUtils.isBlank(corpId)) {
......@@ -175,6 +213,10 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService {
@Override
public void updateWxSecurityType(String wxEnterpriseId) {
WxEnterpriseQwDTO qwDTO = this.getQwInfo(wxEnterpriseId) ;
if(qwDTO.isSelf()) {
return ;
}
int wxSecurityType = this.calcSecretType(wxEnterpriseId);
if(wxSecurityType < 1 || wxSecurityType > 4) {
return ;
......
......@@ -112,7 +112,7 @@ public interface LicenceOrderService {
* @param qywxOrderId
* @return
*/
Integer saveQywxOrderId(Long orderId, String qywxOrderId);
Integer saveQywxOrderId(Long orderId, String qywxOrderId,Date qywxExpireTime);
/**
* 查询订单编号id
......
......@@ -77,27 +77,31 @@ public class LicenceOrderServiceImpl implements LicenceOrderService {
@Transactional(rollbackFor = Exception.class)
public String saveOrUpdateLicenceOrder(LicenceOrderQDTO licenceOrderQDTO) {
long orderId = UniqueIdUtils.uniqueLong();
//订单不支持修改,只能新增
TabHaobanLicenceOrder order = JSONObject.parseObject(JSONObject.toJSONString(licenceOrderQDTO), TabHaobanLicenceOrder.class);
Date now = new Date();
order.setOrderId(orderId);
//默认支付状态为待支付
order.setOrderStatus(0);
order.setCreateTime(now);
order.setUpdateTime(now);
//生成订单编号
String num = "ZH"+orderId;
order.setOrderNumber(num);
Date expireTime;
if(order.getPayType()==1){
expireTime = DateUtil.addNumForMinute(now, 30);
}else {
expireTime = DateUtil.addDay(now, 3);
}
order.setExpireTime(expireTime);
tabHaobanLicenceOrderMapper.insert(order);
//记录订单进度
saveOrderProgress(orderId,"创建订单",licenceOrderQDTO.getEnterpriseId(),licenceOrderQDTO.getWxEnterpriseId(),licenceOrderQDTO.getCreatorName(),1,null,null);
//订单不支持修改,只能新增
TabHaobanLicenceOrder order = JSONObject.parseObject(JSONObject.toJSONString(licenceOrderQDTO), TabHaobanLicenceOrder.class);
Date now = new Date();
order.setOrderId(orderId);
//默认支付状态为待支付
order.setOrderStatus(0);
order.setQywxOrderStatus(0);
order.setCreateTime(now);
order.setUpdateTime(now);
order.setQywxExpireTime(DateUtil.addDay(now, 10));
//生成订单编号
String num = "ZH"+orderId;
order.setOrderNumber(num);
Date expireTime;
if(order.getPayType()==1){
expireTime = DateUtil.addNumForMinute(now, 30);
}else {
expireTime = DateUtil.addDay(now, 3);
}
order.setExpireTime(expireTime);
tabHaobanLicenceOrderMapper.insert(order);
//记录订单进度
saveOrderProgress(orderId,"创建订单",licenceOrderQDTO.getEnterpriseId(),licenceOrderQDTO.getWxEnterpriseId(),licenceOrderQDTO.getCreatorName(),1,null,null);
//记录企业微信订单进度
saveOrderProgress(orderId,"创建订单",licenceOrderQDTO.getEnterpriseId(),licenceOrderQDTO.getWxEnterpriseId(),licenceOrderQDTO.getCreatorName(),2,null,null);
return String.valueOf(orderId);
}
......@@ -223,13 +227,6 @@ public class LicenceOrderServiceImpl implements LicenceOrderService {
}
PageHelper.startPage(qdto);
List<TabHaobanLicenceOrder> licenceOrderPage = tabHaobanLicenceOrderMapper.getLicenceOrderPage(qdto);
//判断订单状态,支付时间已过的订单的需要更改订单状态为已过期
for (TabHaobanLicenceOrder dto : licenceOrderPage){
if (dto.getExpireTime().before(new Date()) && dto.getOrderStatus() == 0){
dto.setOrderStatus(3);
updateLicenceOrderType(dto.getOrderId(), 3,dto.getEnterpriseId(), dto.getWxEnterpriseId(), "系统",1);
}
}
return PageHelperUtils.changePageHelperToCurrentPage(licenceOrderPage, LicenceOrderPageDTO.class);
}
......@@ -250,8 +247,8 @@ public class LicenceOrderServiceImpl implements LicenceOrderService {
}
@Override
public Integer saveQywxOrderId(Long orderId, String qywxOrderId) {
return tabHaobanLicenceOrderMapper.saveQywxOrderId(orderId,qywxOrderId);
public Integer saveQywxOrderId(Long orderId, String qywxOrderId,Date qywxExpireTime) {
return tabHaobanLicenceOrderMapper.saveQywxOrderId(orderId,qywxOrderId,qywxExpireTime);
}
@Override
......
......@@ -106,7 +106,6 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
public void noticeMessageMq(String json) {
logger.info("通知消息:{}", json);
NoticeMessageQDTO messageQDTO = JSONObject.parseObject(json, NoticeMessageQDTO.class);
NoticeMessageTypeEnum messageTypeEnum = NoticeMessageTypeEnum.getByType(messageQDTO.getMessageType());
if (messageTypeEnum == null) {
logger.error("无消息模板:{}", json);
......@@ -244,7 +243,6 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
logger.info("成员关联列表为空");
return ServiceResponse.success();
}
NoticeMessageTypeEnum messageTypeEnum = NoticeMessageTypeEnum.getByType(notifyMessageBatchQDTO.getMessageType());
if (messageTypeEnum == null) {
logger.error("无消息模板:{}", JSON.toJSONString(notifyMessageBatchQDTO));
......@@ -397,15 +395,14 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
appUrl += messageTypeEnum.getPageType();
}
appUrl += "&data=" + data;
messageDTO.setAppid(config.getAppid());
messageDTO.setAppid(qwDTO.getHbWxaAppid());
messageDTO.setAgentId(Integer.parseInt(qwDTO.getAgentId()));
messageDTO.setAgentName(qwDTO.getAgentName());
messageDTO.setUserIds(wxUserIdList);
messageDTO.setPage(appUrl);
messageDTO.setTitle(StringUtils.isNotBlank(title)?title: messageTypeEnum.getName());
messageDTO.setContent(contentList.get(0).getVal());
boolean sendMessage = qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(), messageDTO);
boolean sendMessage = qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), messageDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
NotifyMessageMQDTO mqdto = new NotifyMessageMQDTO();
List<String> clerkIdList = list.stream().map(StaffClerkRelationDTO::getClerkId).collect(Collectors.toList());
mqdto.setClerkIdList(clerkIdList);
......@@ -558,11 +555,11 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
List<String> userList = new ArrayList<>();
userList.add(wxUserId);
messageDTO.setAppid(config.getAppid());
messageDTO.setAppid(qwDTO.getHbWxaAppid());
messageDTO.setUserIds(userList);
messageDTO.setPage(appUrl);
messageDTO.setTitle(StringUtils.isNotBlank(title)?title:messageTypeEnum.getName());
messageDTO.setItems(items);
qywxSuiteApiService.sendMessage(corpid, config.getWxSuiteid(), messageDTO);
qywxSuiteApiService.sendMessage(corpid, qwDTO.getSelf3thSecret(), messageDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
}
}
......@@ -23,9 +23,10 @@ public class ClerkMainStoreRelatedApiServiceImpl implements ClerkMainStoreRelate
@Override
public void setMainStore(String staffId, String storeId, String wxEnterpriseId) {
TabHaobanClerkMainStoreRelated related = clerkMainStoreRelatedService.selectByWxEnterpriseIdAndStoreId(staffId, wxEnterpriseId);
TabHaobanClerkMainStoreRelated related = clerkMainStoreRelatedService.selectStaffMainStore(staffId, wxEnterpriseId);
if (related == null) {
clerkMainStoreRelatedService.setMainStore(staffId, storeId, wxEnterpriseId);
this.clerkMainStoreRelatedService.setMainStore(staffId, storeId, wxEnterpriseId);
this.clerkMainStoreRelatedService.reflushExternal(wxEnterpriseId, staffId);
} else if (null != related && (!related.getStoreId().equals(storeId))) {
related.setStatusFlag(0);
related.setUpdateTime(new Date());
......
......@@ -535,7 +535,7 @@ public class DealSyncOperationApiServiceImpl implements DealSyncOperationApiServ
unlockTask(wxEnterpriseId);
return "没有配置secret";
}
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = qywxDepartmentApiService.listSelfDepartment(qwDTO.getDkCorpid(), secretSetting.getSecretVal(), 1);
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = qywxDepartmentApiService.listSelfDepartment(qwDTO.getDkCorpid(), secretSetting.getSecretVal(), 1,qwDTO.getUrlHost());
if (CollectionUtils.isEmpty(list)) {
logger.info("没有数据同步");
syncTaskService.updateTaskStatus(taskId, SyncTaskStatusEnum.exception_close.getVal());
......
......@@ -13,6 +13,7 @@ import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.DepartmentShortDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
......@@ -207,7 +208,8 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
if (RedisUtil.getCache(key) == null) {
RedisUtil.setCache(key, 1, 60 * 60L);
String taskId = StringUtil.randomUUID();
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService.listSelfDepartment(corpid, contactSecret, null);
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService.listSelfDepartment(corpid, contactSecret, null , qwDTO.getUrlHost());
logger.info("企业所有部门数据:{}", JSON.toJSONString(list));
if (CollectionUtils.isNotEmpty(list)) {
this.addAllDepartment(list, 0, wxEnterpriseId, corpid, contactSecret, taskId);
......@@ -225,7 +227,8 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
String corpid = json.getString("corpid");
String contactSecret = json.getString("contactSecret");
String taskId = json.getString("taskId");
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService.listSelfDepartment(corpid, contactSecret, parentId);
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService.listSelfDepartment(corpid, contactSecret, parentId,qwDTO.getUrlHost());
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> handerList = new ArrayList<>();
if (parentId.equals(0)) {
for (com.gic.wechat.api.dto.qywx.DepartmentDTO departmentDTO : list) {
......
......@@ -27,7 +27,6 @@ import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.*;
import com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated;
import com.gic.haoban.manage.service.entity.TabHaobanStaffClerkRelation;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.entity.ext.MemberStaffRelExtDO;
import com.gic.haoban.manage.service.pojo.QywxTagSyncInfoPojo;
......@@ -488,8 +487,8 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA
// }
@Override
public List<String> listMemberAndClerk(List<String> memberIdList, List<String> clerkIdList, String enterpriseId) {
List<String> list = tabHaobanExternalClerkRelatedMapper.listMemberAndClerk(memberIdList, clerkIdList, enterpriseId);
public List<String> listMemberAndStaff(List<String> memberIdList, String staffId, String enterpriseId) {
List<String> list = tabHaobanExternalClerkRelatedMapper.listMemberAndStaff(memberIdList, staffId, enterpriseId);
return list;
}
......
......@@ -104,7 +104,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
String cursor = null;
do {
//离职成员客户列表
unassignedListDTO = qywxUserApiService.getUnassignedList(qwDTO.getThirdCorpid(), config.getWxSuiteid(), cursor);
unassignedListDTO = qywxUserApiService.getUnassignedList(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), cursor , qwDTO.isSelf(),qwDTO.getUrlHost());
cursor = unassignedListDTO.getNextCursor();
if (CollectionUtils.isNotEmpty(unassignedListDTO.getInfo())) {
ret.addAll(unassignedListDTO.getInfo());
......@@ -145,7 +145,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
logger.info("takeover is null={}",dto.getTakeoverStaffId());
return;
}
QywxTransferCustomerDTO customerDTO = qywxUserApiService.transferResult(qwDTO.getThirdCorpid(), config.getWxSuiteid(), handover.getWxUserId(), takeover.getWxUserId(), true);
QywxTransferCustomerDTO customerDTO = qywxUserApiService.transferResult(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), handover.getWxUserId(), takeover.getWxUserId(), true , qwDTO.isSelf() , qwDTO.getUrlHost());
if (customerDTO.getErrcode() != 0) {
return;
}
......@@ -255,7 +255,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
for (Map.Entry<String, List<String>> entry : handoverStaffExternalMap.entrySet()) {
String wxUserId = entry.getKey();
List<String> list = entry.getValue();
QywxTransferCustomerDTO transferCustomerResp = qywxUserApiService.transferCustomer(qwDTO.getThirdCorpid(), config.getWxSuiteid(), wxUserId, takeoverUserId, list);
QywxTransferCustomerDTO transferCustomerResp = qywxUserApiService.transferCustomer(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), wxUserId, takeoverUserId, list,qwDTO.isSelf(),qwDTO.getUrlHost());
if (transferCustomerResp.getErrcode() != 0) {
logger.info("转移异常");
}
......
......@@ -15,6 +15,7 @@ import com.gic.haoban.manage.api.dto.CommonMQDTO;
import com.gic.haoban.manage.api.service.HaobanCommonMQApiService;
import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.haoban.manage.service.service.WelcomeSendService;
import com.gic.member.api.service.MemberOpenCardBusinessService;
import com.gic.mq.sdk.GicMQClient;
import com.gic.quartz.api.dto.QuartzTaskDTO;
import com.gic.quartz.api.service.QuartzService;
......@@ -32,6 +33,8 @@ public class HaobanCommonMQApiServiceImpl implements HaobanCommonMQApiService {
private StaffDepartmentRelatedService staffDepartmentRelatedService;
@Autowired
private WelcomeSendService welcomeSendService;
@Autowired
private MemberOpenCardBusinessService memberOpenCardBusinessService ;
@Override
public void putCommonMessage(CommonMQDTO dto) {
......@@ -74,6 +77,13 @@ public class HaobanCommonMQApiServiceImpl implements HaobanCommonMQApiService {
if (StringUtils.isNotBlank(staffId)) {
this.staffDepartmentRelatedService.repairStaffDepart(staffId);
}
break ;
case 3:
String memberId = map.get("memberId") ;
enterpriseId = map.get("enterpriseId") ;
String clerkId = map.get("clerkId") ;
this.memberOpenCardBusinessService.memberClerkByQywx(enterpriseId, memberId, clerkId);
break ;
default:
break;
}
......
......@@ -147,7 +147,7 @@ public class MaterialApiServiceImpl implements MaterialApiService {
if (type == 3) {
String imgUrl = materialDTO.getImgUrl();
logger.info("【上传图片】imgUrl={}", imgUrl);
JSONResponse response = qywxSuiteApiService.uploadImage(qwDTO.getThirdCorpid() , config.getWxSuiteid(), CommonUtil.getFileByte(imgUrl));
JSONResponse response = qywxSuiteApiService.uploadImage(qwDTO.getThirdCorpid() , qwDTO.getSelf3thSecret(), imgUrl , qwDTO.isSelf(),qwDTO.getUrlHost());
logger.info("【上传图片返回】response={}", JSON.toJSONString(response));
String wxImgUrl = response.getResult() == null ? "" : response.getResult().toString();
materialDTO.setWxImgUrl(wxImgUrl);
......@@ -155,7 +155,8 @@ public class MaterialApiServiceImpl implements MaterialApiService {
if (fileType != null) {
String[] arr = url.split("/");
int count = arr.length;
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid() , config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode());
boolean selfFlag = qwDTO.isSelf() ;
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid() , qwDTO.getSelf3thSecret(), url, arr[count - 1], fileType.getCode(),selfFlag,qwDTO.getUrlHost());
if (jp.getErrorCode() == 0) {
materialDTO.setWxLastUploadTime(new Date());
materialDTO.setMediaId(jp.getResult().toString());
......@@ -232,7 +233,7 @@ public class MaterialApiServiceImpl implements MaterialApiService {
String imgUrl = materialDTO.getImgUrl();
String oldImgUrl = materialDTO.getImgUrl();
if (!imgUrl.equals(oldImgUrl)) {
JSONResponse response = qywxSuiteApiService.uploadImage(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(imgUrl));
JSONResponse response = qywxSuiteApiService.uploadImage(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), imgUrl ,qwDTO.isSelf(),qwDTO.getUrlHost());
String wxImgUrl = response.getResult() == null ? "" : response.getResult().toString();
materialDTO.setWxImgUrl(wxImgUrl);
}
......@@ -240,7 +241,8 @@ public class MaterialApiServiceImpl implements MaterialApiService {
if (fileType != null && !url.equals(oldUrl)) {
String[] arr = url.split("/");
int count = arr.length;
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode());
boolean selfFlag = qwDTO.isSelf() ;
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), url , arr[count - 1], fileType.getCode(),selfFlag,qwDTO.getUrlHost());
if (jp.getErrorCode() == 0) {
materialDTO.setWxLastUploadTime(new Date());
materialDTO.setMediaId(jp.getResult().toString());
......@@ -289,7 +291,7 @@ public class MaterialApiServiceImpl implements MaterialApiService {
}
String[] arr = url.split("/");
int count = arr.length;
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode());
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), url, arr[count - 1], fileType.getCode(),qwDTO.isSelf(),qwDTO.getUrlHost());
if (jp.getErrorCode() == 0) {
old.setWxLastUploadTime(new Date());
old.setMediaId(jp.getResult().toString());
......@@ -449,7 +451,7 @@ public class MaterialApiServiceImpl implements MaterialApiService {
materialDTO.setMaterialTitle(material.getMaterialTitle());
}
materialDTO.setImgUrl(one.getMediaUrl());
String mediaId = uploadMediaToWx(qwDTO.getThirdCorpid(), one.getMediaUrl());
String mediaId = uploadMediaToWx(qwDTO.getThirdCorpid(), one.getMediaUrl(),qwDTO);
if (StringUtils.isNotEmpty(mediaId)) {
materialDTO.setWxLastUploadTime(new Date());
materialDTO.setMediaId(mediaId);
......@@ -460,12 +462,13 @@ public class MaterialApiServiceImpl implements MaterialApiService {
materialService.batchInsertMaterial(materialList);
}
private String uploadMediaToWx(String corPid, String url) {
private String uploadMediaToWx(String corPid, String url, WxEnterpriseQwDTO qwDTO) {
String[] arr = url.split("/");
// 先写死为图片类型, 以后有别的再扩展
QywxMediaTypeEnum fileType = QywxMediaTypeEnum.IMAGE;
int count = arr.length;
JSONResponse jp = qywxSuiteApiService.uploadMedia(corPid, config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode());
boolean selfFlag = qwDTO.isSelf() ;
JSONResponse jp = qywxSuiteApiService.uploadMedia(corPid, qwDTO.getSelf3thSecret(), url, arr[count - 1], fileType.getCode(),selfFlag,qwDTO.getUrlHost());
if (jp.getErrorCode() == 0) {
return jp.getResult().toString();
}
......
......@@ -62,7 +62,8 @@ public class MiniprogramSettingServiceImpl implements MiniprogramSettingService
}
String[] arr = miniprogramSetting.getImageUrl().split("/");
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(miniprogramSetting.getWxEnterpriseId()) ;
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(miniprogramSetting.getImageUrl()), arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode());
boolean selfFlag = qwDTO.isSelf() ;
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), miniprogramSetting.getImageUrl(), arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode(),selfFlag,qwDTO.getUrlHost());
if (jp.getErrorCode() == 0) {
miniprogramSetting.setMediaTime(date);
miniprogramSetting.setMediaId(jp.getResult().toString());
......@@ -116,7 +117,8 @@ public class MiniprogramSettingServiceImpl implements MiniprogramSettingService
}
String[] arr = miniprogramSetting.getImageUrl().split("/");
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(miniprogramSetting.getImageUrl()), arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode());
boolean selfFlag = qwDTO.isSelf() ;
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), miniprogramSetting.getImageUrl(), arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode(),selfFlag,qwDTO.getUrlHost());
if (jp.getErrorCode() == 0) {
miniprogramSetting.setMediaTime(date);
miniprogramSetting.setMediaId(jp.getResult().toString());
......
......@@ -196,14 +196,14 @@ public class StaffApiServiceImpl implements StaffApiService {
if (qwDTO.getWxSecurityType() == 4) {
user = qywxUserApiService.getWorkWxUser(qwDTO.getThirdCorpid(), config.getWxSuiteid(), wxUserId);
logger.info("成员详情(第三方)={}", JSON.toJSONString(user));
UserDTO userSelf = qywxUserApiService.getSelfWorkWxUser(dkCorpid, secretSetting.getSecretVal(), user.getOpen_userid());
UserDTO userSelf = qywxUserApiService.getSelfWorkWxUser(dkCorpid, secretSetting.getSecretVal(), user.getOpen_userid() , qwDTO.getUrlHost());
logger.info("成员详情(代开)={}", JSON.toJSONString(user));
if (user != null && userSelf != null) {
user.setName(userSelf.getName());
user.setPosition(userSelf.getPosition());
}
} else {
user = qywxUserApiService.getSelfWorkWxUser(dkCorpid, secretSetting.getSecretVal(), wxUserId);
user = qywxUserApiService.getSelfWorkWxUser(dkCorpid, secretSetting.getSecretVal(), wxUserId , qwDTO.getUrlHost());
logger.info("成员详情(代开)={}", JSON.toJSONString(user));
}
if (null == user) {
......@@ -255,6 +255,11 @@ public class StaffApiServiceImpl implements StaffApiService {
if (StringUtils.isNotBlank(qr_code)) {
staff.setQrCode(qr_code);
}
//判断成员是否开启联系我
if (this.openConcatFlag(wxEnterpriseId,wxUserId)) {
logger.info("成员开启联系我");
staff.setOpenConcatFlag(1);
}
//成员更改或更新
if (StringUtils.isBlank(staff.getStaffId())) {
logger.info("新增成员");
......@@ -270,6 +275,22 @@ public class StaffApiServiceImpl implements StaffApiService {
res.setResult(staff.getStaffName());
return res;
}
private Boolean openConcatFlag(String wxEnterpriseId,String userId){
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
//企微已经开启联系我
List<String> wxUserIdsList = null ;
Boolean flag = false;
if(qwDTO.isSelf()) {
wxUserIdsList = qywxUserApiService.listCorpExternalUserSelf(qwDTO.getDkCorpid(), qwDTO.getSelfSecret(),qwDTO.getUrlHost());
}else {
wxUserIdsList = qywxUserApiService.listCorpExternalUser(qwDTO.getThirdCorpid(), config.getWxSuiteid());
}
if (CollUtil.isNotEmpty(wxUserIdsList) && wxUserIdsList.contains(userId)) {
logger.info("成员开启联系我");
flag = true;
}
return flag;
}
/**
* 获取wxopenuserid
......@@ -279,6 +300,9 @@ public class StaffApiServiceImpl implements StaffApiService {
* @return
*/
private String getOpenUserid(String userId, String corpid, WxEnterpriseQwDTO qwDTO) {
if(qwDTO.isSelf()) {
return null ;
}
if (qwDTO.getWxSecurityType() == 2) {
return userId;
}
......@@ -489,7 +513,8 @@ public class StaffApiServiceImpl implements StaffApiService {
@Override
public void initWxUser(String corpid, String contactSecret, String wxEnterpriseId, Integer wxDepartmentId, String taskId) {
List<UserDTO> list = this.qywxUserApiService.listSelfDepartmentUser(corpid, contactSecret, wxDepartmentId.toString(), 0);
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
List<UserDTO> list = this.qywxUserApiService.listSelfDepartmentUser(corpid, contactSecret, wxDepartmentId.toString(), 0 , qwDTO.getUrlHost());
if (CollectionUtils.isNotEmpty(list)) {
for (UserDTO dto : list) {
try {
......
......@@ -98,12 +98,17 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
clerkName = clerkDTO.getClerkName();
}
String operClerkId = infoDTO.getOptStaffId();
//操作人只有staffId,operName字段存储成员名称
TabHaobanStaff tabHaobanStaff = staffService.selectById(operClerkId);
// clerkDTO = clerkService.getClerkByClerkIdNoStatus(clerkRelation.getClerkId());
ClerkDTO operClerkDTO = clerkService.getClerkByClerkIdNoStatus(operClerkId);
String operName = null;
if (null != tabHaobanStaff) {
operName = tabHaobanStaff.getStaffName();
if (null != operClerkDTO) {
operName = operClerkDTO.getClerkName();
}
//如果是小程序解绑,需要存储staffName
if(infoDTO.getChannelCode() != null &&(infoDTO.getChannelCode().equals(ChannelCodeEnum.SELF_UNBIND.getCode()) || infoDTO.getChannelCode().equals(ChannelCodeEnum.SELF_BIND.getCode()))){
TabHaobanStaff tabHaobanStaff = staffService.selectById(operClerkId);
if (null != tabHaobanStaff) {
operName =tabHaobanStaff.getStaffName();
}
}
TabHaobanStaffClerkBindLog enity = new TabHaobanStaffClerkBindLog();
enity.setClerkId(clerkRelation.getClerkId());
......@@ -199,23 +204,25 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
logger.info("该导购已经被被申请绑定,请审核处理后再绑定");
return ServiceResponse.failure("4", "该导购已经被被申请绑定,请审核处理后再绑定");
}
List<AuditDTO> list = auditApiService.listByStoreId(staffClerkRelationDTO.getStoreId());
if (CollectionUtils.isNotEmpty(list)) {
Set<String> staffIds = list.stream().map(AuditDTO::getCommitStaffId).collect(Collectors.toSet());
if (staffIds.contains(staffId)) {
logger.info("该成员已经已经在该门店下申请了绑定,请审核处理后再绑定");
return ServiceResponse.failure("5", "该成员已经已经在该门店下申请了绑定,请审核处理后再绑定");
if (manageFlag == null || manageFlag == 0) {
List<AuditDTO> list = auditApiService.listByStoreId(staffClerkRelationDTO.getStoreId());
if (CollectionUtils.isNotEmpty(list)) {
Set<String> staffIds = list.stream().map(AuditDTO::getCommitStaffId).collect(Collectors.toSet());
if (staffIds.contains(staffId)) {
logger.info("该成员已经已经在该门店下申请了绑定,请审核处理后再绑定");
return ServiceResponse.failure("5", "该成员已经已经在该门店下申请了绑定,请审核处理后再绑定");
}
}
StaffClerkRelationDTO storeHasBind = staffClerkRelationService.getOneBindByStoreId(staffId, staffClerkRelationDTO.getStoreId());
if (storeHasBind != null) {
logger.info("该导购已在该门店下有其它成员绑定");
return ServiceResponse.failure("3", "该导购已在该门店下有其它成员绑定");
}
List<StaffClerkRelationDTO> staffClerkRelationDTOS = staffClerkRelationService.listManageBindByStaffId(staffId);
if (CollectionUtils.isNotEmpty(staffClerkRelationDTOS)) {
logger.info("该导购已绑定区经,不允许绑定导购");
return ServiceResponse.failure("3", "该导购已绑定区经,不允许绑定导购");
}
}
StaffClerkRelationDTO storeHasBind = staffClerkRelationService.getOneBindByStoreId(staffId, staffClerkRelationDTO.getStoreId());
if (storeHasBind != null) {
logger.info("该导购已在该门店下有其它成员绑定");
return ServiceResponse.failure("3", "该导购已在该门店下有其它成员绑定");
}
List<StaffClerkRelationDTO> staffClerkRelationDTOS = staffClerkRelationService.listManageBindByStaffId(staffId);
if (CollectionUtils.isNotEmpty(staffClerkRelationDTOS)) {
logger.info("该导购已绑定区经,不允许绑定导购");
return ServiceResponse.failure("3", "该导购已绑定区经,不允许绑定导购");
}
return null;
}
......@@ -437,7 +444,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
} else {
userIds.add(relationDTO.getQwUserId());
}
QywxExternalcontactResultDTO configResp = qywxUserApiService.addContactWay(qwDTO.getThirdCorpid(), config.getWxSuiteid(), send);
QywxExternalcontactResultDTO configResp = qywxUserApiService.addContactWay(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), send,qwDTO.isSelf(),qwDTO.getUrlHost());
logger.info("configId:{}", JSON.toJSONString(configResp));
String configId = configResp.getConfig_id();
if (StringUtils.isBlank(configId)) {
......@@ -540,11 +547,11 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
// 导购门店转移
private void moveOrAddClerk(ClerkSyncQDTO clerkSyncQDTO, StaffClerkRelationDTO oldRelationDTO) {
boolean flag = false;
/* boolean flag = false;
if (null != RedisUtil.getCache("clerkMoveFlag2022")) {
flag = true;
}
if (flag) {
if (flag) {*/
String oldClerkId = oldRelationDTO.getClerkId();
this.staffClerkRelationService.delBind(oldClerkId, "-1", ChannelCodeEnum.SYNC_UNBIND.getCode(), clerkSyncQDTO.getClerkId(),oldRelationDTO.getWxEnterpriseId());
// 设置新的ID
......@@ -554,16 +561,21 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
logger.info("绑定结果正常:{},{}", JSONObject.toJSONString(response), oldRelationDTO.getClerkId());
if (response == null) {
this.staffClerkRelationService.insert(oldRelationDTO);
logger.info("换门店后,查询主门店,newClerkId={}",oldRelationDTO.getStaffId());
// 设置主门店
List<StaffClerkRelationDTO> relationList = this.listByStaffId(oldRelationDTO.getWxEnterpriseId(), oldRelationDTO.getStaffId()) ;
List<String> storeIdList = relationList.stream().map(o->o.getStoreId()).collect(Collectors.toList()) ;
this.clerkMainStoreRelatedService.getMainStoreByStaffId(oldRelationDTO.getStaffId(), oldRelationDTO.getWxEnterpriseId(), storeIdList) ;
}
} else {
/*} else {
String oldClerkId = oldRelationDTO.getClerkId();
this.staffClerkRelationService.delBind(oldClerkId, "-1", ChannelCodeEnum.SYNC_UNBIND.getCode(), null,null);
// 设置新的ID
oldRelationDTO.setClerkId(clerkSyncQDTO.getClerkId());
oldRelationDTO.setStoreId(clerkSyncQDTO.getStoreId());
ServiceResponse resp = this.bindStaffClerk(oldRelationDTO, "-1", ChannelCodeEnum.SYNC_BIND.getCode());
logger.info("绑定结果正常:{},{}", JSONObject.toJSONString(resp), oldRelationDTO.getClerkId());
}
logger.info("绑定结果正常:{},{}", JSONObject.toJSONString(resp), oldRelationDTO.getClerkId());*/
// }
}
@Override
......
......@@ -34,6 +34,7 @@ import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.StaffDepartmentRelatedMapper;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanStaffClerkRelationMapper;
import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.wechat.api.dto.qywx.ItemDTO;
......@@ -248,15 +249,16 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
items.add(dto2);
ArrayList<String> list = new ArrayList<>();
list.add(wxUserId);
messageDTO.setAppid(config.getAppid());
TabHaobanWxEnterprise wxEnterprise = this.wxEnterpriseService.getEnterpriseBycorpId(corpId);
WxEnterpriseQwDTO qwDTO =this.wxEnterpriseService.getQwInfo(wxEnterprise.getWxEnterpriseId()) ;
messageDTO.setAppid(qwDTO.getHbWxaAppid());
messageDTO.setUserIds(list);
messageDTO.setPage(pageUrl);
messageDTO.setTitle(title);
messageDTO.setItems(items);
logger.info("发送参数为corpId============:{},suitId============:{},messageDTO============:{},", corpId, config.getWxSuiteid(), JSONObject.toJSONString(messageDTO));
boolean b = qywxSuiteApiService.sendMessage(corpId, config.getWxSuiteid(), messageDTO);
boolean b = qywxSuiteApiService.sendMessage(corpId, qwDTO.getSelf3thSecret(), messageDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
logger.info("发送===============》{}", b);
return b;
}
......@@ -303,13 +305,15 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
contentList.add(itemDTO);
});
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
messageDTO.setAppid(this.config.getAppid());
TabHaobanWxEnterprise wxEnterprise = this.wxEnterpriseService.getEnterpriseBycorpId(corpId);
WxEnterpriseQwDTO qwDTO =this.wxEnterpriseService.getQwInfo(wxEnterprise.getWxEnterpriseId()) ;
messageDTO.setAppid(qwDTO.getHbWxaAppid());
messageDTO.setUserIds(Collections.singletonList(wxUserId));
messageDTO.setTitle(title);
messageDTO.setItems(contentList);
messageDTO.setPage(pageUrl);
logger.info("消息发送, corpId : {}, suitId : {}, messageDTO : {}", corpId, config.getWxSuiteid(), JSONObject.toJSONString(messageDTO));
boolean sendResult = qywxSuiteApiService.sendMessage(corpId, config.getWxSuiteid(), messageDTO);
boolean sendResult = qywxSuiteApiService.sendMessage(corpId, qwDTO.getSelf3thSecret(), messageDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
logger.info("消息发送结果, sendResult : {}", sendResult);
return sendResult;
}
......@@ -354,14 +358,16 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
}
ArrayList<String> list = new ArrayList<>();
list.add(wxUserId);
messageDTO.setAppid(config.getAppid());
TabHaobanWxEnterprise wxEnterprise = this.wxEnterpriseService.getEnterpriseBycorpId(corpId);
WxEnterpriseQwDTO qwDTO =this.wxEnterpriseService.getQwInfo(wxEnterprise.getWxEnterpriseId()) ;
messageDTO.setAppid(qwDTO.getHbWxaAppid());
messageDTO.setUserIds(list);
messageDTO.setPage(pageUrl);
messageDTO.setTitle(title);
messageDTO.setItems(items);
logger.info("发送消息参数为corpId={},messageDTO={},", corpId, JSONObject.toJSONString(messageDTO));
boolean b = qywxSuiteApiService.sendMessage(corpId, config.getWxSuiteid(), messageDTO);
boolean b = qywxSuiteApiService.sendMessage(corpId, qwDTO.getSelf3thSecret(), messageDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
logger.info("发送消息返回={}", b);
return b;
}
......
......@@ -49,27 +49,11 @@ public class TestServiceImpl implements TestApiService {
@Override
public String listSelfQywxUser(String corpid, String secretVal, String dataId) {
long t = System.currentTimeMillis();
List<UserDTO> list = this.qywxUserApiService.listSelfDepartmentUser(corpid, secretVal, dataId, 0);
logger.info("耗时为===============>{}毫秒", (System.currentTimeMillis() - t));
if (null != list) {
logger.info("微信获取部门成员数量为:{}", list.size());
} else {
logger.info("微信获取部门成员数量异常");
}
return "";
}
@Override
public String listAllQywxUser(String corpid, String secretVal, String dataId) {
long t = System.currentTimeMillis();
List<UserDTO> list = this.qywxUserApiService.listSelfDepartmentUser(corpid, secretVal, dataId, 1);
logger.info("耗时为===============>{}毫秒", (System.currentTimeMillis() - t));
if (null != list) {
logger.info("微信获取部门成员数量为:{}", list.size());
} else {
logger.info("微信获取部门成员数量异常");
}
return "";
}
......
......@@ -249,6 +249,13 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
WxEnterpriseDTO wxDTO = EntityUtil.changeEntityByJSON(WxEnterpriseDTO.class, tab);
return wxDTO;
}
@Override
public WxEnterpriseDTO selectByWxaAppid(String appid) {
TabHaobanWxEnterprise tab = wxEnterpriseMapper.selectByWxaAppid(appid);
WxEnterpriseDTO wxDTO = EntityUtil.changeEntityByJSON(WxEnterpriseDTO.class, tab);
return wxDTO;
}
@Override
public WxEnterpriseQwDTO getQwInfo(String wxEnterpriseId) {
......
......@@ -23,6 +23,7 @@ import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.DateUtil;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.PageHelperUtils;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.dto.chat.ChatEventDTO;
import com.gic.haoban.manage.api.dto.chat.GroupChatDTO;
import com.gic.haoban.manage.api.dto.chat.GroupChatOwnerDTO;
......@@ -33,11 +34,13 @@ import com.gic.haoban.manage.api.dto.qdto.chat.GroupChatUserSearchQDTO;
import com.gic.haoban.manage.api.dto.qdto.chat.OwnerSearchQDTO;
import com.gic.haoban.manage.api.service.chat.GroupChatApiService;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated;
import com.gic.haoban.manage.service.pojo.bo.chat.GroupChatBO;
import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import com.gic.haoban.manage.service.service.StaffService;
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.haoban.manage.service.service.chat.GroupChatUserService;
......@@ -56,6 +59,8 @@ public class GroupChatApiServiceImpl implements GroupChatApiService {
private WxEnterpriseRelatedService wxEnterpriseRelatedService;
@Autowired
private StaffClerkRelationService staffClerkRelationService;
@Autowired
private WxEnterpriseService wxEnterpriseService ;
@Override
public ServiceResponse<Page<GroupChatDTO>> listPage(GroupChatSearchQDTO qdto, BasePageInfo basePageInfo) {
......@@ -183,6 +188,17 @@ public class GroupChatApiServiceImpl implements GroupChatApiService {
String changeType = dto.getChangeType();
String wxChatId = dto.getChatId();
String corpid = dto.getCorpid();
TabHaobanWxEnterprise wxEnterprise = this.wxEnterpriseService.getEnterpriseBycorpId(corpid);
if (wxEnterprise == null) {
logger.info("企业不存在,corpid={}", corpid);
return ServiceResponse.success();
}
String wxEnterpriseId = wxEnterprise.getWxEnterpriseId();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
if(qwDTO.isSelf() && dto.getSelfCallback()==0) {
logger.info("非自建应用回调");
return ServiceResponse.success();
}
// 群解散事件
if ("dismiss".equals(changeType)) {
this.groupChatService.dismissChat(corpid, wxChatId);
......
......@@ -105,7 +105,7 @@ public class InteractRecordApiServiceImpl implements InteractRecordApiService {
// 会员授权事件
// 根据unionId 刷新 memberId 并写入销售线索
interactRecordService.memberAuthorized(memberAttrChangeBO.getMemberId(), memberAttrChangeBO.getUnionId());
// interactRecordService.memberAuthorized(memberAttrChangeBO.getMemberId(), memberAttrChangeBO.getUnionId());
}
if (MemberAttrChangeBO.MemberChangeOpt.MEMBER_MERGE.getCode().equals(memberAttrChangeBO.getOpt())) {
......
......@@ -110,14 +110,14 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
*/
@Override
public ServiceResponse<Void> handlerMaterialWeekReport(String params) {
log.info("handlerMaterialWeekReport 执行素材周报任务开始 >>>>> {}", DateUtil.datetimeToString(new Date()));
log.info("handlerMaterialWeekReport 执行素材周报任务开始 >>>>> params:{} date: {}", params, DateUtil.datetimeToString(new Date()));
Date now = new Date();
Week week = cn.hutool.core.date.DateUtil.dayOfWeekEnum(now);
if (!Week.MONDAY.equals(week)) {
log.info("handlerMaterialWeekReport 当前时间 不是周一 忽略 》》》 {}", DateUtil.datetimeToString(new Date()));
log.info("handlerMaterialWeekReport 当前时间 不是周一 忽略 》》》 params:{}, date:{}", params, DateUtil.datetimeToString(new Date()));
return ServiceResponse.success();
}
return doHandlerReportInner(MaterialReportType.WEEK.getCode());
return doHandlerReportInner(MaterialReportType.WEEK.getCode(), params);
}
/**
......@@ -129,7 +129,7 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
@Override
public ServiceResponse<Void> handlerMaterialMonthReport(String params) {
log.info("handlerMaterialWeekReport 执行素材月报任务开始 >>>>> {}", DateUtil.datetimeToString(new Date()));
return doHandlerReportInner(MaterialReportType.MONTH.getCode());
return doHandlerReportInner(MaterialReportType.MONTH.getCode(), params);
}
/**
......@@ -138,13 +138,20 @@ public class QywxGroupMsgTaskApiServiceImpl implements QywxGroupMsgTaskApiServic
* @param reportType
* @return
*/
private ServiceResponse<Void> doHandlerReportInner(Integer reportType) {
private ServiceResponse<Void> doHandlerReportInner(Integer reportType, String params) {
List<String> enterpriseIds = groupMessageService.hasMaterialRightEnterprise(MaterialEnterpriseAdaptor.MaterialLevel.LOW.getCode());
if (CollectionUtils.isEmpty(enterpriseIds)) {
return ServiceResponse.success();
}
for (String enterpriseId : enterpriseIds) {
if (StringUtils.isNotBlank(params) && !StringUtils.equals("-1", params)) {
log.info("执行指定企业的数据 {}", params);
if (!StringUtils.equals(params, enterpriseId)) {
log.info("企业{}非目标企业,忽略", enterpriseId);
continue;
}
}
List<String> wxEnterpriseIds = wxEnterpriseService.queryWxEnterpriseWithEnterpriseId(enterpriseId);
if (CollectionUtils.isEmpty(wxEnterpriseIds)) {
log.info("企业 {}未关联企微", enterpriseId);
......
......@@ -161,8 +161,8 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
}
String serviceCorpid = config.getCorpid();
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
if (wxEnterpriseDTO.getWxSecurityType() <= 0) {
logger.info("WxSecurityType=0,wxEnterpriseId={}", wxEnterpriseId);
if (wxEnterpriseDTO.getWxSecurityType() <= 0 || wxEnterpriseDTO.getWxSecurityType()==5) {
logger.info("WxSecurityType=0/5,wxEnterpriseId={}", wxEnterpriseId);
return;
}
String corpid = wxEnterpriseDTO.getOpenCorpid();
......@@ -226,7 +226,6 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
// 成员的激活码信息
this.staffService.activedAccountTimer(wxEnterpriseId);
// 更新企业的激活数量统计
this.wxEnterpriseActiveDataService.saveOrUpdate(wxEnterpriseId);
// 统计 haobanQywxFeeDetailDTO 30天内最新过期的时间和人数
......@@ -250,8 +249,9 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
tabHaobanQywxFee.setInterceptFlag(0);
haobanQywxFeeService.insert(tabHaobanQywxFee);
// 判断今天是否是本月最后一天
if (DateUtil.isSameDay(DateUtil.endOfMonth(new Date()), new Date()) || "ca66a01b79474c40b3e7c7f93daf1a3b".equals(wxEnterpriseId)) {
int monthWillInterceptNum = haobanQywxFeeDetailDTO.getInterceptUserNum() ;
if (DateUtil.isSameDay(DateUtil.endOfMonth(new Date()), new Date())
|| "ca66a01b79474c40b3e7c7f93daf1a3b".equals(wxEnterpriseId)) {
int monthWillInterceptNum = haobanQywxFeeDetailDTO.getInterceptUserNum();
String content = "30天将有" + monthWillInterceptNum + "个接口许可证即将过期,您总共还剩余" + permissionUserNum
+ "个可用的接口许可证,请保证数量充足,如需增加请及时联系相关人员续费,避免影响使用";
messageAlert(wxEnterpriseId, corpName, corpid, AlertTypeEnum.FEE_ALARM.getName(), content);
......@@ -296,13 +296,13 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
TabHaobanQywxFeeOrderAccount activeAccount = new TabHaobanQywxFeeOrderAccount();
// 查询激活码的详情
List<ActiveInfoCodeResponseDTO> respList = qywxUserApiService.getActiveInfoByCodeList(corpid, serviceCorpid,
codeList);
if (CollectionUtils.isNotEmpty(respList)) {
List<List<ActiveInfoCodeResponseDTO>> list = Lists.partition(respList, 800);
for (int i = 0; i < list.size(); i++) {
List<ActiveInfoCodeResponseDTO> subList = list.get(i);
for (ActiveInfoCodeResponseDTO activeDetail : subList) {
List<List<String>> list = Lists.partition(codeList, 1000);
for (int i = 0; i < list.size(); i++) {
List<String> subCodeList = list.get(i);
List<ActiveInfoCodeResponseDTO> respList = qywxUserApiService.getActiveInfoByCodeList(corpid, serviceCorpid,
subCodeList);
if (CollectionUtils.isNotEmpty(respList)) {
for (ActiveInfoCodeResponseDTO activeDetail : respList) {
String userid = activeDetail.getUserid();
String activeCode = activeDetail.getActiveCode();
activeAccount.setWxUserId(userid);
......
package com.gic.haoban.manage.service.service.out.impl.hm;
import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.haoban.base.api.common.errCode.HaoBanErrCodeCommon;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.PageUtil;
......
......@@ -540,8 +540,7 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
paramsDTO.setUser(Arrays.asList(tabHaobanStaff.getWxUserId()));
}
}
QywxExternalcontactResultDTO wxResp = qywxUserApiService.addContactWay(qwDTO.getThirdCorpid(),
config.getWxSuiteid(), paramsDTO);
QywxExternalcontactResultDTO wxResp = qywxUserApiService.addContactWay(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), paramsDTO , qwDTO.isSelf(),qwDTO.getUrlHost());
log.info("创建动态活码参数corpid={},app={},param={},返回={}", qwDTO.getThirdCorpid(), config.getWxSuiteid(),
JSON.toJSONString(paramsDTO), JSON.toJSONString(wxResp));
if (null != wxResp && 0 == wxResp.getErrcode()) {
......
......@@ -151,14 +151,13 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
qywxExternalcontactDTO.setRemark(hmQrcodeQDTO.getName());
qywxExternalcontactDTO.setSkipVerify(hmQrcodeQDTO.getPassFlag() == 1);
qywxExternalcontactDTO.setState("HM" + hmId);
String corpid = qwDTO.getThirdCorpid();
List<String> userIds = staffClerkRelationService.listWxUserIdByClerkIds(clerkIdList, wxEnterpriseId);
if (CollectionUtils.isEmpty(userIds)) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "导购未关联好办");
}
qywxExternalcontactDTO.setUser(userIds);
logger.info("新增活码参数:{}", JSON.toJSONString(qywxExternalcontactDTO));
QywxExternalcontactResultDTO qywxExternalcontactResultDTO = qywxUserApiService.addContactWay(corpid, config.getWxSuiteid(), qywxExternalcontactDTO);
QywxExternalcontactResultDTO qywxExternalcontactResultDTO = qywxUserApiService.addContactWay(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), qywxExternalcontactDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
if (qywxExternalcontactResultDTO.getErrcode() != 0) {
GicLogRecordEvaluationContext.noWriteLog();
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_0.getCode()), "创建企微活码失败,具体失败原因请参考企微报错http链接:" + qywxExternalcontactResultDTO.getErrmsg());
......@@ -341,7 +340,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "导购未关联好办");
}
qywxExternalcontactDTO.setUser(userIds);
QywxResponseDTO qywxResponseDTO = qywxUserApiService.updateContactWay(qwDTO.getThirdCorpid(), config.getWxSuiteid(), qywxExternalcontactDTO);
QywxResponseDTO qywxResponseDTO = qywxUserApiService.updateContactWay(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), qywxExternalcontactDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
if (qywxResponseDTO.getErrcode() != 0) {
logger.error("更新企微活码失败");
GicLogRecordEvaluationContext.noWriteLog();
......@@ -691,7 +690,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
String wxConfigId = hmQrcodeBO.getWxConfigId();
if (StringUtils.isNotBlank(wxConfigId)) {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(hmQrcodeBO.getWxEnterpriseId());
QywxResponseDTO qywxResponseDTO = qywxUserApiService.delContactWay(qwDTO.getThirdCorpid(), config.getWxSuiteid(), wxConfigId);
QywxResponseDTO qywxResponseDTO = qywxUserApiService.delContactWay(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), wxConfigId,qwDTO.isSelf(),qwDTO.getUrlHost());
int errcode = qywxResponseDTO.getErrcode();
//https://open.work.weixin.qq.com/devtool/query?e=41044
if (errcode != 0) {
......@@ -816,7 +815,12 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
//查询出所有正常的导购
//企微已经开启联系我
List<String> wxUserIdsList = qywxUserApiService.listCorpExternalUser(qwDTO.getThirdCorpid(), config.getWxSuiteid());
List<String> wxUserIdsList = null ;
if(qwDTO.isSelf()) {
wxUserIdsList = qywxUserApiService.listCorpExternalUserSelf(qwDTO.getDkCorpid(), qwDTO.getSelfSecret(),qwDTO.getUrlHost());
}else {
wxUserIdsList = qywxUserApiService.listCorpExternalUser(qwDTO.getThirdCorpid(), config.getWxSuiteid());
}
this.staffService.updateOpenConcatFlag(wxUserIdsList,qwDTO.needOpenUserId3th()?1:0) ;
List<StaffClerkRelationDTO> staffClerkRelationDTOS = staffClerkRelationService.listIdsByWxUserIds(wxUserIdsList, wxEnterpriseId, enterpriseId);
if (CollectionUtils.isEmpty(staffClerkRelationDTOS)) {
......
......@@ -16,7 +16,9 @@ import com.gic.haoban.manage.service.pojo.GroupSyncPojo;
import com.gic.haoban.manage.service.pojo.bo.content.binlog.MaterialMemberEOrderPojo;
import com.gic.haoban.manage.service.pojo.StoreSyncPojo;
import com.gic.haoban.manage.service.pojo.bo.content.binlog.MaterialMemberGicOrderPojo;
import com.gic.haoban.manage.service.pojo.bo.content.binlog.MaterialMemberUnionIdPoJo;
import com.gic.haoban.manage.service.service.StoreRangeService;
import com.gic.haoban.manage.service.service.content.InteractRecordService;
import com.gic.haoban.manage.service.service.content.PotentialCustomerService;
import com.gic.haoban.manage.service.service.hm.HmQrcodeService;
import org.apache.commons.lang3.StringUtils;
......@@ -49,6 +51,8 @@ public class KafkaMessageServiceImpl implements MessageListener<String, GicRecor
private final String tab_gic_eorder = "tab_gic_eorder";
private final String tab_gic_order = "tab_gic_order";
private final String tab_gic_member = "tab_gic_member";
@Autowired
private StoreRangeService storeRangeService;
......@@ -59,6 +63,8 @@ public class KafkaMessageServiceImpl implements MessageListener<String, GicRecor
private HmQrcodeService hmQrcodeService;
@Autowired
PotentialCustomerService potentialCustomerService;
@Autowired
private InteractRecordService interactRecordService;
@Override
public void onMessage(ConsumerRecord<String, GicRecord> record) {
......@@ -95,6 +101,9 @@ public class KafkaMessageServiceImpl implements MessageListener<String, GicRecor
else if (StringUtils.startsWith(record.value().getTableName(), tab_gic_order)) {
// 处理会员订单新增事件
dealMemberGicOrder((MaterialMemberGicOrderPojo) pojo);
}else if (StringUtils.startsWith(record.value().getTableName(), tab_gic_member)) {
// 会员unionId新增事件
dealMemberUnionIdChange((MaterialMemberUnionIdPoJo) pojo);
}
}
......@@ -119,6 +128,36 @@ public class KafkaMessageServiceImpl implements MessageListener<String, GicRecor
mid.put(gicField.getName(), gicField.getValue());
}
return JSON.parseObject(JSON.toJSONString(mid), MaterialMemberGicOrderPojo.class);
} else if (StringUtils.startsWith(record.getTableName(), tab_gic_member)) {
GicRecordType recordType = record.getRecordType();
if (GicRecordType.INSERT.equals(recordType)) {
Map<String, String> mid = new HashMap<>();
for (GicField gicField : record.getFieldList()) {
mid.put(gicField.getName(), gicField.getValue());
}
return JSON.parseObject(JSON.toJSONString(mid), MaterialMemberUnionIdPoJo.class);
}
if (GicRecordType.UPDATE.equals(recordType)) {
Map<String, String> old = new HashMap<>();
Map<String, String> newMap = new HashMap<>();
for (int i = 0; i < record.getFieldList().size(); i++) {
GicField gicField = record.getFieldList().get(i);
if (i % 2 == 0){
old.put(gicField.getName(), gicField.getValue());
}else {
newMap.put(gicField.getName(), gicField.getValue());
}
}
MaterialMemberUnionIdPoJo oldMember = JSON.parseObject(JSON.toJSONString(old), MaterialMemberUnionIdPoJo.class);
MaterialMemberUnionIdPoJo newMemberInfo = JSON.parseObject(JSON.toJSONString(newMap), MaterialMemberUnionIdPoJo.class);
if (oldMember == null || StringUtils.isNotBlank(oldMember.getUnionId())) {
logger.info("会员原本存在unionId, old:{}, new:{}", JSON.toJSONString(oldMember), JSON.toJSONString(newMemberInfo));
return null;
}
return newMemberInfo;
}
return null;
}
return null;
}
......@@ -235,5 +274,17 @@ public class KafkaMessageServiceImpl implements MessageListener<String, GicRecor
potentialCustomerService.updateMemberDealFlag(memberOrderPojo.getEnterpriseId(), memberOrderPojo.getMemberId());
}
/**
*
* @param materialMemberUnionIdPoJo
*/
private void dealMemberUnionIdChange(MaterialMemberUnionIdPoJo materialMemberUnionIdPoJo) {
logger.info("处理会员unionId新增事件 >> {}", JSON.toJSONString(materialMemberUnionIdPoJo));
if (StringUtils.isBlank(materialMemberUnionIdPoJo.getUnionId()) || StringUtils.equalsIgnoreCase("null", materialMemberUnionIdPoJo.getUnionId())) {
logger.info("处理会员unionId事件异常,会员unionId为空 {}", JSON.toJSONString(materialMemberUnionIdPoJo));
return;
}
interactRecordService.memberAuthorized(materialMemberUnionIdPoJo.getMemberId(), materialMemberUnionIdPoJo.getUnionId());
}
}
......@@ -170,12 +170,12 @@ public class QywxDeptSyncOperation implements BaseSyncOperation {
if ("0".equals(pDataId)) {
//根级部门
List<UserDTO> list = null ;
WxEnterpriseQwDTO wxInfo = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if(wxInfo.getWxSecurityType()==4) {
list = this.qywxUserApiService.listDepartmentUser(wxInfo.getThirdCorpid(), config.getWxSuiteid(), dataId, 1) ;
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if(qwDTO.getWxSecurityType()==4) {
list = this.qywxUserApiService.listDepartmentUser(qwDTO.getThirdCorpid(), config.getWxSuiteid(), dataId, 1) ;
logger.info("从(第三方)获取通讯录={}",JSON.toJSONString(list)) ;
}else {
list = this.qywxUserApiService.listSelfDepartmentUser(wxInfo.getDkCorpid(), secretSetting.getSecretVal(), dataId, 1);
list = this.qywxUserApiService.listSelfDepartmentUser(qwDTO.getDkCorpid(), secretSetting.getSecretVal(), dataId, 1,qwDTO.getUrlHost());
logger.info("从(代开)获取通讯录={}",JSON.toJSONString(list)) ;
}
if (null == list) {
......
......@@ -56,7 +56,7 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation {
@Override
public void dealSingleByMq(DealParamMqDTO dealParamMqDTO, TabHaobanPreDealLog dataPre) {
logger.info("dealParamMqDTO={},dataPre={}", JSON.toJSONString(dealParamMqDTO), JSON.toJSONString(dataPre));
logger.info("刷新好友列表(7-8),dealParamMqDTO={},dataPre={}", JSON.toJSONString(dealParamMqDTO), JSON.toJSONString(dataPre));
String reason = "";
boolean dealFlag = true;
try {
......@@ -74,6 +74,7 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation {
dkWxUserId = staff.getWxOpenUseId();
}
List<String> selfUserIdList = memberUnionidRelatedApiService.listSelfExterialList(wxEnterpriseId, dkWxUserId);
List<String> delUserIdList = selfUserIdList ;
logger.info("selfUserIdList={}", JSONObject.toJSONString(selfUserIdList));
if (CollectionUtils.isEmpty(selfUserIdList)) {
logger.info("自建应用调用第三方接口进入重试");
......@@ -82,31 +83,35 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation {
return;
}
if (CollectionUtils.isEmpty(selfUserIdList)) {
logger.info("改用户没有外部联系人:{}", JSONObject.toJSONString(dataPre));
logger.info("该用户无代开外部联系人:{}", JSONObject.toJSONString(dataPre));
dealFlag = false;
reason = "该用户没有外部联系人";
return;
}
//第三方服务商的外部联系人
String wxUserId3th = staff.getWxUserId() ;
if(qwDTO.needOpenUserId3th()) {
wxUserId3th = staff.getWxOpenUseId() ;
}
List<String> userIdList = memberUnionidRelatedApiService.listExterialList(wxEnterpriseId, wxUserId3th);
if (CollectionUtils.isEmpty(selfUserIdList)) {
dealFlag = tryAgainToMq(dataPre);
reason = "重试次数过多";
logger.info("第三方服务商外部联系人调用失败进入重试:{}", dataPre.getDataId());
return;
}
if (CollectionUtils.isEmpty(userIdList)) {
logger.info("该用户没有外部联系人2:{}", JSONObject.toJSONString(dataPre));
dealFlag = false;
reason = "该用户没有外部联系人";
return;
List<String> userIdList = null ;
if(!qwDTO.isSelf()) {
//第三方服务商的外部联系人
userIdList = memberUnionidRelatedApiService.listExterialList(wxEnterpriseId, wxUserId3th);
delUserIdList = userIdList ;
if (CollectionUtils.isEmpty(selfUserIdList)) {
dealFlag = tryAgainToMq(dataPre);
reason = "重试次数过多";
logger.info("第三方服务商外部联系人调用失败进入重试:{}", dataPre.getDataId());
return;
}
if (CollectionUtils.isEmpty(userIdList)) {
logger.info("该用户无第三方外部联系人:{}", JSONObject.toJSONString(dataPre));
dealFlag = false;
reason = "该用户没有外部联系人";
return;
}
}
//清理外部联系人
memberUnionidRelatedApiService.cleanNoExsitFriendNew(wxEnterpriseId, staffId, userIdList);
memberUnionidRelatedApiService.cleanNoExsitFriendNew(wxEnterpriseId, staffId, delUserIdList);
//写入外部联系人的处理队列
List<TabHaobanPreDealLog> dealLogList = new ArrayList<>();
for (String externalUserId : selfUserIdList) {
......@@ -122,21 +127,23 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation {
}
preDealService.insert(dealLogList);
//写入外部联系人的处理队列
List<TabHaobanPreDealLog> thirddealLogList = new ArrayList<>();
for (String externalUserId : userIdList) {
TabHaobanPreDealLog dealLog = new TabHaobanPreDealLog();
dealLog.setDataId(externalUserId + "###" + wxUserId3th);
dealLog.setpDataId(staffId);
dealLog.setDataType(PreDealTypeEnum.friend.getVal());
dealLog.setStatusFlag(0);
dealLog.setTaskId(dataPre.getTaskId());
dealLog.setDataContent(externalUserId);
dealLog.setWxEnterpriseId(wxEnterpriseId);
thirddealLogList.add(dealLog);
if(!qwDTO.isSelf()) {
//写入外部联系人的处理队列
List<TabHaobanPreDealLog> thirddealLogList = new ArrayList<>();
for (String externalUserId : userIdList) {
TabHaobanPreDealLog dealLog = new TabHaobanPreDealLog();
dealLog.setDataId(externalUserId + "###" + wxUserId3th);
dealLog.setpDataId(staffId);
dealLog.setDataType(PreDealTypeEnum.friend.getVal());
dealLog.setStatusFlag(0);
dealLog.setTaskId(dataPre.getTaskId());
dealLog.setDataContent(externalUserId);
dealLog.setWxEnterpriseId(wxEnterpriseId);
thirddealLogList.add(dealLog);
}
preDealService.insert(thirddealLogList);
}
preDealService.insert(thirddealLogList);
//成功更新状态
dealSuccess(dealParamMqDTO.getTaskId(), dealParamMqDTO.getData(), dataPre.getEnterpriseId(), dataPre.getWxEnterpriseId());
} catch (Exception e) {
......
......@@ -8,6 +8,7 @@ import com.esotericsoftware.minlog.Log;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.haoban.manage.api.dto.DealParamMqDTO;
import com.gic.haoban.manage.api.dto.ExternalUserDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.enums.PreDealStatusEnum;
import com.gic.haoban.manage.api.enums.PreDealTypeEnum;
import com.gic.haoban.manage.api.enums.SyncTaskStatusEnum;
......@@ -16,10 +17,12 @@ import com.gic.haoban.manage.service.entity.TabHaobanPreDealLog;
import com.gic.haoban.manage.service.exception.WxApiLimitException;
import com.gic.haoban.manage.service.service.PreDealService;
import com.gic.haoban.manage.service.service.SyncTaskService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.task.BaseSyncOperation;
import com.gic.mq.sdk.GicMQClient;
import com.gic.redis.data.util.RedisUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -46,12 +49,14 @@ public class SelfFriendSyncNewOperation implements BaseSyncOperation {
private SyncTaskService syncTaskService;
@Autowired
private FriendClerkSyncNewOperation friendClerkSyncNewOperation;
@Autowired
private WxEnterpriseService wxEnterpriseService ;
private static final String TRY_AGAIN = "haoban_fresh_wx_friend_again_";
@Override
public void dealSingleByMq(DealParamMqDTO dealParamMqDTO, TabHaobanPreDealLog dataPre) {
logger.info("同步好友开始,自建代开发={}", JSONObject.toJSONString(dataPre));
logger.info("刷新好友列表7,代开发={}", JSONObject.toJSONString(dataPre));
String reason = "成功";
boolean dealFlag = true;
try {
......@@ -60,10 +65,10 @@ public class SelfFriendSyncNewOperation implements BaseSyncOperation {
String staffId = dataPre.getpDataId() ;
String taskId = dealParamMqDTO.getTaskId();
String externalUserId = dataPre.getDataContent();
// 查询企微侧外部联系人详情
ExternalUserDTO externalUserDTO = memberUnionidRelatedApiService.getCorpSelfExternalUseridInfo(wxEnterpriseId, wxUserId, externalUserId);
if (externalUserDTO == null) {
logger.info("外部联系人好友不存在:{}", JSONObject.toJSONString(dataPre));
logger.info("代开发外部联系人详情查询失败,staffId={},{},{}", staffId,wxUserId,externalUserId);
dealException(taskId, dataPre.getDataId(), null, "好友不存在");
return;
}
......@@ -74,13 +79,22 @@ public class SelfFriendSyncNewOperation implements BaseSyncOperation {
json.put("avatar", externalUserDTO.getAvatar());
json.put("externalUserId", externalUserDTO.getExternalUserId());
json.put("addCreateTime", externalUserDTO.getAddCreateTime());
//relationkey
logger.info("生成relationKey:{},{},{}",staffId,externalUserDTO.getName(),externalUserDTO.getAddCreateTime());
String relationKey = SecureUtil.md5(staffId + "_" + externalUserDTO.getName() + "_" + externalUserDTO.getAddCreateTime());
logger.info("relationKey:{},{}", relationKey, externalUserDTO.getExternalUserId());
String str = staffId + "_" + externalUserDTO.getName() + "_" + externalUserDTO.getAddCreateTime() ;
String relationKey = SecureUtil.md5(str);
logger.info("生成代开发relationKey={},staff={},{}",relationKey,staffId,str);
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if(qwDTO.isSelf()) {
externalUserDTO.setSelfExternalUserId(externalUserDTO.getExternalUserId());
String ret = this.memberUnionidRelatedApiService.dealMergeForReflsh(externalUserDTO, wxEnterpriseId, staffId) ;
if (StringUtils.isNotBlank(ret)) {
logger.info("好友创建失败:{},{}", ret, JSONObject.toJSONString(externalUserDTO));
dealFlag = false;
reason = ret + ":" + relationKey;
return;
}
}
//更新状态
preDealService.updateFriendStatusByDataId(taskId, dataPre.getDataId(), PreDealStatusEnum.computed.getVal(), reason, json.toJSONString(), relationKey , PreDealTypeEnum.self_friend.getVal());
this.preDealService.updateFriendStatusByDataId(taskId, dataPre.getDataId(), PreDealStatusEnum.computed.getVal(), reason, json.toJSONString(), relationKey , PreDealTypeEnum.self_friend.getVal());
dealSuccess(taskId, dataPre.getDataId(), null, wxEnterpriseId);
} catch (WxApiLimitException e) {
logger.info("接口次数限制:{}", JSONObject.toJSONString(dataPre));
......
......@@ -141,7 +141,7 @@
<dubbo:reference interface="com.gic.enterprise.api.service.DepartmentService" id="gicDepartmentService"/>
<dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxDepartmentApiService"
id="qywxDepartmentApiService"/>
<dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxSuiteApiService" id="qywxSuiteApiService"/>
<dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxSuiteApiService" id="qywxSuiteApiService" timeout="20000"/>
<dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxUserApiService" id="qywxUserApiService"/>
<dubbo:reference interface="com.gic.enterprise.api.service.StoreGroupService" id="storeGroupService"/>
......
......@@ -41,6 +41,7 @@
<value>haoban_gic_store_group</value>
<value>tab_haoban_member_order_event_prod</value>
<value>haoban_gic_order</value>
<value>content_member_unionId_notice</value>
</list>
</constructor-arg>
<property name="messageListener" ref="kafkaConsumerService"/>
......
......@@ -12,10 +12,12 @@
<result column="status_flag" jdbcType="INTEGER" property="statusFlag" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="agent_name" property="agentName" />
<result column="agent_id" property="agentId" />
</resultMap>
<sql id="Base_Column_List">
secret_id, wx_enterprise_id, secret_name, secret_val, enterprise_id, secret_type,
check_flag, status_flag, create_time, update_time
check_flag, status_flag, create_time, update_time,agent_name,agent_id
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
......@@ -28,11 +30,11 @@
insert into tab_haoban_secret_setting (secret_id, wx_enterprise_id, secret_name,
secret_val, enterprise_id, secret_type,
check_flag, status_flag, create_time,
update_time)
update_time,agent_name,agent_id)
values (#{secretId,jdbcType=VARCHAR}, #{wxEnterpriseId,jdbcType=VARCHAR}, #{secretName,jdbcType=VARCHAR},
#{secretVal,jdbcType=VARCHAR}, #{enterpriseId,jdbcType=VARCHAR}, #{secretType,jdbcType=INTEGER},
#{checkFlag,jdbcType=INTEGER}, #{statusFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
#{updateTime,jdbcType=TIMESTAMP},#{agentName} , #{agentId})
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.haoban.manage.service.entity.TabSecretSetting">
......@@ -65,6 +67,12 @@
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="agentName != null">
agent_name = #{agentName},
</if>
<if test="agentId != null">
agent_id = #{agentId},
</if>
</set>
where secret_id = #{secretId,jdbcType=VARCHAR}
</update>
......
......@@ -120,6 +120,9 @@
<if test="qrCode != null">
qr_code,
</if>
<if test="openConcatFlag != null">
open_concat_flag,
</if>
<if test="addNum != null">
add_num,
</if>
......@@ -188,6 +191,9 @@
<if test="qrCode != null">
#{qrCode},
</if>
<if test="openConcatFlag != null">
#{openConcatFlag},
</if>
<if test="addNum != null">
#{addNum}
</if>
......
......@@ -121,7 +121,7 @@
<include refid="Base_Column_List"/>
from tab_haoban_sync_task
where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
and task_type != 4
and task_type not in (4,5)
order by update_time desc
</select>
......
......@@ -745,6 +745,13 @@
and status_flag in (1,3,4)
</update>
<select id="listByClerkId" resultType="String">
select member_id from tab_haoban_external_clerk_related
where staff_id = #{staffId}
and clerk_id = #{clerkId}
and status_flag = 1
</select>
<update id="updateExternalStatus">
update tab_haoban_external_clerk_related set external_status = #{status} where
external_user_id = #{externalUserid} and wx_enterprise_id = #{wxEnterpriseId}
......@@ -774,4 +781,16 @@
</foreach>
</select>
<select id="listMemberAndStaff" resultType="java.lang.String">
select member_id
from tab_haoban_external_clerk_related
where member_id in
<foreach collection="memberIdList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
and staff_id = #{staffId}
and enterprise_id = #{enterpriseId}
AND status_flag = 1
</select>
</mapper>
\ No newline at end of file
......@@ -43,6 +43,8 @@
<result column="auto_active_flag" property="autoActiveFlag" jdbcType="INTEGER"/>
<result column="wx_corpid" property="wxCorpid"/>
<result column="open_corpid" property="openCorpid"/>
<result column="wxa_appid" property="wxaAppid" />
<result column="url_host" property="urlHost"/>
</resultMap>
<sql id="Base_Column_List">
......@@ -50,7 +52,7 @@
corp_user_max, corp_full_name, subject_type, verified_end_time, corp_wxqrcode, corp_scale,
corp_industry, corp_sub_industry, location, auth_info, agent, agentid, appid, name,
square_logo_url, round_logo_url, level, bind_flag, status_flag, create_time, update_time,contact_flag,wx_secret_key,wx_secret_key_last_time,member_secret_last_time,contact_secret_last_time
,member_secret,contact_secret,agree_external_userid_flag,agree_external_userid_time,external_flag,userid_flag ,wx_security_type , wx_corpid , open_corpid , auto_active_flag
,member_secret,contact_secret,agree_external_userid_flag,agree_external_userid_time,external_flag,userid_flag ,wx_security_type , wx_corpid , open_corpid , auto_active_flag , wxa_appid , url_host
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">
select
......@@ -58,7 +60,14 @@
from tab_haoban_wx_enterprise
where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
</select>
<select id="selectByWxaAppid" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_wx_enterprise
where wxa_appid = #{appid} and wx_security_type = 5 and status_flag = 1
</select>
<insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise">
insert into tab_haoban_wx_enterprise
<trim prefix="(" suffix=")" suffixOverrides=",">
......@@ -503,7 +512,6 @@
from tab_haoban_wx_enterprise_related a
left join tab_haoban_wx_enterprise b on a.wx_enterprise_id = b.wx_enterprise_id
where a.status_flag = 1 and b.status_flag = 1
group by a.enterprise_id
</select>
<select id="queryWxEnterpriseByEnterpriseId" resultType="java.lang.String">
......
......@@ -61,6 +61,7 @@
name,
staff_id,
wx_chat_id,
wx_chat_id_dk,
chat_add_time,
chat_dissolve_time,
chat_notice,
......@@ -82,6 +83,7 @@
#{name},
#{staffId},
#{wxChatId},
#{wxChatIdDk},
#{chatAddTime},
#{chatDissolveTime},
#{chatNotice},
......
......@@ -296,7 +296,7 @@
<select id="staticsClerkInteractRecordNew" resultType="com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerStaticsBO">
select clerk_id clerkId, count(DISTINCT member_id) num
from tab_haoban_interact_record
where delete_flag = 0 and member_id is not null
where delete_flag = 0 and member_id is not null and member_id <![CDATA[ <> ]]> ''
<if test="clerkId != null and clerkId != ''">
and clerk_id = #{clerkId}
</if>
......
......@@ -33,6 +33,7 @@
<result column="prepay_id" property="prepayId"/>
<result column="wx_order_id" property="wxOrderId"/>
<result column="wx_url" property="wxUrl"/>
<result column="qywx_expire_time" property="qywxExpireTime"/>
</resultMap>
<sql id="Base_Column_List">
order_id,
......@@ -65,7 +66,8 @@
expire_time,
prepay_id,
wx_order_id,
wx_url
wx_url,
qywx_expire_time
</sql>
<!-- ===================== 新增 ======================== -->
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.licence.TabHaobanLicenceOrder"
......@@ -98,7 +100,8 @@
update_time,
creator_id,
creator_name,
expire_time)
expire_time,
qywx_expire_time)
VALUES (#{orderId,jdbcType=BIGINT},
#{enterpriseId,jdbcType=VARCHAR},
#{wxEnterpriseId,jdbcType=VARCHAR},
......@@ -126,7 +129,8 @@
now(),
#{creatorId,jdbcType=VARCHAR},
#{creatorName,jdbcType=VARCHAR},
#{expireTime,jdbcType=VARCHAR})
#{expireTime,jdbcType=TIMESTAMP},
#{qywxExpireTime,jdbcType=TIMESTAMP})
]]>
</insert>
......@@ -205,7 +209,7 @@
FROM tab_haoban_licence_order
WHERE wx_enterprise_id = #{wxEnterpriseId}
and delete_flag = 0
and order_status = 0 limit 1
and qywx_order_status = 0 limit 1
</select>
<select id="getLicenceOrderPage" resultMap="BaseResultMap">
......@@ -286,7 +290,7 @@
<update id="saveQywxOrderId">
UPDATE tab_haoban_licence_order
SET qywx_order_id = #{qywxOrderId} ,update_time = now()
SET qywx_order_id = #{qywxOrderId} ,update_time = now() ,qywx_expire_time= #{qywxExpireTime}
WHERE order_id = #{orderId}
and delete_flag = 0
</update>
......
......@@ -85,12 +85,6 @@ public class DealSyncTest {
@Test
public void test3() {
List<DepartmentDTO> department = qywxDepartmentApiService.listSelfDepartment("wweac4ef962720aa12", "GFu4FwkfcGFPue-qinB7ThEU4wR2SadbBH1yT5sLDzs", null);
System.out.println(JSONObject.toJSONString(department));
}
@Test
public void test4() {
String s = "";
memberUnionidRelatedApiService.dealQywxExternalUser(s);
......
......@@ -5,6 +5,7 @@ import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.dto.licence.LicenceOrderDTO;
import com.gic.haoban.manage.api.dto.licence.LicenceOrderPageDTO;
import com.gic.haoban.manage.api.dto.qdto.licence.LicenceOrderPageQDTO;
import com.gic.haoban.manage.api.dto.qdto.licence.LicenceOrderQDTO;
import com.gic.haoban.manage.api.service.licence.LicenceOrderApiService;
import com.gic.haoban.manage.service.entity.licence.TabHaobanLicenceOrder;
import com.gic.haoban.manage.service.service.licence.LicenceOrderService;
......@@ -68,4 +69,18 @@ public class LicenceOrderServiceTest {
public void test7(){
licenceOrderApiService.hasPopup("ca66a01b79474c40b3e7c7f93daf1a3b");
}
@Test
public void test8(){
LicenceOrderQDTO licenceOrderQDTO = new LicenceOrderQDTO();
licenceOrderQDTO.setEnterpriseId("ff8080815dacd3a2015dacd3ef5c0000");
licenceOrderQDTO.setWxEnterpriseId("ca66a01b79474c40b3e7c7f93daf1a3b");
licenceOrderQDTO.setOrderType(1);
licenceOrderQDTO.setExternalContactCount(10);
licenceOrderQDTO.setTimeType(1);
licenceOrderQDTO.setTimeValue(2);
licenceOrderQDTO.setPayType(1);
ServiceResponse<String> stringServiceResponse = licenceOrderApiService.saveOrUpdateLicenceOrder(licenceOrderQDTO);
}
}
......@@ -43,6 +43,7 @@ import com.gic.haoban.manage.api.dto.HaobanUserDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.WxApplicationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.service.HaobanUserApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.WxApplicationApiService;
......@@ -330,7 +331,10 @@ public class LoginController extends WebBaseController {
WxApplicationDTO application = wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId,2);
if (null == application) {
logger.info("登录企业应用 没授权!gicEnterpriseId:{}", gicEnterpriseId);
return "1004";
WxEnterpriseQwDTO qw = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
if(!qw.isSelf()) {
return "1004";
}
}
WxEnterpriseDTO enterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
if (null == enterprise) {
......
......@@ -374,11 +374,13 @@ public class StaffController extends WebBaseController {
}
}
StoreDTO store = storeService.getStore(clerkInfoVo.getStoreId());
if (null != store) {
if (null != store && store.getStatus() != -3) {
clerkInfoVo.setStoreName(store.getStoreName());
}
});
if (manageFlag == null || manageFlag != 1) {
retList = retList.stream().filter(o->StringUtils.isNotEmpty(o.getStoreName())).collect(Collectors.toList()) ;
}
}
}
return resultResponse(HaoBanErrCode.ERR_1, retList);
......
......@@ -94,22 +94,6 @@ public class TestController extends WebBaseController {
return this.resultResponse(HaoBanErrCode.ERR_0,this.qwFriendApiService.getCallTimes(wxEnterpriseId));
}
@RequestMapping("/send-message-test")
public HaobanResponse testSendMessage(QywxXcxSendMessageQo qo) {
QywxXcxSendMessageDTO messageDTO = EntityUtil.changeEntityByOrika(QywxXcxSendMessageDTO.class, qo);
ArrayList<String> list = new ArrayList<>();
list.add(qo.getUserId());
messageDTO.setUserIds(list);
boolean b = qywxSuiteApiService.sendMessage("ww9ede832a84b7ae5f",
"ww2c34dc56739bb105", messageDTO);
if (b) {
return resultResponse(HaoBanErrCode.ERR_1);
} else {
return resultResponse(HaoBanErrCode.ERR_0);
}
}
@RequestMapping("/test-dubbo")
public HaobanResponse dubbo(@RequestParam(defaultValue = "2000") Integer n, @RequestParam(defaultValue = "100") String t) {
......
......@@ -163,6 +163,9 @@ public class WxEnterpriseController extends WebBaseController {
return resultResponse(HaoBanErrCode.ERR_10012);
}
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
if(qwDTO.isSelf()) {
return this.fail("自建应用不能刷新");
}
QywxCorpInfoDTO dto = qywxTokenManageService.getCorpInfo(qwDTO.getThirdCorpid(), config.getWxSuiteid());
if (dto == null) {
return resultResponse(HaoBanErrCode.ERR_10012);
......@@ -205,9 +208,12 @@ public class WxEnterpriseController extends WebBaseController {
if(wxType==4) {
desc = "(第三方明文,代开密文)" ;
}
if(wxType==5) {
desc = " ( "+wxEnterpriseDTO.getWxaAppid() +" / " + wxEnterpriseDTO.getUrlHost()+") " ;
}
int newType = this.wxEnterpriseApiService.calcSecretType(wxEnterpriseId) ;
String diff = "";
if(null != wxType && wxType.intValue() != newType) {
if(null != wxType && wxType.intValue() != newType && wxType != 5) {
diff = "*";
}
return Arrays.asList(wxEnterpriseDTO.getWxCorpid(),wxEnterpriseDTO.getOpenCorpid()).stream().filter(str -> StringUtils.isNotBlank(str)).collect(Collectors.joining(" / ")) + desc + diff;
......@@ -314,11 +320,18 @@ public class WxEnterpriseController extends WebBaseController {
if (CollectionUtils.isEmpty(secretTypeList)) {
return resultResponse(HaoBanErrCode.ERR_1, false);
}
if ((secretTypeList.contains(SecretTypeEnum.CUSTOMIZED_APP.getVal()))) {
return resultResponse(HaoBanErrCode.ERR_1, true);
} else {
return resultResponse(HaoBanErrCode.ERR_1, false);
// 如果是第三方校验待开发
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
if(qwDTO.isSelf()) {
if ((secretTypeList.contains(SecretTypeEnum.SELF_APP.getVal()))) {
return resultResponse(HaoBanErrCode.ERR_1, true);
}
}else {
if ((secretTypeList.contains(SecretTypeEnum.CUSTOMIZED_APP.getVal()))) {
return resultResponse(HaoBanErrCode.ERR_1, true);
}
}
return resultResponse(HaoBanErrCode.ERR_1, false);
}
/**
......@@ -340,16 +353,16 @@ public class WxEnterpriseController extends WebBaseController {
}
wxSecretKey = wxSecretKey.trim();
String token = this.qywxCorpApiService.getToken(qwDTO.getDkCorpid(), wxSecretKey);
logger.info("查询token", token) ;
logger.info("查询token={}", token) ;
if(StringUtils.isEmpty(token) || token.length() < 10) {
return this.fail("请确认secret是否正确") ;
}
SecretSettingDTO secretSetting = wxEnterpriseApiService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.CONTACT_CUSTOMER.getVal(), null);
SecretSettingDTO secretSetting = wxEnterpriseApiService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.SELF_APP.getVal(), null);
if (null == secretSetting) {
secretSetting = new SecretSettingDTO();
}
secretSetting.setSecretType(SecretTypeEnum.CONTACT_CUSTOMER.getVal());
secretSetting.setSecretName(SecretTypeEnum.CONTACT_CUSTOMER.getName());
secretSetting.setSecretType(SecretTypeEnum.SELF_APP.getVal());
secretSetting.setSecretName(SecretTypeEnum.SELF_APP.getName());
secretSetting.setWxEnterpriseId(wxEnterpriseId);
secretSetting.setEnterpriseId("-1");
secretSetting.setSecretVal(wxSecretKey);
......
package com.gic.haoban.manage.web.controller.chat;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
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.util.ExcelUtils;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import com.gic.haoban.common.utils.AuthWebRequestUtil;
import com.gic.haoban.manage.api.dto.StaffDTO;
......@@ -28,14 +20,29 @@ import com.gic.haoban.manage.api.dto.qdto.chat.GroupChatUserSearchQDTO;
import com.gic.haoban.manage.api.dto.qdto.chat.OwnerSearchQDTO;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.chat.GroupChatApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.log.LogRecordUserServiceImpl;
import com.gic.log.record.anno.GicLogRecord;
import com.gic.log.record.util.GicLogRecordCategoryEnum;
import com.gic.log.record.util.GicLogRecordEvaluationContext;
import com.gic.log.record.util.GicLogRecordOptTypeEnum;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
*
*
* @ClassName: GroupChatController
* @Description: 群
* @author xugh
......@@ -52,6 +59,8 @@ public class GroupChatController {
private GroupChatApiService groupChatApiService;
@Autowired
private StaffApiService staffApiService;
@Autowired
private EnterpriseService enterpriseService;
@RequestMapping("get-set-gic-flag")
public RestResponse<Object> getFlag() {
......@@ -63,7 +72,7 @@ public class GroupChatController {
}
/**
*
*
* @Title: save
* @Description: 认领gic
* @author xugh
......@@ -204,5 +213,52 @@ public class GroupChatController {
GicLogRecordEvaluationContext.putOptTargetId(AuthWebRequestUtil.getLoginUser().getClerkId());
return RestResponse.successResult(resp.getResult());
}
/**
* 客户群列表数据明细导出
*/
@RequestMapping("customer-group-export")
public RestResponse<Boolean> customerGroupExport(HttpServletRequest request, HttpServletResponse response,GroupChatSearchQDTO qdto) {
// 登录校验
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()), HaoBanErrCode.ERR_4.getMsg());
}
String sortColumn = qdto.getSortColumn();
if (StringUtils.isBlank(sortColumn)) {
sortColumn = null;
} else if ("totalCount".equals(sortColumn)) {
sortColumn = "total_count";
} else if ("totalMemberCount".equals(sortColumn)) {
sortColumn = "total_member_count";
} else if ("addMemberCount".equals(sortColumn)) {
sortColumn = "add_member_count";
} else if ("addCount".equals(sortColumn)) {
sortColumn = "add_count";
} else if ("quitCount".equals(sortColumn)) {
sortColumn = "quit_count";
} else if ("quitMemberCount".equals(sortColumn)) {
sortColumn = "quit_member_count";
}
BasePageInfo basePageInfo = new BasePageInfo() ;
basePageInfo.setPageNum(1);
basePageInfo.setPageSize(99999);
qdto.setSortColumn(sortColumn);
qdto.setWxEnterpriseId(loginUser.getWxEnterpriseId());
qdto.setEnterpriseId(loginUser.getEnterpriseId());
ServiceResponse<Page<GroupChatDTO>> page = this.groupChatApiService.listPage(qdto, basePageInfo);
if (page.isSuccess() && CollUtil.isNotEmpty(page.getResult().getResult())){
String fileName = "客户群列表数据";
List<String> titleList = Arrays.asList("客户群ID", "客户群名称", "群人数", "群客户数", "新增总数", "流失总数","群主","群主在好办小程序关联状态","创建时间");
List<String> fileList = Arrays.asList("groupChatId", "name", "totalCount", "totalMemberCount", "addCount", "quitCount", "staffName", "clerkRelationExcel", "createTime");
try {
ExcelUtils.xls(response, request, fileName, page.getResult().getResult(), fileList, titleList);
} catch (Exception e) {
e.printStackTrace();
logger.info("导出失败");
}
return RestResponse.successResult(true);
}
return RestResponse.successResult(false);
}
}
......@@ -9,7 +9,6 @@ import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.DateUtil;
import com.gic.commons.util.PageHelperUtils;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.EnterpriseService;
......@@ -98,38 +97,39 @@ public class LicenceOrderController {
// }
/**
* 新增或者修改订单
* 新增订单
*
* @param licenceOrderQO
* @return JSONObject key:orderId 和 price
*/
@RequestMapping("licence-order-saveOrUpdate")
@GicLogRecord(value = "${#logValue}", category = GicLogRecordCategoryEnum.HB_LICENCE_ORDER,
optType = GicLogRecordOptTypeEnum.HB_1004_01, userFunc = LogRecordUserServiceImpl.class, optPage = "购买企业微信许可账号")
public RestResponse<String> saveOrUpdateLicenceOrder(@RequestBody LicenceOrderQO licenceOrderQO) {
public RestResponse<JSONObject> saveOrUpdateLicenceOrder(@RequestBody LicenceOrderQO licenceOrderQO) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
if (loginUser == null || StringUtils.isBlank(loginUser.getEnterpriseId())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_4.getCode()), HaoBanErrCode.ERR_4.getMsg());
}
//金额校验
Integer integer = licenceOrderQO.checkPrice();
if (integer == -1) {
return RestResponse.failure("-9999", "许可账号数量有误!");
} else if (integer == 0) {
return RestResponse.failure("-9999", "购买金额计算有误!");
}
LicenceOrderQDTO licenceOrderQDTO = JSONObject.parseObject(JSONObject.toJSONString(licenceOrderQO), LicenceOrderQDTO.class);
licenceOrderQDTO.setEnterpriseId(loginUser.getEnterpriseId());
licenceOrderQDTO.setWxEnterpriseId(loginUser.getWxEnterpriseId());
licenceOrderQDTO.setCreatorId(loginUser.getClerkId());
licenceOrderQDTO.setCreatorName(loginUser.getClerkName());
String result = licenceOrderApiService.saveOrUpdateLicenceOrder(licenceOrderQDTO).getResult();
String time = "";
if (licenceOrderQO.getTimeType() == 1) {
time = licenceOrderQO.getTimeValue() + "个月";
} else {
time = licenceOrderQO.getTimeValue() + "天";
ServiceResponse<String> response = licenceOrderApiService.saveOrUpdateLicenceOrder(licenceOrderQDTO);
if (response.isSuccess()) {
JSONObject object = JSONObject.parseObject(response.getResult(), JSONObject.class);
String time = "";
if (licenceOrderQO.getTimeType() == 1) {
time = licenceOrderQO.getTimeValue() + "个月";
} else {
time = licenceOrderQO.getTimeValue() + "天";
}
String logValue = "【购买企微许可账号】:订单编号ZH" + object.getString("orderId") + ",企业员工账号" + licenceOrderQO.getExternalContactCount() + "个,时长" + time;
GicLogRecordEvaluationContext.putAttribute("logValue", logValue);
return RestResponse.successResult(object);
}
String logValue = "【购买企微许可账号】:订单编号ZH" + result + ",企业员工账号" + licenceOrderQO.getExternalContactCount() + "个,时长" + time;
GicLogRecordEvaluationContext.putAttribute("logValue", logValue);
return RestResponse.successResult(result);
GicLogRecordEvaluationContext.noWriteLog();
return RestResponse.failure(response.getCode(), response.getMessage());
}
/**
......@@ -155,7 +155,7 @@ public class LicenceOrderController {
}
/**
* 取消订单/订单已经过期
* 取消订单
*/
@RequestMapping("licence-order-cancel")
@GicLogRecord(value = "${#logValue}", category = GicLogRecordCategoryEnum.HB_LICENCE_ORDER,
......@@ -173,10 +173,18 @@ public class LicenceOrderController {
String enterpriseId = loginUser.getEnterpriseId();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
String clerkName = loginUser.getClerkName();
Boolean result = licenceOrderApiService.updateLicenceOrderType(orderId, type, enterpriseId, wxEnterpriseId, clerkName, 1).getResult();
String logValue = "【取消购买企微许可账号订单】:订单编号" + dto.getOrderNumber() + ",取消时间" + DateUtil.dateToStr(new Date(), DateUtil.FORMAT_DATETIME_19);
GicLogRecordEvaluationContext.putAttribute("logValue", logValue);
return RestResponse.successResult(result);
//取消企业微信订单
ServiceResponse<Boolean> response = licenceOrderApiService.cancelQywxOrder(orderId);
if (response.isSuccess()) {
Boolean result = licenceOrderApiService.updateLicenceOrderType(orderId, type, enterpriseId, wxEnterpriseId, clerkName, 1).getResult();
//操作日志记录
String logValue = "【取消购买企微许可账号订单】:订单编号" + dto.getOrderNumber() + ",取消时间" + DateUtil.dateToStr(new Date(), DateUtil.FORMAT_DATETIME_19);
GicLogRecordEvaluationContext.putAttribute("logValue", logValue);
return RestResponse.successResult(result);
}
GicLogRecordEvaluationContext.noWriteLog();
return RestResponse.failure(response.getCode(), response.getMessage());
}
/**
......@@ -198,10 +206,14 @@ public class LicenceOrderController {
String enterpriseId = loginUser.getEnterpriseId();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
String clerkName = loginUser.getClerkName();
Boolean result = licenceOrderApiService.uploadLicenceOrderVoucher(orderId, voucher, enterpriseId, wxEnterpriseId, clerkName).getResult();
String logValue = "【上传购买企微许可账号支付凭证】:订单编号" + dto.getOrderNumber() + ",上传时间" + DateUtil.dateToStr(new Date(), DateUtil.FORMAT_DATETIME_19);
GicLogRecordEvaluationContext.putAttribute("logValue", logValue);
return RestResponse.successResult(result);
ServiceResponse<Boolean> response = licenceOrderApiService.uploadLicenceOrderVoucher(orderId, voucher, enterpriseId, wxEnterpriseId, clerkName);
if (response.isSuccess()) {
String logValue = "【上传购买企微许可账号支付凭证】:订单编号" + dto.getOrderNumber() + ",上传时间" + DateUtil.dateToStr(new Date(), DateUtil.FORMAT_DATETIME_19);
GicLogRecordEvaluationContext.putAttribute("logValue", logValue);
return RestResponse.successResult(true);
}
GicLogRecordEvaluationContext.noWriteLog();
return RestResponse.failure(response.getCode(), response.getMessage());
}
/**
......@@ -226,7 +238,7 @@ public class LicenceOrderController {
return RestResponse.successResult(map);
}
Integer money = result.getPrice();
if (null != loginUser.getPhoneNumber() && Arrays.asList("13456789987", "13429152802","13383841777","13576223447").contains(loginUser.getPhoneNumber())) {
if (null != loginUser.getPhoneNumber() && Arrays.asList("13456789987", "13429152802", "13383841777", "13576223447").contains(loginUser.getPhoneNumber())) {
//测试账号付款一分
money = 1;
}
......
......@@ -154,5 +154,9 @@ public class LicenceOrderVO implements Serializable {
* 订单进度list
*/
private List<LicenceOrderProgressVO> OrderProgressList;
/**
* 企业微信订单过期时间
*/
private Date qywxExpireTime;
}
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