Commit d6dae55e by 徐高华

企微激活账号

parent ad3cdd57
package com.gic.haoban.manage.service.dao.mapper.fee;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeOrder;
......@@ -48,5 +50,8 @@ public interface TabHaobanQywxFeeOrderMapper {
* @date 2022-08-12 10:42:36
*/
int hasOrder(@Param("wxEnterpriseId") String wxEnterpriseId);
List<TabHaobanQywxFeeOrder> listOrder(@Param("wxEnterpriseId") String wxEnterpriseId);
}
package com.gic.haoban.manage.service.service.fee;
import java.util.List;
import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeOrder;
/**
......@@ -38,6 +40,16 @@ public interface HaobanQywxFeeOrderService {
* @date 2022-08-12 10:43:21
*/
boolean hasOrder(String wxEnterpriseId);
/**
*
* @Title: listOrder
* @Description: 查询订单
* @author xugh
* @param wxEnterpriseId
* @return
* @throws
*/
List<TabHaobanQywxFeeOrder> listOrder(String wxEnterpriseId) ;
}
package com.gic.haoban.manage.service.service.fee.impl;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -54,4 +56,9 @@ public class HaobanQywxFeeOrderServiceImpl implements HaobanQywxFeeOrderService
int count = tabHaobanQywxFeeOrderMapper.hasOrder(wxEnterpriseId);
return count > 0;
}
@Override
public List<TabHaobanQywxFeeOrder> listOrder(String wxEnterpriseId) {
return this.tabHaobanQywxFeeOrderMapper.listOrder(wxEnterpriseId);
}
}
......@@ -26,6 +26,7 @@ import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeAccountStaff;
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.HaobanQywxFeeOrderService;
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.ActiveInfoUserResponseDTO;
......@@ -53,6 +54,8 @@ public class StaffServiceImpl implements StaffService {
private HaobanQywxFeeAccountStaffService haobanQywxFeeAccountStaffService;
@Autowired
private QywxUserApiService qywxUserApiService ;
@Autowired
private HaobanQywxFeeOrderService haobanQywxFeeOrderService ;
@Override
public TabHaobanStaff selectById(String id) {
......@@ -202,6 +205,11 @@ public class StaffServiceImpl implements StaffService {
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);
......
......@@ -118,6 +118,7 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
// 查询订单下的激活码code列表
private void getOrderAccount(String orderId , String corpid , String cursor , List<Map<String, String>> activeCodeList) {
logger.info("处理订单激活码,orderid={}",orderId);
FeeOrderListQDTO feeOrderListQDTO = new FeeOrderListQDTO();
feeOrderListQDTO.setOrderId(orderId);
feeOrderListQDTO.setCursor(cursor);
......@@ -169,8 +170,8 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
this.wxEnterpriseService.updateAutoActiveFlagById(1, wxEnterpriseId);
}
List<Map<String, String>> activeCodeList = new ArrayList<>();
List<String> orderIds = this.listOrderId(corpid) ;
for (String orderId : orderIds) {
List<String> orderIdList = this.listOrderId(corpid) ;
for (String orderId : orderIdList) {
FeeOrderDeatilResponseDTO order = qywxUserApiService.getOrder(corpid, serviceCorpid, orderId);
if (order.getErrcode() != 0) {
logger.error("请求企微失败:{}", orderId);
......@@ -198,8 +199,17 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
tabHaobanQywxFeeOrder.setPayTime(DateUtil.date(orderDTO.getPayTime() * 1000));
// 增加到订单表,如果存在不更新
this.haobanQywxFeeOrderService.insert(tabHaobanQywxFeeOrder);
// 查询订单下的激活码code列表,记录到activeCodeList
this.getOrderAccount(orderId, corpid, null, activeCodeList);
}
// 更新订单的激活码状态
List<TabHaobanQywxFeeOrder> orderList = this.haobanQywxFeeOrderService.listOrder(wxEnterpriseId) ;
if(CollectionUtils.isEmpty(orderList)) {
logger.error("无企微订单:{}", wxEnterpriseId);
return ;
}
// 查询订单下的激活码code列表,记录到activeCodeList
for(TabHaobanQywxFeeOrder order : orderList) {
this.getOrderAccount(order.getOrderId(), corpid, null, activeCodeList);
}
//处理订单下激活账号
......@@ -227,8 +237,8 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
haobanQywxFeeService.insert(tabHaobanQywxFee);
//判断今天是否是本月最后一天
if (DateUtil.isSameDay(DateUtil.endOfMonth(new Date()), new Date())) {
int monthWillInterceptNum = haobanQywxFeeAccountStaffService.monthWillInterceptNum(wxEnterpriseId);
String content = "30天将有" + monthWillInterceptNum + "个接口许可证即将过期,您总共还剩余" + permissionUserNum + "个可用的接口许可证,请保证数量充足,如需增加请及时联系相关人员续费,避免影响使用";
// int monthWillInterceptNum = haobanQywxFeeAccountStaffService.monthWillInterceptNum(wxEnterpriseId);
// String content = "30天将有" + monthWillInterceptNum + "个接口许可证即将过期,您总共还剩余" + permissionUserNum + "个可用的接口许可证,请保证数量充足,如需增加请及时联系相关人员续费,避免影响使用";
//告警
// messageAlert(wxEnterpriseId, corpName, corpid, AlertTypeEnum.FEE_ALARM.getName(), content);
}
......@@ -319,8 +329,6 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
/**
* 告警
*
* @param wxEnterpriseId
*/
private void messageAlert(String wxEnterpriseId, String corpName, String corpid, String titleSub, String content) {
ProviderLocalTag providerLocalTag = ProviderLocalTag.tag.get();
......
......@@ -50,6 +50,13 @@
from tab_haoban_qywx_fee_order
where wx_enterprise_id = #{wxEnterpriseId}
</select>
<select id="listOrder" resultMap="TabHaobanQywxFeeOrderMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_qywx_fee_order
where wx_enterprise_id = #{wxEnterpriseId}
</select>
</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