Commit c57b62fe by guojx

Merge remote-tracking branch 'origin/developer' into developer

# Conflicts:
#	haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/hm/HmQrcodeController.java
parents d0a49c24 b5cb7b86
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
public class CommonMQDTO implements Serializable {
/**
* @Fields serialVersionUID : TODO(用一句话描述这个变量表示什么)
*/
private static final long serialVersionUID = -5681421708810402425L;
private int type ;
private String params ;
public int getType() {
return type;
}
public String getParams() {
return params;
}
public void setType(int type) {
this.type = type;
}
public void setParams(String params) {
this.params = params;
}
}
......@@ -6,100 +6,101 @@ import java.util.List;
public class StaffDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 员工id
*/
private String staffId;
/**
* 企业微信id
*/
private String wxEnterpriseId;
/**
* 微信用户id
*/
private String wxUserId;
/**
* 手机号
*/
private String phoneNumber;
/**
* 员工姓名
*/
private static final long serialVersionUID = 1L;
/**
* 员工id
*/
private String staffId;
/**
* 企业微信id
*/
private String wxEnterpriseId;
/**
* 微信用户id
*/
private String wxUserId;
/**
* 手机号
*/
private String phoneNumber;
/**
* 员工姓名
*/
private String staffName;
/**
* 国家码
*/
/**
* 国家码
*/
private String nationCode;
/**
* 昵称
*/
/**
* 昵称
*/
private String nickName;
/**
* 性别
*/
/**
* 性别
*/
private Integer sex;
/**
* 职位
*/
/**
* 职位
*/
private String postion;
/**
* 激活状态
*/
/**
* 激活状态
*/
private Integer activeFlag;
/**
* 对外职务
*/
/**
* 对外职务
*/
private String extendPostion;
/**
* 状态
*/
/**
* 状态
*/
private Integer statusFlag;
private Date createTime;
private Date updateTime;
private String departmentIds;
private String headImg;
private Integer sort;
private List<DepartmentDTO> departmentList;
private int bindFlag;
private String clerkCode;
private String staffDepartmentRelatedId;
private String staffDepartmentRelatedId;
private int clerkType;
private int clerkType;
private Integer syncPostionFlag;
private Integer syncPostionFlag;
private Integer superManagerFlag;
private Integer superManagerFlag;
private Boolean weixinPush;
private Boolean weixinPush;
private Integer memberCount;
private Integer memberCount;
private String clerkId;
/**
* 关联状态 1 已关联 0 未关联
* 关联状态为 员工是否关联某门店导购
*/
private Integer relationFlag;
private String clerkId;
/**
* 关联状态 1 已关联 0 未关联
* 关联状态为 员工是否关联某门店导购
*/
private Integer relationFlag;
private String wxOpenUseId;
private String wxOpenUseId;
private String wxOpenId;
private String qrCode;
private String clerkName;
private String defaultGicEid ;
private String wxOpenId;
private String qrCode;
private String clerkName;
private String defaultGicEid;
private Integer addNum;
public String getDefaultGicEid() {
public String getDefaultGicEid() {
return defaultGicEid;
}
......@@ -108,97 +109,96 @@ public class StaffDTO implements Serializable {
}
public String getClerkId() {
return clerkId;
}
return clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
public int getClerkType() {
return clerkType;
}
public int getClerkType() {
return clerkType;
}
public void setClerkType(int clerkType) {
this.clerkType = clerkType;
}
public void setClerkType(int clerkType) {
this.clerkType = clerkType;
}
public String getStaffDepartmentRelatedId() {
return staffDepartmentRelatedId;
}
public String getStaffDepartmentRelatedId() {
return staffDepartmentRelatedId;
}
public void setStaffDepartmentRelatedId(String staffDepartmentRelatedId) {
this.staffDepartmentRelatedId = staffDepartmentRelatedId;
}
public void setStaffDepartmentRelatedId(String staffDepartmentRelatedId) {
this.staffDepartmentRelatedId = staffDepartmentRelatedId;
}
public String getClerkCode() {
return clerkCode;
}
public String getClerkCode() {
return clerkCode;
}
public void setClerkCode(String clerkCode) {
this.clerkCode = clerkCode;
}
public void setClerkCode(String clerkCode) {
this.clerkCode = clerkCode;
}
public int getBindFlag() {
return bindFlag;
}
public int getBindFlag() {
return bindFlag;
}
public void setBindFlag(int bindFlag) {
this.bindFlag = bindFlag;
}
public void setBindFlag(int bindFlag) {
this.bindFlag = bindFlag;
}
public String getStaffId() {
public String getStaffId() {
return staffId;
}
public void setStaffId(String staffId) {
this.staffId = staffId == null ? null : staffId.trim();
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
return wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public String getExtendPostion() {
return extendPostion;
}
public String getExtendPostion() {
return extendPostion;
}
public void setExtendPostion(String extendPostion) {
this.extendPostion = extendPostion;
}
public void setExtendPostion(String extendPostion) {
this.extendPostion = extendPostion;
}
public Integer getStatusFlag() {
return statusFlag;
}
public Integer getStatusFlag() {
return statusFlag;
}
public void setStatusFlag(Integer statusFlag) {
this.statusFlag = statusFlag;
}
public void setStatusFlag(Integer statusFlag) {
this.statusFlag = statusFlag;
}
public Date getCreateTime() {
return createTime;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getWxUserId() {
public String getWxUserId() {
return wxUserId;
}
......@@ -262,107 +262,115 @@ public class StaffDTO implements Serializable {
this.activeFlag = activeFlag;
}
public String getDepartmentIds() {
return departmentIds;
}
public String getDepartmentIds() {
return departmentIds;
}
public void setDepartmentIds(String departmentIds) {
this.departmentIds = departmentIds;
}
public void setDepartmentIds(String departmentIds) {
this.departmentIds = departmentIds;
}
public String getHeadImg() {
return headImg;
}
public String getHeadImg() {
return headImg;
}
public void setHeadImg(String headImg) {
this.headImg = headImg;
}
public void setHeadImg(String headImg) {
this.headImg = headImg;
}
public List<DepartmentDTO> getDepartmentList() {
return departmentList;
}
public List<DepartmentDTO> getDepartmentList() {
return departmentList;
}
public void setDepartmentList(List<DepartmentDTO> departmentList) {
this.departmentList = departmentList;
}
public Integer getSort() {
return sort;
}
public void setDepartmentList(List<DepartmentDTO> departmentList) {
this.departmentList = departmentList;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public Integer getSort() {
return sort;
}
public Integer getSyncPostionFlag() {
return syncPostionFlag;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public void setSyncPostionFlag(Integer syncPostionFlag) {
this.syncPostionFlag = syncPostionFlag;
}
public Integer getSyncPostionFlag() {
return syncPostionFlag;
}
public Integer getSuperManagerFlag() {
return superManagerFlag;
}
public void setSyncPostionFlag(Integer syncPostionFlag) {
this.syncPostionFlag = syncPostionFlag;
}
public void setSuperManagerFlag(Integer superManagerFlag) {
this.superManagerFlag = superManagerFlag;
}
public Integer getSuperManagerFlag() {
return superManagerFlag;
}
public Boolean getWeixinPush() {
return weixinPush;
}
public void setSuperManagerFlag(Integer superManagerFlag) {
this.superManagerFlag = superManagerFlag;
}
public void setWeixinPush(Boolean weixinPush) {
this.weixinPush = weixinPush;
}
public Boolean getWeixinPush() {
return weixinPush;
}
public Integer getMemberCount() {
return memberCount;
}
public void setWeixinPush(Boolean weixinPush) {
this.weixinPush = weixinPush;
}
public void setMemberCount(Integer memberCount) {
this.memberCount = memberCount;
}
public Integer getMemberCount() {
return memberCount;
}
public Integer getRelationFlag() {
return relationFlag;
}
public void setMemberCount(Integer memberCount) {
this.memberCount = memberCount;
}
public void setRelationFlag(Integer relationFlag) {
this.relationFlag = relationFlag;
}
public Integer getRelationFlag() {
return relationFlag;
}
public String getWxOpenUseId() {
return wxOpenUseId;
}
public void setRelationFlag(Integer relationFlag) {
this.relationFlag = relationFlag;
}
public void setWxOpenUseId(String wxOpenUseId) {
this.wxOpenUseId = wxOpenUseId;
}
public String getWxOpenUseId() {
return wxOpenUseId;
}
public String getWxOpenId() {
return wxOpenId;
}
public void setWxOpenUseId(String wxOpenUseId) {
this.wxOpenUseId = wxOpenUseId;
}
public void setWxOpenId(String wxOpenId) {
this.wxOpenId = wxOpenId;
}
public String getWxOpenId() {
return wxOpenId;
}
public String getQrCode() {
return qrCode;
}
public void setWxOpenId(String wxOpenId) {
this.wxOpenId = wxOpenId;
}
public void setQrCode(String qrCode) {
this.qrCode = qrCode;
}
public String getQrCode() {
return qrCode;
}
public String getClerkName() {
return clerkName;
}
public void setQrCode(String qrCode) {
this.qrCode = qrCode;
}
public void setClerkName(String clerkName) {
this.clerkName = clerkName;
}
public String getClerkName() {
return clerkName;
}
public Integer getAddNum() {
return addNum;
}
public void setClerkName(String clerkName) {
this.clerkName = clerkName;
}
public void setAddNum(Integer addNum) {
this.addNum = addNum;
}
}
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
public class WxEnterpriseQwDTO implements Serializable {
private static final long serialVersionUID = 1L;
private int wxSecurityType ;
private String wxEnterpriseId;
// 企业表中的id(正常同第三方)
private String corpid;
// 好办 助手
private String dkCorpid;
// 会员小程序dk
private String memberCorpid;
// 第三方
private String thirdCorpid;
// 自建
private String selfCorpid;
public int getWxSecurityType() {
return wxSecurityType;
}
public void setWxSecurityType(int wxSecurityType) {
this.wxSecurityType = wxSecurityType;
}
public String getSelfCorpid() {
return selfCorpid;
}
public void setSelfCorpid(String selfCorpid) {
this.selfCorpid = selfCorpid;
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public String getCorpid() {
return corpid;
}
public String getDkCorpid() {
return dkCorpid;
}
public String getMemberCorpid() {
return memberCorpid;
}
public String getThirdCorpid() {
return thirdCorpid;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public void setCorpid(String corpid) {
this.corpid = corpid;
}
public void setDkCorpid(String dkCorpid) {
this.dkCorpid = dkCorpid;
}
public void setMemberCorpid(String memberCorpid) {
this.memberCorpid = memberCorpid;
}
public void setThirdCorpid(String thirdCorpid) {
this.thirdCorpid = thirdCorpid;
}
}
......@@ -19,6 +19,8 @@ public class HmLinkWxaDTO implements Serializable {
private Long pageId ;
private Long hmId ;
private String wxEnterpriseId ;
private String enterpriseId ;
private HmPageDTO page;
// 二维码
private String hmQrcode;
......@@ -33,6 +35,22 @@ public class HmLinkWxaDTO implements Serializable {
// 说明
private Map<String,String> remarkMap ;
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public Long getHmId() {
return hmId;
}
......
......@@ -25,6 +25,7 @@ public class HmQrcodeListDTO implements Serializable {
private String enterpriseId;
private String name;
private String hmName;
private String creatorId;
......@@ -79,6 +80,7 @@ public class HmQrcodeListDTO implements Serializable {
* 活码分组
*/
private Long hmGroupId;
private String hmGroupName;
/**
* 新增总人数
*/
......@@ -319,4 +321,20 @@ public class HmQrcodeListDTO implements Serializable {
public void setStoreList(List<HmStoreDTO> storeList) {
this.storeList = storeList;
}
public String getHmGroupName() {
return hmGroupName;
}
public void setHmGroupName(String hmGroupName) {
this.hmGroupName = hmGroupName;
}
public String getHmName() {
return hmName;
}
public void setHmName(String hmName) {
this.hmName = hmName;
}
}
......@@ -97,9 +97,9 @@ public class HmQrcodeQDTO implements Serializable {
private String staffId;
private String staffName;
/**
* 调用类型,1:手动调用;2:系统调用;3:批量调用
* 调用类型来源 0:不记录,1:来源为后台操作 其他查看枚举 HbBindEnum
*/
private Integer invokingType;
private Integer invokingType = 0;
public Long getHmId() {
......
package com.gic.haoban.manage.api.dto.qdto.hm;
import com.gic.api.base.commons.BasePageInfo;
import java.io.Serializable;
import java.util.Date;
import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gic.api.base.commons.BasePageInfo;
public class WxUserAddLogSearchQDTO extends BasePageInfo implements Serializable {
/**
......@@ -17,10 +20,27 @@ public class WxUserAddLogSearchQDTO extends BasePageInfo implements Serializable
private Long linkId;
private Long hmId;
private String clerkId;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date startTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endTime;
private Integer addChannel;
private String createTimeOrder = "create_time desc";
// 1添加 2流失
private int statusFlag = 1 ;
private String createTimeOrder = "desc";
public int getStatusFlag() {
if(0==statusFlag) {
return 1 ;
}
return statusFlag;
}
public void setStatusFlag(int statusFlag) {
this.statusFlag = statusFlag;
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
......
......@@ -4,18 +4,22 @@ package com.gic.haoban.manage.api.enums;
* Created by hua on 2020/6/24.
*/
public enum ChannelCodeEnum {
/**
* 好办绑定 解绑类型
*/
ADMIN_BIND(1001,"后台管理员绑定"),
SELF_BIND(1002,"好办客户端绑定"),
AUDIT_BIND(1003,"审核绑定"),
SELF_BIND(1002,"好办小程序绑定"),
AUDIT_BIND(1003,"后台审核绑定"),
SYNC_BIND(1004,"GIC同步绑定"),
ADMIN_UNBIND(2001,"后台管理员解绑"),
SELF_UNBIND(2002,"好办客户端解绑"),
SELF_UNBIND(2002,"好办小程序解绑"),
SYNC_UNBIND(2003,"GIC同步解绑"),
WEIXIN_DEL(2004,"微信删除解绑"),
AUDIT_UNBIND(2005,"审核解绑"),
RIGHT_CHANGE_UNBIND(2006, "权限变更解绑"),
STORE_CHANGE_UNBIND(2007, "门店变更解绑"),
// CHANGR_RIGHT_UNBIND(2005,"审核解绑"),
WEIXIN_DEL(2004,"员工离职解绑"),
AUDIT_UNBIND(2005,"后台审核解绑"),
RIGHT_CHANGE_UNBIND(2006, "好办门店权限变更解绑"),
STORE_CHANGE_UNBIND(2007, "GIC门店变更解绑"),
GIC_CLERK_DEL_UNBIND(2008, "GIC导购删除解绑"),
;
private int code;
private String name;
......@@ -41,6 +45,7 @@ public enum ChannelCodeEnum {
this.name = name;
}
public static String getNameByCode(int code) {
ChannelCodeEnum[] values = ChannelCodeEnum.values();
for (ChannelCodeEnum channelCodeEnum : values) {
......
package com.gic.haoban.manage.api.service;
import com.gic.haoban.manage.api.dto.CommonMQDTO;
/**
*
* @ClassName: HaobanCommonMQApiService
* @Description: 好办通用MQ
* @author xugh
* @date 2022年7月25日 下午2:27:06
*
*/
public interface HaobanCommonMQApiService {
public void commonHandler(CommonMQDTO dto) ;
}
......@@ -72,23 +72,26 @@ public interface HmQrcodeApiService {
/**
* 作废
*
* @param hmId hm id
* @return boolean
* @param hmId hm id
* @param invokingType 调用类型
* @return {@link ServiceResponse }
* @author mozhu
* @date 2022-07-06 13:40:27
* @date 2022-07-22 15:10:42
*/
ServiceResponse delById(Long hmId);
ServiceResponse delById(Long hmId,Integer invokingType);
/**
* 导购解绑作废
*
* @param clerkId
* @param enterpriseId 企业标识
* @return boolean
* @param enterpriseId 企业标识
* @param wxEnterpriseId wx企业标识
* @param invokingType 调用类型
* @return {@link ServiceResponse }
* @author mozhu
* @date 2022-07-06 15:39:01
* @date 2022-07-22 15:14:51
*/
ServiceResponse delByClerkId(String clerkId,String enterpriseId,String wxEnterpriseId);
ServiceResponse delByClerkId(String clerkId,String enterpriseId,String wxEnterpriseId,Integer invokingType);
/**
......@@ -141,7 +144,7 @@ public interface HmQrcodeApiService {
* @author mozhu
* @date 2022-07-08 15:07:15
*/
List<HmQrcodeStoreDTO> getHmStoreByEnterpriseId(String enterpriseId);
List<HmQrcodeStoreDTO> getHmStoreByEnterpriseId(String wxEnterpriseId , String enterpriseId);
/**
*
......@@ -152,7 +155,7 @@ public interface HmQrcodeApiService {
* @return
* @throws
*/
List<String> getHmStoreForWxa(String enterpriseId) ;
List<String> getHmStoreForWxa(String wxEnterpriseId ,String enterpriseId) ;
/**
* 根据导购信息获取hmid
......
......@@ -186,4 +186,23 @@ public interface StaffMapper {
int updateWxUserIdsByWxOpenUserId(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("wxOpenUseId") String wxOpenUseId,
@Param("wxUserId") String wxUserId);
/**
* 更新添加num通过id
*
* @param staffId 员工id
* @return int
* @author mozhu
* @date 2022-07-25 16:33:30
*/
int updateAddNumById(@Param("staffId") String staffId);
/**
* 重置添加num
*
* @return int
* @author mozhu
* @date 2022-07-25 16:36:07
*/
int resetAddNum();
}
\ No newline at end of file
package com.gic.haoban.manage.service.dao.mapper;
import com.gic.haoban.manage.service.entity.TabHaobanWxApplication;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.gic.haoban.manage.service.entity.TabHaobanWxApplication;
public interface WxApplicationMapper {
int insertSelective(TabHaobanWxApplication record);
......@@ -37,4 +40,6 @@ public interface WxApplicationMapper {
* @date 2022-06-30 19:19:19
*/
int updateCorpidById(@Param("wxApplicationId") String wxApplicationId, @Param("corpid") String corpid);
List<TabHaobanWxApplication> listApplication(@Param("wxEnterpriseId")String wxEnterpriseId) ;
}
\ No newline at end of file
......@@ -140,5 +140,17 @@ public interface TabHaobanHmClerkRelationMapper {
* @date 2022-07-21 16:32:43
*/
int updateStatusById(@Param("status") Integer status, @Param("relationId") Long relationId);
/**
* 查询需要删除的数据
*
* @param hmId hm id
* @param clerkIds 职员id
* @return {@link List }<{@link TabHaobanHmClerkRelation }>
* @author mozhu
* @date 2022-07-26 15:42:07
*/
List<TabHaobanHmClerkRelation> queryByHmIdNotInClerkIds(@Param("hmId") Long hmId,
@Param("clerkIds") List<String> clerkIds);
}
......@@ -157,7 +157,7 @@ public interface TabHaobanHmQrcodeMapper {
* @author mozhu
* @date 2022-07-08 15:10:57
*/
List<TabHaobanHmQrcode> getHmStoreByEnterpriseId(@Param("enterpriseId") String enterpriseId);
List<TabHaobanHmQrcode> getHmStoreByEnterpriseId(@Param("wxEnterpriseId")String wxEnterpriseId, @Param("enterpriseId") String enterpriseId);
/**
* 根据分组id获取活码数量
......@@ -203,7 +203,7 @@ public interface TabHaobanHmQrcodeMapper {
List<HmQrcodeClerkBO> listCanAddClerk(@Param("wxEnterpriseId")String wxEnterpriseId , @Param("enterpriseId")String enterpriseId , @Param("storeIdList")List<String> storeIdList);
List<String> getHmStoreForWxa(@Param("enterpriseId") String enterpriseId);
List<String> getHmStoreForWxa(@Param("wxEnterpriseId")String wxEnterpriseId , @Param("enterpriseId") String enterpriseId);
List<String> listHmIdForIndex(HmQrcodeListQDTO qdto);
......
......@@ -48,6 +48,7 @@ public class TabHaobanStaff implements Serializable {
private String wxOpenId;
private String qrCode;
private Integer addNum;
@Transient
private String departmentIds;
......@@ -227,4 +228,12 @@ public class TabHaobanStaff implements Serializable {
public void setDepartmentIds(String departmentIds) {
this.departmentIds = departmentIds;
}
public Integer getAddNum() {
return addNum;
}
public void setAddNum(Integer addNum) {
this.addNum = addNum;
}
}
\ No newline at end of file
......@@ -87,6 +87,15 @@ public class TabHaobanWxEnterprise implements Serializable {
*/
private Integer externalFlag;
private Integer useridFlag;
private Integer wxSecurityType ;
public Integer getWxSecurityType() {
return wxSecurityType;
}
public void setWxSecurityType(Integer wxSecurityType) {
this.wxSecurityType = wxSecurityType;
}
public String getMemberSecret() {
return memberSecret;
......
package com.gic.haoban.manage.service.pojo.bo.hm;
public class HmQrcodeClerkBO {
import java.io.Serializable;
public class HmQrcodeClerkBO implements Serializable {
private static final long serialVersionUID = 6292988639958194870L;
private String clerkId;
private String storeId;
......
......@@ -11,6 +11,15 @@ public class KeyDataLinkBO implements Serializable{
private String unionid;
private Long hmId;
private Long linkId;
private String mobile ;
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getUnionid() {
return unionid;
......
......@@ -144,5 +144,22 @@ public interface StaffService {
int updateUserIdByUserId(String wxEnterpriseId, String newWxUserId, String oldWxUserId);
/**
* 更新添加num通过id
*
* @param staffId 员工id
* @return int
* @author mozhu
* @date 2022-07-25 16:36:38
*/
int updateAddNumById(String staffId);
/**
* 重置添加num
*
* @return int
* @author mozhu
* @date 2022-07-25 16:36:53
*/
int resetAddNum();
}
package com.gic.haoban.manage.service.service;
import java.util.List;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import java.util.List;
public interface WxEnterpriseService {
String add(WxEnterpriseDTO wxDTO);
WxEnterpriseDTO selectById(String wxEnterpriseId);
/**
*
* @Title: getQwInfo
* @Description: 获取商户企微信息
* @author xugh
* @param wxEnterpriseId
* @return
* @throws
*/
WxEnterpriseQwDTO getQwInfo(String wxEnterpriseId);
/**
* 通过微信企业ID查询好办企业ID
......@@ -18,15 +31,6 @@ public interface WxEnterpriseService {
*/
TabHaobanWxEnterprise getEnterpriseBycorpId(String corpId);
/**
* 通过微信企业ID查询删除状态好办企业ID
*
* @param corpId
* @return
*/
@Deprecated
TabHaobanWxEnterprise getDelEnterpriseBycorpId(String corpId);
void update(WxEnterpriseDTO enterpriseDTO);
int delete(String wxEnterpriseId);
......
......@@ -159,4 +159,15 @@ public interface HmClerkRelationService {
*/
int updateStatusById(Integer status, Long relationId);
/**
* 查询需要删除的数据
*
* @param hmId hm id
* @param clerkIds 职员id
* @return {@link List }<{@link HmClerkRelationBO }>
* @author mozhu
* @date 2022-07-26 15:38:33
*/
List<HmClerkRelationBO> queryByHmIdNotInClerkIds(Long hmId, List<String> clerkIds);
}
......@@ -146,7 +146,7 @@ public interface HmQrcodeService {
* @author mozhu
* @date 2022-07-08 15:09:50
*/
List<HmQrcodeBO> getHmStoreByEnterpriseId(String enterpriseId);
List<HmQrcodeBO> getHmStoreByEnterpriseId(String wxEnterpriseId , String enterpriseId);
/**
......@@ -183,7 +183,7 @@ public interface HmQrcodeService {
List<HmQrcodeClerkBO> listCanAddClerk(String wxEnterpriseId , String enterpriseId , String clerkId) ;
List<String> getHmStoreForWxa(String enterpriseId);
List<String> getHmStoreForWxa(String wxEnterpriseId ,String enterpriseId);
List<String> listHmIdForIndex(HmQrcodeListQDTO qdto);
......
......@@ -111,4 +111,9 @@ public class HmClerkRelationServiceImpl implements HmClerkRelationService {
public int updateStatusById(Integer status, Long relationId) {
return tabHaobanHmClerkRelationMapper.updateStatusById(status,relationId);
}
@Override
public List<HmClerkRelationBO> queryByHmIdNotInClerkIds(Long hmId, List<String> clerkIds) {
return EntityUtil.changeEntityListByOrika(HmClerkRelationBO.class,tabHaobanHmClerkRelationMapper.queryByHmIdNotInClerkIds(hmId,clerkIds));
}
}
......@@ -117,9 +117,9 @@ public class HmQrcodeServiceImpl implements HmQrcodeService {
}
@Override
public List<HmQrcodeBO> getHmStoreByEnterpriseId(String enterpriseId) {
public List<HmQrcodeBO> getHmStoreByEnterpriseId(String wxEnterpriseId,String enterpriseId) {
return EntityUtil.changeEntityListNew(HmQrcodeBO.class,
tabHaobanHmQrcodeMapper.getHmStoreByEnterpriseId(enterpriseId));
tabHaobanHmQrcodeMapper.getHmStoreByEnterpriseId(wxEnterpriseId ,enterpriseId));
}
@Override
......@@ -171,8 +171,8 @@ public class HmQrcodeServiceImpl implements HmQrcodeService {
}
@Override
public List<String> getHmStoreForWxa(String enterpriseId) {
return tabHaobanHmQrcodeMapper.getHmStoreForWxa(enterpriseId) ;
public List<String> getHmStoreForWxa(String wxEnterpriseId ,String enterpriseId) {
return tabHaobanHmQrcodeMapper.getHmStoreForWxa(wxEnterpriseId , enterpriseId) ;
}
@Override
......
......@@ -82,7 +82,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
staffClerkBindLogService.pushToMq(clerkRelation.getStaffId(), optStaffId, BindTypeEnum.UNBIND.getVal(), chanelCode, clerkRelation.getStaffClerkRelationId());
//废弃活码
hmQrcodeApiService.delByClerkId(clerkId, clerkRelation.getEnterpriseId(),clerkRelation.getWxEnterpriseId());
hmQrcodeApiService.delByClerkId(clerkId, clerkRelation.getEnterpriseId(),clerkRelation.getWxEnterpriseId(),chanelCode);
}
return b;
}
......@@ -155,6 +155,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
hmQrcodeQDTO.setPassFlag(1);
hmQrcodeQDTO.setStoreId(dto.getStoreId());
hmQrcodeQDTO.setClerkIdList(Collections.singletonList(dto.getClerkId()));
hmQrcodeQDTO.setInvokingType(chanelCode);
hmQrcodeApiService.add(hmQrcodeQDTO);
}
return s;
......
......@@ -64,6 +64,7 @@ public class StaffServiceImpl implements StaffService {
tab.setStaffId(StringUtil.randomUUID());
}
tab.setStatusFlag(1);
tab.setAddNum(0);
mapper.insertSelective(tab);
return tab.getStaffId();
}
......@@ -180,4 +181,14 @@ public class StaffServiceImpl implements StaffService {
public int updateUserIdByUserId(String wxEnterpriseId, String newWxUserId, String oldWxUserId) {
return mapper.updateUserIdByUserId(wxEnterpriseId, newWxUserId, oldWxUserId);
}
@Override
public int updateAddNumById(String staffId) {
return mapper.updateAddNumById(staffId);
}
@Override
public int resetAddNum() {
return mapper.resetAddNum();
}
}
......@@ -17,8 +17,11 @@ import com.gic.commons.util.EntityUtil;
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.service.dao.mapper.WxApplicationMapper;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper;
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.service.WxEnterpriseService;
......@@ -31,9 +34,12 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService {
private WxEnterpriseMapper mapper;
@Autowired
private WxEnterpriseRelatedMapper wxEnterpriseRelatedMapper ;
@Autowired
private WxApplicationMapper wxApplicationMapper ;
@Override
public String add(WxEnterpriseDTO wxDTO) {
logger.info("新增wx_enterprise,dto={}",JSON.toJSONString(wxDTO));
Date now = new Date();
wxDTO.setWxEnterpriseId(StringUtil.randomUUID());
wxDTO.setCreateTime(now);
......@@ -52,7 +58,35 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService {
}
return EntityUtil.changeEntityByJSON(WxEnterpriseDTO.class, mapper.selectByPrimaryKey(wxEnterpriseId));
}
@Override
public WxEnterpriseQwDTO getQwInfo(String wxEnterpriseId) {
TabHaobanWxEnterprise wxEnterprise = this.mapper.selectByPrimaryKey(wxEnterpriseId) ;
WxEnterpriseQwDTO qw = new WxEnterpriseQwDTO();
qw.setCorpid(wxEnterprise.getCorpid());
qw.setWxEnterpriseId(wxEnterpriseId);
if(null != wxEnterprise.getWxSecurityType()) {
qw.setWxSecurityType(wxEnterprise.getWxSecurityType());
}
List<TabHaobanWxApplication> applictionList = this.wxApplicationMapper.listApplication(wxEnterpriseId) ;
if(CollectionUtils.isNotEmpty(applictionList)) {
applictionList.forEach(app->{
Integer appType = app.getApplicationType() ;
if(appType==2) {
qw.setThirdCorpid(app.getCorpid());
}else if(appType.equals(3)) {
qw.setDkCorpid(app.getCorpid());
}else if(appType.equals(4)) {
qw.setMemberCorpid(app.getCorpid());
}
});
}
qw.setSelfCorpid(wxEnterprise.getCorpid());
logger.info("企微所有corpid信息={}",JSON.toJSON(qw));
return qw;
}
@Override
public TabHaobanWxEnterprise getEnterpriseBycorpId(String corpId) {
if (StringUtils.isBlank(corpId)) {
......@@ -62,11 +96,6 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService {
}
@Override
public TabHaobanWxEnterprise getDelEnterpriseBycorpId(String corpId) {
return mapper.getEnterpriseBycorpId(corpId, 0);
}
@Override
public void update(WxEnterpriseDTO enterpriseDTO) {
enterpriseDTO.setUpdateTime(new Date());
mapper.updateByPrimaryKeySelective(EntityUtil.changeEntityByJSON(TabHaobanWxEnterprise.class, enterpriseDTO));
......
package com.gic.haoban.manage.service.service.out.impl;
import org.springframework.stereotype.Service;
import com.gic.haoban.manage.api.dto.CommonMQDTO;
import com.gic.haoban.manage.api.service.HaobanCommonMQApiService;
@Service("haobanCommonMQApiService")
public class HaobanCommonMQApiServiceImpl implements HaobanCommonMQApiService {
@Override
public void commonHandler(CommonMQDTO dto) {
}
}
......@@ -65,13 +65,13 @@ import com.gic.haoban.manage.service.util.EmojiFilterUtil;
import com.gic.member.api.dto.MemberDTO;
import com.gic.member.api.service.MemberApiService;
import com.gic.member.api.service.MemberOpenCardBusinessService;
import com.gic.member.api.service.MemberService;
import com.gic.member.api.service.MemberStoreService;
import com.gic.member.tag.api.dto.outapi.MemberTagSingleDTO;
import com.gic.member.tag.api.service.MemberTagOpenApiService;
import com.gic.mq.sdk.GicMQClient;
import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.dto.qywx.*;
import com.gic.wechat.api.dto.qywx.response.QywxResponseDTO;
import com.gic.wechat.api.dto.qywx.welcome.*;
import com.gic.wechat.api.enums.QywxMediaTypeEnum;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
......@@ -168,6 +168,8 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
private MemberTagOpenApiService memberTagOpenApiService;
@Autowired
private HmLinkService hmLinkService;
@Autowired
private MemberService memberService;
@Override
public void dealQywxExternalUser(String params) {
......@@ -320,6 +322,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
String unionid = dto.getUnionid();
String state = dto.getState();
boolean isHmUnionid = false;
String mobile = "";
log.info("新增外部联系人,wxEnterpriseId:{}", wxEnterpriseId);
if (StringUtils.isAnyBlank(wxUserId, wxEnterpriseId, name, createTime, externalUserId)) {
log.error("新增外部联系人,缺少必须字段:wxUserId:{},wxEnterpriseId:{},name:{},createTime:{},externalUserId:{}", wxUserId, wxEnterpriseId, name, createTime, externalUserId);
......@@ -347,17 +350,18 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
String memberLabelId = "";
if (StringUtils.isNotBlank(state)) {
String id = state.substring(2);
Long hmId = null;
HmQrcodeDTO hmQrcodeDTO = null;
if (state.contains(Manage3Constants.HM)) {
Long hmId = Convert.toLong(id);
hmId = Convert.toLong(id);
log.info("普通活码={}", hmId);
HmQrcodeDTO hmQrcodeDTO = hmQrcodeApiService.getSimpleById(hmId);
hmQrcodeDTO = hmQrcodeApiService.getSimpleById(hmId);
if (hmQrcodeDTO == null) {
log.error("活码为空:{}", hmId);
return;
}
memberLabelId = hmQrcodeDTO.getMemberLabelId();
wxUserAddLogQDTO.setHmId(hmId);
hmQrcodeApiService.updateAddNumById(hmId, hmQrcodeDTO.getClerkId());
//处理活码导购
if (hmQrcodeDTO.getHmType() == 1) {
staffClerkRelationDTO = staffClerkRelationService.getBindByClerkId(hmQrcodeDTO.getClerkId(), wxEnterpriseId);
......@@ -382,13 +386,14 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
} else if (state.contains(Manage3Constants.DT)) {
KeyDataLinkBO dataForHmLink = keyDataService.getDataForHmLink(id);
Long linkId = dataForHmLink.getLinkId();
Long hmId = dataForHmLink.getHmId();
hmId = dataForHmLink.getHmId();
mobile = dataForHmLink.getMobile();
unionid = dataForHmLink.getUnionid();
log.info("动态活码hmId={},linkId={},unionid={}", hmId, linkId, unionid);
isHmUnionid = true;
wxUserAddLogQDTO.setLinkId(linkId);
wxUserAddLogQDTO.setHmId(hmId);
HmQrcodeDTO hmQrcodeDTO = hmQrcodeApiService.getSimpleById(hmId);
hmQrcodeDTO = hmQrcodeApiService.getSimpleById(hmId);
if (hmQrcodeDTO == null) {
log.error("活码动态为空,hmId:{}", hmId);
return;
......@@ -399,6 +404,10 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
memberLabelId = hmLinkBO.getMemberLabelId();
}
}
if (hmId != null && hmQrcodeDTO != null) {
log.info("计算活码的上限和加好友数量:{}", hmId);
hmQrcodeApiService.updateAddNumById(hmId, hmQrcodeDTO.getClerkId());
}
} else {
TabHaobanClerkMainStoreRelated mainStoreRelated = clerkMainStoreRelatedService.getMainStoreByStaffId(staffId, wxEnterpriseId);
if (mainStoreRelated == null) {
......@@ -424,7 +433,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
if (StringUtils.isNotBlank(unionid)) {
log.info("有unionid处理:wxEnterpriseId:{},unionid:{}", wxEnterpriseId, unionid);
dto.setUnionid(unionid);
memberId = addExternalClerkRelated(dto, staffId, staffClerkRelationDTO, wxEnterpriseRelated, isHmUnionid);
memberId = addExternalClerkRelated(dto, staffId, staffClerkRelationDTO, wxEnterpriseRelated, isHmUnionid, mobile);
} else {
log.info("发送欢迎语逻辑:wxEnterpriseId:{}", wxEnterpriseId);
addFriendByWelcome(dto, staffClerkRelationDTO);
......@@ -435,6 +444,8 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
setMemberTag(staffClerkRelationDTO, memberLabelId, memberId);
}
//加好友增加数量
staffService.updateAddNumById(staffId);
log.info("插入加好友日志");
wxUserAddLogQDTO.setWxEnterpriseId(wxEnterpriseId);
wxUserAddLogQDTO.setEnterpriseId(enterpriseId);
......@@ -456,7 +467,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
* @param memberId
*/
private void setMemberTag(StaffClerkRelationDTO staffClerkRelationDTO, String memberLabelId, String memberId) {
log.info("会员打标签,memberLabelId:{},memberId:{}",memberLabelId,memberId);
log.info("会员打标签,memberLabelId:{},memberId:{}", memberLabelId, memberId);
if (StringUtils.isNotBlank(memberLabelId)) {
MemberTagSingleDTO tagSingleDTO = new MemberTagSingleDTO();
tagSingleDTO.setEnterpriseId(staffClerkRelationDTO.getEnterpriseId());
......@@ -475,7 +486,8 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
* @param staffClerkRelationDTO
* @param wxEnterpriseRelated
*/
private String addExternalClerkRelated(MemberUnionidRelatedDTO dto, String staffId, StaffClerkRelationDTO staffClerkRelationDTO, TabHaobanWxEnterpriseRelated wxEnterpriseRelated, boolean isHmUnionid) {
private String addExternalClerkRelated(MemberUnionidRelatedDTO dto, String staffId, StaffClerkRelationDTO staffClerkRelationDTO,
TabHaobanWxEnterpriseRelated wxEnterpriseRelated, boolean isHmUnionid, String mobile) {
String wxUserId = dto.getWxUserId();
String wxEnterpriseId = dto.getWxEnterpriseId();
String name = dto.getExternalName();
......@@ -516,12 +528,25 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
log.info("不能生产导购二维码:{}", JSONObject.toJSONString(clerk));
return "";
}
log.info("【新增外部联系人会员】enterpriseId={},unionId={},name={},avatar={},QrcodeParam={}", enterpriseId, unionId, name, avatar, qrcodeParam);
MemberDTO member = memberOpenCardBusinessService.getMemberByQywxChannelParam(enterpriseId, unionId, "", name, avatar, qrcodeParam);
MemberDTO member = null;
if (isHmUnionid) {
log.info("根据手机号查询会员:{},{}", enterpriseId, mobile);
if (StringUtils.isNotBlank(mobile)) {
member = memberService.getMemberByPhone(enterpriseId, mobile);
}
}
if (member == null) {
log.info("【新增外部联系人会员】enterpriseId={},unionId={},name={},avatar={},QrcodeParam={}", enterpriseId, unionId, name, avatar, qrcodeParam);
member = memberOpenCardBusinessService.getMemberByQywxChannelParam(enterpriseId, unionId, "", name, avatar, qrcodeParam);
}
if (member == null) {
log.info("生产会员memnerid失败:{}", unionId);
log.info("生产会员memberid失败:{}", unionId);
return "";
}
String memberId = member.getMemberId();
List<TabHaobanExternalClerkRelated> externalClerkRelateds = externalClerkRelatedService.listByExTernalUseridAndWxUserIdAllStatus(wxEnterpriseId, externalUserid, dto.getWxUserId());
String relationKey = SecureUtil.md5(staffId + externalUserid);
......@@ -658,10 +683,6 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
log.info("特殊欢迎语 state:{}", state);
WelcomeReferBO welcomeReferBo = getWelcomeReferBo(state);
welcomeDetailBO = welcomeService.getMatchWelcomeWithReferId(staffId, wxEnterpriseId, welcomeReferBo);
//结束临时会话模式
log.info("结束临时会话模式:userid:{},externalUserid:{}", dto.getWxUserId(), dto.getExternalUserid());
QywxResponseDTO qywxResponseDTO = qywxUserApiService.closeTempChat(corpid, config.getWxSuiteid(), dto.getWxUserId(), dto.getExternalUserid());
log.info("结束临时会话返回结果:{}", JSON.toJSONString(qywxResponseDTO));
} else {
welcomeDetailBO = welcomeService.getMatchWelcome(staffId, wxEnterpriseId);
}
......
......@@ -317,19 +317,19 @@ public class StaffApiServiceImpl implements StaffApiService {
res.setCode(4);
return res;
}
String staffThirdWxEnterpriseId = config.getStaffThirdWxEnterpriseId();
UserDTO user = null;
if (staffThirdWxEnterpriseId.contains(corpid)) {
WxEnterpriseQwDTO wxInfo = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if(wxInfo.getWxSecurityType()==4) {
user = qywxUserApiService.getWorkWxUser(corpid, config.getWxSuiteid(), userId);
UserDTO userSelf = qywxUserApiService.getSelfWorkWxUser(corpid, secretSetting.getSecretVal(), user.getOpen_userid());
logger.info("成员详情(第三方)={}",JSON.toJSONString(user)) ;
UserDTO userSelf = qywxUserApiService.getSelfWorkWxUser(wxInfo.getDkCorpid(), secretSetting.getSecretVal(), user.getOpen_userid());
if (user != null && userSelf != null) {
user.setName(userSelf.getName());
}
} else {
user = qywxUserApiService.getSelfWorkWxUser(corpid, secretSetting.getSecretVal(), userId);
logger.info("成员详情(代开)={}",JSON.toJSONString(user)) ;
}
if (null == user) {
logger.info("企业微信用户不存在:{}:{}", wxEnterpriseId, userId);
res.setMessage("企业微信用户不存在");
......
......@@ -238,7 +238,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
//删除绑定关系
tabHaobanStaffClerkRelationMapper.delByStoreIdAndCode(storeId, clerkCode);
//删除主门店
delSetMainStore(staffClerkRelation);
delSetMainStore(staffClerkRelation,ChannelCodeEnum.SELF_UNBIND.getCode());
}
@Override
......@@ -305,7 +305,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
public void delByClerkId(String clerkId) {
TabHaobanStaffClerkRelation staffClerkRelation = tabHaobanStaffClerkRelationMapper.getOneByClerkId(clerkId);
tabHaobanStaffClerkRelationMapper.delByClerkId(clerkId);
delSetMainStore(staffClerkRelation);
delSetMainStore(staffClerkRelation,ChannelCodeEnum.AUDIT_UNBIND.getCode());
}
@Override
......@@ -387,7 +387,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
staffClerkBindLogService.pushToMq(staffId, optStaffId, optType, channelCode, relationId);
}
private void delSetMainStore(TabHaobanStaffClerkRelation staffClerkRelation) {
private void delSetMainStore(TabHaobanStaffClerkRelation staffClerkRelation,Integer channelCode) {
if (staffClerkRelation == null) {
logger.info("staffClerkRelation为空");
return;
......@@ -399,7 +399,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
//删除主门店
clerkMainStoreRelatedService.delMainStore(staffId, staffClerkRelation.getStoreId(), wxEnterpriseId);
//废弃活码
hmQrcodeApiService.delByClerkId(clerkId,staffClerkRelation.getEnterpriseId(),wxEnterpriseId);
hmQrcodeApiService.delByClerkId(clerkId,staffClerkRelation.getEnterpriseId(),wxEnterpriseId,channelCode);
}
@Override
......@@ -495,7 +495,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
//导购删除解绑
if (!clerkDTO.getStatus().equals(1)) {
//解绑
staffClerkRelationService.delBind(clerkId, "-1", ChannelCodeEnum.SYNC_UNBIND.getCode());
staffClerkRelationService.delBind(clerkId, "-1", ChannelCodeEnum.GIC_CLERK_DEL_UNBIND.getCode());
}
} else if (type == 2) {
//门店转移、重新绑定
......
......@@ -34,7 +34,6 @@ import com.gic.haoban.manage.api.dto.WelcomeDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.YwWxEnterpriseDTO;
import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanWelcomeMapper;
......@@ -60,8 +59,6 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
@Autowired
private WxEnterpriseService wxEnterpriseService;
@Autowired
private StaffApiService staffApiService;
@Autowired
private WxEnterpriseMapper wxEnterpriseMapper;
@Autowired
private WxApplicationService wxApplicationService;
......@@ -92,7 +89,6 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
String agentName = dto.getAgentName();
String permanentCode = dto.getPermanentCode();
String applicationName = dto.getName();
String userId = dto.getUserid();
Integer isCustomizedApp = dto.getIsCustomizedApp();
String qywxMemberSuite = config.getQywxMemberSuite();
WxEnterpriseDTO wxDTO = EntityUtil.changeEntityByJSON(WxEnterpriseDTO.class, dto);
......@@ -101,6 +97,7 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
// 获取授权好办小程序
wxEnterprise = this.wxEnterpriseService.getEnterpriseBycorpId(corpid);
if (wxEnterprise == null) {
log.info("通过corpid={}未查到记录",corpid);
wxEnterprise = this.wxEnterpriseService.getEnterpriseByCorpName(corpName);
}
......@@ -110,16 +107,19 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
wxEnterpriseDTO.setWxEnterpriseId(wxEnterpriseId);
wxEnterpriseDTO.setStatusFlag(1);
wxEnterpriseDTO.setBindFlag(1);
wxEnterpriseService.update(wxDTO);
// 如果corpid为空且是好办小程序,写入corpid
wxEnterpriseService.update(wxEnterpriseDTO);
} else {
// 如果不是好办,不需要写入corpid
wxEnterpriseId = wxEnterpriseService.add(wxDTO);
}
if (StringUtils.isNotBlank(userId)) {
/*if (StringUtils.isNotBlank(userId)) {
staffApiService.wxGetAdd(userId, wxEnterpriseId);
}
}*/
TabHaobanWxApplication haobanWxApplication = wxApplicationService.selectBySiteIdAndWxEnterpriseId(siteId,
wxEnterpriseId);
if (haobanWxApplication == null) {
log.info("新增应用,suiteid={}",siteId);
haobanWxApplication = new TabHaobanWxApplication();
haobanWxApplication.setAgentId(agentId);
haobanWxApplication.setCorpid(corpid);
......
......@@ -3,7 +3,6 @@ package com.gic.haoban.manage.service.service.out.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.clerk.api.service.RightService;
......@@ -16,16 +15,19 @@ import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.enterprise.api.service.StoreGroupService;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.base.api.common.errCode.HaoBanErrCodeCommon;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.common.utils.UuidUtil;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.enums.ChannelCodeEnum;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseRelatedMapper;
import com.gic.haoban.manage.service.entity.*;
import com.gic.haoban.manage.service.service.*;
import com.gic.haoban.manage.service.service.DepartmentService;
import com.gic.haoban.manage.service.service.MiniprogramSettingService;
import com.gic.haoban.manage.service.service.StoreRangeService;
import com.gic.haoban.manage.service.service.WxEnterpriseRelatedService;
import com.gic.mq.sdk.GicMQClient;
import com.gic.redis.data.util.RedisUtil;
import com.google.common.collect.Sets;
......@@ -58,14 +60,10 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
@Autowired
private DepartmentService departmentService;
@Autowired
private StaffService staffService;
@Autowired
private MiniprogramSettingService miniprogramSettingService;
@Autowired
private AuthorizeService authorizeService;
@Autowired
private StaffMapper staffMapper;
@Autowired
private EnterpriseService enterpriseService;
@Autowired
private StoreRangeService storeRangeService;
......@@ -74,7 +72,7 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
@Autowired
private RightService rightService;
@Autowired
private ClerkService clerkService ;
private ClerkService clerkService;
/**
* 查询好办所有的企业id
......@@ -88,36 +86,36 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
@Override
public List<EnterpriseDetailDTO> listEnterpriseByWxEnterpriseId(String wxEnterpriseId) {
return this.listEnterpriseByWxEnterpriseId(wxEnterpriseId, null,false) ;
return this.listEnterpriseByWxEnterpriseId(wxEnterpriseId, null, false);
}
@Override
public EnterpriseDetailDTO getByEnterpriseId(String wxEnterpriseId, String enterpriseId) {
TabHaobanWxEnterpriseRelated entity = wxEnterpriseRelatedService.getByEnterpriseId(wxEnterpriseId, enterpriseId);
EnterpriseDetailDTO dto = EntityUtil.changeEntityByJSON(EnterpriseDetailDTO.class, entity);
return dto ;
return dto;
}
@Override
public List<EnterpriseDetailDTO> listEnterpriseByWxEnterpriseIdList(List<String> wxEnterpriseIdList) {
List<TabHaobanWxEnterpriseRelated> relatedList = this.wxEnterpriseRelatedMapper.listByWxenterpriseIdList(wxEnterpriseIdList) ;
if(CollectionUtils.isNotEmpty(relatedList)) {
List<TabHaobanWxEnterpriseRelated> relatedList = this.wxEnterpriseRelatedMapper.listByWxenterpriseIdList(wxEnterpriseIdList);
if (CollectionUtils.isNotEmpty(relatedList)) {
List<EnterpriseDetailDTO> list = EntityUtil.changeEntityListByJSON(EnterpriseDetailDTO.class, relatedList);
for(EnterpriseDetailDTO item : list) {
String enterpriseId = item.getEnterpriseId() ;
EnterpriseDTO en = this.enterpriseService.getEnterpriseById(enterpriseId) ;
if(null != en) {
for (EnterpriseDetailDTO item : list) {
String enterpriseId = item.getEnterpriseId();
EnterpriseDTO en = this.enterpriseService.getEnterpriseById(enterpriseId);
if (null != en) {
item.setEnterpriseName(en.getBrandName());
}
}
return list ;
return list;
}
return null;
}
@Override
public List<EnterpriseDetailDTO> listEnterpriseByWxEnterpriseId(String wxEnterpriseId, String phoneNumber,boolean filterFlag) {
logger.info("listEnterpriseByWxEnterpriseId,wxeid={},phone={}",wxEnterpriseId,phoneNumber);
public List<EnterpriseDetailDTO> listEnterpriseByWxEnterpriseId(String wxEnterpriseId, String phoneNumber, boolean filterFlag) {
logger.info("listEnterpriseByWxEnterpriseId,wxeid={},phone={}", wxEnterpriseId, phoneNumber);
List<TabHaobanWxEnterpriseRelated> relatedList = wxEnterpriseRelatedMapper.listByWxenterpriseId(wxEnterpriseId);
List<EnterpriseDetailDTO> list = EntityUtil.changeEntityListByJSON(EnterpriseDetailDTO.class, relatedList);
if (CollectionUtils.isEmpty(list)) {
......@@ -126,9 +124,9 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
List<String> enterpriseIds = list.stream().map(s -> s.getEnterpriseId()).collect(Collectors.toList());
List<EnterpriseDTO> enterpriseList = enterpriseService.listEnterpriseByIds(enterpriseIds);
Map<String, EnterpriseDTO> map = com.gic.commons.util.CollectionUtil.toMap(enterpriseList, "enterpriseId");
Iterator<EnterpriseDetailDTO> it = list.iterator() ;
while(it.hasNext()) {
EnterpriseDetailDTO dto = it.next() ;
Iterator<EnterpriseDetailDTO> it = list.iterator();
while (it.hasNext()) {
EnterpriseDetailDTO dto = it.next();
EnterpriseDTO enterpriseDTO = map.get(dto.getEnterpriseId());
if (enterpriseDTO != null) {
dto.setEnterpriseName(enterpriseDTO.getEnterpriseName());
......@@ -137,12 +135,12 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
dto.setConactsPhone(enterpriseDTO.getConactsPhone());
dto.setCustomerPhone(enterpriseDTO.getCustomerPhone());
dto.setAclFlag(1);
if(StringUtils.isNotBlank(phoneNumber)) {
com.gic.api.base.commons.ServiceResponse<Boolean> resp = this.rightService.hasHaobanAcl(enterpriseDTO.getEnterpriseId(), phoneNumber) ;
if(!resp.getResult()) {
if (StringUtils.isNotBlank(phoneNumber)) {
com.gic.api.base.commons.ServiceResponse<Boolean> resp = this.rightService.hasHaobanAcl(enterpriseDTO.getEnterpriseId(), phoneNumber);
if (!resp.getResult()) {
dto.setAclFlag(0);
if(filterFlag) {
it.remove();
if (filterFlag) {
it.remove();
}
}
}
......@@ -215,20 +213,28 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
resp.setMessage("总部已经被设置不能存在多个总部!");
return resp;
}
String enterpriseId = detailDTO.getEnterpriseId();
String wxEnterpriseId = detailDTO.getWxEnterpriseId();
//校验关联已经企业绑定
TabHaobanWxEnterpriseRelated tab = wxEnterpriseRelatedMapper.findOneByEIdAndWxEid(detailDTO.getEnterpriseId(), detailDTO.getWxEnterpriseId());
TabHaobanWxEnterpriseRelated tab = wxEnterpriseRelatedMapper.findOneByEIdAndWxEid(enterpriseId, wxEnterpriseId);
if (tab != null && (!tab.getWxEnterpriseRelatedId().equals(detailDTO.getWxEnterpriseRelatedId()))) {
logger.info("该企业已经被绑定过");
resp.setCode(2);
resp.setMessage("该企业已经被绑定过!");
return resp;
}
EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(enterpriseId);
if (enterpriseDTO == null) {
logger.info("该企业为空:{}", enterpriseId);
resp.setCode(2);
resp.setMessage("该企业为空");
return resp;
}
if (tab == null) {
logger.info("该gicEnterpriseId已经绑定过了:{}", JSONObject.toJSONString(detailDTO));
//保存企业关联关系
tab = EntityUtil.changeEntityNew(TabHaobanWxEnterpriseRelated.class, detailDTO);
tab.setEnterpriseName(enterpriseDTO.getEnterpriseName());
tab.setStatusFlag(1);
tab.setRangeType(1);
tab.setVersion("3.0");
......@@ -245,18 +251,9 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
}
//保存门店范围
storeRangeService.saveStoreRange(detailDTO.getRelations(), detailDTO.getEnterpriseId(), detailDTO.getWxEnterpriseId());
/*//超级管理员新增
TabHaobanStaff sStaff = staffMapper.selectSuperByWxEnterpriseId(detailDTO.getWxEnterpriseId());
if (sStaff == null) {
TabHaobanStaff staff = new TabHaobanStaff();
staff.setStaffName("超级管理员");
staff.setWxEnterpriseId(detailDTO.getWxEnterpriseId());
staff.setSuperManagerFlag(1);
staffService.add(staff);
}*/
EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(detailDTO.getEnterpriseId());
List<EnterpriseWxaRelationDTO> relationDTOList = authorizeService.queryList(detailDTO.getEnterpriseId());
storeRangeService.saveStoreRange(detailDTO.getRelations(), enterpriseId, wxEnterpriseId);
List<EnterpriseWxaRelationDTO> relationDTOList = authorizeService.queryList(enterpriseId);
if (CollectionUtils.isEmpty(relationDTOList)) {
logger.info("relationDTOList is null");
return resp;
......@@ -266,30 +263,30 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
logger.info("relationDTO is null");
return resp;
}
TabMiniprogramSetting miniprogramSetting = miniprogramSettingService.getMiniprogramSettingNoMedia(detailDTO.getWxEnterpriseId(), detailDTO.getEnterpriseId());
TabMiniprogramSetting miniprogramSetting = miniprogramSettingService.getMiniprogramSettingNoMedia(wxEnterpriseId, enterpriseId);
if (null == miniprogramSetting) {
miniprogramSetting = new TabMiniprogramSetting();
}
miniprogramSetting.setWxEnterpriseId(detailDTO.getWxEnterpriseId());
miniprogramSetting.setWxEnterpriseId(wxEnterpriseId);
miniprogramSetting.setAppId(relationDTO.getWxaAppkey());
miniprogramSetting.setImageUrl(enterpriseDTO.getMallMiniprogramLogoUrl());
miniprogramSetting.setMiniprogramName(relationDTO.getAuthName());
miniprogramSetting.setEnterpriseId(detailDTO.getEnterpriseId());
miniprogramSetting.setEnterpriseId(enterpriseId);
miniprogramSetting.setTitle(relationDTO.getAuthName());
miniprogramSettingService.saveMiniprogramSetting(miniprogramSetting);
//刷新门店信息
ServiceResponse response = this.flushBindStoreByEnterpriseId(detailDTO.getEnterpriseId(), detailDTO.getWxEnterpriseId(), detailDTO.getStaffId(), ChannelCodeEnum.RIGHT_CHANGE_UNBIND.getCode());
ServiceResponse response = this.flushBindStoreByEnterpriseId(enterpriseId, wxEnterpriseId, detailDTO.getStaffId(), ChannelCodeEnum.RIGHT_CHANGE_UNBIND.getCode());
logger.info("刷新返回信息:{}", JSONObject.toJSONString(response));
//如果已经在刷新了 需要放入队列再刷新
if (response.getCode() == 2) {
logger.info("放入队列刷新:{}", detailDTO.getEnterpriseId());
logger.info("放入队列刷新:{}", enterpriseId);
FlushStoreMqDTO flushStoreMqDTO = new FlushStoreMqDTO();
flushStoreMqDTO.setEnterpriseId(detailDTO.getEnterpriseId());
flushStoreMqDTO.setEnterpriseId(enterpriseId);
flushStoreMqDTO.setOptStaffId(detailDTO.getStaffId());
flushStoreMqDTO.setWxEnterpriseId(detailDTO.getWxEnterpriseId());
flushStoreMqDTO.setWxEnterpriseId(wxEnterpriseId);
flushStoreMqDTO.setChannalCode(ChannelCodeEnum.ADMIN_UNBIND.getCode());
this.flushBindStoreToDelayMq(detailDTO.getEnterpriseId(), flushStoreMqDTO);
this.flushBindStoreToDelayMq(enterpriseId, flushStoreMqDTO);
}
return resp;
}
......@@ -425,7 +422,7 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
// 获取所有门店信息
List<StoreSimpleDTO> storeDtos = storeService.listSimpleStore(enterpriseId, null, null);
logger.info("所有门店数={},{}",enterpriseId,storeDtos.size());
logger.info("所有门店数={},{}", enterpriseId, storeDtos.size());
Map<String, List<String>> storeMapByGroupId = storeDtos.stream().filter(dto -> StringUtils.isNotBlank(dto.getStoreGroupId())).collect(Collectors.groupingBy(dto -> dto.getStoreGroupId(), Collectors.mapping(dto -> dto.getStoreId(), Collectors.toList())));
Map<String, StoreSimpleDTO> storeIdMap = storeDtos.stream().collect(Collectors.toMap(dto -> dto.getStoreId(), dto -> dto));
......@@ -513,28 +510,28 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
List<WxEnterpriseDTO> ret = EntityUtil.changeEntityListNew(WxEnterpriseDTO.class, wxEnterprises);
return ret;
}
@Override
public List<WxEnterpriseDTO> listWxEnterpriseByEid(String enterpriseId, String clerkPhoneNumber) {
List<WxEnterpriseDTO> list = new ArrayList<>();
List<WxEnterpriseDTO> list = new ArrayList<>();
ClerkDTO clerk = this.clerkService.getUserByPhoneNumber(clerkPhoneNumber, enterpriseId);
if(null == clerk || (StringUtils.isBlank(clerk.getHbEnt()) && null != clerk.getSuperAdmin() && 0==clerk.getSuperAdmin())) {
logger.info("导购校验不通过,不存在或hbEnt为空,clerkPhoneNumber={},eid={}",clerkPhoneNumber,enterpriseId);
return list ;
}
List<WxEnterpriseDTO> dtoList = this.listWxEnterpriseByEid(enterpriseId) ;
logger.info("用户管辖微信企业phone={},hbEnt={},dtoList={},super={}",clerkPhoneNumber,clerk.getHbEnt(),JSON.toJSONString(dtoList),clerk.getSuperAdmin());
if(CollectionUtils.isEmpty(dtoList)) {
return list ;
}
if(null != clerk.getSuperAdmin() && 0 == clerk.getSuperAdmin()) {
for(WxEnterpriseDTO item : dtoList) {
if(clerk.getHbEnt().contains(item.getWxEnterpriseId())) {
list.add(item) ;
if (null == clerk || (StringUtils.isBlank(clerk.getHbEnt()) && null != clerk.getSuperAdmin() && 0 == clerk.getSuperAdmin())) {
logger.info("导购校验不通过,不存在或hbEnt为空,clerkPhoneNumber={},eid={}", clerkPhoneNumber, enterpriseId);
return list;
}
List<WxEnterpriseDTO> dtoList = this.listWxEnterpriseByEid(enterpriseId);
logger.info("用户管辖微信企业phone={},hbEnt={},dtoList={},super={}", clerkPhoneNumber, clerk.getHbEnt(), JSON.toJSONString(dtoList), clerk.getSuperAdmin());
if (CollectionUtils.isEmpty(dtoList)) {
return list;
}
if (null != clerk.getSuperAdmin() && 0 == clerk.getSuperAdmin()) {
for (WxEnterpriseDTO item : dtoList) {
if (clerk.getHbEnt().contains(item.getWxEnterpriseId())) {
list.add(item);
}
}
}else {
return dtoList ;
} else {
return dtoList;
}
return list;
}
......@@ -643,17 +640,13 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
if (tabHaobanWxEnterpriseRelated == null) {
return false;
}
/* if (tabHaobanWxEnterpriseRelated.getWxEnterpriseType() == 1) {
logger.info("非总部不能设置好友");
return false;
}*/
wxEnterpriseRelatedService.setClerkEdit(wxEnterprieseRelatedId, clerkEditFlag);
return true;
}
@Override
public void saveClerkEditFlag(String wxEnterpriseId, String enterpriseId, int value) {
this.wxEnterpriseRelatedMapper.saveClerkEditFlag(wxEnterpriseId,enterpriseId,value) ;
this.wxEnterpriseRelatedMapper.saveClerkEditFlag(wxEnterpriseId, enterpriseId, value);
}
@Override
......@@ -665,18 +658,18 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
//return enterpriseRelated.getWxEnterpriseType() == 0;
return true;
}
@Override
public List<StoreOrGroupInfoDTO> queryBindStoreRange(String enterpriseId, String wxEnterpriseId) {
return this.storeRangeService.queryBindStoreRange(enterpriseId, wxEnterpriseId);
}
@Override
public List<String> listStoreIdByName(String wxEnterpriseId, String enterpriseId, String storeName) {
if(StringUtils.isAnyBlank(wxEnterpriseId,enterpriseId,storeName)) {
return null ;
if (StringUtils.isAnyBlank(wxEnterpriseId, enterpriseId, storeName)) {
return null;
}
return this.storeRangeService.listStoreIdByName(wxEnterpriseId, enterpriseId,storeName);
return this.storeRangeService.listStoreIdByName(wxEnterpriseId, enterpriseId, storeName);
}
/**
......@@ -690,13 +683,13 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
public com.gic.api.base.commons.ServiceResponse<EnterpriseDetailDTO> queryEnterpriseDetail(String wxEnterpriseId, String enterpriseId) {
TabHaobanWxEnterpriseRelated oneByEnterpriseId = wxEnterpriseRelatedMapper.findOneByEIdAndWxEid(enterpriseId, wxEnterpriseId);
if (oneByEnterpriseId == null){
return com.gic.api.base.commons.ServiceResponse.failure(HaoBanErrCodeCommon.ERR_8.getCode()+"", HaoBanErrCodeCommon.ERR_8.getMsg());
if (oneByEnterpriseId == null) {
return com.gic.api.base.commons.ServiceResponse.failure(HaoBanErrCodeCommon.ERR_8.getCode() + "", HaoBanErrCodeCommon.ERR_8.getMsg());
}
EnterpriseDetailDTO enterpriseDetailDTO = EntityUtil.changeEntity(EnterpriseDetailDTO.class, oneByEnterpriseId);
EnterpriseDTO enterprise = enterpriseService.getEnterpriseById(enterpriseId);
if (enterprise == null){
return com.gic.api.base.commons.ServiceResponse.failure(HaoBanErrCodeCommon.ERR_8.getCode()+"", HaoBanErrCodeCommon.ERR_8.getMsg());
if (enterprise == null) {
return com.gic.api.base.commons.ServiceResponse.failure(HaoBanErrCodeCommon.ERR_8.getCode() + "", HaoBanErrCodeCommon.ERR_8.getMsg());
}
enterpriseDetailDTO.setEnterpriseName(enterprise.getEnterpriseName());
enterpriseDetailDTO.setEnterpriseLogo(enterprise.getQcloudImageUrl());
......
......@@ -163,7 +163,7 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
Map<String, String> remarkMap = new HashMap<>();
if (null == link) {
log.error("链接记录不存,linkShortCode={}", linkShortCode);
return ServiceResponse.failure(HaoBanErrCode.ERR_OTHER.getCode(), "链接记录不存");
return ServiceResponse.failure(HaoBanErrCode.ERR_OTHER.getCode(), "无效的链接");
}
// 查询页面
retDTO.setPageId(link.getPageId());
......@@ -174,16 +174,20 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
}
Long linkId = link.getLinkId();
String wxEnterpriseId = link.getWxEnterpriseId();
retDTO.setWxEnterpriseId(wxEnterpriseId);
retDTO.setEnterpriseId(enterpriseId);
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
if (wxEnterpriseDTO == null) {
log.error("未查询到微信企业,id={}", wxEnterpriseId);
return ServiceResponse.failure(HaoBanErrCode.ERR_OTHER.getCode(), "未查到微信企业");
return ServiceResponse.failure(HaoBanErrCode.ERR_OTHER.getCode(), "未查到微信企业");
}
// 判断导购是否有活码,如果没有返回错误
if (StringUtils.isNotBlank(inClerkId)) {
hm = this.getHmFromClerk(inClerkId, wxEnterpriseId);
if (null == hm) {
return ServiceResponse.failure(HaoBanErrCode.ERR_OTHER.getCode(), "导购活码不存在");
remarkMap.put("reason","无任何导购活码");
retDTO.setRemarkMap(remarkMap);
return ServiceResponse.success(retDTO) ;
}
}
// 直接返回门店的导购活码,如果没有返回错误
......@@ -220,11 +224,22 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
hm = this.getHmFormStore(wxEnterpriseId, inStoreId, dz, dy, new ArrayList<>());
log.info("获取到的门店配置dz={},dy={},获取的活码={}", dz, dy, JSON.toJSONString(hm));
if (null == hm) {
return ServiceResponse.failure(HaoBanErrCode.ERR_OTHER.getCode(), "导购活码不存在");
remarkMap.put("reason","无任何导购活码");
retDTO.setRemarkMap(remarkMap);
return ServiceResponse.success(retDTO) ;
}
remarkMap.put("sm", "会员选门店活码");
}
}
String mobile = null ;
if (StringUtils.isNotEmpty(mixPhone)) {
mobile = this.keyDataService.getMobile(mixPhone, linkShortCode);
log.info("查询手机号,mobile={},mixPhone={}", mobile, mixPhone);
String mobileMemberId = this.memberService.getMemberIdByPhoneNumber(mobile, enterpriseId);
if (StringUtils.isNotBlank(mobileMemberId)) {
memberId = mobileMemberId;
}
}
// 会员门店
if (null == hm) {
HmLinkStoreSettingDTO fwStore = null;
......@@ -241,14 +256,6 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
if (null == xgStore || xgStore.getOpen() == 0) {
xgStore = null;
}
if (StringUtils.isNotEmpty(mixPhone)) {
String mobile = this.keyDataService.getMobile(mixPhone, linkShortCode);
log.info("小程序获取活码mobile={},mixPhone={}", mobile, mixPhone);
String mobileMemberId = this.memberService.getMemberIdByPhoneNumber(mobile, enterpriseId);
if (StringUtils.isNotBlank(mobileMemberId)) {
memberId = mobileMemberId;
}
}
log.info("小程序获取活码memberId={}", memberId);
if (StringUtils.isNotBlank(memberId)) {
MemberDataDTO member = this.getMemberClerk(enterpriseId, memberId);
......@@ -258,16 +265,22 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
if (null != fwStore) {
log.info("处理服务门店逻辑");
List<String> clerkIdList = new ArrayList<>() ;
if (fwStore.getZs() == 1 && StringUtils.isNotBlank(mainClerkId)) {
hm = this.getHmFromClerk(mainClerkId, wxEnterpriseId);
if(StringUtils.isNotBlank(mainClerkId)) {
clerkIdList.add(mainClerkId);
if (fwStore.getZs() == 1) {
hm = this.getHmFromClerk(mainClerkId, wxEnterpriseId);
if(null != hm) {
log.info("获取服务导购活码,mainClerkId={}",mainClerkId);
remarkMap.put("sm", "主门店-服务导购");
}
}
}
if (null == hm && StringUtils.isNotBlank(mainStoreId)) {
hm = this.getHmFormStore(wxEnterpriseId, mainStoreId, fwStore.getDz(), fwStore.getDy(),
clerkIdList);
}
if (null != hm) {
remarkMap.put("sm", "会员主门店活码");
if (null != hm) {
remarkMap.put("sm", "主门店-店长-店员");
}
}
}
// 协管门店
......@@ -287,6 +300,7 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
}
hm = this.getHmFromClerk(clerkId, wxEnterpriseId);
if (null != hm) {
remarkMap.put("sm", "协管活码-主导购");
storeIdList = null;
break;
}
......@@ -298,6 +312,7 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
for (String storeId : storeIdList) {
hm = this.getHmFormStore(wxEnterpriseId, storeId, 1, 0, clerkIdList);
if (null != hm) {
remarkMap.put("sm", "协管活码-店长");
break;
}
}
......@@ -307,13 +322,11 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
for (String storeId : storeIdList) {
hm = this.getHmFormStore(wxEnterpriseId, storeId, 0, 1, clerkIdList);
if (null != hm) {
remarkMap.put("sm", "协管活码-店员");
break;
}
}
}
if (null != hm) {
remarkMap.put("sm", "会员协管活码");
}
}
}
}
......@@ -363,6 +376,9 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
bo.setUnionid(unionid);
bo.setLinkId(linkId);
bo.setHmId(hm.getHmId());
if(StringUtils.isNotBlank(mixPhone) && StringUtils.isNotBlank(mobile)) {
bo.setMobile(mobile);
}
String dthmKey = this.keyDataService.saveDataForLink(enterpriseId, bo);
remarkMap.put("dthmKey", dthmKey);
if (null != dthmKey) {
......@@ -370,7 +386,9 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
if (!addResp.isSuccess()) {
remarkMap.put("sm", "创建动态活码失败,取单人活码");
if (StringUtils.isBlank(hm.getWxQrcode())) {
return ServiceResponse.failure(HaoBanErrCode.ERR_OTHER.getCode(), "导购活码不存在");
remarkMap.put("reason","无任何导购活码");
retDTO.setRemarkMap(remarkMap);
return ServiceResponse.success(retDTO) ;
}
retDTO.setHmQrcode(hm.getWxQrcode());
} else {
......@@ -492,7 +510,7 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
if (dz == 1) {
hm = this.getHmFromClerk(dzClerk.getClerkId(), wxEnterpriseId);
if (null != hm) {
log.info("选择门店后,获取到店长活码,clerkId={},inStoreId={}", hm.getClerkId(), inStoreId);
log.info("获取到店长活码,clerkId={},inStoreId={}", hm.getClerkId(), inStoreId);
}
}
} else {
......@@ -502,12 +520,15 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
log.info("过滤的导购={}",clerkIdList);
if (null == hm && dy == 1) {
List<HmQrcodeBO> list = this.hmQrcodeService.listByStoreId(wxEnterpriseId, inStoreId, 0);
list = list.stream().filter(dto -> !clerkIdList.contains(dto.getClerkId())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(list)) {
log.info("选择门店下{},导购数={}", inStoreId, list.size());
log.info("查询门店下有活码的导购数={}",list.size());
list = list.stream().filter(dto -> !clerkIdList.contains(dto.getClerkId())).collect(Collectors.toList());
}
if (CollectionUtils.isNotEmpty(list)) {
log.info("门店下{},导购数={}", inStoreId, list.size());
hm = list.get(new Random().nextInt(list.size()));
if (null != hm) {
log.info("选择门店后,获取到店员活码,clerkId={},inStoreId={}", hm.getClerkId(), inStoreId);
log.info("获取到店员活码,clerkId={},inStoreId={}", hm.getClerkId(), inStoreId);
}
}
}
......
......@@ -22,6 +22,7 @@ import com.gic.haoban.manage.api.dto.hm.HmQrcodeStoreDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.HmClerkRelationQDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeListQDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeQDTO;
import com.gic.haoban.manage.api.enums.ChannelCodeEnum;
import com.gic.haoban.manage.api.enums.hm.HmWelcomeReferType;
import com.gic.haoban.manage.api.service.hm.HmQrcodeApiService;
import com.gic.haoban.manage.service.config.Config;
......@@ -153,16 +154,39 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
}
hmQrcodeQDTO.setWxQrcode(qywxExternalcontactResultDTO.getQr_code());
hmQrcodeQDTO.setWxConfigId(qywxExternalcontactResultDTO.getConfig_id());
//操作日志
addLog(hmQrcodeQDTO, wxEnterpriseId, hmId);
int saveResult = hmQrcodeService.insert(hmQrcodeQDTO);
if (saveResult == 1) {
// save welcome relation
this.updateWelcomeRelation(hmQrcodeQDTO);
}
setLoggerContext(hmQrcodeQDTO.getEnterpriseId(), wxEnterpriseId, hmQrcodeQDTO.getCreatorId(), hmQrcodeQDTO.getCreatorName());
GicLogRecordEvaluationContext.putAttribute("logContent", "【" + hmId + "-" + hmQrcodeQDTO.getName() + "】");
return ServiceResponse.success();
}
private void addLog(HmQrcodeQDTO hmQrcodeQDTO, String wxEnterpriseId, Long hmId) {
Integer invokingType = hmQrcodeQDTO.getInvokingType();
if (invokingType == 0) {
GicLogRecordEvaluationContext.noWriteLog();
} else {
//操作日志
setLoggerContext(hmQrcodeQDTO.getEnterpriseId(), wxEnterpriseId, hmQrcodeQDTO.getCreatorId(), hmQrcodeQDTO.getCreatorName());
String logContent = "【" + hmId + "-" + hmQrcodeQDTO.getName() + "】";
if (StringUtils.isBlank(logContent)) {
GicLogRecordEvaluationContext.noWriteLog();
} else {
if (invokingType != 1) {
logContent = logContent + "——" + ChannelCodeEnum.getNameByCode(invokingType);
}
GicLogRecordEvaluationContext.putAttribute("logContent", logContent);
logger.info("新增活码日志:logText:{}", logContent);
}
}
}
@Override
@Transactional(rollbackFor = Exception.class)
@GicLogRecord(value = "批量新增员工活码-${#logContent}",
......@@ -184,19 +208,25 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
}
if (clerkIdList.contains("-1")) {
List<HmQrcodeClerkBO> hmQrcodeClerkBOS = hmQrcodeService.listCanAddClerk(wxEnterpriseId, enterpriseId, hmQrcodeQDTO.getCreatorId());
clerkIdList = hmQrcodeClerkBOS.stream().map(HmQrcodeClerkBO::getClerkId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(clerkIdList)) {
if (CollectionUtils.isEmpty(hmQrcodeClerkBOS)) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_5.getCode()), "无需要生成活码导购");
}
clerkIdList = hmQrcodeClerkBOS.stream().map(HmQrcodeClerkBO::getClerkId).filter(StringUtils::isNotBlank).collect(Collectors.toList());
}
if (CollectionUtils.isEmpty(clerkIdList)) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_5.getCode()), "无需要生成活码导购");
}
for (String clerkId : clerkIdList) {
hmQrcodeQDTO.setClerkIdList(Collections.singletonList(clerkId));
hmQrcodeQDTO.setInvokingType(3);
add(hmQrcodeQDTO);
}
setLoggerContext(enterpriseId, wxEnterpriseId, hmQrcodeQDTO.getCreatorId(), hmQrcodeQDTO.getCreatorName());
GicLogRecordEvaluationContext.putAttribute("logContent", "【" + "批量创建数量" + clerkIdList.size() + "】");
String logContent = "【" + "批量创建数量" + clerkIdList.size() + "】";
GicLogRecordEvaluationContext.putAttribute("logContent", logContent);
logger.info("批量新增活码日志:logText:{}", logContent);
return ServiceResponse.success();
}
......@@ -219,7 +249,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
}
@GicLogRecord(value = "修改员工活码-${#hmName}-${#logContent}",
@GicLogRecord(value = "修改员工活码-${#hmName}${#logContent}",
category = GicLogRecordCategoryEnum.HUOMA,
optType = GicLogRecordOptTypeEnum.HUOMA_EDIT,
optPage = "活码管理-修改员工活码",
......@@ -262,15 +292,14 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_0.getCode()), qywxResponseDTO.getErrmsg());
}
setLoggerContext(hmQrcodeQDTO.getEnterpriseId(), wxEnterpriseId, hmQrcodeQDTO.getModifierId(), hmQrcodeQDTO.getModifierName());
updateSystemLog(hmQrcodeQDTO, hmId);
int updateResult = hmQrcodeService.update(hmQrcodeQDTO);
if (updateResult == 1) {
// 更新欢迎语引用次数
this.updateWelcomeRelation(hmQrcodeQDTO);
}
setLoggerContext(hmQrcodeQDTO.getEnterpriseId(), wxEnterpriseId, hmQrcodeQDTO.getModifierId(), hmQrcodeQDTO.getModifierName());
updateSystemLog(hmQrcodeQDTO, hmId);
return ServiceResponse.success();
}
......@@ -286,6 +315,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
//操作日志
//名称
String name = hmQrcodeQDTO.getName();
Integer invokingType = hmQrcodeQDTO.getInvokingType();
String nameOld = hmOld.getName();
if (!name.equals(nameOld)) {
logContent.append("活码名称「").append(nameOld).append("」").append("变更为「").append(name).append("」");
......@@ -349,8 +379,15 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
logContent.append("欢迎语「").append(welcomeOld.getTitle()).append("」").append("变更为「").append(welcome.getTitle()).append("」");
}
}
GicLogRecordEvaluationContext.putAttribute("hmName", "【" + hmId + "-" + hmQrcodeQDTO.getName() + "】:");
GicLogRecordEvaluationContext.putAttribute("logContent", logContent.toString());
String logText = logContent.toString();
String hmName = "【" + hmId + "-" + hmQrcodeQDTO.getName() + "】";
GicLogRecordEvaluationContext.putAttribute("hmName", hmName);
if (invokingType != 1) {
logText = logText + "——" + ChannelCodeEnum.getNameByCode(invokingType);
}
GicLogRecordEvaluationContext.putAttribute("logContent", logText);
logger.info("更新活码日志:hmName:{},logText:{}", hmName, logText);
}
......@@ -385,11 +422,12 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
if (CollectionUtils.isEmpty(clerkIdList)) {
return null;
}
String enterpriseId = hmQrcodeQDTO.getEnterpriseId();
//单人活码
String clerkId = clerkIdList.get(0);
if (hmType == 2) {
//多人活码
insertHmClerkRelation(hmQrcodeQDTO, wxEnterpriseId, hmId, clerkIdList, addFlag);
insertHmClerkRelation(enterpriseId, wxEnterpriseId, hmId, clerkIdList, addFlag);
} else if (hmType == 1) {
HmQrcodeBO hmQrcodeBO = hmQrcodeService.queryByClerkId(clerkId, wxEnterpriseId);
if (addFlag && hmQrcodeBO != null) {
......@@ -401,7 +439,12 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
hmQrcodeQDTO.setClerkId(clerkId);
ClerkDTO clerkDTO = clerkService.getclerkById(clerkId);
if (clerkDTO != null) {
hmQrcodeQDTO.setClerkName(clerkDTO.getClerkName());
String name = hmQrcodeQDTO.getName();
String clerkName = clerkDTO.getClerkName();
if (StringUtils.isBlank(name)) {
hmQrcodeQDTO.setName(clerkName);
}
hmQrcodeQDTO.setClerkName(clerkName);
hmQrcodeQDTO.setClerkCode(clerkDTO.getClerkCode());
String storeId = clerkDTO.getStoreId();
hmQrcodeQDTO.setStoreId(storeId);
......@@ -425,17 +468,27 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
/**
* 多人活码关联关系
*
* @param hmQrcodeQDTO
* @param enterpriseId
* @param wxEnterpriseId
* @param hmId
* @param clerkIdList
* @param addFlag
*/
private void insertHmClerkRelation(HmQrcodeQDTO hmQrcodeQDTO, String wxEnterpriseId, Long hmId, List<String> clerkIdList, Boolean addFlag) {
private void insertHmClerkRelation(String enterpriseId,String wxEnterpriseId, Long hmId, List<String> clerkIdList, Boolean addFlag) {
Date now = new Date();
if (!addFlag) {
//修改,删除其余无效导购
List<HmClerkRelationBO> hmClerkRelationBOS = hmClerkRelationService.queryByHmIdNotInClerkIds(hmId, clerkIdList);
if (CollectionUtils.isNotEmpty(hmClerkRelationBOS)) {
for (HmClerkRelationBO hmClerkRelationBO : hmClerkRelationBOS) {
hmClerkRelationService.updateStatusById(0,hmClerkRelationBO.getRelationId());
}
}
}
for (String clerkId : clerkIdList) {
HmClerkRelationBO hmClerkRelationBO = hmClerkRelationService.queryByHmIdAndClerkId(hmId, clerkId);
if (addFlag && hmClerkRelationBO != null) {
if (hmClerkRelationBO != null) {
logger.error("该导购已经在该多人活码中,clerkId:{}", clerkId);
continue;
}
......@@ -446,7 +499,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
hmClerkRelationQDTO.setHmId(hmId);
hmClerkRelationQDTO.setWxUserId(clerkRelationDTO.getWxUserId());
hmClerkRelationQDTO.setWxEnterpriseId(wxEnterpriseId);
hmClerkRelationQDTO.setEnterpriseId(hmQrcodeQDTO.getEnterpriseId());
hmClerkRelationQDTO.setEnterpriseId(enterpriseId);
hmClerkRelationQDTO.setClerkId(clerkId);
ClerkDTO clerkDTO = clerkService.getclerkById(clerkId);
if (clerkDTO != null) {
......@@ -531,11 +584,12 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
afterFunc = LogRecordAfterServiceImpl.class)
@Override
@Transactional(rollbackFor = Exception.class)
public ServiceResponse delById(Long hmId) {
public ServiceResponse delById(Long hmId, Integer invokingType) {
HmQrcodeBO hmQrcodeBO = hmQrcodeService.queryById(hmId);
if (hmQrcodeBO == null) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "活码不存在");
}
String wxConfigId = hmQrcodeBO.getWxConfigId();
if (StringUtils.isNotBlank(wxConfigId)) {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(hmQrcodeBO.getWxEnterpriseId());
......@@ -545,18 +599,25 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), qywxResponseDTO.getErrmsg());
}
}
hmQrcodeService.deleteById(hmId);
//操作日志
setLoggerContext(hmQrcodeBO.getEnterpriseId(), hmQrcodeBO.getWxEnterpriseId(), hmQrcodeBO.getModifierId(), hmQrcodeBO.getModifierName());
GicLogRecordEvaluationContext.putAttribute("logContent", "【" + hmId + "-" + hmQrcodeBO.getName() + "】");
String logContent = "【" + hmId + "-" + hmQrcodeBO.getName() + "】";
if (invokingType != 1) {
logContent = logContent + "——" + ChannelCodeEnum.getNameByCode(invokingType);
}
GicLogRecordEvaluationContext.putAttribute("logContent", logContent);
hmQrcodeService.deleteById(hmId);
return ServiceResponse.success();
}
@Override
public ServiceResponse delByClerkId(String clerkId, String enterpriseId, String wxEnterpriseId) {
public ServiceResponse delByClerkId(String clerkId, String enterpriseId, String wxEnterpriseId, Integer invokingType) {
// 单人活码 直接废弃,多人活码,更新
HmQrcodeBO hmQrcodeBO = hmQrcodeService.queryByClerkId(clerkId, wxEnterpriseId);
if (hmQrcodeBO != null) {
delById(hmQrcodeBO.getHmId());
delById(hmQrcodeBO.getHmId(), invokingType);
}
// 多人活码逻辑
......@@ -565,32 +626,41 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
logger.info("无多人活码");
return ServiceResponse.success();
}
for (HmClerkRelationBO hmClerkRelationBO : hmClerkRelationBOS) {
Long hmId = hmClerkRelationBO.getHmId();
List<String> clerkIds = hmClerkRelationService.getClerkIdByHmId(hmId);
hmClerkRelationService.updateStatusById(0,hmClerkRelationBO.getRelationId());
hmClerkRelationService.updateStatusById(0, hmClerkRelationBO.getRelationId());
clerkIds.remove(clerkId);
// 更新活码
HmQrcodeQDTO hmQrcodeQDTO = new HmQrcodeQDTO();
hmQrcodeQDTO.setHmId(hmId);
hmQrcodeQDTO.setClerkIdList(clerkIds);
update(hmQrcodeQDTO);
if (CollectionUtils.isNotEmpty(clerkIds)) {
// 更新活码
HmQrcodeQDTO hmQrcodeQDTO = new HmQrcodeQDTO();
hmQrcodeQDTO.setHmId(hmId);
hmQrcodeQDTO.setClerkIdList(clerkIds);
update(hmQrcodeQDTO);
} else {
delById(hmId, invokingType);
}
}
return ServiceResponse.success();
}
@Override
public int updateAddNumById(Long hmId, String clerkId) {
StaffClerkRelationDTO staffClerkRelationDTO = staffClerkRelationService.getByClerkId(clerkId);
if (staffClerkRelationDTO == null) {
logger.error("未绑定好办:{}",clerkId);
return 0;
}
HmQrcodeBO hmQrcodeBO = hmQrcodeService.queryById(hmId);
if (hmQrcodeBO == null) {
logger.error("无活码数据");
return 0;
}
TabHaobanStaff tabHaobanStaff = staffService.selectById(staffClerkRelationDTO.getStaffId());
Integer addNum = tabHaobanStaff.getAddNum();
Integer hmType = hmQrcodeBO.getHmType();
int limit = QwFriendLimitCountUtil.getLimit(true);
Integer addNum = hmQrcodeBO.getAddNum();
if (hmType == 1) {
//单人活码
Integer overFlag = 0;
......@@ -620,6 +690,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
logger.info("重置上限时间定时任务 start");
hmQrcodeService.resetAddNumAndOverFlag();
hmClerkRelationService.resetAddNumAndOverFlag();
staffService.resetAddNum();
logger.info("重置上限时间定时任务 end");
}
......@@ -716,26 +787,26 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
}
@Override
public List<HmQrcodeStoreDTO> getHmStoreByEnterpriseId(String enterpriseId) {
String key = "HM:STORE:" + enterpriseId;
public List<HmQrcodeStoreDTO> getHmStoreByEnterpriseId(String wxEnterpriseId, String enterpriseId) {
String key = "HM:STORE:" + enterpriseId + wxEnterpriseId;
Object cache = RedisUtil.getCache(key);
if (cache != null) {
return (List<HmQrcodeStoreDTO>) cache;
}
List<HmQrcodeStoreDTO> hmQrcodeStoreDTOS = EntityUtil.changeEntityListNew(HmQrcodeStoreDTO.class, hmQrcodeService.getHmStoreByEnterpriseId(enterpriseId));
RedisUtil.setCache(key, hmQrcodeStoreDTOS, 10L, TimeUnit.MINUTES);
List<HmQrcodeStoreDTO> hmQrcodeStoreDTOS = EntityUtil.changeEntityListNew(HmQrcodeStoreDTO.class, hmQrcodeService.getHmStoreByEnterpriseId(wxEnterpriseId, enterpriseId));
RedisUtil.setCache(key, hmQrcodeStoreDTOS, 5L, TimeUnit.MINUTES);
return hmQrcodeStoreDTOS;
}
@Override
public List<String> getHmStoreForWxa(String enterpriseId) {
String key = "HM:STORE:WXA" + enterpriseId;
public List<String> getHmStoreForWxa(String wxEnterpriseId, String enterpriseId) {
String key = "HM:STORE:WXA" + enterpriseId + wxEnterpriseId;
Object cache = RedisUtil.getCache(key);
if (cache != null) {
return (List<String>) cache;
}
List<String> list = hmQrcodeService.getHmStoreForWxa(enterpriseId);
RedisUtil.setCache(key, list, 10L, TimeUnit.MINUTES);
List<String> list = hmQrcodeService.getHmStoreForWxa(wxEnterpriseId, enterpriseId);
RedisUtil.setCache(key, list, 5L, TimeUnit.MINUTES);
return list;
}
......@@ -781,9 +852,9 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
public ServiceResponse<List<String>> listHmIdForIndex(HmQrcodeListQDTO qdto) {
return ServiceResponse.success(hmQrcodeService.listHmIdForIndex(qdto));
}
@Override
public ServiceResponse<List<String>> listHasQrcodeClerk(String enterpriseId, List<String> clerkIdList) {
return ServiceResponse.success(hmQrcodeService.listHasQrcodeClerk(enterpriseId,clerkIdList));
return ServiceResponse.success(hmQrcodeService.listHasQrcodeClerk(enterpriseId, clerkIdList));
}
}
package com.gic.haoban.manage.service.task;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.EntityUtil;
......@@ -9,28 +19,25 @@ import com.gic.haoban.manage.api.dto.DealParamMqDTO;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.SecretSettingDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
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.SecretTypeEnum;
import com.gic.haoban.manage.api.enums.SyncTaskStatusEnum;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
import com.gic.haoban.manage.service.entity.TabHaobanPreDealLog;
import com.gic.haoban.manage.service.entity.TabHaobanSyncTask;
import com.gic.haoban.manage.service.service.*;
import com.gic.haoban.manage.service.service.DepartmentService;
import com.gic.haoban.manage.service.service.PreDealService;
import com.gic.haoban.manage.service.service.SecretSettingService;
import com.gic.haoban.manage.service.service.SyncTaskService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.util.EmojiFilterUtil;
import com.gic.mq.sdk.GicMQClient;
import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.dto.qywx.UserDTO;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 同步通讯录部门
......@@ -44,24 +51,20 @@ public class QywxDeptSyncOperation implements BaseSyncOperation {
@Autowired
private DepartmentService departmentService;
@Autowired
private PreDealService preDealService;
@Autowired
private SyncTaskService syncTaskService;
@Autowired
private QywxUserApiService qywxUserApiService;
@Autowired
private WxEnterpriseService wxEnterpriseService;
@Autowired
private QywxStaffSyncOperation qywxClerkSyncOperation;
@Autowired
private SecretSettingService secretSettingService;
@Autowired
private Config config;
@Override
public void dealSingleByMq(DealParamMqDTO dealParamMqDTO, TabHaobanPreDealLog dataPre) {
......@@ -168,12 +171,20 @@ public class QywxDeptSyncOperation implements BaseSyncOperation {
String pDataId = preData.getpDataId();
if ("0".equals(pDataId)) {
//根级部门
List<UserDTO> list = this.qywxUserApiService.listSelfDepartmentUser(wxEnterpriseDTO.getCorpid(), secretSetting.getSecretVal(), dataId, 1);
List<UserDTO> list = null ;
WxEnterpriseQwDTO wxInfo = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if(wxInfo.getWxSecurityType()==4) {
list = this.qywxUserApiService.listDepartmentUser(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), dataId, 1) ;
logger.info("通讯录(第三方)={}",JSON.toJSONString(list)) ;
}else {
list = this.qywxUserApiService.listSelfDepartmentUser(wxEnterpriseDTO.getCorpid(), secretSetting.getSecretVal(), dataId, 1);
logger.info("通讯录(代开)={}",JSON.toJSONString(list)) ;
}
if (null == list) {
logger.info("微信获取部门成员异常:{},{}", taskId, dataId);
return;
}
logger.info("是否已经进来了,进来");
logger.info("获取部门列表");
//预处理门店 写入预处理表
if (CollectionUtils.isNotEmpty(list)) {
List<String> dataList = preDealService.listDataIdByTaskIdAndDataType(taskId, PreDealTypeEnum.clerk.getVal());
......
......@@ -57,11 +57,7 @@ public class QywxStaffSyncOperation implements BaseSyncOperation {
@Autowired
private WxEnterpriseApiService wxEnterpriseApiService;
@Autowired
private WxApplicationMapper wxApplicationMapper;
@Autowired
private Config config;
@Autowired
private SecretSettingService secretSettingService;
@Override
public void dealSingleByMq(DealParamMqDTO dealParamMqDTO, TabHaobanPreDealLog dataPre) {
......
......@@ -22,6 +22,7 @@
<constructor-arg index="0" value="haoban-manage-service"/>
</bean>
<dubbo:service interface="com.gic.haoban.manage.api.service.HaobanCommonMQApiService" ref="haobanCommonMQApiService" timeout="10000"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.hm.WxUserAddLogApiService" ref="wxUserAddLogApiService" timeout="10000"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.KeyDataApiService" ref="keyDataApiService" timeout="10000"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.hm.HmLinkApiService" ref="hmLinkApiService" timeout="10000"/>
......
......@@ -23,14 +23,14 @@
<result column="wx_open_user_id" property="wxOpenUseId" jdbcType="VARCHAR"/>
<result column="wx_open_id" property="wxOpenId" jdbcType="VARCHAR"/>
<result column="qr_code" property="qrCode" jdbcType="VARCHAR"/>
<result column="add_num" property="addNum" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
staff_id
, wx_user_id, phone_number, staff_name, nation_code, nick_name, sex, postion,
active_flag, extend_postion, status_flag, create_time, update_time,wx_enterprise_id,head_img,
sort,sync_postion_flag,super_manager_flag,wx_open_user_id,wx_open_id,qr_code
sort,sync_postion_flag,super_manager_flag,wx_open_user_id,wx_open_id,qr_code,add_num
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">
select
......@@ -120,6 +120,9 @@
<if test="qrCode != null">
qr_code,
</if>
<if test="addNum != null">
add_num,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="staffId != null">
......@@ -183,7 +186,10 @@
#{wxOpenId},
</if>
<if test="qrCode != null">
#{qrCode}
#{qrCode},
</if>
<if test="addNum != null">
#{addNum}
</if>
</trim>
</insert>
......@@ -250,6 +256,9 @@
<if test="qrCode != null">
qr_code = #{qrCode}
</if>
<if test="addNum != null">
add_num = #{addNum}
</if>
</set>
where staff_id = #{staffId,jdbcType=VARCHAR}
</update>
......@@ -532,4 +541,20 @@
and wx_open_user_id = #{wxOpenUseId}
</update>
<update id="updateAddNumById" parameterType="java.lang.String">
update tab_haoban_staff
set add_num = add_num +1,
update_time = now()
where staff_id = #{staffId}
</update>
<update id="resetAddNum">
update tab_haoban_staff
<set>
add_num = 0,update_time = now()
</set>
</update>
</mapper>
\ No newline at end of file
......@@ -197,5 +197,10 @@
where wx_application_id = #{wxApplicationId}
and status_flag = 1
</update>
<select id="listApplication" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from
tab_haoban_wx_application where wx_enterprise_id = #{wxEnterpriseId} and status_flag = 1
</select>
</mapper>
\ No newline at end of file
......@@ -40,6 +40,7 @@
<result column="agree_external_userid_time" property="agreeExternalUseridTime" jdbcType="TIMESTAMP"/>
<result column="external_flag" property="externalFlag" jdbcType="INTEGER"/>
<result column="userid_flag" property="useridFlag" jdbcType="INTEGER"/>
<result column="wx_security_type" property="wxSecurityType"/>
</resultMap>
<sql id="Base_Column_List">
......@@ -47,7 +48,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
,member_secret,contact_secret,agree_external_userid_flag,agree_external_userid_time,external_flag,userid_flag ,wx_security_type
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">
select
......
......@@ -126,7 +126,7 @@
<if test="null != linkType">
and link_type = #{linkType}
</if>
and status_flag = 1
and status_flag = 1 order by create_time desc
limit 20
</select>
......@@ -144,7 +144,7 @@
<if test="null != linkType">
and link_type = #{linkType}
</if>
and status_flag = 1
and status_flag = 1 order by create_time desc
</select>
<select id="queryPageRelationList" resultMap="result-map-tabHaobanHmLink">
......
......@@ -131,7 +131,7 @@
select <include refid="Base_Column_List"></include>
from tab_haoban_hm_clerk_relation
where clerk_id = #{clerkId}
and hm_id = #{hmId}
and hm_id = #{hmId} and status = 1
limit 1
</select>
......@@ -166,7 +166,7 @@
<select id="getNumByHmId" resultType="string">
select clerk_id
from tab_haoban_hm_clerk_relation
where hm_id = #{hmId}
where hm_id = #{hmId} and status = 1
</select>
......@@ -190,5 +190,15 @@
where relation_id = #{relationId}
</update>
<select id="queryByHmIdNotInClerkIds" resultMap="TabHaobanHmClerkRelationMap">
select <include refid="Base_Column_List"></include>
from tab_haoban_hm_clerk_relation
where hm_id = #{hmId} and status = 1
and clerk_id not in
<foreach item="id" index="index" collection="clerkIds" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>
......@@ -315,15 +315,23 @@
select store_id storeId,
MIN(over_flag) overFlag
from tab_haoban_hm_qrcode
where enterprise_id = #{enterpriseId} and status_flag = 1
where 1
<if test="null != wxEnterpriseId">
and wx_enterprise_id = #{wxEnterpriseId}
</if>
and enterprise_id = #{enterpriseId} and status_flag = 1
and store_id is not null
GROUP BY store_id
</select>
<select id="getHmStoreForWxa" resultType="String">
select distinct(store_id)
from tab_haoban_hm_qrcode
where enterprise_id = #{enterpriseId} and status_flag = 1 and over_flag = 0 and store_id is not null
from tab_haoban_hm_qrcode
where 1
<if test="null != wxEnterpriseId">
and wx_enterprise_id = #{wxEnterpriseId}
</if>
and enterprise_id = #{enterpriseId} and status_flag = 1 and over_flag = 0 and store_id is not null
</select>
<select id="listHmIdForIndex" resultType="String" parameterType="com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeListQDTO">
......@@ -334,7 +342,7 @@
and a.wx_enterprise_id = #{wxEnterpriseId}
</if>
<if test="null != hmSelect and '' != hmSelect ">
and (a.hm_code=#{hmSelect} or a.name like '%${hmSelect}%' or a.creator_name like '%${hmSelect}%' )
and (a.hm_id=#{hmSelect} or a.hm_code=#{hmSelect} or a.name like '%${hmSelect}%' or a.creator_name like '%${hmSelect}%' )
</if>
<if test="null != clerkSelect and '' != clerkSelect">
and ( a.clerk_id = #{clerkSelect} or b.clerk_id = #{clerkSelect} )
......@@ -425,7 +433,10 @@
</select>
<select id="listCanAddClerk" resultType="com.gic.haoban.manage.service.pojo.bo.hm.HmQrcodeClerkBO">
select a.clerk_id , a.store_id , a.staff_id from
select a.clerk_id clerkId,
a.store_id storeId,
a.staff_id staffId
from
<include refid="canAddClerkSql" />
</select>
......
......@@ -208,6 +208,6 @@
<if test="null != addChannel">
and add_channel = #{addChannel}
</if>
and status_flag != 0 order by #{createTimeOrder}
and status_flag = #{statusFlag} order by create_time ${createTimeOrder}
</select>
</mapper>
\ No newline at end of file
package com.gic.haoban.manage.web.controller;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.redisson.api.RRateLimiter;
import org.redisson.api.RateIntervalUnit;
import org.redisson.api.RateType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.ctrip.framework.apollo.ConfigService;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.HttpClient;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.service.*;
import com.gic.haoban.manage.api.dto.MaidianLogDTO;
import com.gic.haoban.manage.api.dto.QywxCorpInfoSimpleDTO;
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.service.MaidianLogApiService;
import com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.TestApiService;
import com.gic.haoban.manage.api.service.WxApplicationApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.api.service.hm.HmQrcodeApiService;
import com.gic.haoban.manage.web.config.Config;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
......@@ -15,28 +49,9 @@ import com.gic.redis.data.util.GicRateLimiter;
import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.dto.qywx.QywxNewUseridDTO;
import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO;
import com.gic.wechat.api.service.qywx.QywxCorpApiService;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.redisson.api.RRateLimiter;
import org.redisson.api.RateIntervalUnit;
import org.redisson.api.RateType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* Created 2020/4/9.
......@@ -54,19 +69,14 @@ public class TestController extends WebBaseController {
@Autowired
private QywxSuiteApiService qywxSuiteApiService;
@Autowired
private MemberUnionidRelatedApiService memberUnionidRelatedApiService;
@Autowired
private TestApiService testApiService;
@Autowired
private MaidianLogApiService maidianLogApiService;
@Autowired
private WxEnterpriseRelatedApiService wxEnterpriseRelatedApiService;
@Autowired
private WxEnterpriseApiService wxEnterpriseApiService;
@Autowired
......@@ -79,6 +89,10 @@ public class TestController extends WebBaseController {
private Config config;
@Autowired
private HmQrcodeApiService hmQrcodeApiService;
@Autowired
private QywxCorpApiService qywxCorpApiService;
@RequestMapping("/send-message-test")
public HaobanResponse testSendMessage(QywxXcxSendMessageQo qo) {
......@@ -326,4 +340,91 @@ public class TestController extends WebBaseController {
hmQrcodeApiService.checkStaffOpenContactByWxEnterpriseId(wxEnterpriseId);
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("test-qw-post-fws")
public HaobanResponse testQwPost(String url , String corpid , String json) {
if(isProd()) {
return null ;
}
String token = qywxCorpApiService.getProviderAccessToken(corpid) ;
logger.info("toekn={},corpId={} , url={} , json={}",token, corpid ,(url + token) , json);
Map<String, Object> map = HttpClient.getWinxinResByJson(url + token ,json);
return resultResponse(HaoBanErrCode.ERR_0, map) ;
}
@RequestMapping("test-qw-get-fws")
public HaobanResponse testQwGet(String url , String corpId) {
if(isProd()) {
return null ;
}
String token =qywxCorpApiService.getProviderAccessToken(corpId) ;
logger.info("toekn={},appid={} , url={} , json={}",token,corpId ,(url + token));
Map<String, Object> map = HttpClient.getHttpByGet(url + token);
return resultResponse(HaoBanErrCode.ERR_0, map) ;
}
@RequestMapping("test-qw-post-3")
public HaobanResponse testQwPost3(String url , String corpid , String json) {
if(isProd()) {
return null ;
}
String token = qywxCorpApiService.getCorpAccessToken(corpid,config.getWxSuiteid()) ;
logger.info("toekn={},corpId={} , url={} , json={}",token, corpid ,(url + token) , json);
Map<String, Object> map = HttpClient.getWinxinResByJson(url + token ,json);
return resultResponse(HaoBanErrCode.ERR_0, map) ;
}
@RequestMapping("test-qw-token")
public HaobanResponse testQwPost3(String corpid , String secret) {
if(StringUtils.isBlank(secret)) {
String token = qywxCorpApiService.getCorpAccessToken(corpid,config.getWxSuiteid()) ;
return resultResponse(HaoBanErrCode.ERR_0, token) ;
}else {
String token = qywxCorpApiService.getToken(corpid, secret) ;
return resultResponse(HaoBanErrCode.ERR_0, token) ;
}
}
@RequestMapping("test-qw-get-3")
public HaobanResponse testQwGet3(String url , String corpid) {
if(isProd()) {
return null ;
}
String token = qywxCorpApiService.getCorpAccessToken(corpid,config.getWxSuiteid()) ;
logger.info("toekn={},appid={} , url={} , json={}",token,corpid ,(url + token));
Map<String, Object> map = HttpClient.getHttpByGet(url + token);
return resultResponse(HaoBanErrCode.ERR_0, map) ;
}
@RequestMapping("test-qw-post-dk")
public HaobanResponse testQwPostdk(String url , String corpid , String secret, String json) {
if(isProd()) {
return null ;
}
String token = qywxCorpApiService.getToken(corpid, secret) ;
logger.info("toekn={},corpId={} , url={} , json={}",token, corpid ,(url + token) , json);
Map<String, Object> map = HttpClient.getWinxinResByJson(url + token ,json);
return resultResponse(HaoBanErrCode.ERR_0, map) ;
}
@RequestMapping("test-qw-get-dk")
public HaobanResponse testQwGetdk(String url , String corpid , String secret) {
if(isProd()) {
return null ;
}
String token = qywxCorpApiService.getToken(corpid, secret) ;
logger.info("toekn={},appid={} , url={} , json={}",token,corpid ,(url + token));
Map<String, Object> map = HttpClient.getHttpByGet(url + token);
return resultResponse(HaoBanErrCode.ERR_0, map) ;
}
private boolean isProd() {
com.ctrip.framework.apollo.Config config = ConfigService.getConfig("COMMON.gic-properties");
String env = config.getProperty("environment.value", "");
boolean isProd = "prod".equals(env);
return isProd ;
}
}
......@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
......@@ -24,18 +25,14 @@ import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import com.gic.haoban.common.utils.AuthWebRequestUtil;
import com.gic.haoban.manage.api.constants.StatisticsApolloKeyConstant;
import com.gic.haoban.manage.api.dto.hm.HmClerkDTO;
import com.gic.haoban.manage.api.dto.hm.HmClerkRelationDTO;
import com.gic.haoban.manage.api.dto.hm.HmQrcodeDTO;
import com.gic.haoban.manage.api.dto.hm.HmQrcodeListDTO;
import com.gic.haoban.manage.api.dto.hm.HmStoreDTO;
import com.gic.haoban.manage.api.dto.hm.WxUserAddLogDTO;
import com.gic.haoban.manage.api.dto.hm.*;
import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeListQDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeQDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.WxUserAddLogSearchQDTO;
import com.gic.haoban.manage.api.dto.statistics.StatisticsDTO;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.api.service.hm.HmGroupApiService;
import com.gic.haoban.manage.api.service.hm.HmQrcodeApiService;
import com.gic.haoban.manage.api.service.hm.WxUserAddLogApiService;
import com.gic.haoban.manage.api.util.DataHttpUtil;
......@@ -48,8 +45,17 @@ import com.gic.haoban.manage.web.qo.hm.data.HmQrcodeListQO;
import com.gic.haoban.manage.web.qo.hm.data.HmTrendQO;
import com.gic.haoban.manage.web.vo.hm.HmDetailClerkListVO;
import com.gic.haoban.manage.web.vo.hm.HmTrendVO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.logging.log4j.LogManager;
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.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import cn.hutool.core.convert.Convert;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 活码(TabHaobanHmQrcode)表控制层
......@@ -71,6 +77,8 @@ public class HmQrcodeController {
private WxUserAddLogApiService wxUserAddLogApiService;
@Autowired
private StaffClerkRelationApiService staffClerkRelationApiService;
@Autowired
private HmGroupApiService hmGroupApiService;
/**
* 新增
......@@ -87,6 +95,7 @@ public class HmQrcodeController {
hmQrcodeQDTO.setModifierName(loginUser.getClerkName());
hmQrcodeQDTO.setWxEnterpriseId(loginUser.getWxEnterpriseId());
hmQrcodeQDTO.setEnterpriseId(loginUser.getEnterpriseId());
hmQrcodeQDTO.setInvokingType(1);
ServiceResponse serviceResponse = this.hmQrcodeApiService.add(hmQrcodeQDTO);
if (!"0000".equals(serviceResponse.getCode())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_DEFINE.getCode()), serviceResponse.getMessage());
......@@ -123,6 +132,7 @@ public class HmQrcodeController {
hmQrcodeQDTO.setModifierName(loginUser.getClerkName());
hmQrcodeQDTO.setWxEnterpriseId(loginUser.getWxEnterpriseId());
hmQrcodeQDTO.setEnterpriseId(loginUser.getEnterpriseId());
hmQrcodeQDTO.setInvokingType(1);
ServiceResponse serviceResponse = this.hmQrcodeApiService.update(hmQrcodeQDTO);
if (!"0000".equals(serviceResponse.getCode())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_DEFINE.getCode()), serviceResponse.getMessage());
......@@ -145,12 +155,16 @@ public class HmQrcodeController {
if (CollectionUtils.isEmpty(storeList)) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_100007.getCode()), HaoBanErrCode.ERR_100007.getMsg());
}
if (!storeList.contains("-1")) {
StringBuffer stringBuffer = new StringBuffer();
storeList.forEach(c -> stringBuffer.append(c).append(","));
hmQrcodeListQO.getInFields().setStoreId(stringBuffer.toString());
}
Long hmGroupId = hmQrcodeListQO.getInFields().getHmGroupId();
//-1 代表全部分组
if (hmGroupId == -1) {
hmQrcodeListQO.getInFields().setHmGroupId(null);
}
HmQrcodeListQDTO qdto = EntityUtil.changeEntityByJSON(HmQrcodeListQDTO.class, hmQrcodeListQO.getInFields());
if (!storeList.contains("-1")) {
qdto.setStoreId(storeList);
......@@ -166,10 +180,10 @@ public class HmQrcodeController {
hmQrcodeListQO.getInFields().setHmId(stringBuffer.toString());
StatisticsDTO statisticsDTO = DataHttpUtil.post(StatisticsApolloKeyConstant.data_haoban_hm_list, hmQrcodeListQO);
List<HmQrcodeListDTO> data = JSON.parseArray(JSON.toJSONString(statisticsDTO.getData()), HmQrcodeListDTO.class);
List<HmStoreDTO> storeDTOList = new ArrayList<>();
List<HmClerkDTO> clerkDTOList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(data)) {
for (HmQrcodeListDTO hmQrcodeListDTO : data) {
List<HmStoreDTO> storeDTOList = new ArrayList<>();
List<HmClerkDTO> clerkDTOList = new ArrayList<>();
Long hmId = hmQrcodeListDTO.getHmId();
Integer hmType = hmQrcodeListDTO.getHmType();
if (hmType == 1) {
......@@ -178,6 +192,7 @@ public class HmQrcodeController {
clerkDTO.setClerkId(hmQrcodeListDTO.getClerkId());
clerkDTO.setClerkCode(hmQrcodeListDTO.getClerkCode());
clerkDTOList.add(clerkDTO);
HmStoreDTO storeDTO = new HmStoreDTO();
storeDTO.setStoreId(hmQrcodeListDTO.getStoreId());
storeDTO.setStoreName(hmQrcodeListDTO.getStoreName());
......@@ -186,7 +201,7 @@ public class HmQrcodeController {
} else if (hmType == 2) {
BasePageInfo basePageInfo = new BasePageInfo();
basePageInfo.setPageNum(1);
basePageInfo.setPageNum(1000);
basePageInfo.setPageSize(1000);
Page<HmClerkRelationDTO> hmClerkByHmId = hmQrcodeApiService.getHmClerkByHmId(basePageInfo, hmId);
List<HmClerkRelationDTO> hmClerkRelationDTOList = hmClerkByHmId.getResult();
if (CollectionUtils.isNotEmpty(hmClerkRelationDTOList)) {
......@@ -196,6 +211,7 @@ public class HmQrcodeController {
clerkDTO.setClerkId(hmClerkRelationDTO.getClerkId());
clerkDTO.setClerkCode(hmClerkRelationDTO.getClerkCode());
clerkDTOList.add(clerkDTO);
HmStoreDTO storeDTO = new HmStoreDTO();
storeDTO.setStoreId(hmClerkRelationDTO.getStoreId());
storeDTO.setStoreName(hmClerkRelationDTO.getStoreName());
......@@ -204,9 +220,21 @@ public class HmQrcodeController {
}
}
}
ServiceResponse<HmGroupDTO> hmGroupDTOServiceResponse = hmGroupApiService.queryGroupDetail(hmQrcodeListDTO.getHmGroupId());
HmGroupDTO hmGroupDTO = hmGroupDTOServiceResponse.getResult();
if (hmGroupDTO != null) {
hmQrcodeListDTO.setHmGroupName(hmGroupDTO.getGroupName());
}
//if (CollectionUtils.isNotEmpty(storeDTOList)) {
// //门店id去重
// storeDTOList = storeDTOList.stream()
// .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(HmStoreDTO::getStoreId))), ArrayList::new));
//}
hmQrcodeListDTO.setClerkList(clerkDTOList);
hmQrcodeListDTO.setStoreList(storeDTOList);
}
statisticsDTO.setData(data);
}
return RestResponse.successResult(statisticsDTO);
}
......@@ -231,7 +259,7 @@ public class HmQrcodeController {
*/
@RequestMapping(value = "del", method = RequestMethod.DELETE)
public RestResponse del(Long hmId) {
ServiceResponse serviceResponse = this.hmQrcodeApiService.delById(hmId);
ServiceResponse serviceResponse = this.hmQrcodeApiService.delById(hmId,1);
if (!"0000".equals(serviceResponse.getCode())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_DEFINE.getCode()), serviceResponse.getMessage());
}
......
......@@ -214,17 +214,20 @@ public class HmStoreController {
searchDTO.setSearchName(storeSearchParams);
// 企业ID
searchDTO.setEnterpriseId(enterpriseId);
List<HmQrcodeStoreDTO> hmStoreList = this.hmQrcodeApiService.getHmStoreByEnterpriseId(enterpriseId);
List<HmQrcodeStoreDTO> hmStoreList = this.hmQrcodeApiService.getHmStoreByEnterpriseId(wxEnterpriseId , enterpriseId);
if (CollectionUtils.isEmpty(hmStoreList)) {
return RestResponse.failure("-1", "无活码门店");
}
Map<String, Integer> map = hmStoreList.stream()
.collect(Collectors.toMap(HmQrcodeStoreDTO::getStoreId, HmQrcodeStoreDTO::getOverFlag, (k1, k2) -> k1));
List<String> hmStoreIdList = hmStoreList.stream().map(dto -> dto.getStoreId()).collect(Collectors.toList());
Sets.SetView<String> setView = Sets.intersection(Sets.newHashSet(authStoreIdList),
Sets.newHashSet(hmStoreIdList));
hmStoreIdList = setView.stream().collect(Collectors.toList());
if (CollectionUtils.isEmpty(hmStoreList)) {
logger.info("活码门店={}",hmStoreIdList);
if(!authStoreIdList.contains("-1")) {
Sets.SetView<String> setView = Sets.intersection(Sets.newHashSet(authStoreIdList),
Sets.newHashSet(hmStoreIdList));
hmStoreIdList = setView.stream().collect(Collectors.toList());
}
if (CollectionUtils.isEmpty(hmStoreIdList)) {
return RestResponse.failure("-1", "无符合门店");
}
// 授权门店 且有活码的门店
......
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