Commit adf7e102 by fudahua

Merge branch 'developer' into 'master'

Developer

See merge request !104
parents e0b33f52 b12b189a
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
/**
* Created 2021/5/31.
*
* @author hua
*/
public class CheckFriendSettingDTO implements Serializable {
private String wxEnterpriseId;
private String name;
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
......@@ -15,6 +15,8 @@ public class ClerkMainStoreRelatedDTO implements Serializable{
private Integer mainStoreFlag;
private Integer freshFriendFlag;
private Integer statusFlag;
private Date createTime;
......@@ -23,6 +25,14 @@ public class ClerkMainStoreRelatedDTO implements Serializable{
private static final long serialVersionUID = 1L;
public Integer getFreshFriendFlag() {
return freshFriendFlag;
}
public void setFreshFriendFlag(Integer freshFriendFlag) {
this.freshFriendFlag = freshFriendFlag;
}
public String getClerkMainStoreRelatedId() {
return clerkMainStoreRelatedId;
}
......
......@@ -18,13 +18,25 @@ public class EnterpriseDetailDTO implements Serializable{
private String version;
private int nodeCount;
private String enterpriseLogo;
private String staffId;
/**
* 导购编辑权限
*/
private Integer clerkEditFlag;
private String staffId;
private String staffName;
private Date createTime;
private String brandName;
private Integer wxEnterpriseType;
private Integer memberOpenCardFlag;
public Integer getClerkEditFlag() {
return clerkEditFlag;
}
public void setClerkEditFlag(Integer clerkEditFlag) {
this.clerkEditFlag = clerkEditFlag;
}
public Integer getWxEnterpriseType() {
return wxEnterpriseType;
}
......
......@@ -29,6 +29,19 @@ public class ExternalUserDTO implements Serializable{
private String staffId;
private String selfExternalUserId;
/**
* 好友类型
* 1表示该外部联系人是微信用户,2表示该外部联系人是企业微信用户
*/
private Integer friendType;
public Integer getFriendType() {
return friendType;
}
public void setFriendType(Integer friendType) {
this.friendType = friendType;
}
public String getSelfExternalUserId() {
return selfExternalUserId;
......
......@@ -42,9 +42,27 @@ public class MaterialDTO implements Serializable{
private Date updateTime;
private String fromMaterialId = "-1";
//appid link路径 img_url 封面图 materialTitle
private String appId;
private static final long serialVersionUID = 1L;
public String getMediaid() {
return mediaid;
}
public void setMediaid(String mediaid) {
this.mediaid = mediaid;
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getFromMaterialId() {
return fromMaterialId;
}
......
......@@ -35,6 +35,18 @@ public class StaffClerkInfoDTO implements Serializable{
private Date updateTime;
private String clerkPhoneNumber;
/**
* 是否主门店
*/
private Integer mainStoreFlag;
public Integer getMainStoreFlag() {
return mainStoreFlag;
}
public void setMainStoreFlag(Integer mainStoreFlag) {
this.mainStoreFlag = mainStoreFlag;
}
private static final long serialVersionUID = 1L;
......
......@@ -18,8 +18,17 @@ public class WxEnterpriseRelationDetailDTO implements Serializable {
private String staffName;
private int wxEnterpriseType;
private int memberOpenCardFlag;
private Integer clerkEditFlag;
private List<StoreOrGroupInfoDTO> relations;
public Integer getClerkEditFlag() {
return clerkEditFlag;
}
public void setClerkEditFlag(Integer clerkEditFlag) {
this.clerkEditFlag = clerkEditFlag;
}
public String getWxEnterpriseRelatedId() {
return wxEnterpriseRelatedId;
}
......
package com.gic.haoban.manage.api.service;
import com.gic.haoban.manage.api.dto.CheckFriendSettingDTO;
import com.gic.haoban.manage.api.dto.ExternalUserDTO;
import com.gic.haoban.manage.api.dto.MemberUnionidRelatedDTO;
/**
* Created 2021/5/31.
*
* @author hua
*/
public interface CheckQywxSettingApiService {
/**
* 设置好友添加流程
*
* @param wxEnterpriseId
* @param name
*/
public void setFriendSetting(String wxEnterpriseId, String name);
/**
* 获取设置的好友流程
*/
public CheckFriendSettingDTO getFriendSetting();
/**
* 校验保存
*
* @param externalUserDTO
* @param dto
*/
public void saveFriendCallback(String wxEnterpriseId, ExternalUserDTO externalUserDTO, MemberUnionidRelatedDTO dto);
}
......@@ -8,4 +8,12 @@ public interface ClerkMainStoreRelatedApiService {
ClerkMainStoreRelatedDTO getWxEnterpriseIdAndStaffId(String wxEnterpriseId, String staffId);
/**
* 设置刷新好友状态为已刷新
*
* @param wxEnterpriseId
* @param staffId
*/
void setFreshFriend(String wxEnterpriseId, String staffId);
}
......@@ -165,4 +165,13 @@ public interface DealSyncOperationApiService {
public void quartWxFriendClerk(String res);
void test(String wxEnterpriseId, String taskId);
/**
* 获取刷新状态
*
* @param wxEnterpriseId
* @param staffId
* @return true 刷新中 false 没刷新或刷新完成
*/
public boolean getFreshFriendSyncTask(String wxEnterpriseId, String staffId);
}
package com.gic.haoban.manage.api.service;
import java.util.Date;
import java.util.List;
import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.manage.api.dto.AuditDTO;
import com.gic.haoban.manage.api.dto.BatchAuditLogDTO;
import com.gic.haoban.manage.api.dto.ExternalClerkRelatedDTO;
import com.gic.haoban.manage.api.dto.MemberUnionidRelatedDTO;
import java.util.Date;
import java.util.List;
/**
* Created by tgs on 2020/2/9.
*/
public interface ExternalClerkRelatedApiService {
/**
* 查询导购好友关联
*
* @param wxUserId : 微信用户id
* @param wxEnterpriseId : 微信企业id
* @param enterpriseId : 企业id
* @return : 返回好友关联
*/
List<ExternalClerkRelatedDTO> listByWxUserIdAndWxEnterpriseId(String wxUserId, String wxEnterpriseId, String enterpriseId);
/**
* 查询会员在企业下的好友关系
*
* @param memberId : 会员id
* @param wxEnterpriseId : 微信企业id
* @param enterpriseId : 企业id
* @return : 返回会员导购关联关系
*/
List<ExternalClerkRelatedDTO> listByMemberIdAndWxEnterpriseId(String memberId, String wxEnterpriseId, String enterpriseId);
List<ExternalClerkRelatedDTO> listByEnterpriseIdAndDate(String enterpriseId,Date date);
Page<ExternalClerkRelatedDTO> pageMemberUnionByParams(List<String> userIdList, List<String> sendMemberIds,
......
......@@ -59,4 +59,12 @@ public interface MaterialApiService {
*/
void delMaterial(List<String> ids);
/**
* 自动刷新madiaid的 获取素材
*
* @param materialId
* @return
*/
MaterialDTO getHasChangeMadieMaterialById(String materialId);
}
package com.gic.haoban.manage.api.service;
import java.util.Date;
import java.util.List;
import com.gic.api.base.commons.JSONResponse;
import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.manage.api.dto.*;
import java.util.Date;
import java.util.List;
public interface MemberUnionidRelatedApiService {
/**
......@@ -52,6 +52,38 @@ public interface MemberUnionidRelatedApiService {
String sendMessage(String wxEnterpriseId, String userId, List<String> extendUserList, String materialId);
/**
* 创建企业群发, 支出素材批量发送
*
* @param wxEnterpriseId : 微信企业id
* @param userId : 用户id
* @param extendUserList : 发送的用户id
* @param materialIdList : 素材id列表
* @return : 返回群发执行结果
*/
JSONResponse sendMessage(String wxEnterpriseId, String userId, List<String> extendUserList, List<String> materialIdList);
/**
* 获取群发成员发送任务列表
*
* @param wxEnterpriseId : 微信企业id
* @param wxMessageId : 消息id
* @param cursor : 分页游标
* @return : 返回请求结果
*/
JSONResponse taskExternalMessage(String wxEnterpriseId, String wxMessageId, String cursor);
/**
* 获取企业群发成员执行结果
*
* @param wxEnterpriseId : 微信企业id
* @param wxMessageId : 消息id
* @param cursor : 分页游标
* @param userId : 用户id
* @return : 返回请求结果
*/
JSONResponse resultExternalMessage(String wxEnterpriseId, String wxMessageId, String cursor, String userId);
JSONResponse getMessageStatus(String wxEnterpriseId, String wxMessageId);
List<MemberUnionidRelatedDTO> getByWxUserIdListAndWxEnterpriseId(List<String> userIdList, String wxEnterpriseId);
......
......@@ -134,4 +134,11 @@ public interface WxEnterpriseRelatedApiService {
*/
public boolean initHistoryEnterprise(String wxEnterpriseId);
/**
* 初始化历史门店数据
*
* @return
*/
public boolean setClerkEditFlag(String wxEnterprieseRelatedId, int clerkEditFlag);
}
......@@ -108,6 +108,25 @@ public interface TabHaobanExternalClerkRelatedMapper {
@Param("wxEnterpriseId") String wxEnterpriseId, @Param("wxUserId") String wxUserId,
@Param("enterpriseId") String enterpriseId, @Param("externalUserId") String externalUserId);
/**
* 查询会员在企业下的好友关系
* @param memberId
* @param wxEnterpriseId
* @param enterpriseId
* @return
*/
List<TabHaobanExternalClerkRelated> listByMemberIdAndWxEnterpriseId(@Param("memberId")String memberId,
@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("enterpriseId") String enterpriseId);
/**
* 查询会员在企业下的好友关系
* @param wxUserId
* @param wxEnterpriseId
* @param enterpriseId
* @return
*/
List<TabHaobanExternalClerkRelated> listByWxUserIdAndWxEnterpriseId(@Param("wxUserId")String wxUserId,
@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("enterpriseId") String enterpriseId);
}
\ No newline at end of file
......@@ -26,6 +26,8 @@ public interface TabHaobanMaterialMapper {
Page<TabHaobanMaterial> listMaterial(@Param("wxEnterpriseId")String wxEnterpriseId, @Param("keyword")String keyword, @Param("categoryId")String categoryId, @Param("materialType")Integer materialType);
List<TabHaobanMaterial> listMaterialByCategoryIds(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("keyword") String keyword, @Param("categoryIds") List<String> categoryIds, @Param("materialType") Integer materialType);
TabHaobanMaterial selectByfromMaterialId(@Param("fromMaterialId") String fromMaterialId, @Param("wxEnterpriseId") String wxEnterpriseId);
List<TabHaobanMaterial> listByfromMaterialId(@Param("fromMaterialId") String fromMaterialId);
......
......@@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
@Mapper
public interface TabHaobanStoreRelationMapper {
......@@ -64,6 +65,14 @@ public interface TabHaobanStoreRelationMapper {
public int deleteAllStoreRalation(@Param("enterpriseId") String enterpriseId);
/**
* 删除门店
*
* @param enterpriseId
* @return
*/
public int deleteStoreRalationByStoreIds(@Param("enterpriseId") String enterpriseId, @Param("storeIds") Set<String> storeIds);
/**
* 所有门店id
*
* @param wxEnterpriseId
......
......@@ -14,6 +14,8 @@ public class TabHaobanClerkMainStoreRelated implements Serializable {
private Integer mainStoreFlag;
private Integer freshFriendFlag;
private Integer statusFlag;
private Date createTime;
......@@ -22,6 +24,14 @@ public class TabHaobanClerkMainStoreRelated implements Serializable {
private static final long serialVersionUID = 1L;
public Integer getFreshFriendFlag() {
return freshFriendFlag;
}
public void setFreshFriendFlag(Integer freshFriendFlag) {
this.freshFriendFlag = freshFriendFlag;
}
public String getClerkMainStoreRelatedId() {
return clerkMainStoreRelatedId;
}
......
......@@ -34,12 +34,22 @@ public class TabHaobanMaterial implements Serializable {
private String link;
private String appId;
private Date createTime;
private Date updateTime;
private String fromMaterialId;
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getFromMaterialId() {
return fromMaterialId;
}
......
......@@ -28,7 +28,15 @@ public class TabHaobanWxEnterpriseRelated implements Serializable {
private Integer rangeType;
private Integer clerkEditFlag;
public Integer getClerkEditFlag() {
return clerkEditFlag;
}
public void setClerkEditFlag(Integer clerkEditFlag) {
this.clerkEditFlag = clerkEditFlag;
}
private static final long serialVersionUID = 1L;
......
......@@ -15,6 +15,19 @@ public class ExternalUserPojo implements Serializable{
private String addCreateTime;
private String externalUserId;
/**
* 好友类型
* 1表示该外部联系人是微信用户,2表示该外部联系人是企业微信用户
*/
private Integer friendType;
public Integer getFriendType() {
return friendType;
}
public void setFriendType(Integer friendType) {
this.friendType = friendType;
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
......
......@@ -17,7 +17,19 @@ public interface MaterialService {
void edit(MaterialDTO materialDTO);
com.github.pagehelper.Page listMaterial(String wxEnterpriseId, String keyword, String categoryId,
Integer materialType);
Integer materialType);
/**
* 查询素材
*
* @param wxEnterpriseId
* @param keyword
* @param categoryId
* @param materialType
* @return
*/
com.github.pagehelper.Page listMaterial(String wxEnterpriseId, String keyword, List<String> categoryId,
Integer materialType);
MaterialDTO getMaterialByFromMaterialId(String fromMaterialId, String wxEnterpriseId);
......
......@@ -52,4 +52,5 @@ public interface MiniprogramSettingService {
*/
public boolean delMiniprogramSetting(String id);
}
......@@ -27,4 +27,12 @@ public interface WxEnterpriseRelatedService {
* @return
*/
TabHaobanWxEnterpriseRelated getByEnterpriseId(String wxEnterpriseId, String enterpriseId);
/**
* 设置导购编辑权限
*
* @param id
* @return
*/
void setClerkEdit(String id, int clerkEditFlag);
}
......@@ -27,5 +27,7 @@ public interface WxEnterpriseService {
int delete(String wxEnterpriseId);
int unbind(String wxEnterpriseId);
TabHaobanWxEnterprise getEnterpriseBycorpIdNoStatus(String corpid);
}
......@@ -39,8 +39,9 @@ public class ClerkMainStoreRelatedServiceImpl implements ClerkMainStoreRelatedSe
t.setCreateTime(now);
t.setUpdateTime(now);
t.setStatusFlag(1);
t.setClerkMainStoreRelatedId(uuId);
mapper.insert(t);
t.setFreshFriendFlag(0);
t.setClerkMainStoreRelatedId(uuId);
mapper.insert(t);
}
......
......@@ -3,6 +3,7 @@ package com.gic.haoban.manage.service.service.impl;
import java.util.Date;
import java.util.List;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -64,8 +65,14 @@ public class MaterialServiceImpl implements MaterialService {
return mapper.listMaterial(wxEnterpriseId,keyword,categoryId,materialType);
}
@Override
public MaterialDTO getMaterialByFromMaterialId(String fromMaterialId, String wxEnterpriseId) {
@Override
public Page<TabHaobanMaterial> listMaterial(String wxEnterpriseId, String keyword, List<String> categoryIds, Integer materialType) {
List<TabHaobanMaterial> materials = mapper.listMaterialByCategoryIds(wxEnterpriseId, keyword, categoryIds, materialType);
return (Page) materials;
}
@Override
public MaterialDTO getMaterialByFromMaterialId(String fromMaterialId, String wxEnterpriseId) {
TabHaobanMaterial tabHaobanMaterial = mapper.selectByfromMaterialId(fromMaterialId, wxEnterpriseId);
return EntityUtil.changeEntityByJSON(MaterialDTO.class, tabHaobanMaterial);
}
......
......@@ -109,37 +109,83 @@ public class StoreRangeServiceImpl implements StoreRangeService {
@Override
public boolean saveStoreRelations(List<TabStoreRelation> list, String optStaffId, int channelCode) {
if (CollectionUtils.isEmpty(list)) {
logger.info("没有需要保存的");
logger.info("没有需要保存的: 有问题的授权");
return true;
}
String enterpriseId = list.get(0).getEnterpriseId();
//更新前绑定门店列表
List<TabStoreRelation> storeRelations = tabHaobanStoreRelationMapper.listStoreRange(enterpriseId);
Map<String, Set<String>> oldStoreIdByMap = storeRelations.stream().collect(Collectors.groupingBy(TabStoreRelation::getWxEnterpriseId, Collectors.mapping(dto -> dto.getStoreId(), Collectors.toSet())));
//根据wxEnterpriseId 分组
Map<String, Set<String>> newStoreIdBywxEnterpriseMap = list.stream().collect(Collectors.groupingBy(TabStoreRelation::getWxEnterpriseId, Collectors.mapping(dto -> dto.getStoreId(), Collectors.toSet())));
//所有就的门店old绑定列表
Map<String, Set<String>> oldStoreIdBywxEnterpriseMap = getOldStoreIdsByWxEnterpriseId(enterpriseId);
Map<String, Set<String>> oldStoreIdBywxEnterpriseMap = getOldStoreIdsByWxEnterpriseId(enterpriseId, oldStoreIdByMap);
//需要解绑门店
Set<String> needUnBindStoreIds = new HashSet<>();
//需要新增权限门店
Set<String> needAddStoreIds = new HashSet<>();
oldStoreIdBywxEnterpriseMap.forEach((wxEid, oldStoreIds) -> {
Set<String> newStoreIds = newStoreIdBywxEnterpriseMap.get(wxEid);
logger.info("wxEnterpriseId-difference-" + wxEid + ":{},{}", JSONObject.toJSONString(oldStoreIds), JSONObject.toJSONString(newStoreIds));
if (CollectionUtils.isEmpty(newStoreIds)) {
//没有新的 老的都需要删除
needUnBindStoreIds.addAll(oldStoreIds);
return;
}
Sets.SetView<String> needDelStoreIds = Sets.difference(oldStoreIds, newStoreIds);
logger.info("wxEnterpriseId-difference-" + wxEid + ":{},{}", JSONObject.toJSONString(oldStoreIds), JSONObject.toJSONString(newStoreIds));
logger.info("wxEnterpriseId:{},{}", wxEid, JSONObject.toJSONString(needDelStoreIds));
Set<String> mid = needDelStoreIds.stream().collect(Collectors.toSet());
needUnBindStoreIds.addAll(mid);
//需要新增
Set<String> old = oldStoreIdByMap.get(wxEid);
if (CollectionUtils.isEmpty(old)) {
needAddStoreIds.addAll(newStoreIds);
return;
}
Sets.SetView<String> needAdd = Sets.difference(newStoreIds, old);
if (CollectionUtils.isNotEmpty(needAdd)) {
needAddStoreIds.addAll(needAdd);
}
});
//这些门店解除绑定
staffClerkRelationService.delBindByStoreIds(null, needUnBindStoreIds, optStaffId, channelCode);
//先删除 后新增
tabHaobanStoreRelationMapper.deleteAllStoreRalation(enterpriseId);
//批量插入
insertStoreRelationBatch(list);
//批量处理关联关系
dealStoreRelation(list, enterpriseId, needUnBindStoreIds, needAddStoreIds);
return true;
}
/**
* 批量处理关联关系
*
* @param storeRelations
* @param enterpriseId
* @param delStoreIds
* @param addStoreIds
*/
private void dealStoreRelation(List<TabStoreRelation> storeRelations, String enterpriseId, Set<String> delStoreIds, Set<String> addStoreIds) {
// //先删除 后新增
// tabHaobanStoreRelationMapper.deleteAllStoreRalation(enterpriseId);
// //批量插入
// insertStoreRelationBatch(storeRelations);
//先删除 后新增
if (CollectionUtils.isNotEmpty(delStoreIds)) {
logger.info("批量删除门店:{}", JSONObject.toJSONString(delStoreIds));
tabHaobanStoreRelationMapper.deleteStoreRalationByStoreIds(enterpriseId, delStoreIds);
}
if (CollectionUtils.isNotEmpty(addStoreIds)) {
logger.info("批量新增门店:{}", JSONObject.toJSONString(addStoreIds));
List<TabStoreRelation> adds = storeRelations.stream().filter(dto -> addStoreIds.contains(dto.getStoreId())).collect(Collectors.toList());
//批量插入
insertStoreRelationBatch(adds);
}
}
/**
* 批量插入
*
* @param storeRelations
......@@ -163,21 +209,21 @@ public class StoreRangeServiceImpl implements StoreRangeService {
* @param enterpriseId
* @return
*/
private Map<String, Set<String>> getOldStoreIdsByWxEnterpriseId(String enterpriseId) {
private Map<String, Set<String>> getOldStoreIdsByWxEnterpriseId(String enterpriseId, Map<String, Set<String>> oldStoreIdBywxEnterpriseMap) {
Map<String, Set<String>> ret = new HashMap<>();
Set<String> wxEnterpriseIds = new HashSet<>();
//更新前绑定门店列表
List<TabStoreRelation> storeRelations = tabHaobanStoreRelationMapper.listStoreRange(enterpriseId);
Map<String, Set<String>> oldStoreIdBywxEnterpriseMap = storeRelations.stream().collect(Collectors.groupingBy(TabStoreRelation::getWxEnterpriseId, Collectors.mapping(dto -> dto.getStoreId(), Collectors.toSet())));
if (CollectionUtils.isNotEmpty(storeRelations)) {
// //更新前绑定门店列表
// List<TabStoreRelation> storeRelations = tabHaobanStoreRelationMapper.listStoreRange(enterpriseId);
// Map<String, Set<String>> oldStoreIdBywxEnterpriseMap = storeRelations.stream().collect(Collectors.groupingBy(TabStoreRelation::getWxEnterpriseId, Collectors.mapping(dto -> dto.getStoreId(), Collectors.toSet())));
if (oldStoreIdBywxEnterpriseMap != null && oldStoreIdBywxEnterpriseMap.size() > 0) {
wxEnterpriseIds.addAll(oldStoreIdBywxEnterpriseMap.keySet());
}
//导购绑定列表
List<StaffClerkRelationDTO> staffClerkRelationDTOS = staffClerkRelationService.listBindStoreIdByEnterpriseId(enterpriseId);
Map<String, Set<String>> oldStaffStoreIdByWxEidMap = staffClerkRelationDTOS.stream().collect(Collectors.groupingBy(StaffClerkRelationDTO::getWxEnterpriseId, Collectors.mapping(dto -> dto.getStoreId(), Collectors.toSet())));
if (CollectionUtils.isNotEmpty(staffClerkRelationDTOS)) {
if (oldStaffStoreIdByWxEidMap != null && oldStaffStoreIdByWxEidMap.size() > 0) {
wxEnterpriseIds.addAll(oldStaffStoreIdByWxEidMap.keySet());
}
......
......@@ -13,6 +13,7 @@ import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated;
import com.gic.haoban.manage.service.service.WxEnterpriseRelatedService;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
......@@ -59,4 +60,14 @@ public class WxEnterpriseRelatedServiceImpl implements WxEnterpriseRelatedServic
public TabHaobanWxEnterpriseRelated getByEnterpriseId(String wxEnterpriseId, String enterpriseId) {
return mapper.findOneByEIdAndWxEid(enterpriseId, wxEnterpriseId);
}
@Override
public void setClerkEdit(String id, int clerkEditFlag) {
TabHaobanWxEnterpriseRelated record = new TabHaobanWxEnterpriseRelated();
record.setClerkEditFlag(clerkEditFlag);
record.setWxEnterpriseRelatedId(id);
record.setUpdateTime(new Date());
mapper.updateByPrimaryKeySelective(record);
}
}
......@@ -27,7 +27,8 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService {
wxDTO.setUpdateTime(now);
TabHaobanWxEnterprise tabHaobanWxEnterprise = EntityUtil.changeEntityByJSON(TabHaobanWxEnterprise.class, wxDTO);
tabHaobanWxEnterprise.setStatusFlag(1);
mapper.insertSelective(tabHaobanWxEnterprise);
tabHaobanWxEnterprise.setBindFlag(1);
mapper.insertSelective(tabHaobanWxEnterprise);
return wxDTO.getWxEnterpriseId();
}
......@@ -66,16 +67,26 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService {
TabHaobanWxEnterprise enterprise = new TabHaobanWxEnterprise();
enterprise.setWxEnterpriseId(wxEnterpriseId);
enterprise.setStatusFlag(0);
return this.mapper.updateByPrimaryKeySelective(enterprise);
enterprise.setUpdateTime(new Date());
return this.mapper.updateByPrimaryKeySelective(enterprise);
}
@Override
public TabHaobanWxEnterprise getEnterpriseBycorpIdNoStatus(String corpId) {
List<TabHaobanWxEnterprise> list = this.mapper.getEnterpriseBycorpIdNoStatus(corpId);
if(CollectionUtils.isNotEmpty(list)){
return list.get(0);
}
return null;
}
public int unbind(String wxEnterpriseId) {
TabHaobanWxEnterprise enterprise = new TabHaobanWxEnterprise();
enterprise.setWxEnterpriseId(wxEnterpriseId);
enterprise.setBindFlag(0);
enterprise.setUpdateTime(new Date());
return this.mapper.updateByPrimaryKeySelective(enterprise);
}
@Override
public TabHaobanWxEnterprise getEnterpriseBycorpIdNoStatus(String corpId) {
List<TabHaobanWxEnterprise> list = this.mapper.getEnterpriseBycorpIdNoStatus(corpId);
if (CollectionUtils.isNotEmpty(list)) {
return list.get(0);
}
return null;
}
}
package com.gic.haoban.manage.service.service.out.impl;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.gic.dubbo.entity.ProviderLocalTag;
import com.gic.haoban.manage.api.dto.CheckFriendSettingDTO;
import com.gic.haoban.manage.api.dto.ExternalUserDTO;
import com.gic.haoban.manage.api.dto.MemberUnionidRelatedDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.service.CheckQywxSettingApiService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.redis.data.util.RedisUtil;
import org.apache.commons.lang3.StringUtils;
import org.redisson.api.RBucket;
import org.redisson.api.RMap;
import org.redisson.api.RedissonClient;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Created 2021/5/31.
*
* @author hua
*/
@Service
public class CheckQywxSettingApiServiceImpl implements CheckQywxSettingApiService {
private static final Logger logger = getLogger(CheckQywxSettingApiServiceImpl.class);
private static final String FRIEND_SETTING_KEY = "haoban-check-friend-setting";
private static final String FRIEND_SETTING_VAL_KEY = "haoban-check-friend-setting-val";
private static final String SELF_APP = "selfSuiteId";
private static final String THIRD_APP = "thirdSuiteId";
private static final String ALERT_KEY = "friend-alert:";
private static final String ALERT_URL = "https://oapi.dingtalk.com/robot/send?access_token=435c0ddaacda849e145b64cc3a83c37f742105d88cf27b719b2dbef167436ad4";
@Autowired
private WxEnterpriseService wxEnterpriseService;
@Override
public void setFriendSetting(String wxEnterpriseId, String name) {
CheckFriendSettingDTO checkFriendSettingDTO = new CheckFriendSettingDTO();
checkFriendSettingDTO.setName(name);
checkFriendSettingDTO.setWxEnterpriseId(wxEnterpriseId);
RedisUtil.setCache(FRIEND_SETTING_KEY, checkFriendSettingDTO);
RedissonClient redisClient = RedisUtil.getRedisClient();
RMap<Object, Object> map = redisClient.getMap(FRIEND_SETTING_VAL_KEY);
map.delete();
}
@Override
public CheckFriendSettingDTO getFriendSetting() {
return RedisUtil.getCache(FRIEND_SETTING_KEY, CheckFriendSettingDTO.class);
}
@Override
public void saveFriendCallback(String wxEnterpriseId, ExternalUserDTO externalUserDTO, MemberUnionidRelatedDTO dto) {
if (null == externalUserDTO) {
messageAlert(wxEnterpriseId, dto, null);
//todo 告警
return;
}
CheckFriendSettingDTO friendSetting = this.getFriendSetting();
if (!wxEnterpriseId.equals(friendSetting.getWxEnterpriseId())) {
return;
}
if (!friendSetting.getName().equals(externalUserDTO.getName())) {
return;
}
RedissonClient redisClient = RedisUtil.getRedisClient();
RMap<Object, Object> map = redisClient.getMap(FRIEND_SETTING_VAL_KEY);
if (SELF_APP.equals(dto.getSuiteid())) {
map.put(SELF_APP, externalUserDTO);
} else {
map.put(THIRD_APP, externalUserDTO);
}
messageAlert(wxEnterpriseId, dto, "好友提醒:" + dto.getSuiteid());
}
/**
* 告警
*
* @param wxEnterpriseId
* @param dto
*/
private void messageAlert(String wxEnterpriseId, MemberUnionidRelatedDTO dto, String titleSub) {
titleSub = StringUtils.isBlank(titleSub) ? "加好友异常" : titleSub;
String key = ALERT_KEY + wxEnterpriseId;
RBucket<Object> bucket = RedisUtil.getRedisClient().getBucket(key);
boolean b = bucket.trySet(1, 60L, TimeUnit.SECONDS);
if (!b) {
return;
}
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
ProviderLocalTag providerLocalTag = ProviderLocalTag.tag.get();
String traceId = providerLocalTag.traceId;
String traceUrl = "http://212.64.4.231:8780/damo-stats/mongodb/getLogMessagesView?trace_id=" + traceId;
String title = wxEnterpriseDTO.getCorpName() + ": " + titleSub;
Map<String, Object> map = new HashMap<>();
Map<String, Object> link = new HashMap<>();
map.put("msgtype", "link");
link.put("title", title);
link.put("text", JSONObject.toJSONString(dto));
link.put("messageUrl", traceUrl);
map.put("link", link);
String post = HttpUtil.post(ALERT_URL, JSONObject.toJSONString(map));
logger.info("alert:{}", post);
}
}
......@@ -33,4 +33,13 @@ public class ClerkMainStoreRelatedApiServiceImpl implements ClerkMainStoreRelate
return EntityUtil.changeEntityByJSON(ClerkMainStoreRelatedDTO.class, clerkMainStoreRelatedService.getMainStoreByStaffId(staffId, wxEnterpriseId));
}
@Override
public void setFreshFriend(String wxEnterpriseId, String staffId) {
TabHaobanClerkMainStoreRelated related = clerkMainStoreRelatedService.getMainStoreByStaffId(staffId, wxEnterpriseId);
if (related != null) {
related.setUpdateTime(new Date());
related.setFreshFriendFlag(1);
clerkMainStoreRelatedService.update(related);
}
}
}
......@@ -869,4 +869,14 @@ public class DealSyncOperationApiServiceImpl implements DealSyncOperationApiServ
e.printStackTrace();
}
}
@Override
public boolean getFreshFriendSyncTask(String wxEnterpriseId, String staffId) {
String staffLockKey = FRIEND_LOCK + staffId;
Object cache = RedisUtil.getCache(staffLockKey);
if (null == cache) {
return false;
}
return true;
}
}
package com.gic.haoban.manage.service.service.out.impl;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.EntityUtil;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.manage.api.dto.*;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import com.gic.haoban.manage.api.dto.ExternalClerkRelatedDTO;
import com.gic.haoban.manage.api.service.ExternalClerkRelatedApiService;
import com.gic.haoban.manage.service.dao.mapper.MemberUnionidRelatedMapper;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanExternalClerkRelatedMapper;
import com.gic.haoban.manage.service.entity.MemberUnionidRelated;
import com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.EntityUtil;
import com.gic.haoban.manage.api.service.ExternalClerkRelatedApiService;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanExternalClerkRelatedMapper;
import com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated;
import com.github.pagehelper.PageHelper;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@Service
public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedApiService{
......@@ -34,6 +32,34 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA
@Autowired
private MemberUnionidRelatedMapper memberUnionidRelatedMapper;
/**
* 查询导购好友关联
*
* @param wxUserId : 微信用户id
* @param wxEnterpriseId : 微信企业id
* @param enterpriseId : 企业id
* @return : 返回好友关联
*/
@Override
public List<ExternalClerkRelatedDTO> listByWxUserIdAndWxEnterpriseId(String wxUserId, String wxEnterpriseId, String enterpriseId) {
List<TabHaobanExternalClerkRelated> list = tabHaobanExternalClerkRelatedMapper.listByWxUserIdAndWxEnterpriseId(wxUserId, wxEnterpriseId, enterpriseId);
return EntityUtil.changeEntityListByJSON(ExternalClerkRelatedDTO.class, list);
}
/**
* 查询会员在企业下的好友关系
*
* @param memberId : 会员id
* @param wxEnterpriseId : 微信企业id
* @param enterpriseId : 企业id
* @return : 返回会员导购关联关系
*/
@Override
public List<ExternalClerkRelatedDTO> listByMemberIdAndWxEnterpriseId(String memberId, String wxEnterpriseId, String enterpriseId){
List<TabHaobanExternalClerkRelated> list = tabHaobanExternalClerkRelatedMapper.listByMemberIdAndWxEnterpriseId(memberId, wxEnterpriseId, enterpriseId);
return EntityUtil.changeEntityListByJSON(ExternalClerkRelatedDTO.class,list);
}
@Override
public List<ExternalClerkRelatedDTO> listByEnterpriseIdAndDate(
String enterpriseId, Date date) {
......
......@@ -2,11 +2,16 @@ package com.gic.haoban.manage.service.service.out.impl;
import java.io.InputStream;
import java.net.URL;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.manage.service.entity.TabMiniprogramSetting;
import com.gic.haoban.manage.service.service.MiniprogramSettingService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -52,8 +57,11 @@ public class MaterialApiServiceImpl implements MaterialApiService {
@Autowired
private Config config;
private static Logger logger = LoggerFactory.getLogger(MaterialApiServiceImpl.class);
@Autowired
private MiniprogramSettingService miniprogramSettingService;
private static Logger logger = LoggerFactory.getLogger(MaterialApiServiceImpl.class);
@Override
public boolean hasCategoryNameExsit(String categoryName, String categoryParentId,String categoryId) {
......@@ -123,7 +131,11 @@ public class MaterialApiServiceImpl implements MaterialApiService {
fileType = QywxMediaTypeEnum.FILE;
url = materialDTO.getLink();
}
if(type == 3){
if (type == 6) {
fileType = QywxMediaTypeEnum.IMAGE;
url = materialDTO.getImgUrl();
}
if(type == 3){
String imgUrl = materialDTO.getImgUrl();
logger.info("【上传图片】imgUrl={}",imgUrl);
JSONResponse response = qywxSuiteApiService.uploadImage(enterprise.getCorpid(), config.getWxSuiteid(), getFileByte(imgUrl));
......@@ -236,8 +248,11 @@ public class MaterialApiServiceImpl implements MaterialApiService {
if(type == 5){
fileType = QywxMediaTypeEnum.FILE;
url = old.getLink();
}
String[] arr = url.split("/");
} else if (type == 6) {
fileType = QywxMediaTypeEnum.IMAGE;
url = old.getImgUrl();
}
String[] arr = url.split("/");
int count = arr.length;
JSONResponse jp = qywxSuiteApiService.uploadMedia(enterprise.getCorpid(), config.getWxSuiteid(), getFileByte(url),arr[count - 1], fileType.getCode());
if(jp.getErrorCode() == 0){
......@@ -248,12 +263,38 @@ public class MaterialApiServiceImpl implements MaterialApiService {
return old.getMediaId();
}
private List<String> listSubCategoryIdsByParentId(String categoryId) {
List<String> categoryIds = new ArrayList<>();
categoryIds.add(categoryId);
if (StringUtils.isBlank(categoryId)) {
return categoryIds;
}
List<MaterialCategoryDTO> categoryDTOList = materialCategoryService.listByParentCategory(categoryId);
if (CollectionUtils.isEmpty(categoryDTOList)) {
return categoryIds;
}
for (MaterialCategoryDTO categoryDTO : categoryDTOList) {
categoryIds.addAll(this.listSubCategoryIdsByParentId(categoryDTO.getCategoryId()));
}
return categoryIds;
}
@Override
public Page<MaterialDTO> listMaterial(String wxEnterpriseId, String keyword, String categoryId,
Integer materialType,BasePageInfo pageInfo) {
List<String> categoryIds = this.listSubCategoryIdsByParentId(categoryId);
PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());
com.github.pagehelper.Page<TabHaobanMaterial> page = materialService.listMaterial(wxEnterpriseId,keyword,categoryId,materialType);
return PageUtil.changePageHelperToCurrentPage(page,MaterialDTO.class);
com.github.pagehelper.Page<TabHaobanMaterial> page = materialService.listMaterial(wxEnterpriseId, keyword, categoryIds, materialType);
List<TabHaobanMaterial> result = page.getResult();
List<TabMiniprogramSetting> settings = miniprogramSettingService.listMiniprogram(wxEnterpriseId);
if (CollectionUtils.isNotEmpty(result) && CollectionUtils.isNotEmpty(settings)) {
Map<String, TabMiniprogramSetting> settingMap = settings.stream().collect(Collectors.toMap(dto -> dto.getAppId(), dto -> dto));
result.forEach(dto -> {
TabMiniprogramSetting miniprogramSetting = settingMap.get(dto.getAppId());
dto.setMaterialDesc(miniprogramSetting == null ? "--" : miniprogramSetting.getMiniprogramName());
});
}
return PageUtil.changePageHelperToCurrentPage(page,MaterialDTO.class);
}
public static void main(String[] args) {
......@@ -320,4 +361,28 @@ public class MaterialApiServiceImpl implements MaterialApiService {
public void delMaterial(List<String> ids) {
materialService.delmaterialByIds(ids);
}
@Override
public MaterialDTO getHasChangeMadieMaterialById(String materialId) {
MaterialDTO materialDTO = this.selectMaterialById(materialId);
if (null == materialDTO) {
return null;
}
Date lastUploadTime = materialDTO.getWxLastUploadTime();
Date date = new Date();
Date compareDate = DateUtils.addDays(date, -3);
if (lastUploadTime != null && lastUploadTime.after(compareDate) && StringUtils.isNotBlank(materialDTO.getMediaId())) {
return materialDTO;
}
Integer materialType = materialDTO.getMaterialType();
String madiaId = materialDTO.getMediaId();
//需要上传的类型
List<Integer> typeList = Arrays.asList(2, 4, 5, 6);
if (typeList.contains(materialType)) {
madiaId = this.reUpdalodMetail(materialId);
}
materialDTO.setMediaId(madiaId);
materialDTO.setWxLastUploadTime(date);
return materialDTO;
}
}
......@@ -40,8 +40,8 @@ public class WxApplicationApiServiceImpl implements WxApplicationApiService{
int i = this.wxApplicationService.cancalWxApplication(enterprise.getWxEnterpriseId(), suiteId);
log.info("取消授权结果:{}", i);
TabHaobanWxApplication wxApplication = this.wxApplicationService.selectByWxEnterpriseIdAndApplicationType(enterprise.getWxEnterpriseId(), 2);
if(wxApplication == null){ //如果取消好办小程序应用授权,删除企业
this.wxEnterpriseService.delete(enterprise.getWxEnterpriseId());
if (wxApplication == null) { //如果取消好办小程序应用授权,临时解除绑定
this.wxEnterpriseService.unbind(enterprise.getWxEnterpriseId());
}
}
log.info("企业未绑定过,{}", corpId);
......
......@@ -70,7 +70,8 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
wxEnterpriseId = enterprise.getWxEnterpriseId();
wxDTO.setWxEnterpriseId(enterprise.getWxEnterpriseId());
wxDTO.setStatusFlag(1);
wxEnterpriseService.update(wxDTO);
wxDTO.setBindFlag(1);
wxEnterpriseService.update(wxDTO);
}else{
wxEnterpriseId = wxEnterpriseService.add(wxDTO);
}
......
......@@ -457,6 +457,7 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
String midGroupId = null;
//如果是1的话 加入对应企业
if (midGroupIds.size() == 1) {
midGroupId = midGroupIds.iterator().next();
} else {
......@@ -511,6 +512,7 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
detailDTO.setMemberOpenCardFlag(wxEnterpriseRelated.getMemberOpenCardFlag());
detailDTO.setWxEnterpriseType(wxEnterpriseRelated.getWxEnterpriseType());
detailDTO.setWxEnterpriseRelatedId(wxEnterpriseRelated.getWxEnterpriseRelatedId());
detailDTO.setClerkEditFlag(wxEnterpriseRelated.getClerkEditFlag());
return detailDTO;
}
......@@ -622,4 +624,18 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
}
return true;
}
@Override
public boolean setClerkEditFlag(String wxEnterprieseRelatedId, int clerkEditFlag) {
TabHaobanWxEnterpriseRelated tabHaobanWxEnterpriseRelated = wxEnterpriseRelatedService.getByGicEnterpriseIdByEnterpriseRelatedId(wxEnterprieseRelatedId);
if (tabHaobanWxEnterpriseRelated == null) {
return false;
}
if (tabHaobanWxEnterpriseRelated.getWxEnterpriseType() == 1) {
logger.info("非总部不能设置好友");
return false;
}
wxEnterpriseRelatedService.setClerkEdit(wxEnterprieseRelatedId, clerkEditFlag);
return true;
}
}
......@@ -165,6 +165,9 @@ public class FriendSyncNewOperation implements BaseSyncOperation {
String wxUserId = dataPre.getpDataId();
String taskId = dataPre.getTaskId();
if (externalUserDTO.getFriendType() == 2) {
return "不是微信好友,是企业微信好友:" + externalUserDTO.getFriendType();
}
//staff信息
StaffDTO staff = staffApiService.selectByUserIdAndEnterpriseId(wxUserId, wxEnterpriseId);
if (staff == null) {
......@@ -219,7 +222,7 @@ public class FriendSyncNewOperation implements BaseSyncOperation {
externalUserDTO.getUnionId(), "", externalUserDTO.getName(), externalUserDTO.getAvatar(), qrcodeParam);
}
if (member == null) {
return "会员不存在:" + externalUserDTO.getUnionId();
return "会员不存在:unionid:" + externalUserDTO.getUnionId();
}
externalUserDTO.setMemberId(member.getMemberId());
return memberUnionidRelatedApiService.addExternal(externalUserDTO);
......
......@@ -216,14 +216,14 @@
<update id="deleteByUnionidAndUserId" parameterType="com.gic.haoban.manage.service.entity.MemberUnionidRelated" >
update tab_haoban_member_unionid_related
set status_flag = 0
set status_flag = 0 ,update_time=now()
where external_userid = #{externalUserid,jdbcType=VARCHAR}
and wx_user_id = #{wxUserId}
</update>
<update id="delMemberUnionidRelatedBatch" parameterType="com.gic.haoban.manage.service.entity.MemberUnionidRelated">
update tab_haoban_member_unionid_related
set status_flag = 0
set status_flag = 0,update_time=now()
where
wx_enterprise_id=#{wxEnterpriseId}
and wx_user_id = #{wxUserId}
......
......@@ -7,12 +7,13 @@
<result column="wx_enterprise_id" property="wxEnterpriseId" jdbcType="VARCHAR" />
<result column="store_id" property="storeId" jdbcType="VARCHAR" />
<result column="main_store_flag" property="mainStoreFlag" jdbcType="INTEGER" />
<result column="fresh_friend_flag" property="freshFriendFlag" jdbcType="INTEGER"/>
<result column="status_flag" property="statusFlag" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
clerk_main_store_related_id, staff_id, wx_enterprise_id, store_id, main_store_flag,
clerk_main_store_related_id, staff_id, wx_enterprise_id, store_id, main_store_flag, fresh_friend_flag,
status_flag, create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
......@@ -26,12 +27,13 @@
where clerk_main_store_related_id = #{clerkMainStoreRelatedId,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabHaobanClerkMainStoreRelated" >
insert into tab_haoban_clerk_main_store_related (clerk_main_store_related_id, staff_id,
wx_enterprise_id, store_id, main_store_flag,
insert into tab_haoban_clerk_main_store_related (clerk_main_store_related_id, staff_id,
wx_enterprise_id, store_id, main_store_flag, fresh_friend_flag,
status_flag, create_time, update_time
)
values (#{clerkMainStoreRelatedId,jdbcType=VARCHAR}, #{staffId,jdbcType=VARCHAR},
#{wxEnterpriseId,jdbcType=VARCHAR}, #{storeId,jdbcType=VARCHAR}, #{mainStoreFlag,jdbcType=INTEGER},
values (#{clerkMainStoreRelatedId,jdbcType=VARCHAR}, #{staffId,jdbcType=VARCHAR},
#{wxEnterpriseId,jdbcType=VARCHAR}, #{storeId,jdbcType=VARCHAR}, #{mainStoreFlag,jdbcType=INTEGER},
#{freshFriendFlag},
#{statusFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
......@@ -53,6 +55,9 @@
<if test="mainStoreFlag != null" >
main_store_flag,
</if>
<if test="freshFriendFlag != null">
fresh_friend_flag,
</if>
<if test="statusFlag != null" >
status_flag,
</if>
......@@ -79,6 +84,9 @@
<if test="mainStoreFlag != null" >
#{mainStoreFlag,jdbcType=INTEGER},
</if>
<if test="freshFriendFlag != null">
#{freshFriendFlag},
</if>
<if test="statusFlag != null" >
#{statusFlag,jdbcType=INTEGER},
</if>
......@@ -105,6 +113,9 @@
<if test="mainStoreFlag != null" >
main_store_flag = #{mainStoreFlag,jdbcType=INTEGER},
</if>
<if test="freshFriendFlag != null">
fresh_friend_flag = #{freshFriendFlag,jdbcType=INTEGER},
</if>
<if test="statusFlag != null" >
status_flag = #{statusFlag,jdbcType=INTEGER},
</if>
......@@ -123,6 +134,7 @@
wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
store_id = #{storeId,jdbcType=VARCHAR},
main_store_flag = #{mainStoreFlag,jdbcType=INTEGER},
fresh_friend_flag = #{freshFriendFlag,jdbcType=INTEGER},
status_flag = #{statusFlag,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
......
......@@ -481,4 +481,25 @@
and status_flag in(1,3,4)
order by update_time desc
</select>
<select id="listByMemberIdAndWxEnterpriseId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and enterprise_id = #{enterpriseId}
and member_id = #{memberId}
and status_flag = 1
</select>
<select id="listByWxUserIdAndWxEnterpriseId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and enterprise_id = #{enterpriseId}
and wx_user_id = #{wxUserId}
and status_flag = 1
</select>
</mapper>
\ No newline at end of file
......@@ -18,13 +18,14 @@
<result column="material_desc" property="materialDesc" jdbcType="VARCHAR" />
<result column="status_flag" property="statusFlag" jdbcType="INTEGER" />
<result column="link" property="link" jdbcType="VARCHAR" />
<result column="app_id" property="appId" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
material_id,from_material_id, material_title, material_type, category_id, material_content, wx_last_upload_time,
media_id, wx_enterprise_id, staff_id, staff_name, img_url, material_desc, status_flag,
link, create_time, update_time,wx_img_url
media_id, wx_enterprise_id, staff_id, staff_name, img_url, material_desc, status_flag,
link,app_id, create_time, update_time,wx_img_url
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
......@@ -51,15 +52,16 @@
insert into tab_haoban_material (material_id, from_material_id, material_title, material_type,
category_id, material_content, wx_last_upload_time,
media_id, wx_enterprise_id, staff_id,
staff_name, img_url,wx_img_url, material_desc,
status_flag, link, create_time,
staff_name, img_url,wx_img_url, material_desc,
status_flag, link,app_id, create_time,
update_time)
values (#{materialId,jdbcType=VARCHAR},#{fromMaterialId}, #{materialTitle,jdbcType=VARCHAR},
#{materialType,jdbcType=INTEGER},
#{categoryId,jdbcType=VARCHAR}, #{materialContent,jdbcType=VARCHAR}, #{wxLastUploadTime,jdbcType=TIMESTAMP},
#{mediaId,jdbcType=VARCHAR}, #{wxEnterpriseId,jdbcType=VARCHAR}, #{staffId,jdbcType=VARCHAR},
#{staffName,jdbcType=VARCHAR}, #{imgUrl,jdbcType=VARCHAR},#{wxImgUrl,jdbcType=VARCHAR}, #{materialDesc,jdbcType=VARCHAR},
#{statusFlag,jdbcType=INTEGER}, #{link,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{staffName,jdbcType=VARCHAR}, #{imgUrl,jdbcType=VARCHAR},#{wxImgUrl,jdbcType=VARCHAR}, #{materialDesc,jdbcType=VARCHAR},
#{statusFlag,jdbcType=INTEGER}, #{link,jdbcType=VARCHAR},#{appId,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanMaterial" >
......@@ -216,6 +218,9 @@
<if test="link != null" >
link = #{link,jdbcType=VARCHAR},
</if>
<if test="appId != null">
app_id = #{appId,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
......@@ -274,6 +279,28 @@
order by update_time desc
</select>
<select id="listMaterialByCategoryIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_material
where status_flag = 1
and wx_enterprise_id = #{wxEnterpriseId}
<if test="keyword != null and keyword != ''">
and material_title like CONCAT('%',#{keyword},'%')
</if>
<if test="materialType != null">
and material_type = #{materialType}
</if>
<if test="categoryIds != null and categoryIds.size>0">
and category_id in
<foreach collection="categoryIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
order by update_time desc
</select>
<select id="selectByfromMaterialId" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
......
......@@ -195,4 +195,17 @@
where enterprise_id=#{enterpriseId}
and status_flag=1
</update>
<update id="deleteStoreRalationByStoreIds">
update tab_haoban_store_relation
set
status_flag = 0,
update_time = now()
where enterprise_id=#{enterpriseId}
and store_id in
<foreach collection="storeIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
and status_flag=1
</update>
</mapper>
\ No newline at end of file
......@@ -11,12 +11,13 @@
<result column="status_flag" property="statusFlag" jdbcType="INTEGER" />
<result column="wx_enterprise_type" property="wxEnterpriseType" jdbcType="INTEGER"/>
<result column="member_open_card_flag" property="memberOpenCardFlag" jdbcType="INTEGER"/>
<result column="clerk_edit_flag" property="clerkEditFlag" jdbcType="INTEGER"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
wx_enterprise_related_id, wx_enterprise_id, enterprise_id, version, status_flag, wx_enterprise_type,
member_open_card_flag,
member_open_card_flag,clerk_edit_flag,
create_time, update_time,staff_id,staff_name
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
......@@ -61,6 +62,9 @@
<if test="memberOpenCardFlag != null">
member_open_card_flag,
</if>
<if test="clerkEditFlag != null">
clerk_edit_flag,
</if>
<if test="createTime != null" >
create_time,
</if>
......@@ -96,6 +100,9 @@
<if test="memberOpenCardFlag != null">
#{memberOpenCardFlag,jdbcType=INTEGER},
</if>
<if test="clerkEditFlag != null">
#{clerkEditFlag,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
......@@ -131,6 +138,9 @@
<if test="memberOpenCardFlag != null">
member_open_card_flag = #{memberOpenCardFlag,jdbcType=INTEGER},
</if>
<if test="clerkEditFlag != null">
clerk_edit_flag = #{clerkEditFlag,jdbcType=INTEGER},
</if>
<if test="wxEnterpriseType != null">
wx_enterprise_type = #{wxEnterpriseType,jdbcType=INTEGER},
</if>
......
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.manage.api.dto.FlushStoreMqDTO;
import com.gic.haoban.manage.api.dto.MaterialDTO;
import com.gic.haoban.manage.api.dto.MemberUnionidRelatedDTO;
import com.gic.haoban.manage.api.enums.ChannelCodeEnum;
import com.gic.haoban.manage.api.service.*;
import com.gic.haoban.manage.service.service.MemberUnionRelatedService;
......@@ -53,24 +56,34 @@ public class ServiceTest {
@Autowired
private MaterialApiService materialApiService;
@Autowired
private CheckQywxSettingApiService checkQywxSettingApiService;
private final ExecutorService pools = Executors.newFixedThreadPool(50);
@Test
public void test11() {
FlushStoreMqDTO flushStoreMqDTO = new FlushStoreMqDTO();
flushStoreMqDTO.setEnterpriseId("testEnteroriseId");
int i = 2;
while (i-- > 0) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
wxEnterpriseRelatedApiService.flushBindStoreByEnterpriseId("ff8080815dacd3a2015dacd3ef5c0000",
"-1", "-1", ChannelCodeEnum.SYNC_UNBIND.getCode());
}
// FlushStoreMqDTO flushStoreMqDTO = new FlushStoreMqDTO();
// flushStoreMqDTO.setEnterpriseId("testEnteroriseId");
// int i = 2;
// while (i-- > 0) {
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// wxEnterpriseRelatedApiService.flushBindStoreByEnterpriseId("ff8080815dacd3a2015dacd3ef5c0000",
// "-1", "-1", ChannelCodeEnum.SYNC_UNBIND.getCode());
// }
checkQywxSettingApiService.setFriendSetting("ca66a01b79474c40b3e7c7f93daf1a3b", "宿命の战");
// MemberUnionidRelatedDTO dto = new MemberUnionidRelatedDTO();
// dto.setSuiteid("selfSuiteId");
// checkQywxSettingApiService.saveFriendCallback("ca66a01b79474c40b3e7c7f93daf1a3b", null, dto);
// wxEnterpriseRelatedApiService.flushBindStoreByEnterpriseId("ff808081593917d90159398ec6340012",
// "ca66a01b79474c40b3e7c7f93daf1a3b", "-1", ChannelCodeEnum.SYNC_UNBIND.getCode());
// List<String> ids = new ArrayList<>();
// ids.add("8f5ddb9df0a54332acfa2d5804e90c64");
......@@ -82,14 +95,13 @@ public class ServiceTest {
// System.out.println(JSONObject.toJSONString(response));
}
@Test
public void test() {
List<String> staffIds = new ArrayList<>();
staffIds.add("0006ae5de6484cf9b55072d2d967c481");
public void sendMessage() {
List<String> staffIds = new ArrayList<>();
staffIds.add("0006ae5de6484cf9b55072d2d967c481");
GicMQClient clientInstance = GICMQClientUtil.getClientInstance();
try {
clientInstance.sendMessage("haoban3OrderBackForFaceMq","11111");
clientInstance.sendMessage("haoban3OrderBackForFaceMq", "11111");
} catch (Exception e) {
e.printStackTrace();
}
......@@ -107,6 +119,15 @@ public class ServiceTest {
}
@Test
public void test() {
BasePageInfo basePageInfo = new BasePageInfo();
Page<MaterialDTO> ret = materialApiService.listMaterial("ca66a01b79474c40b3e7c7f93daf1a3b", null, "-1", 1, basePageInfo);
System.out.println(ret);
}
//// @Test
//// public void test1() {
//// String res = qywxUserApiService.leaveClerkExternal("ww9ede832a84b7ae5f"
......
......@@ -7,10 +7,15 @@ import org.apache.commons.lang3.StringUtils;
public class test {
public static void main(String[] args) {
String key = "3.2.1";
String[] split = key.split(".");
// String key = "3.2.1";
// String[] split = key.split(".");
//
// System.out.println(split[1]);
System.out.println(split[1]);
Integer num = 2;
int i = 2 & 4;
System.out.println(i);
//
// //插入不存在的我们pre表的企业微信数据
// int pageSize = 500;
......
......@@ -51,13 +51,15 @@ public class GicDepartmentController extends WebBaseController{
Map<String, StoreRangeInfoDTO> storeRangeMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(rangeInfoDTOList)) {
List<WxEnterpriseDTO> wxEnterpriseDTOS = wxEnterpriseRelatedApiService.listWxEnterpriseByEid(enterpriseId);
Map<String, WxEnterpriseDTO> wxEnterpriseDTOMap = wxEnterpriseDTOS.stream().collect(Collectors.toMap(dto -> dto.getWxEnterpriseId(), dto -> dto));
if (CollectionUtils.isNotEmpty(wxEnterpriseDTOS)) {
Map<String, WxEnterpriseDTO> wxEnterpriseDTOMap = wxEnterpriseDTOS.stream().collect(Collectors.toMap(dto -> dto.getWxEnterpriseId(), dto -> dto));
storeRangeMap = rangeInfoDTOList.stream().filter(dto -> (!dto.getWxEnterpriseId().equals(wxEnterpriseId)) && dto.getRelationType() == 1)
.map(dto -> {
dto.setWxEnterpriseName(wxEnterpriseDTOMap.get(dto.getWxEnterpriseId()).getCorpName());
return dto;
}).collect(Collectors.toMap(dto -> dto.getRelationId(), dto -> dto));
storeRangeMap = rangeInfoDTOList.stream().filter(dto -> (!dto.getWxEnterpriseId().equals(wxEnterpriseId)) && dto.getRelationType() == 1)
.map(dto -> {
dto.setWxEnterpriseName(wxEnterpriseDTOMap.get(dto.getWxEnterpriseId()).getCorpName());
return dto;
}).collect(Collectors.toMap(dto -> dto.getRelationId(), dto -> dto));
}
}
Map<String, StoreRangeInfoDTO> finalStoreRangeMap = storeRangeMap;
List<StoreGroupVo> ret = departmentList.stream().map(dto -> {
......
......@@ -84,6 +84,9 @@ public class StaffController extends WebBaseController{
@Autowired
private EnterpriseService enterpriseService;
@Autowired
private ClerkMainStoreRelatedApiService clerkMainStoreRelatedApiService;
@RequestMapping("staff-add")
public HaobanResponse staffAdd(StaffDTO staffDTO,String departmentIds){
......@@ -293,6 +296,19 @@ public class StaffController extends WebBaseController{
return resultResponse(HaoBanErrCode.ERR_10007);
}
List<StaffClerkInfoDTO> retList = staffClerkRelationApiService.listBindDetailByStaffId(staffId);
if (CollectionUtils.isEmpty(retList)) {
return resultResponse(HaoBanErrCode.ERR_1);
}
ClerkMainStoreRelatedDTO mainStoreRelatedDTO = clerkMainStoreRelatedApiService.getWxEnterpriseIdAndStaffId(staff.getWxEnterpriseId(), staffId);
if (null != mainStoreRelatedDTO) {
retList.forEach(dto -> {
if (dto.getStoreId().equals(mainStoreRelatedDTO.getStoreId())) {
dto.setMainStoreFlag(1);
} else {
dto.setMainStoreFlag(0);
}
});
}
return resultResponse(HaoBanErrCode.ERR_1,retList);
}
......
......@@ -838,4 +838,24 @@ public class WxEnterpriseController extends WebBaseController{
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 授权绑定-设置导购编辑权限
*
* @return
*/
@IgnoreLogin
@RequestMapping("set-clerk-edit")
public HaobanResponse setClerkEdit(String wxEnterprieseRelatedId, int clerkEditFlag) {
if (StringUtils.isBlank(wxEnterprieseRelatedId)) {
logger.info("缺少参数");
return resultResponse(HaoBanErrCode.ERR_2);
}
boolean b = wxEnterpriseRelatedApiService.setClerkEditFlag(wxEnterprieseRelatedId, clerkEditFlag);
if (b) {
return resultResponse(HaoBanErrCode.ERR_1);
} else {
return resultResponse(HaoBanErrCode.ERR_100032);
}
}
}
......@@ -117,6 +117,7 @@ public enum HaoBanErrCode {
ERR_100021(100021,"创建任务失败"),
ERR_100031(100031, "该小程序已经绑定过,不能重复绑定"),
ERR_100032(100032, "代理不能设置导购编辑权限"),
ERR_DEFINE(-888, "自定义错误"),
ERR_OTHER(-999, "未知错误code");
......
......@@ -24,6 +24,8 @@
<dubbo:reference interface="com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService" id="wxEnterpriseRelatedApiService" />
<dubbo:reference interface="com.gic.haoban.manage.api.service.ApplicationApiService" id="applicationApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.WxEnterpriseApiService" id="wxEnterpriseApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.ClerkMainStoreRelatedApiService"
id="clerkMainStoreRelatedApiService"/>
<dubbo:reference interface="com.gic.enterprise.api.service.EnterpriseService" id="enterpriseService"/>
......
......@@ -113,7 +113,7 @@ public class ClerkController extends WebBaseController{
//门店成员列表
@RequestMapping("/store-clerks")
public HaobanResponse storeClerks(String storeId) {
public HaobanResponse storeClerks(String wxEnterpriseId, String storeId, String version) {
if(StringUtils.isAnyBlank(storeId)){
return resultResponse(HaoBanErrCode.ERR_2);
}
......@@ -143,9 +143,19 @@ public class ClerkController extends WebBaseController{
}
resultList.add(vo);
}
return resultResponse(HaoBanErrCode.ERR_1,resultList);
if (StringUtils.isBlank(version)) {
return resultResponse(HaoBanErrCode.ERR_1, resultList);
} else {
WxEnterpriseRelationDetailDTO enterpriseBindInfo = wxEnterpriseRelatedApiService.getEnterpriseBindInfo(wxEnterpriseId, storeDTO.getEnterpriseId());
Map<String, Object> ret = new HashMap<>();
ret.put("clerkEditFlag", enterpriseBindInfo.getClerkEditFlag());
ret.put("clerkList", resultList);
return resultResponse(HaoBanErrCode.ERR_1, ret);
}
}
//获取后台认证配置
@RequestMapping("/get-audit-setting")
public HaobanResponse getAuditSetting(String wxEnterpriseId) {
......@@ -186,7 +196,7 @@ public class ClerkController extends WebBaseController{
}
auditSettingVO.setMemberOpenCardFlag(enterpriseBindInfo.getMemberOpenCardFlag());
auditSettingVO.setWxEnterpriseType(enterpriseBindInfo.getWxEnterpriseType());
auditSettingVO.setFreshFriendFlag(mainStore.getFreshFriendFlag());
return resultResponse(HaoBanErrCode.ERR_1, auditSettingVO);
}
......@@ -391,13 +401,40 @@ public class ClerkController extends WebBaseController{
audit.setCommitTime(new Date());
audit.setAuditType(AuditType.CLERK_DEL.getCode());
auditApiService.insert(audit);
syncHaobanToGicServiceApi.delGicClerk(clerkId);
}
}
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 删除设置主门店和刷新微信好友的缓存限制
*
* @param staffId : 关联标识
* @param dateTime : 时间, 13位时间戳
* @param type : 类型, 1 : 主门店, 2 : 刷新微信好友
*/
@RequestMapping("/delCache")
public void deleteCache(String staffId, Long dateTime, Integer type) {
if (StringUtils.isBlank(staffId) || dateTime == null || type == null) {
return;
}
String yyyyMM = DateUtil.dateToStr(new Date(dateTime), "yyyyMM");
String key = null;
//设置主门店缓存
if (Objects.equals(type, 1)) {
key = "haoban_set_main_store_" + yyyyMM + staffId;
}
if (Objects.equals(type, 2)) {
key = "haoban_fresh_wx_friend" + yyyyMM + staffId;
}
if (StringUtils.isBlank(key)) {
return;
}
RedisUtil.delCache(key);
}
//设置主导购
......@@ -435,8 +472,6 @@ public class ClerkController extends WebBaseController{
logger.info("次数超出限制:{}", staffId);
return resultResponse(HaoBanErrCode.ERR_10011);
}
RedisUtil.setCache(key, count + 1, 31 * 24 * 60 * 60L);
if (flushType == 0) {
String taskName = "刷新企业微信好友("+staff.getStaffName()+")";
String taskId = dealSyncOperationApiService.createWxFriendTaskSingle(wxEnterpriseId, taskName, staffId, staff.getStaffName(), SyncTaskTypeEnum.FRIEND_SINGLE.getType());
......@@ -454,9 +489,27 @@ public class ClerkController extends WebBaseController{
return resultResponse(HaoBanErrCode.ERR_10022);
}
}
RedisUtil.setCache(key, count + 1, 31 * 24 * 60 * 60L);
//刷新状态变更
clerkMainStoreRelatedApiService.setFreshFriend(wxEnterpriseId, staffId);
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 刷新好友状态
*
* @param staffId
* @param storeId
* @param wxEnterpriseId
* @return
*/
@HttpLimit
@RequestMapping("/check-fresh-friend")
public HaobanResponse checkFreshFriend(String staffId, String storeId, String wxEnterpriseId) {
boolean freshFriendSyncTask = dealSyncOperationApiService.getFreshFriendSyncTask(wxEnterpriseId, staffId);
return resultResponse(HaoBanErrCode.ERR_1, freshFriendSyncTask);
}
//获取门店详情
public boolean isEnterpriseOver(String eid) {
......
......@@ -20,9 +20,18 @@ public class AuditSettingVO implements Serializable {
private int wxEnterpriseType;
private int memberOpenCardFlag;
private int freshFriendFlag;
private static final long serialVersionUID = 1L;
public int getFreshFriendFlag() {
return freshFriendFlag;
}
public void setFreshFriendFlag(int freshFriendFlag) {
this.freshFriendFlag = freshFriendFlag;
}
public int getWxEnterpriseType() {
return wxEnterpriseType;
}
......
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