Commit 54a88416 by 徐高华

企微操作日志

parent 0353a54b
......@@ -2,6 +2,7 @@ package com.gic.haoban.manage.web.controller.open;
import cn.hutool.core.date.DatePattern;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.JSONResponse;
import com.gic.api.base.commons.Page;
......@@ -12,6 +13,7 @@ import com.gic.commons.util.PageHelperUtils;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.dto.EnterpriseUsingPermissionDto;
import com.gic.enterprise.api.dto.WechatWorkServiceSetting;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.enterprise.api.service.EnterpriseUseForbidService;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
......@@ -24,6 +26,7 @@ import com.gic.haoban.manage.api.service.OpenStaffApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.web.qo.open.OpenStaffQO;
import com.gic.haoban.manage.web.vo.open.OpenQwAccountInfoVO;
import com.gic.haoban.manage.web.vo.open.OpenStaffVO;
import com.gic.qcloud.BucketNameEnum;
import com.gic.web.common.download.DownloadTask;
......@@ -31,6 +34,8 @@ import com.gic.web.common.download.DownloadTaskUtil;
import com.gic.web.common.download.constants.TaskTypeEnum;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -48,40 +53,43 @@ import java.util.stream.Collectors;
@RequestMapping("/qw-open")
public class QywxOpenController {
private static final Logger log = LogManager.getLogger(QywxOpenController.class);
@Autowired
private OpenStaffApiService openStaffApiService ;
private OpenStaffApiService openStaffApiService;
@Autowired
private StaffApiService staffApiService ;
private StaffApiService staffApiService;
@Autowired
private StaffClerkRelationApiService staffClerkRelationApiService ;
private StaffClerkRelationApiService staffClerkRelationApiService;
@Autowired
private EnterpriseService enterpriseService ;
private EnterpriseService enterpriseService;
@Autowired
private OpenStaffExcelHandler openStaffExcelHandler ;
private OpenStaffExcelHandler openStaffExcelHandler;
@Autowired
private EnterpriseUseForbidService enterpriseUseForbidService;
/**
* 托管列表
*
* @param qo
* @return
*/
@RequestMapping("open-staff-page")
public RestResponse<Page<OpenStaffVO>> page(@RequestBody OpenStaffQO qo) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
OpenStaffPageQDTO qdto = EntityUtil.changeEntityByJSON(OpenStaffPageQDTO.class,qo) ;
String enterpriseId = loginUser.getEnterpriseId() ;
OpenStaffPageQDTO qdto = EntityUtil.changeEntityByJSON(OpenStaffPageQDTO.class, qo);
String enterpriseId = loginUser.getEnterpriseId();
qdto.setWxEnterpriseId(loginUser.getWxEnterpriseId());
qdto.setEnterpriseId(enterpriseId);
BasePageInfo basePageInfo = new BasePageInfo() ;
BasePageInfo basePageInfo = new BasePageInfo();
basePageInfo.setPageNum(qo.getPageNum());
basePageInfo.setPageSize(qo.getPageSize());
ServiceResponse<Page<OpenStaffListDTO>> pageResp = this.openStaffApiService.page(qdto, basePageInfo);
Page<OpenStaffListDTO> page = pageResp.getResult();
Page<OpenStaffVO> retPage = PageHelperUtils.changePageToCurrentPage(page, OpenStaffVO.class);
if(CollectionUtils.isNotEmpty(retPage.getResult())) {
EnterpriseDTO en = this.enterpriseService.getEnterpriseById(enterpriseId) ;
retPage.getResult().forEach(o->{
if (CollectionUtils.isNotEmpty(retPage.getResult())) {
EnterpriseDTO en = this.enterpriseService.getEnterpriseById(enterpriseId);
retPage.getResult().forEach(o -> {
o.setBrandName(en.getBrandName());
});
}
......@@ -90,20 +98,21 @@ public class QywxOpenController {
/**
* 托管列表导出
*
* @param qo
* @return
*/
@RequestMapping("open-staff-excel")
public RestResponse<String> excel(@RequestBody OpenStaffQO qo) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
OpenStaffPageQDTO qdto = EntityUtil.changeEntityByJSON(OpenStaffPageQDTO.class,qo) ;
OpenStaffPageQDTO qdto = EntityUtil.changeEntityByJSON(OpenStaffPageQDTO.class, qo);
qdto.setWxEnterpriseId(loginUser.getWxEnterpriseId());
qdto.setEnterpriseId(loginUser.getEnterpriseId());
BasePageInfo basePageInfo = new BasePageInfo() ;
BasePageInfo basePageInfo = new BasePageInfo();
basePageInfo.setPageNum(1);
basePageInfo.setPageSize(1);
ServiceResponse<Page<OpenStaffListDTO>> pageResp =this.openStaffApiService.page(qdto,basePageInfo) ;
final int totalCount = pageResp.getResult().getTotalCount() ;
ServiceResponse<Page<OpenStaffListDTO>> pageResp = this.openStaffApiService.page(qdto, basePageInfo);
final int totalCount = pageResp.getResult().getTotalCount();
if (totalCount == 0) {
return RestResponse.failure("9999", "导出数据条数为0");
}
......@@ -111,10 +120,10 @@ public class QywxOpenController {
user.setUserId(loginUser.getClerkId());
user.setEnterpriseId(loginUser.getEnterpriseId());
user.setRealName(loginUser.getClerkName());
String fileName = "好办托管企微号" ;
String fileName = "好办托管企微号";
Date startDate = new Date();
Date endDate = new Date() ;
if(null != startDate && null != endDate) {
Date endDate = new Date();
if (null != startDate && null != endDate) {
fileName = "好办托管企微号" + "-" + DateUtil.formatString(startDate, "yyyy-MM-dd") + "到" + DateUtil.formatString(endDate, "yyyy-MM-dd");
}
// 1.组装数据查询条件
......@@ -133,50 +142,51 @@ public class QywxOpenController {
if (jsonResponse.isSuccess()) {
reportId = (String) jsonResponse.getResult();
} else {
return RestResponse.failure("9999",jsonResponse.getErrorMessage());
return RestResponse.failure("9999", jsonResponse.getErrorMessage());
}
return RestResponse.successResult(reportId);
}
/**
* 登录初始化
*
* @param staffId
* @return
*/
@RequestMapping("login-init")
public RestResponse<OpenStaffDTO> init(String staffId , @RequestParam(defaultValue = "0") int loginAgainFlag) {
public RestResponse<OpenStaffDTO> init(String staffId, @RequestParam(defaultValue = "0") int loginAgainFlag) {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
String enterpriseId = login.getEnterpriseId() ;
if(StringUtils.isBlank(staffId)) {
return RestResponse.failure("9999","请先选择成员") ;
String enterpriseId = login.getEnterpriseId();
if (StringUtils.isBlank(staffId)) {
return RestResponse.failure("9999", "请先选择成员");
}
StaffDTO staff = this.staffApiService.selectById(staffId) ;
if(null == staff || !staff.getWxEnterpriseId().equals(wxEnterpriseId)) {
return RestResponse.failure("9999","成员不存在") ;
StaffDTO staff = this.staffApiService.selectById(staffId);
if (null == staff || !staff.getWxEnterpriseId().equals(wxEnterpriseId)) {
return RestResponse.failure("9999", "成员不存在");
}
List<StaffClerkRelationDTO> relationList = this.staffClerkRelationApiService.listByStaffId(wxEnterpriseId,staffId) ;
if(CollectionUtils.isEmpty(relationList)) {
return RestResponse.failure("9999","成员未关联导购") ;
List<StaffClerkRelationDTO> relationList = this.staffClerkRelationApiService.listByStaffId(wxEnterpriseId, staffId);
if (CollectionUtils.isEmpty(relationList)) {
return RestResponse.failure("9999", "成员未关联导购");
}
relationList = relationList.stream().filter(o->o.getClerkType() <=1 && o.getEnterpriseId().equals(enterpriseId)).collect(Collectors.toList());
if(CollectionUtils.isEmpty(relationList)) {
return RestResponse.failure("9999","成员需关联gic商户下导购") ;
relationList = relationList.stream().filter(o -> o.getClerkType() <= 1 && o.getEnterpriseId().equals(enterpriseId)).collect(Collectors.toList());
if (CollectionUtils.isEmpty(relationList)) {
return RestResponse.failure("9999", "成员需关联gic商户下导购");
}
String checkMsg = this.check(wxEnterpriseId,enterpriseId) ;
if(null != this.check(wxEnterpriseId,enterpriseId)) {
return RestResponse.failure("9999",checkMsg) ;
String checkMsg = this.check(wxEnterpriseId, enterpriseId);
if (null != this.check(wxEnterpriseId, enterpriseId)) {
return RestResponse.failure("9999", checkMsg);
}
OpenStaffInitQDTO initQDTO = new OpenStaffInitQDTO() ;
OpenStaffInitQDTO initQDTO = new OpenStaffInitQDTO();
initQDTO.setWxEnterpriseId(wxEnterpriseId);
initQDTO.setEnterpriseId(enterpriseId);
initQDTO.setStaffId(staffId);
initQDTO.setLoginAgainFlag(loginAgainFlag);
ServiceResponse<OpenStaffDTO> resp = this.openStaffApiService.init(initQDTO) ;
if(!resp.isSuccess()) {
return RestResponse.failure("9999",resp.getMessage()) ;
ServiceResponse<OpenStaffDTO> resp = this.openStaffApiService.init(initQDTO);
if (!resp.isSuccess()) {
return RestResponse.failure("9999", resp.getMessage());
}
OpenStaffDTO openStaffDTO = resp.getResult() ;
OpenStaffDTO openStaffDTO = resp.getResult();
openStaffDTO.setStaffHeadImg(staff.getHeadImg());
openStaffDTO.setStaffName(staff.getStaffName());
return RestResponse.successResult(openStaffDTO);
......@@ -184,17 +194,18 @@ public class QywxOpenController {
/**
* 获取账号详情
*
* @param openStaffId
* @return
*/
@RequestMapping("get-open-staff")
public RestResponse<OpenStaffDTO> getOpenStaff(Long openStaffId) {
ServiceResponse<OpenStaffDTO> resp = this.openStaffApiService.getById(openStaffId) ;
if(!resp.isSuccess()) {
return RestResponse.failure("9999",resp.getMessage()) ;
ServiceResponse<OpenStaffDTO> resp = this.openStaffApiService.getById(openStaffId);
if (!resp.isSuccess()) {
return RestResponse.failure("9999", resp.getMessage());
}
OpenStaffDTO openStaffDTO = resp.getResult() ;
StaffDTO staff = this.staffApiService.selectById(openStaffDTO.getStaffId()) ;
OpenStaffDTO openStaffDTO = resp.getResult();
StaffDTO staff = this.staffApiService.selectById(openStaffDTO.getStaffId());
openStaffDTO.setStaffHeadImg(staff.getHeadImg());
openStaffDTO.setStaffName(staff.getStaffName());
return RestResponse.successResult(openStaffDTO);
......@@ -202,29 +213,31 @@ public class QywxOpenController {
/**
* 校验验证码
*
* @param openStaffId
* @param code
* @return
*/
@RequestMapping("check-code")
public RestResponse<Void> checkCode(Long openStaffId , String code) {
ServiceResponse<Void> resp = this.openStaffApiService.checkCode(openStaffId,code) ;
if(!resp.isSuccess()) {
return RestResponse.failure("9999",resp.getMessage()) ;
public RestResponse<Void> checkCode(Long openStaffId, String code) {
ServiceResponse<Void> resp = this.openStaffApiService.checkCode(openStaffId, code);
if (!resp.isSuccess()) {
return RestResponse.failure("9999", resp.getMessage());
}
return RestResponse.successResult();
}
/**
* 获取2次验证二维码
*
* @param openStaffId
* @return
*/
@RequestMapping("get-2qrcode")
public RestResponse<OpenStaffDTO> get2Qrcode(Long openStaffId) {
ServiceResponse<OpenStaffDTO> resp = this.openStaffApiService.get2Qrcode(openStaffId) ;
if(!resp.isSuccess()) {
return RestResponse.failure("9999",resp.getMessage()) ;
ServiceResponse<OpenStaffDTO> resp = this.openStaffApiService.get2Qrcode(openStaffId);
if (!resp.isSuccess()) {
return RestResponse.failure("9999", resp.getMessage());
}
return RestResponse.successResult(resp.getResult());
}
......@@ -236,43 +249,71 @@ public class QywxOpenController {
public RestResponse<OpenStaffLicenseDTO> licenseInfo() {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
String enterpriseId = login.getEnterpriseId() ;
ServiceResponse<OpenStaffLicenseDTO> resp = this.openStaffApiService.getLicenseInfo(wxEnterpriseId,enterpriseId) ;
if(!resp.isSuccess()) {
return RestResponse.failure("9999",resp.getMessage()) ;
String enterpriseId = login.getEnterpriseId();
ServiceResponse<OpenStaffLicenseDTO> resp = this.openStaffApiService.getLicenseInfo(wxEnterpriseId, enterpriseId);
if (!resp.isSuccess()) {
return RestResponse.failure("9999", resp.getMessage());
}
return RestResponse.successResult(resp.getResult());
}
/**
* 删除托管
*
* @return
*/
@RequestMapping("del-open-staff")
public RestResponse<Void> delOpenStaff(Long openStaffId) {
ServiceResponse<Void> resp = this.openStaffApiService.delete(openStaffId) ;
if(!resp.isSuccess()) {
return RestResponse.failure("9999",resp.getMessage()) ;
ServiceResponse<Void> resp = this.openStaffApiService.delete(openStaffId);
if (!resp.isSuccess()) {
return RestResponse.failure("9999", resp.getMessage());
}
return RestResponse.successResult();
}
/**
* 取消授权
*
* @return
*/
@RequestMapping("cancel-open-staff")
public RestResponse<Void> cancelOpenStaff(Long openStaffId) {
ServiceResponse<Void> resp = this.openStaffApiService.logout(openStaffId) ;
if(!resp.isSuccess()) {
return RestResponse.failure("9999",resp.getMessage()) ;
ServiceResponse<Void> resp = this.openStaffApiService.logout(openStaffId);
if (!resp.isSuccess()) {
return RestResponse.failure("9999", resp.getMessage());
}
return RestResponse.successResult();
}
private String check(String wxEnterpriseId , String enterpriseId) {
ServiceResponse<EnterpriseUsingPermissionDto> resp = this.enterpriseUseForbidService.getWxEnterpriseService(enterpriseId,wxEnterpriseId) ;
private String check(String wxEnterpriseId, String enterpriseId) {
OpenQwAccountInfoVO vo = this.getCheckInfo(wxEnterpriseId,enterpriseId) ;
if(vo.getStatus() == 1) {
return null ;
}
return null ;
}
private OpenQwAccountInfoVO getCheckInfo(String wxEnterpriseId, String enterpriseId) {
OpenQwAccountInfoVO vo = new OpenQwAccountInfoVO();
ServiceResponse<EnterpriseUsingPermissionDto> resp = this.enterpriseUseForbidService.getWxEnterpriseService(enterpriseId, wxEnterpriseId);
log.info("托管许可={}", JSONObject.toJSONString(resp));
if (resp.isSuccess()) {
EnterpriseUsingPermissionDto dto = resp.getResult();
if (null == dto) {
vo.setStatus(0);
} else {
vo.setExpireDate(dto.getServiceEndDate());
vo.setStatus(1);
if (dto.getServiceEndDate().before(new Date())) {
vo.setStatus(2);
}
String json = dto.getModuleSetting();
WechatWorkServiceSetting bo = JSONObject.parseObject(json, WechatWorkServiceSetting.class);
vo.setGiceTotal(bo.getAccountNumber());
}
}
log.info("OpenQwAccountInfoVO={}", JSONObject.toJSONString(vo));
return vo;
}
}
......@@ -399,8 +399,8 @@ public class QywxOpenTaskController {
logContent3 = this.addListForLog(n1, n2, n3);
}
String logContent4 = this.storeLog(oldDTO.getMainStoreJson(), dto.getMainStoreJson(), "服务门店");
String logContent5 = this.storeLog(oldDTO.getMainStoreJson(), dto.getMainStoreJson(), "协管门店");
String logContent6 = this.storeLog(oldDTO.getMainStoreJson(), dto.getMainStoreJson(), "指定门店");
String logContent5 = this.storeLog(oldDTO.getOtherStoreJson(), dto.getOtherStoreJson(), "协管门店");
String logContent6 = this.storeLog(oldDTO.getAssignStoreJson(), dto.getAssignStoreJson(), "指定门店");
String logContent = this.addListForLog(logContent1, logContent2, logContent3, logContent4, logContent5, logContent6);
if (StringUtils.isNotBlank(logContent)) {
GicLogRecordEvaluationContext.putAttribute("logValue", logContent);
......
package com.gic.haoban.manage.web.vo.open;
import com.gic.haoban.manage.api.dto.OpenStaffLicenseDTO;
import java.io.Serializable;
import java.util.Date;
/**
* 托管账号信息
*/
public class OpenQwAccountInfoVO extends OpenStaffLicenseDTO implements Serializable {
// 0为购买 1已购买且有效 2已过期
private int status;
/**
* 到期时间
*/
private Date expireDate;
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public Date getExpireDate() {
return expireDate;
}
public void setExpireDate(Date expireDate) {
this.expireDate = expireDate;
}
}
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