Commit 4d1e57be by 徐高华

Merge remote-tracking branch 'origin/feature/获取用户敏感信息' into developer

Conflicts:
	haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/dao/mapper/fee/TabHaobanQywxFeeAccountInterceptLogMapper.java
	haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/dao/mapper/fee/TabHaobanQywxFeeAccountStaffMapper.java
	haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/fee/HaobanQywxFeeAccountStaffService.java
	haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/fee/impl/HaobanQywxFeeAccountStaffServiceImpl.java
	haoban-manage3-service/src/main/resources/mapper/fee/TabHaobanQywxFeeAccountStaffMapper.xml
parents a595dfee f26d0c94
package com.gic.haoban.manage.service.dao.mapper.fee; package com.gic.haoban.manage.service.dao.mapper.fee;
import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeAccountInterceptLog; import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeAccountInterceptLog;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.util.List; import java.util.List;
/** /**
* 企业微信账号拦截日志(TabHaobanQywxFeeAccountInterceptLog)表数据库访问层 * 企业微信账号拦截日志(TabHaobanQywxFeeAccountInterceptLog)表数据库访问层
* *
* @author mozhu * @author mozhu
* @since 2022-08-10 10:27:45 * @since 2022-08-10 10:27:45
*/ */
public interface TabHaobanQywxFeeAccountInterceptLogMapper { public interface TabHaobanQywxFeeAccountInterceptLogMapper {
/** /**
* 通过ID查询单条数据 * 通过ID查询单条数据
* *
* @param feeAccountInterceptId 主键 * @param feeAccountInterceptId 主键
* @return 实例对象 * @return 实例对象
*/ */
TabHaobanQywxFeeAccountInterceptLog queryById(Long feeAccountInterceptId); TabHaobanQywxFeeAccountInterceptLog queryById(Long feeAccountInterceptId);
/** /**
* 查询指定行数据 * 查询指定行数据
* *
* @param tabHaobanQywxFeeAccountInterceptLog 查询条件 * @param tabHaobanQywxFeeAccountInterceptLog 查询条件
* @param pageable 分页对象 * @param pageable 分页对象
* @return 对象列表 * @return 对象列表
*/ */
List<TabHaobanQywxFeeAccountInterceptLog> queryAllByLimit(TabHaobanQywxFeeAccountInterceptLog tabHaobanQywxFeeAccountInterceptLog, @Param("pageable") Pageable pageable); List<TabHaobanQywxFeeAccountInterceptLog> queryAllByLimit(TabHaobanQywxFeeAccountInterceptLog tabHaobanQywxFeeAccountInterceptLog, @Param("pageable") Pageable pageable);
/** /**
* 新增数据 * 新增数据
* *
* @param tabHaobanQywxFeeAccountInterceptLog 实例对象 * @param tabHaobanQywxFeeAccountInterceptLog 实例对象
* @return 影响行数 * @return 影响行数
*/ */
int insert(TabHaobanQywxFeeAccountInterceptLog tabHaobanQywxFeeAccountInterceptLog); int insert(TabHaobanQywxFeeAccountInterceptLog tabHaobanQywxFeeAccountInterceptLog);
/** /**
* 批量新增数据(MyBatis原生foreach方法) * 批量新增数据(MyBatis原生foreach方法)
* *
* @param entities List<TabHaobanQywxFeeAccountInterceptLog> 实例对象列表 * @param entities List<TabHaobanQywxFeeAccountInterceptLog> 实例对象列表
* @return 影响行数 * @return 影响行数
*/ */
int insertBatch(@Param("entities") List<TabHaobanQywxFeeAccountInterceptLog> entities); int insertBatch(@Param("entities") List<TabHaobanQywxFeeAccountInterceptLog> entities);
/** /**
* 修改数据 * 修改数据
* *
* @param tabHaobanQywxFeeAccountInterceptLog 实例对象 * @param tabHaobanQywxFeeAccountInterceptLog 实例对象
* @return 影响行数 * @return 影响行数
*/ */
int update(TabHaobanQywxFeeAccountInterceptLog tabHaobanQywxFeeAccountInterceptLog); int update(TabHaobanQywxFeeAccountInterceptLog tabHaobanQywxFeeAccountInterceptLog);
/** /**
* 通过主键删除数据 * 查询天气企业服务id
* *
* @param feeAccountInterceptId 主键 * @param wxEnterpriseId wx企业标识
* @return 影响行数 * @return {@link List }<{@link TabHaobanQywxFeeAccountInterceptLog }>
*/ * @author mozhu
int deleteById(Long feeAccountInterceptId); * @date 2022-08-10 14:55:59
*/
/** List<TabHaobanQywxFeeAccountInterceptLog> queryByWxEnterpriseId(@Param("wxEnterpriseId") String wxEnterpriseId);
* 查询天气企业服务id }
*
* @param wxEnterpriseId wx企业标识
* @return {@link List }<{@link TabHaobanQywxFeeAccountInterceptLog }>
* @author mozhu
* @date 2022-08-10 14:55:59
*/
List<TabHaobanQywxFeeAccountInterceptLog> queryByWxEnterpriseId(@Param("wxEnterpriseId") String wxEnterpriseId);
}
package com.gic.haoban.manage.service.dao.mapper.fee; package com.gic.haoban.manage.service.dao.mapper.fee;
import com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeDetailDTO; import com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeDetailDTO;
import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeAccountStaff; import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeAccountStaff;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
/** /**
* 企业微信收费订单成员激活详情(TabHaobanQywxFeeAccountStaff)表数据库访问层 * 企业微信收费订单成员激活详情(TabHaobanQywxFeeAccountStaff)表数据库访问层
* *
* @author mozhu * @author mozhu
* @since 2022-08-03 16:12:31 * @since 2022-08-03 16:12:31
*/ */
public interface TabHaobanQywxFeeAccountStaffMapper { public interface TabHaobanQywxFeeAccountStaffMapper {
/** /**
* 通过ID查询单条数据 * 通过ID查询单条数据
* *
* @param feeAccountId 主键 * @param feeAccountId 主键
* @return 实例对象 * @return 实例对象
*/ */
TabHaobanQywxFeeAccountStaff queryById(Long feeAccountId); TabHaobanQywxFeeAccountStaff selectByActiveCode(@Param("wxEnterpriseId")String wxEnterpriseId , @Param("activeCode")String activeCode);
/** /**
* 新增数据 * 新增数据
* *
* @param tabHaobanQywxFeeAccountStaff 实例对象 * @param tabHaobanQywxFeeAccountStaff 实例对象
* @return 影响行数 * @return 影响行数
*/ */
int insert(TabHaobanQywxFeeAccountStaff tabHaobanQywxFeeAccountStaff); int insert(TabHaobanQywxFeeAccountStaff tabHaobanQywxFeeAccountStaff);
/** /**
* 批量新增数据(MyBatis原生foreach方法) * 修改数据
* *
* @param entities List<TabHaobanQywxFeeAccountStaff> 实例对象列表 * @param tabHaobanQywxFeeAccountStaff 实例对象
* @return 影响行数 * @return 影响行数
*/ */
int insertBatch(@Param("entities") List<TabHaobanQywxFeeAccountStaff> entities); int update(TabHaobanQywxFeeAccountStaff tabHaobanQywxFeeAccountStaff);
/** /**
* 修改数据 * 详情
* *
* @param tabHaobanQywxFeeAccountStaff 实例对象 * @param wxEnterpriseId wx企业标识
* @return 影响行数 * @return {@link List }<{@link HaobanQywxFeeDetailDTO }>
*/ * @author mozhu
int update(TabHaobanQywxFeeAccountStaff tabHaobanQywxFeeAccountStaff); * @date 2022-08-05 15:40:09
*/
/** List<HaobanQywxFeeDetailDTO> feeDetail(@Param("wxEnterpriseId") String wxEnterpriseId);
* 通过主键删除数据
*
* @param feeAccountId 主键 /**
* @return 影响行数 * 获取最新的过期时间
*/ * @param wxEnterpriseId
int deleteById(Long feeAccountId); * @return
*/
/** Date lastFeeInterceptTime(@Param("wxEnterpriseId") String wxEnterpriseId);
* 详情
* /**
* @param wxEnterpriseId wx企业标识 * 未来30天过期拦截数
* @return {@link List }<{@link HaobanQywxFeeDetailDTO }> *
* @author mozhu * @param wxEnterpriseId wx企业标识
* @date 2022-08-05 15:40:09 * @return int
*/ * @author mozhu
List<HaobanQywxFeeDetailDTO> feeDetail(@Param("wxEnterpriseId") String wxEnterpriseId); * @date 2022-08-08 15:53:32
*/
int lastFeeInterceptCount(@Param("wxEnterpriseId") String wxEnterpriseId);
/** }
* 获取最新的过期时间
* @param wxEnterpriseId
* @return
*/
Date lastFeeInterceptTime(@Param("wxEnterpriseId") String wxEnterpriseId);
/**
* 未来30天过期拦截数
*
* @param wxEnterpriseId wx企业标识
* @return int
* @author mozhu
* @date 2022-08-08 15:53:32
*/
int lastFeeInterceptCount(@Param("wxEnterpriseId") String wxEnterpriseId);
}
package com.gic.haoban.manage.service.service.fee; package com.gic.haoban.manage.service.service.fee;
import com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeDetailDTO; import com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeDetailDTO;
import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeAccountStaff; import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeAccountStaff;
import java.util.List; import java.util.List;
/** /**
* 企业微信收费订单成员激活详情(TabHaobanQywxFeeAccountStaff)表服务接口 * 企业微信收费订单成员激活详情(TabHaobanQywxFeeAccountStaff)表服务接口
* *
* @author mozhu * @author mozhu
* @since 2022-08-03 16:12:32 * @since 2022-08-03 16:12:32
*/ */
public interface HaobanQywxFeeAccountStaffService { public interface HaobanQywxFeeAccountStaffService {
/** /**
* 通过ID查询单条数据 * 新增数据
* *
* @param feeAccountId 主键 * @param tabHaobanQywxFeeAccountStaff 实例对象
* @return 实例对象 * @return 实例对象
*/ */
TabHaobanQywxFeeAccountStaff queryById(Long feeAccountId); TabHaobanQywxFeeAccountStaff save(TabHaobanQywxFeeAccountStaff tabHaobanQywxFeeAccountStaff);
/** /**
* 新增数据 * 详情
* *
* @param tabHaobanQywxFeeAccountStaff 实例对象 * @param wxEnterpriseId wx企业标识
* @return 实例对象 * @return {@link List }<{@link HaobanQywxFeeDetailDTO }>
*/ * @author mozhu
TabHaobanQywxFeeAccountStaff insert(TabHaobanQywxFeeAccountStaff tabHaobanQywxFeeAccountStaff); * @date 2022-08-05 15:39:37
*/
/** List<HaobanQywxFeeDetailDTO> feeDetail(String wxEnterpriseId);
* 修改数据
*
* @param tabHaobanQywxFeeAccountStaff 实例对象 /**
* @return 实例对象 * 费用详细拦截
*/ *
TabHaobanQywxFeeAccountStaff update(TabHaobanQywxFeeAccountStaff tabHaobanQywxFeeAccountStaff); * @param wxEnterpriseId wx企业标识
* @return {@link HaobanQywxFeeDetailDTO }
/** * @author mozhu
* 通过主键删除数据 * @date 2022-08-08 15:46:21
* */
* @param feeAccountId 主键 HaobanQywxFeeDetailDTO feeIntercept(String wxEnterpriseId);
* @return 是否成功
*/
boolean deleteById(Long feeAccountId); /**
* 未来30天将拦截数量
*
/** * @param wxEnterpriseId wx企业标识
* 详情 * @return int
* * @author mozhu
* @param wxEnterpriseId wx企业标识 * @date 2022-08-12 13:57:00
* @return {@link List }<{@link HaobanQywxFeeDetailDTO }> */
* @author mozhu int monthWillInterceptNum(String wxEnterpriseId);
* @date 2022-08-05 15:39:37
*/ }
List<HaobanQywxFeeDetailDTO> feeDetail(String wxEnterpriseId);
/**
* 费用详细拦截
*
* @param wxEnterpriseId wx企业标识
* @return {@link HaobanQywxFeeDetailDTO }
* @author mozhu
* @date 2022-08-08 15:46:21
*/
HaobanQywxFeeDetailDTO feeIntercept(String wxEnterpriseId);
/**
* 未来30天将拦截数量
*
* @param wxEnterpriseId wx企业标识
* @return int
* @author mozhu
* @date 2022-08-12 13:57:00
*/
int monthWillInterceptNum(String wxEnterpriseId);
}
package com.gic.haoban.manage.service.service.fee.impl; package com.gic.haoban.manage.service.service.fee.impl;
import com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeDetailDTO; import com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeDetailDTO;
import com.gic.haoban.manage.service.dao.mapper.fee.TabHaobanQywxFeeAccountStaffMapper; import com.gic.haoban.manage.service.dao.mapper.fee.TabHaobanQywxFeeAccountStaffMapper;
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.fee.HaobanQywxFeeAccountStaffService; import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeAccountStaffService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
/** /**
* 企业微信收费订单成员激活详情(TabHaobanQywxFeeAccountStaff)表服务实现类 * 企业微信收费订单成员激活详情(TabHaobanQywxFeeAccountStaff)表服务实现类
* *
* @author mozhu * @author mozhu
* @since 2022-08-03 16:12:32 * @since 2022-08-03 16:12:32
*/ */
@Service @Service
public class HaobanQywxFeeAccountStaffServiceImpl implements HaobanQywxFeeAccountStaffService { public class HaobanQywxFeeAccountStaffServiceImpl implements HaobanQywxFeeAccountStaffService {
@Autowired @Autowired
private TabHaobanQywxFeeAccountStaffMapper tabHaobanQywxFeeAccountStaffMapper; private TabHaobanQywxFeeAccountStaffMapper tabHaobanQywxFeeAccountStaffMapper;
/** /**
* 通过ID查询单条数据 * 新增数据
* *
* @param feeAccountId 主键 * @param tabHaobanQywxFeeAccountStaff 实例对象
* @return 实例对象 * @return 实例对象
*/ */
@Override @Override
public TabHaobanQywxFeeAccountStaff queryById(Long feeAccountId) { public TabHaobanQywxFeeAccountStaff save(TabHaobanQywxFeeAccountStaff account) {
return this.tabHaobanQywxFeeAccountStaffMapper.queryById(feeAccountId); TabHaobanQywxFeeAccountStaff old = this.tabHaobanQywxFeeAccountStaffMapper.selectByActiveCode(account.getWxEnterpriseId(), account.getActiveCode()) ;
} if(null != old) {
account.setFeeAccountStaffId(old.getFeeAccountStaffId());
this.tabHaobanQywxFeeAccountStaffMapper.update(account) ;
/** }else {
* 新增数据 this.tabHaobanQywxFeeAccountStaffMapper.insert(account);
* }
* @param tabHaobanQywxFeeAccountStaff 实例对象 return account ;
* @return 实例对象 }
*/
@Override @Override
public TabHaobanQywxFeeAccountStaff insert(TabHaobanQywxFeeAccountStaff tabHaobanQywxFeeAccountStaff) { public List<HaobanQywxFeeDetailDTO> feeDetail(String wxEnterpriseId) {
this.tabHaobanQywxFeeAccountStaffMapper.insert(tabHaobanQywxFeeAccountStaff); return tabHaobanQywxFeeAccountStaffMapper.feeDetail(wxEnterpriseId);
return tabHaobanQywxFeeAccountStaff; }
}
@Override
/** public HaobanQywxFeeDetailDTO feeIntercept(String wxEnterpriseId) {
* 修改数据 Date lastFeeInterceptTime = tabHaobanQywxFeeAccountStaffMapper.lastFeeInterceptTime(wxEnterpriseId);
* int count = tabHaobanQywxFeeAccountStaffMapper.lastFeeInterceptCount(wxEnterpriseId);
* @param tabHaobanQywxFeeAccountStaff 实例对象 HaobanQywxFeeDetailDTO haobanQywxFeeDetailDTO = new HaobanQywxFeeDetailDTO();
* @return 实例对象 haobanQywxFeeDetailDTO.setInterceptTime(lastFeeInterceptTime);
*/ haobanQywxFeeDetailDTO.setInterceptUserNum(count);
@Override return haobanQywxFeeDetailDTO;
public TabHaobanQywxFeeAccountStaff update(TabHaobanQywxFeeAccountStaff tabHaobanQywxFeeAccountStaff) { }
this.tabHaobanQywxFeeAccountStaffMapper.update(tabHaobanQywxFeeAccountStaff);
return this.queryById(tabHaobanQywxFeeAccountStaff.getFeeAccountStaffId()); @Override
} public int monthWillInterceptNum(String wxEnterpriseId) {
return tabHaobanQywxFeeAccountStaffMapper.lastFeeInterceptCount(wxEnterpriseId);
/** }
* 通过主键删除数据 }
*
* @param feeAccountId 主键
* @return 是否成功
*/
@Override
public boolean deleteById(Long feeAccountId) {
return this.tabHaobanQywxFeeAccountStaffMapper.deleteById(feeAccountId) > 0;
}
@Override
public List<HaobanQywxFeeDetailDTO> feeDetail(String wxEnterpriseId) {
return tabHaobanQywxFeeAccountStaffMapper.feeDetail(wxEnterpriseId);
}
@Override
public HaobanQywxFeeDetailDTO feeIntercept(String wxEnterpriseId) {
Date lastFeeInterceptTime = tabHaobanQywxFeeAccountStaffMapper.lastFeeInterceptTime(wxEnterpriseId);
int count = tabHaobanQywxFeeAccountStaffMapper.lastFeeInterceptCount(wxEnterpriseId);
HaobanQywxFeeDetailDTO haobanQywxFeeDetailDTO = new HaobanQywxFeeDetailDTO();
haobanQywxFeeDetailDTO.setInterceptTime(lastFeeInterceptTime);
haobanQywxFeeDetailDTO.setInterceptUserNum(count);
return haobanQywxFeeDetailDTO;
}
@Override
public int monthWillInterceptNum(String wxEnterpriseId) {
return tabHaobanQywxFeeAccountStaffMapper.lastFeeInterceptCount(wxEnterpriseId);
}
}
...@@ -13,6 +13,7 @@ import org.springframework.stereotype.Service; ...@@ -13,6 +13,7 @@ import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.ServiceResponse; import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.base.api.common.BasePageInfo; import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.PageUtil; import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.common.utils.StringUtil; import com.gic.haoban.common.utils.StringUtil;
...@@ -22,7 +23,9 @@ import com.gic.haoban.manage.service.dao.mapper.StaffMapper; ...@@ -22,7 +23,9 @@ import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper; import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper;
import com.gic.haoban.manage.service.entity.TabHaobanStaff; import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise; 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.StaffService;
import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeAccountStaffService;
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.service.qywx.QywxOrderApiService; import com.gic.wechat.api.service.qywx.QywxOrderApiService;
...@@ -30,6 +33,8 @@ import com.github.pagehelper.Page; ...@@ -30,6 +33,8 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import cn.hutool.core.date.DateUtil;
@Service @Service
public class StaffServiceImpl implements StaffService { public class StaffServiceImpl implements StaffService {
private static final Logger log = LogManager.getLogger(StaffServiceImpl.class); private static final Logger log = LogManager.getLogger(StaffServiceImpl.class);
...@@ -42,6 +47,8 @@ public class StaffServiceImpl implements StaffService { ...@@ -42,6 +47,8 @@ public class StaffServiceImpl implements StaffService {
private WxEnterpriseMapper wxEnterpriseMapper ; private WxEnterpriseMapper wxEnterpriseMapper ;
@Autowired @Autowired
private Config config ; private Config config ;
@Autowired
private HaobanQywxFeeAccountStaffService haobanQywxFeeAccountStaffService;
@Override @Override
public TabHaobanStaff selectById(String id) { public TabHaobanStaff selectById(String id) {
...@@ -220,6 +227,7 @@ public class StaffServiceImpl implements StaffService { ...@@ -220,6 +227,7 @@ public class StaffServiceImpl implements StaffService {
private void updateAccount(String wxEnterpriseId , List<AccountListDTO> list) { private void updateAccount(String wxEnterpriseId , List<AccountListDTO> list) {
for(AccountListDTO item : list) { for(AccountListDTO item : list) {
String userId = item.getUserid() ; String userId = item.getUserid() ;
String activeCode = item.getActiveCode() ;
Date start = new Date(item.getActiveTime()*1000L) ; Date start = new Date(item.getActiveTime()*1000L) ;
Date end = new Date(item.getExpireTime()*1000L) ; Date end = new Date(item.getExpireTime()*1000L) ;
TabHaobanStaff staff = this.mapper.selectByUserIdAndEnterpriseId(userId, wxEnterpriseId) ; TabHaobanStaff staff = this.mapper.selectByUserIdAndEnterpriseId(userId, wxEnterpriseId) ;
...@@ -228,6 +236,16 @@ public class StaffServiceImpl implements StaffService { ...@@ -228,6 +236,16 @@ public class StaffServiceImpl implements StaffService {
} }
if(null != staff) { if(null != staff) {
this.updateActiveStatusById(staff.getStaffId(), start, end, new Date(), 1) ; this.updateActiveStatusById(staff.getStaffId(), start, end, new Date(), 1) ;
TabHaobanQywxFeeAccountStaff accountStaff = new TabHaobanQywxFeeAccountStaff();
accountStaff.setFeeAccountStaffId(UniqueIdUtils.uniqueLong());
accountStaff.setWxEnterpriseId(wxEnterpriseId);
accountStaff.setActiveCode(activeCode);
accountStaff.setStaffId(staff.getStaffId());
accountStaff.setAccountType(item.getType());
accountStaff.setExpireTime(DateUtil.date(item.getExpireTime() * 1000));
accountStaff.setActiveTime(DateUtil.date(item.getActiveTime() * 1000));
this.haobanQywxFeeAccountStaffService.save(accountStaff);
}else { }else {
log.info("查询激活账号,用户不存在,userid={}",userId); log.info("查询激活账号,用户不存在,userid={}",userId);
} }
......
package com.gic.haoban.manage.service.service.out.impl.fee; package com.gic.haoban.manage.service.service.out.impl.fee;
import cn.hutool.core.date.DateField; import java.math.BigDecimal;
import cn.hutool.core.date.DateUtil; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
...@@ -13,7 +25,6 @@ import com.gic.haoban.common.utils.PageUtil; ...@@ -13,7 +25,6 @@ import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.manage.api.constants.Manage3Constants; import com.gic.haoban.manage.api.constants.Manage3Constants;
import com.gic.haoban.manage.api.dto.AlertMessageDTO; import com.gic.haoban.manage.api.dto.AlertMessageDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO; import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeAccountInterceptLogDTO; import com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeAccountInterceptLogDTO;
import com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeDTO; import com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeDTO;
import com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeDetailDTO; import com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeDetailDTO;
...@@ -23,24 +34,29 @@ import com.gic.haoban.manage.api.service.fee.HaobanQywxFeeApiService; ...@@ -23,24 +34,29 @@ import com.gic.haoban.manage.api.service.fee.HaobanQywxFeeApiService;
import com.gic.haoban.manage.service.config.Config; import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.entity.TabHaobanStaff; import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise; import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.entity.fee.*; import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFee;
import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeAccountInterceptLog;
import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeOrder;
import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeOrderAccount;
import com.gic.haoban.manage.service.pojo.bo.fee.HaobanQywxFeeBO; import com.gic.haoban.manage.service.pojo.bo.fee.HaobanQywxFeeBO;
import com.gic.haoban.manage.service.service.StaffService; import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.WxEnterpriseService; import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.fee.*; import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeAccountInterceptLogService;
import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeAccountStaffService;
import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeOrderAccountService;
import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeOrderService;
import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeService;
import com.gic.mq.sdk.GicMQClient; import com.gic.mq.sdk.GicMQClient;
import com.gic.wechat.api.dto.qywx.fee.*; 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.ActiveInfoCodeResponseDTO;
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.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 org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal; import cn.hutool.core.date.DateField;
import java.util.*; import cn.hutool.core.date.DateUtil;
@Service("haobanQywxFeeApiService") @Service("haobanQywxFeeApiService")
public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService { public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
...@@ -79,64 +95,81 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService { ...@@ -79,64 +95,81 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
} }
} }
private List<String> listOrderId(String corpid) {
List<String> orderIds = new ArrayList<>();
FeeOrderListQDTO feeOrderListQDTO = new FeeOrderListQDTO();
feeOrderListQDTO.setCorpid(corpid);
feeOrderListQDTO.setStartTime(DateUtil.beginOfDay(new Date()).offsetNew(DateField.HOUR_OF_DAY, -1).getTime());
feeOrderListQDTO.setEndTime(DateUtil.endOfDay(new Date()).offsetNew(DateField.HOUR_OF_DAY, -1).getTime());
feeOrderListQDTO.setLimit(Manage3Constants.QW_LIMIT);
FeeOrderResponseList feeOrderResponseList = qywxUserApiService.listOrder(corpid, config.getCorpid(), feeOrderListQDTO);
logger.error("查询订单列表,{}", JSON.toJSONString(feeOrderResponseList));
int errcode = feeOrderResponseList.getErrcode();
if (errcode == 0) {
for (FeeOrderResponseList.OrderListDTO orderListDTO : feeOrderResponseList.getOrderList()) {
orderIds.add(orderListDTO.getOrderId());
}
}
return orderIds ;
}
private void getOrderAccount(String orderId , String corpid , String cursor , List<Map<String, String>> activeCodeList) {
FeeOrderListQDTO feeOrderListQDTO = new FeeOrderListQDTO();
feeOrderListQDTO.setOrderId(orderId);
feeOrderListQDTO.setCursor(feeOrderListQDTO.getCursor());
feeOrderListQDTO.setLimit(Manage3Constants.QW_LIMIT);
AccountListResponseDTO accountListResponseDTO = qywxUserApiService.listOrderAccount(corpid, config.getCorpid(), feeOrderListQDTO);
if (accountListResponseDTO.getErrcode() != 0) {
logger.info("订单账号列表报错:{}", accountListResponseDTO.getErrmsg());
return ;
}
for (AccountListDTO accountListDTO : accountListResponseDTO.getAccountList()) {
Map<String, String> map = new HashMap<>();
map.put("orderId", orderId);
map.put("activeCode", accountListDTO.getActiveCode());
activeCodeList.add(map);
}
cursor = accountListResponseDTO.getNextCursor() ;
Integer hasMore = accountListResponseDTO.getHasMore();
if (hasMore == 1 && StringUtils.isNotBlank(cursor)) {
this.getOrderAccount(orderId, corpid, cursor, activeCodeList);
}
}
@Override @Override
public void addFee(String wxEnterpriseId) { public void addFee(String wxEnterpriseId) {
logger.info("企微收费wxEnterpriseId={}", wxEnterpriseId);
if (StringUtils.isBlank(wxEnterpriseId)) { if (StringUtils.isBlank(wxEnterpriseId)) {
logger.error("wx企业id为空"); logger.info("wxEnterpriseId为空");
return; return;
} }
String serviceCorpid = config.getCorpid(); String serviceCorpid = config.getCorpid();
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId); WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId); if(wxEnterpriseDTO.getWxSecurityType()<=0) {
String corpid = qwDTO.getThirdCorpid(); logger.info("WxSecurityType=0,wxEnterpriseId={}",wxEnterpriseId);
return ;
}
String corpid = wxEnterpriseDTO.getOpenCorpid() ;
String corpName = wxEnterpriseDTO.getCorpName(); String corpName = wxEnterpriseDTO.getCorpName();
String autoActiveStatus = qywxUserApiService.getAutoActiveStatus(corpid, serviceCorpid); String autoActiveStatus = qywxUserApiService.getAutoActiveStatus(corpid, serviceCorpid);
if (!"1".equals(autoActiveStatus)) { if (!"1".equals(autoActiveStatus)) {
logger.info("未开启自动激活:{}", corpid); logger.info("未开启自动激活:{},wxeid={}", corpid,wxEnterpriseId);
wxEnterpriseService.updateAutoActiveFlagById(0, wxEnterpriseId); this.wxEnterpriseService.updateAutoActiveFlagById(0, wxEnterpriseId);
return; return;
} }
logger.info("企微收费:{},{}", corpid, wxEnterpriseId); Integer autoActiveFlag = wxEnterpriseDTO.getAutoActiveFlag();
boolean hasOrder = haobanQywxFeeOrderService.hasOrder(wxEnterpriseId); if (autoActiveFlag != null && autoActiveFlag != 1) {
//更新订单 this.wxEnterpriseService.updateAutoActiveFlagById(1, wxEnterpriseId);
List<String> orderIds = new ArrayList<>();
while (true) {
FeeOrderListQDTO feeOrderListQDTO = new FeeOrderListQDTO();
feeOrderListQDTO.setCorpid(corpid);
if (hasOrder) {
feeOrderListQDTO.setStartTime(DateUtil.beginOfDay(new Date()).offsetNew(DateField.HOUR_OF_DAY, -1).getTime());
feeOrderListQDTO.setEndTime(DateUtil.endOfDay(new Date()).offsetNew(DateField.HOUR_OF_DAY, -1).getTime());
}
feeOrderListQDTO.setLimit(Manage3Constants.QW_LIMIT);
FeeOrderResponseList feeOrderResponseList = qywxUserApiService.listOrder(corpid, serviceCorpid, feeOrderListQDTO);
int errcode = feeOrderResponseList.getErrcode();
if (errcode != 0) {
logger.error("查询订单列表失败:{}", feeOrderResponseList.getErrmsg());
break;
}
for (FeeOrderResponseList.OrderListDTO orderListDTO : feeOrderResponseList.getOrderList()) {
orderIds.add(orderListDTO.getOrderId());
}
Integer hasMore = feeOrderResponseList.getHasMore();
if (hasMore == 0) {
logger.error("订单无更多账号");
break;
}
feeOrderListQDTO.setCursor(feeOrderResponseList.getNextCursor());
feeOrderResponseList = qywxUserApiService.listOrder(corpid, serviceCorpid, feeOrderListQDTO);
for (FeeOrderResponseList.OrderListDTO orderListDTO : feeOrderResponseList.getOrderList()) {
orderIds.add(orderListDTO.getOrderId());
}
} }
List<Map<String, String>> activeCodeList = new ArrayList<>(); List<Map<String, String>> activeCodeList = new ArrayList<>();
List<String> orderIds = this.listOrderId(corpid) ;
for (String orderId : orderIds) { for (String orderId : orderIds) {
FeeOrderDeatilResponseDTO order = qywxUserApiService.getOrder(corpid, serviceCorpid, orderId); FeeOrderDeatilResponseDTO order = qywxUserApiService.getOrder(corpid, serviceCorpid, orderId);
if (order.getErrcode() != 0) { if (order.getErrcode() != 0) {
logger.error("请求企微失败:{}", orderId); logger.error("请求企微失败:{}", orderId);
break; continue;
} }
//插入订单 //插入订单
FeeOrderDeatilResponseDTO.OrderDTO orderDTO = order.getOrder(); FeeOrderDeatilResponseDTO.OrderDTO orderDTO = order.getOrder();
Integer orderStatus = orderDTO.getOrderStatus(); Integer orderStatus = orderDTO.getOrderStatus();
...@@ -144,7 +177,6 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService { ...@@ -144,7 +177,6 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
logger.info("只处理已支付订单:{}", orderId); logger.info("只处理已支付订单:{}", orderId);
continue; continue;
} }
TabHaobanQywxFeeOrder tabHaobanQywxFeeOrder = new TabHaobanQywxFeeOrder(); TabHaobanQywxFeeOrder tabHaobanQywxFeeOrder = new TabHaobanQywxFeeOrder();
tabHaobanQywxFeeOrder.setFeeOrderId(UniqueIdUtils.uniqueLong()); tabHaobanQywxFeeOrder.setFeeOrderId(UniqueIdUtils.uniqueLong());
tabHaobanQywxFeeOrder.setOrderId(orderId); tabHaobanQywxFeeOrder.setOrderId(orderId);
...@@ -158,84 +190,16 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService { ...@@ -158,84 +190,16 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
tabHaobanQywxFeeOrder.setMonths(orderDTO.getAccountDuration().getMonths()); tabHaobanQywxFeeOrder.setMonths(orderDTO.getAccountDuration().getMonths());
tabHaobanQywxFeeOrder.setCreateTime(DateUtil.date(orderDTO.getCreateTime() * 1000)); tabHaobanQywxFeeOrder.setCreateTime(DateUtil.date(orderDTO.getCreateTime() * 1000));
tabHaobanQywxFeeOrder.setPayTime(DateUtil.date(orderDTO.getPayTime() * 1000)); tabHaobanQywxFeeOrder.setPayTime(DateUtil.date(orderDTO.getPayTime() * 1000));
haobanQywxFeeOrderService.insert(tabHaobanQywxFeeOrder); this.haobanQywxFeeOrderService.insert(tabHaobanQywxFeeOrder);
FeeOrderListQDTO feeOrderListQDTO = new FeeOrderListQDTO(); this.getOrderAccount(orderId, corpid, null, activeCodeList);
feeOrderListQDTO.setOrderId(orderId);
feeOrderListQDTO.setLimit(Manage3Constants.QW_LIMIT);
AccountListResponseDTO accountListResponseDTO = qywxUserApiService.listOrderAccount(corpid, serviceCorpid, feeOrderListQDTO);
if (accountListResponseDTO.getErrcode() != 0) {
logger.info("订单账号列表报错:{}", accountListResponseDTO.getErrmsg());
break;
}
for (AccountListDTO accountListDTO : accountListResponseDTO.getAccountList()) {
Map<String, String> map = new HashMap<>();
map.put("orderId", orderId);
map.put("activeCode", accountListDTO.getActiveCode());
activeCodeList.add(map);
}
Integer hasMore = accountListResponseDTO.getHasMore();
if (hasMore == 0) {
logger.error("订单无更多账号");
break;
}
feeOrderListQDTO.setCursor(feeOrderListQDTO.getCursor());
accountListResponseDTO = qywxUserApiService.listOrderAccount(corpid, serviceCorpid, feeOrderListQDTO);
for (AccountListDTO accountListDTO : accountListResponseDTO.getAccountList()) {
Map<String, String> map = new HashMap<>();
map.put("orderId", orderId);
map.put("activeCode", accountListDTO.getActiveCode());
activeCodeList.add(map);
}
} }
//处理订单账号
if (CollectionUtils.isNotEmpty(activeCodeList)) { if (CollectionUtils.isNotEmpty(activeCodeList)) {
//处理订单账号
addOrderAccount(wxEnterpriseId, serviceCorpid, corpid, activeCodeList); addOrderAccount(wxEnterpriseId, serviceCorpid, corpid, activeCodeList);
} }
List<String> userIdList = new ArrayList<>();
//企业账号
while (true) {
FeeOrderListQDTO feeOrderListQDTO = new FeeOrderListQDTO();
feeOrderListQDTO.setCorpid(corpid);
feeOrderListQDTO.setLimit(Manage3Constants.QW_LIMIT);
AccountListResponseDTO accountListResponseDTO = qywxUserApiService.listActivedAccount(corpid, serviceCorpid, feeOrderListQDTO);
if (accountListResponseDTO.getErrcode() != 0) {
logger.info("订单账号列表报错:{}", accountListResponseDTO.getErrmsg());
break;
}
List<AccountListDTO> accountList = accountListResponseDTO.getAccountList();
for (AccountListDTO accountListDTO : accountList) {
userIdList.add(accountListDTO.getUserid());
}
Integer hasMore = accountListResponseDTO.getHasMore();
if (hasMore == 0) {
logger.error("无更多账号");
break;
}
feeOrderListQDTO.setCursor(feeOrderListQDTO.getCursor());
accountListResponseDTO = qywxUserApiService.listActivedAccount(corpid, serviceCorpid, feeOrderListQDTO);
for (AccountListDTO accountListDTO : accountListResponseDTO.getAccountList()) {
userIdList.add(accountListDTO.getUserid());
}
}
if (CollectionUtils.isNotEmpty(userIdList)) {
addAccountStaff(wxEnterpriseId, serviceCorpid, corpid, userIdList);
}
Integer autoActiveFlag = wxEnterpriseDTO.getAutoActiveFlag();
if (autoActiveFlag != null && autoActiveFlag != 1) {
//更新企微状态
wxEnterpriseService.updateAutoActiveFlagById(1, wxEnterpriseId);
}
//更新收费 //更新收费
HaobanQywxFeeDetailDTO haobanQywxFeeDetailDTO = haobanQywxFeeAccountStaffService.feeIntercept(wxEnterpriseId); HaobanQywxFeeDetailDTO haobanQywxFeeDetailDTO = haobanQywxFeeAccountStaffService.feeIntercept(wxEnterpriseId);
int permissionUserNum = haobanQywxFeeOrderAccountService.countOrderAccountStatus(1, wxEnterpriseId); int permissionUserNum = haobanQywxFeeOrderAccountService.countOrderAccountStatus(1, wxEnterpriseId);
...@@ -310,38 +274,6 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService { ...@@ -310,38 +274,6 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
} }
} }
private void addAccountStaff(String wxEnterpriseId, String serviceCorpid, String corpid, List<String> useridList) {
if (CollectionUtils.isEmpty(useridList)) {
logger.error("成员激活为空");
return;
}
for (String userid : useridList) {
//更新成员
ActiveInfoUserResponseDTO activeInfoUserResponseDTO = qywxUserApiService.getActiveInfoByUser(corpid, serviceCorpid, userid);
if (activeInfoUserResponseDTO.getErrcode() != 0) {
logger.info("成员激活详情报错:{}", activeInfoUserResponseDTO.getErrmsg());
return;
}
List<AccountListDTO> activeInfoList = activeInfoUserResponseDTO.getActiveInfoList();
TabHaobanStaff tabHaobanStaff = staffService.selectByUserIdAndEnterpriseId(userid, wxEnterpriseId);
for (AccountListDTO accountListDTO : activeInfoList) {
TabHaobanQywxFeeAccountStaff tabHaobanQywxFeeAccountStaff = new TabHaobanQywxFeeAccountStaff();
tabHaobanQywxFeeAccountStaff.setFeeAccountStaffId(UniqueIdUtils.uniqueLong());
tabHaobanQywxFeeAccountStaff.setCorpId(corpid);
tabHaobanQywxFeeAccountStaff.setWxEnterpriseId(wxEnterpriseId);
if (tabHaobanStaff != null) {
String staffId = tabHaobanStaff.getStaffId();
tabHaobanQywxFeeAccountStaff.setStaffId(staffId);
}
tabHaobanQywxFeeAccountStaff.setActiveCode(accountListDTO.getActiveCode());
tabHaobanQywxFeeAccountStaff.setAccountType(accountListDTO.getType());
tabHaobanQywxFeeAccountStaff.setExpireTime(DateUtil.date(accountListDTO.getExpireTime() * 1000));
tabHaobanQywxFeeAccountStaff.setActiveTime(DateUtil.date(accountListDTO.getActiveTime() * 1000));
haobanQywxFeeAccountStaffService.insert(tabHaobanQywxFeeAccountStaff);
}
}
}
@Override @Override
public Page<HaobanQywxFeeDTO> listPage(QywxFeeListQDTO qywxFeeListQDTO) { public Page<HaobanQywxFeeDTO> listPage(QywxFeeListQDTO qywxFeeListQDTO) {
Page<HaobanQywxFeeBO> haobanQywxFeeBOS = haobanQywxFeeService.listPage(qywxFeeListQDTO); Page<HaobanQywxFeeBO> haobanQywxFeeBOS = haobanQywxFeeService.listPage(qywxFeeListQDTO);
...@@ -355,18 +287,20 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService { ...@@ -355,18 +287,20 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
@Override @Override
public void addInterceptLog(String param) { public void addInterceptLog(String param) {
HaobanQywxFeeAccountInterceptLogDTO haobanQywxFeeAccountInterceptLogDTO = JSON.toJavaObject(JSON.parseObject(param), HaobanQywxFeeAccountInterceptLogDTO.class); HaobanQywxFeeAccountInterceptLogDTO logDTO = JSON.toJavaObject(JSON.parseObject(param), HaobanQywxFeeAccountInterceptLogDTO.class);
haobanQywxFeeAccountInterceptLogDTO.setFeeAccountInterceptId(UniqueIdUtils.uniqueLong()); logDTO.setFeeAccountInterceptId(UniqueIdUtils.uniqueLong());
TabHaobanWxEnterprise haobanWxEnterprise = wxEnterpriseService.getEnterpriseBycorpId(haobanQywxFeeAccountInterceptLogDTO.getCorpId()); TabHaobanWxEnterprise haobanWxEnterprise = wxEnterpriseService.getEnterpriseBycorpId(logDTO.getCorpId());
if (haobanWxEnterprise != null) { if(null == haobanWxEnterprise) {
String wxEnterpriseId = haobanWxEnterprise.getWxEnterpriseId(); return ;
haobanQywxFeeAccountInterceptLogDTO.setWxEnterpriseId(wxEnterpriseId); }
TabHaobanStaff tabHaobanStaff = staffService.selectByUserIdAndEnterpriseId(haobanQywxFeeAccountInterceptLogDTO.getWxUserId(), wxEnterpriseId); String wxEnterpriseId = haobanWxEnterprise.getWxEnterpriseId();
if (tabHaobanStaff != null) { logDTO.setWxEnterpriseId(wxEnterpriseId);
haobanQywxFeeAccountInterceptLogDTO.setStaffId(tabHaobanStaff.getStaffId()); TabHaobanStaff tabHaobanStaff = staffService.selectByUserIdAndEnterpriseId(logDTO.getWxUserId(), wxEnterpriseId);
} if(null == tabHaobanStaff) {
return ;
} }
haobanQywxFeeAccountInterceptLogService.insert(EntityUtil.changeEntityNew(TabHaobanQywxFeeAccountInterceptLog.class, haobanQywxFeeAccountInterceptLogDTO)); logDTO.setStaffId(tabHaobanStaff.getStaffId());
haobanQywxFeeAccountInterceptLogService.insert(EntityUtil.changeEntityNew(TabHaobanQywxFeeAccountInterceptLog.class, logDTO));
} }
@Override @Override
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gic.haoban.manage.service.dao.mapper.fee.TabHaobanQywxFeeAccountStaffMapper"> <mapper namespace="com.gic.haoban.manage.service.dao.mapper.fee.TabHaobanQywxFeeAccountStaffMapper">
<resultMap type="com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeAccountStaff" id="TabHaobanQywxFeeAccountStaffMap"> <resultMap type="com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeAccountStaff" id="TabHaobanQywxFeeAccountStaffMap">
<result property="feeAccountStaffId" column="fee_account_staff_id" jdbcType="INTEGER"/> <result property="feeAccountStaffId" column="fee_account_staff_id" jdbcType="INTEGER"/>
<result property="orderId" column="order_id" jdbcType="VARCHAR"/> <result property="orderId" column="order_id" jdbcType="VARCHAR"/>
<result property="corpId" column="corp_id" jdbcType="VARCHAR"/> <result property="corpId" column="corp_id" jdbcType="VARCHAR"/>
<result property="wxEnterpriseId" column="wx_enterprise_id" jdbcType="VARCHAR"/> <result property="wxEnterpriseId" column="wx_enterprise_id" jdbcType="VARCHAR"/>
<result property="staffId" column="staff_id" jdbcType="VARCHAR"/> <result property="staffId" column="staff_id" jdbcType="VARCHAR"/>
<result property="activeCode" column="active_code" jdbcType="VARCHAR"/> <result property="activeCode" column="active_code" jdbcType="VARCHAR"/>
<result property="accountType" column="account_type" jdbcType="INTEGER"/> <result property="accountType" column="account_type" jdbcType="INTEGER"/>
<result property="expireTime" column="expire_time" jdbcType="TIMESTAMP"/> <result property="expireTime" column="expire_time" jdbcType="TIMESTAMP"/>
<result property="activeTime" column="active_time" jdbcType="TIMESTAMP"/> <result property="activeTime" column="active_time" jdbcType="TIMESTAMP"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
fee_account_staff_id fee_account_staff_id
, order_id, corp_id, wx_enterprise_id, staff_id, active_code, account_type, expire_time, active_time , order_id, corp_id, wx_enterprise_id, staff_id, active_code, account_type, expire_time, active_time
</sql> </sql>
<!--查询单个--> <!--查询单个-->
<select id="queryById" resultMap="TabHaobanQywxFeeAccountStaffMap"> <select id="selectByActiveCode" resultMap="TabHaobanQywxFeeAccountStaffMap">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from tab_haoban_qywx_fee_account_staff from tab_haoban_qywx_fee_account_staff
where fee_account_id = #{feeAccountId} where wx_enterprise_id = #{wxEnterpriseId} and active_code = #{activeCode}
</select> </select>
<!--查询指定行数据--> <!--新增所有列-->
<select id="queryAllByLimit" resultMap="TabHaobanQywxFeeAccountStaffMap"> <insert id="insert" keyProperty="feeAccountId" useGeneratedKeys="true">
select insert into tab_haoban_qywx_fee_account_staff(fee_account_staff_id, order_id, corp_id, wx_enterprise_id,
<include refid="Base_Column_List"/> staff_id, active_code, account_type, expire_time, active_time)
from tab_haoban_qywx_fee_account_staff values (#{feeAccountStaffId}, #{orderId}, #{corpId}, #{wxEnterpriseId}, #{staffId}, #{activeCode},
<where> #{accountType}, #{expireTime}, #{activeTime})
<if test="feeAccountId != null"> </insert>
and fee_account_id = #{feeAccountId}
</if> <!--通过主键修改数据-->
<if test="orderId != null and orderId != ''"> <update id="update">
and order_id = #{orderId} update tab_haoban_qywx_fee_account_staff
</if> <set>
<if test="corpId != null and corpId != ''"> <if test="orderId != null and orderId != ''">
and corp_id = #{corpId} order_id = #{orderId},
</if> </if>
<if test="wxEnterpriseId != null and wxEnterpriseId != ''"> <if test="corpId != null and corpId != ''">
and wx_enterprise_id = #{wxEnterpriseId} corp_id = #{corpId},
</if> </if>
<if test="wxUserId != null and wxUserId != ''"> <if test="wxEnterpriseId != null and wxEnterpriseId != ''">
and wx_user_id = #{wxUserId} wx_enterprise_id = #{wxEnterpriseId},
</if> </if>
<if test="staffId != null and staffId != ''"> <if test="staffId != null and staffId != ''">
and staff_id = #{staffId} staff_id = #{staffId},
</if> </if>
<if test="activeCode != null and activeCode != ''"> <if test="activeCode != null and activeCode != ''">
and active_code = #{activeCode} active_code = #{activeCode},
</if> </if>
<if test="accountType != null"> <if test="accountType != null">
and account_type = #{accountType} account_type = #{accountType},
</if> </if>
<if test="expireTime != null"> <if test="expireTime != null">
and expire_time = #{expireTime} expire_time = #{expireTime},
</if> </if>
<if test="activeTime != null"> <if test="activeTime != null">
and active_time = #{activeTime} active_time = #{activeTime},
</if> </if>
</where> </set>
limit #{pageable.offset}, #{pageable.pageSize} where fee_account_id = #{feeAccountStaffId}
</select> </update>
<select id="feeDetail" resultType="com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeDetailDTO">
<!--新增所有列--> select
<insert id="insert" keyProperty="feeAccountId" useGeneratedKeys="true"> count(distinct staff_id) interceptUserNum,
insert into tab_haoban_qywx_fee_account_staff(fee_account_staff_id, order_id, corp_id, wx_enterprise_id, DATE_FORMAT( expire_time, '%Y-%m-%d' ) interceptTime
staff_id, active_code, account_type, expire_time, active_time) from tab_haoban_qywx_fee_account_staff
values (#{feeAccountStaffId}, #{orderId}, #{corpId}, #{wxEnterpriseId}, #{staffId}, #{activeCode}, where wx_enterprise_id = #{wxEnterpriseId}
#{accountType}, #{expireTime}, #{activeTime}) and expire_time between DATE(CURDATE()) and DATE_add(CURDATE(), INTERVAL 30 DAY)
</insert> group by DATE_FORMAT( expire_time, '%Y-%m-%d' )
</select>
<insert id="insertBatch" keyProperty="feeAccountId" useGeneratedKeys="true">
insert into tab_haoban_qywx_fee_account_staff(fee_account_staff_id, order_id, corp_id, wx_enterprise_id,
staff_id, active_code, account_type, expire_time, active_time) <select id="lastFeeInterceptTime" resultType="java.util.Date">
values select
<foreach collection="entities" item="entity" separator=","> expire_time expireTime
(#{entity.feeAccountStaffId}, #{entity.orderId}, #{entity.corpId}, #{entity.wxEnterpriseId}, from tab_haoban_qywx_fee_account_staff
#{entity.staffId}, #{entity.activeCode}, #{entity.accountType}, #{entity.expireTime}, #{entity.activeTime}) where wx_enterprise_id = #{wxEnterpriseId}
</foreach> and expire_time between DATE(CURDATE()) and DATE_add(CURDATE(), INTERVAL 30 DAY)
</insert> order by expire_time desc limit 1
</select>
<!--通过主键修改数据--> <select id="lastFeeInterceptCount" resultType="java.lang.Integer">
<update id="update"> select
update tab_haoban_qywx_fee_account_staff count(distinct staff_id)
<set> from tab_haoban_qywx_fee_account_staff
<if test="orderId != null and orderId != ''"> where wx_enterprise_id = #{wxEnterpriseId}
order_id = #{orderId}, and expire_time between DATE(CURDATE()) and DATE_add(CURDATE(), INTERVAL 30 DAY)
</if> </select>
<if test="corpId != null and corpId != ''"> </mapper>
corp_id = #{corpId},
</if>
<if test="wxEnterpriseId != null and wxEnterpriseId != ''">
wx_enterprise_id = #{wxEnterpriseId},
</if>
<if test="staffId != null and staffId != ''">
staff_id = #{staffId},
</if>
<if test="activeCode != null and activeCode != ''">
active_code = #{activeCode},
</if>
<if test="accountType != null">
account_type = #{accountType},
</if>
<if test="expireTime != null">
expire_time = #{expireTime},
</if>
<if test="activeTime != null">
active_time = #{activeTime},
</if>
</set>
where fee_account_id = #{feeAccountStaffId}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete
from tab_haoban_qywx_fee_account_staff
where fee_account_staff_id = #{feeAccountId}
</delete>
<select id="feeDetail" resultType="com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeDetailDTO">
select
count(distinct staff_id) interceptUserNum,
DATE_FORMAT( expire_time, '%Y-%m-%d' ) interceptTime
from tab_haoban_qywx_fee_account_staff
where wx_enterprise_id = #{wxEnterpriseId}
and expire_time between DATE(CURDATE()) and DATE_add(CURDATE(), INTERVAL 30 DAY)
group by DATE_FORMAT( expire_time, '%Y-%m-%d' )
</select>
<select id="lastFeeInterceptTime" resultType="java.util.Date">
select
expire_time expireTime
from tab_haoban_qywx_fee_account_staff
where wx_enterprise_id = #{wxEnterpriseId}
and expire_time between DATE(CURDATE()) and DATE_add(CURDATE(), INTERVAL 30 DAY)
order by expire_time desc limit 1
</select>
<select id="lastFeeInterceptCount" resultType="java.lang.Integer">
select
count(distinct staff_id)
from tab_haoban_qywx_fee_account_staff
where wx_enterprise_id = #{wxEnterpriseId}
and expire_time between DATE(CURDATE()) and DATE_add(CURDATE(), INTERVAL 30 DAY)
</select>
</mapper>
import cn.hutool.core.thread.ConcurrencyTester; import java.util.ArrayList;
import cn.hutool.core.thread.ThreadUtil; import java.util.List;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.manage.api.dto.HandoverExternalDTO;
import com.gic.haoban.manage.api.service.*;
import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.TestService;
import com.gic.mq.sdk.GicMQClient;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -20,8 +9,18 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -20,8 +9,18 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList; import com.alibaba.fastjson.JSON;
import java.util.List; import com.alibaba.fastjson.JSONObject;
import com.ctrip.framework.apollo.Config;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.manage.api.dto.HandoverExternalDTO;
import com.gic.haoban.manage.api.service.HandoverOperationApiService;
import com.gic.mq.sdk.GicMQClient;
import com.gic.wechat.api.dto.qywx.fee.AccountListResponseDTO;
import com.gic.wechat.api.service.qywx.QywxOrderApiService;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"}) @ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"})
...@@ -31,12 +30,17 @@ public class HandoverTest { ...@@ -31,12 +30,17 @@ public class HandoverTest {
@Autowired @Autowired
private HandoverOperationApiService handoverOperationApiService; private HandoverOperationApiService handoverOperationApiService;
@Autowired
private QywxOrderApiService qywxOrderApiService ;
@Autowired
private com.gic.haoban.manage.service.config.Config config ;
@Test @Test
public void test() { public void test() {
String wxEnterpriseId = "e86dbc7f329d41be9db2e3526c9b48c4"; ServiceResponse<AccountListResponseDTO> resp = this.qywxOrderApiService.listActivedAccount(config.getCorpid(), "wp59NLDQAAJL6DsM6YwOGqJlhCBykkeA", 100, null) ;
handoverOperationApiService.dealQywxEnterpriseHandover(wxEnterpriseId); System.out.println(JSON.toJSONString(resp));
System.out.println("11");
} }
@Test @Test
......
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