Commit ceb42c4a by jinxin

通讯录接口开发

parent b91e2596
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
/**
* @description: 通讯录许可数据总览
* @Author: wenhua
* @Date: 2023/1/30 20:28
*/
public class StaffActiveDataDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
private String id;
/**
* wx企业id
*/
private String wxEnterpriseId;
/**
* 已购买许可总数
*/
private Integer purchased;
/**
* 已使用许可总数
*/
private Integer used;
/**
* 未激活许可总数
*/
private Integer inactive;
/**
* 待转移许可总数
*/
private Integer transfer;
/**
* 已激活许可总数
*/
private Integer activated;
/**
* 已过期许可总数
*/
private Integer expired;
/**
* 其他占用许可总数
*/
private Integer occupy;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public Integer getPurchased() {
return purchased;
}
public void setPurchased(Integer purchased) {
this.purchased = purchased;
}
public Integer getInactive() {
return inactive;
}
public void setInactive(Integer inactive) {
this.inactive = inactive;
}
public Integer getTransfer() {
return transfer;
}
public void setTransfer(Integer transfer) {
this.transfer = transfer;
}
public Integer getActivated() {
return activated;
}
public void setActivated(Integer activated) {
this.activated = activated;
}
public Integer getExpired() {
return expired;
}
public void setExpired(Integer expired) {
this.expired = expired;
}
public Integer getOccupy() {
return occupy;
}
public void setOccupy(Integer occupy) {
this.occupy = occupy;
}
public Integer getUsed() {
return used;
}
public void setUsed(Integer used) {
this.used = used;
}
}
...@@ -104,9 +104,9 @@ public class StaffDTO implements Serializable { ...@@ -104,9 +104,9 @@ public class StaffDTO implements Serializable {
private Integer activeStatus; private Integer activeStatus;
private String enterpriseId; private String enterpriseId;
private String storeId; private String storeId;
private int openConcatFlag = 0 ; private int openConcatFlag = 0;
private String ownerRemark ; private String ownerRemark;
/** /**
* 许可激活时间 * 许可激活时间
...@@ -120,6 +120,23 @@ public class StaffDTO implements Serializable { ...@@ -120,6 +120,23 @@ public class StaffDTO implements Serializable {
* 许可状态 0 未激活,1 正常有效,2 即将过期,3 已过期 * 许可状态 0 未激活,1 正常有效,2 即将过期,3 已过期
*/ */
private Integer permitState; private Integer permitState;
/**
* 是否授权 0否1是
*/
private Integer authorizedFlag;
public Integer getAuthorizedFlag() {
// 如果员工有qr_code,则代表已经授权
if (null != this.qrCode)
this.authorizedFlag = 1;
else
this.authorizedFlag = 0;
return authorizedFlag;
}
public void setAuthorizedFlag(Integer authorizedFlag) {
this.authorizedFlag = authorizedFlag;
}
public Date getActiveTime() { public Date getActiveTime() {
return activeTime; return activeTime;
...@@ -145,15 +162,15 @@ public class StaffDTO implements Serializable { ...@@ -145,15 +162,15 @@ public class StaffDTO implements Serializable {
* 已过期:当前许可已到过期时间 * 已过期:当前许可已到过期时间
*/ */
Date now = new Date(); Date now = new Date();
if (null == this.expireTime){ if (null == this.expireTime) {
this.permitState = 0; this.permitState = 0;
}else if (now.after(this.expireTime)){ } else if (now.after(this.expireTime)) {
this.permitState = 3; this.permitState = 3;
}else if (now.before(this.expireTime)){ } else if (now.before(this.expireTime)) {
Date date = DateUtil.addDay(now, 30); Date date = DateUtil.addDay(now, 30);
if (now.after(this.expireTime)){ if (now.after(this.expireTime)) {
this.permitState = 2; this.permitState = 2;
}else { } else {
this.permitState = 1; this.permitState = 1;
} }
} }
......
package com.gic.haoban.manage.api.service;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.dto.StaffActiveDataDTO;
/**
* @description: 通讯录数据总览
* @Author: wenhua
* @Date: 2023/2/2 10:11
*/
public interface WxEnterpriseActiveDataApiService {
/**
* 通过wxEnterpriseId新增或者更新WxEnterpriseActiveData
* @param wxEnterpriseId
* @return
*/
ServiceResponse<Integer> saveOrUpdate(String wxEnterpriseId);
ServiceResponse<StaffActiveDataDTO> getWxEnterpriseActiveDataById(String id);
ServiceResponse<StaffActiveDataDTO> getWxEnterpriseActiveDataByWxEnterpriseId(String wxEnterpriseId);
}
...@@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject; ...@@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.authcenter.commons.dto.AuthcenterUserDetails; import com.gic.authcenter.commons.dto.AuthcenterUserDetails;
import com.gic.authcenter.commons.util.SessionContextUtil; import com.gic.authcenter.commons.util.SessionContextUtil;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.GlobalVar; import com.gic.commons.util.GlobalVar;
import com.gic.enterprise.api.dto.EnterpriseAndUserDTO; import com.gic.enterprise.api.dto.EnterpriseAndUserDTO;
import com.gic.enterprise.api.dto.EnterpriseDTO; import com.gic.enterprise.api.dto.EnterpriseDTO;
...@@ -76,6 +78,8 @@ public class EnterpriseController extends WebBaseController { ...@@ -76,6 +78,8 @@ public class EnterpriseController extends WebBaseController {
private QywxUserApiService qywxUserApiService; private QywxUserApiService qywxUserApiService;
@Autowired @Autowired
private StoreGroupService storeGroupService ; private StoreGroupService storeGroupService ;
@Autowired
private ClerkService clerkService;
private static final String QYWX_TAG_OPRN_KEY = "qywx-tag-open"; private static final String QYWX_TAG_OPRN_KEY = "qywx-tag-open";
private static final String QYWX_TAG_OPRN_KEY_LOCK = "qywx-tag-open-lock"; private static final String QYWX_TAG_OPRN_KEY_LOCK = "qywx-tag-open-lock";
...@@ -479,18 +483,24 @@ public class EnterpriseController extends WebBaseController { ...@@ -479,18 +483,24 @@ public class EnterpriseController extends WebBaseController {
//gic企业列表 //gic企业列表
@RequestMapping("enterprise-search") @RequestMapping("enterprise-search")
public HaobanResponse gicEnterpriseDetail(String enterpriseName) { public HaobanResponse gicEnterpriseDetail(String enterpriseId) {
if (StringUtils.isEmpty(enterpriseName)) { if (StringUtils.isEmpty(enterpriseId)) {
return resultResponse(HaoBanErrCode.ERR_1); return resultResponse(HaoBanErrCode.ERR_1);
} }
EnterpriseAndUserDTO dto = enterpriseService.getEnterpriseAndUserByName(enterpriseName); EnterpriseSearchVO vo = new EnterpriseSearchVO();
EnterpriseSearchVO vo = EntityUtil.changeEntityByJSON(EnterpriseSearchVO.class, dto); EnterpriseDTO enterprise = enterpriseService.getEnterpriseById(enterpriseId);
if (vo != null) { if (enterprise != null) {
String enterpriseId = vo.getEnterpriseId(); vo.setEnterpriseId(enterpriseId);
EnterpriseDTO enterprise = enterpriseService.getEnterpriseById(enterpriseId); vo.setEnterpriseName(enterprise.getEnterpriseName());
if (enterprise != null) { vo.setBrandName(enterprise.getBrandName());
vo.setBrandName(enterprise.getBrandName()); }
} ClerkDTO clerk = clerkService.getSuperAdminByEnterpriseId(enterpriseId);
if (clerk != null) {
vo.setClerkId(clerk.getClerkId());
vo.setClerkCode(clerk.getClerkCode());
vo.setClerkName(clerk.getClerkName());
vo.setPhoneNumber(clerk.getPhoneNumber());
vo.setNationCode(clerk.getNationcode());
} }
return resultResponse(HaoBanErrCode.ERR_1, vo); return resultResponse(HaoBanErrCode.ERR_1, vo);
} }
......
...@@ -2,6 +2,7 @@ package com.gic.haoban.manage.service.dao.mapper; ...@@ -2,6 +2,7 @@ package com.gic.haoban.manage.service.dao.mapper;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseActiveData; import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseActiveData;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* @description: * @description:
...@@ -13,9 +14,9 @@ public interface TabHaobanWxEnterpriseActiveDataMapper { ...@@ -13,9 +14,9 @@ public interface TabHaobanWxEnterpriseActiveDataMapper {
int insert(TabHaobanWxEnterpriseActiveData tabHaobanWxEnterpriseActiveData); int insert(TabHaobanWxEnterpriseActiveData tabHaobanWxEnterpriseActiveData);
TabHaobanWxEnterpriseActiveData getWxEnterpriseActiveDataById(); TabHaobanWxEnterpriseActiveData getWxEnterpriseActiveDataById(@Param("id")String id);
TabHaobanWxEnterpriseActiveData getWxEnterpriseActiveDataByWxEnterpriseId(); TabHaobanWxEnterpriseActiveData getWxEnterpriseActiveDataByWxEnterpriseId(@Param("wxEnterpriseId")String wxEnterpriseId);
int updateActiveDataByWxEnterpriseId(TabHaobanWxEnterpriseActiveData activeData); int updateActiveDataByWxEnterpriseId(TabHaobanWxEnterpriseActiveData activeData);
......
...@@ -4,6 +4,9 @@ import org.apache.ibatis.annotations.Param; ...@@ -4,6 +4,9 @@ import org.apache.ibatis.annotations.Param;
import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeOrderAccount; import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeOrderAccount;
import java.util.HashMap;
import java.util.List;
/** /**
* 企业微信收费订单账号(激活码)(TabHaobanQywxFeeOrderAccount)表数据库访问层 * 企业微信收费订单账号(激活码)(TabHaobanQywxFeeOrderAccount)表数据库访问层
* *
...@@ -46,5 +49,7 @@ public interface TabHaobanQywxFeeOrderAccountMapper { ...@@ -46,5 +49,7 @@ public interface TabHaobanQywxFeeOrderAccountMapper {
* @date 2022-08-05 11:24:02 * @date 2022-08-05 11:24:02
*/ */
int countOrderAccountStatus(@Param("status") Integer status,@Param("wxEnterpriseId") String wxEnterpriseId); int countOrderAccountStatus(@Param("status") Integer status,@Param("wxEnterpriseId") String wxEnterpriseId);
List<HashMap<String,Integer>> countStatusByWxEnterpriseId(@Param("wxEnterpriseId") String wxEnterpriseId);
} }
...@@ -24,6 +24,10 @@ public class TabHaobanWxEnterpriseActiveData implements Serializable { ...@@ -24,6 +24,10 @@ public class TabHaobanWxEnterpriseActiveData implements Serializable {
*/ */
private Integer purchased; private Integer purchased;
/** /**
* 已使用许可总数
*/
private Integer used;
/**
* 未激活许可总数 * 未激活许可总数
*/ */
private Integer inactive; private Integer inactive;
...@@ -126,4 +130,11 @@ public class TabHaobanWxEnterpriseActiveData implements Serializable { ...@@ -126,4 +130,11 @@ public class TabHaobanWxEnterpriseActiveData implements Serializable {
this.expired = expired; this.expired = expired;
} }
public Integer getUsed() {
return used;
}
public void setUsed(Integer used) {
this.used = used;
}
} }
package com.gic.haoban.manage.service.service;
import com.gic.haoban.manage.api.dto.StaffActiveDataDTO;
/**
* @description: 通讯录数据总览内部service
* @Author: wenhua
* @Date: 2023/2/2 10:11
*/
public interface WxEnterpriseActiveDataService {
/**
* 通过wxEnterpriseId新增或者更新WxEnterpriseActiveData
* @param wxEnterpriseId
* @return
*/
Integer saveOrUpdate(String wxEnterpriseId);
StaffActiveDataDTO getWxEnterpriseActiveDataById(String id);
StaffActiveDataDTO getWxEnterpriseActiveDataByWxEnterpriseId(String wxEnterpriseId);
}
...@@ -86,6 +86,9 @@ public class StaffServiceImpl implements StaffService { ...@@ -86,6 +86,9 @@ public class StaffServiceImpl implements StaffService {
@Override @Override
public Page<TabHaobanStaff> pageStaff(List<String> staffIds, Integer activeFlag, String keyword,List<String> departmentIds,String wxEnterpriseId,Integer relationFlag) { public Page<TabHaobanStaff> pageStaff(List<String> staffIds, Integer activeFlag, String keyword,List<String> departmentIds,String wxEnterpriseId,Integer relationFlag) {
return mapper.pageStaff(staffIds, activeFlag, keyword,departmentIds,wxEnterpriseId,relationFlag); return mapper.pageStaff(staffIds, activeFlag, keyword,departmentIds,wxEnterpriseId,relationFlag);
} }
......
package com.gic.haoban.manage.service.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.manage.api.dto.StaffActiveDataDTO;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanWxEnterpriseActiveDataMapper;
import com.gic.haoban.manage.service.dao.mapper.fee.TabHaobanQywxFeeOrderAccountMapper;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseActiveData;
import com.gic.haoban.manage.service.service.WxEnterpriseActiveDataService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
/**
* @description:
* @Author: wenhua
* @Date: 2023/2/2 10:44
*/
@Service
public class WxEnterpriseActiveDataServiceImpl implements WxEnterpriseActiveDataService {
private static final Logger log = LogManager.getLogger(WxEnterpriseActiveDataServiceImpl.class);
@Autowired
private TabHaobanWxEnterpriseActiveDataMapper tabHaobanWxEnterpriseActiveDataMapper;
@Autowired
private TabHaobanQywxFeeOrderAccountMapper tabHaobanQywxFeeOrderAccountMapper;
@Override
public Integer saveOrUpdate(String wxEnterpriseId) {
if (StrUtil.isBlank(wxEnterpriseId))
return 0;
List<HashMap<String, Integer>> feeOrderAccountMapList = tabHaobanQywxFeeOrderAccountMapper.countStatusByWxEnterpriseId(wxEnterpriseId);
log.info("查询订单表返回的map", JSONObject.toJSONString(feeOrderAccountMapList));
if (CollUtil.isEmpty(feeOrderAccountMapList)) {
return 0;
}
//初始化各状态
Integer purchased = 0, used = 0, inactive = 0, transfer = 0, activated = 0, expired = 0;
for (HashMap<String, Integer> map : feeOrderAccountMapList) {
switch (map.get("status")) {
case 1:
purchased += map.get("num");
inactive += map.get("num");
break;
case 2:
purchased += map.get("num");
activated += map.get("num");
break;
case 3:
purchased += map.get("num");
expired += map.get("num");
break;
case 4:
purchased += map.get("num");
transfer += map.get("num");
break;
case 5:
purchased += map.get("num");
activated += map.get("num");
break;
default:
break;
}
}
//已使用为已购买总数-未使用的
used = purchased - inactive;
TabHaobanWxEnterpriseActiveData tabHaobanWxEnterpriseActiveData = tabHaobanWxEnterpriseActiveDataMapper.getWxEnterpriseActiveDataByWxEnterpriseId(wxEnterpriseId);
if (ObjectUtil.isNotNull(tabHaobanWxEnterpriseActiveData)) {
//更新
tabHaobanWxEnterpriseActiveData.setActivated(activated);
tabHaobanWxEnterpriseActiveData.setPurchased(purchased);
tabHaobanWxEnterpriseActiveData.setInactive(inactive);
tabHaobanWxEnterpriseActiveData.setUsed(used);
tabHaobanWxEnterpriseActiveData.setTransfer(transfer);
return tabHaobanWxEnterpriseActiveDataMapper.updateActiveDataByWxEnterpriseId(tabHaobanWxEnterpriseActiveData);
} else {
//新增
tabHaobanWxEnterpriseActiveData.setId(UniqueIdUtils.uniqueLong());
tabHaobanWxEnterpriseActiveData.setWxEnterpriseId(wxEnterpriseId);
tabHaobanWxEnterpriseActiveData.setActivated(activated);
tabHaobanWxEnterpriseActiveData.setPurchased(purchased);
tabHaobanWxEnterpriseActiveData.setInactive(inactive);
tabHaobanWxEnterpriseActiveData.setUsed(used);
tabHaobanWxEnterpriseActiveData.setTransfer(transfer);
return tabHaobanWxEnterpriseActiveDataMapper.insert(tabHaobanWxEnterpriseActiveData);
}
}
@Override
public StaffActiveDataDTO getWxEnterpriseActiveDataById(String id) {
if (StrUtil.isBlank(id))
return null;
return EntityUtil.changeEntityByJSON(StaffActiveDataDTO.class, tabHaobanWxEnterpriseActiveDataMapper.getWxEnterpriseActiveDataById(id));
}
@Override
public StaffActiveDataDTO getWxEnterpriseActiveDataByWxEnterpriseId(String wxEnterpriseId) {
if (StrUtil.isBlank(wxEnterpriseId))
return null;
return EntityUtil.changeEntityByJSON(StaffActiveDataDTO.class, tabHaobanWxEnterpriseActiveDataMapper.getWxEnterpriseActiveDataById(wxEnterpriseId));
}
}
package com.gic.haoban.manage.service.service.out.impl;
import cn.hutool.core.util.ObjectUtil;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.dto.StaffActiveDataDTO;
import com.gic.haoban.manage.api.service.WxEnterpriseActiveDataApiService;
import com.gic.haoban.manage.service.service.WxEnterpriseActiveDataService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @description:
* @Author: wenhua
* @Date: 2023/2/2 10:21
*/
@Service
public class WxEnterpriseActiveDataApiServiceImpl implements WxEnterpriseActiveDataApiService {
private static final Logger log = LogManager.getLogger(WxEnterpriseApiServiceImpl.class);
@Autowired
private WxEnterpriseActiveDataService wxEnterpriseActiveDataService;
@Override
public ServiceResponse<Integer> saveOrUpdate(String wxEnterpriseId) {
return ServiceResponse.success(wxEnterpriseActiveDataService.saveOrUpdate(wxEnterpriseId));
}
@Override
public ServiceResponse<StaffActiveDataDTO> getWxEnterpriseActiveDataById(String id) {
StaffActiveDataDTO staffActiveDataDTO= wxEnterpriseActiveDataService.getWxEnterpriseActiveDataById(id);
if (ObjectUtil.isNotNull(staffActiveDataDTO))
return ServiceResponse.success(staffActiveDataDTO);
else
return ServiceResponse.failure("9999","id不存在");
}
@Override
public ServiceResponse<StaffActiveDataDTO> getWxEnterpriseActiveDataByWxEnterpriseId(String wxEnterpriseId) {
StaffActiveDataDTO staffActiveDataDTO= wxEnterpriseActiveDataService.getWxEnterpriseActiveDataByWxEnterpriseId(wxEnterpriseId);
if (ObjectUtil.isNotNull(staffActiveDataDTO))
return ServiceResponse.success(staffActiveDataDTO);
else
return ServiceResponse.failure("9999","wxEnterpriseId不存在");
}
}
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<id column="id" jdbcType="BIGINT" property="id"/> <id column="id" jdbcType="BIGINT" property="id"/>
<result column="wx_enterprise_id" jdbcType="VARCHAR" property="wxEnterpriseId"/> <result column="wx_enterprise_id" jdbcType="VARCHAR" property="wxEnterpriseId"/>
<result column="purchased" jdbcType="INTEGER" property="purchased"/> <result column="purchased" jdbcType="INTEGER" property="purchased"/>
<result column="used" jdbcType="INTEGER" property="used"/>
<result column="inactive" jdbcType="INTEGER" property="inactive"/> <result column="inactive" jdbcType="INTEGER" property="inactive"/>
<result column="transfer" jdbcType="INTEGER" property="transfer"/> <result column="transfer" jdbcType="INTEGER" property="transfer"/>
<result column="activated" jdbcType="INTEGER" property="activated"/> <result column="activated" jdbcType="INTEGER" property="activated"/>
......
...@@ -78,5 +78,13 @@ ...@@ -78,5 +78,13 @@
where wx_enterprise_id = #{wxEnterpriseId} and status = #{status} where wx_enterprise_id = #{wxEnterpriseId} and status = #{status}
</select> </select>
<select id="countStatusByWxEnterpriseId" resultType="java.util.HashMap">
select
status,
count(*) as num
from tab_haoban_qywx_fee_order_account
where wx_enterprise_id = #{wxEnterpriseId} GROUP BY STATUS
</select>
</mapper> </mapper>
...@@ -616,6 +616,8 @@ public class StaffController extends WebBaseController { ...@@ -616,6 +616,8 @@ public class StaffController extends WebBaseController {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser(); WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId(); String wxEnterpriseId = login.getWxEnterpriseId();
StaffActiveDataVO staffActiveDataVo = new StaffActiveDataVO(); StaffActiveDataVO staffActiveDataVo = new StaffActiveDataVO();
return RestResponse.successResult(staffActiveDataVo); return RestResponse.successResult(staffActiveDataVo);
} }
/** /**
......
...@@ -23,6 +23,10 @@ public class StaffActiveDataVO implements Serializable { ...@@ -23,6 +23,10 @@ public class StaffActiveDataVO implements Serializable {
*/ */
private Integer purchased; private Integer purchased;
/** /**
* 已使用许可总数
*/
private Integer used;
/**
* 未激活许可总数 * 未激活许可总数
*/ */
private Integer inactive; private Integer inactive;
...@@ -106,4 +110,12 @@ public class StaffActiveDataVO implements Serializable { ...@@ -106,4 +110,12 @@ public class StaffActiveDataVO implements Serializable {
public void setOccupy(Integer occupy) { public void setOccupy(Integer occupy) {
this.occupy = occupy; this.occupy = occupy;
} }
public Integer getUsed() {
return used;
}
public void setUsed(Integer used) {
this.used = used;
}
} }
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