|
@@ -4,10 +4,14 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.fs.common.annotation.Log;
|
|
import com.fs.common.annotation.Log;
|
|
|
import com.fs.common.annotation.RepeatSubmit;
|
|
import com.fs.common.annotation.RepeatSubmit;
|
|
|
|
|
+import com.fs.common.constant.HttpStatus;
|
|
|
import com.fs.common.core.controller.BaseController;
|
|
import com.fs.common.core.controller.BaseController;
|
|
|
import com.fs.common.core.domain.AjaxResult;
|
|
import com.fs.common.core.domain.AjaxResult;
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
|
|
|
+import com.fs.common.core.page.PageDomain;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
|
|
+import com.fs.common.core.page.TableSupport;
|
|
|
|
|
+import com.fs.company.cache.ICompanyDeptCacheService;
|
|
|
import com.fs.common.enums.BusinessType;
|
|
import com.fs.common.enums.BusinessType;
|
|
|
import com.fs.common.utils.ServletUtils;
|
|
import com.fs.common.utils.ServletUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
import com.fs.common.utils.StringUtils;
|
|
@@ -38,6 +42,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
@@ -70,6 +75,8 @@ public class FsCourseRedPacketLogController extends BaseController
|
|
|
private ICompanyRechargeService rechargeService;
|
|
private ICompanyRechargeService rechargeService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ICompanyService companyService;
|
|
private ICompanyService companyService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ICompanyDeptCacheService companyDeptCacheService;
|
|
|
@Value("${cloud_host.company_name}")
|
|
@Value("${cloud_host.company_name}")
|
|
|
private String signProjectName;
|
|
private String signProjectName;
|
|
|
/**
|
|
/**
|
|
@@ -318,19 +325,66 @@ public class FsCourseRedPacketLogController extends BaseController
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 红包消耗统计(含当前企业红包余额 redPackageMoney)
|
|
|
|
|
|
|
+ * 红包消耗统计(含当前企业红包余额 redPackageMoney、部门筛选信息)
|
|
|
* @param fsCourseRedPacketLog 支持 beginTime、endTime、deptId(部门筛选,含子部门,逻辑同 qwList)
|
|
* @param fsCourseRedPacketLog 支持 beginTime、endTime、deptId(部门筛选,含子部门,逻辑同 qwList)
|
|
|
- * @return TableDataInfo,其中 ext.redPackageMoney 为当前企业红包余额
|
|
|
|
|
|
|
+ * @return TableDataInfo,ext 含 redPackageMoney;筛选部门时 ext 含 deptId、deptName;列表末尾含合计行
|
|
|
*/
|
|
*/
|
|
|
@GetMapping("/getReadPackageTotal")
|
|
@GetMapping("/getReadPackageTotal")
|
|
|
public TableDataInfo getReadPackageTotal(FsCourseRedPacketLog fsCourseRedPacketLog) {
|
|
public TableDataInfo getReadPackageTotal(FsCourseRedPacketLog fsCourseRedPacketLog) {
|
|
|
- startPage();
|
|
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
Long companyId = loginUser.getCompany().getCompanyId();
|
|
Long companyId = loginUser.getCompany().getCompanyId();
|
|
|
fsCourseRedPacketLog.setCompanyId(companyId);
|
|
fsCourseRedPacketLog.setCompanyId(companyId);
|
|
|
List<FsCourseRedPacketLogListPVO> list = fsCourseRedPacketLogService.getReadPackageTotal(fsCourseRedPacketLog);
|
|
List<FsCourseRedPacketLogListPVO> list = fsCourseRedPacketLogService.getReadPackageTotal(fsCourseRedPacketLog);
|
|
|
|
|
+
|
|
|
|
|
+ Long deptId = fsCourseRedPacketLog.getDeptId();
|
|
|
|
|
+ String deptName = null;
|
|
|
|
|
+ if (deptId != null && deptId != 0) {
|
|
|
|
|
+ deptName = companyDeptCacheService.getDeptNameById(deptId);
|
|
|
|
|
+ if ("-".equals(deptName)) {
|
|
|
|
|
+ deptName = null;
|
|
|
|
|
+ }
|
|
|
|
|
+ for (FsCourseRedPacketLogListPVO vo : list) {
|
|
|
|
|
+ vo.setDeptId(deptId);
|
|
|
|
|
+ vo.setDeptName(deptName);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ FsCourseRedPacketLogListPVO sumTotal = new FsCourseRedPacketLogListPVO();
|
|
|
|
|
+ sumTotal.setCompanyName("合计");
|
|
|
|
|
+ BigDecimal totalAmount = list.stream()
|
|
|
|
|
+ .filter(item -> item.getAmount() != null)
|
|
|
|
|
+ .map(FsCourseRedPacketLogListPVO::getAmount)
|
|
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
+ sumTotal.setAmount(totalAmount);
|
|
|
|
|
+
|
|
|
|
|
+ PageDomain pageDomain = TableSupport.buildPageRequest();
|
|
|
|
|
+ Integer pageNum = pageDomain.getPageNum();
|
|
|
|
|
+ Integer pageSize = pageDomain.getPageSize();
|
|
|
|
|
+
|
|
|
|
|
+ int total = list.size();
|
|
|
|
|
+ if (pageNum != null && pageSize != null) {
|
|
|
|
|
+ int fromIndex = (pageNum - 1) * pageSize;
|
|
|
|
|
+ int toIndex = Math.min(fromIndex + pageSize, total);
|
|
|
|
|
+ if (fromIndex < total) {
|
|
|
|
|
+ list = list.subList(fromIndex, toIndex);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ list = new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ list.add(sumTotal);
|
|
|
|
|
+
|
|
|
BigDecimal redPackageMoney = companyService.getRedPackageMoney(companyId);
|
|
BigDecimal redPackageMoney = companyService.getRedPackageMoney(companyId);
|
|
|
- return getDataTable(list).put("redPackageMoney", redPackageMoney);
|
|
|
|
|
|
|
+ TableDataInfo rspData = new TableDataInfo();
|
|
|
|
|
+ rspData.setCode(HttpStatus.SUCCESS);
|
|
|
|
|
+ rspData.setMsg("查询成功");
|
|
|
|
|
+ rspData.setRows(list);
|
|
|
|
|
+ rspData.setTotal(total);
|
|
|
|
|
+ rspData.put("redPackageMoney", redPackageMoney);
|
|
|
|
|
+ if (deptId != null && deptId != 0) {
|
|
|
|
|
+ rspData.put("deptId", deptId);
|
|
|
|
|
+ rspData.put("deptName", deptName);
|
|
|
|
|
+ }
|
|
|
|
|
+ return rspData;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|