Commit a67953f7 by jinxin

批量分配成员许可码

parent f0d50744
...@@ -42,4 +42,6 @@ public interface HaobanQywxFeeOrderService { ...@@ -42,4 +42,6 @@ public interface HaobanQywxFeeOrderService {
*/ */
List<TabHaobanQywxFeeOrder> listOrder(String wxEnterpriseId) ; List<TabHaobanQywxFeeOrder> listOrder(String wxEnterpriseId) ;
TabHaobanQywxFeeOrder selectByOrderId(String wxEnterpriseId,String orderId);
} }
...@@ -55,4 +55,9 @@ public class HaobanQywxFeeOrderServiceImpl implements HaobanQywxFeeOrderService ...@@ -55,4 +55,9 @@ public class HaobanQywxFeeOrderServiceImpl implements HaobanQywxFeeOrderService
public List<TabHaobanQywxFeeOrder> listOrder(String wxEnterpriseId) { public List<TabHaobanQywxFeeOrder> listOrder(String wxEnterpriseId) {
return this.tabHaobanQywxFeeOrderMapper.listOrder(wxEnterpriseId); return this.tabHaobanQywxFeeOrderMapper.listOrder(wxEnterpriseId);
} }
@Override
public TabHaobanQywxFeeOrder selectByOrderId(String wxEnterpriseId, String orderId) {
return this.tabHaobanQywxFeeOrderMapper.selectByOrderId(wxEnterpriseId, orderId);
}
} }
...@@ -37,12 +37,14 @@ import com.gic.haoban.manage.service.config.Config; ...@@ -37,12 +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.StaffDepartmentRelatedMapper;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper; import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.entity.*; 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.entity.fee.TabHaobanQywxFeeOrderAccount;
import com.gic.haoban.manage.service.errorcode.QywxErrCode; import com.gic.haoban.manage.service.errorcode.QywxErrCode;
import com.gic.haoban.manage.service.pojo.bo.StaffListBO; import com.gic.haoban.manage.service.pojo.bo.StaffListBO;
import com.gic.haoban.manage.service.service.*; import com.gic.haoban.manage.service.service.*;
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.fee.HaobanQywxFeeOrderAccountService; 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.haoban.manage.service.util.EmojiFilterUtil;
import com.gic.redis.data.util.RedisUtil; import com.gic.redis.data.util.RedisUtil;
import com.gic.thirdparty.cloudfile.CloudFileUtil; import com.gic.thirdparty.cloudfile.CloudFileUtil;
...@@ -52,6 +54,7 @@ import com.gic.thirdparty.cloudfile.pojo.CloudFileInfo; ...@@ -52,6 +54,7 @@ import com.gic.thirdparty.cloudfile.pojo.CloudFileInfo;
import com.gic.wechat.api.dto.qywx.QywxNewUseridDTO; import com.gic.wechat.api.dto.qywx.QywxNewUseridDTO;
import com.gic.wechat.api.dto.qywx.UserDTO; 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.AccountTransferUserDTO;
import com.gic.wechat.api.dto.qywx.fee.FeeOrderDeatilResponseDTO;
import com.gic.wechat.api.dto.qywx.response.QywxResponseDTO; import com.gic.wechat.api.dto.qywx.response.QywxResponseDTO;
import com.gic.wechat.api.service.qywx.QywxOrderApiService; import com.gic.wechat.api.service.qywx.QywxOrderApiService;
import com.gic.wechat.api.service.qywx.QywxUserApiService; import com.gic.wechat.api.service.qywx.QywxUserApiService;
...@@ -126,6 +129,8 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -126,6 +129,8 @@ public class StaffApiServiceImpl implements StaffApiService {
private WxEnterpriseActiveDataService wxEnterpriseActiveDataService; private WxEnterpriseActiveDataService wxEnterpriseActiveDataService;
@Autowired @Autowired
private HaobanQywxFeeOrderAccountService haobanQywxFeeOrderAccountService; private HaobanQywxFeeOrderAccountService haobanQywxFeeOrderAccountService;
@Autowired
private HaobanQywxFeeOrderService haobanQywxFeeOrderService;
@Override @Override
public StaffDTO selectById(String staffId) { public StaffDTO selectById(String staffId) {
...@@ -1188,6 +1193,7 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -1188,6 +1193,7 @@ public class StaffApiServiceImpl implements StaffApiService {
return com.gic.api.base.commons.ServiceResponse.failure("-9999","成员userid不存在!"); return com.gic.api.base.commons.ServiceResponse.failure("-9999","成员userid不存在!");
} }
String staffId = staff.getStaffId(); String staffId = staff.getStaffId();
StaffActiveDataDTO activeDataDTO = wxEnterpriseActiveDataService.getWxEnterpriseActiveDataByWxEnterpriseId(wxEnterprise.getWxEnterpriseId()); StaffActiveDataDTO activeDataDTO = wxEnterpriseActiveDataService.getWxEnterpriseActiveDataByWxEnterpriseId(wxEnterprise.getWxEnterpriseId());
if (null == activeDataDTO){ if (null == activeDataDTO){
logger.info("查询不到企业微信id->{}的许可账号统计信息!",wxEnterprise.getWxEnterpriseId()); logger.info("查询不到企业微信id->{}的许可账号统计信息!",wxEnterprise.getWxEnterpriseId());
...@@ -1315,6 +1321,9 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -1315,6 +1321,9 @@ public class StaffApiServiceImpl implements StaffApiService {
int num = 0; int num = 0;
String errMessage = null; String errMessage = null;
for (int i = 0;i<haobanStaffs.size();i++){ 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(); JSONObject object = new JSONObject();
object.put("active_code",accounts.get(i).getActiveCode()); object.put("active_code",accounts.get(i).getActiveCode());
object.put("corpid",openCorpid); object.put("corpid",openCorpid);
...@@ -1327,6 +1336,50 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -1327,6 +1336,50 @@ public class StaffApiServiceImpl implements StaffApiService {
if(!response.isSuccess()){ if(!response.isSuccess()){
num++; num++;
errMessage = "许可账号分配失败,复制链接查看失败原因:https://developer.work.weixin.qq.com/devtool/query?e="+response.getCode(); 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.setNums(num);
......
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