Pārlūkot izejas kodu

Merge branch 'feature-statistics2-210705' into master

Qutong 3 gadi atpakaļ
vecāks
revīzija
f7875bfec3

+ 9 - 74
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/impl/WmDaCustomerStatisticsServiceImpl.java

@@ -1,21 +1,19 @@
 package com.qunzhixinxi.hnqz.admin.service.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qunzhixinxi.hnqz.admin.entity.*;
-import com.qunzhixinxi.hnqz.admin.enums.TenantStatus;
-import com.qunzhixinxi.hnqz.admin.service.*;
+import com.qunzhixinxi.hnqz.admin.service.SysFileService;
+import com.qunzhixinxi.hnqz.admin.service.WmDaCustomerService;
+import com.qunzhixinxi.hnqz.admin.service.WmDaCustomerStatisticsService;
 import com.qunzhixinxi.hnqz.admin.util.OsEnvUtils;
 import com.qunzhixinxi.hnqz.common.core.util.R;
 import lombok.AllArgsConstructor;
 import net.fenghaitao.AutoExcel;
 import net.fenghaitao.parameters.TemplateExportPara;
 import org.apache.commons.io.IOUtils;
-import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
@@ -50,75 +48,8 @@ public class WmDaCustomerStatisticsServiceImpl implements WmDaCustomerStatistics
 
 	private final WmDaCustomerService wmDaCustomerService;
 
-	private final WmDeptGmvRecordService wmDeptGmvRecordService;
-
-	private final WmDeptGmvService wmDeptGmvService;
-
 	private final SysFileService sysFileService;
 
-	/**
-	 * 查询当月销售列表
-	 *
-	 * @param page
-	 * @param queryWrapper
-	 * @return
-	 */
-//	@Override
-//	public IPage<WmDaCustomer> listCurrentMonthStatisticsPage(Page page, Wrapper<WmDaCustomer> queryWrapper) {
-//		LambdaQueryWrapper<WmDaCustomer> query = (LambdaQueryWrapper<WmDaCustomer>) queryWrapper;
-//		// 已上线的客户
-//		query.eq(WmDaCustomer::getCustomerStatus, TenantStatus.GOING_ONLINE);
-//		// 部门id不为空
-//		query.isNotNull(WmDaCustomer::getDeptId);
-//		IPage<WmDaCustomer> pageResult = wmDaCustomerService.page(page, queryWrapper);
-//		List<WmDaCustomer> records = pageResult.getRecords();
-//		// 当前年月和上一日
-//		String year = String.valueOf(LocalDate.now().getYear());
-//		String month = String.valueOf(LocalDate.now().getMonthValue());
-//		String day = String.valueOf(LocalDate.now().getDayOfMonth() - 1);
-//
-//		records.forEach(wmDaCustomer -> {
-//					WmDeptGmv deptGmv = wmDeptGmvService.getOne(Wrappers.<WmDeptGmv>lambdaQuery()
-//							.eq(WmDeptGmv::getDeptId, wmDaCustomer.getDeptId())
-//							.eq(WmDeptGmv::getYear, year)
-//							.eq(WmDeptGmv::getMonth, month));
-//					WmDeptGmvRecord wmDeptGmvRecord = null;
-//					if (deptGmv != null) {
-//						wmDeptGmvRecord = wmDeptGmvRecordService.getOne(Wrappers.<WmDeptGmvRecord>lambdaQuery()
-//								.eq(WmDeptGmvRecord::getGmvId, deptGmv.getId())
-//								.eq(WmDeptGmvRecord::getStatisticsDay, day));
-//					}
-//					// 加入业绩统计数据
-//					WmDaCustomerStatistics customerStatistics = new WmDaCustomerStatistics();
-//					if (wmDeptGmvRecord != null) {
-//						customerStatistics.setGmv1(wmDeptGmvRecord.getGmv1());
-//						customerStatistics.setGmv2(new BigDecimal(wmDeptGmvRecord.getGmv2() * 1.0 / 100)
-//								.setScale(2, BigDecimal.ROUND_HALF_UP));
-//						customerStatistics.setIncome(new BigDecimal(wmDeptGmvRecord.getIncome() * 1.0 / 100)
-//								.setScale(2, BigDecimal.ROUND_HALF_UP));
-//					} else {
-//						customerStatistics.setGmv1(0L);
-//						customerStatistics.setGmv2(new BigDecimal("0.00"));
-//						customerStatistics.setIncome(new BigDecimal("0.00"));
-//					}
-//					Map<String, WmDaCustomerStatistics> entRes = new HashMap<>(1);
-//					entRes.put(month, customerStatistics);
-//					wmDaCustomer.setMultiGMVStatistics(entRes);
-//					wmDaCustomer.setDeptGmvList(null);
-//				}
-//		);
-//
-//		List<WmDaCustomer> temp = records.stream().sorted((o1, o2) -> {
-//			Map<String, WmDaCustomerStatistics> o1Map = o1.getMultiGMVStatistics();
-//			BigDecimal bd1 = o1Map.get(month).getIncome();
-//			Map<String, WmDaCustomerStatistics> o2Map = o2.getMultiGMVStatistics();
-//			BigDecimal bd2 = o2Map.get(month).getIncome();
-//			return bd2.compareTo(bd1);
-//		}).collect(Collectors.toList());
-//		pageResult.setRecords(temp);
-//		return pageResult;
-//	}
-
 	/**
 	 * 查询指定月的统计列表
 	 *
@@ -140,7 +71,11 @@ public class WmDaCustomerStatisticsServiceImpl implements WmDaCustomerStatistics
 			// gmv数据
 			List<WmDeptGmv> deptGmvList = wmDaCustomer.getDeptGmvList();
 			if (CollectionUtil.isNotEmpty(deptGmvList)) {
-				deptGmvList.forEach(wmDeptGmv -> {
+				deptGmvList.stream().filter(wmDeptGmv -> {
+					// 过滤,只取指定月份区间的数据
+					int month = Integer.parseInt(wmDeptGmv.getMonth());
+					return month >= startMonth && month <= endMonth;
+				}).forEach(wmDeptGmv -> {
 					// 封装GMV数据
 					WmDaCustomerStatistics customerStatistics = new WmDaCustomerStatistics();
 					// 如果企业的积分是以分为单位,则需要转换 '分'->'元'

+ 2 - 2
hnqz-visual/hnqz-daemon-quartz/src/main/resources/mapper/WmScorePackageSettleNoteMapper.xml

@@ -29,10 +29,10 @@
 	<select id="listSettleAmountByDeptId" resultMap="wmScorePackageSettleNoteMap">
 		SELECT n.settle_amount
 		FROM wm_score_package_settle_note n
-				 LEFT JOIN sys_user u ON u.user_id = n.user_id
+				 LEFT JOIN wm_score_package p on p.id = n.package_id
 		WHERE n.settle_note_status = 1
 		  AND n.settle_amount IS NOT NULL
-		  AND u.dept_id = #{deptId}
+		  AND p.send_package_dept_id = #{deptId}
 		  AND n.sub_type = #{subType}
 		  AND n.notify_time BETWEEN #{startTime} AND #{endTime}
 	</select>

+ 1 - 1
hnqz-visual/hnqz-daemon-quartz/src/main/resources/mapper/WmTaskSettleNoteMapper.xml

@@ -32,7 +32,7 @@
 				 LEFT JOIN wm_score_package p ON p.id = n.package_id
 		WHERE settle_note_status = 1
 		  AND n.settle_amount IS NOT NULL
-		  AND p.dept_id = #{deptId}
+		  AND p.send_package_dept_id = #{deptId}
 		  AND p.sub_type = #{subType}
 		  AND n.notify_time BETWEEN #{startTime} AND #{endTime}
 	</select>