Commit 54a473df by 徐高华

激活码查询改成批量

parent 47392f2f
...@@ -99,16 +99,5 @@ public interface HaobanTimerApiService { ...@@ -99,16 +99,5 @@ public interface HaobanTimerApiService {
* @throws * @throws
*/ */
public ServiceResponse<Void> ownerDimission(String params); public ServiceResponse<Void> ownerDimission(String params);
/**
*
* @Title: activedAccountTimer
* @Description: 获取激活账号
* @author xgh331
* @param params
* @return
* @throws
*/
public ServiceResponse<Void> activedAccountTimer(String params);
} }
package com.gic.haoban.manage.service.service.impl; package com.gic.haoban.manage.service.service.impl;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -26,7 +25,6 @@ import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise; ...@@ -26,7 +25,6 @@ import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeAccountStaff; import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeAccountStaff;
import com.gic.haoban.manage.service.service.StaffService; import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeAccountStaffService; import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeAccountStaffService;
import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeOrderService;
import com.gic.wechat.api.dto.qywx.fee.AccountListDTO; import com.gic.wechat.api.dto.qywx.fee.AccountListDTO;
import com.gic.wechat.api.dto.qywx.fee.AccountListResponseDTO; import com.gic.wechat.api.dto.qywx.fee.AccountListResponseDTO;
import com.gic.wechat.api.dto.qywx.fee.ActiveInfoUserResponseDTO; import com.gic.wechat.api.dto.qywx.fee.ActiveInfoUserResponseDTO;
...@@ -54,8 +52,6 @@ public class StaffServiceImpl implements StaffService { ...@@ -54,8 +52,6 @@ public class StaffServiceImpl implements StaffService {
private HaobanQywxFeeAccountStaffService haobanQywxFeeAccountStaffService; private HaobanQywxFeeAccountStaffService haobanQywxFeeAccountStaffService;
@Autowired @Autowired
private QywxUserApiService qywxUserApiService ; private QywxUserApiService qywxUserApiService ;
@Autowired
private HaobanQywxFeeOrderService haobanQywxFeeOrderService ;
@Override @Override
public TabHaobanStaff selectById(String id) { public TabHaobanStaff selectById(String id) {
...@@ -194,28 +190,11 @@ public class StaffServiceImpl implements StaffService { ...@@ -194,28 +190,11 @@ public class StaffServiceImpl implements StaffService {
@Override @Override
public void activedAccountTimer(String wxEid) { public void activedAccountTimer(String wxEid) {
log.info("开始查询激活账号,wxEid={}", wxEid); log.info("开始查询激活账号,wxEid={}", wxEid);
List<TabHaobanWxEnterprise> list = new ArrayList<>() ; TabHaobanWxEnterprise wxEnterprise = this.wxEnterpriseMapper.selectByPrimaryKey(wxEid) ;
if("-1".equals(wxEid)) { if(wxEnterprise.getWxSecurityType()>0 && StringUtils.isNotEmpty(wxEnterprise.getOpenCorpid()) && wxEnterprise.getStatusFlag()==1) {
list = this.wxEnterpriseMapper.listAll() ; this.haobanQywxFeeAccountStaffService.deleteAll(wxEid) ;
}else { this.mapper.deleteActivieInfo(wxEid);
TabHaobanWxEnterprise en = this.wxEnterpriseMapper.selectByPrimaryKey(wxEid) ; this.listAccount(wxEnterprise, 500, null);
if(null != en) {
list.add(en) ;
}
}
if(CollectionUtils.isNotEmpty(list)) {
for(TabHaobanWxEnterprise item : list) {
if(item.getWxSecurityType()>0 && StringUtils.isNotEmpty(item.getOpenCorpid()) && item.getStatusFlag()==1) {
boolean hasFlag = this.haobanQywxFeeOrderService.hasOrder(item.getWxEnterpriseId()) ;
if(!hasFlag) {
log.info("无订单,跳过={}",item.getWxEnterpriseId());
continue ;
}
this.haobanQywxFeeAccountStaffService.deleteAll(item.getWxEnterpriseId()) ;
this.mapper.deleteActivieInfo(item.getWxEnterpriseId());
this.listAccount(item, 500, null);
}
}
} }
} }
......
...@@ -7,7 +7,6 @@ import com.gic.api.base.commons.ServiceResponse; ...@@ -7,7 +7,6 @@ import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.service.HaobanTimerApiService; import com.gic.haoban.manage.api.service.HaobanTimerApiService;
import com.gic.haoban.manage.service.service.ExternalClerkRelatedService; import com.gic.haoban.manage.service.service.ExternalClerkRelatedService;
import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService; import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.chat.GroupChatService; import com.gic.haoban.manage.service.service.chat.GroupChatService;
import com.gic.haoban.manage.service.service.hm.HmQrcodeTempService; import com.gic.haoban.manage.service.service.hm.HmQrcodeTempService;
...@@ -22,8 +21,6 @@ public class HaobanTimerApiServiceImpl implements HaobanTimerApiService { ...@@ -22,8 +21,6 @@ public class HaobanTimerApiServiceImpl implements HaobanTimerApiService {
private StaffDepartmentRelatedService staffDepartmentRelatedService; private StaffDepartmentRelatedService staffDepartmentRelatedService;
@Autowired @Autowired
private GroupChatService groupChatService; private GroupChatService groupChatService;
@Autowired
private StaffService staffService ;
@Override @Override
public ServiceResponse<Void> deleteTempWxHm(String params) { public ServiceResponse<Void> deleteTempWxHm(String params) {
...@@ -72,10 +69,4 @@ public class HaobanTimerApiServiceImpl implements HaobanTimerApiService { ...@@ -72,10 +69,4 @@ public class HaobanTimerApiServiceImpl implements HaobanTimerApiService {
this.groupChatService.ownerDimission(); this.groupChatService.ownerDimission();
return ServiceResponse.success(); return ServiceResponse.success();
} }
@Override
public ServiceResponse<Void> activedAccountTimer(String params) {
this.staffService.activedAccountTimer(params) ;
return ServiceResponse.success();
}
} }
...@@ -56,6 +56,7 @@ import com.gic.wechat.api.dto.qywx.fee.FeeOrderDeatilResponseDTO; ...@@ -56,6 +56,7 @@ import com.gic.wechat.api.dto.qywx.fee.FeeOrderDeatilResponseDTO;
import com.gic.wechat.api.dto.qywx.fee.FeeOrderResponseList; import com.gic.wechat.api.dto.qywx.fee.FeeOrderResponseList;
import com.gic.wechat.api.dto.qywx.fee.qdto.FeeOrderListQDTO; import com.gic.wechat.api.dto.qywx.fee.qdto.FeeOrderListQDTO;
import com.gic.wechat.api.service.qywx.QywxUserApiService; import com.gic.wechat.api.service.qywx.QywxUserApiService;
import com.google.common.collect.Lists;
import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
...@@ -212,10 +213,16 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService { ...@@ -212,10 +213,16 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
// 查询订单下的激活码code列表,记录到activeCodeList // 查询订单下的激活码code列表,记录到activeCodeList
for(TabHaobanQywxFeeOrder order : orderList) { for(TabHaobanQywxFeeOrder order : orderList) {
List<Map<String, String>> activeCodeList = new ArrayList<>(); List<Map<String, String>> activeCodeList = new ArrayList<>();
// 查询订单下的激活码code列表
this.getOrderAccount(order.getOrderId(), corpid, null, activeCodeList); this.getOrderAccount(order.getOrderId(), corpid, null, activeCodeList);
// 保存激活码列表
this.addOrderAccount(wxEnterpriseId, serviceCorpid, corpid, activeCodeList); this.addOrderAccount(wxEnterpriseId, serviceCorpid, corpid, activeCodeList);
} }
// 成员的激活码信息
this.staffService.activedAccountTimer(wxEnterpriseId);
// 更新企业的激活数量统计
this.wxEnterpriseActiveDataService.saveOrUpdate(wxEnterpriseId) ; this.wxEnterpriseActiveDataService.saveOrUpdate(wxEnterpriseId) ;
//统计 haobanQywxFeeDetailDTO 30天内最新过期的时间和人数 //统计 haobanQywxFeeDetailDTO 30天内最新过期的时间和人数
...@@ -271,27 +278,40 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService { ...@@ -271,27 +278,40 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
logger.error("订单账号无激活码"); logger.error("订单账号无激活码");
return; return;
} }
List<String> codeList = new ArrayList<>();
Map<String,String> keyMap = new HashMap<>();
for (Map<String, String> activeCodeMap : activeCodeList) { for (Map<String, String> activeCodeMap : activeCodeList) {
String activeCode = activeCodeMap.get("activeCode"); String activeCode = activeCodeMap.get("activeCode");
String orderId = activeCodeMap.get("orderId"); String orderId = activeCodeMap.get("orderId");
TabHaobanQywxFeeOrderAccount activeAccount = new TabHaobanQywxFeeOrderAccount(); codeList.add(activeCode) ;
// 查询激活码的详情 keyMap.put(activeCode,orderId) ;
ActiveInfoCodeResponseDTO activeDetail = qywxUserApiService.getActiveInfoByCode(corpid, serviceCorpid, activeCode); }
if (activeDetail.getErrcode() == 0) {
String userid = activeDetail.getUserid(); TabHaobanQywxFeeOrderAccount activeAccount = new TabHaobanQywxFeeOrderAccount();
activeAccount.setWxUserId(userid); // 查询激活码的详情
activeAccount.setStatus(activeDetail.getStatus()); List<ActiveInfoCodeResponseDTO> respList = qywxUserApiService.getActiveInfoByCodeList(corpid, serviceCorpid, codeList);
if(null != activeDetail.getExpireTime()) { if(CollectionUtils.isNotEmpty(respList)) {
activeAccount.setExpireTime(DateUtil.date(activeDetail.getExpireTime() * 1000)); List<List<ActiveInfoCodeResponseDTO>> list = Lists.partition(respList, 800) ;
activeAccount.setActiveTime(DateUtil.date(activeDetail.getActiveTime() * 1000)); for(int i=0;i<list.size();i++) {
List<ActiveInfoCodeResponseDTO> subList = list.get(i);
for(ActiveInfoCodeResponseDTO activeDetail : subList) {
String userid = activeDetail.getUserid();
String activeCode = activeDetail.getActiveCode() ;
activeAccount.setWxUserId(userid);
activeAccount.setStatus(activeDetail.getStatus());
if(null != activeDetail.getExpireTime()) {
activeAccount.setExpireTime(DateUtil.date(activeDetail.getExpireTime() * 1000));
activeAccount.setActiveTime(DateUtil.date(activeDetail.getActiveTime() * 1000));
}
activeAccount.setAccountType(2);
activeAccount.setOrderId(keyMap.get(activeCode));
activeAccount.setActiveCode(activeCode);
activeAccount.setCorpId(corpid);
activeAccount.setWxEnterpriseId(wxEnterpriseId);
haobanQywxFeeOrderAccountService.save(activeAccount);
} }
} }
activeAccount.setAccountType(2);
activeAccount.setOrderId(orderId);
activeAccount.setActiveCode(activeCode);
activeAccount.setCorpId(corpid);
activeAccount.setWxEnterpriseId(wxEnterpriseId);
haobanQywxFeeOrderAccountService.save(activeAccount);
} }
} }
...@@ -328,30 +348,4 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService { ...@@ -328,30 +348,4 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
public HaobanQywxFeeDTO queryByWxEnterpriseId(String wxEnterpriseId) { public HaobanQywxFeeDTO queryByWxEnterpriseId(String wxEnterpriseId) {
return EntityUtil.changeEntityNew(HaobanQywxFeeDTO.class, haobanQywxFeeService.queryByWxEnterpriseId(wxEnterpriseId)); return EntityUtil.changeEntityNew(HaobanQywxFeeDTO.class, haobanQywxFeeService.queryByWxEnterpriseId(wxEnterpriseId));
} }
/**
* 告警
*/
private void messageAlert(String wxEnterpriseId, String corpName, String corpid, String titleSub, String content) {
ProviderLocalTag providerLocalTag = ProviderLocalTag.tag.get();
String traceId = providerLocalTag.traceId;
AlertMessageDTO messageDTO = new AlertMessageDTO();
messageDTO.setAlertTitle(titleSub);
messageDTO.setAlertType(AlertTypeEnum.FEE_ALARM.getType());
messageDTO.setWxEnterpriseId(wxEnterpriseId);
Map<String, Object> map = new HashMap<>();
map.put("企业名称", corpName);
map.put("企业id", corpid);
map.put("内容", content);
messageDTO.setContentMap(map);
messageDTO.setTraceId(traceId);
GicMQClient clientInstance = GICMQClientUtil.getClientInstance();
try {
clientInstance.sendMessage("haobanAlertMq", JSONObject.toJSONString(messageDTO), 6 * 3600);
} catch (Exception e) {
logger.info("异常:{}", e.getMessage(), e);
}
}
} }
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