Commit a7f06c4c by jinxin

分配许可账号

parent b94f74b1
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
/**
* @description:
* @Author: wenhua
* @Date: 2023/8/16 10:08
*/
public class StaffActiveAllocationDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 失败个数
*/
private Integer nums;
/**
* 失败原因
*/
private String errMessage;
public Integer getNums() {
return nums;
}
public void setNums(Integer nums) {
this.nums = nums;
}
public String getErrMessage() {
return errMessage;
}
public void setErrMessage(String errMessage) {
this.errMessage = errMessage;
}
}
......@@ -356,4 +356,6 @@ public interface StaffApiService {
*/
com.gic.api.base.commons.ServiceResponse<Boolean> syncQywxStaffList(String params) ;
com.gic.api.base.commons.ServiceResponse<StaffActiveAllocationDTO> staffActiveAllocation(String wxEnterpriseId,String staffIds);
}
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.TabHaobanQywxFeeOrderAccount;
import org.apache.ibatis.annotations.Param;
import java.util.HashMap;
import java.util.List;
......@@ -53,5 +50,9 @@ public interface TabHaobanQywxFeeOrderAccountMapper {
int countOrderAccountStatus(@Param("status") Integer status,@Param("wxEnterpriseId") String wxEnterpriseId);
List<HashMap<String,Integer>> countStatusByWxEnterpriseId(@Param("wxEnterpriseId") String wxEnterpriseId);
List<TabHaobanQywxFeeOrderAccount> selectByWxEnterpriseId( @Param("wxEnterpriseId")String wxEnterpriseId);
void updateByActiveCode(@Param("wxEnterpriseId")String wxEnterpriseId , @Param("activeCode")String activeCode);
}
package com.gic.haoban.manage.service.service.fee;
import java.util.List;
import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeOrderAccount;
import java.util.List;
/**
* 企业微信收费订单账号(激活码)(TabHaobanQywxFeeOrderAccount)表服务接口
*
......@@ -31,4 +31,8 @@ public interface HaobanQywxFeeOrderAccountService {
*/
int countOrderAccountStatus(Integer status,String wxEnterpriseId);
List<TabHaobanQywxFeeOrderAccount> selectByWxEnterpriseId(String wxEnterpriseId);
void updateByActiveCode(String wxEnterpriseId ,String activeCode);
}
......@@ -4,12 +4,11 @@ import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.manage.service.dao.mapper.fee.TabHaobanQywxFeeOrderAccountMapper;
import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeOrderAccount;
import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeOrderAccountService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 企业微信收费订单账号(激活码)(TabHaobanQywxFeeOrderAccount)表服务实现类
*
......@@ -48,4 +47,14 @@ public class HaobanQywxFeeOrderAccountServiceImpl implements HaobanQywxFeeOrderA
return tabHaobanQywxFeeOrderAccountMapper.countOrderAccountStatus(status,wxEnterpriseId);
}
@Override
public List<TabHaobanQywxFeeOrderAccount> selectByWxEnterpriseId(String wxEnterpriseId) {
return tabHaobanQywxFeeOrderAccountMapper.selectByWxEnterpriseId(wxEnterpriseId);
}
@Override
public void updateByActiveCode(String wxEnterpriseId, String activeCode) {
tabHaobanQywxFeeOrderAccountMapper.updateByActiveCode(wxEnterpriseId,activeCode);
}
}
......@@ -37,10 +37,12 @@ import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.StaffDepartmentRelatedMapper;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.entity.*;
import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeOrderAccount;
import com.gic.haoban.manage.service.errorcode.QywxErrCode;
import com.gic.haoban.manage.service.pojo.bo.StaffListBO;
import com.gic.haoban.manage.service.service.*;
import com.gic.haoban.manage.service.service.chat.GroupChatService;
import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeOrderAccountService;
import com.gic.haoban.manage.service.util.EmojiFilterUtil;
import com.gic.redis.data.util.RedisUtil;
import com.gic.thirdparty.cloudfile.CloudFileUtil;
......@@ -50,6 +52,7 @@ import com.gic.thirdparty.cloudfile.pojo.CloudFileInfo;
import com.gic.wechat.api.dto.qywx.QywxNewUseridDTO;
import com.gic.wechat.api.dto.qywx.UserDTO;
import com.gic.wechat.api.dto.qywx.fee.AccountTransferUserDTO;
import com.gic.wechat.api.dto.qywx.response.QywxResponseDTO;
import com.gic.wechat.api.service.qywx.QywxOrderApiService;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import com.github.pagehelper.PageHelper;
......@@ -121,6 +124,8 @@ public class StaffApiServiceImpl implements StaffApiService {
private ExternalClerkRelatedService externalClerkRelatedService;
@Autowired
private WxEnterpriseActiveDataService wxEnterpriseActiveDataService;
@Autowired
private HaobanQywxFeeOrderAccountService haobanQywxFeeOrderAccountService;
@Override
public StaffDTO selectById(String staffId) {
......@@ -1215,6 +1220,9 @@ public class StaffApiServiceImpl implements StaffApiService {
}
staffMapper.updateActiveStatusById(staffId,timeStampDate,expireTimeDate,activeCode);
groupChatService.initStaffGroupChat(staffId);
//更新好办激活码许可表
haobanQywxFeeOrderAccountService.updateByActiveCode(wxEnterprise.getWxEnterpriseId(),activeCode);
}
return com.gic.api.base.commons.ServiceResponse.success(true);
}
......@@ -1283,4 +1291,48 @@ public class StaffApiServiceImpl implements StaffApiService {
}
return null;
}
@Override
public com.gic.api.base.commons.ServiceResponse<StaffActiveAllocationDTO> staffActiveAllocation(String wxEnterpriseId, String staffIds) {
StaffActiveAllocationDTO result = new StaffActiveAllocationDTO();
if (StrUtil.isBlank(staffIds)){
return com.gic.api.base.commons.ServiceResponse.failure("-9999","参数不能为空");
}
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
if (wxEnterpriseDTO == null) {
return com.gic.api.base.commons.ServiceResponse.failure("-9999", "企业微信不存在!!");
}
String openCorpid = wxEnterpriseDTO.getOpenCorpid();
String serviceCorpid = config.getCorpid();
List<String> staffIdList = Arrays.asList(staffIds.split(","));
List<TabHaobanStaff> haobanStaffs = staffMapper.listByIds(staffIdList);
List<TabHaobanQywxFeeOrderAccount> accounts = haobanQywxFeeOrderAccountService.selectByWxEnterpriseId(wxEnterpriseId);
if ( CollUtil.isEmpty(accounts) || accounts.size() < haobanStaffs.size()){
return com.gic.api.base.commons.ServiceResponse.failure("-9999", "剩余可用许可数量小于激活成员数量");
}
if (CollUtil.isNotEmpty(haobanStaffs)){
int num = 0;
String errMessage = null;
for (int i = 0;i<haobanStaffs.size();i++){
JSONObject object = new JSONObject();
object.put("active_code",accounts.get(i).getActiveCode());
object.put("corpid",openCorpid);
String wxUserId = haobanStaffs.get(i).getWxUserId();
if (StrUtil.isBlank(wxUserId)){
wxUserId = haobanStaffs.get(i).getWxOpenUseId();
}
object.put("userid",wxUserId);
com.gic.api.base.commons.ServiceResponse<QywxResponseDTO> response = qywxOrderApiService.activeAccount(serviceCorpid, JSON.toJSONString(object));
if(!response.isSuccess()){
num++;
errMessage = "许可账号分配失败,复制链接查看失败原因:https://developer.work.weixin.qq.com/devtool/query?e="+response.getCode();
}
}
result.setNums(num);
result.setErrMessage(errMessage);
return com.gic.api.base.commons.ServiceResponse.success(result);
}
return com.gic.api.base.commons.ServiceResponse.failure("-9999","成员不存在");
}
}
......@@ -87,5 +87,19 @@
where wx_enterprise_id = #{wxEnterpriseId} GROUP BY STATUS
</select>
<select id="selectByWxEnterpriseId" resultMap="TabHaobanQywxFeeOrderAccountMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_qywx_fee_order_account
where wx_enterprise_id = #{wxEnterpriseId}
and status in (1,4)
</select>
<update id="updateByActiveCode">
update tab_haoban_qywx_fee_order_account
set status = 2,update_time = NOW()
where wx_enterprise_id = #{wxEnterpriseId} and active_code = #{activeCode}
</update>
</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