This commit is contained in:
cun-nan 2024-10-29 10:21:37 +08:00
parent 5179ad290f
commit dc6551a581
5 changed files with 401 additions and 294 deletions

View File

@ -0,0 +1,297 @@
<template>
<div class="app-container">
<!-- 商品销售统计-->
<!-- 搜索框-->
<div class="card-change">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
<el-form-item label="" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入商品名称"
clearable
style="width: 240px;"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="" prop="cvsGoodId">
<el-select
v-model="queryParams.cvsGoodId"
placeholder="请选择品类名称"
clearable
>
<el-option v-for="item in cvsGoodList" :key="item.id" :label="item.name" :value="item.id"/>
</el-select>
</el-form-item>
<el-form-item label="">
<el-date-picker
v-model="beginTime"
style="width: 160px"
type="date"
placeholder="销售开始日期">
</el-date-picker>
<el-date-picker
v-model="endTime"
style="width: 160px"
type="date"
placeholder="销售结束日期">
</el-date-picker>
</el-form-item>
<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" @click="dialogVisible = true">导出</el-button>
</el-form-item>
</el-form>
<div style="height: 71vh;overflow: auto">
<el-table ref="tables" v-loading="loading" :data="list" border
@selection-change="handleSelectionChange" :default-sort="defaultSort"
@sort-change="handleSortChange">
<el-table-column type="index" width="60" align="center" label="序号"/>
<el-table-column label="商品名称" align="center" prop="name"/>
<el-table-column label="品类名称" align="center" prop="pinLeiName"/>
<el-table-column label="条形码" align="center" prop="goodsNo"/>
<el-table-column label="拼音码" align="center" prop="pinyinCode"/>
<el-table-column label="商品规格" align="center" prop="goodsSpecs"/>
<el-table-column label="单位" align="center" prop="unit"/>
<el-table-column label="销售数量" align="center" prop="saleNumber"/>
<el-table-column label="销售总额" align="center" prop="saleTotal"/>
<el-table-column label="成本总金额" align="center" prop="costTotal"/>
<el-table-column label="盈利总额" align="center" prop="profitTotal"/>
<el-table-column label="统计周期" align="center">
<template slot-scope="scope">
<div>{{ beginTime ? parseTime(beginTime) + '~' : '--' }}{{ parseTime(endTime) || '' }}</div>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
@click="detail(scope.row)"
>销售记录
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
<el-drawer
title="销售记录"
:visible.sync="table"
direction="rtl"
size="60%">
<div style="width: 96%;margin: 0 auto">
<div style="display: flex;margin-bottom: 20px">
<div>商品名称{{goodsInfo.name || 0}}</div>
<div style="margin: 0 50px">品类名称{{goodsInfo.pinLeiName || 0}}</div>
<div>销售总额{{goodsInfo.saleTotal || 0}}</div>
<div style="margin: 0 50px">统计周期{{ beginTime ? parseTime(beginTime) + '~' : '--' }}{{ parseTime(endTime) || '' }}</div>
</div>
<div style="height: 78vh;overflow: auto">
<el-table ref="tables" border
v-loading="loading"
:data="detailList">
<el-table-column label="序号" align="center" type="index"></el-table-column>
<el-table-column label="商品名称" align="center" prop="name"/>
<el-table-column label="销售数量" align="center" prop="saleNumber"/>
<el-table-column label="零售价" align="center" prop="retailPrice"/>
<el-table-column label="会员价" align="center" prop="memberPrice"/>
<el-table-column label="成本价" align="center" prop="buyingPrice"/>
<el-table-column label="盈利金额" align="center" prop="profitTotal"/>
<el-table-column label="销售总额" align="center" prop="saleTotal"/>
<el-table-column label="成本总额" align="center" prop="costTotal"/>
<el-table-column label="订单完成时间" align="center" prop="createTime" width="160">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
</el-table>
</div>
<pagination
v-show="total1>0"
:total="total1"
:page.sync="queryParam.page"
:limit.sync="queryParam.pageSize"
@pagination="getDetailList"
/>
</div>
</el-drawer>
<el-dialog
title="导出状态"
:visible.sync="dialogVisible"
width="20%"
style="margin-top: 200px"
:before-close="handleClose">
<span>导出文档已生成,请点击下载按钮进行下载</span>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="exportSale">
<!-- <a href="/dev-api/business/convenience/stockStatistic/export"> </a>-->
</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {exportSale, listSale} from "@/api/convenienceStore/salestatistic";
import {addSaleDetail, listSaleDetail} from "@/api/convenienceStore/saledetail";
import {list} from "@/api/convenienceStore/goods";
import {listSuppliers} from "@/api/convenienceStore/supplier";
export default {
name: 'goodsSale',
data() {
return {
table: false,
//
queryParams: {
page: 1,
pageSize: 10,
id: '',
name: '',
pinyinCode: '',
goodsNo: '',
},
//
queryParam: {
page: 1,
pageSize: 10,
id: '',
saleId: '',
},
//
cvsGoodList: [],
//
dateRange: [],
beginTime: "",
endTime: "",
dialogVisible: false,
//
loading: false,
//
defaultSort: {prop: 'createTime', order: 'descending'},
//
total: 0,
total1: 0,
//
list: [],
detailList: [],
goodsInfo:{}
}
},
created() {
this.getList()
this.getQueryList()
},
methods: {
//
getQueryList() {
list().then(response => {
this.cvsGoodList = response.data
});
},
//
exportSale() {
this.dateRange = []
if (this.beginTime && this.endTime) {
this.dateRange.push(this.beginTime.toLocaleDateString())
this.dateRange.push(this.endTime.toLocaleDateString())
}
exportSale(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
const blob = new Blob([response], {type: 'application/json'})
this.$download.saveAs(blob, '商品销售统计.xlsx')
})
this.dialogVisible = false
},
//
detail(data) {
this.table = true;
this.queryParam.saleId = data.id;
this.dateRange = []
if (this.beginTime && this.endTime) {
this.dateRange.push(this.beginTime.toLocaleDateString())
this.dateRange.push(this.endTime.toLocaleDateString())
}
this.goodsInfo = data
listSaleDetail(this.addDateRange(this.queryParam, this.dateRange)).then(response => {
this.detailList = response.data.records;
this.total1 = response.data.total;
this.loading = false;
})
},
//
getList() {
this.loading = true;
this.dateRange = []
if (this.beginTime && this.endTime) {
this.dateRange.push(this.beginTime.toLocaleDateString())
this.dateRange.push(this.endTime.toLocaleDateString())
}
listSale(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.list = response.data.records;
this.total = response.data.total;
this.loading = false;
});
},
//
getDetailList() {
},
//
handleQuery() {
this.queryParams.page = 1;
this.getList();
},
//
resetQuery() {
this.dateRange = [];
this.beginTime = ""
this.endTime = ""
this.resetForm("queryForm");
this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order);
this.handleQuery();
},
//
handleClose(done) {
done();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.multiple = !selection.length
},
//
handleSortChange(column, prop, order) {
this.queryParams.orderByColumn = column.prop;
this.queryParams.isAsc = column.order;
this.getList();
},
}
}
</script>
<style lang="scss" scoped>
.app-container {
width: 100%;
height: 100%;
background: #f6f8f9;
}
.el-form--inline .el-form-item {
margin-right: 18px;
}
</style>

View File

@ -1,291 +1,94 @@
<template>
<div class="app-container">
<!-- 搜索框-->
<div class="card-change" >
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
<el-form-item label="" prop="name">
<el-input
v-model="queryParams.name"
placeholder="商品名称"
clearable
style="width: 240px;"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="" prop="pinyinCode">
<el-input
v-model="queryParams.pinyinCode"
placeholder="拼音码"
clearable
style="width: 240px;"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="" prop="goodsNo">
<el-input
v-model="queryParams.goodsNo"
placeholder="条形码"
clearable
style="width: 240px;"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="">
<!-- <el-date-picker-->
<!-- v-model="dateRange"-->
<!-- style="width: 240px"-->
<!-- size="medium"-->
<!-- value-format="yyyy-MM-dd"-->
<!-- type="daterange"-->
<!-- range-separator="-"-->
<!-- start-placeholder="开始日期"-->
<!-- end-placeholder="结束日期"-->
<!-- ></el-date-picker>-->
<el-date-picker
v-model="beginTime"
style="width: 160px"
type="date"
placeholder="销售开始日期">
</el-date-picker>
<el-date-picker
v-model="endTime"
style="width: 160px"
type="date"
placeholder="销售结束日期">
</el-date-picker>
</el-form-item>
<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" @click="dialogVisible = true">导出</el-button>
</el-form-item>
</el-form>
<div style="display: flex;justify-content: space-between">
<div class="container">
<div class="tab-box">
<div class="f-box" v-for="(item,index) in tabList" :key="index" @click="activeIndex=index" :class="{ 'active' :activeIndex==index}">{{item.name}}</div>
</div>
<stockStatistic v-if="activeIndex == '0'"></stockStatistic>
<goodsSale v-if="activeIndex == '1'"></goodsSale>
</div>
<el-table ref="tables" v-loading="loading" :data="list" border
@selection-change="handleSelectionChange" :default-sort="defaultSort"
@sort-change="handleSortChange">
<el-table-column type="index" width="80" align="center" label="序号"/>
<el-table-column label="商品名称" align="center" prop="name" width="160" />
<el-table-column label="条码" align="center" prop="goodsNo" width="300" />
<el-table-column label="拼音码" align="center" prop="pinyinCode" />
<el-table-column label="单位" align="center" prop="unit" />
<el-table-column label="销售数量" align="center" prop="saleNumber" />
<el-table-column label="销售总额" align="center" prop="saleTotal" />
<el-table-column label="成本总额" align="center" prop="costTotal" />
<el-table-column label="盈利总额" align="center" prop="profitTotal" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-document"
@click="detail(scope.row)"
>详细信息</el-button>
<!-- -->
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
<el-drawer
title="销售详情信息"
:visible.sync="table"
direction="rtl"
size="60%">
<el-card style="width: 98%;margin: 0px auto">
<el-table ref="tables"
v-loading="loading"
:data="detailList"
:default-sort="defaultSort">
<el-table-column
lable="#"
type="index"
>
</el-table-column>
<el-table-column label="销售商品名称" align="center" prop="name" width="140" />
<el-table-column label="销售数量" align="center" prop="saleNumber" />
<el-table-column label="销售总额" align="center" prop="saleTotal" />
<el-table-column label="销售单价" align="center" prop="retailPrice" />
<el-table-column label="销售会员单价" align="center" prop="memberPrice" width="100" />
<el-table-column label="成本单价" align="center" prop="buyingPrice" />
<el-table-column label="成本总额" align="center" prop="costTotal" />
<el-table-column label="盈利总额" align="center" prop="profitTotal" />
<el-table-column label="销售时间" align="center" prop="createTime" width="150">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total1>0"
:total="total1"
:page.sync="queryParam.page"
:limit.sync="queryParam.pageSize"
@pagination="getDetailList"
/>
</el-card>
</el-drawer>
<el-dialog
title="导出状态"
:visible.sync="dialogVisible"
width="20%"
style="margin-top: 200px"
:before-close="handleClose">
<span>导出文档已生成,请点击下载按钮进行下载</span>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="exportSale">
<!-- <a href="/dev-api/business/convenience/stockStatistic/export"> </a>-->
</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {exportSale, listSale} from "@/api/convenienceStore/salestatistic";
import {addSaleDetail, listSaleDetail} from "@/api/convenienceStore/saledetail";
import stockStatistic from "@/views/convenienceStore/stockStatistic.vue";
import goodsSale from "@/views/convenienceStore/goodsSale.vue";
export default {
name: "buy-list",
data() {
return {
table: false,
//
queryParams: {
page: 1,
pageSize: 10,
id: '',
name: '',
pinyinCode: '',
goodsNo: '',
radio1: '商品列表',
activeIndex: 0,
tabList: [
{
name: '库存统计',
},
//
queryParam: {
page: 1,
pageSize: 10,
id: '',
saleId: '',
{
name: '销售统计',
},
//
dateRange: [],
beginTime:"",
endTime:"",
dialogVisible: false,
//
loading: false,
//
defaultSort: {prop: 'createTime', order: 'descending'},
//
total: 0,
total1: 0,
//
list: [],
detailList: [],
]
}
},
created() {
this.getList()
components: {
stockStatistic,
goodsSale
},
methods: {
//
exportSale(){
this.dateRange = []
if (this.beginTime && this.endTime) {
this.dateRange.push(this.beginTime.toLocaleDateString())
this.dateRange.push(this.endTime.toLocaleDateString())
handleClick(tab, event) {
console.log(tab, event);
}
exportSale(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
const blob = new Blob([response], { type: 'application/json' })
this.$download.saveAs(blob,'商品销售统计.xlsx')
})
this.dialogVisible = false
},
//
detail(data){
this.table = true;
this.queryParam.saleId = data.id;
this.dateRange = []
if (this.beginTime && this.endTime) {
this.dateRange.push(this.beginTime.toLocaleDateString())
this.dateRange.push(this.endTime.toLocaleDateString())
}
listSaleDetail(this.addDateRange(this.queryParam, this.dateRange)).then(response => {
this.detailList = response.data.records;
this.total1 = response.data.total;
this.loading = false;
})
},
//
getList(){
this.loading = true;
this.dateRange = []
if (this.beginTime && this.endTime) {
this.dateRange.push(this.beginTime.toLocaleDateString())
this.dateRange.push(this.endTime.toLocaleDateString())
}
listSale(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.list = response.data.records;
this.total = response.data.total;
this.loading = false;
});
},
//
getDetailList(){
},
//
handleQuery() {
this.queryParams.page = 1;
this.getList();
},
//
resetQuery() {
this.dateRange = [];
this.beginTime = ""
this.endTime = ""
this.resetForm("queryForm");
this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order);
this.handleQuery();
},
//
handleClose(done) {
done();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.multiple = !selection.length
},
//
handleSortChange(column, prop, order) {
this.queryParams.orderByColumn = column.prop;
this.queryParams.isAsc = column.order;
this.getList();
},
}
}
</script>
<style lang="scss" scoped>
.app-container{
<style scoped lang="scss">
.app-center {
width: 100%;
height: 100vh;
background: #f6f8f9;
}
.el-form--inline .el-form-item {
margin-right: 18px;
box-sizing: border-box;
padding: 10px;
}
.app-top {
width: 100%;
margin-bottom: 20px;
height: 60px;
box-sizing: border-box;
}
.tab-box {
width: 100%;
background: #fff;
display: flex;
box-sizing: border-box;
padding: 0px 50px;
}
.f-box {
height: 40px;
color: #999999;
margin-right: 50px;
display: flex;
align-items: center;
}
.active {
color: #FF9655 !important;
border-bottom: 2px solid #FF9655 !important;
}
.container {
background: #F4F5F9;
box-sizing: border-box;
//padding: 20px;
}
.tabder-box {
width: 85%;
}
</style>

View File

@ -2,8 +2,9 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fuint.business.convenienceSore.mapper.SaleStatisticMapper">
<sql id="selectSale">
select sa.*,mg.name,mg.goods_no,mg.pinyin_code,mg.unit from sale_statistic sa
select sa.*,mg.name,mg.goods_no,mg.pinyin_code,mg.unit,mg.goods_specs,cg.name pinLeiName from sale_statistic sa
left join mt_goods mg on sa.goods_id = mg.id
left join cvs_goods cg on mg.cvs_good_id = cg.id
</sql>
<select id="selectSaleList" resultType="com.fuint.business.convenienceSore.vo.SaleStatisticVo">

View File

@ -39,28 +39,28 @@ public class SaleStatisticServiceImpl extends ServiceImpl<SaleStatisticMapper, S
Integer storeId = nowAccountInfo.getStoreId();
saleStatisticVo.setStoreId(storeId);
IPage<SaleStatisticVo> saleStatisticVoIPage = baseMapper.selectSaleList(page, saleStatisticVo);
for (SaleStatisticVo record : saleStatisticVoIPage.getRecords()) {
SaleDetailVo saleDetailVo = new SaleDetailVo();
saleDetailVo.setSaleId(record.getId());
saleDetailVo.setParams(saleStatisticVo.getParams());
List<SaleDetailVo> saleDetailVos = saleDetailService.selectSaleDetails(saleDetailVo);
Integer saleNumber = 0;
Double saleTotal = 0.0;
Double costTotal = 0.0;
Double profitTotal = 0.0;
if (CollectionUtil.isNotEmpty(saleDetailVos)){
for (SaleDetailVo detailVo : saleDetailVos) {
saleNumber += detailVo.getSaleNumber();
saleTotal += detailVo.getSaleTotal();
costTotal += detailVo.getCostTotal();
profitTotal += detailVo.getProfitTotal();
}
}
record.setSaleNumber(saleNumber);
record.setSaleTotal(saleTotal);
record.setCostTotal(costTotal);
record.setProfitTotal(profitTotal);
}
// for (SaleStatisticVo record : saleStatisticVoIPage.getRecords()) {
// SaleDetailVo saleDetailVo = new SaleDetailVo();
// saleDetailVo.setSaleId(record.getId());
// saleDetailVo.setParams(saleStatisticVo.getParams());
// List<SaleDetailVo> saleDetailVos = saleDetailService.selectSaleDetails(saleDetailVo);
// Integer saleNumber = 0;
// Double saleTotal = 0.0;
// Double costTotal = 0.0;
// Double profitTotal = 0.0;
// if (CollectionUtil.isNotEmpty(saleDetailVos)){
// for (SaleDetailVo detailVo : saleDetailVos) {
// saleNumber += detailVo.getSaleNumber();
// saleTotal += detailVo.getSaleTotal();
// costTotal += detailVo.getCostTotal();
// profitTotal += detailVo.getProfitTotal();
// }
// }
// record.setSaleNumber(saleNumber);
// record.setSaleTotal(saleTotal);
// record.setCostTotal(costTotal);
// record.setProfitTotal(profitTotal);
// }
return saleStatisticVoIPage;
}

View File

@ -24,12 +24,18 @@ public class SaleStatisticVo extends BaseEntity {
// 商品名称
@ExcelProperty(value = "商品名称")
private String name;
// 品类名称
@ExcelProperty(value = "品类名称")
private String pinLeiName;
// 条码
@ExcelProperty(value = "条码")
private String goodsNo;
// 拼音码
@ExcelProperty(value = "拼音码")
private String pinyinCode;
// 商品规格
@ExcelProperty(value = "商品规格")
private String goodsSpecs;
// 单位
@ExcelProperty(value = "单位")
private String unit;