This commit is contained in:
gaowdong 2025-05-30 13:48:26 +08:00
parent 63c88cf464
commit af3432fd7b
30 changed files with 1479 additions and 0 deletions

View File

@ -0,0 +1,86 @@
package com.bonus.canteen.core.report.controller;
import com.bonus.canteen.core.account.domain.param.AccountInfoQueryParam;
import com.bonus.canteen.core.account.domain.vo.AccInfoDetailsVO;
import com.bonus.canteen.core.report.domain.*;
import com.bonus.canteen.core.report.service.AccReportService;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.page.TableDataInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* 交易报表
*
* @author ruoyi
* @date 2025-04-14
*/
@Controller
@RequestMapping("/report/acc")
public class AccountReportController extends BaseController
{
@Autowired
private AccReportService accReportService;
@ApiOperation("查询交易流水")
@PostMapping("/balance")
@ResponseBody
public TableDataInfo balanceList(@RequestBody AccountInfoQueryParam accountInfoQueryParam)
{
startPage();
List<AccInfoDetailsVO> list = accReportService.balanceList(accountInfoQueryParam);
return getDataTable(list);
}
// @ApiOperation("账户余额汇总")
// @PostMapping({"/balance/sum"})
// public AjaxResult queryAccInfoBalanceSum(@RequestBody AccountInfoQueryParam accountInfoQueryParam) {
// return AjaxResult.success(this.accReportService.balanceListSum(accountInfoQueryParam));
// }
@ApiOperation("充值方式汇总")
@PostMapping("/recharge")
@ResponseBody
public TableDataInfo rechargeCount(@RequestBody RechargeRecordParam param)
{
startPage();
List<RechargeRecordVO> list = accReportService.rechargeCount(param);
return getDataTable(list);
}
@ApiOperation("取款汇总")
@PostMapping("/withdraw")
@ResponseBody
public TableDataInfo withdrawCount(@RequestBody WithdrawRecordParam param)
{
startPage();
List<WithdrawRecordVO> list = accReportService.selectWithdrawRecord(param);
return getDataTable(list);
}
@ApiOperation("组织收支汇总")
@PostMapping("/dept/income-outcome")
@ResponseBody
public TableDataInfo deptIncomeOutcome(@RequestBody DeptIncomeOutcomeParam param)
{
startPage();
List<DeptIncomeOutcomeVO> list = accReportService.selectDeptIncomeOutcome(param);
return getDataTable(list);
}
@ApiOperation("个人收支汇总")
@PostMapping("/user/income-outcome")
@ResponseBody
public TableDataInfo userIncomeOutcome(@RequestBody UserIncomeOutcomeParam param)
{
startPage();
List<UserIncomeOutcomeVO> list = accReportService.selectUserIncomeOutcome(param);
return getDataTable(list);
}
}

View File

@ -0,0 +1,83 @@
package com.bonus.canteen.core.report.controller;
import com.bonus.canteen.core.report.domain.*;
import com.bonus.canteen.core.report.service.TradeReportService;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.page.TableDataInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* 交易报表
*
* @author ruoyi
* @date 2025-04-14
*/
@Controller
@RequestMapping("/report/trade")
public class TradeReportController extends BaseController
{
@Autowired
private TradeReportService tradeReportService;
@ApiOperation("交易流水")
@PostMapping("/flow")
@ResponseBody
public TableDataInfo tradeFlowList(@RequestBody TradeFlowParam param)
{
startPage();
List<TradeFlowVO> list = tradeReportService.selectTradeFlow(param);
return getDataTable(list);
}
@ApiOperation("营业汇总")
@PostMapping("/revenue/operating")
@ResponseBody
public TableDataInfo selectOperatingRevenue(@RequestBody OperatingRevenueParam param)
{
startPage();
List<OperatingRevenueVO> list = tradeReportService.selectOperatingRevenue(param);
return getDataTable(list);
}
@ApiOperation("食堂档口汇总")
@PostMapping("/revenue/canteen")
@ResponseBody
public TableDataInfo selectCanteenStallRevenue(@RequestBody CanteenStallRevenueParam param)
{
startPage();
List<CanteenStallRevenueVO> list = tradeReportService.selectCanteenStallRevenue(param);
return getDataTable(list);
}
@ApiOperation("设备汇总")
@PostMapping("/revenue/device")
@ResponseBody
public TableDataInfo selectDeviceRevenue(@RequestBody DeviceRevenueParam param)
{
startPage();
List<DeviceRevenueVO> list = tradeReportService.selectDeviceRevenue(param);
return getDataTable(list);
}
@ApiOperation("个人消费汇总")
@PostMapping("/revenue/user")
@ResponseBody
public TableDataInfo selectUserRevenue(@RequestBody UserRevenueParam param)
{
startPage();
List<UserRevenueVO> list = tradeReportService.selectUserRevenue(param);
return getDataTable(list);
}
@ApiOperation("菜品销售汇总")
@PostMapping("/revenue/goods")
@ResponseBody
public TableDataInfo selectGoodsRevenue(@RequestBody GoodsRevenueParam param)
{
startPage();
List<GoodsRevenueVO> list = tradeReportService.selectGoodsRevenue(param);
return getDataTable(list);
}
}

View File

@ -0,0 +1,25 @@
package com.bonus.canteen.core.report.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class CanteenStallRevenueParam implements Serializable {
private List<Long> deptIdList;
@ApiModelProperty("开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startDateTime;
@ApiModelProperty("结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endDateTime;
public CanteenStallRevenueParam() {
this.endDateTime = LocalDateTime.now().plusDays(7);
this.startDateTime = LocalDateTime.now().minusDays(7);
}
}

View File

@ -0,0 +1,28 @@
package com.bonus.canteen.core.report.domain;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class CanteenStallRevenueVO implements Serializable {
private Long canteenId;
private Long stallId;
private String canteenAndStallName;
private int breakfastUserCount;
private int breakfastOrderCount;
private BigDecimal breakfastConsumeCount;
private int lunchUserCount;
private int lunchOrderCount;
private BigDecimal lunchConsumeCount;
private int afternoonTeaUserCount;
private int afternoonTeaOrderCount;
private BigDecimal afternoonTeaConsumeCount;
private int dinnerUserCount;
private int dinnerOrderCount;
private BigDecimal dinnerConsumeCount;
private int midnightSnackUserCount;
private int midnightSnackOrderCount;
private BigDecimal midnightSnackConsumeCount;
}

View File

@ -0,0 +1,26 @@
package com.bonus.canteen.core.report.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
@Data
public class DeptIncomeOutcomeParam implements Serializable {
@ApiModelProperty("开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startDateTime;
@ApiModelProperty("结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endDateTime;
private List<Long> deptIdList;
public DeptIncomeOutcomeParam() {
this.endDateTime = LocalDateTime.now().plusDays(7).with(LocalTime.MAX);
this.startDateTime = LocalDateTime.now().minusDays(7).with(LocalTime.MIN);
}
}

View File

@ -0,0 +1,19 @@
package com.bonus.canteen.core.report.domain;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class DeptIncomeOutcomeVO implements Serializable {
private Long deptId;
private String deptName;
private String deptFullName;
private BigDecimal walletBal;
private BigDecimal income;
private BigDecimal outcome;
private BigDecimal lastWalletBal;
private BigDecimal otherIncome;
private BigDecimal otherOutcome;
}

View File

@ -0,0 +1,26 @@
package com.bonus.canteen.core.report.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class DeviceRevenueParam implements Serializable {
private List<Long> deptIdList;
@ApiModelProperty("开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startDateTime;
@ApiModelProperty("结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endDateTime;
private String searchValue;
public DeviceRevenueParam() {
this.endDateTime = LocalDateTime.now().plusDays(7);
this.startDateTime = LocalDateTime.now().minusDays(7);
}
}

View File

@ -0,0 +1,28 @@
package com.bonus.canteen.core.report.domain;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class DeviceRevenueVO implements Serializable {
private String deviceNumber;
private String deviceSn;
private String deviceName;
private int breakfastUserCount;
private int breakfastOrderCount;
private BigDecimal breakfastConsumeCount;
private int lunchUserCount;
private int lunchOrderCount;
private BigDecimal lunchConsumeCount;
private int afternoonTeaUserCount;
private int afternoonTeaOrderCount;
private BigDecimal afternoonTeaConsumeCount;
private int dinnerUserCount;
private int dinnerOrderCount;
private BigDecimal dinnerConsumeCount;
private int midnightSnackUserCount;
private int midnightSnackOrderCount;
private BigDecimal midnightSnackConsumeCount;
}

View File

@ -0,0 +1,28 @@
package com.bonus.canteen.core.report.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class GoodsRevenueParam implements Serializable {
private List<Integer> orderDetailTypeList;
// 1:食堂 2:档口
// private Integer countType;
private List<Long> deptIdList;
@ApiModelProperty("开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startDateTime;
@ApiModelProperty("结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endDateTime;
public GoodsRevenueParam() {
this.endDateTime = LocalDateTime.now().plusDays(7);
this.startDateTime = LocalDateTime.now().minusDays(7);
}
}

View File

@ -0,0 +1,25 @@
package com.bonus.canteen.core.report.domain;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class GoodsRevenueVO implements Serializable {
private Long goodsId;
private String goodsName;
private BigDecimal salePrice;
private int breakfastQuantityCount;
private BigDecimal breakfastConsumeCount;
private int lunchQuantityCount;
private BigDecimal lunchConsumeCount;
private int afternoonTeaQuantityCount;
private BigDecimal afternoonTeaConsumeCount;
private int dinnerQuantityCount;
private BigDecimal dinnerConsumeCount;
private int midnightSnackQuantityCount;
private BigDecimal midnightSnackConsumeCount;
private int otherQuantityCount;
private BigDecimal otherConsumeCount;
}

View File

@ -0,0 +1,25 @@
package com.bonus.canteen.core.report.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class OperatingRevenueParam implements Serializable {
private List<Long> deptIdList;
@ApiModelProperty("开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startDateTime;
@ApiModelProperty("结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endDateTime;
public OperatingRevenueParam() {
this.endDateTime = LocalDateTime.now().plusDays(7);
this.startDateTime = LocalDateTime.now().minusDays(7);
}
}

View File

@ -0,0 +1,17 @@
package com.bonus.canteen.core.report.domain;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class OperatingRevenueVO implements Serializable {
private int userCount;
private int orderCount;
private BigDecimal payableAmount;
private BigDecimal discountsAmount;
private BigDecimal realAmount;
private BigDecimal personalWalletCount;
private BigDecimal subWalletCount;
}

View File

@ -0,0 +1,24 @@
package com.bonus.canteen.core.report.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.LocalTime;
@Data
public class RechargeRecordParam implements Serializable {
@ApiModelProperty("开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startDateTime;
@ApiModelProperty("结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endDateTime;
public RechargeRecordParam() {
this.endDateTime = LocalDateTime.now().plusDays(7).with(LocalTime.MAX);
this.startDateTime = LocalDateTime.now().minusDays(7).with(LocalTime.MIN);
}
}

View File

@ -0,0 +1,20 @@
package com.bonus.canteen.core.report.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class RechargeRecordVO implements Serializable {
private String statisticDate;
@JsonIgnore
private Long rechargeNum;
@JsonIgnore
private Long subNum;
private BigDecimal cashRechargeAmount;
@JsonIgnore
private BigDecimal aliRechargeAmount;
private BigDecimal subRechargeAmount;
}

View File

@ -0,0 +1,26 @@
package com.bonus.canteen.core.report.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class TradeFlowParam implements Serializable {
private String searchValue;
private List<Long> deptIdList;
@ApiModelProperty("开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startDateTime;
@ApiModelProperty("结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endDateTime;
public TradeFlowParam() {
this.endDateTime = LocalDateTime.now().plusDays(7);
this.startDateTime = LocalDateTime.now().minusDays(7);
}
}

View File

@ -0,0 +1,27 @@
package com.bonus.canteen.core.report.domain;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
public class TradeFlowVO implements Serializable {
private Long userId;
private String userName;
private Integer userType;
private String phonenumber;
private Long deptId;
private String deptName;
private String deptFullName;
private BigDecimal accountAllBal;
private LocalDateTime tradeTime;
private Integer tradeType;
private Integer payType;
private String machineSn;
private String deviceName;
private String createBy;
private BigDecimal income;
private BigDecimal outcome;
}

View File

@ -0,0 +1,27 @@
package com.bonus.canteen.core.report.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
@Data
public class UserIncomeOutcomeParam implements Serializable {
@ApiModelProperty("开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startDateTime;
@ApiModelProperty("结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endDateTime;
private List<Long> deptIdList;
private String searchValue;
public UserIncomeOutcomeParam() {
this.endDateTime = LocalDateTime.now().plusDays(7).with(LocalTime.MAX);
this.startDateTime = LocalDateTime.now().minusDays(7).with(LocalTime.MIN);
}
}

View File

@ -0,0 +1,21 @@
package com.bonus.canteen.core.report.domain;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class UserIncomeOutcomeVO implements Serializable {
private Long userId;
private String phonenumber;
private Long deptId;
private String deptName;
private String deptFullName;
private String nickName;
private BigDecimal walletBal;
private BigDecimal walletBalNow;
private BigDecimal income;
private BigDecimal outcome;
private BigDecimal lastWalletBal;
}

View File

@ -0,0 +1,26 @@
package com.bonus.canteen.core.report.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class UserRevenueParam implements Serializable {
private String searchValue;
private List<Long> deptIdList;
@ApiModelProperty("开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startDateTime;
@ApiModelProperty("结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endDateTime;
public UserRevenueParam() {
this.endDateTime = LocalDateTime.now().plusDays(7);
this.startDateTime = LocalDateTime.now().minusDays(7);
}
}

View File

@ -0,0 +1,28 @@
package com.bonus.canteen.core.report.domain;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class UserRevenueVO implements Serializable {
private Long userId;
private String nickName;
private String deptFullName;
private int breakfastUserCount;
private int breakfastOrderCount;
private BigDecimal breakfastConsumeCount;
private int lunchUserCount;
private int lunchOrderCount;
private BigDecimal lunchConsumeCount;
private int afternoonTeaUserCount;
private int afternoonTeaOrderCount;
private BigDecimal afternoonTeaConsumeCount;
private int dinnerUserCount;
private int dinnerOrderCount;
private BigDecimal dinnerConsumeCount;
private int midnightSnackUserCount;
private int midnightSnackOrderCount;
private BigDecimal midnightSnackConsumeCount;
}

View File

@ -0,0 +1,25 @@
package com.bonus.canteen.core.report.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.LocalTime;
@Data
public class WithdrawRecordParam implements Serializable {
@ApiModelProperty("开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startDateTime;
@ApiModelProperty("结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endDateTime;
private String searchValue;
public WithdrawRecordParam() {
this.endDateTime = LocalDateTime.now().plusDays(7).with(LocalTime.MAX);
this.startDateTime = LocalDateTime.now().minusDays(7).with(LocalTime.MIN);
}
}

View File

@ -0,0 +1,16 @@
package com.bonus.canteen.core.report.domain;
import lombok.Data;
import java.io.Serializable;
@Data
public class WithdrawRecordVO implements Serializable {
private Long userId;
private String nickName;
private Long deptId;
private String deptName;
private String deptFullName;
private int withdrawNum;
private double withdrawAmount;
}

View File

@ -0,0 +1,14 @@
package com.bonus.canteen.core.report.mapper;
import com.bonus.canteen.core.report.domain.*;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface AccReportMapper {
public List<RechargeRecordVO> selectRechargeRecord(@Param("param") RechargeRecordParam param);
public List<WithdrawRecordVO> selectWithdrawRecord(@Param("param") WithdrawRecordParam param);
public List<DeptIncomeOutcomeVO> selectDeptIncomeOutcome(@Param("param") DeptIncomeOutcomeParam param);
public List<UserIncomeOutcomeVO> selectUserIncomeOutcome(@Param("param") UserIncomeOutcomeParam param,
@Param("encryptedSearchValue") String encryptedSearchValue);
}

View File

@ -0,0 +1,17 @@
package com.bonus.canteen.core.report.mapper;
import com.bonus.canteen.core.report.domain.*;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TradeReportMapper {
public List<TradeFlowVO> selectTradeFlow(@Param("param")TradeFlowParam param,
@Param("encryptedSearchValue") String encryptedSearchValue);
public List<OperatingRevenueVO> selectOperatingRevenue(@Param("param") OperatingRevenueParam param);
public List<CanteenStallRevenueVO> selectCanteenStallRevenue(@Param("param")CanteenStallRevenueParam param);
public List<DeviceRevenueVO> selectDeviceRevenue(@Param("param")DeviceRevenueParam param);
public List<UserRevenueVO> selectUserRevenue(@Param("param")UserRevenueParam param,
@Param("encryptedSearchValue") String encryptedSearchValue);
public List<GoodsRevenueVO> selectGoodsRevenue(@Param("param")GoodsRevenueParam param);
}

View File

@ -0,0 +1,16 @@
package com.bonus.canteen.core.report.service;
import com.bonus.canteen.core.account.domain.param.AccountInfoQueryParam;
import com.bonus.canteen.core.account.domain.vo.AccInfoDetailsVO;
import com.bonus.canteen.core.report.domain.*;
import java.util.List;
public interface AccReportService {
List<AccInfoDetailsVO> balanceList(AccountInfoQueryParam accountInfoQueryParam);
AccInfoDetailsVO balanceListSum(AccountInfoQueryParam accountInfoQueryParam);
List<RechargeRecordVO> rechargeCount(RechargeRecordParam param);
List<WithdrawRecordVO> selectWithdrawRecord(WithdrawRecordParam param);
List<DeptIncomeOutcomeVO> selectDeptIncomeOutcome(DeptIncomeOutcomeParam param);
List<UserIncomeOutcomeVO> selectUserIncomeOutcome(UserIncomeOutcomeParam param);
}

View File

@ -0,0 +1,14 @@
package com.bonus.canteen.core.report.service;
import com.bonus.canteen.core.report.domain.*;
import java.util.List;
public interface TradeReportService {
List<TradeFlowVO> selectTradeFlow(TradeFlowParam param);
List<OperatingRevenueVO> selectOperatingRevenue(OperatingRevenueParam param);
List<CanteenStallRevenueVO> selectCanteenStallRevenue(CanteenStallRevenueParam param);
List<DeviceRevenueVO> selectDeviceRevenue(DeviceRevenueParam param);
List<UserRevenueVO> selectUserRevenue(UserRevenueParam param);
List<GoodsRevenueVO> selectGoodsRevenue(GoodsRevenueParam param);
}

View File

@ -0,0 +1,59 @@
package com.bonus.canteen.core.report.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.bonus.canteen.core.account.domain.param.AccountInfoQueryParam;
import com.bonus.canteen.core.account.domain.vo.AccInfoDetailsVO;
import com.bonus.canteen.core.account.service.IAccInfoService;
import com.bonus.canteen.core.report.domain.*;
import com.bonus.canteen.core.report.mapper.AccReportMapper;
import com.bonus.canteen.core.report.service.AccReportService;
import com.bonus.common.houqin.utils.SM4EncryptUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class AccReportServiceImpl implements AccReportService {
@Resource
AccReportMapper accReportMapper;
@Autowired
IAccInfoService accInfoService;
@Override
public List<AccInfoDetailsVO> balanceList(AccountInfoQueryParam accountInfoQueryParam) {
return accInfoService.selectAccInfoList(accountInfoQueryParam);
}
@Override
public AccInfoDetailsVO balanceListSum(AccountInfoQueryParam accountInfoQueryParam) {
return accInfoService.queryAccInfoBalanceSum(accountInfoQueryParam);
}
@Override
public List<RechargeRecordVO> rechargeCount(RechargeRecordParam param) {
return accReportMapper.selectRechargeRecord(param);
}
@Override
public List<WithdrawRecordVO> selectWithdrawRecord(WithdrawRecordParam param) {
return accReportMapper.selectWithdrawRecord(param);
}
@Override
public List<DeptIncomeOutcomeVO> selectDeptIncomeOutcome(DeptIncomeOutcomeParam param) {
return accReportMapper.selectDeptIncomeOutcome(param);
}
@Override
public List<UserIncomeOutcomeVO> selectUserIncomeOutcome(UserIncomeOutcomeParam param) {
String encryptedSearchValue = SM4EncryptUtils.sm4Encrypt(param.getSearchValue());
List<UserIncomeOutcomeVO> list = accReportMapper.selectUserIncomeOutcome(param, encryptedSearchValue);
if(CollUtil.isNotEmpty(list)) {
for (UserIncomeOutcomeVO userIncomeOutcomeVO : list) {
userIncomeOutcomeVO.setPhonenumber(SM4EncryptUtils.sm4Decrypt(userIncomeOutcomeVO.getPhonenumber()));
}
}
return list;
}
}

View File

@ -0,0 +1,54 @@
package com.bonus.canteen.core.report.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.bonus.canteen.core.report.domain.*;
import com.bonus.canteen.core.report.mapper.TradeReportMapper;
import com.bonus.canteen.core.report.service.TradeReportService;
import com.bonus.common.houqin.utils.SM4EncryptUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class TradeReportServiceImpl implements TradeReportService {
@Resource
TradeReportMapper tradeReportMapper;
@Override
public List<TradeFlowVO> selectTradeFlow(TradeFlowParam param) {
String encryptedSearchValue = SM4EncryptUtils.sm4Encrypt(param.getSearchValue());
List<TradeFlowVO> tradeFlowVOList = tradeReportMapper.selectTradeFlow(param, encryptedSearchValue);
if(CollUtil.isNotEmpty(tradeFlowVOList)) {
for(TradeFlowVO vo : tradeFlowVOList) {
vo.setPhonenumber(SM4EncryptUtils.sm4Decrypt(vo.getPhonenumber()));
}
}
return tradeFlowVOList;
}
@Override
public List<OperatingRevenueVO> selectOperatingRevenue(OperatingRevenueParam param) {
return tradeReportMapper.selectOperatingRevenue(param);
}
@Override
public List<CanteenStallRevenueVO> selectCanteenStallRevenue(CanteenStallRevenueParam param) {
return tradeReportMapper.selectCanteenStallRevenue(param);
}
@Override
public List<DeviceRevenueVO> selectDeviceRevenue(DeviceRevenueParam param) {
return tradeReportMapper.selectDeviceRevenue(param);
}
@Override
public List<UserRevenueVO> selectUserRevenue(UserRevenueParam param) {
return tradeReportMapper.selectUserRevenue(param, SM4EncryptUtils.sm4Encrypt(param.getSearchValue()));
}
@Override
public List<GoodsRevenueVO> selectGoodsRevenue(GoodsRevenueParam param) {
return tradeReportMapper.selectGoodsRevenue(param);
}
}

View File

@ -0,0 +1,254 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.canteen.core.report.mapper.AccReportMapper">
<select id="selectRechargeRecord" resultType="com.bonus.canteen.core.report.domain.RechargeRecordVO">
select
DATE_FORMAT(atwd.trade_time , '%Y-%m-%d') AS statistic_date,
count(IF(atwd.trade_type = 10, 1, NULL)) AS recharge_num,
count(IF(atwd.trade_type = 20, 1, NULL)) AS sub_num,
SUM(IF(atwd.trade_type = 10 and at2.pay_type = 2, atwd.amount, 0)) AS cash_recharge_amount,
SUM(IF(atwd.trade_type = 10 and at2.pay_type = 18, atwd.amount, 0)) AS ali_recharge_amount,
SUM(IF(atwd.trade_type = 20, atwd.amount, 0)) AS sub_recharge_amount
from
account_trade_wallet_detail atwd
Left join account_trade at2 on
atwd.trade_id = at2.trade_id
where
atwd.trade_type in (10, 20)
and atwd.trade_time <![CDATA[ >= ]]> #{param.startDateTime}
and atwd.trade_time <![CDATA[ <= ]]> #{param.endDateTime}
group by
statistic_date
order by
statistic_date desc
</select>
<select id="selectWithdrawRecord" resultType="com.bonus.canteen.core.report.domain.WithdrawRecordVO">
select
atwd.user_id,
su.nick_name,
sd.dept_id,
sd.dept_name,
sd.dept_full_name,
count(1) AS withdraw_num,
SUM(IFNULL( atwd.amount, 0)) AS withdraw_amount
from account_trade_wallet_detail atwd
LEFT JOIN sys_user su on atwd.user_id = su.user_id
LEFT JOIN sys_dept sd on su.dept_id = sd.dept_id
where atwd.trade_type in (30)
and atwd.trade_time <![CDATA[ >= ]]> #{param.startDateTime}
and atwd.trade_time <![CDATA[ <= ]]> #{param.endDateTime}
<if test="param.searchValue != null and param.searchValue != ''">
and (su.nick_name like CONCAT('%',#{param.searchValue},'%')
or su.user_id like CONCAT('%',#{param.searchValue},'%')
)
</if>
group by user_id
order by user_id
</select>
<select id="selectDeptIncomeOutcome" resultType="com.bonus.canteen.core.report.domain.DeptIncomeOutcomeVO">
SELECT
c.dept_id,
c.dept_name,
c.dept_full_name,
c.wallet_bal_dept as wallet_bal,
b.income,
b.outcome,
(c.wallet_bal_dept + b.outcome - b.income) as last_wallet_bal,
0 as other_income,
0 as other_outcome
from
(
select
sd.dept_id,
SUM(IFNULL(CASE
WHEN at2.trade_type in (10, 20, 130) then
at2.actual_amount
end, 0)) as income,
SUM(IFNULL(CASE
WHEN at2.trade_type in (30, 100, 110, 120) then
at2.actual_amount
end, 0)) as outcome
from
account_trade at2
left join sys_user su on
at2.user_id = su.user_id
left join sys_dept sd on
su.dept_id = sd.dept_id
where
at2.pay_state = 3
<if test="param.deptIdList != null and param.deptIdList.size() > 0">
and su.dept_id in
<foreach collection="param.deptIdList" item="deptId" separator="," open="(" close=")">
#{deptId}
</foreach>
</if>
and at2.trade_time <![CDATA[ >= ]]> #{param.startDateTime}
and at2.trade_time <![CDATA[ <= ]]> #{param.endDateTime}
GROUP BY
sd.dept_id
) b
left join
(
select
IFNULL(sum(a.wallet_bal), 0) as wallet_bal_dept ,
su.dept_id,
sd.dept_name,
sd.dept_full_name
from
(
select
awi.user_id,
IFNULL(sum(awi.wallet_bal), 0) as wallet_bal
from
account_wallet_info awi
group by
awi.user_id ) a
left join sys_user su on
a.user_id = su.user_id
left join sys_dept sd on
su.dept_id = sd.dept_id
where
1 = 1
<if test="param.deptIdList != null and param.deptIdList.size() > 0">
and su.dept_id in
<foreach collection="param.deptIdList" item="deptId" separator="," open="(" close=")">
#{deptId}
</foreach>
</if>
group by
su.dept_id ) c
on
c.dept_id = b.dept_id
order by c.dept_id
</select>
<select id="selectUserIncomeOutcome" resultType="com.bonus.canteen.core.report.domain.UserIncomeOutcomeVO">
SELECT
b.user_id,
b.phonenumber,
b.dept_id,
b.dept_name,
b.dept_full_name,
b.nick_name,
c.wallet_bal_user as wallet_bal,
((d.income - d.outcome) + (b.income - b.outcome)) as wallet_bal_now,
b.income,
b.outcome,
(d.income - d.outcome) as last_wallet_bal
from
(
select
su.user_id,
su.nick_name,
su.phonenumber,
sd.dept_id,
sd.dept_name,
sd.dept_full_name,
SUM(IFNULL(CASE
WHEN at2.trade_type in (10, 20, 130) then
at2.actual_amount
end, 0)) as income,
SUM(IFNULL(CASE
WHEN at2.trade_type in (30, 100, 110, 120) then
at2.actual_amount
end, 0)) as outcome
from
sys_user su
left join account_trade at2 on
at2.user_id = su.user_id
and at2.trade_time <![CDATA[ >= ]]> #{param.startDateTime}
and at2.trade_time <![CDATA[ <= ]]> #{param.endDateTime}
and at2.pay_state = 3
left join sys_dept sd on
su.dept_id = sd.dept_id
where
1 = 1
<if test="param.deptIdList != null and param.deptIdList.size() > 0">
and su.dept_id in
<foreach collection="param.deptIdList" item="deptId" separator="," open="(" close=")">
#{deptId}
</foreach>
</if>
GROUP BY
su.user_id
) b
left join
(
select
su.user_id,
su.nick_name,
su.phonenumber,
sd.dept_id,
sd.dept_name,
sd.dept_full_name,
SUM(IFNULL(CASE
WHEN at2.trade_type in (10, 20, 130) then
at2.actual_amount
end, 0)) as income,
SUM(IFNULL(CASE
WHEN at2.trade_type in (30, 100, 110, 120) then
at2.actual_amount
end, 0)) as outcome
from
sys_user su
left join account_trade at2 on
at2.user_id = su.user_id
and at2.trade_time <![CDATA[ < ]]> #{param.startDateTime}
and at2.pay_state = 3
left join sys_dept sd on
su.dept_id = sd.dept_id
where
1 = 1
<if test="param.deptIdList != null and param.deptIdList.size() > 0">
and su.dept_id in
<foreach collection="param.deptIdList" item="deptId" separator="," open="(" close=")">
#{deptId}
</foreach>
</if>
GROUP BY
su.user_id
) d on b.user_id = d.user_id
left join
(
select
IFNULL(sum(a.wallet_bal), 0) as wallet_bal_user ,
su.user_id
from
sys_user su
left join
(
select
awi.user_id,
IFNULL(sum(awi.wallet_bal), 0) as wallet_bal
from
account_wallet_info awi
group by
awi.user_id ) a
on a.user_id = su.user_id
where
1 = 1
<if test="param.deptIdList != null and param.deptIdList.size() > 0">
and su.dept_id in
<foreach collection="param.deptIdList" item="deptId" separator="," open="(" close=")">
#{deptId}
</foreach>
</if>
group by
a.user_id) c
on
c.user_id = b.user_id
where
1 = 1
<if test="param.searchValue != null and param.searchValue != ''">
and (b.nick_name like CONCAT('%',#{param.searchValue},'%')
or b.phonenumber = #{encryptedSearchValue}
or c.user_id like CONCAT('%',#{param.searchValue},'%')
)
</if>
order by outcome desc
</select>
</mapper>

View File

@ -0,0 +1,395 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.canteen.core.report.mapper.TradeReportMapper">
<select id="selectTradeFlow" resultType="com.bonus.canteen.core.report.domain.TradeFlowVO">
select
su.user_id,
su.user_name,
su.user_type,
su.phonenumber,
sd.dept_id,
sd.dept_name,
sd.dept_full_name,
at2.account_all_bal,
at2.trade_time,
at2.trade_type,
at2.pay_type,
at2.machine_sn,
di.device_name,
at2.create_by,
IFNULL(CASE
WHEN at2.trade_type in (10, 20, 130) then
at2.actual_amount
end, 0)as income,
IFNULL(CASE
WHEN at2.trade_type in (30, 100, 110) then
at2.actual_amount
end, 0) as outcome
from
account_trade at2
left join sys_user su on
at2.user_id = su.user_id
left join sys_dept sd on
su.dept_id = sd.dept_id
left join device_info di on
at2.machine_sn = di.device_sn
where
at2.pay_state = 3
and at2.trade_time <![CDATA[ >= ]]> #{param.startDateTime}
and at2.trade_time <![CDATA[ <= ]]> #{param.endDateTime}
<if test="param.deptIdList != null and param.deptIdList.size() > 0">
and su.dept_id IN
<foreach collection="param.deptIdList" item="deptId" separator="," open="(" close=")">
#{deptId}
</foreach>
</if>
<if test="param.searchValue != null and param.searchValue != ''">
and (
su.nick_name like CONCAT('%',#{param.searchValue},'%')
or su.phonenumber = #{encryptedSearchValue}
or su.user_id like concat('%', #{param.searchValue}, '%')
)
</if>
order by at2.trade_time desc
</select>
<select id="selectOperatingRevenue" resultType="com.bonus.canteen.core.report.domain.OperatingRevenueVO">
select
count(distinct oi.user_id) as user_count,
count(oi.order_id) as order_count,
sum(oi.payable_amount) as payable_amount ,
sum(oi.discounts_amount) as discounts_amount ,
sum(oi.real_amount - oi.refund_amount) as real_amount,
sum(b.personal_wallet_count) as personal_wallet_count,
sum(b.sub_wallet_count) as sub_wallet_count
from
order_info oi
left join sys_user su on
oi.user_id = su.user_id
left join (
select
ats.order_no,
sum(case when atwd.wallet_type = 1 and ats.trade_type = 110 and ats.pay_state = 3 then
ifnull(atwd.amount, 0) ELSE 0 end) -
sum(case when atwd.wallet_type = 1 and ats.trade_type = 130 and ats.pay_state = 3 then
ifnull(atwd.amount, 0) ELSE 0 end) as personal_wallet_count,
sum(case when atwd.wallet_type = 2 and ats.trade_type = 110 and ats.pay_state = 3 then
ifnull(atwd.amount, 0) ELSE 0 end) -
sum(case when atwd.wallet_type = 2 and ats.trade_type = 130 and ats.pay_state = 3 then
ifnull(atwd.amount, 0) ELSE 0 end) as sub_wallet_count
from
account_trade ats
left join account_trade_wallet_detail atwd on
ats.trade_id = atwd.trade_id
group by
ats.order_no) b on
oi.order_id = b.order_no
where oi.pay_state = 3 and oi.order_state in (1, 2)
and oi.pay_time <![CDATA[ >= ]]> #{param.startDateTime}
and oi.pay_time <![CDATA[ <= ]]> #{param.endDateTime}
<if test="param.deptIdList != null and param.deptIdList.size() > 0">
and su.dept_id IN
<foreach collection="param.deptIdList" item="deptId" separator="," open="(" close=")">
#{deptId}
</foreach>
</if>
</select>
<select id="selectCanteenStallRevenue" resultType="com.bonus.canteen.core.report.domain.CanteenStallRevenueVO">
select
oi.canteen_id,
oi.stall_id,
CONCAT(ac.canteen_name , '/', ast.stall_name) as canteenAndStallName,
count(distinct case when oi.mealtime_type = 1 then
oi.user_id else null
end) as breakfast_user_count,
count(case when oi.mealtime_type = 1 then
oi.order_id else null
end) as breakfast_order_count,
sum(case when oi.mealtime_type = 1 then
oi.real_amount - oi.refund_amount else 0
end) as breakfast_consume_count,
count(distinct case when oi.mealtime_type = 2 then
oi.user_id else null
end) as lunch_user_count,
count(case when oi.mealtime_type = 2 then
oi.order_id else null
end) as lunch_order_count,
sum(case when oi.mealtime_type = 2 then
oi.real_amount - oi.refund_amount else 0
end) as lunch_consume_count,
count(distinct case when oi.mealtime_type = 3 then
oi.user_id else null
end) as afternoon_tea_user_count,
count(case when oi.mealtime_type = 3 then
oi.order_id else null
end) as afternoon_tea_order_count,
sum(case when oi.mealtime_type = 3 then
oi.real_amount - oi.refund_amount else 0
end) as afternoon_tea_consume_count,
count(distinct case when oi.mealtime_type = 4 then
oi.user_id else null
end) as dinner_user_count,
count(case when oi.mealtime_type = 4 then
oi.order_id else null
end) as dinner_order_count,
sum(case when oi.mealtime_type = 4 then
oi.real_amount - oi.refund_amount else 0
end) as dinner_consume_count,
count(distinct case when oi.mealtime_type = 5 then
oi.user_id else null
end) as midnight_snack_user_count,
count(case when oi.mealtime_type = 5 then
oi.order_id else null
end) as midnight_snack_order_count,
sum(case when oi.mealtime_type = 5 then
oi.real_amount - oi.refund_amount else 0
end) as midnight_snack_consume_count
from
order_info oi
left join sys_user su on
oi.user_id = su.user_id
left join basic_canteen ac on
oi.canteen_id = ac.canteen_id
left join basic_stall ast on
oi.stall_id = ast.stall_id
where oi.pay_state = 3 and oi.order_state in (1, 2)
and oi.pay_time <![CDATA[ >= ]]> #{param.startDateTime}
and oi.pay_time <![CDATA[ <= ]]> #{param.endDateTime}
<if test="param.deptIdList != null and param.deptIdList.size() > 0">
and su.dept_id IN
<foreach collection="param.deptIdList" item="deptId" separator="," open="(" close=")">
#{deptId}
</foreach>
</if>
group by
oi.canteen_id,
oi.stall_id
</select>
<select id="selectDeviceRevenue" resultType="com.bonus.canteen.core.report.domain.DeviceRevenueVO">
select
di.device_number,
di.device_sn,
di.device_name,
count(distinct case when oi.mealtime_type = 1 then
oi.user_id else null
end) as breakfast_user_count,
count(case when oi.mealtime_type = 1 then
oi.order_id else null
end) as breakfast_order_count,
sum(case when oi.mealtime_type = 1 then
oi.real_amount - oi.refund_amount else 0
end) as breakfast_consume_count,
count(distinct case when oi.mealtime_type = 2 then
oi.user_id else null
end) as lunch_user_count,
count(case when oi.mealtime_type = 2 then
oi.order_id else null
end) as lunch_order_count,
sum(case when oi.mealtime_type = 2 then
oi.real_amount - oi.refund_amount else 0
end) as lunch_consume_count,
count(distinct case when oi.mealtime_type = 3 then
oi.user_id else null
end) as afternoon_tea_user_count,
count(case when oi.mealtime_type = 3 then
oi.order_id else null
end) as afternoon_tea_order_count,
sum(case when oi.mealtime_type = 3 then
oi.real_amount - oi.refund_amount else 0
end) as afternoon_tea_consume_count,
count(distinct case when oi.mealtime_type = 4 then
oi.user_id else null
end) as dinner_user_count,
count(case when oi.mealtime_type = 4 then
oi.order_id else null
end) as dinner_order_count,
sum(case when oi.mealtime_type = 4 then
oi.real_amount - oi.refund_amount else 0
end) as dinner_consume_count,
count(distinct case when oi.mealtime_type = 5 then
oi.user_id else null
end) as midnight_snack_user_count,
count(case when oi.mealtime_type = 5 then
oi.order_id else null
end) as midnight_snack_order_count,
sum(case when oi.mealtime_type = 5 then
oi.real_amount - oi.refund_amount else 0
end) as midnight_snack_consume_count
from
order_info oi
left join sys_user su on
oi.user_id = su.user_id
left join device_info di on
oi.device_sn = di.device_sn and oi.device_num = di.device_number
where oi.source_type = 20 and oi.pay_state = 3 and oi.order_state in (1, 2)
and oi.pay_time <![CDATA[ >= ]]> #{param.startDateTime}
and oi.pay_time <![CDATA[ <= ]]> #{param.endDateTime}
<if test="param.deptIdList != null and param.deptIdList.size() > 0">
and su.dept_id IN
<foreach collection="param.deptIdList" item="deptId" separator="," open="(" close=")">
#{deptId}
</foreach>
</if>
<if test="param.searchValue != null and param.searchValue != ''">
and (
di.device_number = #{param.searchValue}
or di.device_name like concat('%', #{param.searchValue}, '%')
)
</if>
group by
oi.device_sn,
oi.device_num
</select>
<select id="selectUserRevenue" resultType="com.bonus.canteen.core.report.domain.UserRevenueVO">
select
oi.user_id,
su.nick_name,
sd.dept_full_name,
count(distinct case when oi.mealtime_type = 1 then
oi.user_id else null
end) as breakfast_user_count,
count(case when oi.mealtime_type = 1 then
oi.order_id else null
end) as breakfast_order_count,
sum(case when oi.mealtime_type = 1 then
oi.real_amount - oi.refund_amount else 0
end) as breakfast_consume_count,
count(distinct case when oi.mealtime_type = 2 then
oi.user_id else null
end) as lunch_user_count,
count(case when oi.mealtime_type = 2 then
oi.order_id else null
end) as lunch_order_count,
sum(case when oi.mealtime_type = 2 then
oi.real_amount - oi.refund_amount else 0
end) as lunch_consume_count,
count(distinct case when oi.mealtime_type = 3 then
oi.user_id else null
end) as afternoon_tea_user_count,
count(case when oi.mealtime_type = 3 then
oi.order_id else null
end) as afternoon_tea_order_count,
sum(case when oi.mealtime_type = 3 then
oi.real_amount - oi.refund_amount else 0
end) as afternoon_tea_consume_count,
count(distinct case when oi.mealtime_type = 4 then
oi.user_id else null
end) as dinner_user_count,
count(case when oi.mealtime_type = 4 then
oi.order_id else null
end) as dinner_order_count,
sum(case when oi.mealtime_type = 4 then
oi.real_amount - oi.refund_amount else 0
end) as dinner_consume_count,
count(distinct case when oi.mealtime_type = 5 then
oi.user_id else null
end) as midnight_snack_user_count,
count(case when oi.mealtime_type = 5 then
oi.order_id else null
end) as midnight_snack_order_count,
sum(case when oi.mealtime_type = 5 then
oi.real_amount - oi.refund_amount else 0
end) as midnight_snack_consume_count
from
order_info oi
left join sys_user su on
oi.user_id = su.user_id
left join sys_dept sd on
su.dept_id = sd.dept_id
where oi.pay_state = 3 and oi.order_state in (1, 2)
and oi.pay_time <![CDATA[ >= ]]> #{param.startDateTime}
and oi.pay_time <![CDATA[ <= ]]> #{param.endDateTime}
<if test="param.deptIdList != null and param.deptIdList.size() > 0">
and su.dept_id IN
<foreach collection="param.deptIdList" item="deptId" separator="," open="(" close=")">
#{deptId}
</foreach>
</if>
<if test="param.searchValue != null and param.searchValue != ''">
and (
su.nick_name like CONCAT('%',#{param.searchValue},'%')
or su.phonenumber = #{encryptedSearchValue}
or su.user_id like concat('%', #{param.searchValue}, '%')
)
</if>
group by
oi.user_id
</select>
<select id="selectGoodsRevenue" resultType="com.bonus.canteen.core.report.domain.GoodsRevenueVO">
select
od.goods_id,
od.goods_name,
ifnull(mrd.sale_price, 0) as sale_price,
sum(case when oi.mealtime_type = 1 then
od.quantity else 0
end) as breakfast_quantity_count,
sum(case when oi.mealtime_type = 1 then
od.real_amount - od.refund_amount else 0
end) as breakfast_consume_count,
sum(case when oi.mealtime_type = 2 then
od.quantity else 0
end) as lunch_quantity_count,
sum(case when oi.mealtime_type = 2 then
od.real_amount - od.refund_amount else 0
end) as lunch_consume_count,
sum(case when oi.mealtime_type = 3 then
od.quantity else 0
end) as afternoon_tea_quantity_count,
sum(case when oi.mealtime_type = 3 then
od.real_amount - od.refund_amount else 0
end) as afternoon_tea_consume_count,
sum(case when oi.mealtime_type = 4 then
od.quantity else 0
end) as dinner_quantity_count,
sum(case when oi.mealtime_type = 4 then
od.real_amount - od.refund_amount else 0
end) as dinner_consume_count,
sum(case when oi.mealtime_type = 5 then
od.quantity else 0
end) as midnight_snack_quantity_count,
sum(case when oi.mealtime_type = 5 then
od.real_amount - od.refund_amount else 0
end) as midnight_snack_consume_count,
sum(case when oi.mealtime_type not in (1, 2, 3, 4, 5) then
od.quantity else 0
end) as other_quantity_count,
sum(case when oi.mealtime_type not in (1, 2, 3, 4, 5) then
od.real_amount - od.refund_amount else 0
end) as other_consume_count
from
order_detail od
left join order_info oi on
oi.order_id = od.order_id
left join sys_user su on
oi.user_id = su.user_id
left join cook_recipe_dishes mrd on
od.menu_detail_id = mrd.recipe_detail_id
and od.goods_id = mrd.dishes_id
where
oi.pay_state = 3
and oi.order_state in (1, 2)
and oi.pay_time <![CDATA[ >= ]]> #{param.startDateTime}
and oi.pay_time <![CDATA[ <= ]]> #{param.endDateTime}
<if test="param.deptIdList != null and param.deptIdList.size() > 0">
and su.dept_id IN
<foreach collection="param.deptIdList" item="deptId" separator="," open="(" close=")">
#{deptId}
</foreach>
</if>
<if test="param.orderDetailTypeList != null and param.orderDetailTypeList.size() > 0">
and od.detail_type IN
<foreach collection="param.orderDetailTypeList" item="detailType" separator="," open="(" close=")">
#{detailType}
</foreach>
</if>
group by
od.goods_id
</select>
</mapper>