Commit 7b734cc8 by 墨竹

feat:1:活码加好友数量 2:定时任务重置 3:上限判断

parent d2e0b78b
...@@ -73,4 +73,28 @@ public interface HmQrcodeApiService { ...@@ -73,4 +73,28 @@ public interface HmQrcodeApiService {
* @date 2022-07-06 15:39:01 * @date 2022-07-06 15:39:01
*/ */
boolean delByClerkId(String clerkId,String enterpriseId); boolean delByClerkId(String clerkId,String enterpriseId);
/**
* 通过id添加num
*
* @param hmId hm id
* @param clerkId 职员id
* @return int
* @author mozhu
* @date 2022-07-07 11:14:53
*/
int updateAddNumById(Long hmId, String clerkId);
/**
* 重置 每天的上限好友数量
* 定时任务
*
* @param param 参数
* @author mozhu
* @date 2022-07-07 13:52:28
*/
void resetAddNumAndOverFlag(String param);
} }
package com.gic.haoban.manage.service.dao.mapper.hm; package com.gic.haoban.manage.service.dao.mapper.hm;
import com.gic.haoban.manage.service.entity.hm.TabHaobanHmClerkRelation; import com.gic.haoban.manage.service.entity.hm.TabHaobanHmClerkRelation;
import com.gic.haoban.manage.service.pojo.bo.hm.HmClerkRelationBO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;
import java.util.List; import java.util.List;
...@@ -22,22 +22,6 @@ public interface TabHaobanHmClerkRelationMapper { ...@@ -22,22 +22,6 @@ public interface TabHaobanHmClerkRelationMapper {
*/ */
TabHaobanHmClerkRelation queryById(Long relationId); TabHaobanHmClerkRelation queryById(Long relationId);
/**
* 查询指定行数据
*
* @param tabHaobanHmClerkRelation 查询条件
* @param pageable 分页对象
* @return 对象列表
*/
List<TabHaobanHmClerkRelation> queryAllByLimit(TabHaobanHmClerkRelation tabHaobanHmClerkRelation, @Param("pageable") Pageable pageable);
/**
* 统计总行数
*
* @param tabHaobanHmClerkRelation 查询条件
* @return 总行数
*/
long count(TabHaobanHmClerkRelation tabHaobanHmClerkRelation);
/** /**
* 新增数据 * 新增数据
...@@ -55,14 +39,6 @@ public interface TabHaobanHmClerkRelationMapper { ...@@ -55,14 +39,6 @@ public interface TabHaobanHmClerkRelationMapper {
*/ */
int insertBatch(@Param("entities") List<TabHaobanHmClerkRelation> entities); int insertBatch(@Param("entities") List<TabHaobanHmClerkRelation> entities);
/**
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
*
* @param entities List<TabHaobanHmClerkRelation> 实例对象列表
* @return 影响行数
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
*/
int insertOrUpdateBatch(@Param("entities") List<TabHaobanHmClerkRelation> entities);
/** /**
* 修改数据 * 修改数据
...@@ -84,5 +60,34 @@ public interface TabHaobanHmClerkRelationMapper { ...@@ -84,5 +60,34 @@ public interface TabHaobanHmClerkRelationMapper {
*/ */
int updateStatusByHmId(@Param("hmId") Long hmId, @Param("status") Integer status); int updateStatusByHmId(@Param("hmId") Long hmId, @Param("status") Integer status);
/**
* 查询hm id和职员id
*
* @param hmId
* @param clerkId
* @return {@link HmClerkRelationBO }
* @author mozhu
* @date 2022-07-07 13:33:22
*/
HmClerkRelationBO queryByHmIdAndClerkId(@Param("hmId") Long hmId, @Param("clerkId") String clerkId);
/**
* 更新 addnum
*
* @param relationId 关系id
* @param overFlag 是否上限1是0否
* @return int
* @author mozhu
* @date 2022-07-07 13:40:00
*/
int updateAddNumById(@Param("relationId") Long relationId, @Param("overFlag") Integer overFlag);
/**
* 重置
*
* @author mozhu
* @date 2022-07-07 13:53:36
*/
void resetAddNumAndOverFlag();
} }
...@@ -97,5 +97,23 @@ public interface TabHaobanHmQrcodeMapper { ...@@ -97,5 +97,23 @@ public interface TabHaobanHmQrcodeMapper {
*/ */
List<HmQrcodeBO> listByStoreId(@Param("storeId") String storeId,@Param("overFlag") Integer overFlag); List<HmQrcodeBO> listByStoreId(@Param("storeId") String storeId,@Param("overFlag") Integer overFlag);
/**
* 通过id添加num
*
* @param hmId hm id
* @param overFlag 在国旗
* @return int
* @author mozhu
* @date 2022-07-07 11:32:27
*/
int updateAddNumById(@Param("hmId") Long hmId, @Param("overFlag") Integer overFlag);
/**
* 重置
*
* @author mozhu
* @date 2022-07-07 13:54:43
*/
void resetAddNumAndOverFlag();
} }
...@@ -46,6 +46,8 @@ public class TabHaobanHmClerkRelation implements Serializable { ...@@ -46,6 +46,8 @@ public class TabHaobanHmClerkRelation implements Serializable {
*/ */
private Integer overFlag; private Integer overFlag;
private Integer addNum;
public Long getRelationId() { public Long getRelationId() {
return relationId; return relationId;
...@@ -167,5 +169,12 @@ public class TabHaobanHmClerkRelation implements Serializable { ...@@ -167,5 +169,12 @@ public class TabHaobanHmClerkRelation implements Serializable {
this.overFlag = overFlag; this.overFlag = overFlag;
} }
public Integer getAddNum() {
return addNum;
}
public void setAddNum(Integer addNum) {
this.addNum = addNum;
}
} }
...@@ -59,4 +59,34 @@ public interface HmClerkRelationService { ...@@ -59,4 +59,34 @@ public interface HmClerkRelationService {
*/ */
boolean deleteByHmId(Long hmId); boolean deleteByHmId(Long hmId);
/**
* 查询hm id和职员id
*
* @param hmId hm id
* @param clerkId 职员id
* @return {@link HmClerkRelationBO }
* @author mozhu
* @date 2022-07-07 11:44:53
*/
HmClerkRelationBO queryByHmIdAndClerkId(Long hmId, String clerkId);
/**
* 更新上线时间
*
* @param relationId 关系id
* @param overFlag 是否上限1是0否
* @return int
* @author mozhu
* @date 2022-07-07 13:41:29
*/
int updateAddNumById(Long relationId, Integer overFlag);
/**
* 重置
*
* @author mozhu
* @date 2022-07-07 13:53:13
*/
void resetAddNumAndOverFlag();
} }
...@@ -65,7 +65,7 @@ public interface HmQrcodeService { ...@@ -65,7 +65,7 @@ public interface HmQrcodeService {
* @author mozhu * @author mozhu
* @date 2022-07-06 15:35:40 * @date 2022-07-06 15:35:40
*/ */
List<HmQrcodeBO> listByClerkId(String clerkId,String enterpriseId); List<HmQrcodeBO> listByClerkId(String clerkId, String enterpriseId);
/** /**
...@@ -79,4 +79,22 @@ public interface HmQrcodeService { ...@@ -79,4 +79,22 @@ public interface HmQrcodeService {
*/ */
List<HmQrcodeBO> listByStoreId(String storeId, Integer overFlag); List<HmQrcodeBO> listByStoreId(String storeId, Integer overFlag);
/**
* 通过id添加num
*
* @param hmId hm id
* @param overFlag 在国旗
* @return int
* @author mozhu
* @date 2022-07-07 13:46:10
*/
int updateAddNumById(Long hmId, Integer overFlag);
/**
* 重置
*
* @author mozhu
* @date 2022-07-07 13:54:24
*/
void resetAddNumAndOverFlag();
} }
...@@ -53,4 +53,19 @@ public class HmClerkRelationServiceImpl implements HmClerkRelationService { ...@@ -53,4 +53,19 @@ public class HmClerkRelationServiceImpl implements HmClerkRelationService {
public boolean deleteByHmId(Long hmId) { public boolean deleteByHmId(Long hmId) {
return tabHaobanHmClerkRelationMapper.updateStatusByHmId(hmId, 0) > 0; return tabHaobanHmClerkRelationMapper.updateStatusByHmId(hmId, 0) > 0;
} }
@Override
public HmClerkRelationBO queryByHmIdAndClerkId(Long hmId, String clerkId) {
return tabHaobanHmClerkRelationMapper.queryByHmIdAndClerkId(hmId,clerkId);
}
@Override
public int updateAddNumById(Long relationId, Integer overFlag) {
return tabHaobanHmClerkRelationMapper.updateAddNumById(relationId,overFlag);
}
@Override
public void resetAddNumAndOverFlag() {
tabHaobanHmClerkRelationMapper.resetAddNumAndOverFlag();
}
} }
...@@ -62,16 +62,26 @@ public class HmQrcodeServiceImpl implements HmQrcodeService { ...@@ -62,16 +62,26 @@ public class HmQrcodeServiceImpl implements HmQrcodeService {
*/ */
@Override @Override
public boolean deleteById(Long hmId) { public boolean deleteById(Long hmId) {
return this.tabHaobanHmQrcodeMapper.updateStatusById(2,hmId) > 0; return this.tabHaobanHmQrcodeMapper.updateStatusById(2, hmId) > 0;
} }
@Override @Override
public List<HmQrcodeBO> listByClerkId(String clerkId, String enterpriseId) { public List<HmQrcodeBO> listByClerkId(String clerkId, String enterpriseId) {
return tabHaobanHmQrcodeMapper.listByClerkId(clerkId,enterpriseId); return tabHaobanHmQrcodeMapper.listByClerkId(clerkId, enterpriseId);
} }
@Override @Override
public List<HmQrcodeBO> listByStoreId(String storeId, Integer overFlag) { public List<HmQrcodeBO> listByStoreId(String storeId, Integer overFlag) {
return tabHaobanHmQrcodeMapper.listByStoreId(storeId,overFlag); return tabHaobanHmQrcodeMapper.listByStoreId(storeId, overFlag);
}
@Override
public int updateAddNumById(Long hmId, Integer overFlag) {
return tabHaobanHmQrcodeMapper.updateAddNumById(hmId, overFlag);
}
@Override
public void resetAddNumAndOverFlag() {
tabHaobanHmQrcodeMapper.resetAddNumAndOverFlag();
} }
} }
package com.gic.haoban.manage.service.service.impl; package com.gic.haoban.manage.service.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
...@@ -8,17 +7,16 @@ import com.gic.haoban.base.api.common.BasePageInfo; ...@@ -8,17 +7,16 @@ import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.PageUtil; import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.common.utils.StringUtil; import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO; import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeQDTO;
import com.gic.haoban.manage.api.enums.BindTypeEnum; import com.gic.haoban.manage.api.enums.BindTypeEnum;
import com.gic.haoban.manage.api.enums.ChannelCodeEnum; import com.gic.haoban.manage.api.enums.ChannelCodeEnum;
import com.gic.haoban.manage.api.service.hm.HmQrcodeApiService; import com.gic.haoban.manage.api.service.hm.HmQrcodeApiService;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanMemberClerkChatConfigMapper; import com.gic.haoban.manage.service.dao.mapper.TabHaobanMemberClerkChatConfigMapper;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanStaffClerkRelationMapper; import com.gic.haoban.manage.service.dao.mapper.TabHaobanStaffClerkRelationMapper;
import com.gic.haoban.manage.service.entity.MemberClerkChatConfig; import com.gic.haoban.manage.service.entity.MemberClerkChatConfig;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.TabHaobanStaffClerkRelation; import com.gic.haoban.manage.service.entity.TabHaobanStaffClerkRelation;
import com.gic.haoban.manage.service.service.ClerkMainStoreRelatedService; import com.gic.haoban.manage.service.service.*;
import com.gic.haoban.manage.service.service.ExternalClerkRelatedService;
import com.gic.haoban.manage.service.service.StaffClerkBindLogService;
import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
...@@ -53,6 +51,8 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService ...@@ -53,6 +51,8 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
@Autowired @Autowired
private HmQrcodeApiService hmQrcodeApiService; private HmQrcodeApiService hmQrcodeApiService;
@Autowired
private StaffService staffService;
@Override @Override
public List<StaffClerkRelationDTO> listBindCode(String enterpriseId, Set<String> clerkCodeList) { public List<StaffClerkRelationDTO> listBindCode(String enterpriseId, Set<String> clerkCodeList) {
...@@ -129,19 +129,33 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService ...@@ -129,19 +129,33 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
@Override @Override
public String bind(StaffClerkRelationDTO dto, String optStaffId, int chanelCode) { public String bind(StaffClerkRelationDTO dto, String optStaffId, int chanelCode) {
Date now = new Date();
dto.setStaffClerkRelationId(ToolUtil.randomUUID()); dto.setStaffClerkRelationId(ToolUtil.randomUUID());
dto.setStatusFlag(1); dto.setStatusFlag(1);
dto.setCreateTime(new Date()); dto.setCreateTime(now);
dto.setUpdateTime(new Date()); dto.setUpdateTime(now);
int insert = mapper.insert(EntityUtil.changeEntityByJSON(TabHaobanStaffClerkRelation.class, dto)); int insert = mapper.insert(EntityUtil.changeEntityByJSON(TabHaobanStaffClerkRelation.class, dto));
String s = insert > 0 ? dto.getStaffClerkRelationId() : null; String s = insert > 0 ? dto.getStaffClerkRelationId() : null;
if (null != s) { if (null != s) {
String staffId = dto.getStaffId(); String staffId = dto.getStaffId();
clerkMainStoreRelatedService.getMainStoreByStaffId(staffId, dto.getWxEnterpriseId()); TabHaobanStaff tabHaobanStaff = staffService.selectById(staffId);
String wxEnterpriseId = dto.getWxEnterpriseId();
clerkMainStoreRelatedService.getMainStoreByStaffId(staffId, wxEnterpriseId);
//推入日志 //推入日志
staffClerkBindLogService.pushToMq(staffId, optStaffId, BindTypeEnum.BIND.getVal(), chanelCode, dto.getStaffClerkRelationId()); staffClerkBindLogService.pushToMq(staffId, optStaffId, BindTypeEnum.BIND.getVal(), chanelCode, dto.getStaffClerkRelationId());
// TODO: 2022/7/6 绑定自动创建活码
// 绑定自动创建活码
HmQrcodeQDTO hmQrcodeQDTO = new HmQrcodeQDTO();
hmQrcodeQDTO.setHmType(1);
hmQrcodeQDTO.setWxEnterpriseId(wxEnterpriseId);
hmQrcodeQDTO.setEnterpriseId(dto.getEnterpriseId());
hmQrcodeQDTO.setName(tabHaobanStaff.getStaffName());
hmQrcodeQDTO.setCreateTime(now);
hmQrcodeQDTO.setUpdateTime(now);
hmQrcodeQDTO.setPassFlag(1);
hmQrcodeQDTO.setStoreId(dto.getStoreId());
hmQrcodeQDTO.setClerkIdList(Collections.singletonList(dto.getClerkId()));
hmQrcodeApiService.add(hmQrcodeQDTO);
} }
return s; return s;
} }
......
...@@ -2,14 +2,12 @@ package com.gic.haoban.manage.service.service.impl; ...@@ -2,14 +2,12 @@ package com.gic.haoban.manage.service.service.impl;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.commons.util.UniqueIdUtils; import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.common.utils.StringUtil; import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.welcome.qdto.QueryWelcomeQDTO; import com.gic.haoban.manage.api.dto.welcome.qdto.QueryWelcomeQDTO;
import com.gic.haoban.manage.api.enums.FriendSettingTypeEnum; import com.gic.haoban.manage.api.enums.FriendSettingTypeEnum;
import com.gic.haoban.manage.api.enums.WelcomeMediaTypeEnum; import com.gic.haoban.manage.api.enums.WelcomeMediaTypeEnum;
import com.gic.haoban.manage.api.enums.WelcomeRelationStatusEnum; import com.gic.haoban.manage.api.enums.WelcomeRelationStatusEnum;
import com.gic.haoban.manage.api.enums.WelcomeSuitTypeEnum; import com.gic.haoban.manage.api.enums.WelcomeSuitTypeEnum;
import com.gic.haoban.manage.api.enums.hm.HmWelcomeReferType;
import com.gic.haoban.manage.api.enums.hm.HmWelcomeType; import com.gic.haoban.manage.api.enums.hm.HmWelcomeType;
import com.gic.haoban.manage.service.dao.mapper.*; import com.gic.haoban.manage.service.dao.mapper.*;
import com.gic.haoban.manage.service.entity.*; import com.gic.haoban.manage.service.entity.*;
...@@ -644,4 +642,5 @@ public class WelcomeServiceImpl implements WelcomeService { ...@@ -644,4 +642,5 @@ public class WelcomeServiceImpl implements WelcomeService {
TabWelcome tabWelcome = welcomeMapper.selectByPrimaryKey(welcomeTemplateRelation.getWelcomeId()); TabWelcome tabWelcome = welcomeMapper.selectByPrimaryKey(welcomeTemplateRelation.getWelcomeId());
return convertWelcomeToBo(tabWelcome); return convertWelcomeToBo(tabWelcome);
} }
} }
...@@ -38,6 +38,7 @@ import com.gic.haoban.manage.api.service.CheckQywxSettingApiService; ...@@ -38,6 +38,7 @@ import com.gic.haoban.manage.api.service.CheckQywxSettingApiService;
import com.gic.haoban.manage.api.service.ExternalClerkRelatedApiService; import com.gic.haoban.manage.api.service.ExternalClerkRelatedApiService;
import com.gic.haoban.manage.api.service.MaterialApiService; import com.gic.haoban.manage.api.service.MaterialApiService;
import com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService; import com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService;
import com.gic.haoban.manage.api.service.hm.HmQrcodeApiService;
import com.gic.haoban.manage.service.config.Config; import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.MemberUnionidRelatedMapper; import com.gic.haoban.manage.service.dao.mapper.MemberUnionidRelatedMapper;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanExternalClerkRelatedMapper; import com.gic.haoban.manage.service.dao.mapper.TabHaobanExternalClerkRelatedMapper;
...@@ -145,6 +146,8 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA ...@@ -145,6 +146,8 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
private ImageService imageService; private ImageService imageService;
@Autowired @Autowired
private StaffDepartmentRelatedService staffDepartmentRelatedService; private StaffDepartmentRelatedService staffDepartmentRelatedService;
@Autowired
private HmQrcodeApiService hmQrcodeApiService;
@Override @Override
public void dealQywxExternalUser(String params) { public void dealQywxExternalUser(String params) {
...@@ -505,6 +508,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA ...@@ -505,6 +508,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
private void sendWelcome(MemberUnionidRelatedDTO dto, String wxEnterpriseId, String enterpriseId, String staffId, String clerkId) { private void sendWelcome(MemberUnionidRelatedDTO dto, String wxEnterpriseId, String enterpriseId, String staffId, String clerkId) {
log.info("发送欢迎语:dto:{},wxEnterpriseId:{},staffId:{}", JSONObject.toJSONString(dto), wxEnterpriseId, staffId); log.info("发送欢迎语:dto:{},wxEnterpriseId:{},staffId:{}", JSONObject.toJSONString(dto), wxEnterpriseId, staffId);
String welcomeCode = dto.getWelcomeCode(); String welcomeCode = dto.getWelcomeCode();
String state = dto.getState();
if (StringUtils.isBlank(welcomeCode)) { if (StringUtils.isBlank(welcomeCode)) {
log.error("welcomeCode为空,请检查是否使用企微的欢迎语:{}", wxEnterpriseId); log.error("welcomeCode为空,请检查是否使用企微的欢迎语:{}", wxEnterpriseId);
GicMQClient clientInstance = GICMQClientUtil.getClientInstance(); GicMQClient clientInstance = GICMQClientUtil.getClientInstance();
...@@ -522,11 +526,17 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA ...@@ -522,11 +526,17 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
} }
return; return;
} }
String relationKey = SecureUtil.md5(staffId + dto.getExternalUserid()); String relationKey = SecureUtil.md5(staffId + dto.getExternalUserid());
// TODO: 2022/7/4 正常欢迎语还是活码
WelcomeDetailBO welcomeDetailBO = welcomeService.getMatchWelcome(staffId, wxEnterpriseId); WelcomeDetailBO welcomeDetailBO = null;
if (StringUtils.isNotBlank(state)) {
log.info("特殊欢迎语 state:{}", state);
welcomeDetailBO = welcomeService.getMatchWelcomeWithReferId(staffId, wxEnterpriseId, state.substring(2));
} else {
welcomeDetailBO = welcomeService.getMatchWelcome(staffId, wxEnterpriseId);
}
if (Objects.isNull(welcomeDetailBO)) { if (Objects.isNull(welcomeDetailBO)) {
log.info("欢迎语未配置:wxEnterpriseId:{}", wxEnterpriseId); log.info("欢迎语未配置:wxEnterpriseId:{}", wxEnterpriseId);
return; return;
...@@ -581,6 +591,17 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA ...@@ -581,6 +591,17 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
} else { } else {
qywxUserApiService.sendWelcomeMsgByExternal(dto.getCorpid(), config.getWxSuiteid(), qywxWelcomeMsgDTO); qywxUserApiService.sendWelcomeMsgByExternal(dto.getCorpid(), config.getWxSuiteid(), qywxWelcomeMsgDTO);
} }
//发送完成欢迎语,数量+1
//"DT" "HM"
String refId = "";
if (StringUtils.isNotBlank(state) && StringUtils.isNotBlank(clerkId)) {
refId = state.substring(2);
if (state.contains("HM")) {
//活码
hmQrcodeApiService.updateAddNumById(Convert.toLong(refId),clerkId);
}
}
} }
private void attachmentAddImage(List<QywxExternalMessageBaseDTO> attachments, WelcomeMediaBO media, WxEnterpriseDTO wxEnterpriseDTO) { private void attachmentAddImage(List<QywxExternalMessageBaseDTO> attachments, WelcomeMediaBO media, WxEnterpriseDTO wxEnterpriseDTO) {
......
...@@ -17,11 +17,13 @@ import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeListQDTO; ...@@ -17,11 +17,13 @@ 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.HmQrcodeQDTO;
import com.gic.haoban.manage.api.service.hm.HmQrcodeApiService; import com.gic.haoban.manage.api.service.hm.HmQrcodeApiService;
import com.gic.haoban.manage.service.config.Config; import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.pojo.bo.hm.HmClerkRelationBO;
import com.gic.haoban.manage.service.pojo.bo.hm.HmQrcodeBO; import com.gic.haoban.manage.service.pojo.bo.hm.HmQrcodeBO;
import com.gic.haoban.manage.service.service.StaffClerkRelationService; import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import com.gic.haoban.manage.service.service.WxEnterpriseService; import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.hm.HmClerkRelationService; import com.gic.haoban.manage.service.service.hm.HmClerkRelationService;
import com.gic.haoban.manage.service.service.hm.HmQrcodeService; import com.gic.haoban.manage.service.service.hm.HmQrcodeService;
import com.gic.haoban.manage.service.util.QwFriendLimitCountUtil;
import com.gic.wechat.api.dto.qywx.welcome.QywxExternalcontactDTO; import com.gic.wechat.api.dto.qywx.welcome.QywxExternalcontactDTO;
import com.gic.wechat.api.dto.qywx.welcome.QywxExternalcontactResultDTO; import com.gic.wechat.api.dto.qywx.welcome.QywxExternalcontactResultDTO;
import com.gic.wechat.api.service.qywx.QywxUserApiService; import com.gic.wechat.api.service.qywx.QywxUserApiService;
...@@ -132,6 +134,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService { ...@@ -132,6 +134,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
/** /**
* 设置门店和导购 * 设置门店和导购
*
* @param hmQrcodeQDTO * @param hmQrcodeQDTO
* @param wxEnterpriseId * @param wxEnterpriseId
* @param hmId * @param hmId
...@@ -163,6 +166,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService { ...@@ -163,6 +166,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
/** /**
* 多人活码关联关系 * 多人活码关联关系
*
* @param hmQrcodeQDTO * @param hmQrcodeQDTO
* @param wxEnterpriseId * @param wxEnterpriseId
* @param hmId * @param hmId
...@@ -220,7 +224,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService { ...@@ -220,7 +224,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
public boolean delByClerkId(String clerkId, String enterpriseId) { public boolean delByClerkId(String clerkId, String enterpriseId) {
List<HmQrcodeBO> hmQrcodeBOS = hmQrcodeService.listByClerkId(clerkId, enterpriseId); List<HmQrcodeBO> hmQrcodeBOS = hmQrcodeService.listByClerkId(clerkId, enterpriseId);
if (CollectionUtils.isEmpty(hmQrcodeBOS)) { if (CollectionUtils.isEmpty(hmQrcodeBOS)) {
logger.error("无活码:clerkId:{}",clerkId); logger.error("无活码:clerkId:{}", clerkId);
return false; return false;
} }
...@@ -229,4 +233,44 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService { ...@@ -229,4 +233,44 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
} }
return true; return true;
} }
@Override
public int updateAddNumById(Long hmId, String clerkId) {
HmQrcodeBO hmQrcodeBO = hmQrcodeService.queryById(hmId);
if (hmQrcodeBO == null) {
logger.error("无活码数据");
return 0;
}
Integer hmType = hmQrcodeBO.getHmType();
int limit = QwFriendLimitCountUtil.getLimit(true);
Integer addNum = hmQrcodeBO.getAddNum();
if (hmType == 1) {
//单人活码
Integer overFlag = 0;
if (addNum + 1 >= limit) {
overFlag = 1;
}
return hmQrcodeService.updateAddNumById(hmId, overFlag);
} else if (hmType == 2) {
//多人活码
HmClerkRelationBO hmClerkRelationBO = hmClerkRelationService.queryByHmIdAndClerkId(hmId, clerkId);
if (hmClerkRelationBO == null) {
logger.error("无多人活码导购数据,clerkId:{},hmId:{}", clerkId, hmId);
return 0;
}
Integer overFlag = 0;
if (addNum + 1 >= limit) {
overFlag = 1;
}
Long relationId = hmClerkRelationBO.getRelationId();
return hmClerkRelationService.updateAddNumById(relationId, overFlag);
}
return 0;
}
@Override
public void resetAddNumAndOverFlag(String param) {
hmQrcodeService.resetAddNumAndOverFlag();
hmClerkRelationService.resetAddNumAndOverFlag();
}
} }
...@@ -18,182 +18,34 @@ ...@@ -18,182 +18,34 @@
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="overFlag" column="over_flag" jdbcType="INTEGER"/> <result property="overFlag" column="over_flag" jdbcType="INTEGER"/>
<result property="addNum" column="add_num" jdbcType="INTEGER"/>
</resultMap> </resultMap>
<!--查询单个--> <!--查询单个-->
<select id="queryById" resultMap="TabHaobanHmClerkRelationMap"> <select id="queryById" resultMap="TabHaobanHmClerkRelationMap">
select relation_id, select *
hm_id,
wx_user_id,
wx_enterprise_id,
enterprise_id,
store_id,
store_name,
store_code,
clerk_id,
clerk_name,
clerk_code,
status,
create_time,
update_time,
over_flag
from tab_haoban_hm_clerk_relation from tab_haoban_hm_clerk_relation
where relation_id = #{relationId} where relation_id = #{relationId}
</select> </select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="TabHaobanHmClerkRelationMap">
select
relation_id, hm_id, wx_user_id, wx_enterprise_id, enterprise_id, store_id, store_name, store_code, clerk_id,
clerk_name, clerk_code, status, create_time, update_time, over_flag
from tab_haoban_hm_clerk_relation
<where>
<if test="relationId != null">
and relation_id = #{relationId}
</if>
<if test="hmId != null">
and hm_id = #{hmId}
</if>
<if test="wxUserId != null and wxUserId != ''">
and wx_user_id = #{wxUserId}
</if>
<if test="wxEnterpriseId != null and wxEnterpriseId != ''">
and wx_enterprise_id = #{wxEnterpriseId}
</if>
<if test="enterpriseId != null and enterpriseId != ''">
and enterprise_id = #{enterpriseId}
</if>
<if test="storeId != null and storeId != ''">
and store_id = #{storeId}
</if>
<if test="storeName != null and storeName != ''">
and store_name = #{storeName}
</if>
<if test="storeCode != null and storeCode != ''">
and store_code = #{storeCode}
</if>
<if test="clerkId != null and clerkId != ''">
and clerk_id = #{clerkId}
</if>
<if test="clerkName != null and clerkName != ''">
and clerk_name = #{clerkName}
</if>
<if test="clerkCode != null and clerkCode != ''">
and clerk_code = #{clerkCode}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="overFlag != null">
and over_flag = #{overFlag}
</if>
</where>
limit #{pageable.offset}, #{pageable.pageSize}
</select>
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from tab_haoban_hm_clerk_relation
<where>
<if test="relationId != null">
and relation_id = #{relationId}
</if>
<if test="hmId != null">
and hm_id = #{hmId}
</if>
<if test="wxUserId != null and wxUserId != ''">
and wx_user_id = #{wxUserId}
</if>
<if test="wxEnterpriseId != null and wxEnterpriseId != ''">
and wx_enterprise_id = #{wxEnterpriseId}
</if>
<if test="enterpriseId != null and enterpriseId != ''">
and enterprise_id = #{enterpriseId}
</if>
<if test="storeId != null and storeId != ''">
and store_id = #{storeId}
</if>
<if test="storeName != null and storeName != ''">
and store_name = #{storeName}
</if>
<if test="storeCode != null and storeCode != ''">
and store_code = #{storeCode}
</if>
<if test="clerkId != null and clerkId != ''">
and clerk_id = #{clerkId}
</if>
<if test="clerkName != null and clerkName != ''">
and clerk_name = #{clerkName}
</if>
<if test="clerkCode != null and clerkCode != ''">
and clerk_code = #{clerkCode}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="overFlag != null">
and over_flag = #{overFlag}
</if>
</where>
</select>
<!--新增所有列--> <!--新增所有列-->
<insert id="insert" keyProperty="relationId" useGeneratedKeys="true"> <insert id="insert" keyProperty="relationId" useGeneratedKeys="true">
insert into tab_haoban_hm_clerk_relation(hm_id, wx_user_id, wx_enterprise_id, enterprise_id, store_id, insert into tab_haoban_hm_clerk_relation(hm_id, wx_user_id, wx_enterprise_id, enterprise_id, store_id,
store_name, store_code, clerk_id, clerk_name, clerk_code, status, store_name, store_code, clerk_id, clerk_name, clerk_code, status,
create_time, update_time, over_flag) create_time, update_time, over_flag, add_num)
values (#{hmId}, #{wxUserId}, #{wxEnterpriseId}, #{enterpriseId}, #{storeId}, #{storeName}, #{storeCode}, values (#{hmId}, #{wxUserId}, #{wxEnterpriseId}, #{enterpriseId}, #{storeId}, #{storeName}, #{storeCode},
#{clerkId}, #{clerkName}, #{clerkCode}, #{status}, #{createTime}, #{updateTime}, #{overFlag}) #{clerkId}, #{clerkName}, #{clerkCode}, #{status}, #{createTime}, #{updateTime}, #{overFlag}, #{addNum})
</insert> </insert>
<insert id="insertBatch" keyProperty="relationId" useGeneratedKeys="true"> <insert id="insertBatch" keyProperty="relationId" useGeneratedKeys="true">
insert into tab_haoban_hm_clerk_relation(hm_id, wx_user_id, wx_enterprise_id, enterprise_id, store_id, insert into tab_haoban_hm_clerk_relation(hm_id, wx_user_id, wx_enterprise_id, enterprise_id, store_id,
store_name, store_code, clerk_id, clerk_name, clerk_code, status, create_time, update_time, over_flag) store_name, store_code, clerk_id, clerk_name, clerk_code, status, create_time, update_time, over_flag,add_num)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.hmId}, #{entity.wxUserId}, #{entity.wxEnterpriseId}, #{entity.enterpriseId}, #{entity.storeId},
#{entity.storeName}, #{entity.storeCode}, #{entity.clerkId}, #{entity.clerkName}, #{entity.clerkCode},
#{entity.status}, #{entity.createTime}, #{entity.updateTime}, #{entity.overFlag})
</foreach>
</insert>
<insert id="insertOrUpdateBatch" keyProperty="relationId" useGeneratedKeys="true">
insert into tab_haoban_hm_clerk_relation(hm_id, wx_user_id, wx_enterprise_id, enterprise_id, store_id,
store_name, store_code, clerk_id, clerk_name, clerk_code, status, create_time, update_time, over_flag)
values values
<foreach collection="entities" item="entity" separator=","> <foreach collection="entities" item="entity" separator=",">
(#{entity.hmId}, #{entity.wxUserId}, #{entity.wxEnterpriseId}, #{entity.enterpriseId}, #{entity.storeId}, (#{entity.hmId}, #{entity.wxUserId}, #{entity.wxEnterpriseId}, #{entity.enterpriseId}, #{entity.storeId},
#{entity.storeName}, #{entity.storeCode}, #{entity.clerkId}, #{entity.clerkName}, #{entity.clerkCode}, #{entity.storeName}, #{entity.storeCode}, #{entity.clerkId}, #{entity.clerkName}, #{entity.clerkCode},
#{entity.status}, #{entity.createTime}, #{entity.updateTime}, #{entity.overFlag}) #{entity.status}, #{entity.createTime}, #{entity.updateTime}, #{entity.overFlag},#{entity.addNum})
</foreach> </foreach>
on duplicate key update
hm_id = values(hm_id),
wx_user_id = values(wx_user_id),
wx_enterprise_id = values(wx_enterprise_id),
enterprise_id = values(enterprise_id),
store_id = values(store_id),
store_name = values(store_name),
store_code = values(store_code),
clerk_id = values(clerk_id),
clerk_name = values(clerk_name),
clerk_code = values(clerk_code),
status = values(status),
create_time = values(create_time),
update_time = values(update_time),
over_flag = values(over_flag)
</insert> </insert>
<!--通过主键修改数据--> <!--通过主键修改数据-->
...@@ -242,6 +94,9 @@ ...@@ -242,6 +94,9 @@
<if test="overFlag != null"> <if test="overFlag != null">
over_flag = #{overFlag}, over_flag = #{overFlag},
</if> </if>
<if test="addNum != null">
add_num = #{addNum},
</if>
</set> </set>
where relation_id = #{relationId} where relation_id = #{relationId}
</update> </update>
...@@ -256,5 +111,35 @@ ...@@ -256,5 +111,35 @@
where hm_id = #{hmId} where hm_id = #{hmId}
</update> </update>
<!--查询单个-->
<select id="queryByHmIdAndClerkId" resultMap="TabHaobanHmClerkRelationMap">
select *
from tab_haoban_hm_clerk_relation
where clerk_id = #{clerkId}
and hm_id = #{hmId}
limit 1
</select>
<update id="updateAddNumById">
update tab_haoban_hm_clerk_relation
<set>
add_num = add_num +1,
<if test="overFlag != null">
over_flag = #{overFlag},
</if>
update_time = now()
</set>
where relation_id = #{relationId}
</update>
<update id="resetAddNumAndOverFlag">
update tab_haoban_hm_clerk_relation
<set>
add_num = 0,over_flag = 0,update_time = now()
</set>
where status != 0
</update>
</mapper> </mapper>
...@@ -240,16 +240,38 @@ ...@@ -240,16 +240,38 @@
<select id="listByClerkId" resultMap="TabHaobanHmQrcodeMap"> <select id="listByClerkId" resultMap="TabHaobanHmQrcodeMap">
select * select *
from tab_haoban_hm_qrcode from tab_haoban_hm_qrcode
where enterprise_id = #{enterpriseId} and clerk_id = #{clerkId} and status_flag in (1,3) where enterprise_id = #{enterpriseId}
and clerk_id = #{clerkId}
and status_flag in (1, 3)
</select> </select>
<select id="listByStoreId" resultMap="TabHaobanHmQrcodeMap"> <select id="listByStoreId" resultMap="TabHaobanHmQrcodeMap">
select * select *
from tab_haoban_hm_qrcode from tab_haoban_hm_qrcode
where store_id = #{storeId} and status_flag in (1,3) where store_id = #{storeId} and status_flag in (1,3)
<if test="overFlag != null"> <if test="overFlag != null">
and over_flag = #{overFlag} and over_flag = #{overFlag}
</if> </if>
</select> </select>
<update id="updateAddNumById">
update tab_haoban_hm_qrcode
<set>
add_num = add_num +1,
<if test="overFlag != null">
over_flag = #{overFlag},
</if>
update_time = now()
</set>
where hm_id = #{hmId}
</update>
<update id="resetAddNumAndOverFlag">
update
<set>
add_num = 0,over_flag = 0,update_time = now()
</set>
where status_flag != 0
</update>
</mapper> </mapper>
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