From 5654783cba05e2994e55fc3688b831cd2c677fd1 Mon Sep 17 00:00:00 2001
From: v_bairong06 <Yhbr52699>
Date: Wed, 6 Jun 2018 10:17:03 +0800
Subject: [PATCH] 后台添加库存预警商品列表

---
 admin/themes/simplebootx/Admin/WarningGoods/index.html        | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 application/Admin/Controller/WarningGoodsController.class.php | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 application/Portal/Controller/AdminGoodsController.class.php  |  4 ++--
 themes/simplebootx/Portal/Successor/detail.html               |  2 +-
 themes/simplebootx_mobile/Portal/Goods/goods_list.html        | 31 ++++++++++++++++++++-----------
 themes/simplebootx_mobile/Public/assets/css/Khaled_res.css    |  4 ++++
 6 files changed, 192 insertions(+), 14 deletions(-)
 create mode 100644 admin/themes/simplebootx/Admin/WarningGoods/index.html
 create mode 100644 application/Admin/Controller/WarningGoodsController.class.php

diff --git a/admin/themes/simplebootx/Admin/WarningGoods/index.html b/admin/themes/simplebootx/Admin/WarningGoods/index.html
new file mode 100644
index 0000000..e194799
--- /dev/null
+++ b/admin/themes/simplebootx/Admin/WarningGoods/index.html
@@ -0,0 +1,80 @@
+<admintpl file="header" />
+</head>
+<body>
+<div class="wrap js-check-wrap">
+    <ul class="nav nav-tabs">
+        <li class="active"><a href="javascript:;">库存预警商品列表</a></li>
+    </ul>
+    <form class="well form-search" method="post" action="{:U('WarningGoods/index')}">
+        关键字:
+        <input type="text" name="keyword" style="width: 200px;" value="{$formget.keyword|default=''}" placeholder="请输入关键字...">
+        <input type="submit" class="btn btn-primary" value="搜索" />
+        <a class="btn btn-danger" href="{:U('WarningGoods/index')}">清空</a>
+    </form>
+    <form class="js-ajax-form" action="" method="post">
+        <table class="table table-hover table-bordered table-list">
+            <thead>
+            <tr>
+                <th width="15"><label><input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x"></label></th>
+                <th width="50">ID</th>
+                <th>商品名称</th>
+                <th>品牌名称</th>
+                <th>分类名称</th>
+                <th width="100">简要描述</th>
+                <th width="100">商品价格(现)</th>
+                <th width="100">商品价格(原)</th>
+                <th width="150">发布时间</th>
+                <th width="70">操作</th>
+            </tr>
+            </thead>
+            <foreach name="posts" item="vo">
+                <tr>
+                    <td><input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]" value="{$vo.id}" title="ID:{$vo.id}"></td>
+                    <td><b>{$vo.id}</b></td>
+                    <td>{$vo.goods_name}</td>
+                    <td>{$vo.brand_name}</td>
+                    <td>{$vo.name}</td>
+                    <td>{$vo.short_name}</td>
+                    <td>¥{$vo.goods_price}</td>
+                    <td>¥{$vo.price}</td>
+                    <td>{:date('Y-m-d H:i',$vo['ctime'])}</td>
+                    <td>
+                        <a href="{:U('Portal/AdminGoods/edit',array('id'=>$vo['id']))}">{:L('EDIT')}</a>
+                    </td>
+                </tr>
+            </foreach>
+            <tfoot>
+            <tr>
+                <th width="15"><label><input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x"></label></th>
+                <th width="50">ID</th>
+                <th>商品名称</th>
+                <th>品牌名称</th>
+                <th>分类名称</th>
+                <th width="100">简要描述</th>
+                <th width="100">商品价格(现)</th>
+                <th width="100">商品价格(原)</th>
+                <th width="150">发布时间</th>
+                <th width="70">操作</th>
+            </tr>
+            </tfoot>
+        </table>
+        <div class="pagination">{$page}</div>
+    </form>
+</div>
+<script src="__PUBLIC__/js/common.js"></script>
+<script>
+    function refersh_window() {
+        var refersh_time = getCookie('refersh_time');
+        if (refersh_time == 1) {
+            window.location = "{:U('WarningGoods/index',$formget)}";
+        }
+    }
+    setInterval(function() {
+        refersh_window();
+    }, 2000);
+    $(function() {
+        setCookie("refersh_time", 0);
+    });
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/application/Admin/Controller/WarningGoodsController.class.php b/application/Admin/Controller/WarningGoodsController.class.php
new file mode 100644
index 0000000..ef505aa
--- /dev/null
+++ b/application/Admin/Controller/WarningGoodsController.class.php
@@ -0,0 +1,85 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: 29925
+ * Date: 2018/6/5
+ * Time: 19:50
+ */
+
+namespace Admin\Controller;
+
+use Common\Controller\AdminbaseController;
+
+class WarningGoodsController extends AdminbaseController {
+
+    protected $goods_model;
+    protected $product_model;
+    protected $goods_brand_model;
+
+    function _initialize() {
+        parent::_initialize();
+        $this->goods_model = D("Common/Goods");
+        $this->product_model = D("Common/Product");
+        $this->goods_brand_model = D("Common/GoodsBrand");
+        $this->region();
+    }
+
+    // 后台商品库存预警列表
+    public function index(){
+        $warning = M('Warning')->where(array('id'=>1))->getField('num');
+        $this->_lists(array("g.is_del"=>0,'g.num'=>array('elt',$warning)));
+        $this->display();
+    }
+
+    /**
+     * 商品列表处理方法,根据不同条件显示不同的列表
+     * @param array $where 查询条件
+     */
+    private function _lists($where=array()){
+        $start_time = I('request.start_time');
+        if(!empty($start_time)){
+            $where['g.ctime']=array(
+                array('EGT',strtotime($start_time))
+            );
+        }
+
+        $end_time = I('request.end_time');
+        if(!empty($end_time)){
+            if(empty($where['g.ctime'])){
+                $where['g.ctime']=array();
+            }
+            array_push($where['g.ctime'], array('ELT',strtotime($end_time)));
+        }
+
+        $keyword = I('request.keyword');
+        if(!empty($keyword)){
+            $where['g.goods_name|g.short_name|g.goods_keywords']=array('like',"%$keyword%");
+        }
+
+        $this->goods_model
+            ->alias("g")
+            ->where($where);
+
+        if(!empty($term_id)){
+            $this->goods_model->join("__GOODS_BRAND__ b ON g.brand_id = b.id");
+        }
+
+        $count = $this->goods_model->count();
+
+        $page = $this->page($count, 20);
+
+        $posts = $this->goods_model
+            ->field('g.*,b.brand_name,p.name')
+            ->alias("g")
+            ->join("__GOODS_BRAND__ b ON g.brand_id = b.id")
+            ->join("__PRODUCT__ p ON g.sort_id = p.id")
+            ->where($where)
+            ->limit($page->firstRow , $page->listRows)
+            ->order("g.ctime DESC")
+            ->select();
+
+        $this->assign("page", $page->show('Admin'));
+        $this->assign("formget",array_merge($_GET,$_POST));
+        $this->assign("posts",$posts);
+    }
+}
\ No newline at end of file
diff --git a/application/Portal/Controller/AdminGoodsController.class.php b/application/Portal/Controller/AdminGoodsController.class.php
index 7a5f779..ecbd4b7 100644
--- a/application/Portal/Controller/AdminGoodsController.class.php
+++ b/application/Portal/Controller/AdminGoodsController.class.php
@@ -153,7 +153,7 @@ class AdminGoodsController extends AdminbaseController {
         $start_time = I('request.start_time');
         if(!empty($start_time)){
             $where['g.ctime']=array(
-                array('EGT',$start_time)
+                array('EGT',strtotime($start_time))
             );
         }
 
@@ -162,7 +162,7 @@ class AdminGoodsController extends AdminbaseController {
             if(empty($where['g.ctime'])){
                 $where['g.ctime']=array();
             }
-            array_push($where['g.ctime'], array('ELT',$end_time));
+            array_push($where['g.ctime'], array('ELT',strtotime($end_time)));
         }
 
         $keyword = I('request.keyword');
diff --git a/themes/simplebootx/Portal/Successor/detail.html b/themes/simplebootx/Portal/Successor/detail.html
index c2f0c27..da54204 100644
--- a/themes/simplebootx/Portal/Successor/detail.html
+++ b/themes/simplebootx/Portal/Successor/detail.html
@@ -39,7 +39,7 @@
                     <div class="fy-g-item">性别    <eq name="sex" value="1">男</eq><eq name="sex" value="2">女</eq></div>
                     <div class="fy-g-item">民族    {$nation}</div>
                     <div class="fy-g-item">出生日期    {$birth}</div>
-                    <div class="fy-g-item">所属非遗项目    汉绣</div>
+                    <div class="fy-g-item">所属非遗项目    {$name}</div>
                 </div>
             </div>
             <!--杨柳青年画·介绍-->
diff --git a/themes/simplebootx_mobile/Portal/Goods/goods_list.html b/themes/simplebootx_mobile/Portal/Goods/goods_list.html
index 093e462..bc97948 100644
--- a/themes/simplebootx_mobile/Portal/Goods/goods_list.html
+++ b/themes/simplebootx_mobile/Portal/Goods/goods_list.html
@@ -31,21 +31,21 @@
         <p class="seach_title">搜索</p>
     </div>
     <div class="shoplist_select">
-        <div class="select_quyu" onclick="qy($(this),region,redata)">
+        <div class="select_quyu" onclick="qy($(this),region,'区域')">
             <p class="shoplist_select_title">区域</p>
             <i class="iconfont icon-fylb_icon_arrow_norm"></i>
         </div>
         <div class="select_line">
 
         </div>
-        <div class="select_price" onclick="qy($(this),price,prdata)">
+        <div class="select_price" onclick="qy($(this),price,'价格')">
             <p class="shoplist_select_title">价格</p>
             <i class="iconfont icon-fylb_icon_arrow_norm"></i>
         </div>
         <div class="select_line">
 
         </div>
-        <div class="select_pai" onclick="qy($(this),brand,brdata)">
+        <div class="select_pai" onclick="qy($(this),brand,'品牌')">
             <p class="shoplist_select_title">品牌</p>
             <i class="iconfont icon-fylb_icon_arrow_norm"></i>
         </div>
@@ -89,13 +89,13 @@
 //            //			scrollbar: '.swiper-scrollbar',
 //        })
 //    }
-var  page=0;
+//var  page=0;
     var region = change(`"{$region_mobile}"`);
-    console.log(region)
+
     var price = change(`"{$price_search}"`);
-console.log(price)
+
     var brand = change(`"{$brandList}"`);
-console.log(brand)
+
     var redata="",prdata="",brdata=''
    function change(arr) {
        qyarr = arr.substring(1, arr.length - 1);
@@ -113,8 +113,14 @@ console.log(brand)
             container: 'body',
             defaultValue: [0],
             onConfirm: function (result) {
-                that.find(".shoplist_select_title").html(result[0].label)
-                datatype=result[0].value
+                that.find(".shoplist_select_title").html(result[0].label);
+                if(datatype=='区域'){
+                    redata=result[0].value
+                }else if(datatype=='价格'){
+                    prdata=result[0].value
+                }else{
+                    brdata=result[0].value
+                }
                 ajax()
             },
             id: 'singleLinePicker'
@@ -141,16 +147,19 @@ console.log(brand)
             },
             dataType: 'json',
             success: function(data) {
+                console.log(data)
                 var arrLen = data.data;
+
                 if(arrLen.length > 0) {
+
                     for(var i = 0; i < arrLen.length; i++) {
-                        result += "<div class='list_view'><a href='1111'><img src="+arrLen[i].thumb+" class='list_logo'/></a><div class='list_res'><p class='res_title'>"+arrLen[i].name+"</p><p class='res_mintitle'>"+arrLen[i].goods_name+"</p><p class='res_price'>¥"+arrLen[i].goods_price+"<s>¥"+arrLen[i].price+"</s></p></div></div>"
+                        result += "<div class='list_view'><a href='"+arrLen[i].url+"'><img src="+arrLen[i].thumb+" class='list_logo'/></a><div class='list_res'><p class='res_title'>"+arrLen[i].name+"</p><p class='res_mintitle'>"+arrLen[i].goods_name+"</p><p class='res_price'>¥"+arrLen[i].goods_price+"<s>¥"+arrLen[i].price+"</s></p></div></div>"
                     }
                     $('.list_content').html(result);
                     // 如果没有数据
                 } else {
                     // 无数据
-
+                    $('.list_content').html(result);
                 }
             },
             error: function(xhr, type) {
diff --git a/themes/simplebootx_mobile/Public/assets/css/Khaled_res.css b/themes/simplebootx_mobile/Public/assets/css/Khaled_res.css
index f1bbd69..65fa0ee 100644
--- a/themes/simplebootx_mobile/Public/assets/css/Khaled_res.css
+++ b/themes/simplebootx_mobile/Public/assets/css/Khaled_res.css
@@ -112,6 +112,10 @@
 	box-sizing: border-box;
 	padding: 0.32rem;
 }
+.main img {
+	width: 100% !important;
+	height: auto !important;
+}
 
 .main p {
 	font-size: 0.28rem;
--
libgit2 0.24.0