Commit 7c01d458 by 徐高华

Merge remote-tracking branch 'origin/master_xgh_加好友队列调整' into developer

Conflicts:
	haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/hm/HmQrcodeController.java
parents 8628e481 4f409ddc
package com.gic.haoban.manage.web.controller.hm;
import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import com.gic.haoban.common.utils.AuthWebRequestUtil;
import com.gic.haoban.manage.api.constants.StatisticsApolloKeyConstant;
import com.gic.haoban.manage.api.dto.hm.*;
import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeListQDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeQDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.WxUserAddLogSearchQDTO;
import com.gic.haoban.manage.api.dto.statistics.StatisticsDTO;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.api.service.hm.HmClerkRelationApiService;
import com.gic.haoban.manage.api.service.hm.HmGroupApiService;
import com.gic.haoban.manage.api.service.hm.HmQrcodeApiService;
import com.gic.haoban.manage.api.service.hm.WxUserAddLogApiService;
import com.gic.haoban.manage.api.util.DataHttpUtil;
import com.gic.haoban.manage.web.dto.HmOverviewDTO;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.hm.HmQrcodeDetailQO;
import com.gic.haoban.manage.web.qo.hm.HmQrcodeUpdateQO;
import com.gic.haoban.manage.web.qo.hm.data.HmDetailClerkListQO;
import com.gic.haoban.manage.web.qo.hm.data.HmQrcodeListQO;
import com.gic.haoban.manage.web.qo.hm.data.HmTrendQO;
import com.gic.haoban.manage.web.utils.statistics.DataStatisticsParamUtils;
import com.gic.haoban.manage.web.utils.statistics.DateUtils;
import com.gic.haoban.manage.web.vo.hm.HmDetailClerkListVO;
import com.gic.haoban.manage.web.vo.hm.HmTrendVO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
/**
* 活码(TabHaobanHmQrcode)表控制层
*
* @author mozhu
* @since 2022-07-04 15:42:20
*/
@RestController
@RequestMapping("/hm/qrcode")
public class HmQrcodeController {
private static org.apache.logging.log4j.Logger logger = LogManager.getLogger(HmQrcodeController.class);
@Autowired
private HmQrcodeApiService hmQrcodeApiService;
@Autowired
private StaffApiService staffApiService;
@Autowired
private WxUserAddLogApiService wxUserAddLogApiService;
@Autowired
private StaffClerkRelationApiService staffClerkRelationApiService;
@Autowired
private HmGroupApiService hmGroupApiService;
@Autowired
private HmClerkRelationApiService hmClerkRelationApiService;
/**
* 新增
*
* @param hmQrcodeQDTO
* @return
*/
@RequestMapping(value = "add", method = RequestMethod.POST)
public RestResponse add(@RequestBody HmQrcodeQDTO hmQrcodeQDTO) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
hmQrcodeQDTO.setCreatorId(loginUser.getClerkId());
hmQrcodeQDTO.setCreatorName(loginUser.getClerkName());
hmQrcodeQDTO.setModifierId(loginUser.getClerkId());
hmQrcodeQDTO.setModifierName(loginUser.getClerkName());
hmQrcodeQDTO.setWxEnterpriseId(loginUser.getWxEnterpriseId());
hmQrcodeQDTO.setEnterpriseId(loginUser.getEnterpriseId());
hmQrcodeQDTO.setInvokingType(1);
hmQrcodeQDTO.setWebLoginDTO(loginUser);
ServiceResponse serviceResponse = this.hmQrcodeApiService.add(hmQrcodeQDTO);
if (!"0000".equals(serviceResponse.getCode())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_DEFINE.getCode()), serviceResponse.getMessage());
}
return RestResponse.successResult();
}
@RequestMapping(value = "addList", method = RequestMethod.POST)
public RestResponse addList(@RequestBody HmQrcodeQDTO hmQrcodeQDTO) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
hmQrcodeQDTO.setCreatorId(loginUser.getClerkId());
hmQrcodeQDTO.setCreatorName(loginUser.getClerkName());
hmQrcodeQDTO.setModifierId(loginUser.getClerkId());
hmQrcodeQDTO.setModifierName(loginUser.getClerkName());
hmQrcodeQDTO.setWxEnterpriseId(loginUser.getWxEnterpriseId());
hmQrcodeQDTO.setEnterpriseId(loginUser.getEnterpriseId());
hmQrcodeQDTO.setWebLoginDTO(loginUser);
ServiceResponse serviceResponse = this.hmQrcodeApiService.addList(hmQrcodeQDTO);
if (!"0000".equals(serviceResponse.getCode())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_DEFINE.getCode()), serviceResponse.getMessage());
}
return RestResponse.successResult();
}
/**
* 修改
*
* @param hmQrcodeQDTO
* @return
*/
@RequestMapping(value = "update", method = RequestMethod.POST)
public RestResponse update(@RequestBody HmQrcodeQDTO hmQrcodeQDTO) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
hmQrcodeQDTO.setModifierId(loginUser.getClerkId());
hmQrcodeQDTO.setModifierName(loginUser.getClerkName());
hmQrcodeQDTO.setWxEnterpriseId(loginUser.getWxEnterpriseId());
hmQrcodeQDTO.setEnterpriseId(loginUser.getEnterpriseId());
hmQrcodeQDTO.setInvokingType(1);
hmQrcodeQDTO.setWebLoginDTO(loginUser);
ServiceResponse serviceResponse = this.hmQrcodeApiService.update(hmQrcodeQDTO);
if (!"0000".equals(serviceResponse.getCode())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_DEFINE.getCode()), serviceResponse.getMessage());
}
return RestResponse.successResult();
}
/**
* 列表
*
* @param hmQrcodeListQO
* @return
*/
@RequestMapping(value = "list", method = RequestMethod.POST)
public RestResponse<StatisticsDTO> list(@RequestBody HmQrcodeListQO hmQrcodeListQO) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
hmQrcodeListQO.getInFields().setEnterpriseId(loginUser.getEnterpriseId());
hmQrcodeListQO.getInFields().setWxEnterpriseId(loginUser.getWxEnterpriseId());
List<String> storeList = staffApiService.getHaoBanStoreIdsRolesByClerkId(loginUser.getClerkId(), loginUser.getWxEnterpriseId());
if (CollectionUtils.isEmpty(storeList)) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_100007.getCode()), HaoBanErrCode.ERR_100007.getMsg());
}
if (!storeList.contains("-1")) {
StringBuffer stringBuffer = new StringBuffer();
storeList.forEach(c -> stringBuffer.append(c).append(","));
hmQrcodeListQO.getInFields().setStoreId(stringBuffer.toString());
}
Long hmGroupId = hmQrcodeListQO.getInFields().getHmGroupId();
//-1 代表全部分组
if (hmGroupId == -1) {
hmQrcodeListQO.getInFields().setHmGroupId(null);
}
HmQrcodeListQDTO qdto = EntityUtil.changeEntityByJSON(HmQrcodeListQDTO.class, hmQrcodeListQO.getInFields());
if (!storeList.contains("-1")) {
qdto.setStoreId(storeList);
}
ServiceResponse<List<String>> listResp = this.hmQrcodeApiService.listHmIdForIndex(qdto);
logger.info("HMid列表={}", JSON.toJSONString(listResp));
List<String> hmIds = listResp.getResult();
if(CollectionUtils.isEmpty(hmIds)) {
return RestResponse.successResult(new StatisticsDTO()) ;
}
StringBuffer stringBuffer = new StringBuffer();
hmIds.forEach(c -> stringBuffer.append(c).append(","));
hmQrcodeListQO.getInFields().setHmId(stringBuffer.toString());
StatisticsDTO statisticsDTO = DataHttpUtil.post(StatisticsApolloKeyConstant.data_haoban_hm_list, hmQrcodeListQO);
List<HmQrcodeListDTO> data = JSON.parseArray(JSON.toJSONString(statisticsDTO.getData()), HmQrcodeListDTO.class);
if (CollectionUtils.isNotEmpty(data)) {
for (HmQrcodeListDTO hmQrcodeListDTO : data) {
List<HmStoreDTO> storeDTOList = new ArrayList<>();
List<HmClerkDTO> clerkDTOList = new ArrayList<>();
Long hmId = hmQrcodeListDTO.getHmId();
Integer hmType = hmQrcodeListDTO.getHmType();
if (hmType == 1) {
HmClerkDTO clerkDTO = new HmClerkDTO();
clerkDTO.setClerkName(hmQrcodeListDTO.getClerkName());
clerkDTO.setClerkId(hmQrcodeListDTO.getClerkId());
clerkDTO.setClerkCode(hmQrcodeListDTO.getClerkCode());
clerkDTOList.add(clerkDTO);
HmStoreDTO storeDTO = new HmStoreDTO();
storeDTO.setStoreId(hmQrcodeListDTO.getStoreId());
storeDTO.setStoreName(hmQrcodeListDTO.getStoreName());
storeDTO.setStoreCode(hmQrcodeListDTO.getStoreCode());
storeDTOList.add(storeDTO);
} else if (hmType == 2) {
BasePageInfo basePageInfo = new BasePageInfo();
basePageInfo.setPageNum(1);
basePageInfo.setPageSize(1000);
Page<HmClerkRelationDTO> hmClerkByHmId = hmClerkRelationApiService.getHmClerkByHmId(basePageInfo, hmId);
List<HmClerkRelationDTO> hmClerkRelationDTOList = hmClerkByHmId.getResult();
if (CollectionUtils.isNotEmpty(hmClerkRelationDTOList)) {
for (HmClerkRelationDTO hmClerkRelationDTO : hmClerkRelationDTOList) {
HmClerkDTO clerkDTO = new HmClerkDTO();
clerkDTO.setClerkName(hmClerkRelationDTO.getClerkName());
clerkDTO.setClerkId(hmClerkRelationDTO.getClerkId());
clerkDTO.setClerkCode(hmClerkRelationDTO.getClerkCode());
clerkDTOList.add(clerkDTO);
HmStoreDTO storeDTO = new HmStoreDTO();
storeDTO.setStoreId(hmClerkRelationDTO.getStoreId());
storeDTO.setStoreName(hmClerkRelationDTO.getStoreName());
storeDTO.setStoreCode(hmClerkRelationDTO.getStoreCode());
storeDTOList.add(storeDTO);
}
}
}
ServiceResponse<HmGroupDTO> hmGroupDTOServiceResponse = hmGroupApiService.queryGroupDetail(hmQrcodeListDTO.getHmGroupId());
HmGroupDTO hmGroupDTO = hmGroupDTOServiceResponse.getResult();
if (hmGroupDTO != null) {
hmQrcodeListDTO.setHmGroupName(hmGroupDTO.getGroupName());
}
if (CollectionUtils.isNotEmpty(storeDTOList)) {
//门店id去重
storeDTOList = storeDTOList.stream().filter(c-> StringUtils.isNotBlank(c.getStoreId()))
.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(HmStoreDTO::getStoreId))), ArrayList::new));
}
hmQrcodeListDTO.setClerkList(clerkDTOList);
hmQrcodeListDTO.setStoreList(storeDTOList);
}
statisticsDTO.setData(data);
}
return RestResponse.successResult(statisticsDTO);
}
/**
* 详情
*
* @param hmId
* @return
*/
@RequestMapping(value = "detail", method = RequestMethod.GET)
public RestResponse detail(Long hmId) {
HmQrcodeDTO hmQrcodeDTO = this.hmQrcodeApiService.getDetailById(hmId);
return RestResponse.successResult(hmQrcodeDTO);
}
/**
* 作废
*
* @param hmId
* @return
*/
@RequestMapping(value = "del", method = RequestMethod.DELETE)
public RestResponse del(Long hmId) {
ServiceResponse serviceResponse = this.hmQrcodeApiService.delById(hmId,1,AuthWebRequestUtil.getLoginUser());
if (!"0000".equals(serviceResponse.getCode())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_DEFINE.getCode()), serviceResponse.getMessage());
}
return RestResponse.successResult();
}
/**
* 数据统计
*
* @param hmTrendQO
* @return
*/
@RequestMapping(value = "detail-data-statistics", method = RequestMethod.POST)
public RestResponse detailDataStatistics(@RequestBody HmTrendQO hmTrendQO) throws ParseException {
Integer type = hmTrendQO.getInFields().getType();
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
hmTrendQO.getInFields().setEnterpriseId(loginUser.getEnterpriseId());
StatisticsDTO statisticsDTO = DataHttpUtil.post(StatisticsApolloKeyConstant.data_haoban_hm_overview, hmTrendQO);
HmOverviewDTO hmOverviewDTO = JSON.parseObject(JSON.toJSONString(statisticsDTO.getOne()), HmOverviewDTO.class);
HmTrendVO hmTrendVO = EntityUtil.changeEntityNew(HmTrendVO.class, hmOverviewDTO);
List<Map> list = new ArrayList<>();
if (type == 1) {
//天
StatisticsDTO dto = DataHttpUtil.post(StatisticsApolloKeyConstant.data_haoban_hm_trend_d, hmTrendQO);
list = JSON.parseArray(JSON.toJSONString(dto.getData()), Map.class);
} else if (type == 2) {
//月
StatisticsDTO dto = DataHttpUtil.post(StatisticsApolloKeyConstant.data_haoban_hm_trend_m, hmTrendQO);
list = JSON.parseArray(JSON.toJSONString(dto.getData()), Map.class);
}
if (hmTrendVO == null) {
hmTrendVO = new HmTrendVO();
hmTrendVO.setAddNum(0);
hmTrendVO.setAddNumT(0);
}
//日期补充
List<String> dateList = DateUtils.getDateList(hmTrendQO.getInFields().getStartTime(), hmTrendQO.getInFields().getEndTime(), type);
Map<String, Object> trendMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(list)) {
for (Map temp : list) {
trendMap.put((String) temp.get("bizDate"), temp.get("addNum"));
}
}
list.clear();
for (String date : dateList) {
Map vo = new HashMap();
vo.put("bizDate", date);
Object addNum = trendMap.get(date);
if (addNum == null) {
vo.put("addNum", 0);
} else {
vo.put("addNum", addNum);
}
list.add(vo);
}
hmTrendVO.setDateList(list);
return RestResponse.successResult(hmTrendVO);
}
/**
* 使用成员
*
* @return
*/
@RequestMapping(value = "detail-clerk-list", method = RequestMethod.POST)
public RestResponse detailClerkList(@RequestBody HmQrcodeDetailQO hmQrcodeDetailQO) {
Long hmId = hmQrcodeDetailQO.getHmId();
HmQrcodeDTO hmQrcodeDTO = hmQrcodeApiService.getDetailById(hmId);
if (hmQrcodeDTO == null) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_8.getCode()), HaoBanErrCode.ERR_8.getMsg());
}
Integer hmType = hmQrcodeDTO.getHmType();
Page page = new Page();
if (hmType == 1) {
List<HmDetailClerkListVO> list = new ArrayList<>();
HmDetailClerkListVO hmDetailClerkListVO = EntityUtil.changeEntityNew(HmDetailClerkListVO.class, hmQrcodeDTO);
list.add(hmDetailClerkListVO);
page.setResult(list);
page.setTotalCount(list.size());
} else if (hmType == 2) {
BasePageInfo basePageInfo = new BasePageInfo();
basePageInfo.setPageNum(hmQrcodeDetailQO.getPageNum());
basePageInfo.setPageSize(hmQrcodeDetailQO.getPageSize());
page = hmClerkRelationApiService.getHmClerkByHmId(basePageInfo, hmId);
}
return RestResponse.successResult(page);
}
/**
* 查看明细列表
*
* @param hmDetailClerkListQO
* @return
*/
@RequestMapping(value = "detail-clerk-list-page", method = RequestMethod.POST)
public RestResponse detailClerkListPage(@RequestBody HmDetailClerkListQO hmDetailClerkListQO) {
hmDetailClerkListQO.getInFields().setEnterpriseId(AuthWebRequestUtil.getLoginUser().getEnterpriseId());
Long hmId = hmDetailClerkListQO.getInFields().getHmId();
HmQrcodeDTO hmQrcodeDTO = hmQrcodeApiService.getDetailById(hmId);
if (hmQrcodeDTO == null) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_8.getCode()), HaoBanErrCode.ERR_8.getMsg());
}
Integer hmType = hmQrcodeDTO.getHmType();
StatisticsDTO statisticsDTO = null;
if (hmType == 1) {
statisticsDTO = DataHttpUtil.post(StatisticsApolloKeyConstant.data_haoban_hm_single_detail, hmDetailClerkListQO);
} else if (hmType == 2) {
statisticsDTO = DataHttpUtil.post(StatisticsApolloKeyConstant.data_haoban_hm_many_detail, hmDetailClerkListQO);
}
return DataStatisticsParamUtils.responsePage(statisticsDTO);
}
@RequestMapping(path = "/update/qrcode/group")
public RestResponse<?> batchUpdateQrcodeGroup(@RequestBody HmQrcodeUpdateQO qrcodeUpdateQo) {
ServiceResponse<Boolean> serviceResponse = hmQrcodeApiService.batchUpdateHmQrcodeGroup(qrcodeUpdateQo.getHmIds(), qrcodeUpdateQo.getGroupId());
if (!serviceResponse.isSuccess()) {
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
return RestResponse.successResult(serviceResponse.getResult());
}
/**
* 详情-查看记录
*
* @param qdto
* @return
*/
@RequestMapping(path = "/wxUserAddLog/list")
public RestResponse<?> wxUserAddLogList(@RequestBody WxUserAddLogSearchQDTO qdto) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
BasePageInfo pageInfo = new BasePageInfo();
pageInfo.setPageNum(qdto.getPageNum());
pageInfo.setPageSize(qdto.getPageSize());
qdto.setEnterpriseId(loginUser.getEnterpriseId());
qdto.setWxEnterpriseId(loginUser.getWxEnterpriseId());
ServiceResponse<Page<WxUserAddLogDTO>> page = wxUserAddLogApiService.page(qdto, pageInfo);
return RestResponse.successResult(page.getResult());
}
/**
* @return
* @throws
* @Title: getAddCount
* @Description: 新增全部返回的数量
* @author xugh
*/
@RequestMapping(path = "/getAddCount")
public RestResponse<?> getAddCount() {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
String enterpriseId = loginUser.getEnterpriseId();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
String clerkId = loginUser.getClerkId();
int count = this.staffClerkRelationApiService.getCanAddHmCount(wxEnterpriseId, enterpriseId, clerkId);
return RestResponse.successResult(count);
}
}
package com.gic.haoban.manage.web.controller.hm;
import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import com.gic.haoban.common.utils.AuthWebRequestUtil;
import com.gic.haoban.manage.api.constants.StatisticsApolloKeyConstant;
import com.gic.haoban.manage.api.dto.hm.*;
import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeListQDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeQDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.WxUserAddLogSearchQDTO;
import com.gic.haoban.manage.api.dto.statistics.StatisticsDTO;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.api.service.hm.HmClerkRelationApiService;
import com.gic.haoban.manage.api.service.hm.HmGroupApiService;
import com.gic.haoban.manage.api.service.hm.HmQrcodeApiService;
import com.gic.haoban.manage.api.service.hm.WxUserAddLogApiService;
import com.gic.haoban.manage.api.util.DataHttpUtil;
import com.gic.haoban.manage.web.dto.HmOverviewDTO;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.hm.HmQrcodeDetailQO;
import com.gic.haoban.manage.web.qo.hm.HmQrcodeUpdateQO;
import com.gic.haoban.manage.web.qo.hm.data.HmDetailClerkListQO;
import com.gic.haoban.manage.web.qo.hm.data.HmQrcodeListQO;
import com.gic.haoban.manage.web.qo.hm.data.HmTrendQO;
import com.gic.haoban.manage.web.utils.statistics.DataStatisticsParamUtils;
import com.gic.haoban.manage.web.utils.statistics.DateUtils;
import com.gic.haoban.manage.web.vo.hm.HmDetailClerkListVO;
import com.gic.haoban.manage.web.vo.hm.HmTrendVO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
/**
* 活码(TabHaobanHmQrcode)表控制层
*
* @author mozhu
* @since 2022-07-04 15:42:20
*/
@RestController
@RequestMapping("/hm/qrcode")
public class HmQrcodeController {
private static org.apache.logging.log4j.Logger logger = LogManager.getLogger(HmQrcodeController.class);
@Autowired
private HmQrcodeApiService hmQrcodeApiService;
@Autowired
private StaffApiService staffApiService;
@Autowired
private WxUserAddLogApiService wxUserAddLogApiService;
@Autowired
private StaffClerkRelationApiService staffClerkRelationApiService;
@Autowired
private HmGroupApiService hmGroupApiService;
@Autowired
private HmClerkRelationApiService hmClerkRelationApiService;
/**
* 新增
*
* @param hmQrcodeQDTO
* @return
*/
@RequestMapping(value = "add", method = RequestMethod.POST)
public RestResponse add(@RequestBody HmQrcodeQDTO hmQrcodeQDTO) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
hmQrcodeQDTO.setCreatorId(loginUser.getClerkId());
hmQrcodeQDTO.setCreatorName(loginUser.getClerkName());
hmQrcodeQDTO.setModifierId(loginUser.getClerkId());
hmQrcodeQDTO.setModifierName(loginUser.getClerkName());
hmQrcodeQDTO.setWxEnterpriseId(loginUser.getWxEnterpriseId());
hmQrcodeQDTO.setEnterpriseId(loginUser.getEnterpriseId());
hmQrcodeQDTO.setInvokingType(1);
hmQrcodeQDTO.setWebLoginDTO(loginUser);
ServiceResponse serviceResponse = this.hmQrcodeApiService.add(hmQrcodeQDTO);
if (!"0000".equals(serviceResponse.getCode())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_DEFINE.getCode()), serviceResponse.getMessage());
}
return RestResponse.successResult();
}
@RequestMapping(value = "addList", method = RequestMethod.POST)
public RestResponse addList(@RequestBody HmQrcodeQDTO hmQrcodeQDTO) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
hmQrcodeQDTO.setCreatorId(loginUser.getClerkId());
hmQrcodeQDTO.setCreatorName(loginUser.getClerkName());
hmQrcodeQDTO.setModifierId(loginUser.getClerkId());
hmQrcodeQDTO.setModifierName(loginUser.getClerkName());
hmQrcodeQDTO.setWxEnterpriseId(loginUser.getWxEnterpriseId());
hmQrcodeQDTO.setEnterpriseId(loginUser.getEnterpriseId());
hmQrcodeQDTO.setWebLoginDTO(loginUser);
ServiceResponse serviceResponse = this.hmQrcodeApiService.addList(hmQrcodeQDTO);
if (!"0000".equals(serviceResponse.getCode())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_DEFINE.getCode()), serviceResponse.getMessage());
}
return RestResponse.successResult();
}
/**
* 修改
*
* @param hmQrcodeQDTO
* @return
*/
@RequestMapping(value = "update", method = RequestMethod.POST)
public RestResponse update(@RequestBody HmQrcodeQDTO hmQrcodeQDTO) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
hmQrcodeQDTO.setModifierId(loginUser.getClerkId());
hmQrcodeQDTO.setModifierName(loginUser.getClerkName());
hmQrcodeQDTO.setWxEnterpriseId(loginUser.getWxEnterpriseId());
hmQrcodeQDTO.setEnterpriseId(loginUser.getEnterpriseId());
hmQrcodeQDTO.setInvokingType(1);
hmQrcodeQDTO.setWebLoginDTO(loginUser);
ServiceResponse serviceResponse = this.hmQrcodeApiService.update(hmQrcodeQDTO);
if (!"0000".equals(serviceResponse.getCode())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_DEFINE.getCode()), serviceResponse.getMessage());
}
return RestResponse.successResult();
}
/**
* 列表
*
* @param hmQrcodeListQO
* @return
*/
@RequestMapping(value = "list", method = RequestMethod.POST)
public RestResponse<StatisticsDTO> list(@RequestBody HmQrcodeListQO hmQrcodeListQO) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
hmQrcodeListQO.getInFields().setEnterpriseId(loginUser.getEnterpriseId());
hmQrcodeListQO.getInFields().setWxEnterpriseId(loginUser.getWxEnterpriseId());
List<String> storeList = staffApiService.getHaoBanStoreIdsRolesByClerkId(loginUser.getClerkId(), loginUser.getWxEnterpriseId());
if (CollectionUtils.isEmpty(storeList)) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_100007.getCode()), HaoBanErrCode.ERR_100007.getMsg());
}
if (!storeList.contains("-1")) {
StringBuffer stringBuffer = new StringBuffer();
storeList.forEach(c -> stringBuffer.append(c).append(","));
hmQrcodeListQO.getInFields().setStoreId(stringBuffer.toString());
}
Long hmGroupId = hmQrcodeListQO.getInFields().getHmGroupId();
//-1 代表全部分组
if (hmGroupId == -1) {
hmQrcodeListQO.getInFields().setHmGroupId(null);
}
HmQrcodeListQDTO qdto = EntityUtil.changeEntityByJSON(HmQrcodeListQDTO.class, hmQrcodeListQO.getInFields());
if (!storeList.contains("-1")) {
qdto.setStoreId(storeList);
}
ServiceResponse<List<String>> listResp = this.hmQrcodeApiService.listHmIdForIndex(qdto);
logger.info("HMid列表={}", JSON.toJSONString(listResp));
List<String> hmIds = listResp.getResult();
if(CollectionUtils.isEmpty(hmIds)) {
return RestResponse.successResult(new StatisticsDTO()) ;
}
// 如果是所有门店
if (!storeList.contains("-1") || null != qdto.getStartTime() || null != qdto.getHmGroupId() ||
null != qdto.getHmTypeInt() || null != qdto.getStatusFlagInt() || StringUtils.isNotBlank(qdto.getClerkSelect())
|| StringUtils.isNotBlank(qdto.getStoreSelect()) || StringUtils.isNotBlank(qdto.getHmSelect())) {
StringBuffer stringBuffer = new StringBuffer();
hmIds.forEach(c -> stringBuffer.append(c).append(","));
hmQrcodeListQO.getInFields().setHmId(stringBuffer.toString());
}
StatisticsDTO statisticsDTO = DataHttpUtil.post(StatisticsApolloKeyConstant.data_haoban_hm_list, hmQrcodeListQO);
List<HmQrcodeListDTO> data = JSON.parseArray(JSON.toJSONString(statisticsDTO.getData()), HmQrcodeListDTO.class);
if (CollectionUtils.isNotEmpty(data)) {
for (HmQrcodeListDTO hmQrcodeListDTO : data) {
List<HmStoreDTO> storeDTOList = new ArrayList<>();
List<HmClerkDTO> clerkDTOList = new ArrayList<>();
Long hmId = hmQrcodeListDTO.getHmId();
Integer hmType = hmQrcodeListDTO.getHmType();
if (hmType == 1) {
HmClerkDTO clerkDTO = new HmClerkDTO();
clerkDTO.setClerkName(hmQrcodeListDTO.getClerkName());
clerkDTO.setClerkId(hmQrcodeListDTO.getClerkId());
clerkDTO.setClerkCode(hmQrcodeListDTO.getClerkCode());
clerkDTOList.add(clerkDTO);
HmStoreDTO storeDTO = new HmStoreDTO();
storeDTO.setStoreId(hmQrcodeListDTO.getStoreId());
storeDTO.setStoreName(hmQrcodeListDTO.getStoreName());
storeDTO.setStoreCode(hmQrcodeListDTO.getStoreCode());
storeDTOList.add(storeDTO);
} else if (hmType == 2) {
BasePageInfo basePageInfo = new BasePageInfo();
basePageInfo.setPageNum(1);
basePageInfo.setPageSize(1000);
Page<HmClerkRelationDTO> hmClerkByHmId = hmClerkRelationApiService.getHmClerkByHmId(basePageInfo, hmId);
List<HmClerkRelationDTO> hmClerkRelationDTOList = hmClerkByHmId.getResult();
if (CollectionUtils.isNotEmpty(hmClerkRelationDTOList)) {
for (HmClerkRelationDTO hmClerkRelationDTO : hmClerkRelationDTOList) {
HmClerkDTO clerkDTO = new HmClerkDTO();
clerkDTO.setClerkName(hmClerkRelationDTO.getClerkName());
clerkDTO.setClerkId(hmClerkRelationDTO.getClerkId());
clerkDTO.setClerkCode(hmClerkRelationDTO.getClerkCode());
clerkDTOList.add(clerkDTO);
HmStoreDTO storeDTO = new HmStoreDTO();
storeDTO.setStoreId(hmClerkRelationDTO.getStoreId());
storeDTO.setStoreName(hmClerkRelationDTO.getStoreName());
storeDTO.setStoreCode(hmClerkRelationDTO.getStoreCode());
storeDTOList.add(storeDTO);
}
}
}
ServiceResponse<HmGroupDTO> hmGroupDTOServiceResponse = hmGroupApiService.queryGroupDetail(hmQrcodeListDTO.getHmGroupId());
HmGroupDTO hmGroupDTO = hmGroupDTOServiceResponse.getResult();
if (hmGroupDTO != null) {
hmQrcodeListDTO.setHmGroupName(hmGroupDTO.getGroupName());
}
if (CollectionUtils.isNotEmpty(storeDTOList)) {
//门店id去重
storeDTOList = storeDTOList.stream().filter(c-> StringUtils.isNotBlank(c.getStoreId()))
.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(HmStoreDTO::getStoreId))), ArrayList::new));
}
hmQrcodeListDTO.setClerkList(clerkDTOList);
hmQrcodeListDTO.setStoreList(storeDTOList);
}
statisticsDTO.setData(data);
}
return RestResponse.successResult(statisticsDTO);
}
/**
* 详情
*
* @param hmId
* @return
*/
@RequestMapping(value = "detail", method = RequestMethod.GET)
public RestResponse detail(Long hmId) {
HmQrcodeDTO hmQrcodeDTO = this.hmQrcodeApiService.getDetailById(hmId);
return RestResponse.successResult(hmQrcodeDTO);
}
/**
* 作废
*
* @param hmId
* @return
*/
@RequestMapping(value = "del", method = RequestMethod.DELETE)
public RestResponse del(Long hmId) {
ServiceResponse serviceResponse = this.hmQrcodeApiService.delById(hmId,1,AuthWebRequestUtil.getLoginUser());
if (!"0000".equals(serviceResponse.getCode())) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_DEFINE.getCode()), serviceResponse.getMessage());
}
return RestResponse.successResult();
}
/**
* 数据统计
*
* @param hmTrendQO
* @return
*/
@RequestMapping(value = "detail-data-statistics", method = RequestMethod.POST)
public RestResponse detailDataStatistics(@RequestBody HmTrendQO hmTrendQO) throws ParseException {
Integer type = hmTrendQO.getInFields().getType();
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
hmTrendQO.getInFields().setEnterpriseId(loginUser.getEnterpriseId());
StatisticsDTO statisticsDTO = DataHttpUtil.post(StatisticsApolloKeyConstant.data_haoban_hm_overview, hmTrendQO);
HmOverviewDTO hmOverviewDTO = JSON.parseObject(JSON.toJSONString(statisticsDTO.getOne()), HmOverviewDTO.class);
HmTrendVO hmTrendVO = EntityUtil.changeEntityNew(HmTrendVO.class, hmOverviewDTO);
List<Map> list = new ArrayList<>();
if (type == 1) {
//天
StatisticsDTO dto = DataHttpUtil.post(StatisticsApolloKeyConstant.data_haoban_hm_trend_d, hmTrendQO);
list = JSON.parseArray(JSON.toJSONString(dto.getData()), Map.class);
} else if (type == 2) {
//月
StatisticsDTO dto = DataHttpUtil.post(StatisticsApolloKeyConstant.data_haoban_hm_trend_m, hmTrendQO);
list = JSON.parseArray(JSON.toJSONString(dto.getData()), Map.class);
}
if (hmTrendVO == null) {
hmTrendVO = new HmTrendVO();
hmTrendVO.setAddNum(0);
hmTrendVO.setAddNumT(0);
}
//日期补充
List<String> dateList = DateUtils.getDateList(hmTrendQO.getInFields().getStartTime(), hmTrendQO.getInFields().getEndTime(), type);
Map<String, Object> trendMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(list)) {
for (Map temp : list) {
trendMap.put((String) temp.get("bizDate"), temp.get("addNum"));
}
}
list.clear();
for (String date : dateList) {
Map vo = new HashMap();
vo.put("bizDate", date);
Object addNum = trendMap.get(date);
if (addNum == null) {
vo.put("addNum", 0);
} else {
vo.put("addNum", addNum);
}
list.add(vo);
}
hmTrendVO.setDateList(list);
return RestResponse.successResult(hmTrendVO);
}
/**
* 使用成员
*
* @return
*/
@RequestMapping(value = "detail-clerk-list", method = RequestMethod.POST)
public RestResponse detailClerkList(@RequestBody HmQrcodeDetailQO hmQrcodeDetailQO) {
Long hmId = hmQrcodeDetailQO.getHmId();
HmQrcodeDTO hmQrcodeDTO = hmQrcodeApiService.getDetailById(hmId);
if (hmQrcodeDTO == null) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_8.getCode()), HaoBanErrCode.ERR_8.getMsg());
}
Integer hmType = hmQrcodeDTO.getHmType();
Page page = new Page();
if (hmType == 1) {
List<HmDetailClerkListVO> list = new ArrayList<>();
HmDetailClerkListVO hmDetailClerkListVO = EntityUtil.changeEntityNew(HmDetailClerkListVO.class, hmQrcodeDTO);
list.add(hmDetailClerkListVO);
page.setResult(list);
page.setTotalCount(list.size());
} else if (hmType == 2) {
BasePageInfo basePageInfo = new BasePageInfo();
basePageInfo.setPageNum(hmQrcodeDetailQO.getPageNum());
basePageInfo.setPageSize(hmQrcodeDetailQO.getPageSize());
page = hmClerkRelationApiService.getHmClerkByHmId(basePageInfo, hmId);
}
return RestResponse.successResult(page);
}
/**
* 查看明细列表
*
* @param hmDetailClerkListQO
* @return
*/
@RequestMapping(value = "detail-clerk-list-page", method = RequestMethod.POST)
public RestResponse detailClerkListPage(@RequestBody HmDetailClerkListQO hmDetailClerkListQO) {
hmDetailClerkListQO.getInFields().setEnterpriseId(AuthWebRequestUtil.getLoginUser().getEnterpriseId());
Long hmId = hmDetailClerkListQO.getInFields().getHmId();
HmQrcodeDTO hmQrcodeDTO = hmQrcodeApiService.getDetailById(hmId);
if (hmQrcodeDTO == null) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_8.getCode()), HaoBanErrCode.ERR_8.getMsg());
}
Integer hmType = hmQrcodeDTO.getHmType();
StatisticsDTO statisticsDTO = null;
if (hmType == 1) {
statisticsDTO = DataHttpUtil.post(StatisticsApolloKeyConstant.data_haoban_hm_single_detail, hmDetailClerkListQO);
} else if (hmType == 2) {
statisticsDTO = DataHttpUtil.post(StatisticsApolloKeyConstant.data_haoban_hm_many_detail, hmDetailClerkListQO);
}
return DataStatisticsParamUtils.responsePage(statisticsDTO);
}
@RequestMapping(path = "/update/qrcode/group")
public RestResponse<?> batchUpdateQrcodeGroup(@RequestBody HmQrcodeUpdateQO qrcodeUpdateQo) {
ServiceResponse<Boolean> serviceResponse = hmQrcodeApiService.batchUpdateHmQrcodeGroup(qrcodeUpdateQo.getHmIds(), qrcodeUpdateQo.getGroupId());
if (!serviceResponse.isSuccess()) {
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
return RestResponse.successResult(serviceResponse.getResult());
}
/**
* 详情-查看记录
*
* @param qdto
* @return
*/
@RequestMapping(path = "/wxUserAddLog/list")
public RestResponse<?> wxUserAddLogList(@RequestBody WxUserAddLogSearchQDTO qdto) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
BasePageInfo pageInfo = new BasePageInfo();
pageInfo.setPageNum(qdto.getPageNum());
pageInfo.setPageSize(qdto.getPageSize());
qdto.setEnterpriseId(loginUser.getEnterpriseId());
qdto.setWxEnterpriseId(loginUser.getWxEnterpriseId());
ServiceResponse<Page<WxUserAddLogDTO>> page = wxUserAddLogApiService.page(qdto, pageInfo);
return RestResponse.successResult(page.getResult());
}
/**
* @return
* @throws
* @Title: getAddCount
* @Description: 新增全部返回的数量
* @author xugh
*/
@RequestMapping(path = "/getAddCount")
public RestResponse<?> getAddCount() {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
String enterpriseId = loginUser.getEnterpriseId();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
String clerkId = loginUser.getClerkId();
int count = this.staffClerkRelationApiService.getCanAddHmCount(wxEnterpriseId, enterpriseId, clerkId);
return RestResponse.successResult(count);
}
}
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