Commit 7f422dd1 by 徐高华

Merge remote-tracking branch 'origin/master_xgh_pendingid' into

developer

Conflicts:
	haoban-manage3-service/src/main/resources/dubbo-haoban-manage-service.xml
parents 1b6b188f 8a69d1a2
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
public class QwPendingIdDTO implements Serializable {
private static final long serialVersionUID = -7791318666042954957L;
private String externalUserId;
private String pendingId;
public String getExternalUserId() {
return externalUserId;
}
public String getPendingId() {
return pendingId;
}
public void setExternalUserId(String externalUserId) {
this.externalUserId = externalUserId;
}
public void setPendingId(String pendingId) {
this.pendingId = pendingId;
}
}
package com.gic.haoban.manage.api.service;
public interface BindApiService {
void clerkManagerTranfer(String departmentId,String fromClerkCode,String toStaffDepartmentRelatedId);
void clerkUnbind(String departmentId,String fromClerkCode,String toStaffId,String manager);
void clerkSingleUnbind(String fromClerkCode,String departmentId);
void staffBind(String departmentId,String fromClerkCode,String fromStaffDepartmentRelatedId);
}
...@@ -4,7 +4,6 @@ import com.gic.api.base.commons.Page; ...@@ -4,7 +4,6 @@ import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.BasePageInfo; import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.manage.api.dto.MaidianLogDTO; import com.gic.haoban.manage.api.dto.MaidianLogDTO;
import java.util.List;
public interface MaidianLogApiService { public interface MaidianLogApiService {
......
package com.gic.haoban.manage.api.service;
import java.util.List;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.dto.QwPendingIdDTO;
/**
*
* @ClassName: QwFriendApiService
* @Description: 企微好友
* @author xugh
* @date 2022年9月27日 上午10:09:14
*
*/
public interface QwFriendApiService {
/**
*
* @Title: getPendingIdByUnionid
* @Description: 通过uniond获取好友id/pendingid
* @author xugh
* @param enterpriseId
* @param unionid
* @param openid 小程序或者服务号openid
* @return
* @throws
*/
public ServiceResponse<QwPendingIdDTO> getPendingIdByUnionid(String enterpriseId, String unionid, String openid);
/**
*
* @Title: getPendingIdByExternalid
* @Description: 通过好友id查询pendingid
* @author xugh
* @param enterpriseId
* @param externalUserId
* @return
* @throws
*/
public ServiceResponse<QwPendingIdDTO> getPendingIdByExternalid(String enterpriseId, String externalUserId);
/**
*
* @Title: getPendingIdByExternalid
* @Description: 通过好友id查询pendingid
* @author xugh
* @param enterpriseId
* @param externalUserId
* @return
* @throws
*/
public ServiceResponse<List<QwPendingIdDTO>> listPendingIdByExternalid(String enterpriseId,
List<String> externalUserIdList);
}
...@@ -8,8 +8,6 @@ import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated; ...@@ -8,8 +8,6 @@ import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated;
public interface WxEnterpriseRelatedMapper { public interface WxEnterpriseRelatedMapper {
int deleteByPrimaryKey(String wxEnterpriseRelatedId);
int deleteByEnterpriseId(String enterpriseId) ; int deleteByEnterpriseId(String enterpriseId) ;
int insertSelective(TabHaobanWxEnterpriseRelated record); int insertSelective(TabHaobanWxEnterpriseRelated record);
......
...@@ -8,8 +8,8 @@ public enum HaoBanErrCode { ...@@ -8,8 +8,8 @@ public enum HaoBanErrCode {
ERR_0001("10100001", "参数没有传"), ERR_0001("10100001", "参数没有传"),
ERR_10012("10012","企业微信不存在"), ERR_10012("10012","企业微信不存在"),
ERR_OTHER("9999","业务异常"), ERR_OTHER("9999","业务异常"),
ERR_100033("100033", "活码分组已经被关联,不可删除"),
ERR_100033("100033", "活码分组已经被关联,不可删除") ERR_2000("2000", "企微接口调用次数限制")
; ;
private String code; private String code;
......
package com.gic.haoban.manage.service.pojo.bo;
public class QwLimitTimesBO {
private int month;
private int day;
private int hour;
public int getMonth() {
return month;
}
public int getDay() {
return day;
}
public int getHour() {
return hour;
}
public void setMonth(int month) {
this.month = month;
}
public void setDay(int day) {
this.day = day;
}
public void setHour(int hour) {
this.hour = hour;
}
}
package com.gic.haoban.manage.service.pojo.bo;
import java.io.Serializable;
public class WxEnterpriseRelationBO implements Serializable {
private static final long serialVersionUID = 4140789670421435421L;
private String wxEnterpriseRelatedId;
private String wxEnterpriseId;
private String enterpriseId;
private int wxEnterpriseType;
private int memberOpenCardFlag;
public String getWxEnterpriseRelatedId() {
return wxEnterpriseRelatedId;
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public int getWxEnterpriseType() {
return wxEnterpriseType;
}
public int getMemberOpenCardFlag() {
return memberOpenCardFlag;
}
public void setWxEnterpriseRelatedId(String wxEnterpriseRelatedId) {
this.wxEnterpriseRelatedId = wxEnterpriseRelatedId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public void setWxEnterpriseType(int wxEnterpriseType) {
this.wxEnterpriseType = wxEnterpriseType;
}
public void setMemberOpenCardFlag(int memberOpenCardFlag) {
this.memberOpenCardFlag = memberOpenCardFlag;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
}
package com.gic.haoban.manage.service.service; package com.gic.haoban.manage.service.service;
import java.util.List;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise; import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated; import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated;
import com.gic.haoban.manage.service.pojo.bo.WxEnterpriseRelationBO;
import java.util.List;
public interface WxEnterpriseRelatedService { public interface WxEnterpriseRelatedService {
...@@ -37,4 +38,6 @@ public interface WxEnterpriseRelatedService { ...@@ -37,4 +38,6 @@ public interface WxEnterpriseRelatedService {
void setClerkEdit(String id, int clerkEditFlag); void setClerkEdit(String id, int clerkEditFlag);
int getRelationCount(String enterpriseId) ; int getRelationCount(String enterpriseId) ;
public WxEnterpriseRelationBO getHeadEnterprise(String enterpriseId) ;
} }
package com.gic.haoban.manage.service.service.impl; package com.gic.haoban.manage.service.service.impl;
import com.gic.commons.util.EntityUtil;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper; import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise; import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service; ...@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseRelatedMapper; import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseRelatedMapper;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated; import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated;
import com.gic.haoban.manage.service.pojo.bo.WxEnterpriseRelationBO;
import com.gic.haoban.manage.service.service.WxEnterpriseRelatedService; import com.gic.haoban.manage.service.service.WxEnterpriseRelatedService;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -75,4 +76,13 @@ public class WxEnterpriseRelatedServiceImpl implements WxEnterpriseRelatedServic ...@@ -75,4 +76,13 @@ public class WxEnterpriseRelatedServiceImpl implements WxEnterpriseRelatedServic
List<TabHaobanWxEnterpriseRelated> list = this.mapper.listByEnterpriseId(enterpriseId) ; List<TabHaobanWxEnterpriseRelated> list = this.mapper.listByEnterpriseId(enterpriseId) ;
return list.size(); return list.size();
} }
@Override
public WxEnterpriseRelationBO getHeadEnterprise(String enterpriseId) {
TabHaobanWxEnterpriseRelated root = this.mapper.findRootWxEnterpriseByEnterpriseId(enterpriseId) ;
if(null != root) {
return EntityUtil.changeEntityByJSON(WxEnterpriseRelationBO.class, root);
}
return null;
}
} }
package com.gic.haoban.manage.service.service.out.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import com.gic.haoban.manage.api.enums.AppPageType;
import com.gic.haoban.manage.api.service.BindApiService;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class BindApiServiceImpl implements BindApiService {
private static Logger logger = LoggerFactory.getLogger(BindApiServiceImpl.class);
@Autowired
private ClerkService clerkService;
@Autowired
private StaffApiService staffApiService;
@Autowired
private StaffDepartmentRelatedApiService staffDepartmentRelatedApiService;
@Autowired
private DepartmentApiService departmentApiService;
@Transactional
@Override
@Deprecated
public void clerkManagerTranfer(String departmentId, String fromClerkCode,
String toStaffDepartmentRelatedId) {
logger.info("===========================》222222222222222");
DepartmentDTO departmentDTO = departmentApiService.selectById(departmentId);
String storeId = departmentDTO.getRelatedId();
StaffDepartmentRelatedDTO oldStaffDepartmentRelatedDTO = staffDepartmentRelatedApiService.getByStaffDepartmentRelatedId(toStaffDepartmentRelatedId);
logger.info("===========================》333333333333333");
//老店长
StaffDepartmentRelatedDTO one = staffDepartmentRelatedApiService.getOneByClerkCodeAndDepartmentId(fromClerkCode,departmentId);
if(one != null){
//老店长清空好办这边code
one.setClerkCode(null);
one.setUpdateTime(new Date());
staffDepartmentRelatedApiService.deleteCode(one);
}
logger.info("===========================》444444444444444");
//新店长更新好办code
StaffDepartmentRelatedDTO dto = new StaffDepartmentRelatedDTO();
dto.setStaffDepartmentRelatedId(toStaffDepartmentRelatedId);
dto.setClerkCode(fromClerkCode);
dto.setUpdateTime(new Date());
staffDepartmentRelatedApiService.updateById(dto);
logger.info("===========================》555555555555555");
if(StringUtils.isNotEmpty(oldStaffDepartmentRelatedDTO.getClerkCode())){
//新店长老clerkCode对应的gicClerk更新gic姓名
List<String> clerkCodes = new ArrayList<>();
clerkCodes.add(oldStaffDepartmentRelatedDTO.getClerkCode());
List<ClerkDTO> list = clerkService.listClerk(storeId, clerkCodes, true);
for(ClerkDTO clerkDTO :list){
clerkDTO.setPhoneNumber("--");
clerkDTO.setClerkName(clerkDTO.getClerkName()+"(已解绑)");
clerkDTO.setHeadImgUrl("");
clerkService.updateClerk(clerkDTO);
}
}
logger.info("===========================》666666666666666");
//老店长更新gic那边的数据为新店长数据
List<String> clerkCodes = new ArrayList<>();
clerkCodes.add(fromClerkCode);
List<ClerkDTO> list = clerkService.listClerk(storeId, clerkCodes, true);
StaffDepartmentRelatedDTO staffDepartmentRelatedDTO = staffDepartmentRelatedApiService.getByStaffDepartmentRelatedId(toStaffDepartmentRelatedId);
StaffDTO staffDTO = staffApiService.selectById(staffDepartmentRelatedDTO.getStaffId());
logger.info("===========================》77777777777777");
for(ClerkDTO clerkDTO :list){
clerkDTO.setPhoneNumber(staffDTO.getPhoneNumber());
clerkDTO.setClerkName(staffDTO.getStaffName());
clerkDTO.setHeadImgUrl(StringUtils.isEmpty(staffDTO.getHeadImg())?"":staffDTO.getHeadImg());
clerkService.updateClerk(clerkDTO);
}
//消息推送
if(StringUtils.isNotEmpty(oldStaffDepartmentRelatedDTO.getClerkCode())){
String clerkId = list.get(0).getClerkId();
String storeName = departmentDTO.getDepartmentName();
String staffName = staffDTO.getStaffName();
String clerkCode = oldStaffDepartmentRelatedDTO.getClerkCode();
String content = "【"+staffName+"】:【"+storeName+"】"+staffName+"导购code:"+clerkCode+"已解绑,请重新分配会员!";
JSONObject jsonObject = new JSONObject();
jsonObject.put("storeId", storeId);
String data = jsonObject.toJSONString();
String pageUrl = staffDepartmentRelatedApiService.getPageUrl(AppPageType.MEMBER_LIST.getCode(), data);
staffDepartmentRelatedApiService.sendSingleMessage(clerkId, "分配会员通知", content, pageUrl);
}
logger.info("===========================》888888888888888");
}
@Transactional
@Override
@Deprecated
public void clerkUnbind(String departmentId, String fromClerkCode,
String toStaffId, String manager) {
DepartmentDTO departmentDTO = departmentApiService.selectById(departmentId);
StaffDepartmentRelatedDTO staffDepartmentRelatedDTO = staffDepartmentRelatedApiService.getOneByStaffIdAndDepartmentId(toStaffId, departmentId);
String oldClerkCode = staffDepartmentRelatedDTO.getClerkCode();
if("1".equals(manager)){
//店长操作
//第一个点击的人的clerkCode置空
StaffDepartmentRelatedDTO one = staffDepartmentRelatedApiService.getOneByClerkCodeAndDepartmentId(fromClerkCode,departmentId);
if(one != null){
//存在,则先置空
one.setClerkCode(null);
one.setUpdateTime(new Date());
staffDepartmentRelatedApiService.deleteCode(one);
}
StaffDepartmentRelatedDTO dto = staffDepartmentRelatedApiService.getOneByStaffIdAndDepartmentId(toStaffId, departmentId);
//存在,则先置空
dto.setClerkCode(fromClerkCode);
dto.setUpdateTime(new Date());
staffDepartmentRelatedApiService.updateById(dto);
//更新gic数据
String storeId = departmentDTO.getRelatedId();
List<String> clerkCodes = new ArrayList<>();
clerkCodes.add(fromClerkCode);
List<ClerkDTO> list = clerkService.listClerk(storeId, clerkCodes, true);
String clerkName = CollectionUtil.isEmpty(list)?null:list.get(0).getClerkName();//获取姓名,发消息用
StaffDTO staffDTO = staffApiService.selectById(toStaffId);
for(ClerkDTO clerkDTO :list){
clerkDTO.setPhoneNumber(staffDTO.getPhoneNumber());
clerkDTO.setClerkName(staffDTO.getStaffName());
clerkDTO.setHeadImgUrl(StringUtils.isEmpty(staffDTO.getHeadImg())?"":staffDTO.getHeadImg());
clerkService.updateClerk(clerkDTO);
}
//清空gic原来的手机号
List<String> oldClerkCodes = new ArrayList<>();
oldClerkCodes.add(oldClerkCode);
List<ClerkDTO> oldList = clerkService.listClerk(storeId, oldClerkCodes, true);
for(ClerkDTO clerkDTO :oldList){
clerkDTO.setPhoneNumber("--");
clerkDTO.setClerkName(clerkDTO.getClerkName()+"(已解绑)");
clerkDTO.setHeadImgUrl("");
clerkService.updateClerk(clerkDTO);
}
//发送消息
if(StringUtils.isNotBlank(fromClerkCode)){
//发送消息
ClerkDTO leader = clerkService.getClerkLeaderByStoreId(storeId);
if(leader == null){
leader = new ClerkDTO();
}
String clerkId = leader.getClerkId();
String storeName = departmentDTO.getDepartmentName();
String staffName = clerkName;
String leaderName = leader.getClerkName();
String clerkCode = fromClerkCode;
String content = "【"+leaderName+"】:【"+storeName+"】"+staffName+"导购code:"+clerkCode+"已解绑,请重新分配会员!";
JSONObject jsonObject = new JSONObject();
jsonObject.put("storeId", storeId);
String data = jsonObject.toJSONString();
String pageUrl = staffDepartmentRelatedApiService.getPageUrl(AppPageType.MEMBER_LIST.getCode(), data);
staffDepartmentRelatedApiService.sendSingleMessage(clerkId, "分配会员通知", content, pageUrl);
}
}else{
//把别人的的clerkCode置空
logger.info("000000000000");
StaffDepartmentRelatedDTO one = staffDepartmentRelatedApiService.getOneByClerkCodeAndDepartmentId(fromClerkCode,departmentId);
if(one != null){
//存在,则先置空
logger.info("111111111111111");
one.setClerkCode(null);
one.setUpdateTime(new Date());
staffDepartmentRelatedApiService.deleteCode(one);
}
logger.info("222222222222222");
//别人的clerkCOde换到自己上
StaffDepartmentRelatedDTO dto = staffDepartmentRelatedApiService.getOneByStaffIdAndDepartmentId(toStaffId, departmentId);
logger.info("3333333333333");
String sendClerkCode = dto.getClerkCode();
dto.setClerkCode(fromClerkCode);
dto.setUpdateTime(new Date());
staffDepartmentRelatedApiService.updateById(dto);
//更新gic数据
String storeId = departmentDTO.getRelatedId();
List<String> clerkCodes = new ArrayList<>();
clerkCodes.add(fromClerkCode);
List<ClerkDTO> list = clerkService.listClerk(storeId, clerkCodes, true);
StaffDTO staffDTO = staffApiService.selectById(toStaffId);
logger.info("444444444444");
for(ClerkDTO clerkDTO :list){
clerkDTO.setPhoneNumber(staffDTO.getPhoneNumber());
clerkDTO.setClerkName(staffDTO.getStaffName());
clerkDTO.setHeadImgUrl(StringUtils.isEmpty(staffDTO.getHeadImg())?"":staffDTO.getHeadImg());
clerkService.updateClerk(clerkDTO);
}
//清空gic原来的手机号
List<String> oldClerkCodes = new ArrayList<>();
oldClerkCodes.add(oldClerkCode);
logger.info("oldClerkCode====================>{}",oldClerkCode);
List<ClerkDTO> oldList = clerkService.listClerk(storeId, oldClerkCodes, true);
logger.info("oldList====================>{}",JSONObject.toJSONString(oldList));
for(ClerkDTO clerkDTO :oldList){
clerkDTO.setPhoneNumber("--");
clerkDTO.setClerkName(clerkDTO.getClerkName()+"(已解绑)");
clerkDTO.setHeadImgUrl("");
clerkService.updateClerk(clerkDTO);
}
//发送消息
if(StringUtils.isNotBlank(sendClerkCode)){
//发送消息
ClerkDTO leader = clerkService.getClerkLeaderByStoreId(storeId);
if(leader == null){
leader = new ClerkDTO();
}
String clerkId = leader.getClerkId();
String storeName = departmentDTO.getDepartmentName();
String staffName = staffDTO.getStaffName();
String leaderName = leader.getClerkName();
String clerkCode = sendClerkCode;
String content = "【"+leaderName+"】:【"+storeName+"】"+staffName+"导购code:"+clerkCode+"已解绑,请重新分配会员!";
JSONObject jsonObject = new JSONObject();
jsonObject.put("storeId", storeId);
String data = jsonObject.toJSONString();
String pageUrl = staffDepartmentRelatedApiService.getPageUrl(AppPageType.MEMBER_LIST.getCode(), data);
staffDepartmentRelatedApiService.sendSingleMessage(clerkId, "分配会员通知", content, pageUrl);
}
}
}
@Deprecated
@Transactional
@Override
public void clerkSingleUnbind(String fromClerkCode, String departmentId) {
//将自己的clerkCode置空
StaffDepartmentRelatedDTO one = staffDepartmentRelatedApiService.getOneByClerkCodeAndDepartmentId(fromClerkCode, departmentId);
if(one != null){
//存在,则先置空
one.setClerkCode(null);
one.setUpdateTime(new Date());
staffDepartmentRelatedApiService.deleteCode(one);
}
//更新gic数据
DepartmentDTO departmentDTO = departmentApiService.selectById(departmentId);
String storeId = departmentDTO.getRelatedId();
List<String> clerkCodes = new ArrayList<>();
clerkCodes.add(fromClerkCode);
List<ClerkDTO> list = clerkService.listClerk(storeId, clerkCodes, true);
String clerkName = CollectionUtil.isEmpty(list)?null:list.get(0).getClerkName();//获取姓名,发消息用
for(ClerkDTO clerkDTO :list){
clerkDTO.setPhoneNumber("--");
clerkDTO.setClerkName(clerkDTO.getClerkName()+"(已解绑)");
clerkDTO.setHeadImgUrl("");
clerkService.updateClerk(clerkDTO);
}
//发送消息
if(StringUtils.isNotBlank(fromClerkCode)){
//发送消息
ClerkDTO leader = clerkService.getClerkLeaderByStoreId(storeId);
if(leader == null){
leader = new ClerkDTO();
}
String clerkId = leader.getClerkId();
String storeName = departmentDTO.getDepartmentName();
String staffName = clerkName;
String leaderName = leader.getClerkName();
String clerkCode = fromClerkCode;
String content = "【"+leaderName+"】:【"+storeName+"】"+staffName+"导购code:"+clerkCode+"已解绑,请重新分配会员!";
JSONObject jsonObject = new JSONObject();
jsonObject.put("storeId", storeId);
String data = jsonObject.toJSONString();
String pageUrl = staffDepartmentRelatedApiService.getPageUrl(AppPageType.MEMBER_LIST.getCode(), data);
staffDepartmentRelatedApiService.sendSingleMessage(clerkId, "分配会员通知", content, pageUrl);
}
}
@Transactional
@Override
public void staffBind(String departmentId, String fromClerkCode,
String fromStaffDepartmentRelatedId) {
StaffDepartmentRelatedDTO oldStaffDepartmentRelatedDTO = staffDepartmentRelatedApiService.getByStaffDepartmentRelatedId(fromStaffDepartmentRelatedId);
if(oldStaffDepartmentRelatedDTO!=null){
//删除gic测的手机号和姓名
String clerkCode = oldStaffDepartmentRelatedDTO.getClerkCode();
if(StringUtils.isNotBlank(clerkCode)){
DepartmentDTO departmentDTO = departmentApiService.selectById(departmentId);
String storeId = departmentDTO.getRelatedId();
List<String> clerkCodes = new ArrayList<>();
clerkCodes.add(clerkCode);
List<ClerkDTO> list = clerkService.listClerk(storeId, clerkCodes, true);
for(ClerkDTO clerkDTO :list){
clerkDTO.setPhoneNumber("--");
clerkDTO.setClerkName(clerkDTO.getClerkName()+"(已解绑)");
clerkDTO.setHeadImgUrl("");
clerkService.updateClerk(clerkDTO);
}
}
}
//将指定人绑定clerkCode
StaffDepartmentRelatedDTO dto = new StaffDepartmentRelatedDTO();
dto.setStaffDepartmentRelatedId(fromStaffDepartmentRelatedId);
dto.setClerkCode(fromClerkCode);
dto.setUpdateTime(new Date());
staffDepartmentRelatedApiService.updateById(dto);
//更新gic数据
DepartmentDTO departmentDTO = departmentApiService.selectById(departmentId);
String storeId = departmentDTO.getRelatedId();
List<String> clerkCodes = new ArrayList<>();
clerkCodes.add(fromClerkCode);
List<ClerkDTO> list = clerkService.listClerk(storeId, clerkCodes, true);
String clerkName = CollectionUtil.isEmpty(list)?null:list.get(0).getClerkName();//获取姓名,发消息用
StaffDepartmentRelatedDTO staffDepartmentRelatedDTO = staffDepartmentRelatedApiService.getByStaffDepartmentRelatedId(fromStaffDepartmentRelatedId);
StaffDTO staffDTO = staffApiService.selectById(staffDepartmentRelatedDTO.getStaffId());
for(ClerkDTO clerkDTO :list){
clerkDTO.setPhoneNumber(staffDTO.getPhoneNumber());
clerkDTO.setClerkName(staffDTO.getStaffName());
clerkDTO.setHeadImgUrl(StringUtils.isEmpty(staffDTO.getHeadImg())?"":staffDTO.getHeadImg());
clerkService.updateClerk(clerkDTO);
}
//发送消息
if(StringUtils.isNotBlank(fromClerkCode)){
//发送消息
ClerkDTO leader = clerkService.getClerkLeaderByStoreId(storeId);
if(leader == null){
leader = new ClerkDTO();
}
String clerkId = leader.getClerkId();
String storeName = departmentDTO.getDepartmentName();
String staffName = clerkName;
String leaderName = leader.getClerkName();
String clerkCode = fromClerkCode;
String content = "【"+leaderName+"】:【"+storeName+"】"+staffName+"导购code:"+clerkCode+"已解绑,请重新分配会员!";
JSONObject jsonObject = new JSONObject();
jsonObject.put("storeId", storeId);
String data = jsonObject.toJSONString();
String pageUrl = staffDepartmentRelatedApiService.getPageUrl(AppPageType.MEMBER_LIST.getCode(), data);
staffDepartmentRelatedApiService.sendSingleMessage(clerkId, "分配会员通知", content, pageUrl);
}
}
}
package com.gic.haoban.manage.service.service.out.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.enterprise.api.constant.EnterpriseServiceEnum;
import com.gic.enterprise.api.service.EnterpriseUseForbidService;
import com.gic.haoban.manage.api.dto.QwPendingIdDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.service.QwFriendApiService;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.errorcode.HaoBanErrCode;
import com.gic.haoban.manage.service.pojo.bo.WxEnterpriseRelationBO;
import com.gic.haoban.manage.service.service.WxEnterpriseRelatedService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.util.QwInterfaceLimitEnum;
import com.gic.haoban.manage.service.util.QwTimesUtils;
import com.gic.wechat.api.dto.qywx.PendingIdDTO;
import com.gic.wechat.api.service.qywx.QywxExternalUserService;
@Service("qwFriendApiService")
public class QwFriendApiServiceImpl implements QwFriendApiService {
private static final Logger log = LogManager.getLogger(QwFriendApiService.class);
@Autowired
private EnterpriseUseForbidService enterpriseUseForbidService;
@Autowired
private QywxExternalUserService qywxExternalUserService;
@Autowired
private WxEnterpriseRelatedService wxEnterpriseRelatedService;
@Autowired
private WxEnterpriseService wxEnterpriseService;
@Autowired
private Config config;
@Override
public ServiceResponse<QwPendingIdDTO> getPendingIdByUnionid(String enterpriseId, String unionid, String openid) {
String suiteid = config.getWxSuiteid();
ServiceResponse<WxEnterpriseQwDTO> corpidResp = this.checkAndGetCorpid(enterpriseId);
if (!corpidResp.isSuccess()) {
return ServiceResponse.failure(corpidResp.getCode(), corpidResp.getMessage());
}
WxEnterpriseQwDTO qwDTO = corpidResp.getResult();
String wxEnterpriseId = qwDTO.getWxEnterpriseId();
boolean isLimit = QwTimesUtils.isLimit(wxEnterpriseId, enterpriseId,QwInterfaceLimitEnum.GET_PENDING_ID);
if (isLimit) {
return ServiceResponse.failure(HaoBanErrCode.ERR_2000.getCode(), HaoBanErrCode.ERR_2000.getMsg());
}
String corpid = qwDTO.getThirdCorpid();
ServiceResponse<PendingIdDTO> qwResp = this.qywxExternalUserService.unionidToExternalUserid(corpid, suiteid,
unionid, openid, 1);
QwTimesUtils.addTimes(wxEnterpriseId, QwInterfaceLimitEnum.GET_PENDING_ID);
log.info("获取pendingid,参数={},返回={}", unionid, JSON.toJSONString(qwResp));
if (!qwResp.isSuccess()) {
return ServiceResponse.failure(qwResp.getCode(), qwResp.getMessage());
}
QwPendingIdDTO dto = new QwPendingIdDTO();
dto.setExternalUserId(qwResp.getResult().getExternal_userid());
dto.setPendingId(qwResp.getResult().getPending_id());
return ServiceResponse.success(dto);
}
@Override
public ServiceResponse<QwPendingIdDTO> getPendingIdByExternalid(String enterpriseId, String externalUserId) {
String suiteid = config.getWxSuiteid();
ServiceResponse<WxEnterpriseQwDTO> corpidResp = this.checkAndGetCorpid(enterpriseId);
if (!corpidResp.isSuccess()) {
return ServiceResponse.failure(corpidResp.getCode(), corpidResp.getMessage());
}
WxEnterpriseQwDTO qwDTO = corpidResp.getResult();
String corpid = qwDTO.getThirdCorpid();
ServiceResponse<List<PendingIdDTO>> qwResp = this.qywxExternalUserService.externalUseridToPendingId(corpid,
suiteid, Arrays.asList(externalUserId));
log.info("获取pendingid,参数={},返回={}", externalUserId, JSON.toJSONString(qwResp));
if (!qwResp.isSuccess()) {
return ServiceResponse.failure(qwResp.getCode(), qwResp.getMessage());
}
List<PendingIdDTO> list = qwResp.getResult();
if (CollectionUtils.isNotEmpty(list)) {
QwPendingIdDTO dto = new QwPendingIdDTO();
dto.setExternalUserId(list.get(0).getExternal_userid());
dto.setPendingId(list.get(0).getPending_id());
return ServiceResponse.success(dto);
}
return ServiceResponse.failure("9999", "企微未查询到数据");
}
@Override
public ServiceResponse<List<QwPendingIdDTO>> listPendingIdByExternalid(String enterpriseId,
List<String> externalUserIdList) {
if (CollectionUtils.isEmpty(externalUserIdList) || externalUserIdList.size() > 1000) {
return ServiceResponse.failure("9999", "外部联系人不能为空且每次最多1000条");
}
String suiteid = config.getWxSuiteid();
ServiceResponse<WxEnterpriseQwDTO> corpidResp = this.checkAndGetCorpid(enterpriseId);
if (!corpidResp.isSuccess()) {
return ServiceResponse.failure(corpidResp.getCode(), corpidResp.getMessage());
}
WxEnterpriseQwDTO qwDTO = corpidResp.getResult();
String corpid = qwDTO.getThirdCorpid();
ServiceResponse<List<PendingIdDTO>> qwResp = this.qywxExternalUserService.externalUseridToPendingId(corpid,
suiteid, externalUserIdList);
log.info("获取pendingid,参数={},返回={}", externalUserIdList, JSON.toJSONString(qwResp));
if (!qwResp.isSuccess()) {
return ServiceResponse.failure(qwResp.getCode(), qwResp.getMessage());
}
List<PendingIdDTO> list = qwResp.getResult();
if (CollectionUtils.isNotEmpty(list)) {
List<QwPendingIdDTO> retList = new ArrayList<>();
for (PendingIdDTO item : list) {
QwPendingIdDTO dto = new QwPendingIdDTO();
dto.setExternalUserId(item.getExternal_userid());
dto.setPendingId(item.getPending_id());
retList.add(dto);
}
return ServiceResponse.success(retList);
}
return ServiceResponse.failure("9999", "企微未查询到数据");
}
// 判断企业是否能用企微
private ServiceResponse<WxEnterpriseQwDTO> checkAndGetCorpid(String enterpriseId) {
WxEnterpriseRelationBO enterpriseRelation = this.wxEnterpriseRelatedService.getHeadEnterprise(enterpriseId);
if (null == enterpriseRelation) {
// 非总部或不存在
return ServiceResponse.failure("9999", "请确认商户是否有效且是总部");
}
Integer code = this.enterpriseUseForbidService.selectPermissionStatus(enterpriseId,
EnterpriseServiceEnum.HAO_BAN.getRightMenuCode());
log.info("好办是否到期停用={},{}", enterpriseId, code);
if (code != 0 && code != 1) {
return ServiceResponse.failure("9999", "商户已停用");
}
int memberOpenCardlag = enterpriseRelation.getMemberOpenCardFlag();
if (memberOpenCardlag != 0) {
// 不在同一开放平台
return ServiceResponse.failure("9999", "不在同一开放平台");
}
String wxEnterpriseId = enterpriseRelation.getWxEnterpriseId();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
return ServiceResponse.success(qwDTO);
}
}
package com.gic.haoban.manage.service.util;
public enum QwInterfaceLimitEnum {
GET_PENDING_ID("qw_limit_pending_id", "unionid查询external_userid接口", 0);
private String name;
private String remark;
private int type;
private QwInterfaceLimitEnum(String name, String remark, int type) {
this.name = name;
this.remark = remark;
this.type = type;
}
public String getName() {
return name;
}
public String getRemark() {
return remark;
}
public int getType() {
return type;
}
public void setName(String name) {
this.name = name;
}
public void setRemark(String remark) {
this.remark = remark;
}
public void setType(int type) {
this.type = type;
}
}
package com.gic.haoban.manage.service.util;
import java.util.Date;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.redisson.api.RAtomicLong;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.DateUtil;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.enterprise.service.CustomSettingApiService;
import com.gic.haoban.common.utils.DingUtils;
import com.gic.haoban.manage.service.pojo.bo.QwLimitTimesBO;
import com.gic.redis.data.util.RedisUtil;
@Component
public class QwTimesUtils {
private static Logger logger = LogManager.getLogger(QwTimesUtils.class);
private static CustomSettingApiService customSettingApiService;
public static EnterpriseService enterpriseService;
@Autowired
public void setCustomSettingApiService(CustomSettingApiService customSettingApiService) {
QwTimesUtils.customSettingApiService = customSettingApiService;
}
@Autowired
public void setEnterpriseService(EnterpriseService enterpriseService) {
QwTimesUtils.enterpriseService = enterpriseService;
}
public static boolean isLimit(String wxEnterpriseId, String enterpriseId, QwInterfaceLimitEnum obj) {
QwLimitTimesBO setTimeBO = getSettingTimes(wxEnterpriseId, obj);
logger.info("获取配置次数={},wxEnterpriseId={}", JSON.toJSONString(setTimeBO), wxEnterpriseId);
// 先判断月
String interfaceName = obj.getName();
Date now = new Date();
String dateStr = getDateStr(now);
String keyMonth = getCacheKey(wxEnterpriseId, interfaceName, dateStr.substring(0, 6));
boolean monthResult = timesCheck(1, keyMonth, obj, wxEnterpriseId, enterpriseId, now, setTimeBO);
if (monthResult) {
logger.info("月达到限制={}", keyMonth);
return true;
}
// 天
String keyDay = getCacheKey(wxEnterpriseId, interfaceName, dateStr.substring(0, 8));
boolean dayResult = timesCheck(2, keyDay, obj, wxEnterpriseId, enterpriseId, now, setTimeBO);
if (dayResult) {
logger.info("天达到限制={}", keyDay);
return true;
}
// 小时
String keyHour = getCacheKey(wxEnterpriseId, interfaceName, dateStr.substring(0, 10));
boolean hourResult = timesCheck(3, keyHour, obj, wxEnterpriseId, enterpriseId, now, setTimeBO);
if (hourResult) {
logger.info("小时达到限制={}", keyHour);
return true;
}
return false;
}
private static boolean timesCheck(int type, String cacheKey, QwInterfaceLimitEnum obj, String wxEnterpriseId,
String enterpriseId, Date now, QwLimitTimesBO setTimeBO) {
Integer doneTimes = RedisUtil.getCache(cacheKey, Integer.class);
logger.info("获取已调次数={},cacheKey={}", doneTimes, cacheKey);
if (null == doneTimes) {
return false;
}
int setTimes = 0;
switch (type) {
case 1:
setTimes = setTimeBO.getMonth();
break;
case 2:
setTimes = setTimeBO.getDay();
break;
case 3:
setTimes = setTimeBO.getHour();
break;
default:
break;
}
sendAlert(type, doneTimes, setTimes, obj, enterpriseId, now);
if (doneTimes >= setTimes) {
return true;
}
return false;
}
private static QwLimitTimesBO getSettingTimes(String wxEnterpriseId, QwInterfaceLimitEnum obj) {
String key = String.format("%s_%s", obj.getName(), wxEnterpriseId);
QwLimitTimesBO times = getTimes(key);
if (null == times) {
return getTimes(obj.getName());
}
return times;
}
private static QwLimitTimesBO getTimes(String key) {
JSONObject searchParamMap = new JSONObject();
searchParamMap.put("key", key);
ServiceResponse<Map<String, Object>> resp = customSettingApiService.getDetail("tab_gic_map",
searchParamMap.toJSONString());
if (resp.isSuccess() && null != resp.getResult()) {
QwLimitTimesBO times = new QwLimitTimesBO();
times = JSON.parseObject(resp.getResult().get("value").toString(), QwLimitTimesBO.class);
logger.info("获取默认配置次数={},{}", times, key);
return times;
}
return null;
}
private static void sendAlert(int type, int doneTimes, int setTimes, QwInterfaceLimitEnum obj, String enterpriseId,
Date now) {
// 调用次数达上线
String time = null;
String title = "已达上限";
boolean sendFlag = false;
if (doneTimes >= setTimes) {
sendFlag = true;
if (type == 1) {
time = DateUtil.dateToStr(now, "yyyy年MM月");
}
if (type == 2) {
time = DateUtil.dateToStr(now, "yyyy年MM月dd日");
}
if (type == 3) {
time = DateUtil.dateToStr(now, "yyyy年MM月dd日 HH:mm:ss");
}
} else if (type == 1 || type == 2) {
switch (type) {
case 1:
setTimes = setTimes - 30000;
break;
case 2:
setTimes = setTimes - 300000;
break;
default:
break;
}
if (doneTimes >= setTimes) {
sendFlag = true;
if (type == 1) {
time = DateUtil.dateToStr(now, "yyyy年MM月");
}
if (type == 2) {
DateUtil.dateToStr(now, "yyyy年MM月dd日");
}
title = "即将达到可调用次数";
}
}
if (sendFlag) {
EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(enterpriseId);
String brandName = enterpriseDTO.getBrandName();
// 达到上限时文案
String msg = String.format("告警【%s】%s调用在【%s】%s", brandName, obj.getRemark(), time, title);
DingUtils.send(msg, false);
}
}
public static void addTimes(String wxEnterpriseId, QwInterfaceLimitEnum obj) {
String interfaceName = obj.getName();
Date now = new Date();
String dateStr = getDateStr(now);
String keyHour = getCacheKey(wxEnterpriseId, interfaceName, dateStr.substring(0, 10));
addTimes(3, keyHour);
String keyDay = getCacheKey(wxEnterpriseId, interfaceName, dateStr.substring(0, 8));
addTimes(2, keyDay);
String keyMonth = getCacheKey(wxEnterpriseId, interfaceName, dateStr.substring(0, 6));
addTimes(1, keyMonth);
}
private static String getCacheKey(String wxEnterpriseId, String interfacName, String dateStr) {
return new StringBuilder(wxEnterpriseId).append(interfacName).append(dateStr).toString();
}
// 1月 2天 3小时
private static void addTimes(int type, String key) {
RAtomicLong cache = RedisUtil.getRedisClient().getAtomicLong(key);
long val = cache.addAndGet(1);
if (val <= 1) {
switch (type) {
case 1:
cache.expire(31, TimeUnit.DAYS);
break;
case 2:
cache.expire(1, TimeUnit.DAYS);
break;
case 3:
cache.expire(1, TimeUnit.HOURS);
break;
default:
break;
}
}
}
private static String getDateStr(Date now) {
String dateStr = DateUtil.dateToStr(now, "yyyyMMddHHmmss");
return dateStr;
}
}
...@@ -46,8 +46,6 @@ ...@@ -46,8 +46,6 @@
timeout="10000"/> timeout="10000"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService" <dubbo:service interface="com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService"
ref="memberUnionidRelatedApiServiceImpl" timeout="10000"/> ref="memberUnionidRelatedApiServiceImpl" timeout="10000"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.BindApiService" ref="bindApiServiceImpl"
timeout="10000"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.ApplicationSettingApiService" <dubbo:service interface="com.gic.haoban.manage.api.service.ApplicationSettingApiService"
ref="applicationSettingApiServiceImpl" timeout="10000"/> ref="applicationSettingApiServiceImpl" timeout="10000"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.AuditSettingApiService" ref="auditSettingApiServiceImpl" <dubbo:service interface="com.gic.haoban.manage.api.service.AuditSettingApiService" ref="auditSettingApiServiceImpl"
...@@ -134,8 +132,7 @@ ...@@ -134,8 +132,7 @@
<dubbo:reference interface="com.gic.enterprise.api.service.EnterpriseUseForbidService" id="enterpriseUseForbidService"/> <dubbo:reference interface="com.gic.enterprise.api.service.EnterpriseUseForbidService" id="enterpriseUseForbidService"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.role.HaobanMenuApiService" ref="haobanMenuApiServiceImpl"/> <dubbo:service interface="com.gic.haoban.manage.api.service.role.HaobanMenuApiService" ref="haobanMenuApiServiceImpl"/>
<dubbo:service interface="com.gic.haoban.manage.api.service.role.HaobanRoleApiService" ref="haobanRoleApiServiceImpl"/> <dubbo:service interface="com.gic.haoban.manage.api.service.role.HaobanRoleApiService" ref="haobanRoleApiServiceImpl"/>
<dubbo:reference interface="com.gic.enterprise.api.service.DepartmentService" id="gicDepartmentService"/> <dubbo:reference interface="com.gic.enterprise.api.service.DepartmentService" id="gicDepartmentService"/>
<dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxDepartmentApiService" <dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxDepartmentApiService"
id="qywxDepartmentApiService"/> id="qywxDepartmentApiService"/>
...@@ -191,7 +188,7 @@ ...@@ -191,7 +188,7 @@
interface="com.gic.enterprise.api.service.StoreWidgetService" timeout="10000" interface="com.gic.enterprise.api.service.StoreWidgetService" timeout="10000"
retries="0" check="false"/> retries="0" check="false"/>
<dubbo:reference id="memberTagOpenApiService" interface="com.gic.member.tag.api.service.MemberTagOpenApiService" timeout="10000" retries="0" check="false"/> <dubbo:reference id="memberTagOpenApiService" interface="com.gic.member.tag.api.service.MemberTagOpenApiService" timeout="10000" retries="0" check="false"/>
<dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxExternalUserService" id="qywxExternalUserService"/>
<dubbo:reference interface="com.gic.marketing.api.service.SmsService" id="smsService" timeout="10000" retries="0"/> <dubbo:reference interface="com.gic.marketing.api.service.SmsService" id="smsService" timeout="10000" retries="0"/>
<dubbo:reference interface="com.gic.marketing.api.service.AccountOverdueSmsSendService" id="accountOverdueSmsSendService" timeout="10000" retries="0"/> <dubbo:reference interface="com.gic.marketing.api.service.AccountOverdueSmsSendService" id="accountOverdueSmsSendService" timeout="10000" retries="0"/>
<dubbo:reference interface="com.gic.thirdparty.api.service.VoiceService" id="voiceService" timeout="10000" retries="0"/> <dubbo:reference interface="com.gic.thirdparty.api.service.VoiceService" id="voiceService" timeout="10000" retries="0"/>
......
...@@ -27,11 +27,6 @@ ...@@ -27,11 +27,6 @@
from tab_haoban_wx_enterprise_related from tab_haoban_wx_enterprise_related
where wx_enterprise_related_id = #{wxEnterpriseRelatedId,jdbcType=VARCHAR} where wx_enterprise_related_id = #{wxEnterpriseRelatedId,jdbcType=VARCHAR}
</select> </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete
from tab_haoban_wx_enterprise_related
where wx_enterprise_related_id = #{wxEnterpriseRelatedId,jdbcType=VARCHAR}
</delete>
<update id="deleteByEnterpriseId"> <update id="deleteByEnterpriseId">
update tab_haoban_wx_enterprise_related set status_flag = 0 , update_time=now() where enterprise_id=#{enterpriseId} and status_flag=1 update tab_haoban_wx_enterprise_related set status_flag = 0 , update_time=now() where enterprise_id=#{enterpriseId} and status_flag=1
......
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse; import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.dto.EnterpriseDetailDTO; import com.gic.haoban.manage.api.dto.EnterpriseDetailDTO;
import com.gic.haoban.manage.api.dto.hm.HmGroupDTO; import com.gic.haoban.manage.api.dto.hm.HmGroupDTO;
import com.gic.haoban.manage.api.dto.hm.HmGroupQueryDTO; import com.gic.haoban.manage.api.dto.hm.HmGroupQueryDTO;
import com.gic.haoban.manage.api.dto.hm.HmPageDTO; import com.gic.haoban.manage.api.dto.hm.HmPageDTO;
import com.gic.haoban.manage.api.dto.hm.HmPageRelationDTO; import com.gic.haoban.manage.api.dto.hm.HmPageRelationDTO;
import com.gic.haoban.manage.api.dto.hm.HmWelcomeRelationDTO; import com.gic.haoban.manage.api.dto.hm.HmWelcomeRelationDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.HmPageRelationQDTO; import com.gic.haoban.manage.api.dto.qdto.hm.HmPageRelationQDTO;
import com.gic.haoban.manage.api.dto.welcome.qdto.QueryWelcomeRelationQDTO; import com.gic.haoban.manage.api.dto.welcome.qdto.QueryWelcomeRelationQDTO;
import com.gic.haoban.manage.api.enums.hm.HmWelcomeReferType; import com.gic.haoban.manage.api.enums.hm.HmWelcomeReferType;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService; import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService; import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.api.service.hm.HmGroupApiService; import com.gic.haoban.manage.api.service.hm.HmGroupApiService;
import com.gic.haoban.manage.api.service.hm.HmPageApiService; import com.gic.haoban.manage.api.service.hm.HmPageApiService;
import com.gic.haoban.manage.api.service.hm.HmQrcodeApiService; import com.gic.haoban.manage.api.service.hm.HmQrcodeApiService;
import com.gic.haoban.manage.api.service.hm.HmWelcomeRelationApiService; import com.gic.haoban.manage.api.service.hm.HmWelcomeRelationApiService;
import com.gic.haoban.manage.service.pojo.bo.hm.HmWelcomeRelationBO; import com.gic.haoban.manage.service.pojo.bo.hm.HmWelcomeRelationBO;
import com.gic.haoban.manage.service.service.ExternalClerkRelatedService; import com.gic.haoban.manage.service.service.ExternalClerkRelatedService;
import com.gic.haoban.manage.service.service.hm.WelcomeRelationService; import com.gic.haoban.manage.service.service.hm.WelcomeRelationService;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"}) @ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"})
public class HmPageServiceTest { public class HmPageServiceTest {
@Autowired @Autowired
private HmPageApiService pageService; private HmPageApiService pageService;
@Autowired @Autowired
private WxEnterpriseRelatedApiService enterpriseRelatedApiService; private WxEnterpriseRelatedApiService enterpriseRelatedApiService;
@Autowired @Autowired
private HmGroupApiService groupService; private HmGroupApiService groupService;
@Autowired @Autowired
private HmWelcomeRelationApiService welcomeRelationApiService; private HmWelcomeRelationApiService welcomeRelationApiService;
@Autowired @Autowired
private WxEnterpriseApiService wxEnterpriseApiService ; private WxEnterpriseApiService wxEnterpriseApiService ;
@Autowired @Autowired
private ExternalClerkRelatedService externalClerkRelatedService ; private ExternalClerkRelatedService externalClerkRelatedService ;
@Test @Test
public void test(){ public void test(){
this.externalClerkRelatedService.repairExternalUserId("218a8a6c2ca14e28a1053f541be0e49d,ca66a01b79474c40b3e7c7f93daf1a3b"); this.externalClerkRelatedService.repairExternalUserId("218a8a6c2ca14e28a1053f541be0e49d,ca66a01b79474c40b3e7c7f93daf1a3b");
// this.wxEnterpriseApiService.stopHaoban("ff80808182c3a46b0182c3a4ea7d0000"); // this.wxEnterpriseApiService.stopHaoban("ff80808182c3a46b0182c3a4ea7d0000");
/* HmPageQDTO pageQDTO = new HmPageQDTO(); /* HmPageQDTO pageQDTO = new HmPageQDTO();
pageQDTO.setPageSearchText("MB01419872763172380673"); pageQDTO.setPageSearchText("MB01419872763172380673");
ServiceResponse<Page<HmPageDTO>> pageServiceResponse = pageService.queryPageList(pageQDTO);*/ ServiceResponse<Page<HmPageDTO>> pageServiceResponse = pageService.queryPageList(pageQDTO);*/
} }
@Test @Test
public void entriprise(){ public void entriprise(){
ServiceResponse<EnterpriseDetailDTO> enterpriseDetailDTOServiceResponse = enterpriseRelatedApiService.queryEnterpriseDetail("ca66a01b79474c40b3e7c7f93daf1a3b", "ff8080815dacd3a2015dacd3ef5c0000"); ServiceResponse<EnterpriseDetailDTO> enterpriseDetailDTOServiceResponse = enterpriseRelatedApiService.queryEnterpriseDetail("ca66a01b79474c40b3e7c7f93daf1a3b", "ff8080815dacd3a2015dacd3ef5c0000");
System.out.println(JSON.toJSONString(enterpriseDetailDTOServiceResponse)); System.out.println(JSON.toJSONString(enterpriseDetailDTOServiceResponse));
} }
@Test @Test
public void queryPageList(){ public void queryPageList(){
HmPageRelationQDTO pageRelationQDTO = new HmPageRelationQDTO(); HmPageRelationQDTO pageRelationQDTO = new HmPageRelationQDTO();
pageRelationQDTO.setPageId(418460224953786370L); pageRelationQDTO.setPageId(418460224953786370L);
pageRelationQDTO.setEnterpriseId("ff8080815dacd3a2015dacd3ef5c0000"); pageRelationQDTO.setEnterpriseId("ff8080815dacd3a2015dacd3ef5c0000");
ServiceResponse<Page<HmPageRelationDTO>> pageServiceResponse = pageService.queryPageRelation(pageRelationQDTO); ServiceResponse<Page<HmPageRelationDTO>> pageServiceResponse = pageService.queryPageRelation(pageRelationQDTO);
System.out.println(JSON.toJSONString(pageServiceResponse)); System.out.println(JSON.toJSONString(pageServiceResponse));
} }
@Test @Test
public void deletePage(){ public void deletePage(){
HmPageDTO pageDTO = new HmPageDTO(); HmPageDTO pageDTO = new HmPageDTO();
pageDTO.setPageId(418460224953786370L); pageDTO.setPageId(418460224953786370L);
ServiceResponse<Boolean> booleanServiceResponse = pageService.deleteHmPage(pageDTO); ServiceResponse<Boolean> booleanServiceResponse = pageService.deleteHmPage(pageDTO);
System.out.println(JSON.toJSONString(booleanServiceResponse)); System.out.println(JSON.toJSONString(booleanServiceResponse));
} }
@Test @Test
public void groupList(){ public void groupList(){
HmGroupQueryDTO groupQueryDTO = new HmGroupQueryDTO(); HmGroupQueryDTO groupQueryDTO = new HmGroupQueryDTO();
//groupQueryDTO.setGroupName("默认"); //groupQueryDTO.setGroupName("默认");
groupQueryDTO.setEnterpriseId("ff8080815dacd3a2015dacd3ef5c0000"); groupQueryDTO.setEnterpriseId("ff8080815dacd3a2015dacd3ef5c0000");
groupQueryDTO.setClerkId("b7279937120a433b9d96ae3c9abedb04"); groupQueryDTO.setClerkId("b7279937120a433b9d96ae3c9abedb04");
ServiceResponse<Page<HmGroupDTO>> pageServiceResponse = groupService.queryHmGroupSettingList(groupQueryDTO); ServiceResponse<Page<HmGroupDTO>> pageServiceResponse = groupService.queryHmGroupSettingList(groupQueryDTO);
System.out.println(JSON.toJSONString(pageServiceResponse)); System.out.println(JSON.toJSONString(pageServiceResponse));
} }
@Autowired @Autowired
private WelcomeRelationService welcomeRelationService; private WelcomeRelationService welcomeRelationService;
@Test @Test
public void saveWelcomeRelation(){ public void saveWelcomeRelation(){
HmWelcomeRelationBO welcomeRelationBo = new HmWelcomeRelationBO(); HmWelcomeRelationBO welcomeRelationBo = new HmWelcomeRelationBO();
welcomeRelationBo.setEnterpriseId("1231321312312"); welcomeRelationBo.setEnterpriseId("1231321312312");
welcomeRelationBo.setWxEnterpriseId("31312312312"); welcomeRelationBo.setWxEnterpriseId("31312312312");
welcomeRelationBo.setReferId("313131"); welcomeRelationBo.setReferId("313131");
welcomeRelationBo.setReferCode("HM1312312312"); welcomeRelationBo.setReferCode("HM1312312312");
welcomeRelationBo.setReferName("活码名称"); welcomeRelationBo.setReferName("活码名称");
welcomeRelationBo.setType(HmWelcomeReferType.HM.getCode()); welcomeRelationBo.setType(HmWelcomeReferType.HM.getCode());
welcomeRelationService.saveHmWelcomeRelation(welcomeRelationBo); welcomeRelationService.saveHmWelcomeRelation(welcomeRelationBo);
} }
@Test @Test
public void updateWelcomeRelationTest(){ public void updateWelcomeRelationTest(){
HmWelcomeRelationBO welcomeRelationBo = new HmWelcomeRelationBO(); HmWelcomeRelationBO welcomeRelationBo = new HmWelcomeRelationBO();
welcomeRelationBo.setEnterpriseId("1231321312312"); welcomeRelationBo.setEnterpriseId("1231321312312");
welcomeRelationBo.setWxEnterpriseId("31312312312"); welcomeRelationBo.setWxEnterpriseId("31312312312");
welcomeRelationBo.setReferId("313131"); welcomeRelationBo.setReferId("313131");
welcomeRelationBo.setReferCode("HM1312312dada"); welcomeRelationBo.setReferCode("HM1312312dada");
welcomeRelationBo.setReferName("活码名称"); welcomeRelationBo.setReferName("活码名称");
welcomeRelationBo.setType(HmWelcomeReferType.HM.getCode()); welcomeRelationBo.setType(HmWelcomeReferType.HM.getCode());
welcomeRelationService.updateWelcomeRelation(welcomeRelationBo); welcomeRelationService.updateWelcomeRelation(welcomeRelationBo);
} }
@Autowired @Autowired
private HmQrcodeApiService qrcodeApiService; private HmQrcodeApiService qrcodeApiService;
@Test @Test
public void batchUpdateQrcode(){ public void batchUpdateQrcode(){
List<Long> ids = Arrays.asList(418494104339988481L, 418494104339988482L); List<Long> ids = Arrays.asList(418494104339988481L, 418494104339988482L);
long grouoId = 420219621589671937L; long grouoId = 420219621589671937L;
ServiceResponse<Boolean> booleanServiceResponse = qrcodeApiService.batchUpdateHmQrcodeGroup(ids, grouoId); ServiceResponse<Boolean> booleanServiceResponse = qrcodeApiService.batchUpdateHmQrcodeGroup(ids, grouoId);
System.out.println(JSON.toJSONString(booleanServiceResponse)); System.out.println(JSON.toJSONString(booleanServiceResponse));
} }
@Test @Test
public void welcomeTest(){ public void welcomeTest(){
QueryWelcomeRelationQDTO qdto = new QueryWelcomeRelationQDTO(); QueryWelcomeRelationQDTO qdto = new QueryWelcomeRelationQDTO();
qdto.setWelcomeId("7f12bdab4fb543e8977f96e30fc8eddb"); qdto.setWelcomeId("7f12bdab4fb543e8977f96e30fc8eddb");
//qdto.setSearchContent("测试"); //qdto.setSearchContent("测试");
ServiceResponse<Page<HmWelcomeRelationDTO>> serviceResponse = welcomeRelationApiService.queryWelcomeRelation(qdto); ServiceResponse<Page<HmWelcomeRelationDTO>> serviceResponse = welcomeRelationApiService.queryWelcomeRelation(qdto);
System.out.println(JSON.toJSONString(serviceResponse)); System.out.println(JSON.toJSONString(serviceResponse));
} }
@Test @Test
public void groupNameCheckTest(){ public void groupNameCheckTest(){
ServiceResponse<List<HmGroupDTO>> ms = groupService.queryGroupListByName("", "ff8080815dacd3a2015dacd3ef5c0000", "测试006"); ServiceResponse<List<HmGroupDTO>> ms = groupService.queryGroupListByName("", "ff8080815dacd3a2015dacd3ef5c0000", "测试006");
System.out.println(JSON.toJSONString(ms)); System.out.println(JSON.toJSONString(ms));
} }
} }
...@@ -10,6 +10,8 @@ import com.gic.haoban.manage.api.dto.MaidianLogDTO; ...@@ -10,6 +10,8 @@ import com.gic.haoban.manage.api.dto.MaidianLogDTO;
import com.gic.haoban.manage.api.service.MaidianLogApiService; import com.gic.haoban.manage.api.service.MaidianLogApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode; import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -17,39 +19,57 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -17,39 +19,57 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@RestController @RestController
public class MaidianLogController extends WebBaseController{ public class MaidianLogController extends WebBaseController {
private static final Logger logger = LoggerFactory.getLogger(MaidianLogController.class);
@Autowired
private MaidianLogApiService maidianLogApiService; @Autowired
@Autowired private MaidianLogApiService maidianLogApiService;
private ClerkService clerkService; @Autowired
@Autowired private ClerkService clerkService;
private StoreService storeService; @Autowired
private StoreService storeService;
@RequestMapping("save-maidian-log")
@IgnoreLogin @RequestMapping("save-maidian-log")
public HaobanResponse saveUserLoginLog(String maidianLogStr) { @IgnoreLogin
if(StringUtils.isBlank(maidianLogStr)){ public HaobanResponse saveUserLoginLog(String maidianLogStr) {
return resultResponse(HaoBanErrCode.ERR_2); if (StringUtils.isBlank(maidianLogStr)) {
} return resultResponse(HaoBanErrCode.ERR_2);
List<MaidianLogDTO> maidianLogDTOList = JSON.parseArray(maidianLogStr,MaidianLogDTO.class); }
for (MaidianLogDTO maidianLogDTO : maidianLogDTOList) { if (!isJsonArray(maidianLogStr)) {
String options = maidianLogDTO.getOptions(); logger.error("埋点格式不正确:{}", maidianLogStr);
if(StringUtils.isNotBlank(options) && options.length() > 2000){ return resultResponse(HaoBanErrCode.ERR_1);
maidianLogDTO.setOptions(options.substring(0,1999)); }
} List<MaidianLogDTO> maidianLogDTOList = JSON.parseArray(maidianLogStr, MaidianLogDTO.class);
StoreDTO store = storeService.getStore(maidianLogDTO.getStoreId()); for (MaidianLogDTO maidianLogDTO : maidianLogDTOList) {
if(store != null){ String options = maidianLogDTO.getOptions();
com.gic.clerk.api.dto.ClerkDTO clerkDTO = clerkService.getClerkByClerkCode(store.getEnterpriseId(), maidianLogDTO.getClerkCode()); if (StringUtils.isNotBlank(options) && options.length() > 2000) {
maidianLogDTO.setEnterpriseId(store.getEnterpriseId()); maidianLogDTO.setOptions(options.substring(0, 1999));
if(clerkDTO != null){ }
maidianLogDTO.setClerkId(clerkDTO.getClerkId()); StoreDTO store = storeService.getStore(maidianLogDTO.getStoreId());
} if (store != null) {
} com.gic.clerk.api.dto.ClerkDTO clerkDTO = clerkService.getClerkByClerkCode(store.getEnterpriseId(), maidianLogDTO.getClerkCode());
maidianLogApiService.insert(maidianLogDTO); maidianLogDTO.setEnterpriseId(store.getEnterpriseId());
} if (clerkDTO != null) {
return resultResponse(HaoBanErrCode.ERR_1); maidianLogDTO.setClerkId(clerkDTO.getClerkId());
}
} }
maidianLogApiService.insert(maidianLogDTO);
}
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 检查JSON数据合法性
*/
public boolean isJsonArray(String str) {
try {
JSON.parseArray(str);
return true;
} catch (Exception e) {
logger.error("埋点格式不正确:{}", str, e);
return false;
}
}
} }
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
<dubbo:reference interface="com.gic.enterprise.api.service.StoreService" id="storeService"/> <dubbo:reference interface="com.gic.enterprise.api.service.StoreService" id="storeService"/>
<dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxCorpApiService" id="qywxCorpApiService"/> <dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxCorpApiService" id="qywxCorpApiService"/>
<dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxUserApiService" id="qywxUserApiService"/> <dubbo:reference interface="com.gic.wechat.api.service.qywx.QywxUserApiService" id="qywxUserApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.BindApiService" id="bindApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.AuditApiService" id="auditApiService"/> <dubbo:reference interface="com.gic.haoban.manage.api.service.AuditApiService" id="auditApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.AuditSettingApiService" id="auditSettingApiService"/> <dubbo:reference interface="com.gic.haoban.manage.api.service.AuditSettingApiService" id="auditSettingApiService"/>
<dubbo:reference interface="com.gic.dict.api.service.ManagerDictService" id="managerDictService"/> <dubbo:reference interface="com.gic.dict.api.service.ManagerDictService" id="managerDictService"/>
......
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