finish custom-consume statistics
	
		
		1 files added
	
		
		4 files modified
	
	
 
	
	
	
	
	
	
	
	
|  |  |  | 
|---|
|  |  |  | package com.matrix.system.hive.statistics; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.matrix.core.constance.MatrixConstance; | 
|---|
|  |  |  | import com.matrix.core.pojo.AjaxResult; | 
|---|
|  |  |  | import com.matrix.core.pojo.PaginationVO; | 
|---|
|  |  |  | import com.matrix.core.tools.WebUtil; | 
|---|
|  |  |  | import com.matrix.system.common.bean.SysUsers; | 
|---|
|  |  |  | import com.matrix.system.common.constance.AppConstance; | 
|---|
|  |  |  | import com.matrix.system.hive.bean.AchieveNew; | 
|---|
|  |  |  | import com.matrix.system.hive.service.AchieveNewService; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/vipConsumeStatistics") | 
|---|
|  |  |  | @ResponseBody | 
|---|
|  |  |  | public AjaxResult vipConsumeStatistics(AchieveNew achieveNew, PaginationVO pageVo) { | 
|---|
|  |  |  | SysUsers sysUsers = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); | 
|---|
|  |  |  | if(!AppConstance.ZONGDIAN.equals(sysUsers.getShopName())){ | 
|---|
|  |  |  | achieveNew.setShopId(sysUsers.getShopId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<AchieveNew> list = achieveNewService.findVipConsumeStatisticsList(achieveNew, pageVo); | 
|---|
|  |  |  | int total = achieveNewService.findVipConsumeStatisticsTotal(achieveNew); | 
|---|
|  |  |  | return AjaxResult.buildSuccessInstance(list, total); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #线上测试环境 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | spring.datasource.username=chuhuan | 
|---|
|  |  |  | spring.datasource.password=chuhuan | 
|---|
|  |  |  | spring.datasource.url=jdbc:mysql://119.3.52.84:3306/hive_plus_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 | 
|---|
|  |  |  | spring.datasource.username=ct_test | 
|---|
|  |  |  | spring.datasource.password=123456 | 
|---|
|  |  |  | spring.datasource.url=jdbc:mysql://120.27.238.55:3306/hive_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | <select id="selectVipConsumeStatisticsList" resultMap="AchieveNewMap"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | a.VIP_NAME, | 
|---|
|  |  |  | d.cnt, | 
|---|
|  |  |  | b.buyConsume, | 
|---|
|  |  |  | b.freeConsume, | 
|---|
|  |  |  | b.hisConsume | 
|---|
|  |  |  | a.PHONE t9, | 
|---|
|  |  |  | GROUP_CONCAT(DISTINCT e.su_name) meiliao, | 
|---|
|  |  |  | d.cnt arrive_cnt, | 
|---|
|  |  |  | sum(b.buyConsume) goods_cash, | 
|---|
|  |  |  | sum(b.freeConsume) free_consume, | 
|---|
|  |  |  | sum(b.hisConsume) his_consume | 
|---|
|  |  |  | from sys_vip_info a | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | select vip_id, sum(a.free_consume) freeConsume, sum(a.his_consume) hisConsume, sum(IFNULL(goods_cash, 0) + IFNULL(card_cash, 0)) buyConsume from achieve_new a group by vip_id | 
|---|
|  |  |  | select vip_id,datatime, sum(a.free_consume) freeConsume, sum(a.his_consume) hisConsume, sum(IFNULL(goods_cash, 0) + IFNULL(card_cash, 0)) buyConsume from achieve_new a group by vip_id | 
|---|
|  |  |  | ) b on a.ID = b.vip_id | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | select vip_id, count(1) cnt from ( | 
|---|
|  |  |  | 
|---|
|  |  |  | group by date_format(datatime, '%Y-%m-%d'), vip_id | 
|---|
|  |  |  | ) c group by vip_id | 
|---|
|  |  |  | ) d on a.ID=d.vip_id | 
|---|
|  |  |  |  | 
|---|
|  |  |  | left join sys_users e on find_in_set(e.su_id, a.BEATUY_ID) | 
|---|
|  |  |  | where 1=1 | 
|---|
|  |  |  | <if test="record.vipName != null and record.vipName !=''"> | 
|---|
|  |  |  | and (a.vip_name like CONCAT(CONCAT('%', #{record.vipName}), '%') or a.vip_no=#{record.vipName}) | 
|---|
|  |  |  | and (a.vip_name like CONCAT(CONCAT('%', #{record.vipName}), '%') or a.vip_no=#{record.vipName} or a.phone = #{record.vipName}) | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.shopId != null"> | 
|---|
|  |  |  | and a.shop_id=#{shopId} | 
|---|
|  |  |  | and a.shop_id=#{record.shopId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.beginTime != null and record.endTime!=null"> | 
|---|
|  |  |  | and date_format(datatime, '%Y-%m-%d') between #{record.beginTime} and #{record.endTime} | 
|---|
|  |  |  | and date_format(b.datatime, '%Y-%m-%d') between #{record.beginTime} and #{record.endTime} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <if test="record.meiliao != null and record.meiliao!=''"> | 
|---|
|  |  |  | and FIND_IN_SET(#{record.meiliao}, a.BEATUY_ID) | 
|---|
|  |  |  | <if test="record.beaultId != null and record.beaultId!=''"> | 
|---|
|  |  |  | and FIND_IN_SET(#{record.beaultId}, a.BEATUY_ID) | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | group by a.PHONE | 
|---|
|  |  |  | <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> | 
|---|
|  |  |  | <if test="pageVo.sort !=null  and pageVo.order !=null"> | 
|---|
|  |  |  | order by | 
|---|
|  |  |  | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectVipConsumeStatisticsTotal" resultMap="AchieveNewMap"> | 
|---|
|  |  |  | <select id="selectVipConsumeStatisticsTotal" resultType="java.lang.Integer"> | 
|---|
|  |  |  | select count(1) | 
|---|
|  |  |  | from sys_vip_info a | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | select vip_id, sum(a.free_consume) freeConsume, sum(a.his_consume) hisConsume, sum(IFNULL(goods_cash, 0) + IFNULL(card_cash, 0)) buyConsume from achieve_new a group by vip_id | 
|---|
|  |  |  | select vip_id,datatime, sum(a.free_consume) freeConsume, sum(a.his_consume) hisConsume, sum(IFNULL(goods_cash, 0) + IFNULL(card_cash, 0)) buyConsume from achieve_new a group by vip_id | 
|---|
|  |  |  | ) b on a.ID = b.vip_id | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | select vip_id, count(1) cnt from ( | 
|---|
|  |  |  | 
|---|
|  |  |  | group by date_format(datatime, '%Y-%m-%d'), vip_id | 
|---|
|  |  |  | ) c group by vip_id | 
|---|
|  |  |  | ) d on a.ID=d.vip_id | 
|---|
|  |  |  |  | 
|---|
|  |  |  | left join sys_users e on find_in_set(e.su_id, a.BEATUY_ID) | 
|---|
|  |  |  | where 1=1 | 
|---|
|  |  |  | <if test="record.vipName != null and record.vipName !=''"> | 
|---|
|  |  |  | and (a.vip_name like CONCAT(CONCAT('%', #{record.vipName}), '%') or a.vip_no=#{record.vipName}) | 
|---|
|  |  |  | and (a.vip_name like CONCAT(CONCAT('%', #{record.vipName}), '%') or a.vip_no=#{record.vipName} or a.phone = #{record.vipName}) | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.shopId != null"> | 
|---|
|  |  |  | and a.shop_id=#{shopId} | 
|---|
|  |  |  | and a.shop_id=#{record.shopId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="record.beginTime != null and record.endTime!=null"> | 
|---|
|  |  |  | and date_format(datatime, '%Y-%m-%d') between #{record.beginTime} and #{record.endTime} | 
|---|
|  |  |  | and date_format(b.datatime, '%Y-%m-%d') between #{record.beginTime} and #{record.endTime} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <if test="record.meiliao != null and record.meiliao!=''"> | 
|---|
|  |  |  | and FIND_IN_SET(#{record.meiliao}, a.BEATUY_ID) | 
|---|
|  |  |  | <if test="record.beaultId != null and record.beaultId!=''"> | 
|---|
|  |  |  | and FIND_IN_SET(#{record.beaultId}, a.BEATUY_ID) | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | </mapper> | 
|---|
|  |  |  | 
|---|
|  |  |  | <el-button type="primary" @click="searchVipInfo">查询</el-button> | 
|---|
|  |  |  | </el-col> | 
|---|
|  |  |  | </el-col> | 
|---|
|  |  |  | <el-col :span="6" style="float: right; margin-right: 20px;"> | 
|---|
|  |  |  | <el-col :span="8" style="float: right; margin-right: 20px;"> | 
|---|
|  |  |  | <el-button type="primary" plain @click="recharge">充值</el-button> | 
|---|
|  |  |  | <el-button type="warning" plain @click="addOrder">开单</el-button> | 
|---|
|  |  |  | <el-button type="success" plain @click="addServiceOrder">开服务单</el-button> | 
|---|
|  |  |  | 
|---|
|  |  |  | <el-tab-pane label="服务单" name="serviceOrder"> | 
|---|
|  |  |  | <el-row style="line-height: 40px;"> | 
|---|
|  |  |  | <el-col :span="11"> | 
|---|
|  |  |  | <span>选择时间:</span> | 
|---|
|  |  |  | <el-date-picker v-model="serviceOrderTab.selectTime" | 
|---|
|  |  |  | type="datetimerange" | 
|---|
|  |  |  | range-separator="至" format="yyyy-MM-dd HH:mm" | 
|---|
|  |  |  | 
|---|
|  |  |  | <el-tab-pane label="订单" name="order"> | 
|---|
|  |  |  | <el-row style="line-height: 40px;"> | 
|---|
|  |  |  | <el-col :span="11"> | 
|---|
|  |  |  | <span>选择时间:</span> | 
|---|
|  |  |  | <el-date-picker v-model="orderTab.selectTime" | 
|---|
|  |  |  | type="datetimerange" | 
|---|
|  |  |  | range-separator="至" | 
|---|
|  |  |  | 
|---|
|  |  |  | <el-tab-pane label="皮肤检测" name="skinCheck"> | 
|---|
|  |  |  | <el-row style="line-height: 40px;"> | 
|---|
|  |  |  | <el-col :span="11"> | 
|---|
|  |  |  | <span>选择时间:</span> | 
|---|
|  |  |  | <el-date-picker v-model="skinTab.selectTime" | 
|---|
|  |  |  | type="daterange" | 
|---|
|  |  |  | range-separator="至" | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!DOCTYPE HTML> | 
|---|
|  |  |  | <html xmlns:th="http://www.thymeleaf.org" xmlns:matrix="http://www.w3.org/1999/xhtml"> | 
|---|
|  |  |  | <head> | 
|---|
|  |  |  | <meta charset="utf-8"> | 
|---|
|  |  |  | <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> | 
|---|
|  |  |  | <meta name="renderer" content="webkit|ie-comp|ie-stand"> | 
|---|
|  |  |  | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | 
|---|
|  |  |  | <meta name="viewport" | 
|---|
|  |  |  | content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" /> | 
|---|
|  |  |  | <meta http-equiv="Cache-Control" content="no-siteapp" /> | 
|---|
|  |  |  | <LINK rel="Bookmark" href="../images/favicon.ico"> | 
|---|
|  |  |  | <!-- 本框架基本脚本和样式 --> | 
|---|
|  |  |  | <script type="text/javascript" | 
|---|
|  |  |  | th:src="@{/js/plugin/jquery-2.1.4.min.js}"></script> | 
|---|
|  |  |  | <script type="text/javascript" th:src="@{/js/systools/MBase.js}"></script> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </head> | 
|---|
|  |  |  | <body class="gray-bg"> | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <div class="ibox-content"> | 
|---|
|  |  |  | <!-- 搜索框部分start --> | 
|---|
|  |  |  | <form class="form-inline" id="serchform"> | 
|---|
|  |  |  | <div class="form-group mr-20"> | 
|---|
|  |  |  | <label>日期范围</label> | 
|---|
|  |  |  | <input name="beginTime" type="text" class="form-control datetimepicker" id="beginTime">- | 
|---|
|  |  |  | <input name="endTime"  type="text" class="form-control datetimepicker" id="endTime"> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <div class="form-group mr-20"> | 
|---|
|  |  |  | <label>会员</label> | 
|---|
|  |  |  | <input autocomplete="off" placeholder="姓名/编号/电话"  name="vipName" type="text" class="form-control"  > | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <div class="form-group mr-20"> | 
|---|
|  |  |  | <label>美疗师</label> | 
|---|
|  |  |  | <select class="form-control autoFull select2" | 
|---|
|  |  |  | th:data-url="@{/admin/getShopStaffByRoleName?roleName=美疗师}" | 
|---|
|  |  |  | data-value="suId" | 
|---|
|  |  |  | data-filed="suName" | 
|---|
|  |  |  | name="beaultId" | 
|---|
|  |  |  | id="beaultId"> | 
|---|
|  |  |  | <option value="">--请选择美容师--</option> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <div class="form-group mr-20"> | 
|---|
|  |  |  | <label>门店</label> | 
|---|
|  |  |  | <select class="form-control autoFull" data-filed="shopName" name="shopId" id="shopId" | 
|---|
|  |  |  | th:data-url="@{/admin/shopInfo/findAllWithPermi}"> | 
|---|
|  |  |  | <option value=''>--请选择部所属门店--</option> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <div class="row mb-10"> | 
|---|
|  |  |  | <div class="col-sm-8"> | 
|---|
|  |  |  | <button  onclick="myGrid.serchData()" type="button" class="btn btn-info btn-sm"><i class="fa fa-search" ></i> 搜索</button> | 
|---|
|  |  |  | <button  onclick="myGrid.resetForm()" type="button"   class="btn btn-default btn-sm"><i class="fa fa-refresh " ></i> 重置</button> | 
|---|
|  |  |  | <!--                    <button  matrix:btn="ygyjbb-exportExcel"  onclick="exportExcel()" type="button" class="btn btn-default btn-sm"><i class="fa fa-download" ></i> 导出</button>--> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </form> | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <table id="mgrid"> | 
|---|
|  |  |  | <thead> | 
|---|
|  |  |  | <tr> | 
|---|
|  |  |  | <th data-formatter="MGrid.indexfn" data-align="center" | 
|---|
|  |  |  | data-width="30px">序号</th> | 
|---|
|  |  |  | <th data-field="vipName" data-formatter="buildVipNameJump">姓名</th> | 
|---|
|  |  |  | <th data-field="meiliao">美疗师</th> | 
|---|
|  |  |  | <th data-field="arriveCnt">到店次数</th> | 
|---|
|  |  |  | <th data-field="goodsCash">消费金额</th> | 
|---|
|  |  |  | <th data-field="hisConsume">消耗本金</th> | 
|---|
|  |  |  | <th data-field="freeConsume">消耗赠送</th> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </tr> | 
|---|
|  |  |  | </thead> | 
|---|
|  |  |  | </table> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <script type="text/javascript" th:src="@{/js/systools/MJsBase.js}"></script> | 
|---|
|  |  |  | <script type="text/javascript" th:src="@{/js/function/public.js}"></script> | 
|---|
|  |  |  | <script type="text/javascript"> | 
|---|
|  |  |  | var myGrid; | 
|---|
|  |  |  | var initParam = { | 
|---|
|  |  |  | format : "yyyy-mm-dd hh:ii", //默认显示年与日,如果想显示十分秒:"yyyy-mm-dd hh:ii:ss" | 
|---|
|  |  |  | minView: "hour",     //"month",只显示年月日的选择,不会再跳转去选择时分秒;如果想要选择时分秒的:"hour" | 
|---|
|  |  |  | } | 
|---|
|  |  |  | MTools.ininDatetimepicker(initParam); | 
|---|
|  |  |  | //限制结束时间不小于开始时间 | 
|---|
|  |  |  | MTools.limitStartEndTime({}); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | $(function() { | 
|---|
|  |  |  | MTools.autoFullSelect(); | 
|---|
|  |  |  | myGrid = MGrid.initGrid({ | 
|---|
|  |  |  | url : basePath+"/admin/vipStatistics/vipConsumeStatistics", | 
|---|
|  |  |  | showExport : true, | 
|---|
|  |  |  | showFooter : false, | 
|---|
|  |  |  | height:'auto', | 
|---|
|  |  |  | width:'auto', | 
|---|
|  |  |  | exportDataType : "basic", //basic', 'all', 'selected'. | 
|---|
|  |  |  | exportTypes : [ 'excel', 'xlsx' ], //导出类型 | 
|---|
|  |  |  | exportOptions : { | 
|---|
|  |  |  | ignoreColumn : [ 0 ], | 
|---|
|  |  |  | fileName : "客户消费统计" + MTools.getTime(), //文件名称设置 | 
|---|
|  |  |  | worksheetName : 'Sheet1', //表格工作区名称 | 
|---|
|  |  |  | tableName : '客户消费统计', | 
|---|
|  |  |  | excelstyles : [ 'background-color', 'color', 'font-size', | 
|---|
|  |  |  | 'font-weight' ], | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | $('[data-toggle="tooltip"]').tooltip() | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function footCountTitle(data) { | 
|---|
|  |  |  | return "<b>合计</b>"; | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | function countColumn(data) { | 
|---|
|  |  |  | console.log(data) | 
|---|
|  |  |  | field = this.field; | 
|---|
|  |  |  | var resultsumQuantity = parseFloat((data.reduce(function(sum, row) { | 
|---|
|  |  |  | console.log(sum,row[field]); | 
|---|
|  |  |  | return sum + (+row[field]); | 
|---|
|  |  |  | }, 0)).toFixed(2));//保留有效数字 | 
|---|
|  |  |  | return "<b>"+resultsumQuantity+"</b>"; | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function buildVipNameJump(value, row, index) { | 
|---|
|  |  |  | return '<a  onClick="vipDetail(\'' + row.t9 +'\')"   class="text-primary " >'+value+'</a>'; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function vipDetail(value) { | 
|---|
|  |  |  | layer.full(layer.open({ | 
|---|
|  |  |  | type : 2, | 
|---|
|  |  |  | title : "订单详情", | 
|---|
|  |  |  | maxmin : true, | 
|---|
|  |  |  | area : MUI.SIZE_M, | 
|---|
|  |  |  | content : [basePath+'/admin/redirect/hive/beautySalon/vip?vipPhone=' + value ] | 
|---|
|  |  |  | })); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function exportExcel(){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var param=MForm.toUrlParam("#serchform"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | window.location.href=basePath+"/admin/achieve/exportDailyInfoNew?"+param; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </script> | 
|---|
|  |  |  | </body> | 
|---|
|  |  |  | </html> | 
|---|