This commit is contained in:
齐天大圣 2024-10-31 15:58:43 +08:00
parent 28f27d415c
commit 32d774dc27
9 changed files with 306 additions and 60 deletions

View File

@ -224,3 +224,12 @@ export function getStaffByStorId() {
})
}
//油站交易对账导出
export function exportExcelOrderMsgsApi(data) {
return request({
url: 'business/allOrderInfo/exportExcelOrderMsgApi',
method: 'post',
responseType: 'blob', // 表明响应类型为二进制流
data: data // 通过 data 参数传递需要的数据
});
}

View File

@ -15,7 +15,7 @@
<el-option label="小程序" value="applet"/>
<el-option label="收银台" value="cashier"/>
<el-option label="POS端" value="POS"/>
<el-option label="PC端" value="PC"/>
<el-option label="平台" value="PC"/>
</el-select>
</el-form-item>
<el-form-item label="" prop="payChannel">
@ -104,31 +104,42 @@
<el-form-item label="" prop="userName">
<el-input v-model="queryParams.userName" placeholder="请输入付款用户"></el-input>
</el-form-item>
<el-form-item label="">
<el-date-picker
v-model="beginTime"
style="width: 140px"
type="date"
placeholder="交易开始日期"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
>
</el-date-picker>
<el-date-picker
v-model="endTime"
style="width: 140px"
type="date"
placeholder="交易结束日期"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
>
</el-date-picker>
</el-form-item>
<!-- <el-form-item label="" prop="beginTime">-->
<!-- <el-date-picker-->
<!-- v-model="beginTime"-->
<!-- style="width: 140px"-->
<!-- type="date"-->
<!-- placeholder="交易开始日期"-->
<!-- format="yyyy-MM-DD"-->
<!-- value-format="yyyy-MM-DD"-->
<!-- ></el-date-picker>-->
<!-- -->
<!-- </el-form-item>-->
<!-- <el-form-item label="" prop="endTime">-->
<!-- <el-date-picker-->
<!-- v-model="endTime"-->
<!-- style="width: 140px"-->
<!-- type="date"-->
<!-- placeholder="交易结束日期"-->
<!-- format="yyyy-MM-DD"-->
<!-- value-format="yyyy-MM-DD"-->
<!-- >-->
<!-- </el-date-picker>-->
<!-- </el-form-item>-->
<el-date-picker
v-model="queryParams.dataRange"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
>
</el-date-picker>
<el-form-item style="float: right; margin-right: 0px ">
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
<el-button type="primary">导出</el-button>
<el-button type="primary" @click="exportExcelCashier">导出</el-button>
</el-form-item>
</el-form>
</div>
@ -324,9 +335,10 @@ import {
exportExcelTradingApi,
orderStatistics,
transactionList,
getDicts
getDicts,
exportExcelOrderMsgsApi
} from "@/api/allOrder";
import {getStaffByStorId} from "../../../../api/allOrder";
import {exportExcelOrderMsgApi, getStaffByStorId} from "../../../../api/allOrder";
export default {
name: "reconciliation-trading",
@ -350,7 +362,7 @@ export default {
//
orderList: [],
deptList: [],
dataRange:[],
//
queryParams: {
page: 1,
@ -366,6 +378,7 @@ export default {
deptId: "",
userName:"",
staffId:"",
dataRange:[],
},
orderStatistics: {
CASH: "0",
@ -405,12 +418,7 @@ export default {
this.getStaffByStorId()
},
exportExcelCashier() {
let dateRange = []
if (this.beginTime && this.endTime) {
dateRange.push(this.beginTime.toLocaleDateString())
dateRange.push(this.endTime.toLocaleDateString())
}
exportExcelTradingApi(this.addDateRange(this.queryParams, dateRange)).then(res => {
exportExcelOrderMsgsApi(this.queryParams).then(res => {
const blob = new Blob([res], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'});
this.$download.saveAs(blob, '交易明细统计.xLsx')
})
@ -430,18 +438,17 @@ export default {
//
async getList(val) {
console.log(111111)
let dateRange = []
if (this.beginTime && this.endTime) {
dateRange.push(this.beginTime.toLocaleDateString())
dateRange.push(this.endTime.toLocaleDateString())
dateRange.push(this.beginTime)
dateRange.push(this.endTime)
}
transactionList(this.addDateRange(this.queryParams, dateRange)).then(response => {
console.log(this.beginTime)
transactionList(this.queryParams).then(response => {
this.orderList = response.data.records;
this.total = response.data.total;
this.isSysDate = false
this.getOrderStatistics()
})
},

View File

@ -427,11 +427,20 @@ public class AllOrderInfoController extends BaseController {
/**
* 查询这个油站的所有员工
*
* @param storeId
* @param
* @return
*/
@PostMapping("getStaffByStorId")
public ResponseObject getStaffByStorId(){
return getSuccessResult(allOrderInfoService.getStaffByStorId());
}
/**
* 导出油站订单
* @param response
*/
@PostMapping("exportExcelOrderMsgApi")
public void exportExcelOrderMsgApi(HttpServletResponse response, @RequestBody AllOrderInfoRes allOrderInfoRes) {
this.allOrderInfoService.exportExcelOrderMsgApi(response, allOrderInfoRes);
}
}

View File

@ -124,8 +124,9 @@ public class AllOrderInfo extends BaseEntity implements Serializable {
private Long deptId;
@TableField(exist = false)
private List<Long> storeIds;
@TableField(exist = false)
private String userName;
@TableField(exist = false)
private String[] dataRange;
}

View File

@ -108,7 +108,11 @@ public interface AllOrderInfoMapper extends BaseMapper<AllOrderInfo> {
Double getCountMemberBalance(@Param("storeId") Integer storeId,@Param("endTime") String endTime);
AllOrderInfoVo selectByOrderNo(String orderNo);
IPage<AllOrderInfoVo> transactionList(Page page,@Param("obj") AllOrderInfoRes allOrderInfoRes);
IPage<AllOrderInfoVo> transactionList(Page page,@Param("obj") AllOrderInfoRes allOrderInfoRes,
@Param("beginTime") String beginTime,@Param("endTime") String endTime);
Map<String, Object> orderStatistics(@Param("obj") AllOrderInfoRes allOrderInfoRes);
}
Map<String, Object> orderStatistics(@Param("obj") AllOrderInfoRes allOrderInfoRes,@Param("beginTime") String beginTime,@Param("endTime") String endTime);
List transactionAllList(@Param("obj") AllOrderInfoRes allOrderInfoRes,
@Param("beginTime") String beginTime,@Param("endTime") String endTime);
}

View File

@ -900,28 +900,153 @@
<if test="obj.staffId != null and obj.staffId != ''">
and ai.create_by = #{obj.staffId}
</if>
<if test="beginTime != null and beginTime != ''">
<![CDATA[and ai.create_time >= #{beginTime} ]]>
</if>
<if test="endTime != null and endTime != ''">
<![CDATA[ and ai.create_time <= #{endTime} ]]>
</if>
ORDER BY ai.create_time DESC
</select>
<select id="orderStatistics" resultType="java.util.Map">
SELECT
SUM( CASE WHEN ai.pay_type = 'WECHAT' THEN ai.pay_money ELSE 0 END ) AS s1,-- 微信实付
SUM( CASE WHEN ai.pay_type = 'WECHAT' THEN 1 ELSE 0 END ) AS s2,-- 微信订单笔数
SUM( CASE WHEN ai.pay_type = 'ALIPAY' THEN ai.pay_money ELSE 0 END ) AS s3,-- 支付宝实收
SUM( CASE WHEN ai.pay_type = 'ALIPAY' THEN 1 ELSE 0 END ) AS s4,-- 支付宝订单笔数
SUM( CASE WHEN ai.pay_type = 'UNIONPAY' THEN ai.pay_money ELSE 0 END ) AS s5,-- 银联实收
SUM( CASE WHEN ai.pay_type = 'UNIONPAY' THEN 1 ELSE 0 END ) AS s6,-- 银联订单笔数
SUM( CASE WHEN ai.pay_type = 'CASH' THEN ai.pay_money ELSE 0 END ) AS s7,-- 现金实收
SUM( CASE WHEN ai.pay_type = 'CASH' THEN 1 ELSE 0 END ) AS s8,-- 订单笔数
SUM( CASE WHEN mu.id IS NOT NULL THEN ai.pay_money ELSE 0 END ) AS s9,-- 会员实收
SUM( CASE WHEN mu.id IS NOT NULL THEN 1 ELSE 0 END ) AS s10,-- 会员订单笔数
SUM( CASE WHEN ai.pay_type = 'after_pay' THEN ai.pay_money ELSE 0 END ) AS s11,-- 挂账实收
SUM( CASE WHEN ai.pay_type = 'after_pay' THEN 1 ELSE 0 END ) AS s12 -- 挂账订单笔数
IFNULL(SUM( CASE WHEN ai.pay_type = 'WECHAT' THEN ai.pay_money ELSE 0 END),0) AS s1,-- 微信实付
IFNULL(SUM( CASE WHEN ai.pay_type = 'WECHAT' THEN 1 ELSE 0 END ),0) AS s2,-- 微信订单笔数
IFNULL(SUM( CASE WHEN ai.pay_type = 'ALIPAY' THEN ai.pay_money ELSE 0 END ),0) AS s3,-- 支付宝实收
IFNULL(SUM( CASE WHEN ai.pay_type = 'ALIPAY' THEN 1 ELSE 0 END ),0) AS s4,-- 支付宝订单笔数
IFNULL(SUM( CASE WHEN ai.pay_type = 'UNIONPAY' THEN ai.pay_money ELSE 0 END ),0) AS s5,-- 银联实收
IFNULL(SUM( CASE WHEN ai.pay_type = 'UNIONPAY' THEN 1 ELSE 0 END ),0) AS s6,-- 银联订单笔数
IFNULL(SUM( CASE WHEN ai.pay_type = 'CASH' THEN ai.pay_money ELSE 0 END ),0) AS s7,-- 现金实收
IFNULL(SUM( CASE WHEN ai.pay_type = 'CASH' THEN 1 ELSE 0 END),0) AS s8,-- 订单笔数
IFNULL(SUM( CASE WHEN mu.id IS NOT NULL THEN ai.pay_money ELSE 0 END ),0) AS s9,-- 会员实收
IFNULL(SUM( CASE WHEN mu.id IS NOT NULL THEN 1 ELSE 0 END ),0) AS s10,-- 会员订单笔数
IFNULL(SUM( CASE WHEN ai.pay_type = 'after_pay' THEN ai.pay_money ELSE 0 END ),0) AS s11,-- 挂账实收
IFNULL(SUM( CASE WHEN ai.pay_type = 'after_pay' THEN 1 ELSE 0 END ),0) AS s12 -- 挂账订单笔数
FROM
all_order_info ai
LEFT JOIN mt_user mu ON ai.user_id = mu.id
LEFT JOIN merchant_config mc ON mc.id = ai.m_id
left join mt_staff mt on ai.create_by=mt.id
where 1=1
<if test="obj.storeId != null and obj.storeId != ''">
and ai.store_id = #{obj.storeId}
</if>
<if test="obj.paymentChannel != null and obj.paymentChannel != ''">
and ai.payment_channel = #{obj.paymentChannel}
</if>
<if test="obj.orderNo != null and obj.orderNo != ''">
and ai.order_no like concat('%', #{obj.orderNo}, '%')
</if>
<if test="obj.payType != null and obj.payType != ''">
and ai.pay_type = #{obj.payType}
</if>
<if test="obj.type != null and obj.type != ''">
and ai.type = #{obj.type}
</if>
<if test="obj.payChannel != null and obj.payChannel != ''">
and ai.pay_channel = #{obj.payChannel}
</if>
<if test="obj.userName != null and obj.userName != ''">
and mu.name like concat('%', #{obj.userName}, '%')
</if>
<if test="obj.status != null and obj.status != ''">
and ai.status = #{obj.status}
</if>
<if test="obj.staffId != null and obj.staffId != ''">
and ai.create_by = #{obj.staffId}
</if>
<if test="beginTime != null and beginTime != ''">
<![CDATA[and ai.create_time >= #{beginTime} ]]>
</if>
<if test="endTime != null and endTime != ''">
<![CDATA[ and ai.create_time <= #{endTime} ]]>
</if>
</select>
<select id="transactionAllList" resultType="com.fuint.business.order.vo.Excel.TradingOrderExcel">
SELECT
ai.order_no,
CASE WHEN ai.pay_channel = 'cashier' THEN '收银台'
WHEN ai.pay_channel = 'POS' THEN 'POS机'
WHEN ai.pay_channel = 'PC' THEN '平台'
WHEN ai.pay_channel = 'applet' THEN '小程序'
END as payChannel,
CASE WHEN ai.type = '1' THEN '油品订单'
WHEN ai.type = '2' THEN '商品订单'
WHEN ai.type = '3' THEN '储值卡订单'
WHEN ai.type = '4' THEN '积分商城订单'
WHEN ai.type = '5' THEN '囤油卡订单'
WHEN ai.type = '6' THEN '收银台订单'
WHEN ai.type = '7' THEN '挂账订单'
WHEN ai.type = '8' THEN 'POS订单'
END as type,
ai.goods_money,
ai.discount_amount,
ai.pay_money as payMoney,
ai.pay_money as paysMoney,
ai.ref_money,
CASE WHEN ai.pay_type = 'ALIPAY' THEN '支付宝'
WHEN ai.pay_type = 'WECHAT' THEN '微信'
WHEN ai.pay_type = 'UNIONPAY' THEN '银联二维码'
WHEN ai.pay_type = 'CASH' THEN '现金'
WHEN ai.pay_type = 'APPLET_CODE' THEN '小程序码'
WHEN ai.pay_type = 'card_value' THEN '储值卡'
WHEN ai.pay_type = 'fule_card' THEN '囤油卡'
WHEN ai.pay_type = 'car_card_value' THEN '车队卡'
WHEN ai.pay_type = 'after_pay' THEN '挂账'
END as payType,
CASE WHEN ai.status = 'paid' THEN '已支付'
WHEN ai.status = 'unpaid' THEN '未支付'
WHEN ai.status = 'refund' THEN '已退款'
WHEN ai.status = 'payFail' THEN '支付失败'
WHEN ai.status = 'refunding' THEN '退款中'
END as status,
ai.payment_channel as paymentChannel,
ai.mchnt_cd,
ai.create_time,
ai.update_time,
mu.NAME AS userName,
mc.merchant_name as merchantName,
mt.real_name as createBy
FROM
all_order_info ai
LEFT JOIN mt_user mu ON ai.user_id = mu.id
LEFT JOIN merchant_config mc on mc.id = ai.m_id
left join mt_staff mt on ai.create_by=mt.id
where 1=1
<if test="obj.storeId != null and obj.storeId != ''">
and ai.store_id = #{obj.storeId}
</if>
<if test="obj.paymentChannel != null and obj.paymentChannel != ''">
and ai.payment_channel = #{obj.paymentChannel}
</if>
<if test="obj.orderNo != null and obj.orderNo != ''">
and ai.order_no like concat('%', #{obj.orderNo}, '%')
</if>
<if test="obj.payType != null and obj.payType != ''">
and ai.pay_type = #{obj.payType}
</if>
<if test="obj.type != null and obj.type != ''">
and ai.type = #{obj.type}
</if>
<if test="obj.payChannel != null and obj.payChannel != ''">
and ai.pay_channel = #{obj.payChannel}
</if>
<if test="obj.userName != null and obj.userName != ''">
and mu.name like concat('%', #{obj.userName}, '%')
</if>
<if test="obj.status != null and obj.status != ''">
and ai.status = #{obj.status}
</if>
<if test="obj.staffId != null and obj.staffId != ''">
and ai.create_by = #{obj.staffId}
</if>
<if test="beginTime != null and beginTime != ''">
<![CDATA[and ai.create_time >= #{beginTime} ]]>
</if>
<if test="endTime != null and endTime != ''">
<![CDATA[ and ai.create_time <= #{endTime} ]]>
</if>
ORDER BY ai.create_time DESC
</select>
</mapper>

View File

@ -206,4 +206,6 @@ AllOrderActivityVo getOneByOrderId(Integer orderId);
Object cashierRefund(Map<String, String> map) throws Exception;
List<MtStaff> getStaffByStorId();
void exportExcelOrderMsgApi(HttpServletResponse response, AllOrderInfoRes allOrderInfoRes);
}

View File

@ -100,7 +100,8 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper, All
private MtUserMapper mtUserMapper;
@Override
public Map<String, Object> orderStatistics(AllOrderInfoRes allOrderInfoRes) {
return allOrderInfoMapper.orderStatistics(allOrderInfoRes);
return allOrderInfoMapper.orderStatistics(allOrderInfoRes, allOrderInfoRes.getDataRange()==null?"":allOrderInfoRes.getDataRange()[0],
allOrderInfoRes.getDataRange()==null?"":allOrderInfoRes.getDataRange()[1]);
}
@Override
@ -808,7 +809,7 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper, All
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
if (ObjectUtil.isEmpty(allOrderInfo.getDeptId())) {
IPage<SysDeptVo> sysDepts = sysDeptMapper.selectChildrenDeptById2(new Page(1, 10000), nowAccountInfo.getDeptId(), allOrderInfo.getDeptId(), allOrderInfo.getDeptType());
IPage<SysDeptVo> sysDepts = sysDeptMapper.selectChildrenDeptById2(new Page(1, 10000), nowAccountInfo.getDeptId(), nowAccountInfo.getDeptId(), allOrderInfo.getDeptType());
if (ObjectUtil.isEmpty(sysDepts.getRecords())) {
throw new RuntimeException("组织下没有油站!");
@ -889,7 +890,9 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper, All
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
allOrderInfoRes.setStoreId(nowAccountInfo.getStoreId());
IPage<AllOrderInfoVo> allOrderInfoVoIPage = super.baseMapper.transactionList(page, allOrderInfoRes);
IPage<AllOrderInfoVo> allOrderInfoVoIPage = super.baseMapper.transactionList(page, allOrderInfoRes,
allOrderInfoRes.getDataRange()==null?"":allOrderInfoRes.getDataRange()[0],
allOrderInfoRes.getDataRange()==null?"":allOrderInfoRes.getDataRange()[1]);
return allOrderInfoVoIPage;
}
@ -897,7 +900,6 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper, All
@Override
public void tradingExportExcel(HttpServletResponse response, AllOrderInfoDto order) {
IPage<AllOrderInfoVo> tradingPage = getTradingPage(new Page(1, 100000), order);
List<TradingExcel> tradingExcel = new ArrayList<>();
for (AllOrderInfoVo record : tradingPage.getRecords()) {
@ -2424,4 +2426,47 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper, All
List<MtStaff> mtStaffs= mtStaffMapper.getStaffByStorId(nowAccountInfo.getStoreId());
return mtStaffs;
}
@Override
public void exportExcelOrderMsgApi(HttpServletResponse response, AllOrderInfoRes allOrderInfoRes) {
List<TradingOrderExcel> list= transactionAllList(allOrderInfoRes);
List<TradingOrderExcel> tradingExcel = new ArrayList<>();
for (TradingOrderExcel record : list) {
TradingOrderExcel excel = new TradingOrderExcel();
BeanUtils.copyProperties(record, excel);
excel.setType("其他");
tradingExcel.add(excel);
}
// 设置响应头信息
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-disposition", "attachment;filename=demo.xlsx");
try {
// 写入文件数据
EasyExcel.write(response.getOutputStream(), TradingOrderExcel.class).sheet("download").doWrite(tradingExcel);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
/**
* 查询全部订单数据
* @param
* @param allOrderInfoRes
* @return
*/
public List transactionAllList(AllOrderInfoRes allOrderInfoRes) {
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
allOrderInfoRes.setStoreId(nowAccountInfo.getStoreId());
System.out.println(allOrderInfoRes.getDataRange());
List allOrderInfoVo = super.baseMapper.transactionAllList(allOrderInfoRes,
allOrderInfoRes.getDataRange().length==0?"":allOrderInfoRes.getDataRange()[0],
allOrderInfoRes.getDataRange().length==0?"":allOrderInfoRes.getDataRange()[1]);
return allOrderInfoVo;
}
}

View File

@ -0,0 +1,44 @@
package com.fuint.business.order.vo.Excel;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.util.Date;
@Data
public class TradingOrderExcel {
@ExcelProperty("订单号")
private String orderNo; // 订单号
@ExcelProperty("订单类型")
private String payChannel; // 订单类型
@ExcelProperty("订单分类")
private String type; // 订单分类
@ExcelProperty("订单金额")
private Double goodsMoney; // 订单金额
@ExcelProperty("优惠金额")
private Double discountAmount; // 优惠金额
@ExcelProperty("实收金额")
private Double payMoney; // 实收金额
@ExcelProperty("会员支付金额")
private Double paysMoney; // 会员支付金额
@ExcelProperty("归还金额")
private Double refMoney; // 归还金额
@ExcelProperty("付款用户")
private String userName; // 付款用户
@ExcelProperty("支付方式")
private String payType; // 支付方式
@ExcelProperty("订单状态")
private String status; // 订单状态
@ExcelProperty("支付渠道")
private String paymentChannel; // 支付渠道
@ExcelProperty("商户号")
private String mchntCd; // 付款用户
@ExcelProperty("收银员")
private String createBy; // 收银员
@ExcelProperty("订单创建时间")
private Date createTime; // 支付时间
@ExcelProperty("订单完成时间")
private Date updateTime; // 支付时间
}