报表功能查看
This commit is contained in:
parent
4ebf60c66e
commit
5cadd2e17d
|
|
@ -59,6 +59,8 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
|
|
|
|||
|
|
@ -16,4 +16,9 @@ import java.util.List;
|
|||
public class StageRefundParam extends OrderRefundParam {
|
||||
@NotNull(message = "交易ID不能为空")
|
||||
private Long tradeId;
|
||||
|
||||
@NotNull(message = "交易地点")
|
||||
private String merchant;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
package com.bonus.canteen.core.reportforms.beans;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CanteenOrg {
|
||||
private Long orgId; // org_id
|
||||
private String orgName; // org_name
|
||||
private String orgFullName; // org_full_name
|
||||
private Long superId; // super_id
|
||||
private List<CanteenOrg> children; // 子节点
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.bonus.canteen.core.reportforms.beans;
|
||||
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class CanteenRecord extends BaseEntity {
|
||||
private Long orgId; // 主键ID
|
||||
private String orgName;
|
||||
private String custName; // 姓名
|
||||
private String custId; // 用户编号
|
||||
private String orgFullName; // 所属组织
|
||||
private String flowTypeName; // 消费情况
|
||||
private String consumeSource; // 订单类型
|
||||
private String ordDate; // 就餐日期
|
||||
private Double amount; // 订单金额
|
||||
private String phone; // 用户手机号
|
||||
private String ordTime; // 下单时间
|
||||
private String remark; // 备注
|
||||
private String startPayTime;
|
||||
private String endPayTime;
|
||||
private String flowType;
|
||||
private String[] selectedOrg;
|
||||
}
|
||||
|
|
@ -11,6 +11,9 @@ public class OrgConsume {
|
|||
private BigDecimal reserveAmount = BigDecimal.ZERO; // APP预定金额
|
||||
private BigDecimal canteenAmount = BigDecimal.ZERO; // 食堂消费
|
||||
private BigDecimal superAmount = BigDecimal.ZERO; // 超市消费
|
||||
private BigDecimal deductionAmount = BigDecimal.ZERO; // 补扣消费
|
||||
//H5消费
|
||||
private BigDecimal h5Amount = BigDecimal.ZERO;
|
||||
private BigDecimal amount= BigDecimal.ZERO; //详情中都用这个字段做消费
|
||||
private String startPayTime;//开始支付时间
|
||||
private String endPayTime;//结束支付时间
|
||||
|
|
@ -20,8 +23,9 @@ public class OrgConsume {
|
|||
private String flowId;
|
||||
private Integer flowType;
|
||||
private String payTime;
|
||||
private String orgFullName;
|
||||
/**
|
||||
* 1:APP预定 2:APP消费 3:食堂消费 4:超市消费
|
||||
* 1:APP预定 2:驿站消费 3:食堂消费 4:超市消费
|
||||
*/
|
||||
private Integer conSource;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
package com.bonus.canteen.core.reportforms.controller;
|
||||
|
||||
import com.bonus.canteen.core.reportforms.beans.CanteenOrg;
|
||||
import com.bonus.canteen.core.reportforms.beans.CanteenRecord;
|
||||
import com.bonus.canteen.core.reportforms.beans.OrgConsume;
|
||||
import com.bonus.canteen.core.reportforms.service.reportformsService;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -9,9 +13,11 @@ import org.springframework.web.bind.annotation.*;
|
|||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static com.bonus.common.core.utils.PageUtils.startPage;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({"/api/v2/report"})
|
||||
public class reportformsController {
|
||||
public class reportformsController extends BaseController {
|
||||
private static final Logger log = LoggerFactory.getLogger(reportformsController.class);
|
||||
|
||||
@Resource
|
||||
|
|
@ -20,6 +26,13 @@ public class reportformsController {
|
|||
public List<OrgConsume> list(@RequestBody OrgConsume orgConsume) {
|
||||
return service.getOrgConsumeList(orgConsume);
|
||||
}
|
||||
|
||||
@GetMapping("/consume/peoplelist")
|
||||
public TableDataInfo peoplelist(CanteenRecord orgConsume) {
|
||||
startPage();
|
||||
List<CanteenRecord> peoplelist = service.getPeoplelist(orgConsume);
|
||||
return getDataTable(peoplelist);
|
||||
}
|
||||
/**
|
||||
* 食堂预订餐接口查询
|
||||
* 通过区域名称查询
|
||||
|
|
@ -27,7 +40,7 @@ public class reportformsController {
|
|||
* @return
|
||||
*/
|
||||
@PostMapping("/consume/listByArea")
|
||||
public List<OrgConsume> listByArea(@RequestBody OrgConsume orgConsume) {
|
||||
/*public List<OrgConsume> listByArea(@RequestBody OrgConsume orgConsume) {
|
||||
//区域
|
||||
String orgName = orgConsume.getOrgName();
|
||||
// 去掉里面的“食堂”字样
|
||||
|
|
@ -36,12 +49,71 @@ public class reportformsController {
|
|||
orgConsume.setOrgName(orgName);
|
||||
}
|
||||
if(orgConsume.getConSource() == 1){
|
||||
if ("运检后勤".equals(orgName)) {
|
||||
orgName = "运检分公司";
|
||||
orgConsume.setOrgName(orgName);
|
||||
}
|
||||
return service.getlistByH5list(orgConsume);
|
||||
} else if (orgConsume.getConSource() == 3) {
|
||||
//如果是送变电工业园食堂 修改成sbd工业园
|
||||
if ("送变电工业园".equals(orgName)) {
|
||||
orgName = "sbd工业园";
|
||||
orgConsume.setOrgName(orgName);
|
||||
}
|
||||
return service.getlistByArealist(orgConsume);
|
||||
} else if (orgConsume.getConSource() ==4 ) {
|
||||
if ("送变电工业园".equals(orgName)) {
|
||||
orgName = "sbd工业园";
|
||||
orgConsume.setOrgName(orgName);
|
||||
}
|
||||
return service.getlistBySuperlist(orgConsume);
|
||||
}else if (orgConsume.getConSource() ==5){
|
||||
if ("送变电工业园".equals(orgName)) {
|
||||
orgName = "sbd工业园";
|
||||
orgConsume.setOrgName(orgName);
|
||||
return service.getDeductionlist(orgConsume);
|
||||
}
|
||||
}
|
||||
else if (orgConsume.getConSource() ==2 ) {
|
||||
//驿站消费
|
||||
return service.getlistByOtherlist(orgConsume);
|
||||
}
|
||||
return null;
|
||||
}*/
|
||||
public List<OrgConsume> listByArea(@RequestBody OrgConsume orgConsume) {
|
||||
String orgName = orgConsume.getOrgName();
|
||||
Integer conSource = orgConsume.getConSource();
|
||||
|
||||
// 统一处理机构名称
|
||||
if (orgName != null) {
|
||||
orgName = orgName.replace("食堂", "");
|
||||
|
||||
// 特殊机构名称处理
|
||||
if ("运检后勤".equals(orgName) && conSource == 1) {
|
||||
orgName = "运检分公司";
|
||||
} else if ("送变电工业园".equals(orgName) && (conSource == 3 || conSource == 4 || conSource == 5)) {
|
||||
orgName = "sbd工业园";
|
||||
}
|
||||
|
||||
orgConsume.setOrgName(orgName);
|
||||
}
|
||||
|
||||
// 根据数据源类型路由到不同的服务方法
|
||||
switch (conSource) {
|
||||
case 1:
|
||||
return service.getlistByH5list(orgConsume);
|
||||
case 2:
|
||||
return service.getlistByOtherlist(orgConsume);
|
||||
case 3:
|
||||
return service.getlistByArealist(orgConsume);
|
||||
case 4:
|
||||
return service.getlistBySuperlist(orgConsume);
|
||||
case 5:
|
||||
return service.getDeductionlist(orgConsume);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
|
|
@ -59,5 +131,12 @@ public class reportformsController {
|
|||
public List<OrgConsume> listByH5(@RequestBody OrgConsume orgConsume) {
|
||||
return service.getlistByH5list(orgConsume);
|
||||
}
|
||||
/**
|
||||
* 组织结构后台
|
||||
*/
|
||||
@GetMapping("/tree")
|
||||
public List<CanteenOrg> getOrgTree() {
|
||||
return service.getOrgTree();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,15 +2,20 @@ package com.bonus.canteen.core.reportforms.mapper;
|
|||
|
||||
import com.bonus.canteen.core.menu.vo.AppletReserveCanteenVO;
|
||||
import com.bonus.canteen.core.menu.vo.AppletWeekCanteenVO;
|
||||
import com.bonus.canteen.core.reportforms.beans.CanteenOrg;
|
||||
import com.bonus.canteen.core.reportforms.beans.CanteenRecord;
|
||||
import com.bonus.canteen.core.reportforms.beans.OrgConsume;
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.DoubleStream;
|
||||
|
||||
@Mapper
|
||||
public interface OrgConsumeMapper {
|
||||
|
|
@ -26,4 +31,16 @@ public interface OrgConsumeMapper {
|
|||
List<OrgConsume> getlistBySuperlist(OrgConsume orgConsume);
|
||||
|
||||
List<OrgConsume> getlistByH5list(OrgConsume orgConsume);
|
||||
|
||||
List<OrgConsume> getlistByOtherlist(OrgConsume orgConsume);
|
||||
|
||||
BigDecimal yzSumMoney(OrgConsume neworgConsume);
|
||||
|
||||
List<OrgConsume> getlistConsmerlist(OrgConsume orgConsume);
|
||||
|
||||
List<CanteenRecord> getPeoplelist(CanteenRecord orgConsume);
|
||||
|
||||
List<CanteenOrg> selectAllOrgs();
|
||||
|
||||
List<OrgConsume> getDeductionlist(OrgConsume orgConsume);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.bonus.canteen.core.reportforms.service.impl;
|
||||
|
||||
import com.bonus.canteen.core.reportforms.beans.CanteenOrg;
|
||||
import com.bonus.canteen.core.reportforms.beans.CanteenRecord;
|
||||
import com.bonus.canteen.core.reportforms.beans.OrgConsume;
|
||||
import com.bonus.canteen.core.reportforms.mapper.OrgConsumeMapper;
|
||||
import com.bonus.canteen.core.reportforms.service.reportformsService;
|
||||
|
|
@ -60,9 +62,25 @@ public class reportformsServiceImpl implements reportformsService {
|
|||
oc.setCanteenAmount(oc.getCanteenAmount().add(amount));
|
||||
} else if ("super".equals(conSource)) {
|
||||
oc.setSuperAmount(oc.getSuperAmount().add(amount));
|
||||
}else if("station".equals(conSource)){
|
||||
//
|
||||
//驿站支付sql查询无法达到目标,从子表重新查询
|
||||
// oc.setH5Amount(oc.getH5Amount().add(amount));
|
||||
OrgConsume neworgConsume = new OrgConsume();
|
||||
neworgConsume.setStartPayTime(orgConsume.getStartPayTime());
|
||||
neworgConsume.setEndPayTime(orgConsume.getEndPayTime());
|
||||
neworgConsume.setOrgName(orgName.replace("食堂", ""));
|
||||
List<OrgConsume> orgConsumes = getlistByOtherlist(neworgConsume);
|
||||
BigDecimal othersum = orgConsumes.stream().map(OrgConsume::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
oc.setH5Amount(othersum);
|
||||
}else if("deduction".equals(conSource)){
|
||||
oc.setDeductionAmount(oc.getDeductionAmount().add(amount));
|
||||
}
|
||||
resultMap.put(orgName, oc);
|
||||
}
|
||||
//处理驿站退款情况逻辑
|
||||
// int yzsum = mapper.yzSumMoney(orgConsume);
|
||||
|
||||
return new ArrayList<>(resultMap.values());
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +117,22 @@ public class reportformsServiceImpl implements reportformsService {
|
|||
.collect(Collectors.toList());
|
||||
return orgConsumes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrgConsume> getDeductionlist(OrgConsume orgConsume) {
|
||||
List<OrgConsume> orgConsumes = mapper.getDeductionlist(orgConsume)
|
||||
.stream()
|
||||
.peek(c -> {
|
||||
if (c.getCustName() != null && !c.getCustName().isEmpty()) {
|
||||
try {
|
||||
c.setCustName(SM4EncryptUtils.sm4Decrypt(c.getCustName()));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
return orgConsumes;
|
||||
}
|
||||
@Override
|
||||
public List<OrgConsume> getlistByH5list(OrgConsume orgConsume) {
|
||||
List<OrgConsume> orgConsumes = mapper.getlistByH5list(orgConsume)
|
||||
|
|
@ -116,4 +149,80 @@ public class reportformsServiceImpl implements reportformsService {
|
|||
.collect(Collectors.toList());
|
||||
return orgConsumes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrgConsume> getlistByOtherlist(OrgConsume orgConsume) {
|
||||
List<OrgConsume> orgConsumes = mapper.getlistByOtherlist(orgConsume)
|
||||
.stream()
|
||||
.peek(c -> {
|
||||
if (c.getCustName() != null && !c.getCustName().isEmpty()) {
|
||||
try {
|
||||
c.setCustName(SM4EncryptUtils.sm4Decrypt(c.getCustName()));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 如果列表为空,直接返回
|
||||
if (orgConsumes == null || orgConsumes.isEmpty()) {
|
||||
return orgConsumes;
|
||||
}
|
||||
// 去重退款记录(flowType=130,payTime相同保留第一次)
|
||||
Set<String> seenPayTimes = new HashSet<>();
|
||||
orgConsumes.removeIf(c -> c.getFlowType() == 130 && !seenPayTimes.add(c.getPayTime()));
|
||||
|
||||
return orgConsumes;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CanteenRecord> getPeoplelist(CanteenRecord orgConsume) {
|
||||
if(orgConsume.getCustName() != null){
|
||||
// 解密
|
||||
try {
|
||||
orgConsume.setCustName(SM4EncryptUtils.sm4Encrypt(orgConsume.getCustName()));
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
List<CanteenRecord> list = mapper.getPeoplelist(orgConsume);
|
||||
for (CanteenRecord c : list) {
|
||||
try {
|
||||
if (c.getCustName() != null && !c.getCustName().isEmpty()) {
|
||||
c.setCustName(SM4EncryptUtils.sm4Decrypt(c.getCustName()));
|
||||
}
|
||||
if (c.getPhone() != null) {
|
||||
String phone = SM4EncryptUtils.sm4Decrypt(c.getPhone());
|
||||
if (phone.length() == 11) {
|
||||
phone = phone.substring(0, 3) + "****" + phone.substring(7);
|
||||
}
|
||||
c.setPhone(phone);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CanteenOrg> getOrgTree() {
|
||||
List<CanteenOrg> all = mapper.selectAllOrgs();
|
||||
return buildTree(all, -1L); // 假设顶级 super_id = 0
|
||||
}
|
||||
|
||||
|
||||
private List<CanteenOrg> buildTree(List<CanteenOrg> list, Long parentId) {
|
||||
List<CanteenOrg> tree = new ArrayList<>();
|
||||
for (CanteenOrg org : list) {
|
||||
if (org.getSuperId().equals(parentId)) {
|
||||
org.setChildren(buildTree(list, org.getOrgId()));
|
||||
tree.add(org);
|
||||
}
|
||||
}
|
||||
return tree;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.bonus.canteen.core.reportforms.service;
|
||||
|
||||
import com.bonus.canteen.core.reportforms.beans.CanteenOrg;
|
||||
import com.bonus.canteen.core.reportforms.beans.CanteenRecord;
|
||||
import com.bonus.canteen.core.reportforms.beans.OrgConsume;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -12,4 +14,12 @@ public interface reportformsService {
|
|||
List<OrgConsume> getlistBySuperlist(OrgConsume orgConsume);
|
||||
|
||||
List<OrgConsume> getlistByH5list(OrgConsume orgConsume);
|
||||
|
||||
List<OrgConsume> getlistByOtherlist(OrgConsume orgConsume);
|
||||
|
||||
List<CanteenRecord> getPeoplelist(CanteenRecord orgConsume);
|
||||
|
||||
List<CanteenOrg> getOrgTree();
|
||||
|
||||
List<OrgConsume> getDeductionlist(OrgConsume orgConsume);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue