消费汇总
This commit is contained in:
parent
c97abd5024
commit
4c0affefce
|
|
@ -2,8 +2,7 @@ package com.bonus.canteen.core.report.controller;
|
|||
|
||||
import com.bonus.canteen.core.order.domain.OrderDetail;
|
||||
import com.bonus.canteen.core.order.service.IOrderDetailService;
|
||||
import com.bonus.canteen.core.report.domain.TradeFlowParam;
|
||||
import com.bonus.canteen.core.report.domain.TradeFlowVO;
|
||||
import com.bonus.canteen.core.report.domain.*;
|
||||
import com.bonus.canteen.core.report.service.TradeReportService;
|
||||
import com.bonus.common.core.utils.poi.ExcelUtil;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
|
|
@ -11,6 +10,7 @@ import com.bonus.common.core.web.domain.AjaxResult;
|
|||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
import com.bonus.common.log.annotation.SysLog;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
|
|
@ -31,16 +31,58 @@ public class TradeReportController extends BaseController
|
|||
{
|
||||
@Autowired
|
||||
private TradeReportService tradeReportService;
|
||||
|
||||
/**
|
||||
* 交易流水
|
||||
*/
|
||||
@ApiOperation("交易流水")
|
||||
@PostMapping("/flow")
|
||||
@ResponseBody
|
||||
public TableDataInfo list(TradeFlowParam param)
|
||||
public TableDataInfo tradeFlowList(TradeFlowParam param)
|
||||
{
|
||||
startPage();
|
||||
List<TradeFlowVO> list = tradeReportService.selectTradeFlow(param);
|
||||
return getDataTable(list);
|
||||
}
|
||||
@ApiOperation("营业汇总")
|
||||
@PostMapping("/revenue/operating")
|
||||
@ResponseBody
|
||||
public TableDataInfo selectOperatingRevenue(OperatingRevenueParam param)
|
||||
{
|
||||
startPage();
|
||||
List<OperatingRevenueVO> list = tradeReportService.selectOperatingRevenue(param);
|
||||
return getDataTable(list);
|
||||
}
|
||||
@ApiOperation("食堂档口汇总")
|
||||
@PostMapping("/revenue/canteen")
|
||||
@ResponseBody
|
||||
public TableDataInfo selectCanteenStallRevenue(CanteenStallRevenueParam param)
|
||||
{
|
||||
startPage();
|
||||
List<CanteenStallRevenueVO> list = tradeReportService.selectCanteenStallRevenue(param);
|
||||
return getDataTable(list);
|
||||
}
|
||||
@ApiOperation("设备汇总")
|
||||
@PostMapping("/revenue/device")
|
||||
@ResponseBody
|
||||
public TableDataInfo selectDeviceRevenue(DeviceRevenueParam param)
|
||||
{
|
||||
startPage();
|
||||
List<DeviceRevenueVO> list = tradeReportService.selectDeviceRevenue(param);
|
||||
return getDataTable(list);
|
||||
}
|
||||
@ApiOperation("个人消费汇总")
|
||||
@PostMapping("/revenue/user")
|
||||
@ResponseBody
|
||||
public TableDataInfo selectUserRevenue(UserRevenueParam param)
|
||||
{
|
||||
startPage();
|
||||
List<UserRevenueVO> list = tradeReportService.selectUserRevenue(param);
|
||||
return getDataTable(list);
|
||||
}
|
||||
@ApiOperation("菜品销售汇总")
|
||||
@PostMapping("/revenue/goods")
|
||||
@ResponseBody
|
||||
public TableDataInfo selectGoodsRevenue(GoodsRevenueParam param)
|
||||
{
|
||||
startPage();
|
||||
List<GoodsRevenueVO> list = tradeReportService.selectGoodsRevenue(param);
|
||||
return getDataTable(list);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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 deviceNum;
|
||||
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;
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
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 OperatingRevenueVO implements Serializable {
|
||||
private int userCount;
|
||||
private int orderCount;
|
||||
private BigDecimal payableAmount;
|
||||
private BigDecimal discountsAmount;
|
||||
private BigDecimal realAmount;
|
||||
private BigDecimal personalWalletCount;
|
||||
private BigDecimal subWalletCount;
|
||||
}
|
||||
|
|
@ -10,9 +10,7 @@ import java.util.List;
|
|||
|
||||
@Data
|
||||
public class TradeFlowParam implements Serializable {
|
||||
private Long userId;
|
||||
private String userName;
|
||||
private String phonenumber;
|
||||
private String searchValue;
|
||||
private List<Long> deptIdList;
|
||||
@ApiModelProperty("开始时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -1,11 +1,17 @@
|
|||
package com.bonus.canteen.core.report.mapper;
|
||||
|
||||
import com.bonus.canteen.core.report.domain.TradeFlowParam;
|
||||
import com.bonus.canteen.core.report.domain.TradeFlowVO;
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,15 @@
|
|||
package com.bonus.canteen.core.report.service;
|
||||
|
||||
import com.bonus.canteen.core.report.domain.TradeFlowParam;
|
||||
import com.bonus.canteen.core.report.domain.TradeFlowVO;
|
||||
import com.bonus.canteen.core.report.domain.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package com.bonus.canteen.core.report.service.impl;
|
||||
|
||||
import com.bonus.canteen.core.report.domain.TradeFlowParam;
|
||||
import com.bonus.canteen.core.report.domain.TradeFlowVO;
|
||||
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;
|
||||
|
|
@ -16,6 +16,32 @@ public class TradeReportServiceImpl implements TradeReportService {
|
|||
|
||||
@Override
|
||||
public List<TradeFlowVO> selectTradeFlow(TradeFlowParam param) {
|
||||
return tradeReportMapper.selectTradeFlow(param);
|
||||
String encryptedSearchValue = SM4EncryptUtils.sm4Encrypt(param.getSearchValue());
|
||||
return tradeReportMapper.selectTradeFlow(param, encryptedSearchValue);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,9 +47,347 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="param.searchValue != null and param.searchValue != ''">
|
||||
and (
|
||||
su.nick_name = #{param.searchValue}
|
||||
or su.phonenumber = #{param.encryptedSearchValue}
|
||||
or su.phonenumber = #{encryptedSearchValue}
|
||||
or su.user_id like concat('%', #{param.searchValue}, '%')
|
||||
)
|
||||
</if>
|
||||
</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_id = 1 and ats.trade_type = 110 and ats.pay_state = 3 then
|
||||
ifnull(atwd.amount, 0) ELSE 0 end) -
|
||||
sum(case when atwd.wallet_id = 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_id = 2 and ats.trade_type = 110 and ats.pay_state = 3 then
|
||||
ifnull(atwd.amount, 0) ELSE 0 end) -
|
||||
sum(case when atwd.wallet_id = 2 and ats.trade_type = 130 and ats.pay_state = 3 then
|
||||
ifnull(atwd.amount, 0) ELSE 0 end) as sub_wallet_count
|
||||
from
|
||||
acc_trade ats
|
||||
left join acc_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),
|
||||
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 alloc_canteen ac on
|
||||
oi.canteen_id = ac.canteen_id
|
||||
left join alloc_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_num,
|
||||
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_num
|
||||
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_num = #{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 = #{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,
|
||||
mrd.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 menu_recipe_dishes mrd on
|
||||
od.menu_detail_id = mrd.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>
|
||||
Loading…
Reference in New Issue