报表功能查看

This commit is contained in:
lizhenhua 2025-08-26 16:37:09 +08:00
parent 1b186c7587
commit 162014c18a
7 changed files with 260 additions and 3 deletions

View File

@ -393,7 +393,9 @@ public class OrderPlaceMobileBusinessImplV3 implements OrderPlaceMobileBusiness
custInfo,
stagePayDTO);
unifyPayDTO.setAmount(stagePayDTO.getAmount());
unifyPayDTO.setRemark("驿站支付");
unifyPayDTO.setRemark(stagePayDTO.getRemark()+"支付");
//处理设备sn码问题
unifyPayDTO.setMachineSn( stagePayDTO.getMerchant());
return payApi.pay(unifyPayDTO);
}

View File

@ -21,4 +21,6 @@ public class StagePayMobileDTO extends OrderPayMobileDTO{
@ApiModelProperty("sourceType")
private Integer sourceType;
@ApiModelProperty("设备sn")
private String merchant;
}

View File

@ -0,0 +1,27 @@
package com.bonus.canteen.core.reportforms.beans;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class OrgConsume {
private Long orgId;
private String orgName; // 食堂名字
private BigDecimal reserveAmount = BigDecimal.ZERO; // APP预定金额
private BigDecimal canteenAmount = BigDecimal.ZERO; // 食堂消费
private BigDecimal superAmount = BigDecimal.ZERO; // 超市消费
private BigDecimal amount= BigDecimal.ZERO; //详情中都用这个字段做消费
private String startPayTime;//开始支付时间
private String endPayTime;//结束支付时间
private String custName;
private String custNameLike;
private String flowId;
private Integer flowType;
private String payTime;
/**
* 1:APP预定 2:APP消费 3:食堂消费 4:超市消费
*/
private Integer conSource;
}

View File

@ -0,0 +1,63 @@
package com.bonus.canteen.core.reportforms.controller;
import com.bonus.canteen.core.reportforms.beans.OrgConsume;
import com.bonus.canteen.core.reportforms.service.reportformsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping({"/api/v2/report"})
public class reportformsController {
private static final Logger log = LoggerFactory.getLogger(reportformsController.class);
@Resource
private reportformsService service;
@PostMapping("/consume/list")
public List<OrgConsume> list(@RequestBody OrgConsume orgConsume) {
return service.getOrgConsumeList(orgConsume);
}
/**
* 食堂预订餐接口查询
* 通过区域名称查询
* @param orgConsume
* @return
*/
@PostMapping("/consume/listByArea")
public List<OrgConsume> listByArea(@RequestBody OrgConsume orgConsume) {
//区域
String orgName = orgConsume.getOrgName();
// 去掉里面的食堂字样
if (orgName != null) {
orgName = orgName.replace("食堂", "");
orgConsume.setOrgName(orgName);
}
if(orgConsume.getConSource() == 1){
return service.getlistByH5list(orgConsume);
} else if (orgConsume.getConSource() == 3) {
return service.getlistByArealist(orgConsume);
} else if (orgConsume.getConSource() ==4 ) {
return service.getlistBySuperlist(orgConsume);
}
return null;
}
/**
* 超市预订餐接口查询
*/
@PostMapping("/consume/listBySuper")
public List<OrgConsume> listBySuper(@RequestBody OrgConsume orgConsume) {
return service.getlistBySuperlist(orgConsume);
}
/**
* H5预订餐详情查询
*/
@PostMapping("/consume/listByH5")
public List<OrgConsume> listByH5(@RequestBody OrgConsume orgConsume) {
return service.getlistByH5list(orgConsume);
}
}

View File

@ -0,0 +1,29 @@
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.OrgConsume;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import java.util.Set;
@Mapper
public interface OrgConsumeMapper {
List<Map<String, Object>> selectConsumeRecords(OrgConsume orgConsume);
List<Map<String, Object>> selectReserveRecords(OrgConsume orgConsume);
List<Map<String, String>> selectAreaOrgMap();
List<OrgConsume> getlistByArealist(OrgConsume orgConsume);
List<OrgConsume> getlistBySuperlist(OrgConsume orgConsume);
List<OrgConsume> getlistByH5list(OrgConsume orgConsume);
}

View File

@ -0,0 +1,119 @@
package com.bonus.canteen.core.reportforms.service.impl;
import com.bonus.canteen.core.reportforms.beans.OrgConsume;
import com.bonus.canteen.core.reportforms.mapper.OrgConsumeMapper;
import com.bonus.canteen.core.reportforms.service.reportformsService;
import com.bonus.common.houqin.utils.SM4EncryptUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class reportformsServiceImpl implements reportformsService {
@Resource
private OrgConsumeMapper mapper;
@Override
public List<OrgConsume> getOrgConsumeList(OrgConsume orgConsume) {
// 查询食堂超市的所有数据信息
List<Map<String, Object>> consumeRecords = mapper.selectConsumeRecords(orgConsume);
//查询预订的订单信息
List<Map<String, Object>> reserveRecords = mapper.selectReserveRecords(orgConsume);
//查询区域关联的字段信息
List<Map<String, String>> areaOrgMaps = mapper.selectAreaOrgMap();
// area -> org 映射
Map<String, String> areaToOrg = new HashMap<>();
for (Map<String, String> map : areaOrgMaps) {
areaToOrg.put(map.get("area_name"), map.get("org_name"));
}
// 初始化结果
Map<String, OrgConsume> resultMap = new HashMap<>();
for (Map<String, Object> r : reserveRecords) {
String orgName = (String) r.get("orgName");
BigDecimal reserveAmount = (r.get("reserveAmount") != null) ?
new BigDecimal(r.get("reserveAmount").toString()) : BigDecimal.ZERO;
OrgConsume oc = new OrgConsume();
oc.setOrgName(orgName);
oc.setReserveAmount(reserveAmount);
resultMap.put(orgName, oc);
}
// 合并消费记录
for (Map<String, Object> c : consumeRecords) {
String areaName = (String) c.get("areaName");
String conSource = (String) c.get("conSource");
BigDecimal amount = (c.get("amount") != null) ?
new BigDecimal(c.get("amount").toString()).abs() : BigDecimal.ZERO;
String orgName = areaToOrg.get(areaName);
if (orgName == null) {
continue; // 没有映射关系跳过
}
OrgConsume oc = resultMap.getOrDefault(orgName, new OrgConsume());
oc.setOrgName(orgName);
if ("canteen".equals(conSource)) {
oc.setCanteenAmount(oc.getCanteenAmount().add(amount));
} else if ("super".equals(conSource)) {
oc.setSuperAmount(oc.getSuperAmount().add(amount));
}
resultMap.put(orgName, oc);
}
return new ArrayList<>(resultMap.values());
}
@Override
public List<OrgConsume> getlistByArealist(OrgConsume orgConsume) {
List<OrgConsume> orgConsumes = mapper.getlistByArealist(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> getlistBySuperlist(OrgConsume orgConsume) {
List<OrgConsume> orgConsumes = mapper.getlistBySuperlist(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)
.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;
}
}

View File

@ -0,0 +1,15 @@
package com.bonus.canteen.core.reportforms.service;
import com.bonus.canteen.core.reportforms.beans.OrgConsume;
import java.util.List;
public interface reportformsService {
List<OrgConsume> getOrgConsumeList(OrgConsume orgConsume);
List<OrgConsume> getlistByArealist(OrgConsume orgConsume);
List<OrgConsume> getlistBySuperlist(OrgConsume orgConsume);
List<OrgConsume> getlistByH5list(OrgConsume orgConsume);
}