Ver Fonte

商品表添加字段:成本价/cost_price,日常价/daily_price,商品信息显示,添加,修改页面添加,成本价,日常价输入框;实时销售监测统计图补加条件查询,查询校验,调整了页面样式

hhq há 4 anos atrás
pai
commit
decb8b9df1

+ 4 - 4
kmall-admin/src/main/java/com/kmall/admin/controller/RealtimeSalesDetectionController.java

@@ -29,11 +29,11 @@ public class RealtimeSalesDetectionController {
     @RequestMapping("realtimeSalesDetection/query")
     public R queryRSD(@RequestParam Map<String, Object> r){
         RealtimeSalesDetection realtimeSalesDetection = realtimeSalesDetectionService.queryRealtimeSales(r);
-
-
+        if(null!=r.get("merchSn")){
+            realtimeSalesDetection.setStoreId(null);
+            realtimeSalesDetection.setStoreName(null);
+        }
         ParamUtils.setQueryPowerByRoleType(r, "storeKey", "merchSn", "thirdPartyMerchCode");
-//        List<GoodsEntity> goodsList = goodsService.queryList(query);
-//        int total = goodsService.queryTotal(query);
         int total = 1;
         List<RealtimeSalesDetection> list = new ArrayList<>();
         list.add(realtimeSalesDetection);

+ 23 - 0
kmall-admin/src/main/java/com/kmall/admin/entity/GoodsEntity.java

@@ -208,6 +208,29 @@ public class GoodsEntity implements Serializable {
     // 英文名称
     private String englishName;
 
+
+    // 成本价
+    private BigDecimal costPrice;
+
+    // 日常价
+    private BigDecimal dailyPrice;
+
+    public BigDecimal getCostPrice() {
+        return costPrice;
+    }
+
+    public void setCostPrice(BigDecimal costPrice) {
+        this.costPrice = costPrice;
+    }
+
+    public BigDecimal getDailyPrice() {
+        return dailyPrice;
+    }
+
+    public void setDailyPrice(BigDecimal dailyPrice) {
+        this.dailyPrice = dailyPrice;
+    }
+
     public String getPlu() {
         return plu;
     }

+ 3 - 2
kmall-admin/src/main/java/com/kmall/admin/service/impl/RealtimeSalesDetectionServiceImpl.java

@@ -25,9 +25,10 @@ public class RealtimeSalesDetectionServiceImpl implements RealtimeSalesDetection
         if(r!=null && r.getGuestNumber()>0){
             //计算优惠损失 销售额-实际销售额
             r.setPreferentialLoss(r.getTotalSales().subtract(r.getActualSales()));
-            if(null !=r.getTotalCost() && null !=r.getActualSales()){
-                //计算毛利和率
+            if(null !=r.getTotalCost() && (new BigDecimal(0)!=r.getTotalCost()) && null !=r.getActualSales()){
+                //计算毛利 实际销售额-总成本
                 r.setGrossProfit(r.getActualSales().subtract(r.getTotalCost()));
+                //计算毛利率 总成本/实际销售额
                 r.setGrossProfitRatio(r.getTotalCost().divide(r.getActualSales()));
             }
             //计算客单价

+ 8 - 0
kmall-admin/src/main/resources/mybatis/mapper/GoodsDao.xml

@@ -68,6 +68,8 @@
         <result column="net_weight" property="netWeight"/>
         <result property="isGoodsShareStock" column="is_goods_share_stock"/>
 
+        <result column="cost_price" property="costPrice"/>
+        <result property="dailyPrice" column="daily_price"/>
     </resultMap>
 
     <select id="queryObject" resultType="com.kmall.admin.entity.GoodsEntity">
@@ -442,6 +444,8 @@
 			`sku`,
 			`plu`,
 			`english_name`,
+			`cost_price`,
+            `daily_price`,
 			`goods_biz_type`,
 			`name`,
 			`unit_code`,
@@ -492,6 +496,8 @@
 			#{sku},
 			#{plu},
 			#{englishName},
+			#{costPrice},
+			#{dailyPrice},
 			#{goodsBizType},
 			#{name},
 			#{unitCode},
@@ -546,6 +552,8 @@
             <if test="sku != null">`sku` = #{sku},</if>
             <if test="plu != null">`plu` = #{plu},</if>
             <if test="englishName != null">`english_name` = #{englishName},</if>
+            <if test="costPrice != null">`cost_price` = #{costPrice},</if>
+            <if test="dailyPrice != null">`daily_price` = #{dailyPrice},</if>
             <if test="goodsBizType != null">`goods_biz_type` = #{goodsBizType},</if>
             <if test="name != null">`name` = #{name},</if>
             <if test="unitCode != null">`unit_code` = #{unitCode},</if>

+ 39 - 30
kmall-admin/src/main/resources/mybatis/mapper/OrderDao.xml

@@ -1590,34 +1590,43 @@
             where o.id = #{value}
 	</select>
     <select id="queryRealtimeSales" resultType="com.kmall.admin.entity.RealtimeSalesDetection">
-		select
-          s.id as storeId,
-		  o.merch_sn as merchSn,
-          m.merch_name as merchName,
-		  count(0) as guestNumber,
-		  sum(o.order_price) as totalSales,
-		  sum(o.actual_price) as actualSales,
-		  s.store_name as storeName,
-		  max(o.add_time) as lastSalesTime
-        from
-          mall_order o
-          left join mall_store s on o.store_id = s.id
-          left join mall_merch m on o.merch_sn = m.merch_sn
-        where 1=1
-        <if test="storeId != null and storeId.trim() != ''">
-            and o.store_id=#{storeId}
-        </if>
-        <if test="salesDate != null and salesDate != ''">
-            and ( datediff ( o.add_time , #{salesDate} ) = 0 )
-        </if>
-        <if test="merchSn != null and merchSn.trim() != ''">
-            and o.merch_sn=#{merchSn}
-        </if>
-
-	</select>
-
-
-
-
-
+        SELECT
+            s.id AS storeId,
+            o.merch_sn AS merchSn,
+            m.merch_name AS merchName,
+            count( 0 ) AS guestNumber,
+            sum( o.order_price ) AS totalSales,
+            sum( o.actual_price ) AS actualSales,
+            s.store_name AS storeName,
+            max( o.add_time ) AS lastSalesTime ,
+            sum( g.cost_price) AS totalCost
+        FROM
+            mall_order o
+            LEFT JOIN mall_store s ON o.store_id = s.id
+            LEFT JOIN mall_merch m ON o.merch_sn = m.merch_sn
+            LEFT JOIN mall_order_goods og ON o.id = og.order_id
+            LEFT JOIN mall_goods g ON og.goods_id = g.id
+            LEFT JOIN mall_product_store_rela sr ON sr.goods_id = g.id
+            LEFT JOIN mall_category c ON sr.category_id = c.id
+        WHERE
+            1 = 1
+            <if test="storeId != null and storeId.trim() != ''">
+                and o.store_id=#{storeId}
+            </if>
+            <if test="merchSn != null and merchSn.trim() != ''">
+                and o.merch_sn=#{merchSn}
+            </if>
+            <choose>
+                <when test="compareDate != null and compareDate != ''">
+                    and ( datediff ( o.add_time , #{compareDate} ) = 0 )
+                </when>
+                <when test="salesDate != null and salesDate != ''">
+                    and ( datediff ( o.add_time , #{salesDate} ) = 0 )
+                </when >
+                <otherwise></otherwise>
+            </choose>
+            <if test="categoryId != null and categoryId != ''">
+                AND (c.parent_id = #{categoryId} or c.id = #{categoryId})
+            </if>
+    </select>
 </mapper>

+ 80 - 34
kmall-admin/src/main/webapp/WEB-INF/page/sale/realtimeSalesDetection.html

@@ -4,76 +4,122 @@
     <meta charset="UTF-8">
     <title>实时销售监测</title>
     #parse("sys/header.html")
+    <style>
+        .coldiv{
+            background-color: #f8f8f9;
+        }
+        body{
+            color: #515a6e;
+        }
+        span,button,select,input{
+            font-size: 18px;
+            font-family: 微软雅黑;
+        }
+        #refreshTime,#storeId,#categoryId{
+            width: 100px;
+        }
+        #merchSn{
+            width: 300px;
+        }
+        i{
+            font-size: 20px;
+        }
+        input{
+            border: 1px #dcdee2 solid;
+            border-radius: 5px;
+            outline-color:#5cadff;
+        }
+    </style>
 </head>
 <body>
-<div id="rrapp">
+<div id="rrapp" v-cloak>
     <header class="main-header">
-        <div class="container-fluid">
+        <div class="container-fluid  coldiv">
             <div class="row" style="border:0;margin-bottom:10px">
-                <div class="col-md-12 selectDiv">
+                <div class="col-md-12">
 
-                    日期:<input type="date" name="salesDate" id="salesDate" v-model="salesDate" />&nbsp;
-                    刷新间隔:<input type="number" name="refreshTime" v-model="refreshTime"  id="refreshTime" oninput="if(value > 1000 || value < 1 ){alert('非法输入!');value = ''}"/>秒&nbsp;
+                    <span>日期:</span>
+                    <input type="date" name="salesDate" id="salesDate" v-model="salesDate" />&nbsp;
+                    <span>刷新间隔:</span>
+                    <input type="number" name="refreshTime" v-model="refreshTime"  id="refreshTime" oninput="if(value > 1000 || value < 1 ){alert('非法输入!');value = ''}"/>
+                    <span>秒</span>&nbsp;
 
-                    <input type="radio" name="type" value="store" v-model="type" />门店 &nbsp;
-                    <input type="radio" name="type" value="dept"  v-model="type" />部门 &nbsp;
-                    <input type="radio" name="type" value="category"  v-model="type" />品类 &nbsp;
 
-                    <!--是否含税下拉框-->
-                    <select name="rateSelect" v-model="rateSelect">
-                        <option :value="rate.id" v-for="rate in rateList" >{{rate.name}}</option>
-                    </select>
+                    <input type="radio" name="type" value="store" v-model="type" id="store">
+                        <label for="store"><span>门店 </span></label>&nbsp;
+                    <input type="radio" name="type" value="dept"  v-model="type" id="dept" />
+                        <label for="dept"> <span>部门 </span></label>&nbsp;
+                    <input type="radio" name="type" value="category"  v-model="type" id="category" />
+                        <label for="category"> <span>品类 </span></label>&nbsp;
 
                     <!--统计图类型-->
                     <select name="seriesTypeSelect" v-model="seriesTypeSelect" @change="seriesTypeSwitch">
                         <option :value="seriesType.id" v-for="seriesType in seriesTypeList" >{{seriesType.name}}</option>
                     </select>
 
-                    <button v-on:click="refresh">刷新</button>
-                    <button v-on:click="saveFlushTime">保存条件</button>
-                    <button v-on:click="clearFlushTime">清除条件</button>
-                    |
-                <!--</div>-->
-                <!--<div class="col-md-3 selectDiv">-->
-                    项目:
-                    <!--项目下拉框-->
-                    <select name="projectSelect" v-model="projectSelect">
-                        <option :value="project.id" v-for="project in projectList" >{{project.name}}</option>
-                    </select>&nbsp;
-                    比较日期:<input type="date" name="compareDate" id="compareDate" v-model="compareDate" /> &nbsp;
-                    <button v-on:click="refresh2">比较</button>
+                    <!--含税下拉框-->
+                    <select name="rateSelect" v-model="rateSelect">
+                        <option :value="rate.id" v-for="rate in rateList" >{{rate.name}}</option>
+                    </select>
+                </div>
+            </div>
+
+            <div class="row" style="border:0;margin-bottom:10px">
+                <div class="col-md-12 ">
+                    <span>门店编号:</span><input v-model="storeId" id="storeId"/>
+                        <span style="color: red;margin: 10px">{{storeName}}</span>
+                    <span>品类编号:</span><input v-model="categoryId" id="categoryId"/>
+                        <span style="color: red;margin: 10px">{{categoryName}}</span>
                 </div>
             </div>
             <div class="row" style="border:0;margin-bottom:10px">
                 <div class="col-md-12 ">
-                    门店:<input v-model="storeId" /> {{storeName}}&nbsp;&nbsp;
-                    业态:
+                    <span>部门编号:</span><input v-model="merchSn" id="merchSn"/>
+                        <span style="color: red;margin: 10px">{{merchName}}</span> &nbsp;&nbsp;
+                    <span>业态:</span>
                     <!--业态下拉框-->
                     <select name="formatsSelect" v-model="formatsSelect">
                         <option :value="formats.id" v-for="formats in formatsList" >{{formats.name}}</option>
                     </select>&nbsp;
-                    部门:<input v-model="dept.deptId" /> {{dept.deptName}}&nbsp;&nbsp;
-                    品类:<input v-model="category.categoryId" /> {{category.categoryName}}&nbsp;&nbsp;
                 </div>
             </div>
+            <div class="row" style="border:0;margin-bottom:10px">
+                <div class="col-md-12 ">
+                    <i-button style="margin-right: 10px" type="primary" icon="refresh" size="24px" v-on:click="refresh" id="refresh">刷新</i-button>
+                    <i-button style="margin-right: 10px" type="info" icon="arrow-down-c" v-on:click="saveFlushTime" id="saveFlushTime">保存条件</i-button>
+                    <i-button type="warning" icon="close" v-on:click="clearFlushTime" id="clearFlushTime">清除条件</i-button>
+                </div>
+            </div>
+
+            <div class="row" style="border:0;margin-bottom:10px">
+                <div class="col-md-12 ">
+                    <span>项目:</span>
+                    <!--项目下拉框-->
+                    <select name="projectSelect" v-model="projectSelect">
+                        <option :value="project.id" v-for="project in projectList" >{{project.name}}</option>
+                    </select>&nbsp;
+                    <span>比较日期:</span>
+                        <input type="date" name="compareDate" id="compareDate" v-model="compareDate" /> &nbsp;
+                        <i-button style="margin-right: 10px"  type="primary" shape="circle" icon="arrow-swap" v-on:click="compare" id="clearFlushTime">比较</i-button>
+
+                </div>
+            </div>
+
             <hr/>
         </div>
     </header>
     <!-- 为 ECharts 准备一个具备大小(宽高)的 DOM -->
-    <div id="main" style="width: 90%;height:400px;"></div>
+    <div id="main" style="width: 90%;height:400px;margin-top: 10px"></div>
 <hr/>
 <footer>
     <div v-show="showList">
-        <table id="jqGrid" ></table>
+        <table id="jqGrid" style="margin-top: 10px"></table>
     </div>
 
 
 </footer>
-    <script src="${rc.contextPath}/statics/libs/vue.min.js"></script>
     <script src="${rc.contextPath}/js/sale/echarts.js"></script>
     <script src="${rc.contextPath}/js/sale/realtimeSalesDetection.js"></script>
-    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
-    <script src="${rc.contextPath}/statics/libs/bootstrap.min.js"></script>
 </div>
 </body>
 </html>

+ 8 - 2
kmall-admin/src/main/webapp/WEB-INF/page/shop/goods.html

@@ -206,10 +206,10 @@
                         <i-input v-model="goods.name" placeholder="名称"/>
                     </Form-item>
                     <Form-item label="英文名称" prop="englishName">
-                        <i-input v-model="goods.englishName" placeholder="名称"/>
+                        <i-input v-model="goods.englishName" placeholder="英文名称"/>
                     </Form-item>
                     <Form-item label="PLU" prop="plu">
-                        <i-input v-model="goods.plu" placeholder="名称"/>
+                        <i-input v-model="goods.plu" placeholder="PLU"/>
                     </Form-item>
                     <Form-item label="商品单位" prop="goodsUnit">
                         <i-input v-model="goods.goodsUnit" placeholder="商品单位" style="width: 268px;"/>
@@ -249,6 +249,12 @@
                     <!--<Form-item label="商品总库存" prop="goodsNumber" v-show="isStockShare">-->
                         <!--<Input-number :min="1" :step="1" v-model="goods.goodsNumber" placeholder="商品总库存" style="width: 268px;"/>-->
                     <!--</Form-item>-->
+                    <Form-item label="日常价" prop="dailyPrice">
+                        <Input-number :min="0.01" :step="0.01" v-model="goods.dailyPrice" placeholder="日常价" style="width: 268px;"/>
+                    </Form-item>
+                    <Form-item label="成本价" prop="costPrice">
+                        <Input-number :min="0.01" :step="0.01" v-model="goods.costPrice" placeholder="成本价" style="width: 268px;"/>
+                    </Form-item>
                     <Form-item label="商品总库存" prop="goodsNumber">
                         <Input-number :min="0" :step="1" v-model="goods.goodsNumber" placeholder="商品总库存" style="width: 268px;"/>
                     </Form-item>

+ 236 - 43
kmall-admin/src/main/webapp/js/sale/realtimeSalesDetection.js

@@ -7,23 +7,24 @@ $("#jqGrid").jqGrid({
     url:'../realtimeSalesDetection/query',
     datatype: "json",
     colModel: [
-        {label: '门店编码', name: 'storeId', index: 'storeId', width: 120},
-        {label: '门店名称', name: 'storeName', index: 'storeName', width: 180},
+        {label: '门店编码', name: 'storeId', index: 'storeId', width: 80},
+        {label: '门店名称', name: 'storeName', index: 'storeName', width: 120},
         {label: '商户编码', name: 'merchSn', index: 'storeId', width: 220},
-        {label: '商户名称', name: 'merchName', index: 'storeName', width: 180},
-        {label: '售价总额', name: 'totalSales', index: 'totalSales',align: 'right',width: 140},
-        {label: '实际销售额', name: 'actualSales', index: 'actualSales',align: 'right',width: 140},
-        {label: '占比 %', name: 'proportion', index: 'proportion',align: 'right',width: 140},
-        {label: '优惠损失', name: 'preferentialLoss', index: 'preferentialLoss',align: 'right',width: 140},
-        {label: '成本总额', name: 'totalCost', index: 'totalCost',align: 'right',width: 140},
-        {label: '毛利', name: 'grossProfit', index: 'grossProfit',align: 'right',width: 140},
-        {label: '毛利率', name: 'grossProfitRatio', index: 'grossProfitRatio',align: 'right',width: 140},
+        {label: '商户名称', name: 'merchName', index: 'storeName', width: 120},
+        {label: '售价总额', name: 'totalSales', index: 'totalSales',align: 'right',width: 80},
+        {label: '实际销售额', name: 'actualSales', index: 'actualSales',align: 'right',width: 80},
+        {label: '占比 %', name: 'proportion', index: 'proportion',align: 'right',width: 60},
+        {label: '优惠损失', name: 'preferentialLoss', index: 'preferentialLoss',align: 'right',width: 80},
+        {label: '成本总额', name: 'totalCost', index: 'totalCost',align: 'right',width: 80},
+        {label: '毛利', name: 'grossProfit', index: 'grossProfit',align: 'right',width: 80},
+        {label: '毛利率', name: 'grossProfitRatio', index: 'grossProfitRatio',align: 'right',width: 60},
         {label: '来客数', name: 'guestNumber', index: 'guestNumber',align: 'right',width: 100},
-        {label: '客单价', name: 'guestUnitPrice', index: 'guestUnitPrice',align: 'right',width: 140},
+        {label: '客单价', name: 'guestUnitPrice', index: 'guestUnitPrice',align: 'right',width: 80},
 
         {label: '最后销售时间', name: 'lastSalesTime', index: 'lastSalesTime', align: 'center',width: 180,formatter: function (value) {
                 return transDate(value,'yyyy-MM-dd hh:mm:ss');
             }}
+        // {label: '说明', name: 'guestUnitPrice', index: 'guestUnitPrice',align: 'right',width: 80}
     ],
     viewrecords: true,
     height: 200,
@@ -61,6 +62,7 @@ let vm = new Vue({
         date: '',
         refreshTime: 10,
         type: 'store',
+
         storeId: '',
         merchSn: '',
         merchName: '',
@@ -76,6 +78,9 @@ let vm = new Vue({
         guestNumber: '',
         guestUnitPrice: '',
         lastSalesTime: '',
+        categoryId: '',
+        categoryName: '',
+
         showList:false ,
         compareDate: '',//比较日期
         storeId2: '',
@@ -159,10 +164,11 @@ let vm = new Vue({
             categoryId:'',
             categoryName: ''
         },
-        seriesList:[],
+        seriesList:[], //未使用
         seriesList2:[],
         xAxisList:[],
-        dataList: []
+        dataList: [],
+        tooltip:{}
     },
     created() {
         this.rateSelect = this.rateList[0].id;
@@ -171,22 +177,87 @@ let vm = new Vue({
         this.formatsSelect = this.formatsList[0].id;
     },
     methods: {
+        addParam:function(postParam,dateType){ //添加请求参数, dateType: 0刷新,1比较
+            // var currentDate = new Date();
+            // currentDate = currentDate.getFullYear()+'-'+(currentDate.getMonth()+1)+'-'+currentDate.getDate();
+            postParam={};
+            if(vm.type=="store"){
+                vm.storeId = '10'; //测试
+                console.log('vm.storeId');
+                console.log(vm.storeId);
+                if(vm.storeId==''||vm.storeId==null){
+                    alert("请在输入框中输入门店编号!");
+                    return false;
+                }
+                postParam.storeId = vm.storeId;
+            }else if(vm.type=="dept"){
+                if(vm.merchSn==''||vm.merchSn==null){
+                    alert("请在输入框中输入部门编号!");
+                    return false;
+                }
+                postParam.merchSn = vm.merchSn;
+            }else if(vm.type=="category"){
+                if(vm.storeId==''||vm.storeId==null){
+                    alert("请在输入框中输入门店编号和品类编号!");
+                    return false;
+                }
+                if(vm.categoryId==''||vm.categoryId==null){
+                    alert("请在输入框中输入品类编号!");
+                    return false;
+                }
+                postParam.storeId = vm.storeId;
+                postParam.categoryId = vm.categoryId;
+            }else{
+                alert("请选中查询条件(门店、部门、品类,选中一个)"+vm.type);
+                return false;
+            }
+            //判断是刷新还是比较
+            if(dateType==0){
+                var sDate=vm.salesDate.replace(/(^\s+|\s+$)/g,'');//去两边空格;
+                if(sDate!=''){
+                    postParam.salesDate = vm.salesDate;
+                }
+            }else if(dateType==1){
+                var sDate=vm.compareDate.replace(/(^\s+|\s+$)/g,'');//去两边空格;
+                if(sDate!=''){
+                    postParam.compareDate = vm.compareDate;
+                }
+            }
+            console.log('postParam');
+            console.log(postParam);
+            return postParam;
+        },
         refresh: function () {
+            var postParam={};
+            postParam =  vm.addParam(postParam,0);
+            if(!postParam){
+                return;
+            }
             vm.showList = true;
-            var postParam = {"salesDate":(vm.salesDate==''||vm.salesDate==null)?vm.salesDate='2020-06-02':vm.salesDate, "storeId":vm.storeId==''?'10':vm.storeId}
             $.ajax({
                 url:'../realtimeSalesDetection/query',
                 type:"POST",
                 data:postParam,
                 dataType:'json',
                 success:function(r){
+                    //查询显示表格数据
+                    vm.showTable(postParam);
                     r = r.page.list[0];
                     console.log(r);
 
+                    if(r.lastSalesTime == null){
+                        if(vm.type == 'dept'){
+                            alert("该部门"+vm.salesDate+"无销售记录");
+                            return;
+                        }
+                        alert("该门店"+vm.salesDate+"无销售记录");
+                        return;
+                    }
+
                     vm.storeId = r.storeId;
+                    vm.storeName = r.storeName;
                     vm.merchSn = r.merchSn;
                     vm.merchName = r.merchName;
-                    vm.storeName = r.storeName;
                     vm.totalSales = r.totalSales;
                     vm.actualSales = r.actualSales;
                     vm.preferentialLoss = r.preferentialLoss;
@@ -198,20 +269,27 @@ let vm = new Vue({
                     vm.guestUnitPrice = r.guestUnitPrice;
                     vm.lastSalesTime = r.lastSalesTime;
 
-                    vm.seriesList =[];
-                    vm.seriesList2 =[];
-                    vm.seriesList2.push( vm.totalSales);
-                    console.log(vm.seriesList2);
-                    console.log('vm.seriesList2');
+
+                    vm.seriesList=[];
+                    vm.seriesList2 =[]; //清空 系列 数据
+                    // vm.seriesList2.push( vm.totalSales);
 
                     vm.showEcharts();
-                    vm.showTable(postParam);
                 }
 
             });
         },
-        refresh2: function () {
-            var postParam = {"salesDate":vm.compareDate==''?vm.compareDate='2020-06-17':vm.compareDate, "storeId":vm.storeId==''?'10':vm.storeId}
+        compare: function () {
+            if(vm.seriesList2.length <1){
+                alert("请先刷新一条数据再比较!");
+                return;
+            }
+            vm.switchProjectView();
+            var postParam={};
+            postParam =  vm.addParam(postParam,1);
+            if(!postParam){
+                return;
+            }
             $.ajax({
                 url:'../realtimeSalesDetection/query',
                 type:"POST",
@@ -221,9 +299,14 @@ let vm = new Vue({
                     console.log(r);
                     r = r.page.list[0];
                     console.log(r);
-                    if(r.storeId == null){
+                    if(r.lastSalesTime == null){
+                        if(vm.type == 'dept'){
+                            alert("该部门"+vm.compareDate+"无销售记录");
+                            return;
+                        }
                         alert("该门店"+vm.compareDate+"无销售记录");
-                        return;}
+                        return;
+                    }
 
                     vm.storeId2 = r.storeId;
                     vm.merchSn2 = r.merchSn;
@@ -244,16 +327,60 @@ let vm = new Vue({
 
                     if(vm.seriesList2.length > 1){
                         //删除并替换
-                        vm.seriesList2.splice(1,1,vm.totalSales2);
+                        // vm.seriesList2.splice(1,1,vm.totalSales2);
+                        // if(vm.type == 'dept'){
+                        //     vm.dataList.splice(1,1,
+                        //         '['+vm.merchSn2+']'+vm.merchName2+'/售价总额:'+vm.totalSales2+'('+vm.salesDate2+')'
+                        //     );
+                        // }else{
+                        //     vm.dataList.splice(1,1,
+                        //         '['+vm.storeId2+']'+vm.storeName2+'/售价总额:'+vm.totalSales2+'('+vm.salesDate2+')'
+                        //     );
+                        // }
+
+                        if(vm.projectSelect=='0'){
+                            vm.seriesList2.splice(1,1,vm.totalSales2);
+                            if(vm.type == 'dept'){
+                                vm.dataList.splice(1,1,'['+vm.merchSn+']'+vm.merchName2+'/售价总额:'+vm.totalSales2+'('+vm.salesDate2+')');
+                            }else{
+                                vm.dataList.splice(1,1,'['+vm.storeId+']'+vm.storeName2+'/售价总额:'+vm.totalSales2+'('+vm.salesDate2+')');
+                            }
+                        }else if(vm.projectSelect=='1'){
+                            vm.seriesList2.splice(1,1,vm.guestUnitPrice);
+                            if(vm.type == 'dept'){
+                                vm.dataList.splice(1,1,'['+vm.merchSn+']'+vm.merchName2+'/客单价:'+vm.guestUnitPrice2+'('+vm.salesDate2+')');
+                            }else{
+                                vm.dataList.splice(1,1,'['+vm.storeId+']'+vm.storeName2+'/客单价:'+vm.guestUnitPrice2+'('+vm.salesDate2+')');
+                            }
+                        }
 
-                        vm.dataList.splice(1,1,
-                            '['+vm.storeId2+']'+vm.storeName2+'售价总额('+vm.salesDate2+')'
-                        );
                     }else{
-                        vm.seriesList2.push(vm.totalSales2);
-                        vm.dataList.push(
-                            '['+vm.storeId2+']'+vm.storeName2+'售价总额('+vm.salesDate2+')'
-                        );
+                        // vm.seriesList2.push(vm.totalSales2);
+                        // if(vm.type == 'dept'){
+                        //     vm.dataList.splice(1,1,
+                        //         '['+vm.merchSn2+']'+vm.merchName2+'/售价总额:'+vm.totalSales2+'('+vm.salesDate2+')'
+                        //     );
+                        // }else{
+                        //     vm.dataList.splice(1,1,
+                        //         '['+vm.storeId2+']'+vm.storeName2+'/售价总额:'+vm.totalSales2+'('+vm.salesDate2+')'
+                        //     );
+                        // }
+
+                        if(vm.projectSelect=='0'){
+                            vm.seriesList2.push(vm.totalSales2);
+                            if(vm.type == 'dept'){
+                                vm.dataList.push('['+vm.merchSn+']'+vm.merchName2+'/售价总额:'+vm.totalSales2+'('+vm.salesDate2+')');
+                            }else{
+                                vm.dataList.push('['+vm.storeId+']'+vm.storeName2+'/售价总额:'+vm.totalSales2+'('+vm.salesDate2+')');
+                            }
+                        }else if(vm.projectSelect=='1'){
+                            vm.seriesList2.push(vm.guestUnitPrice2);
+                            if(vm.type == 'dept'){
+                                vm.dataList.push('['+vm.merchSn+']'+vm.merchName2+'/客单价:'+vm.guestUnitPrice2+'('+vm.salesDate2+')');
+                            }else{
+                                vm.dataList.push('['+vm.storeId+']'+vm.storeName2+'/客单价:'+vm.guestUnitPrice2+'('+vm.salesDate2+')');
+                            }
+                        }
                     }
                     console.log(vm.dataList);
                     myChart.setOption({
@@ -290,27 +417,85 @@ let vm = new Vue({
             //加载动画
             myChart.showLoading();
 
-            var seriesList = vm.seriesList;
-            vm.dataList=['['+vm.storeId+']'+vm.storeName+'售价总额('+vm.salesDate+')'];
+
+            //项目下拉框判断
+            var temp ='';
+            if(vm.projectSelect=='0'){
+                if(vm.type == 'dept'){
+                    temp = '['+vm.merchSn+']'+vm.merchName+'/售价总额:'+vm.totalSales+'('+vm.salesDate+')';
+                }else{
+                    temp = '['+vm.storeId+']'+vm.storeName+'/售价总额:'+vm.totalSales+'('+vm.salesDate+')';
+                }
+                vm.seriesList2.push(vm.totalSales);
+                vm.seriesList.push({value:vm.totalSales,name:temp});
+
+            }else if(vm.projectSelect=='1'){
+                if(vm.type == 'dept'){
+                    temp = '['+vm.merchSn+']'+vm.merchName+'/客单价:'+vm.guestUnitPrice+'('+vm.salesDate+')';
+                }else{
+                    temp = '['+vm.storeId+']'+vm.storeName+'/客单价:'+vm.guestUnitPrice+'('+vm.salesDate+')';
+                }
+                vm.seriesList2.push(vm.guestUnitPrice);
+                vm.seriesList.push({value:vm.guestUnitPrice,name:temp});
+
+            }
+            vm.dataList = [temp];
+            if(vm.type=="pie"){
+                console.log("pie");
+                vm.seriesList2 = vm.seriesList;
+
+                console.log('vm.seriesList');
+                console.log(vm.seriesList);
+            }
+
+            console.log('vm.seriesList2');
+            console.log(vm.seriesList2);
+            // if(vm.type == 'dept'){
+            //     vm.dataList= ['['+vm.merchSn+']'+vm.merchName+'/售价总额:'+vm.totalSales+'('+vm.salesDate+')'];
+            // }else{
+            //     vm.dataList=['['+vm.storeId+']'+vm.storeName+'/售价总额:'+vm.totalSales+'('+vm.salesDate+')'];
+            // }
 
             // 指定图表的配置项和数据
             //销售量
             var option = {
                 title: {
-                    text: '分店实时销售统计图'
+                    // textAlign: 'right',
+                    text: '实时销售统计图',
+                    x:'center',
+                    textStyle:{
+                        //文字颜色
+                        color:'#17233d',
+                        //字体风格,'normal','italic','oblique'
+                        fontStyle:'normal',
+                        //字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 | 400...
+                        fontWeight:'bold',
+                        //字体系列
+                        fontFamily:'sans-serif',
+                        //字体大小
+                        fontSize:28
+                    }
+                },
+                tooltip: {
+                    formatter: function (params) {
+                        return params.name;
+                    }
                 },
-                tooltip: {},
                 legend: {
-                    data:['售价总额']
+                    data:['/售价总额']
                 },
                 xAxis: {
-                    data: vm.dataList
+                    data: vm.dataList,
+                    axisLabel: {
+                        interval:0
+                    }
                 },
                 yAxis: {},
-                // series: seriesList
                 series:[{
                     barMaxWidth: '20%' ,
                     barWidth: '50%' ,
+                    radius: '55%',
+                    roseType: 'angle',
                     type: vm.seriesTypeSelect,
                     color: ['#dd6b66','#759aa0'],
                     data: vm.seriesList2
@@ -323,16 +508,24 @@ let vm = new Vue({
             myChart.setOption(option);
 
         },
+        tooltipFormatter: function(){
+            if(vm.type=='dept'){
+                return '['+vm.merchSn+']'+vm.merchName+'/售价总额:'+vm.totalSales+'('+vm.salesDate+')';
+            }
+            return '['+vm.storeId+']'+vm.storeName+'/售价总额:'+vm.totalSales+'('+vm.salesDate+')';
+        },
         showTable: function (postParam) {
 
             console.log(postParam);
 
-
             $("#jqGrid").jqGrid('setGridParam', {
                 postData: postParam
 
-            }).trigger("reloadGrid");
-
+            }).trigger("reloadGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "scroll"});
+        },
+        switchProjectView: function () {
+            console.log("vm.projectSelect");
+            console.log(vm.projectSelect);
         }
     }
 });

+ 2 - 0
kmall-admin/src/main/webapp/js/shop/goods.js

@@ -36,6 +36,8 @@ $(function () {
                     return '-';
                 }},
             {label: '商品库存', name: 'goodsNumber', index: 'goodsNumber', width: 100, align: 'right'},
+            {label: '日常价', name: 'dailyPrice', index: 'dailyPrice', width: 100, align: 'right'},
+            {label: '成本价', name: 'costPrice', index: 'costPrice', width: 100, align: 'right'},
             // {label: '零售价格', name: 'retailPrice', index: 'retail_price', width: 80, align: 'center'},
             // {label: '市场价', name: 'marketPrice', index: 'market_price', width: 80, align: 'center'},
             {