rabin 3 年 前
コミット
566f020db4

+ 49 - 20
database/info.php

@@ -67,7 +67,11 @@ $buy_type = array
     1 => '可采购',
     2 => '不可采购',
 );
-
+$stock = array
+(
+	1 => '是',
+	2 => '否',
+);
 $config = array
 (
 	# 表名
@@ -197,6 +201,18 @@ $config = array
             'tab'		=> 1,
         ),
 
+        'stock'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '是否有库存',
+            'default'   => '1',
+            'desc'      => '是否有库存',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $stock,
+            'tab'		=> 1,
+        ),
+
 		'sell_type'        => array
         (
             'type'      => 'int-11',
@@ -251,6 +267,17 @@ $config = array
 			'show'		=> 'pay_money=1',
 		),
 
+		'commission'		=> array
+		(
+			'type' 		=> 'varchar-20',
+			'name' 		=> '销售商佣金-设置佣金之后,销售商销售了商品,能得到的相应佣金,也可以在销售商里单独设置,填写10%就是销售价的百分之10,直接填写数字就是佣金数额',
+			'default' 	=> '0',
+			'desc' 		=> '销售商佣金',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'tab'		=> 1,
+		),
+
 		'score_id'		=> array
 		(
 			'type' 		=> 'int-11',
@@ -267,7 +294,7 @@ $config = array
 		'category'		=> array
 		(
 			'type' 		=> 'varchar-500',
-			'name' 		=> '属性分类',
+			'name' 		=> '商品分类',
 			'default' 	=> '',
 			'desc' 		=> '分类',
 			'match' 	=> 'is_string',
@@ -377,7 +404,7 @@ $config = array
 		(
 			'type' 		=> 'tinyint-1',
 			'name' 		=> '状态',
-			'default' 	=> '2',
+			'default' 	=> '1',
 			'desc' 		=> '状态',
 			'match' 	=> 'is_numeric',
 			//'update'	=> 'select',
@@ -538,18 +565,35 @@ $config = array
 			'col' => 'name as name, id, id as value, "" as selected, "" as disabled,spec_type|id',
 		),
 
+		# 列表
+		'getData' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'category' => array('yes', 'like'),
+				'top_category_id' => array('yes', 'in'),
+				'second_category_id' => 'yes',
+				'category_id' => 'yes',
+				'status' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'col' => '*',
+		),
+
 		# 列表
 		'getAll' => array
 		(
 			# 匹配的正则或函数 选填项
 			'option' => array
 			(
-				'audit' => 2,
 				'category' => array('yes', 'like'),
 				'top_category_id' => 'yes',
 				'second_category_id' => 'yes',
 				'category_id' => 'yes',
-				//'status' => 1,
+				'status' => 1,
 				'state' => 1,
 			),
 			'type' => 'all',
@@ -566,7 +610,6 @@ $config = array
 			'option' => array
 			(
 				'shop_id' => 'yes',
-				'brand_id' => 'yes',
 				'name' => array('yes', 'like'),
 				'audit' => 2,
 				'category' => array('yes', 'like'),
@@ -581,20 +624,6 @@ $config = array
 			'page' => array(10, 'list'),
 			'col' => '*',
 		),
-		
-		# 更新售出量
-		'updateSell' => array
-		(
-			'type' => 'update',
-			'where' => array
-			(
-				'id' => 'yes',
-			),
-			'set' => array
-			(
-				'sell_num' => array('yes', '+='),
-			),
-		),
 
 		'getOne' => array
         (

+ 1 - 1
index.php

@@ -1,7 +1,7 @@
 <?php
 
 define('DEVER_APP_NAME', 'product');
-define('DEVER_APP_LANG', '商品管理');
+define('DEVER_APP_LANG', '商品');
 define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
 define('DEVER_MANAGE_ORDER', 98);
 define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-component');

+ 136 - 0
lib/Info.php

@@ -31,4 +31,140 @@ class Info
 
         # 获取其他
     }
+
+    # 获取商品及其属性列表
+    public function getSetList($table, $other_where, $cate_id = false, $col = 'goods_id')
+    {
+        $total = Dever::input('total', 1);
+        if ($cate_id) {
+            $where['top_category_id'] = $cate_id;
+        }
+        $where['status'] = 1;
+
+        $data = Dever::db('product/info')->getData($where);
+
+        $result = array();
+        if ($data) {
+            $i = 0;
+            foreach ($data as $k => $v) {
+                
+                $sku = Dever::db('product/info_sku')->select(array('info_id' => $v['id']));
+
+                if ($sku) {
+                    $other_where[$col] = $v['id'];
+                    $other_where['sku_id'] = -1;
+                    $other = Dever::db($table)->find($other_where);
+                    $result[$i]['id'] = $v['id'];
+                    $result[$i]['name'] = $v['name'];
+                    $result[$i]['type'] = $v['type'];
+                    $result[$i]['stock'] = $v['stock'];
+                    $result[$i]['commission'] = $v['commission'];
+                    $result[$i]['price'] = 0;
+                    $result[$i]['select'] = 2;
+                    $result[$i]['del'] = 1;
+                    
+                    if ($other) {
+                        if (isset($other['commission'])) {
+                            $result[$i]['commission'] = $other['commission'];
+                        }
+                        if (isset($other['price'])) {
+                            $result[$i]['price'] = $other['price'];
+                        }
+                        if (isset($other['min'])) {
+                            $result[$i]['min'] = $other['min'];
+                        }
+                        if (isset($other['total_num'])) {
+                            if (isset($other['sell_num'])) {
+                                $result[$i]['total'] = $other['total_num'] - $other['sell_num'];
+                            } else {
+                                $result[$i]['total'] = $other['total_num'];
+                            }
+                            
+                        } else {
+                            $result[$i]['total'] = $other['num'];
+                        }
+                        
+                        $result[$i]['select'] = $other['state'];
+                    } else {
+                        $result[$i]['total'] = 0;
+                    }
+
+                    $result[$i]['total'] = $result[$i]['total'] * $total;
+                    $result[$i]['children'] = array();
+                    $num = count($sku);
+                    if ($num == 1 && $sku[0]['key'] == -1) {
+                        if ($result[$i]['price'] <= 0) {
+                            $result[$i]['price'] = $sku[0]['price'];
+                        }
+                        
+                        $result[$i]['id'] .=  '-' . $sku[0]['id'];
+                        $result[$i]['end'] = true;
+                    } else {
+                        foreach ($sku as $k1 => $v1) {
+                            $v1['sku_name'] = '';
+                            if ($v1['key']) {
+
+                                $key = str_replace('-', ',', $v1['key']);
+                                $spec = Dever::db('product/info_spec_value')->getData(array('ids' => $key));
+
+                                $v1['sku_name'] = $spec['name'];
+                            }
+
+                            $name = $v['name'];
+                            if ($v1['sku_name']) {
+                                $name .= '-' . $v1['sku_name'];
+                            }
+
+                            $children = array
+                            (
+                                'id' => $v['id'] . '-' . $v1['id'],
+                                'name' => $name,
+                                'stock' => $v['stock'],
+                                'commission' => $v['commission'],
+                                'price' => $v1['price'] ? $v1['price'] : 0,
+                                'type' => $v['type'],
+                                'del' => 1,
+                                'end' => true,
+                            );
+                            $other_where['sku_id'] = $v1['id'];
+                            $other_sku = Dever::db($table)->find($other_where);
+
+                            $children['select'] = 2;
+                            $children['total'] = 0;
+                            if ($other_sku) {
+                                if (isset($other_sku['commission'])) {
+                                    $children['commission'] = $other_sku['commission'];
+                                }
+                                if (isset($other_sku['price'])) {
+                                    $children['price'] = $other_sku['price'];
+                                }
+                                if (isset($other_sku['min'])) {
+                                    $children['min'] = $other_sku['min'];
+                                }
+                                if (isset($other_sku['total_num'])) {
+                                    if (isset($other_sku['sell_num'])) {
+                                        $children['total'] = $other_sku['total_num'] - $other_sku['sell_num'];
+                                    } else {
+                                        $children['total'] = $other_sku['total_num'];
+                                    }
+                                    
+                                    
+                                } else {
+                                    $children['total'] = $other_sku['num'];
+                                }
+                                
+                                $children['select'] = $other_sku['state'];
+                            }
+
+                            $children['total'] = $children['total']*$total;
+                            $result[$i]['children'][] = $children;
+                        }
+                    }
+                    $i++;
+                }
+            }
+        }
+
+        return $result;
+    }
 }

+ 2 - 0
module/boot.php

@@ -0,0 +1,2 @@
+<?php
+include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '../../boot.php');

+ 480 - 0
module/role/assets/pc/html/set_seller_goods.html

@@ -0,0 +1,480 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0" />
+<meta name="author" content="siweiyong 2602812659@qq.com"/>
+<title>设置商品</title>
+<link rel="stylesheet" href="../script/lib/miniui/themes/default/miniui.css">
+<link rel="stylesheet" href="../script/lib/layui/css/layui.css" />
+<link rel="stylesheet" href="../script/lib/cashier/common.css">
+<link rel="stylesheet" href="../script/lib/layui/admin/modules/plugin/formselects/formselects.css" media="all" />
+<script src="../script/lib/jquery/jquery.min.js"></script>
+<script src="../script/lib/miniui/miniui.js"></script>
+<script src="../script/lib/layui/layui.js"></script>
+<script><{Dever::script()}></script>
+<script src="../script/dever/core.js"></script>
+</head>
+<body style="background: #F6F7F9;">
+<div class="main">
+<form class="layui-form" lay-filter="form">
+    <div class="layui-row">
+        <div class="main_left layui-col-xs12 layui-col-md3">
+            <div class="layui-row">
+                <div class="top">
+                    <i class="layui-icon layui-icon-app"></i>商品列表
+                </div>
+                <div class="left_main">
+                    <input id="key" class="mini-textbox" onenter="onKeyEnter" value="请输入商品名称" onclick="setVal('key')"/>
+                    <a class="mini-button" onclick="search()">查询</a> 
+                    <button class="layui-btn layui-btn-button" type="button" style="vertical-align: middle;margin-bottom: 2px;" onclick="addGoods()">一键添加</button>
+                    <button class="layui-btn layui-btn-button" type="button" style="vertical-align: middle;margin-bottom: 2px;" onclick="delGoods()">一键删除</button>
+                    <ul id="tree1" class="mini-tree" url="<{$url}>" showTreeIcon="true" textField="name" idField="id" expandOnLoad="true" onNodeClick="onNodeClick">
+                    </ul>
+                </div>
+            </div>
+        </div>
+        <div class="main_right layui-col-xs12 layui-col-md9">
+            <div class="layui-row">
+                <div class="top">
+                    <label>选择商品分类:</label>
+                    <div class="layui-input-inline">
+
+                        <div><select xm-select="shop_id" xm-select-skin="normal" xm-select-search="<{$search}>" xm-select-search-type="dl" xm-select-radio="" class="update_value form-control layui-input layui-select" name="shop_id" id="shop_id"  ></select></div>
+
+                    </div>
+                    <div class="layui-input-inline">
+                        <button class="layui-btn layui-btn-button" type="button" style="vertical-align: middle;margin-bottom: 2px;" onclick="setShop()">确认选择</button>
+                    </div>
+                    <div class="layui-input-inline" style="margin-left:20px">
+                        <input id="search_key" class="mini-textbox" value="请输入商品名称" onclick="setVal('search_key')"/>
+                        <a class="mini-button" onclick="searchGoods()">搜索</a> 
+                    </div>
+                </div>
+                <div class="goods_list" style="height:645px;">
+                    <table class="layui-table">
+                        <thead>
+                            <tr>
+                                <!--<th lay-data="{field:'id'}">商品编码</th>-->
+                                <th lay-data="{field:'name'}">商品名称</th>
+                                <th lay-data="{field:'price', edit: 'text'}">销售价</th>
+                                <th lay-data="{field:'commission', edit: 'text'}">销售佣金</th>
+                                <th lay-data="{field:'total', edit: 'text'}">当前库存</th>
+                                <th lay-data="{field:'number', edit: 'text'}">新增库存</th>
+                                <th lay-data="{field:'number', edit: 'text'}">起订数</th>
+                                <th lay-data="{field:'operation'}">操作</th>
+                            </tr>
+                        </thead>
+                        <tbody id="goods">
+                            
+                        </tbody>
+                    </table>
+                </div>
+                <div class="total ft16">
+                    合计:【<span> 当前总库存:<i class="totalNum">0</i> </span>】【<span> 新增总库存:<i class="totalQuantity">0</i> </span>】
+                </div>
+                <div class="towbtn">
+                    <input type="button" id="settlement" value="确认设置">
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+</form>
+</div>
+<script>
+    var form;
+    var goods = {};
+    var del_goods = {};
+    var tree = {};
+    layui.config(
+    {
+        base: '../script/lib/layui/admin/' //静态资源所在路径
+        ,version: true
+    }).extend(
+    {
+        index: 'lib/index', //主入口模块
+        formSelects: 'plugin/formselects/formselects'
+    }).use(['index', 'contlist', 'table', 'form', 'formSelects','layer'], function()
+    {
+        var table = layui.table;
+        form = layui.form; 
+        var formSelects = layui.formSelects;
+
+        mini.parse();
+        tree = mini.get("tree1");
+        for (var i in tree.data) {
+            if (typeof(tree.data[i].children) == 'object') {
+                if (tree.data[i].children.length > 0) {
+                    for (var j in tree.data[i].children) {
+                        if(tree.data[i].children[j].select == 1) {
+                            setGoods(tree.data[i].children[j]);
+                        }
+                    }
+                } else if(tree.data[i].select == 1) {
+                    setGoods(tree.data[i]);
+                }
+            }
+        }
+    });
+
+    $(function()
+    {
+        $("#settlement").click(function(){
+            var url = '<{$submit}>';
+            var shop_id = '<{$shop_id}>';
+
+            layui.layer.confirm('确定进行此项设置吗?', function() {
+                var goods_string = JSON.stringify(goods);
+
+                var data = {};
+                data = {shop_id:shop_id, goods:goods_string};
+                $.post(url, data, function(t) {
+                    t = JSON.parse(t);
+                    if (t.status == 1) {
+                        layui.layer.alert('商品设置成功', function(index){
+                          if (t.data == 'refer') {
+                                history.back();
+                            } else {
+                                location.href = t.data;
+                            }
+                          layer.close(index);
+                        });
+                    } else {
+                        layui.layer.alert(t.msg);
+                    }
+                });
+            });
+        })
+
+        $("#goods").on("keyup", ".goods_num", function() {
+            var num = parseFloat($(this).val());
+            if (num < 0) {
+                num = 0;
+                $(this).val(0);
+            }
+            var id = $(this).parent().attr('value');
+            goods[id].num = num;
+            setTotal();
+        });
+
+        $("#goods").on("keyup", ".goods_min", function() {
+            var min = parseFloat($(this).val());
+            if (min < 0) {
+                min = 1;
+                $(this).val(1);
+            }
+            var id = $(this).parent().attr('value');
+            goods[id].min = min;
+            setTotal();
+        });
+    })
+
+    function search() 
+    {
+        var key = mini.get("key").getValue();
+        if (key == "") {
+            tree.clearFilter();
+        } else {
+            key = key.toLowerCase();                
+            tree.filter(function (node) {
+                var name = node.name ? node.name.toLowerCase() : "";
+                if (name.indexOf(key) != -1) {
+                    return true;
+                }
+            });
+        }
+    }
+    function onKeyEnter(e)
+    {
+        search();
+    }
+
+    function onNodeClick()
+    {
+        var tree=mini.get("tree1");
+        node=tree.getSelectedNode();
+        if(node.end) {
+            setGoods(node);
+        }
+    }
+
+    function setVal(e)
+    {
+        mini.get(e).setValue('');
+    }
+
+    function searchGoods() 
+    {
+        var key = mini.get("search_key").getValue();
+
+        if (key == "") {
+            $(".mytr").show();
+        } else {
+            key = key.toLowerCase(); 
+            $(".mytr").show();               
+            $(".goods_name").each(function(t) {
+                var name = $(this).html();
+                name = name.toLowerCase(); 
+                if (name.indexOf(key) == -1) {
+                    $(this).parent().hide();
+                }
+            });
+        }
+    }
+
+    // 一键添加
+    function addGoods()
+    {
+        var key = mini.get("key").getValue();
+        if (key == '请输入商品名称') {
+            key = '';
+        }
+        if (key) {
+            key = key.toLowerCase();
+        }
+        for (var i in tree.data) {
+            if (typeof(tree.data[i].children) == 'object') {
+                if (tree.data[i].children.length > 0) {
+                    for (var j in tree.data[i].children) {
+                        if (key) {
+                            var name = tree.data[i].children[j].name;
+                            if (name.indexOf(key) != -1) {
+                                setGoods(tree.data[i].children[j]);
+                            }
+                        } else {
+                            setGoods(tree.data[i].children[j]);
+                        }
+                    }
+                } else {
+                    if (key) {
+                        var name = tree.data[i].name;
+                        if (name.indexOf(key) != -1) {
+                            setGoods(tree.data[i]);
+                        }
+                    } else {
+                        setGoods(tree.data[i]);
+                    }
+                }
+            }
+        }
+    }
+
+    // 一键删除
+    function delGoods()
+    {
+        if (confirm('确定删除吗?')) {
+            var key = mini.get("key").getValue();
+            if (key == '请输入商品名称') {
+                key = '';
+            }
+            if (key) {
+                key = key.toLowerCase();
+            }
+            for (var i in tree.data) {
+                if (typeof(tree.data[i].children) == 'object') {
+                    if (tree.data[i].children.length > 0) {
+                        for (var j in tree.data[i].children) {
+                            if (key) {
+                                var name = tree.data[i].children[j].name;
+                                if (name.indexOf(key) != -1) {
+                                    unsetGoods(tree.data[i].children[j]);
+                                }
+                            } else {
+                                unsetGoods(tree.data[i].children[j]);
+                            }
+                        }
+                    } else {
+                        if (key) {
+                            var name = tree.data[i].name;
+                            if (name.indexOf(key) != -1) {
+                                unsetGoods(tree.data[i]);
+                            }
+                        } else {
+                            unsetGoods(tree.data[i]);
+                        }
+                    }
+                }
+            }
+            setTotal();
+        }
+    }
+
+    function unsetGoods(node)
+    {
+        if (node.id) {
+            if (goods[node.id]) {
+                goods[node.id].del = 2;
+                goods[node.id].num = 0;
+                goods[node.id].total = 0;
+                get(node.id).remove();
+            }
+        }
+    }
+
+    function setGoods(node)
+    {
+        if (node.id) {
+            var key = node.id;
+            if (!goods[key] || (goods[key] && goods[key].del == 2)) {
+                goods[key] = node;
+                goods[key].price = parseFloat(goods[key].price);
+                goods[key].type = parseInt(goods[key].type);
+                goods[key].total = parseFloat(goods[key].total);
+                goods[key].min = goods[key].min ? parseFloat(goods[key].min) : 1;
+                goods[key].num = 0;
+                goods[key].del = 1;
+                create(node);
+                setTotal();
+            } else if(node.type < 4) {
+                add(key);
+            }
+        }
+    }
+
+    function get(key)
+    {
+        return $('#goods_' + key);
+    }
+
+    function create(node)
+    {
+        if (!get(node.id).length) {
+            var select = '';
+
+            /*
+            if (node.type < 3) {
+                select = '<select name="goods_price_template[]" class="goods_price_template" style="width: 120px;margin: 10px;" onchange="setPrice($(this), \''+node.id+'\')" lay-ignore>';
+                var l = node.price_template.length;
+                var i = 0;
+                select += '<option value="0_'+node.price+'_1" selected>默认价格模板</option>';
+                var selected = '';
+                for (i = 0; i < l; i=i+1) {
+                    var id = node.price_template[i].id;
+                    var price = node.price_template[i].price_sell;
+                    var price_num = node.price_template[i].price_num;
+                    if (node.price_template_sku && node.price_template_sku[id]) {
+                        price = node.price_template_sku[id].price_sell;
+                        price_num = node.price_template_sku[id].price_num;
+                    }
+                    if (price == 'null' || price == null || !price) {
+                        price = node.price;
+                    }
+                    selected = '';
+                    if (node.price_template_id == id) {
+                        selected = 'selected';
+                    }
+                    select += '<option value="'+id+'_'+price+'_'+price_num+'" '+selected+'>'+node.price_template[i].name+'</option>';
+                }
+                select += '</select>';
+            }*/
+
+            var addtr = '<tr class="mytr" id="goods_'+node.id+'">';
+            //addtr += '<td class="goods_id">'+node.id+'</td>';
+            addtr += '<td class="goods_name">'+node.name+'</td>';     
+            addtr += '<td class="goods_prices"><span><input type="text" value="'+node.price+'" class="mini-textbox-input"></span>'+select+'</td>'; 
+            addtr += '<td class="goods_commission"><span>'+node.commission+'</span></td>'; 
+            addtr += '<td class="goods_total">'+node.total+'</td>';       
+            if (node.type == 4) {
+                addtr += '<td>组合商品无法设置库存</td>';
+            } else {
+                addtr += '<td><div class="jiajian" value='+node.id+'><span class="jian" onclick="dec(\''+node.id+'\')">-</span><input type="text" value="'+node.num+'" class="goods_num"><span class="jia" onclick="add(\''+node.id+'\')">+</span></div></td>';
+            }   
+
+            addtr += '<td><div class="jiajian" value='+node.id+'><span class="jian" onclick="decMin(\''+node.id+'\')">-</span><input type="text" value="'+node.min+'" class="goods_min"><span class="jia" onclick="addMin(\''+node.id+'\')">+</span></div></td>';
+            
+            if (node.total <= 0) {
+                addtr += '<td><a class="delete_btn" onclick="del(\''+node.id+'\')">删除</a></td>';
+            } else {
+                addtr += '<td></td>';
+            }
+                                  
+            addtr += '</tr>';
+            $("#goods").append(addtr);
+            form.render();
+            //$('.goods_price_template').change();
+        }
+    }
+
+    function setPrice(e, id)
+    {
+        var val = e.val().split('_');
+        goods[id].price_template_id = val[0];
+        e.parent().find('span').html(val[1]);
+        //goods[id].min = val[2];
+        //e.parent().parent().find('.goods_min').val(val[2]);
+    }
+
+    function add(id)
+    {
+        goods[id].num += 1;
+        get(id).find('.goods_num').val(goods[id].num);
+        setTotal();
+    }
+    
+    function dec(id)
+    {
+        goods[id].num -= 1;
+        if (goods[id].num < 1) {
+            goods[id].num = 0;
+        }
+
+        get(id).find('.goods_num').val(goods[id].num);
+        setTotal();
+    }
+
+    function addMin(id)
+    {
+        goods[id].min += 1;
+        get(id).find('.goods_min').val(goods[id].min);
+        setTotal();
+    }
+    
+    function decMin(id)
+    {
+        goods[id].min -= 1;
+        if (goods[id].min < 1) {
+            goods[id].min = 0;
+        }
+
+        get(id).find('.goods_min').val(goods[id].min);
+        setTotal();
+    }
+
+    function del(id)
+    {
+        //if (confirm('确定删除吗?')) {
+            goods[id].del = 2;
+            goods[id].num = 0;
+            get(id).remove();
+            setTotal();
+        //}
+    }
+
+    function setTotal()
+    {
+        var cash = 0;
+        var num = 0;
+        var total = 0;
+        for (var i in goods) {
+            num += goods[i].num;
+            total += goods[i].total;
+        }
+        $(".totalQuantity").html(num);
+        $(".totalNum").html(total);
+    }
+
+    function setShop()
+    {
+        var shop_id = $('.xm-select-parent[fs_id="shop_id"] span[fsw="xm-select"]').attr('value');
+        if (!shop_id) {
+            layui.layer.alert('请选择门店');
+            return;
+        }
+        layui.layer.confirm('确定切换门店吗?切换后现在选择的商品都将清空', function() {
+            location.href = '<{$host}>&id=' + shop_id;
+        });
+    }
+</script>
+</body>
+</html>

+ 385 - 0
module/role/database/seller.php

@@ -0,0 +1,385 @@
+<?php
+
+$type = function()
+{
+	$array = array();
+	$data = Dever::load('role/seller_type-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$seller = function()
+{
+	$array = array();
+	$data = Dever::load('role/seller-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$category = function()
+{
+	$array = array();
+	$data = Dever::load('product/category-getTop');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+$sell_goods = array
+(
+	1 => '销售所有商品',
+	2 => '销售部分商品',
+);
+
+$identity = array
+(
+	1 => '个人',
+	2 => '个体户',
+	3 => '企业',
+);
+
+$stock = array
+(
+	1 => '独立库存',
+	2 => '共享库存',
+);
+
+return array
+(
+	# 表名
+	'name' => 'seller',
+	# 显示给用户看的名称
+	'lang' => '销售商',
+	# 是否显示在后台菜单
+	'order' => 10,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '销售商ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '销售商名称',
+			'default' 	=> '',
+			'desc' 		=> '销售商名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'info'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '销售商介绍',
+            'default'   => '',
+            'desc'      => '销售商介绍',
+            'match'     => 'is_string',
+            'update'    => 'textarea',
+        ),
+
+		'type_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '销售商类型',
+            'default'   => '1',
+            'desc'      => '销售商类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+            'list'		=> true,
+        ),
+
+        'stock'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '库存设置-如果商品有库存,这里设置库存是否独立或共享,独立库存就是该销售商自己使用一套库存,共享库存就是和其他销售商共享一套库存',
+            'default'   => '1',
+            'desc'      => '库存设置',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $stock,
+            'control'	=> 'stock',
+        ),
+
+        'stock_seller'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '共享销售商-选择和哪个销售商共享一套库存',
+            'default'   => '-1',
+            'desc'      => '共享销售商',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $seller,
+            'show'		=> 'stock=2'
+        ),
+
+        'sell_goods'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '销售商品范围',
+            'default'   => '1',
+            'desc'      => '销售商品范围',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $sell_goods,
+            'control'	=> 'sell_goods',
+            'list'		=> true,
+        ),
+
+        'sell_goods_category'		=> array
+		(
+			'type' 		=> 'varchar-2000',
+			'name' 		=> '销售商品分类-如不选择就是可以销售所有商品分类下的商品',
+			'default' 	=> '',
+			'desc' 		=> '销售商品分类',
+			'match' 	=> 'is_string',
+			'update'	=> 'checkbox',
+			'option'	=> $category,
+			'show'		=> 'sell_goods=2',
+		),
+
+		'truename'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '联系人姓名',
+            'default'   => '',
+            'desc'      => '请输入联系人姓名',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'tab'		=> 1,
+        ),
+
+        'mobile'      => array
+        (
+            'type'      => 'bigint-11',
+            'name'      => '联系人电话',
+            'default'   => '',
+            'desc'      => '请输入联系人电话',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'tab'		=> 1,
+        ),
+
+        'area'       => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '联系人城市',
+            'default'   => '',
+            'desc'      => '联系人城市',
+            'match'     => 'option',
+            'search'    => 'linkage',
+            'update'    => 'linkage',
+            'option'    => Dever::url('api.get?level_total=3', 'area'),
+            //'list'      => 'Dever::load("area/api.string", "{area}")',
+            'tab'		=> 1,
+        ),
+
+        'province'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '省份',
+            'default'   => '',
+            'desc'      => '省份',
+            'match'     => 'option',
+            //'update'  => 'text',
+            'tab'		=> 1,
+        ),
+
+        'city'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '城市',
+            'default'   => '',
+            'desc'      => '城市',
+            'match'     => 'option',
+            //'update'  => 'text',
+            'tab'		=> 1,
+        ),
+
+        'county'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '县区',
+            'default'   => '',
+            'desc'      => '县区',
+            'match'     => 'option',
+            //'update'  => 'text',
+            'tab'		=> 1,
+        ),
+
+        'address'       => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '联系人地址',
+            'default'   => '',
+            'desc'      => '联系人地址',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'        => true,
+            'tab'		=> 1,
+        ),
+
+        'identity'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '销售商身份',
+            'default'   => '1',
+            'desc'      => '销售商身份',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $identity,
+            'control'	=> 'identity',
+            'tab'		=> 2,
+        ),
+
+        'idcard_front'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '身份证正面-如果是个人,这里上传联系人身份证,如果是个体户或者企业,这里上传法人身份证',
+            'default'   => '',
+            'desc'      => '身份证正面',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '8',
+            'place'     => '660*660',
+            'tab'		=> 2,
+        ),
+
+        'idcard_back'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '身份证背面-如果是个人,这里上传联系人身份证,如果是个体户或者企业,这里上传法人身份证',
+            'default'   => '',
+            'desc'      => '身份证背面',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '8',
+            'place'     => '660*660',
+            'tab'		=> 2,
+        ),
+
+        'company_name'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '企业名称',
+            'default'   => '',
+            'desc'      => '企业名称',
+            'match'     => 'option',
+            'update'    => 'text',
+            'show'		=> 'identity=2,3',
+            'tab'		=> 2,
+        ),
+
+        'company_license'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '企业营业执照',
+            'default'   => '',
+            'desc'      => '企业营业执照',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '8',
+            'place'     => '660*660',
+            'show'		=> 'identity=2,3',
+            'tab'		=> 2,
+        ),
+
+        'company_license_number'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '企业营业执照号码',
+            'default'   => '',
+            'desc'      => '营业执照号码',
+            'match'     => 'option',
+            'update'    => 'text',
+            'show'		=> 'identity=2,3',
+            'tab'		=> 2,
+        ),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+		
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			//'search'	=> 'date',
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'manage' => array
+	(
+		'tab' => array('基本设置', '联系人信息', '认证信息'),
+		'button' => array
+        (
+            '类型配置' => array('list', 'seller_type&oper_parent=seller'),
+        ),
+        'list_button' => array
+        (
+        	'location' => array('配置商品', Dever::url('lib/seller.setGoods', 'role')),
+        )
+	),
+
+	'default' => array
+	(
+		'col' => 'name,type_id,state,cdate',
+		'value' => array
+		(
+			'"平台销售", 1, 1,' . DEVER_TIME,
+		),
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 157 - 0
module/role/database/seller_goods.php

@@ -0,0 +1,157 @@
+<?php
+$status = Dever::config('base')->status;
+return array
+(
+    # 表名
+    'name' => 'seller_goods',
+    # 显示给用户看的名称
+    'lang' => '销售商商品列表',
+    'order' => 10,
+    'menu'  => false,
+
+    /*
+    'end' => array
+    (
+        'insert' => 'role/lib/seller.goodsUpdate',
+        'update' => 'role/lib/seller.goodsUpdate',
+    ),
+    */
+
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'seller_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属销售商',
+            'default'   => '',
+            'desc'      => '所属销售商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => Dever::input('search_option_seller_id'),
+            'list'      => 'Dever::load("role/seller-one#name", {seller_id})',
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品名称',
+            'default'   => '',
+            'desc'      => '商品名称',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'update_search' => 'product/lib/manage.search',
+            'list'      => 'Dever::load("product/info-one#name", {goods_id})',
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '创建时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            //'insert'    => true,
+            //'search'    => 'date',
+            //'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'insert' => false,
+        'edit' => false,
+        'delete' => false,
+    ),
+
+    'request' => array
+    (
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => array('yes-t_1.seller_id'),
+                'sell_type' => array('yes-t_2.sell_type'),
+                'name' => array('yes-t_2.name', 'like'),
+                'category' => array('yes-t_2.category', 'like'),
+                'top_category_id' => array('yes-t_2.top_category_id'),
+                'second_category_id' => array('yes-t_2.second_category_id'),
+                'category_id' => array('yes-t_2.category_id'),
+                'status' => 'yes-t_2.status-1',
+                'state' => 'yes-t_2.state-1',
+                'state_1' => 'yes-t_1.state-1',
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'product/info',
+                    'type' => 'left join',
+                    'on' => array('goods_id','id'),
+                    'col' => 'goods_id',
+                ),
+            ),
+            'type' => 'all',
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
+            'col' => '*,t_2.*',
+        ),
+
+        'getDataPage' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => array('yes-t_1.seller_id'),
+                'sell_type' => array('yes-t_2.sell_type'),
+                'name' => array('yes-t_2.name', 'like'),
+                'category' => array('yes-t_2.category', 'like'),
+                'top_category_id' => array('yes-t_2.top_category_id'),
+                'second_category_id' => array('yes-t_2.second_category_id'),
+                'category_id' => array('yes-t_2.category_id'),
+                'status' => 'yes-t_2.status-1',
+                'state' => 'yes-t_2.state-1',
+                'state_1' => 'yes-t_1.state-1',
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'product/info',
+                    'type' => 'left join',
+                    'on' => array('goods_id','id'),
+                    'col' => 'goods_id',
+                ),
+            ),
+            'type' => 'all',
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => '*,t_2.*',
+        ),
+    ),
+);

+ 336 - 0
module/role/database/seller_goods_sku.php

@@ -0,0 +1,336 @@
+<?php
+
+$config = array
+(
+    # 表名
+    'name' => 'seller_goods_sku',
+    # 显示给用户看的名称
+    'lang' => '商品价格设置',
+    'order' => 200,
+    'menu' => false,
+    /*
+    'end' => array
+    (
+        'insert' => 'role/lib/seller.skuUpdate',
+        'update' => 'role/lib/seller.skuUpdate',
+    ),
+    */
+
+    # 数据结构 不同的字段放这里
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'list'        => true,
+        ),
+
+        'seller_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属销售商',
+            'default'   => '',
+            'desc'      => '所属销售商',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'search'    => 'hidden',
+            'value'     => Dever::input('search_option_seller_id'),
+            'list'      => 'Dever::load("role/seller-one#name", {seller_id})',
+        ),
+
+        'goods-info_sku-code'=> array
+        (
+            'name'      => '商品编码',
+            'default'   => '',
+            'desc'      => '商品编码',
+            'match'     => 'option',
+            # 读取另外表的关联方式
+            'sync'      => array('sku_id', 'id', 'goods_id', 'info_id', 'key'),
+            'list'      => true,
+            'list_order' => 4,
+        ),
+
+        'goods_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商品名称',
+            'default'   => '',
+            'desc'      => '商品名称',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'update_search' => 'product/lib/manage.search',
+            'list'      => 'Dever::load("product/info-one#name", {goods_id})',
+        ),
+
+        'sku_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '规格型号',
+            'default'   => '-1',
+            'desc'      => '规格型号',
+            'match'     => 'is_numeric',
+        ),
+
+        'price_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '价格模板',
+            'default'   => '0',
+            'desc'      => '价格模板',
+            'match'     => 'option',
+        ),
+
+        'total_num'        => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '总库存',
+            'default'   => '0',
+            'desc'      => '总库存',
+            'match'     => 'is_numeric',
+        ),
+
+        'sell_num'      => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '销量',
+            'default'   => '0',
+            'desc'      => '请填写销量',
+            'match'     => 'option',
+        ),
+
+        'min'       => array
+        (
+            'type'      => 'float-11,2',
+            'name'      => '起购数',
+            'default'   => '1',
+            'desc'      => '起购数',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            //'list'      => true,
+        ),
+
+        'commission'		=> array
+		(
+			'type' 		=> 'varchar-20',
+			'name' 		=> '销售商佣金',
+			'default' 	=> '0',
+			'desc' 		=> '销售商佣金',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+		),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '数据状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '发布时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            //'search'  => 'date',
+            //'list'        => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'insert' => false,
+        'edit' => false,
+        'delete' => false,
+        //'excel' => array(array('导出门店库存', '门店库存', '')),
+        'page_list_table' => 'sku',
+    ),
+
+    # request 请求接口定义
+    'request' => array
+    (
+        'getDataPage' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => array('yes-t_1.seller_id'),
+                'name' => array('yes-t_2.name', 'like'),
+                'total' => array('yes|t_1.total_num-t_1.sell_num', '<'),
+                'category' => array('yes-t_2.category', 'like'),
+                'top_category_id' => array('yes-t_2.top_category_id'),
+                'second_category_id' => array('yes-t_2.second_category_id'),
+                'category_id' => array('yes-t_2.category_id'),
+                'status' => array('yes-t_2.status', 1),
+                'state' => array('yes-t_2.state', 1),
+                'state_1' => array('yes-t_1.state', 1),
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'product/info',
+                    'type' => 'left join',
+                    'on' => array('goods_id','id'),
+                    'col' => 'goods_id',
+                ),
+            ),
+            'type' => 'all',
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
+            'page' => array(30, 'list'),
+            'col' => '*,t_2.name,t_2.pic,t_2.video,t_2.id as id,t_1.total_num-t_1.sell_num as total,t_1.sell_num',
+        ),
+
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'seller_id' => array('yes-t_1.seller_id'),
+                'name' => array('yes-t_2.name', 'like'),
+                'total' => array('yes|t_1.total_num-t_1.sell_num', '<'),
+                'category' => array('yes-t_2.category', 'like'),
+                'top_category_id' => array('yes-t_2.top_category_id'),
+                'second_category_id' => array('yes-t_2.second_category_id'),
+                'category_id' => array('yes-t_2.category_id'),
+                'status' => array('yes-t_2.status', 1),
+                'state' => array('yes-t_2.state', 1),
+                'state_1' => array('yes-t_1.state', 1),
+            ),
+            # 联表
+            'join' => array
+            (
+                array
+                (
+                    'table' => 'product/info',
+                    'type' => 'left join',
+                    'on' => array('goods_id','id'),
+                    'col' => 'goods_id',
+                ),
+            ),
+            'type' => 'all',
+            'order' => array('t_2.reorder' => 'desc', 't_2.id' => 'desc', 't_2.price' => 'asc'),
+            'col' => '*,t_2.name,t_2.pic,t_2.video,t_2.id as id,t_1.total_num-t_1.sell_num as total,t_1.sell_num',
+        ),
+
+       	# 列表
+        'getList' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'shop_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*,total_num-sell_num as total|sku_id',
+        ),
+
+        # 获取单条数据
+        'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'shop_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => '*,total_num-sell_num as total',
+        ),
+
+        # 更新售出量
+        'incSell' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'shop_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'sell_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 减少售出量
+        'decSell' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'shop_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'sell_num' => array('yes', '-='),
+            ),
+        ),
+
+        # 更新总库存
+        'updateTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'total_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 增加总库存
+        'incTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'shop_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'total_num' => array('yes', '+='),
+            ),
+        ),
+
+        # 减少总库存
+        'decTotal' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'shop_id' => 'yes',
+                'goods_id' => 'yes',
+                'sku_id' => 'yes',
+            ),
+            'set' => array
+            (
+                'total_num' => array('yes', '-='),
+            ),
+        ),
+    ),
+);
+
+return $config;

+ 95 - 0
module/role/database/seller_type.php

@@ -0,0 +1,95 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'seller_type',
+	# 显示给用户看的名称
+	'lang' => '销售商类型',
+	# 是否显示在后台菜单
+	'order' => 10,
+	'menu' => false,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '类型名称',
+			'default' 	=> '',
+			'desc' 		=> '类型名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+		
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			//'search'	=> 'date',
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'manage' => array
+	(
+		
+	),
+
+	'default' => array
+	(
+		'col' => 'name,state,cdate',
+		'value' => array
+		(
+			'"默认类型", 1,' . DEVER_TIME,
+		),
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 119 - 0
module/role/database/supplier.php

@@ -0,0 +1,119 @@
+<?php
+
+$type = function()
+{
+	$array = array();
+	$data = Dever::load('role/supplier_type-state');
+	if($data)
+	{
+		$array += $data;
+	}
+	return $array;
+};
+
+return array
+(
+	# 表名
+	'name' => 'supplier',
+	# 显示给用户看的名称
+	'lang' => '供应商',
+	# 是否显示在后台菜单
+	'order' => 11,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '供应商名称',
+			'default' 	=> '',
+			'desc' 		=> '供应商名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'type_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '供应商类型',
+            'default'   => '1',
+            'desc'      => '供应商类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+        ),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+		
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			//'search'	=> 'date',
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'manage' => array
+	(
+		'button' => array
+        (
+            '类型配置' => array('list', 'supplier_type&oper_parent=supplier'),
+        ),
+	),
+
+	'default' => array
+	(
+		'col' => 'name,type_id,state,cdate',
+		'value' => array
+		(
+			'"默认供应商", 1, 1,' . DEVER_TIME,
+		),
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 111 - 0
module/role/database/supplier_type.php

@@ -0,0 +1,111 @@
+<?php
+
+$stock = array
+(
+	1 => '是',
+	2 => '否',
+);
+return array
+(
+	# 表名
+	'name' => 'supplier_type',
+	# 显示给用户看的名称
+	'lang' => '供应商类型',
+	# 是否显示在后台菜单
+	'order' => 10,
+	'menu' => false,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'asc',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '类型名称',
+			'default' 	=> '',
+			'desc' 		=> '类型名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'stock'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '是否有库存',
+            'default'   => '1',
+            'desc'      => '是否有库存',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $stock,
+        ),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+		
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			//'search'	=> 'date',
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'manage' => array
+	(
+		
+	),
+
+	'default' => array
+	(
+		'col' => 'name,state,cdate',
+		'value' => array
+		(
+			'"默认类型", 1,' . DEVER_TIME,
+		),
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 10 - 0
module/role/index.php

@@ -0,0 +1,10 @@
+<?php
+
+define('DEVER_APP_NAME', 'role');
+define('DEVER_APP_LANG', '角色库');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 97);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-username');
+define('DEVER_GROUP_ORDER', -1);
+define('DEVER_GROUP_NAME', '电商系统');
+include(DEVER_APP_PATH . '../boot.php');

+ 263 - 0
module/role/lib/Seller.php

@@ -0,0 +1,263 @@
+<?php
+
+namespace Role\Lib;
+
+use Dever;
+
+class Seller
+{
+    public function __construct()
+    {
+        Dever::load('manage/auth.init');
+    }
+
+    # 获取门店
+    public function search_api()
+    {
+        return Dever::search('seller/info');
+    }
+
+    # 获取商品列表
+    public function goods_api()
+    {
+        $seller_id = Dever::input('seller_id', 1);
+        $where['seller_id'] = $seller_id;
+        return Dever::outDiy(Dever::load('product/lib/info')->getSetList('role/seller_goods_sku', $where));
+    }
+
+    # 配置商品
+    public function setGoods_api()
+    {
+        $data = array();
+        $data['seller_id'] = Dever::input('id', 1);
+        $data['host'] = Dever::url('lib/seller.setGoods', 'role');
+        $data['url'] = Dever::url('lib/seller.goods?seller_id=' . $data['seller_id'], 'role');
+        $data['search'] = Dever::url('lib/seller.search?yes='.$data['seller_id'].'&json=1', 'role');
+        $data['submit'] = Dever::url('lib/seller.setGoods_action_commit?json=1', 'role');
+
+        return Dever::render('set_seller_goods', $data);
+    }
+
+    # 配置商品
+    public function setGoods_action_commit_api()
+    {
+        $goods = Dever::input('goods');
+        if (!$goods) {
+            Dever::alert('请传入商品');
+        }
+        $goods = Dever::json_decode($goods);
+        $shop_id = Dever::input('shop_id');
+
+        $shop = Dever::db('shop/info')->one($shop_id);
+        $where['option_shop_id'] = $shop_id;
+        $where['set_state'] = 2;
+        Dever::db('shop/goods')->updates($where);
+
+        Dever::db('shop/goods_sku')->updates($where);
+
+        foreach ($goods as $k => $v) {
+            $temp = explode('-', $k);
+            $goods_id = $temp[0];
+            if (isset($temp[1])) {
+                $sku_id = $temp[1];
+            } else {
+                $sku_id = -1;
+            }
+            if ($v['num'] < 0) {
+            	continue;
+            }
+            if ($v['del'] == 2) {
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['shop_id'] = $shop_id;
+                $w['sku_id'] = $sku_id;
+                $sku_info = Dever::db('shop/goods_sku')->one($w);
+
+                if ($sku_info) {
+                    Dever::db('shop/goods_sku')->update(array('where_id' => $sku_info['id'], 'state' => 2));
+                }
+                unset($w['sku_id']);
+                $t = $w;
+                $t['state'] = 1;
+                $total = Dever::db('shop/goods_sku')->total($t);
+                if ($total <= 0) {
+                    $info = Dever::db('shop/goods')->one($w);
+                    if ($info) {
+                        Dever::db('shop/goods')->update(array('where_id' => $info['id'], 'state' => 2));
+                    }
+                }
+            } else {
+                $goods_info = Dever::db('goods/info')->one($goods_id);
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['shop_id'] = $shop_id;
+                $info = Dever::db('shop/goods')->one($w);
+
+                $w['status'] = $goods_info['status'];
+                $w['total_num'] = $v['num'];
+                $w['min'] = $v['min'];
+                if (!$info) {
+                    Dever::db('shop/goods')->insert($w);
+                } else {
+                    $w['total_num'] += $info['total_num'];
+                    $w['where_id'] = $info['id'];
+                    $w['state'] = 1;
+                    Dever::db('shop/goods')->update($w);
+                }
+
+                $w = array();
+                $w['goods_id'] = $goods_id;
+                $w['shop_id'] = $shop_id;
+                $w['sku_id'] = $sku_id;
+                $info = Dever::db('shop/goods_sku')->one($w);
+
+                $w['status'] = $goods_info['status'];
+                $w['total_num'] = $v['num'];
+                $w['min'] = $v['min'];
+                $w['area'] = $shop['area'];
+                $w['price_id'] = $v['price_template_id'];
+                if (!$info) {
+                    Dever::db('shop/goods_sku')->insert($w);
+                } else {
+                    $w['total_num'] += $info['total_num'];
+                    $w['where_id'] = $info['id'];
+                    $w['state'] = 1;
+                    Dever::db('shop/goods_sku')->update($w);
+                }
+            }
+        }
+        return 'refer';
+        return Dever::url('project/database/list&project=shop&&table=info&menu=shop&search_option_state=1', 'manage');
+    }
+
+    # 获取工厂列表
+    public function getFactory_api()
+    {
+        $shop_id = Dever::input('shop_id', 1);
+        $shop_factory = Dever::db('shop/factory')->getAll(array('shop_id' => $shop_id));
+        $factory = Dever::db('factory/info')->select(array('status' => 1));
+
+        $result = array();
+        foreach ($factory as $k => $v) {
+            $key = $v['area'];
+            $area = Dever::load('area/api')->string($key, '', true, '');
+            if (!isset($result[$key])) {
+                $result[$key] = array();
+                $result[$key]['id'] = $v['id'];
+                $result[$key]['name'] = $area;
+                $result[$key]['select'] = 2;
+                $result[$key]['end'] = false;
+                $result[$key]['children'] = array();
+            }
+
+            $data = array();
+            $data['id'] = $v['id'];
+            $data['name'] = $v['name'];
+            $data['area'] = $area;
+            $data['select'] = 2;
+            $data['end'] = true;
+            if (isset($shop_factory[$v['id']]) && $shop_factory[$v['id']]) {
+                $data['select'] = 1;
+            }
+            $result[$key]['children'][] = $data;
+        }
+        $result = array_values($result);
+        return Dever::outDiy($result);
+    }
+
+    # 分配工厂
+    public function factory_api()
+    {
+        $data = array();
+        $data['shop_id'] = Dever::input('id', 1);
+        $data['host'] = Dever::url('lib/set.factory', 'shop');
+        $data['url'] = Dever::url('lib/set.getFactory?shop_id=' . $data['shop_id'], 'shop');
+        $data['search'] = Dever::url('lib/set.search?yes='.$data['shop_id'].'&json=1', 'shop');
+        $data['submit'] = Dever::url('lib/set.source_commit?json=1&type=factory', 'shop');
+
+        return Dever::render('setFactory', $data);
+    }
+
+    # 获取仓库列表
+    public function getStore_api()
+    {
+        $shop_id = Dever::input('shop_id', 1);
+        $shop_store = Dever::db('shop/store')->getAll(array('shop_id' => $shop_id));
+        $store = Dever::db('store/info')->select(array('status' => 1));
+
+        $result = array();
+        foreach ($store as $k => $v) {
+            $key = $v['area'];
+            $area = Dever::load('area/api')->string($key, '', true, '');
+            if (!isset($result[$key])) {
+                $result[$key] = array();
+                $result[$key]['id'] = $v['id'];
+                $result[$key]['name'] = $area;
+                $result[$key]['select'] = 2;
+                $result[$key]['end'] = false;
+                $result[$key]['children'] = array();
+            }
+
+            $data = array();
+            $data['id'] = $v['id'];
+            $data['name'] = $v['name'];
+            $data['area'] = $area;
+            $data['select'] = 2;
+            $data['end'] = true;
+            if (isset($shop_store[$v['id']]) && $shop_store[$v['id']]) {
+                $data['select'] = 1;
+            }
+            $result[$key]['children'][] = $data;
+        }
+        $result = array_values($result);
+        return Dever::outDiy($result);
+    }
+
+    # 分配仓库
+    public function store_api()
+    {
+        $data = array();
+        $data['shop_id'] = Dever::input('id', 1);
+        $data['host'] = Dever::url('lib/set.store', 'shop');
+        $data['url'] = Dever::url('lib/set.getStore?shop_id=' . $data['shop_id'], 'shop');
+        $data['search'] = Dever::url('lib/set.search?yes='.$data['shop_id'].'&json=1', 'shop');
+        $data['submit'] = Dever::url('lib/set.source_commit?json=1&type=store', 'shop');
+
+        return Dever::render('setStore', $data);
+    }
+
+    public function source_commit_api()
+    {
+        $value = Dever::input('value');
+        if (!$value) {
+            Dever::alert('未选择');
+        }
+        $value = Dever::json_decode($value);
+        $shop_id = Dever::input('shop_id');
+        $type = Dever::input('type');
+
+        $col = $type . '_id';
+        $table = 'shop/' . $type;
+        $where['option_shop_id'] = $shop_id;
+        $where['set_state'] = 2;
+        Dever::db($table)->updates($where);
+
+        foreach ($value as $k => $v) {
+            $w = array();
+            $w[$col] = $v['id'];
+            $w['shop_id'] = $shop_id;
+            $info = Dever::db($table)->one($w);
+
+            if (!$info) {
+                Dever::db($table)->insert($w);
+            } else {
+                $w['where_id'] = $info['id'];
+                $w['state'] = 1;
+                Dever::db($table)->update($w);
+            }
+        }
+
+        return 'refer';
+        return Dever::url('project/database/list&project=shop&&table=info&menu=shop&search_option_state=1', 'manage');
+    }
+}