|
|
|
@ -1,20 +1,15 @@
|
|
|
|
|
package com.kiisoo.ic.store.service;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import com.kiisoo.aegis.common.faces.util.HttpUtil;
|
|
|
|
|
import com.kiisoo.ic.common.utils.MD5FileUtil;
|
|
|
|
|
import com.kiisoo.ic.common.utils.httpClientUtil.HttpClientUtil;
|
|
|
|
|
import com.kiisoo.ic.common.utils.httpClientUtil.HttpResult;
|
|
|
|
|
import com.kiisoo.ic.config.WxCpConfiguration;
|
|
|
|
|
import com.kiisoo.ic.customer.bean.OpCustomerDTO;
|
|
|
|
|
import com.kiisoo.ic.customer.service.CustomerViewService;
|
|
|
|
|
import com.kiisoo.ic.domain.mapper.PrivilageDomainEntityDOMapper;
|
|
|
|
|
import com.kiisoo.ic.domain.service.PrivilageDomainService;
|
|
|
|
|
import com.kiisoo.ic.employee.entity.PrivilageCpUserDO;
|
|
|
|
|
import com.kiisoo.ic.employee.mapper.PrivilageCpUserDOMapper;
|
|
|
|
|
import com.kiisoo.ic.generalize.entity.PoiCustomerContactDataStat;
|
|
|
|
|
import com.kiisoo.ic.generalize.entity.PrivilageOrganizational;
|
|
|
|
@ -26,18 +21,23 @@ import com.kiisoo.ic.store.entity.*;
|
|
|
|
|
import com.kiisoo.ic.store.mapper.PoiStoreDOMapper;
|
|
|
|
|
import com.kiisoo.ic.store.mapper.PrivilageCpUserStoreDOMapper;
|
|
|
|
|
import com.kiisoo.ic.store.mapper.StorePromotionDataDOMapper;
|
|
|
|
|
import com.kiisoo.ic.utils.DateUtils;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
|
|
import me.chanjar.weixin.cp.api.WxCpExternalContactService;
|
|
|
|
|
import me.chanjar.weixin.cp.api.WxCpService;
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
@ -333,6 +333,96 @@ public class StorePromotionDataService {
|
|
|
|
|
return new PageInfo<>(results);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void downloadUserBehaviorDataExcel(Long userId, Long companyId, Long shopId, Date startDate, Date endDate, HttpServletResponse response) throws IOException {
|
|
|
|
|
Set<Long> shopIds = new HashSet<>();
|
|
|
|
|
|
|
|
|
|
if (shopId != null) {
|
|
|
|
|
//如果有店铺则查店铺
|
|
|
|
|
shopIds.add(shopId);
|
|
|
|
|
} else if (companyId != null) {
|
|
|
|
|
//如果有公司则查公司店铺
|
|
|
|
|
Set<Long> sp = customerViewService.getCompanyShop(companyId, userId);
|
|
|
|
|
shopIds.addAll(sp);
|
|
|
|
|
} else {
|
|
|
|
|
//查询用户权限店铺
|
|
|
|
|
shopIds = new HashSet<>(privilageDomainService.listUserDatePermission(userId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<PoiCustomerContactDataStat> results = poiCustomerContactDataStatMapper.selectSumDataByShopIds(shopIds,startDate,endDate);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(results)){
|
|
|
|
|
results.forEach(result -> {
|
|
|
|
|
Long storeId = result.getStoreId();
|
|
|
|
|
PoiStore poiStore = poiStoreDOMapper.selectById(storeId);
|
|
|
|
|
if (poiStore == null){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
result.setStoreName(poiStore.getName());
|
|
|
|
|
result.setStoreCode(poiStore.getCode());
|
|
|
|
|
result.setAddress(poiStore.getAddress());
|
|
|
|
|
|
|
|
|
|
//客户orgId
|
|
|
|
|
Long customerId = privilageDomainEntityDOMapper.selectDomainIdByShopEntity(storeId);
|
|
|
|
|
|
|
|
|
|
if (customerId != null){
|
|
|
|
|
PrivilageOrganizational customer = retailCompanyMapper.selectById(customerId);
|
|
|
|
|
PrivilageOrganizational company = retailCompanyMapper.selectById(customer.getParentId());
|
|
|
|
|
result.setCompanyName(company.getName());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String[] headNames = new String[]{"序号","店铺名","店铺编号","所属零售公司","新增客户数","聊天总数","发消息数","已回复聊天占比","平均回复时长","删除/拉黑成员客户数"};
|
|
|
|
|
HSSFWorkbook ws = new HSSFWorkbook();
|
|
|
|
|
Sheet hssfSheet = ws.createSheet("店铺号数据");
|
|
|
|
|
HSSFCellStyle cellStyle = ws.createCellStyle();
|
|
|
|
|
cellStyle.setWrapText(true);//设置自动换行
|
|
|
|
|
int isAdd = 0;
|
|
|
|
|
//设置列名
|
|
|
|
|
if (null != headNames && headNames.length > 0) {
|
|
|
|
|
|
|
|
|
|
Row row = hssfSheet.createRow(isAdd++);
|
|
|
|
|
for (int i = 0; i < headNames.length; i++) {
|
|
|
|
|
|
|
|
|
|
String name = headNames[i];
|
|
|
|
|
Cell cell = row.createCell(i);
|
|
|
|
|
cell.setCellValue(name);
|
|
|
|
|
}
|
|
|
|
|
isAdd++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < results.size(); i++) {
|
|
|
|
|
//创造行
|
|
|
|
|
Row row = hssfSheet.createRow(isAdd++);
|
|
|
|
|
PoiCustomerContactDataStat poiCustomerContactDataStat = results.get(i);
|
|
|
|
|
Cell orderCell = row.createCell(0);
|
|
|
|
|
orderCell.setCellValue(i + 1 +"");
|
|
|
|
|
Cell storeCell = row.createCell(1);
|
|
|
|
|
storeCell.setCellValue(poiCustomerContactDataStat.getStoreName());
|
|
|
|
|
Cell storeCodeCell = row.createCell(2);
|
|
|
|
|
storeCodeCell.setCellValue(poiCustomerContactDataStat.getStoreCode());
|
|
|
|
|
Cell companyNameCell = row.createCell(3);
|
|
|
|
|
companyNameCell.setCellValue(poiCustomerContactDataStat.getCompanyName());
|
|
|
|
|
Cell newContactCntCell = row.createCell(4);
|
|
|
|
|
newContactCntCell.setCellValue(poiCustomerContactDataStat.getNewContactCnt());
|
|
|
|
|
Cell chatCntCell = row.createCell(5);
|
|
|
|
|
chatCntCell.setCellValue(poiCustomerContactDataStat.getChatCnt());
|
|
|
|
|
Cell messageCntCell = row.createCell(6);
|
|
|
|
|
messageCntCell.setCellValue(poiCustomerContactDataStat.getMessageCnt());
|
|
|
|
|
Cell replyPercentage = row.createCell(7);
|
|
|
|
|
replyPercentage.setCellValue(poiCustomerContactDataStat.getReplyPercentage());
|
|
|
|
|
Cell avgReplyTime = row.createCell(8);
|
|
|
|
|
avgReplyTime.setCellValue(poiCustomerContactDataStat.getAvgReplyTime());
|
|
|
|
|
Cell negativeFeedbackCnt = row.createCell(9);
|
|
|
|
|
negativeFeedbackCnt.setCellValue(poiCustomerContactDataStat.getNegativeFeedbackCnt());
|
|
|
|
|
}
|
|
|
|
|
OutputStream output = response.getOutputStream();
|
|
|
|
|
response.setHeader("Content-disposition", "attachment; filename=store.xls");
|
|
|
|
|
response.setContentType("application/vnd.ms-excel");
|
|
|
|
|
ws.write(output);
|
|
|
|
|
ws.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取联系客户统计数据
|
|
|
|
|