Commit 375a592a by jinxin

Merge remote-tracking branch 'origin/feature/八月迭代'

parents c78f4949 a67953f7
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);
}
......@@ -42,4 +42,6 @@ public interface HaobanQywxFeeOrderService {
*/
List<TabHaobanQywxFeeOrder> listOrder(String wxEnterpriseId) ;
TabHaobanQywxFeeOrder selectByOrderId(String wxEnterpriseId,String orderId);
}
......@@ -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);
}
}
......@@ -55,4 +55,9 @@ public class HaobanQywxFeeOrderServiceImpl implements HaobanQywxFeeOrderService
public List<TabHaobanQywxFeeOrder> listOrder(String wxEnterpriseId) {
return this.tabHaobanQywxFeeOrderMapper.listOrder(wxEnterpriseId);
}
@Override
public TabHaobanQywxFeeOrder selectByOrderId(String wxEnterpriseId, String orderId) {
return this.tabHaobanQywxFeeOrderMapper.selectByOrderId(wxEnterpriseId, orderId);
}
}
......@@ -37,10 +37,14 @@ 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.TabHaobanQywxFeeOrder;
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.service.fee.HaobanQywxFeeOrderService;
import com.gic.haoban.manage.service.util.EmojiFilterUtil;
import com.gic.redis.data.util.RedisUtil;
import com.gic.thirdparty.cloudfile.CloudFileUtil;
......@@ -50,6 +54,8 @@ 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.fee.FeeOrderDeatilResponseDTO;
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 +127,10 @@ public class StaffApiServiceImpl implements StaffApiService {
private ExternalClerkRelatedService externalClerkRelatedService;
@Autowired
private WxEnterpriseActiveDataService wxEnterpriseActiveDataService;
@Autowired
private HaobanQywxFeeOrderAccountService haobanQywxFeeOrderAccountService;
@Autowired
private HaobanQywxFeeOrderService haobanQywxFeeOrderService;
@Override
public StaffDTO selectById(String staffId) {
......@@ -1183,6 +1193,7 @@ public class StaffApiServiceImpl implements StaffApiService {
return com.gic.api.base.commons.ServiceResponse.failure("-9999","成员userid不存在!");
}
String staffId = staff.getStaffId();
StaffActiveDataDTO activeDataDTO = wxEnterpriseActiveDataService.getWxEnterpriseActiveDataByWxEnterpriseId(wxEnterprise.getWxEnterpriseId());
if (null == activeDataDTO){
logger.info("查询不到企业微信id->{}的许可账号统计信息!",wxEnterprise.getWxEnterpriseId());
......@@ -1215,6 +1226,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 +1297,95 @@ 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++){
String activeCode = accounts.get(i).getActiveCode();
String orderId = accounts.get(i).getOrderId();
String staffId = haobanStaffs.get(i).getStaffId();
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();
}else {
//手动分配成功需要实时更新许可激活码状态
StaffActiveDataDTO activeDataDTO = wxEnterpriseActiveDataService.getWxEnterpriseActiveDataByWxEnterpriseId(wxEnterpriseId);
if (null == activeDataDTO){
logger.info("查询不到企业微信id->{}的许可账号统计信息!",wxEnterpriseId);
}else {
//需要区分激活码,待转移状态的激活码不需要处理
TabHaobanStaff haobanStaff = staffMapper.getNumByActiveCode(wxEnterpriseId, activeCode);
if (null == haobanStaff){
//已使用的加1,已激活的加1,未激活的减1
Integer used = activeDataDTO.getUsed();
Integer inactive = activeDataDTO.getInactive();
Integer activated = activeDataDTO.getActivated();
used++;
activated++;
if(null != inactive && inactive > 0){
inactive--;
}
activeDataDTO.setUsed(used);
activeDataDTO.setInactive(inactive);
activeDataDTO.setActivated(activated);
wxEnterpriseActiveDataService.updateByStaffActiveDataDTO(activeDataDTO);
}else {
//判断是否是其它占用的许可被当天激活
Date delTime = haobanStaff.getDelTime();
Date now = new Date();
int days = DateUtil.daysBetween(delTime, now);
if(days == 0){
staffMapper.updateOccupyFlagByStaffId(haobanStaff.getStaffId());
}
}
}
//根据订单id,查询订单详情,获取购买的时长,当前激活时间加上时长为过期时间
TabHaobanQywxFeeOrder tabHaobanQywxFeeOrder = haobanQywxFeeOrderService.selectByOrderId(wxEnterpriseId, orderId);
Integer months = tabHaobanQywxFeeOrder.getMonths();
Date expireTime = null;
if (null != months){
//转换成天数
months = months * 31;
expireTime = DateUtil.addDay(new Date(),months);
}
staffMapper.updateActiveStatusById(staffId,new Date(),expireTime,activeCode);
//更新好办激活码许可表
haobanQywxFeeOrderAccountService.updateByActiveCode(wxEnterpriseId,activeCode);
}
}
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>
......@@ -10,6 +10,7 @@ import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSONArray;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.dto.qdto.TransferActiveCodeQDTO;
import com.gic.haoban.manage.api.dto.qdto.licence.LicenceOrderPageQDTO;
import com.gic.haoban.manage.api.service.*;
import com.gic.haoban.manage.web.log.LogRecordUserServiceImpl;
import com.gic.haoban.manage.web.qo.StaffListQO;
......@@ -695,4 +696,22 @@ public class StaffController extends WebBaseController {
return RestResponse.successResult(vo);
}
/**
* 批量分配成员许可码
* @param staffIds
* @return
*/
@RequestMapping("staff-active-allocation")
public RestResponse<StaffActiveAllocationVO> staffActiveAllocation(String staffIds) {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
ServiceResponse<StaffActiveAllocationDTO> response = staffApiService.staffActiveAllocation(wxEnterpriseId, staffIds);
if(response.isSuccess()){
StaffActiveAllocationDTO dto = response.getResult();
StaffActiveAllocationVO result = JSONObject.parseObject(JSONObject.toJSONString(dto), StaffActiveAllocationVO.class);
return RestResponse.successResult(result);
}
return RestResponse.failure(response.getCode(),response.getMessage());
}
}
package com.gic.haoban.manage.web.vo;
import java.io.Serializable;
/**
* @description:
* @Author: wenhua
* @Date: 2023/8/16 10:08
*/
public class StaffActiveAllocationVO 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;
}
}
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